Skip to contentSkip to conversation

iio: cdc: ad7746: Suppress false uninitialized value warning.

PATCH In review Jonathan Cameron 2 participants 3 messages Aug 30, 2022 – Sep 4, 2022

Subsystems (2)
lore
Share & tools
lore

Jonathan Cameron

author maintainer
#0 lore raw

PATCH 1/1 iio: cdc: ad7746: Suppress false uninitialized value warning.

From: Jonathan Cameron <[email protected]>

Fix warning:
drivers/iio/cdc/ad7746.c:336:14: warning: use of uninitialized value '<unknown>' [CWE-457] [-Wanalyzer-use-of-uninitialized-value] reported on linux-next. The compiler can't see into the implementation
of kstrtobool() to identify that the if (ret < 0) condition is
sufficient to detect cases where this parameter is not initialized.

---
 drivers/iio/cdc/ad7746.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/cdc/ad7746.c +1 -1
index b266f5328140..5a3863bcaac9 100644
@@ -333,7 +333,7 @@ static inline ssize_t ad7746_start_calib(struct device *dev,
 	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
 	struct ad7746_chip_info *chip = iio_priv(indio_dev);
 	int ret, timeout = 10;
-	bool doit;
+	bool doit = false;
 
 	ret = kstrtobool(buf, &doit);
 	if (ret < 0)
Signature · 1 line
2.37.2
#1 lore raw
Quoted 8 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Fix warning:
drivers/iio/cdc/ad7746.c:336:14: warning: use of uninitialized value '<unknown>' [CWE-457] [-Wanalyzer-use-of-uninitialized-value] reported on linux-next. The compiler can't see into the implementation
of kstrtobool() to identify that the if (ret < 0) condition is
sufficient to detect cases where this parameter is not initialized.

Sorry, but to me this sounds like a false positive that provokes developer to add not only unneeded, but in some cases harmful code (yes, there were cases in the history when preinitializing variable with some value made a regression).
NAK from me (but you always may overrule as a maintainer :-).

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#2 lore raw
Quoted 10 lines · On Tue, 30 Aug 2022 23:04:47 +0300 Andy Shevchenko <[email protected]>…
Quoted 8 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Fix warning:
drivers/iio/cdc/ad7746.c:336:14: warning: use of uninitialized value '<unknown>' [CWE-457] [-Wanalyzer-use-of-uninitialized-value] reported on linux-next. The compiler can't see into the implementation
of kstrtobool() to identify that the if (ret < 0) condition is
sufficient to detect cases where this parameter is not initialized.

Quoted 6 lines

Sorry, but to me this sounds like a false positive that provokes developer to add not only unneeded, but in some cases harmful code (yes, there were cases in the history when preinitializing variable with some value made a regression).
NAK from me (but you always may overrule as a maintainer :-).

I'm fine leaving it as is and exercising the delete key for any reports :)

Jonathan