* [PATCH][V2] iio: adc: ina2xx: add in early -EINVAL returns in case statements
@ 2018-10-16 16:14 Colin King
2018-10-16 18:26 ` Stefan Brüns
0 siblings, 1 reply; 3+ messages in thread
From: Colin King @ 2018-10-16 16:14 UTC (permalink / raw)
To: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
Peter Meerwald-Stadler, Stefan Brüns, Greg Kroah-Hartman,
linux-iio
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Static analysis with CoverityScan is throwing warnings that specific
case statements are missing breaks. Rather than adding breaks, add
return -EINVAL to the specific case statements to clarify the
error return paths. Fix also saves 50 bytes.
Before:
text data bss dec hex filename
21418 4936 128 26482 6772 drivers/iio/adc/ina2xx-adc.o
After:
dec hex filename
21370 4936 128 26434 6742 drivers/iio/adc/ina2xx-adc.o
(gcc 8.2, x86-64)
Detected by CoverityScan, CID#1462408 ("Missing break in switch")
---
V2: use returns instead of break statements to keep with the
current style used in the switch statement.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/iio/adc/ina2xx-adc.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c
index d1239624187d..bdd7cba6f6b0 100644
--- a/drivers/iio/adc/ina2xx-adc.c
+++ b/drivers/iio/adc/ina2xx-adc.c
@@ -250,6 +250,7 @@ static int ina2xx_read_raw(struct iio_dev *indio_dev,
*val2 = chip->shunt_resistor_uohm;
return IIO_VAL_FRACTIONAL;
}
+ return -EINVAL;
case IIO_CHAN_INFO_HARDWAREGAIN:
switch (chan->address) {
@@ -262,6 +263,7 @@ static int ina2xx_read_raw(struct iio_dev *indio_dev,
*val = chip->range_vbus == 32 ? 1 : 2;
return IIO_VAL_INT;
}
+ return -EINVAL;
}
return -EINVAL;
--
2.19.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH][V2] iio: adc: ina2xx: add in early -EINVAL returns in case statements
2018-10-16 16:14 [PATCH][V2] iio: adc: ina2xx: add in early -EINVAL returns in case statements Colin King
@ 2018-10-16 18:26 ` Stefan Brüns
2018-10-21 14:45 ` Jonathan Cameron
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Brüns @ 2018-10-16 18:26 UTC (permalink / raw)
To: Colin King
Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
Peter Meerwald-Stadler, Greg Kroah-Hartman, linux-iio,
kernel-janitors, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1834 bytes --]
On Dienstag, 16. Oktober 2018 18:14:18 CEST Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Static analysis with CoverityScan is throwing warnings that specific
> case statements are missing breaks. Rather than adding breaks, add
> return -EINVAL to the specific case statements to clarify the
> error return paths. Fix also saves 50 bytes.
>
> Before:
> text data bss dec hex filename
> 21418 4936 128 26482 6772 drivers/iio/adc/ina2xx-adc.o
>
> After:
> dec hex filename
> 21370 4936 128 26434 6742 drivers/iio/adc/ina2xx-adc.o
>
> (gcc 8.2, x86-64)
>
> Detected by CoverityScan, CID#1462408 ("Missing break in switch")
>
> ---
>
> V2: use returns instead of break statements to keep with the
> current style used in the switch statement.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
> ---
> drivers/iio/adc/ina2xx-adc.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c
> index d1239624187d..bdd7cba6f6b0 100644
> --- a/drivers/iio/adc/ina2xx-adc.c
> +++ b/drivers/iio/adc/ina2xx-adc.c
> @@ -250,6 +250,7 @@ static int ina2xx_read_raw(struct iio_dev *indio_dev,
> *val2 = chip->shunt_resistor_uohm;
> return IIO_VAL_FRACTIONAL;
> }
> + return -EINVAL;
>
> case IIO_CHAN_INFO_HARDWAREGAIN:
> switch (chan->address) {
> @@ -262,6 +263,7 @@ static int ina2xx_read_raw(struct iio_dev *indio_dev,
> *val = chip->range_vbus == 32 ? 1 : 2;
> return IIO_VAL_INT;
> }
> + return -EINVAL;
> }
>
> return -EINVAL;
--
Stefan Brüns / Bergstraße 21 / 52062 Aachen
home: +49 241 53809034 mobile: +49 151 50412019
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH][V2] iio: adc: ina2xx: add in early -EINVAL returns in case statements
2018-10-16 18:26 ` Stefan Brüns
@ 2018-10-21 14:45 ` Jonathan Cameron
0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2018-10-21 14:45 UTC (permalink / raw)
To: Stefan Brüns
Cc: Colin King, Hartmut Knaack, Lars-Peter Clausen,
Peter Meerwald-Stadler, Greg Kroah-Hartman, linux-iio,
kernel-janitors, linux-kernel
On Tue, 16 Oct 2018 20:26:57 +0200
Stefan Brüns <stefan.bruens@rwth-aachen.de> wrote:
> On Dienstag, 16. Oktober 2018 18:14:18 CEST Colin King wrote:
> > From: Colin Ian King <colin.king@canonical.com>
> >
> > Static analysis with CoverityScan is throwing warnings that specific
> > case statements are missing breaks. Rather than adding breaks, add
> > return -EINVAL to the specific case statements to clarify the
> > error return paths. Fix also saves 50 bytes.
> >
> > Before:
> > text data bss dec hex filename
> > 21418 4936 128 26482 6772 drivers/iio/adc/ina2xx-adc.o
> >
> > After:
> > dec hex filename
> > 21370 4936 128 26434 6742 drivers/iio/adc/ina2xx-adc.o
> >
> > (gcc 8.2, x86-64)
> >
> > Detected by CoverityScan, CID#1462408 ("Missing break in switch")
> >
> > ---
> >
> > V2: use returns instead of break statements to keep with the
> > current style used in the switch statement.
> >
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
>
> Reviewed-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Thanks, and applied to the togreg branch of iio.git and pushed
out as testing for the autobuilders to play with it.
Note however that I was confused when there appeared to be no sign off
in the patch from Colin after applying. It ended up below an
additional cut line so git am dropped it.
All fixed up now.
Thanks,
Jonathan
>
> > ---
> > drivers/iio/adc/ina2xx-adc.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c
> > index d1239624187d..bdd7cba6f6b0 100644
> > --- a/drivers/iio/adc/ina2xx-adc.c
> > +++ b/drivers/iio/adc/ina2xx-adc.c
> > @@ -250,6 +250,7 @@ static int ina2xx_read_raw(struct iio_dev *indio_dev,
> > *val2 = chip->shunt_resistor_uohm;
> > return IIO_VAL_FRACTIONAL;
> > }
> > + return -EINVAL;
> >
> > case IIO_CHAN_INFO_HARDWAREGAIN:
> > switch (chan->address) {
> > @@ -262,6 +263,7 @@ static int ina2xx_read_raw(struct iio_dev *indio_dev,
> > *val = chip->range_vbus == 32 ? 1 : 2;
> > return IIO_VAL_INT;
> > }
> > + return -EINVAL;
> > }
> >
> > return -EINVAL;
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-10-21 14:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-16 16:14 [PATCH][V2] iio: adc: ina2xx: add in early -EINVAL returns in case statements Colin King
2018-10-16 18:26 ` Stefan Brüns
2018-10-21 14:45 ` Jonathan Cameron
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).