Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1384899 > unrolled thread

[patch] iio: light: apds9960: silence uninitialized variable warning

Started byDan Carpenter <dan.carpenter@oracle.com>
First post2016-04-22 12:10 +0200
Last post2016-04-23 23:20 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [patch] iio: light: apds9960: silence uninitialized variable warning Dan Carpenter <dan.carpenter@oracle.com> - 2016-04-22 12:10 +0200
    Re: [patch] iio: light: apds9960: silence uninitialized variable  warning Jonathan Cameron <jic23@kernel.org> - 2016-04-23 23:20 +0200

#1384899 — [patch] iio: light: apds9960: silence uninitialized variable warning

FromDan Carpenter <dan.carpenter@oracle.com>
Date2016-04-22 12:10 +0200
Subject[patch] iio: light: apds9960: silence uninitialized variable warning
Message-ID<rqGca-hy-19@gated-at.bofh.it>
It causes a static checker warning if we use "buf" on the failure path
so move that inside the if statement.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/iio/light/apds9960.c b/drivers/iio/light/apds9960.c
index a6af56a..fbdd172 100644
--- a/drivers/iio/light/apds9960.c
+++ b/drivers/iio/light/apds9960.c
@@ -491,9 +491,10 @@ static int apds9960_read_raw(struct iio_dev *indio_dev,
 		case IIO_INTENSITY:
 			ret = regmap_bulk_read(data->regmap, chan->address,
 					       &buf, 2);
-			if (!ret)
+			if (!ret) {
 				ret = IIO_VAL_INT;
-			*val = le16_to_cpu(buf);
+				*val = le16_to_cpu(buf);
+			}
 			break;
 		default:
 			ret = -EINVAL;

[toc] | [next] | [standalone]


#1385726 — Re: [patch] iio: light: apds9960: silence uninitialized variable warning

FromJonathan Cameron <jic23@kernel.org>
Date2016-04-23 23:20 +0200
SubjectRe: [patch] iio: light: apds9960: silence uninitialized variable warning
Message-ID<rrd86-1ps-15@gated-at.bofh.it>
In reply to#1384899
On 22/04/16 11:04, Dan Carpenter wrote:
> It causes a static checker warning if we use "buf" on the failure path
> so move that inside the if statement.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Applied to the togreg branch of iio.git,

Thanks,

Jonathan
> 
> diff --git a/drivers/iio/light/apds9960.c b/drivers/iio/light/apds9960.c
> index a6af56a..fbdd172 100644
> --- a/drivers/iio/light/apds9960.c
> +++ b/drivers/iio/light/apds9960.c
> @@ -491,9 +491,10 @@ static int apds9960_read_raw(struct iio_dev *indio_dev,
>  		case IIO_INTENSITY:
>  			ret = regmap_bulk_read(data->regmap, chan->address,
>  					       &buf, 2);
> -			if (!ret)
> +			if (!ret) {
>  				ret = IIO_VAL_INT;
> -			*val = le16_to_cpu(buf);
> +				*val = le16_to_cpu(buf);
> +			}
>  			break;
>  		default:
>  			ret = -EINVAL;
> 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web