2019-07-18 13:59:18

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH] [v2] iio: adc: gyroadc: fix uninitialized return code

gcc-9 complains about a blatant uninitialized variable use that
all earlier compiler versions missed:

drivers/iio/adc/rcar-gyroadc.c:510:5: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]

Return -EINVAL instead here and a few lines above it where
we accidentally return 0 on failure.

Cc: [email protected]
Fixes: 059c53b32329 ("iio: adc: Add Renesas GyroADC driver")
Signed-off-by: Arnd Bergmann <[email protected]>
---
v2: fix the second return code as well
---
drivers/iio/adc/rcar-gyroadc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/adc/rcar-gyroadc.c b/drivers/iio/adc/rcar-gyroadc.c
index 2d685730f867..c37f201294b2 100644
--- a/drivers/iio/adc/rcar-gyroadc.c
+++ b/drivers/iio/adc/rcar-gyroadc.c
@@ -382,7 +382,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev)
dev_err(dev,
"Only %i channels supported with %pOFn, but reg = <%i>.\n",
num_channels, child, reg);
- return ret;
+ return -EINVAL;
}
}

@@ -391,7 +391,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev)
dev_err(dev,
"Channel %i uses different ADC mode than the rest.\n",
reg);
- return ret;
+ return -EINVAL;
}

/* Channel is valid, grab the regulator. */
--
2.20.0


2019-07-18 14:03:40

by Wolfram Sang

[permalink] [raw]
Subject: Re: [PATCH] [v2] iio: adc: gyroadc: fix uninitialized return code

On Thu, Jul 18, 2019 at 03:57:49PM +0200, Arnd Bergmann wrote:
> gcc-9 complains about a blatant uninitialized variable use that
> all earlier compiler versions missed:
>
> drivers/iio/adc/rcar-gyroadc.c:510:5: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
>
> Return -EINVAL instead here and a few lines above it where
> we accidentally return 0 on failure.
>
> Cc: [email protected]
> Fixes: 059c53b32329 ("iio: adc: Add Renesas GyroADC driver")
> Signed-off-by: Arnd Bergmann <[email protected]>

Yes, I checked the other error paths, too, and they look proper to me.

Reviewed-by: Wolfram Sang <[email protected]>


Attachments:
(No filename) (691.00 B)
signature.asc (849.00 B)
Download all attachments

2019-07-27 21:00:47

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH] [v2] iio: adc: gyroadc: fix uninitialized return code

On Thu, 18 Jul 2019 16:02:27 +0200
Wolfram Sang <[email protected]> wrote:

> On Thu, Jul 18, 2019 at 03:57:49PM +0200, Arnd Bergmann wrote:
> > gcc-9 complains about a blatant uninitialized variable use that
> > all earlier compiler versions missed:
> >
> > drivers/iio/adc/rcar-gyroadc.c:510:5: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
> >
> > Return -EINVAL instead here and a few lines above it where
> > we accidentally return 0 on failure.
> >
> > Cc: [email protected]
> > Fixes: 059c53b32329 ("iio: adc: Add Renesas GyroADC driver")
> > Signed-off-by: Arnd Bergmann <[email protected]>
>
> Yes, I checked the other error paths, too, and they look proper to me.
>
> Reviewed-by: Wolfram Sang <[email protected]>
>

Thanks for sorting that second case as well.

Applied to the fixes-togreg branch of iio.git.

Thanks,

Jonathan