* [PATCH] usb: dwc3: meson-g12a: Don't use ret uninitialized in dwc3_meson_g12a_otg_init
@ 2020-02-10 22:58 Nathan Chancellor
2020-02-19 14:14 ` Neil Armstrong
0 siblings, 1 reply; 2+ messages in thread
From: Nathan Chancellor @ 2020-02-10 22:58 UTC (permalink / raw)
To: Felipe Balbi
Cc: Greg Kroah-Hartman, Kevin Hilman, Yue Wang, Hanjie Lin,
linux-usb, linux-arm-kernel, linux-amlogic, linux-kernel,
clang-built-linux, Nathan Chancellor, kbuild test robot
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
1 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 <lkp@intel.com>
Link: https://groups.google.com/d/msg/clang-built-linux/w5iBENco_m4/PPuXreAxBQAJ
Link: https://github.com/ClangBuiltLinux/linux/issues/869
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
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(-)
diff --git a/drivers/usb/dwc3/dwc3-meson-g12a.c b/drivers/usb/dwc3/dwc3-meson-g12a.c
index 70d24b98fcad..902553f39889 100644
--- a/drivers/usb/dwc3/dwc3-meson-g12a.c
+++ b/drivers/usb/dwc3/dwc3-meson-g12a.c
@@ -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)
--
2.25.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] usb: dwc3: meson-g12a: Don't use ret uninitialized in dwc3_meson_g12a_otg_init
2020-02-10 22:58 [PATCH] usb: dwc3: meson-g12a: Don't use ret uninitialized in dwc3_meson_g12a_otg_init Nathan Chancellor
@ 2020-02-19 14:14 ` Neil Armstrong
0 siblings, 0 replies; 2+ messages in thread
From: Neil Armstrong @ 2020-02-19 14:14 UTC (permalink / raw)
To: Nathan Chancellor, Felipe Balbi
Cc: Hanjie Lin, kbuild test robot, Greg Kroah-Hartman, linux-usb,
linux-kernel, Yue Wang, clang-built-linux, Kevin Hilman,
linux-amlogic, linux-arm-kernel
On 10/02/2020 23:58, Nathan Chancellor 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
> 1 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 <lkp@intel.com>
> Link: https://groups.google.com/d/msg/clang-built-linux/w5iBENco_m4/PPuXreAxBQAJ
> Link: https://github.com/ClangBuiltLinux/linux/issues/869
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
>
> 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(-)
>
> diff --git a/drivers/usb/dwc3/dwc3-meson-g12a.c b/drivers/usb/dwc3/dwc3-meson-g12a.c
> index 70d24b98fcad..902553f39889 100644
> --- a/drivers/usb/dwc3/dwc3-meson-g12a.c
> +++ b/drivers/usb/dwc3/dwc3-meson-g12a.c
> @@ -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)
>
Acked-by: Neil Armstrong <narmstrong@baylibre.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-02-19 14:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-10 22:58 [PATCH] usb: dwc3: meson-g12a: Don't use ret uninitialized in dwc3_meson_g12a_otg_init Nathan Chancellor
2020-02-19 14:14 ` Neil Armstrong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).