usb: dwc3: meson-g12a: Don't use ret uninitialized in dwc3_meson_g12a_otg_init
Subsystems (3)
PATCH 1/1 usb: dwc3: meson-g12a: Don't use ret uninitialized in dwc3_meson_g12a_otg_init
Clang warns:
../drivers/usb/dwc3/dwc3-meson-g12a.c:421:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
if (priv->otg_mode == USB_DR_MODE_OTG) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/usb/dwc3/dwc3-meson-g12a.c:455:9: note: uninitialized use
occurs here
return ret;
^~~
../drivers/usb/dwc3/dwc3-meson-g12a.c:421:2: note: remove the 'if' if
its condition is always true
if (priv->otg_mode == USB_DR_MODE_OTG) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/usb/dwc3/dwc3-meson-g12a.c:415:9: note: initialize the
variable 'ret' to silence this warning
int ret, irq;
^
= 01 warning generated.
It is not wrong, ret is only used when that if statement is true. Just directly return 0 at the end to avoid this.
---
Note: This patch is against Felipe's testing/next branch.
drivers/usb/dwc3/dwc3-meson-g12a.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/dwc3/dwc3-meson-g12a.c +1 -1
@@ -452,7 +452,7 @@ static int dwc3_meson_g12a_otg_init(struct platform_device *pdev,if (IS_ERR (priv->role_switch))dev_warn (dev,"Unable to register Role Switch\n" ); -return ret; +return 0 ; }static int dwc3_meson_g12a_probe (struct platform_device *pdev)
Signature · 1 line
2.25.0
Quoted 43 lines · Nathan Chancellor
Clang warns:
../drivers/usb/dwc3/dwc3-meson-g12a.c:421:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]if (priv->otg_mode == USB_DR_MODE_OTG) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../drivers/usb/dwc3/dwc3-meson-g12a.c:455:9: note: uninitialized use occurs here return ret; ^~~ ../drivers/usb/dwc3/dwc3-meson-g12a.c:421:2: note: remove the 'if' if its condition is always true if (priv->otg_mode == USB_DR_MODE_OTG) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../drivers/usb/dwc3/dwc3-meson-g12a.c:415:9: note: initialize the variable 'ret' to silence this warning int ret, irq; ^ = 01 warning generated.
It is not wrong, ret is only used when that if statement is true. Just directly return 0 at the end to avoid this.
Fixes 729149c53f04 ("usb: dwc3: Add Amlogic A1 DWC3 glue")Reported-by kbuild test robot <[email protected]>Signed-off-by Nathan Chancellor <[email protected]>---
Note: This patch is against Felipe's testing/next branch.
drivers/usb/dwc3/dwc3-meson-g12a.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/usb/dwc3/dwc3-meson-g12a.c +0
-0
drivers/usb/dwc3/dwc3-meson-g12a.c static int dwc3_meson_g12a_otg_init(struct platform_device *pdev, · line 458
Quoted 8 lines
drivers/usb/dwc3/dwc3-meson-g12a.c +1
-1@@ -452,7 +452,7 @@ static int dwc3_meson_g12a_otg_init(struct platform_device *pdev,if (IS_ERR (priv->role_switch))dev_warn (dev,"Unable to register Role Switch\n" ); -return ret; +return 0 ; }static int dwc3_meson_g12a_probe (struct platform_device *pdev)
This patch was applied to khilman/linux-amlogic.git (refs/heads/for-next).
Hello:
This patch was applied to khilman/linux-amlogic.git (refs/heads/for-next).
Quoted 20 lines · On Mon, 10 Feb 2020 15:58:17 -0700 you wrote:
Clang warns:
../drivers/usb/dwc3/dwc3-meson-g12a.c:421:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]if (priv->otg_mode == USB_DR_MODE_OTG) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../drivers/usb/dwc3/dwc3-meson-g12a.c:455:9: note: uninitialized use occurs here return ret; ^~~ ../drivers/usb/dwc3/dwc3-meson-g12a.c:421:2: note: remove the 'if' if its condition is always true if (priv->otg_mode == USB_DR_MODE_OTG) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../drivers/usb/dwc3/dwc3-meson-g12a.c:415:9: note: initialize the variable 'ret' to silence this warning int ret, irq; ^ = 0
Quoted 3 lines
1 warning generated.
[...]
Here is a summary with links:
- usb: dwc3: meson-g12a: Don't use ret uninitialized in dwc3_meson_g12a_otg_init
https://git.kernel.org/khilman/linux-amlogic/c/238d760216541d345ee930e76c781f5cd1d22fba
You are awesome, thank you!
Signature · 7 lines
Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/pwbot _______________________________________________ linux-amlogic mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-amlogic