media: rzg2l-cru: Remove unnecessary shadowing of ret in rzg2l_csi2_s_stream()
Subsystems (2)
PATCH 1/1 media: rzg2l-cru: Remove unnecessary shadowing of ret in rzg2l_csi2_s_stream()
Clang warns:
drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c:445:7: error: variable 'ret' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
if (ret)
^~~
drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c:475:9: note: uninitialized use occurs here
return ret;
^~~
drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c:445:3: note: remove the 'if' if its condition is always false
if (ret)
^~~~~~~~
drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c:441:7: error: variable 'ret' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
if (ret)
^~~
drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c:475:9: note: uninitialized use occurs here
return ret;
^~~
drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c:441:3: note: remove the 'if' if its condition is always false
if (ret)
^~~~~~~~
drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c:431:9: note: initialize the variable 'ret' to silence this warning
int ret;
^
= 02 errors generated.
ret is unnecessarily shadowed, meaning the assignments to ret within the first 'if (enable)' block are only applied to the inner scope, not the outer one as intended. Remove the shadowing to fix the warnings and make everything work correctly.
--- drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c | 2 -- 1 file changed, 2 deletions(-)
drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c +0 -2
@@ -431,8 +431,6 @@ static int rzg2l_csi2_s_stream(struct v4l2_subdev *sd, int enable)int ret;if (enable) { -int ret; - ret =pm_runtime_resume_and_get (csi2->dev);if (ret)return ret;
base-commit: 6a5a4514854a637d01c50f5ea17b28f78b31ddb8
Signature · 1 line
2.38.1
Hi Nathan,
Thank you for the patch.
Quoted 53 lines
-----Original Message-----
From: Nathan Chancellor <[email protected]>
Sent: 28 November 2022 06:16
To: Mauro Carvalho Chehab <[email protected]>; Sakari Ailus <[email protected]>; Prabhakar Mahadev Lad <[email protected]>
Cc: Nick Desaulniers <[email protected]>; Tom Rix <[email protected]>; linux- [email protected]; [email protected]; [email protected]; [email protected]; Nathan Chancellor <[email protected]>
Subject: [PATCH] media: rzg2l-cru: Remove unnecessary shadowing of ret inrzg2l_csi2_s_stream()Clang warns:
drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c:445:7: error: variable 'ret' is used
uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]if (ret) ^~~ drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c:475:9: note: uninitialized use occurs here return ret; ^~~ drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c:445:3: note: remove the 'if' if its condition is always false if (ret) ^~~~~~~~ drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c:441:7: error: variable 'ret' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized] if (ret) ^~~ drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c:475:9: note: uninitialized use occurs here return ret; ^~~ drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c:441:3: note: remove the 'if' if its condition is always false if (ret) ^~~~~~~~ drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c:431:9: note: initialize the variable 'ret' to silence this warning int ret; ^ = 02 errors generated.
ret is unnecessarily shadowed, meaning the assignments to ret within the first 'if (enable)' block are only applied to the inner scope, not the outer one as intended. Remove the shadowing to fix the warnings and make everything work correctly.
Fixes 51e8415e39a9 ("media: platform: Add Renesas RZ/G2L MIPI CSI-2 receiver driver")Link:
https://jpn01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FClangBuiltLinux%2Flinux
%2Fissues%2F1764&data=05%7C01%7Cprabhakar.mahadev- lad.rj%40bp.renesas.com%7C76d2a49f939a46e8d15208dad1081ed7%7C53d82571da1947e49cb4625a166a4a2a%7C0%7C0% 7C638052130064697087%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXV CI6Mn0%3D%7C3000%7C%7C%7C&sdata=fp%2F1JCtgKY8E6qVMRlLewVLYc9WDZ%2ByNtg6t%2BGqIUvk%3D&reserved= 0
Quoted 5 lines
Signed-off-by Nathan Chancellor <[email protected]>--- drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c | 2 -- 1 file changed, 2 deletions(-)
Cheers,
Prabhakar