Skip to contentSkip to conversation

drm/amdgpu: remove unreachable code

PATCH Applied Jiapeng Chong 4 participants 5 messages May 24, 2021 – May 25, 2021

Subsystems (3)

v1 of 3 Applied Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +0 -2
index 82f0542..375b346 100644
@@ -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;
 }
 
 /**
Signature · 1 line
1.8.3.1
Applied
#1 lore raw

Applied. Thanks!

Alex

Quoted 30 lines · 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.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +0 -3
index 82f0542..375b346 100644
@@ -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;
 }
 
 /**
--
Quoted 2 lines

1.8.3.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#2 lore raw

Am 24.05.21 um 20:48 schrieb Alex Deucher:

Quoted 1 line

Applied. Thanks!

Ok, that's unfortunate.

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

Christian.

Quoted 40 lines

Alex

Quoted 29 lines · 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.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 2 --
  1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +0 -3
index 82f0542..375b346 100644
@@ -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;
  }
 
  /**
--
Quoted 2 lines

1.8.3.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#3 lore raw
Quoted 8 lines · Christian König

Am 24.05.21 um 20:48 schrieb Alex Deucher:

Quoted 1 line

Applied. Thanks!

Ok, that's unfortunate.

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

I can revert it.

Alex

Quoted 43 lines

Christian.

Quoted 40 lines

Alex

Quoted 29 lines · 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.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 2 --
  1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +0 -3
index 82f0542..375b346 100644
@@ -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;
  }
 
  /**
--
Quoted 2 lines

1.8.3.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

maintainer
#4 lore raw
In reply to Jiapeng Chong

Am 24.05.21 um 12:46 schrieb Jiapeng Chong:

Quoted 8 lines

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.

Quoted 20 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 2 --
  1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +0 -2
index 82f0542..375b346 100644
@@ -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;
  }
 
  /**