Re: [PATCH][V2] iio: adc: ina2xx: add in early -EINVAL returns in case statements

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Dienstag, 16. Oktober 2018 18:14:18 CEST Colin King wrote:
> From: Colin Ian King <colin.king@xxxxxxxxxxxxx>
> 
> 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@xxxxxxxxxxxxx>

Reviewed-by: Stefan Brüns <stefan.bruens@xxxxxxxxxxxxxx>

> ---
>  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: signature.asc
Description: This is a digitally signed message part.


[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux