2021-05-24 10:48:53

by Jiapeng Chong

[permalink] [raw]
Subject: [PATCH] drm/amdgpu: remove unreachable code

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 <[email protected]>
Signed-off-by: Jiapeng Chong <[email protected]>
---
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


2021-05-24 18:52:46

by Alex Deucher

[permalink] [raw]
Subject: Re: [PATCH] drm/amdgpu: remove unreachable code

Applied. Thanks!

Alex

On Mon, May 24, 2021 at 6:47 AM Jiapeng Chong
<[email protected]> 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 <[email protected]>
> Signed-off-by: Jiapeng Chong <[email protected]>
> ---
> 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
>

2021-05-25 06:55:57

by Christian König

[permalink] [raw]
Subject: Re: [PATCH] drm/amdgpu: remove unreachable code

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 <[email protected]>
> Signed-off-by: Jiapeng Chong <[email protected]>
> ---
> 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;
> }
>
> /**

2021-05-25 17:35:16

by Christian König

[permalink] [raw]
Subject: Re: [PATCH] drm/amdgpu: remove unreachable code

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
> <[email protected]> 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 <[email protected]>
>> Signed-off-by: Jiapeng Chong <[email protected]>
>> ---
>> 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
> [email protected]
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx

2021-05-25 17:37:16

by Alex Deucher

[permalink] [raw]
Subject: Re: [PATCH] drm/amdgpu: remove unreachable code

On Tue, May 25, 2021 at 11:27 AM Christian König
<[email protected]> 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
> > <[email protected]> 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 <[email protected]>
> >> Signed-off-by: Jiapeng Chong <[email protected]>
> >> ---
> >> 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
> > [email protected]
> > https://lists.freedesktop.org/mailman/listinfo/amd-gfx
>