linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: remove unreachable code
@ 2021-05-24 10:46 Jiapeng Chong
  2021-05-24 18:48 ` Alex Deucher
  2021-05-25  6:53 ` Christian König
  0 siblings, 2 replies; 5+ messages in thread
From: Jiapeng Chong @ 2021-05-24 10:46 UTC (permalink / raw)
  To: alexander.deucher
  Cc: christian.koenig, airlied, daniel, sumit.semwal, amd-gfx,
	dri-devel, linux-kernel, linux-media, linaro-mm-sig,
	Jiapeng Chong

In the function amdgpu_uvd_cs_msg(), every branch in the switch
statement will have a return, so the code below the switch statement
will not be executed.

Eliminate the follow smatch warning:

drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c:845 amdgpu_uvd_cs_msg() warn:
ignoring unreachable code.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
index 82f0542..375b346 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
@@ -842,8 +842,6 @@ static int amdgpu_uvd_cs_msg(struct amdgpu_uvd_cs_ctx *ctx,
 		DRM_ERROR("Illegal UVD message type (%d)!\n", msg_type);
 		return -EINVAL;
 	}
-	BUG();
-	return -EINVAL;
 }
 
 /**
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/amdgpu: remove unreachable code
  2021-05-24 10:46 [PATCH] drm/amdgpu: remove unreachable code Jiapeng Chong
@ 2021-05-24 18:48 ` Alex Deucher
  2021-05-25 15:27   ` Christian König
  2021-05-25  6:53 ` Christian König
  1 sibling, 1 reply; 5+ messages in thread
From: Alex Deucher @ 2021-05-24 18:48 UTC (permalink / raw)
  To: Jiapeng Chong
  Cc: Deucher, Alexander, Dave Airlie, LKML,
	Maling list - DRI developers,
	moderated list:DMA BUFFER SHARING FRAMEWORK, amd-gfx list,
	Christian Koenig, linux-media

Applied.  Thanks!

Alex

On Mon, May 24, 2021 at 6:47 AM Jiapeng Chong
<jiapeng.chong@linux.alibaba.com> wrote:
>
> In the function amdgpu_uvd_cs_msg(), every branch in the switch
> statement will have a return, so the code below the switch statement
> will not be executed.
>
> Eliminate the follow smatch warning:
>
> drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c:845 amdgpu_uvd_cs_msg() warn:
> ignoring unreachable code.
>
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
> index 82f0542..375b346 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
> @@ -842,8 +842,6 @@ static int amdgpu_uvd_cs_msg(struct amdgpu_uvd_cs_ctx *ctx,
>                 DRM_ERROR("Illegal UVD message type (%d)!\n", msg_type);
>                 return -EINVAL;
>         }
> -       BUG();
> -       return -EINVAL;
>  }
>
>  /**
> --
> 1.8.3.1
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/amdgpu: remove unreachable code
  2021-05-24 10:46 [PATCH] drm/amdgpu: remove unreachable code Jiapeng Chong
  2021-05-24 18:48 ` Alex Deucher
@ 2021-05-25  6:53 ` Christian König
  1 sibling, 0 replies; 5+ messages in thread
From: Christian König @ 2021-05-25  6:53 UTC (permalink / raw)
  To: Jiapeng Chong, alexander.deucher
  Cc: airlied, daniel, sumit.semwal, amd-gfx, dri-devel, linux-kernel,
	linux-media, linaro-mm-sig

Am 24.05.21 um 12:46 schrieb Jiapeng Chong:
> In the function amdgpu_uvd_cs_msg(), every branch in the switch
> statement will have a return, so the code below the switch statement
> will not be executed.
>
> Eliminate the follow smatch warning:
>
> drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c:845 amdgpu_uvd_cs_msg() warn:
> ignoring unreachable code.

Mhm, that is a NAK. IIRC we explicitely added that code because some 
compiler versions complained that we don't return a value at the end of 
the function.

I suggest to drop the return from the default case and the BUG() instead.

Regards,
Christian.

>
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 2 --
>   1 file changed, 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
> index 82f0542..375b346 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
> @@ -842,8 +842,6 @@ static int amdgpu_uvd_cs_msg(struct amdgpu_uvd_cs_ctx *ctx,
>   		DRM_ERROR("Illegal UVD message type (%d)!\n", msg_type);
>   		return -EINVAL;
>   	}
> -	BUG();
> -	return -EINVAL;
>   }
>   
>   /**


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/amdgpu: remove unreachable code
  2021-05-24 18:48 ` Alex Deucher
@ 2021-05-25 15:27   ` Christian König
  2021-05-25 15:38     ` Alex Deucher
  0 siblings, 1 reply; 5+ messages in thread
From: Christian König @ 2021-05-25 15:27 UTC (permalink / raw)
  To: Alex Deucher, Jiapeng Chong
  Cc: Dave Airlie, LKML, amd-gfx list,
	moderated list:DMA BUFFER SHARING FRAMEWORK,
	Maling list - DRI developers, Deucher, Alexander,
	Christian Koenig, linux-media

Am 24.05.21 um 20:48 schrieb Alex Deucher:
> Applied.  Thanks!

Ok, that's unfortunate.

IIRC we added the code because of a different compiler warning.

Christian.

>
> Alex
>
> On Mon, May 24, 2021 at 6:47 AM Jiapeng Chong
> <jiapeng.chong@linux.alibaba.com> wrote:
>> In the function amdgpu_uvd_cs_msg(), every branch in the switch
>> statement will have a return, so the code below the switch statement
>> will not be executed.
>>
>> Eliminate the follow smatch warning:
>>
>> drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c:845 amdgpu_uvd_cs_msg() warn:
>> ignoring unreachable code.
>>
>> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
>> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 2 --
>>   1 file changed, 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
>> index 82f0542..375b346 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
>> @@ -842,8 +842,6 @@ static int amdgpu_uvd_cs_msg(struct amdgpu_uvd_cs_ctx *ctx,
>>                  DRM_ERROR("Illegal UVD message type (%d)!\n", msg_type);
>>                  return -EINVAL;
>>          }
>> -       BUG();
>> -       return -EINVAL;
>>   }
>>
>>   /**
>> --
>> 1.8.3.1
>>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/amdgpu: remove unreachable code
  2021-05-25 15:27   ` Christian König
@ 2021-05-25 15:38     ` Alex Deucher
  0 siblings, 0 replies; 5+ messages in thread
From: Alex Deucher @ 2021-05-25 15:38 UTC (permalink / raw)
  To: Christian König
  Cc: Jiapeng Chong, Dave Airlie, LKML, amd-gfx list,
	moderated list:DMA BUFFER SHARING FRAMEWORK,
	Maling list - DRI developers, Deucher, Alexander,
	Christian Koenig, linux-media

On Tue, May 25, 2021 at 11:27 AM Christian König
<ckoenig.leichtzumerken@gmail.com> wrote:
>
> Am 24.05.21 um 20:48 schrieb Alex Deucher:
> > Applied.  Thanks!
>
> Ok, that's unfortunate.
>
> IIRC we added the code because of a different compiler warning.
>

I can revert it.

Alex

> Christian.
>
> >
> > Alex
> >
> > On Mon, May 24, 2021 at 6:47 AM Jiapeng Chong
> > <jiapeng.chong@linux.alibaba.com> wrote:
> >> In the function amdgpu_uvd_cs_msg(), every branch in the switch
> >> statement will have a return, so the code below the switch statement
> >> will not be executed.
> >>
> >> Eliminate the follow smatch warning:
> >>
> >> drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c:845 amdgpu_uvd_cs_msg() warn:
> >> ignoring unreachable code.
> >>
> >> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> >> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> >> ---
> >>   drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 2 --
> >>   1 file changed, 2 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
> >> index 82f0542..375b346 100644
> >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
> >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
> >> @@ -842,8 +842,6 @@ static int amdgpu_uvd_cs_msg(struct amdgpu_uvd_cs_ctx *ctx,
> >>                  DRM_ERROR("Illegal UVD message type (%d)!\n", msg_type);
> >>                  return -EINVAL;
> >>          }
> >> -       BUG();
> >> -       return -EINVAL;
> >>   }
> >>
> >>   /**
> >> --
> >> 1.8.3.1
> >>
> > _______________________________________________
> > amd-gfx mailing list
> > amd-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/amd-gfx
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-05-25 15:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-24 10:46 [PATCH] drm/amdgpu: remove unreachable code Jiapeng Chong
2021-05-24 18:48 ` Alex Deucher
2021-05-25 15:27   ` Christian König
2021-05-25 15:38     ` Alex Deucher
2021-05-25  6:53 ` Christian König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).