Skip to contentSkip to conversation

iio: light: apds9960: silence uninitialized variable warning

PATCH Applied Dan Carpenter 2 participants 2 messages Apr 22, 2016 – Apr 23, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: light: apds9960: silence uninitialized variable warning

It causes a static checker warning if we use "buf" on the failure path so move that inside the if statement.

drivers/iio/light/apds9960.c +3 -2
index a6af56a..fbdd172 100644
@@ -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;
maintainer Applied
#1 lore raw
Quoted 4 lines · Dan Carpenter

It causes a static checker warning if we use "buf" on the failure path so move that inside the if statement.

Applied to the togreg branch of iio.git,

Thanks,

Jonathan

Quoted 19 lines
drivers/iio/light/apds9960.c +3 -2
index a6af56a..fbdd172 100644
@@ -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;