drm/amdgpu: Initialize shadow to false in gfx_v9_0_rlcg_wreg
Subsystems (2)
PATCH 1/1 drm/amdgpu: Initialize shadow to false in gfx_v9_0_rlcg_wreg
clang warns:
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:754:6: warning: variable 'shadow' is used uninitialized whenever 'if' condition is
false [-Wsometimes-uninitialized]
if (offset == grbm_cntl || offset == grbm_idx)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:757:6: note: uninitialized use
occurs here
if (shadow) {
^~~~~~
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:754:2: note: remove the 'if' if
its condition is always true
if (offset == grbm_cntl || offset == grbm_idx)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:738:13: note: initialize the
variable 'shadow' to silence this warning
bool shadow;
^
= 01 warning generated.
It is not wrong so initialize shadow to false to ensure shadow is always used initialized.
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -1
@@ -735,7 +735,7 @@ void gfx_v9_0_rlcg_wreg(struct amdgpu_device *adev, u32 offset, u32 v)static void *spare_int;static uint32_t grbm_cntl;static uint32_t grbm_idx; -bool shadow; +bool shadow = false; scratch_reg0 = adev->rmmio + (adev->reg_offset[GC_HWIP ][0 ][mmSCRATCH_REG0_BASE_IDX] + mmSCRATCH_REG0)*4 ; scratch_reg1 = adev->rmmio + (adev->reg_offset[GC_HWIP ][0 ][mmSCRATCH_REG1_BASE_IDX] + mmSCRATCH_REG1)*4 ;
Signature · 1 line
2.26.0.rc1
Quoted 21 lines · Nathan Chancellor
clang warns:
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:754:6: warning: variable 'shadow' is used uninitialized whenever 'if' condition is
false [-Wsometimes-uninitialized]if (offset == grbm_cntl || offset == grbm_idx) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:757:6: note: uninitialized use occurs here if (shadow) { ^~~~~~ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:754:2: note: remove the 'if' if its condition is always true if (offset == grbm_cntl || offset == grbm_idx) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:738:13: note: initialize the variable 'shadow' to silence this warning bool shadow; ^ = 0
Quoted 4 lines
1 warning generated.
It is not wrong so initialize shadow to false to ensure shadow is always used initialized.
Yep, thanks for the patch.
Quoted 28 lines
Fixes 2e0cc4d48b91 ("drm/amdgpu: revise RLCG access path")Signed-off-by Nathan Chancellor <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1
-2@@ -735,7 +735,7 @@ void gfx_v9_0_rlcg_wreg(struct amdgpu_device *adev, u32 offset, u32 v)static void *spare_int;static uint32_t grbm_cntl;static uint32_t grbm_idx; -bool shadow; +bool shadow = false; scratch_reg0 = adev->rmmio + (adev->reg_offset[GC_HWIP ][0 ][mmSCRATCH_REG0_BASE_IDX] + mmSCRATCH_REG0)*4 ; scratch_reg1 = adev->rmmio + (adev->reg_offset[GC_HWIP ][0 ][mmSCRATCH_REG1_BASE_IDX] + mmSCRATCH_REG1)*4 ; --2.26.0.rc1
--
You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20200318002500.52471-1-natechancellor%40gmail.com.
Signature · 2 lines
Thanks, ~Nick Desaulniers
Quoted 11 lines · Nathan Chancellor
clang warns:
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:754:6: warning: variable 'shadow' is used uninitialized whenever 'if' condition is
false [-Wsometimes-uninitialized]if (offset == grbm_cntl || offset == grbm_idx) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:757:6: note: uninitialized use occurs here if (shadow) { ^~~~~~
Wouldn't it be better to get rid of the shadow variable completely?
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -5
@@ -735,7 +735,6 @@ void gfx_v9_0_rlcg_wreg(struct amdgpu_device *adev, u32 offset, u32 v)static void *spare_int;static uint32_t grbm_cntl;static uint32_t grbm_idx; -bool shadow; scratch_reg0 = adev->rmmio + (adev->reg_offset[GC_HWIP ][0 ][mmSCRATCH_REG0_BASE_IDX] + mmSCRATCH_REG0)*4 ; scratch_reg1 = adev->rmmio + (adev->reg_offset[GC_HWIP ][0 ][mmSCRATCH_REG1_BASE_IDX] + mmSCRATCH_REG1)*4 ;
@@ -751,10 +750,7 @@ void gfx_v9_0_rlcg_wreg(struct amdgpu_device *adev, u32 offset, u32 v)return ; } -if (offset == grbm_cntl || offset == grbm_idx) - shadow = true; - -if (shadow) { +if (offset == grbm_cntl || offset == grbm_idx) {if (offset == grbm_cntl)writel (v, scratch_reg2);else if (offset == grbm_idx)
Quoted 14 lines · Joe Perches
Quoted 11 lines · Nathan Chancellor
clang warns:
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:754:6: warning: variable 'shadow' is used uninitialized whenever 'if' condition is
false [-Wsometimes-uninitialized]if (offset == grbm_cntl || offset == grbm_idx) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:757:6: note: uninitialized use occurs here if (shadow) { ^~~~~~
Quoted 1 line
Wouldn't it be better to get rid of the shadow variable completely?
Yes, much better indeed. Seems it only has one use.
Quoted 34 lines
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1
-6@@ -735,7 +735,6 @@ void gfx_v9_0_rlcg_wreg(struct amdgpu_device *adev, u32 offset, u32 v)static void *spare_int;static uint32_t grbm_cntl;static uint32_t grbm_idx; -bool shadow; scratch_reg0 = adev->rmmio + (adev->reg_offset[GC_HWIP ][0 ][mmSCRATCH_REG0_BASE_IDX] + mmSCRATCH_REG0)*4 ; scratch_reg1 = adev->rmmio + (adev->reg_offset[GC_HWIP ][0 ][mmSCRATCH_REG1_BASE_IDX] + mmSCRATCH_REG1)*4 ;@@ -751,10 +750,7 @@ void gfx_v9_0_rlcg_wreg(struct amdgpu_device *adev, u32 offset, u32 v)return ; } -if (offset == grbm_cntl || offset == grbm_idx) - shadow = true; - -if (shadow) { +if (offset == grbm_cntl || offset == grbm_idx) {if (offset == grbm_cntl)writel (v, scratch_reg2);else if (offset == grbm_idx) --You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/3a997f4ee640e607a171a19668f5f5484062116c.camel%40perches.com.
Signature · 2 lines
Thanks, ~Nick Desaulniers
PATCH v2 1/1 drm/amdgpu: Remove unnecessary variable shadow in gfx_v9_0_rlcg_wreg
In reply to Nathan Chancellorclang warns:
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:754:6: warning: variable 'shadow' is used uninitialized whenever 'if' condition is
false [-Wsometimes-uninitialized]
if (offset == grbm_cntl || offset == grbm_idx)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:757:6: note: uninitialized use
occurs here
if (shadow) {
^~~~~~
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:754:2: note: remove the 'if' if
its condition is always true
if (offset == grbm_cntl || offset == grbm_idx)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:738:13: note: initialize the
variable 'shadow' to silence this warning
bool shadow;
^
= 01 warning generated.
shadow is only assigned in one condition and used as the condition for another if statement; combine the two if statements and remove shadow to make the code cleaner and resolve this warning.
---
v1 -> v2:
* Remove shadow altogether, as suggested by Joe Perches.
* Add Nick's Reviewed-by, as I assume it still stands.
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -5
@@ -735,7 +735,6 @@ void gfx_v9_0_rlcg_wreg(struct amdgpu_device *adev, u32 offset, u32 v)static void *spare_int;static uint32_t grbm_cntl;static uint32_t grbm_idx; -bool shadow; scratch_reg0 = adev->rmmio + (adev->reg_offset[GC_HWIP ][0 ][mmSCRATCH_REG0_BASE_IDX] + mmSCRATCH_REG0)*4 ; scratch_reg1 = adev->rmmio + (adev->reg_offset[GC_HWIP ][0 ][mmSCRATCH_REG1_BASE_IDX] + mmSCRATCH_REG1)*4 ;
@@ -751,10 +750,7 @@ void gfx_v9_0_rlcg_wreg(struct amdgpu_device *adev, u32 offset, u32 v)return ; } -if (offset == grbm_cntl || offset == grbm_idx) - shadow = true; - -if (shadow) { +if (offset == grbm_cntl || offset == grbm_idx) {if (offset == grbm_cntl)writel (v, scratch_reg2);else if (offset == grbm_idx)
Signature · 1 line
2.26.0.rc1
Re: [PATCH v2] drm/amdgpu: Remove unnecessary variable shadow in gfx_v9_0_rlcg_wreg
Quoted 32 lines · Nathan Chancellor
clang warns:
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:754:6: warning: variable 'shadow' is used uninitialized whenever 'if' condition is
false [-Wsometimes-uninitialized]if (offset == grbm_cntl || offset == grbm_idx) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:757:6: note: uninitialized use occurs here if (shadow) { ^~~~~~ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:754:2: note: remove the 'if' if its condition is always true if (offset == grbm_cntl || offset == grbm_idx) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:738:13: note: initialize the variable 'shadow' to silence this warning bool shadow; ^ = 01 warning generated.
shadow is only assigned in one condition and used as the condition for another if statement; combine the two if statements and remove shadow to make the code cleaner and resolve this warning.
Fixes 2e0cc4d48b91 ("drm/amdgpu: revise RLCG access path")Suggested-by Joe Perches <[email protected]>Reviewed-by Nick Desaulniers <[email protected]>Signed-off-by Nathan Chancellor <[email protected]>
Quoted 6 lines
---
v1 -> v2:
* Remove shadow altogether, as suggested by Joe Perches.
* Add Nick's Reviewed-by, as I assume it still stands.
yep, thanks
Quoted 31 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1
-6@@ -735,7 +735,6 @@ void gfx_v9_0_rlcg_wreg(struct amdgpu_device *adev, u32 offset, u32 v)static void *spare_int;static uint32_t grbm_cntl;static uint32_t grbm_idx; -bool shadow; scratch_reg0 = adev->rmmio + (adev->reg_offset[GC_HWIP ][0 ][mmSCRATCH_REG0_BASE_IDX] + mmSCRATCH_REG0)*4 ; scratch_reg1 = adev->rmmio + (adev->reg_offset[GC_HWIP ][0 ][mmSCRATCH_REG1_BASE_IDX] + mmSCRATCH_REG1)*4 ;@@ -751,10 +750,7 @@ void gfx_v9_0_rlcg_wreg(struct amdgpu_device *adev, u32 offset, u32 v)return ; } -if (offset == grbm_cntl || offset == grbm_idx) - shadow = true; - -if (shadow) { +if (offset == grbm_cntl || offset == grbm_idx) {if (offset == grbm_cntl)writel (v, scratch_reg2);else if (offset == grbm_idx) --2.26.0.rc1
Signature · 2 lines
Thanks, ~Nick Desaulniers
Alex Deucher
AppliedRe: [PATCH v2] drm/amdgpu: Remove unnecessary variable shadow in gfx_v9_0_rlcg_wreg
Quoted 30 lines · Nick Desaulniers
Quoted 27 lines · Nathan Chancellor
clang warns:
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:754:6: warning: variable 'shadow' is used uninitialized whenever 'if' condition is
false [-Wsometimes-uninitialized]if (offset == grbm_cntl || offset == grbm_idx) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:757:6: note: uninitialized use occurs here if (shadow) { ^~~~~~ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:754:2: note: remove the 'if' if its condition is always true if (offset == grbm_cntl || offset == grbm_idx) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:738:13: note: initialize the variable 'shadow' to silence this warning bool shadow; ^ = 01 warning generated.
shadow is only assigned in one condition and used as the condition for another if statement; combine the two if statements and remove shadow to make the code cleaner and resolve this warning.
Quoted 5 lines
Quoted 5 lines
Fixes 2e0cc4d48b91 ("drm/amdgpu: revise RLCG access path")Suggested-by Joe Perches <[email protected]>Reviewed-by Nick Desaulniers <[email protected]>Signed-off-by Nathan Chancellor <[email protected]>
Applied. thanks!
Alex
Quoted 42 lines
Quoted 6 lines
---
v1 -> v2:
* Remove shadow altogether, as suggested by Joe Perches.
* Add Nick's Reviewed-by, as I assume it still stands.yep, thanks
Quoted 29 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1
-6@@ -735,7 +735,6 @@ void gfx_v9_0_rlcg_wreg(struct amdgpu_device *adev, u32 offset, u32 v)static void *spare_int;static uint32_t grbm_cntl;static uint32_t grbm_idx; -bool shadow; scratch_reg0 = adev->rmmio + (adev->reg_offset[GC_HWIP ][0 ][mmSCRATCH_REG0_BASE_IDX] + mmSCRATCH_REG0)*4 ; scratch_reg1 = adev->rmmio + (adev->reg_offset[GC_HWIP ][0 ][mmSCRATCH_REG1_BASE_IDX] + mmSCRATCH_REG1)*4 ;@@ -751,10 +750,7 @@ void gfx_v9_0_rlcg_wreg(struct amdgpu_device *adev, u32 offset, u32 v)return ; } -if (offset == grbm_cntl || offset == grbm_idx) - shadow = true; - -if (shadow) { +if (offset == grbm_cntl || offset == grbm_idx) {if (offset == grbm_cntl)writel (v, scratch_reg2);else if (offset == grbm_idx) --Quoted 2 lines
2.26.0.rc1
Quoted 7 lines
--
Thanks,
~Nick Desaulniers
_______________________________________________
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