Skip to contentSkip to conversation

staging: iio: cdc/ad7746: fix missing return value

PATCH In review Arnd Bergmann 3 participants 3 messages Oct 25, 2016 – Oct 26, 2016

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

PATCH 1/1 staging: iio: cdc/ad7746: fix missing return value

As found by "gcc -Wmaybe-uninitialized", the latest change to the driver lacked an initalization for the return code in one of the added cases:

drivers/staging/iio/cdc/ad7746.c: In function ‘ad7746_read_raw’:
drivers/staging/iio/cdc/ad7746.c:655:2: error: ‘ret’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

This sets it to IIO_VAL_INT, which I think is what we want here.

Fixes 2296c0623eb7 ("staging: iio: cdc: ad7746: implement IIO_CHAN_INFO_SAMP_FREQ")
---
 drivers/staging/iio/cdc/ad7746.c | 1 +
 1 file changed, 1 insertion(+)
drivers/staging/iio/cdc/ad7746.c +1 -0
index f41251ceeacd..a5828f9aa437 100644
@@ -642,6 +642,7 @@ static int ad7746_read_raw(struct iio_dev *indio_dev,
 		case IIO_VOLTAGE:
 			*val = ad7746_vt_filter_rate_table[
 					(chip->config >> 6) & 0x3][0];
+			ret = IIO_VAL_INT;
 			break;
 		default:
 			ret = -EINVAL;
Signature · 1 line
2.9.0
maintainer
#1 lore raw
Quoted 11 lines · Arnd Bergmann

As found by "gcc -Wmaybe-uninitialized", the latest change to the driver lacked an initalization for the return code in one of the added cases:

drivers/staging/iio/cdc/ad7746.c: In function ‘ad7746_read_raw’:
drivers/staging/iio/cdc/ad7746.c:655:2: error: ‘ret’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

This sets it to IIO_VAL_INT, which I think is what we want here.

Fixes 2296c0623eb7 ("staging: iio: cdc: ad7746: implement IIO_CHAN_INFO_SAMP_FREQ")

Gah, not a good bit of reviewing from me. Should have caught that one. Thanks Arnd.

Applied to the togreg branch of iio.git - initially pushed out as testing for the autobuilders to play with it. Will probably be a little while before I send another pull to Greg (most likely the weekend)

Thanks again,

Jonathan

Quoted 17 lines
---
 drivers/staging/iio/cdc/ad7746.c | 1 +
 1 file changed, 1 insertion(+)
drivers/staging/iio/cdc/ad7746.c +1 -0
index f41251ceeacd..a5828f9aa437 100644
@@ -642,6 +642,7 @@ static int ad7746_read_raw(struct iio_dev *indio_dev,
 		case IIO_VOLTAGE:
 			*val = ad7746_vt_filter_rate_table[
 					(chip->config >> 6) & 0x3][0];
+			ret = IIO_VAL_INT;
 			break;
 		default:
 			ret = -EINVAL;
#2 lore raw
Quoted 5 lines · Jonathan Cameron
Quoted 4 lines · Arnd Bergmann

As found by "gcc -Wmaybe-uninitialized", the latest change to the driver lacked an initalization for the return code in one of the added cases:

Quoted 9 lines
Quoted 7 lines

drivers/staging/iio/cdc/ad7746.c: In function ‘ad7746_read_raw’:
drivers/staging/iio/cdc/ad7746.c:655:2: error: ‘ret’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

This sets it to IIO_VAL_INT, which I think is what we want here.

Fixes 2296c0623eb7 ("staging: iio: cdc: ad7746: implement IIO_CHAN_INFO_SAMP_FREQ")

Gah, not a good bit of reviewing from me. Should have caught that one. Thanks Arnd.

It's not your fault. My apologies. v1 of this patch is OK, I just happen to encounter a problem and had to rework the v2 on another branch resulting to this blunder.

I will be extra careful next time.

Eva

Quoted 25 lines

Applied to the togreg branch of iio.git - initially pushed out as testing for the autobuilders to play with it. Will probably be a little while before I send another pull to Greg (most likely the weekend)

Thanks again,

Jonathan

Quoted 17 lines
---
 drivers/staging/iio/cdc/ad7746.c | 1 +
 1 file changed, 1 insertion(+)
drivers/staging/iio/cdc/ad7746.c +1 -0
index f41251ceeacd..a5828f9aa437 100644
@@ -642,6 +642,7 @@ static int ad7746_read_raw(struct iio_dev *indio_dev,
 		case IIO_VOLTAGE:
 			*val = ad7746_vt_filter_rate_table[
 					(chip->config >> 6) & 0x3][0];
+			ret = IIO_VAL_INT;
 			break;
 		default:
 			ret = -EINVAL;