lkml.org 
[lkml]   [2022]   [Feb]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] iio: adc: mt6360: strengthen return check of mt6360_adc_read_channel
Date
From: Tom Rix <trix@redhat.com>

Clang static analysis reports this issue
mt6360-adc.c:277:20: warning: Assigned value is
garbage or undefined
data.values[i++] = val;
^ ~~~

val is set by a successful call to m6360_adc_read_channel().
A negative return is checked but within m6360_adc_read_channel,
a non zero check is done.
Strengthen the check to non zero.

Signed-off-by: Tom Rix <trix@redhat.com>
---
drivers/iio/adc/mt6360-adc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/mt6360-adc.c b/drivers/iio/adc/mt6360-adc.c
index 07c0e67683910..9fb6dc305a392 100644
--- a/drivers/iio/adc/mt6360-adc.c
+++ b/drivers/iio/adc/mt6360-adc.c
@@ -269,7 +269,7 @@ static irqreturn_t mt6360_adc_trigger_handler(int irq, void *p)
memset(&data, 0, sizeof(data));
for_each_set_bit(bit, indio_dev->active_scan_mask, indio_dev->masklength) {
ret = mt6360_adc_read_channel(mad, bit, &val);
- if (ret < 0) {
+ if (ret) {
dev_warn(&indio_dev->dev, "Failed to get channel %d conversion val\n", bit);
goto out;
}
--
2.26.3
\
 
 \ /
  Last update: 2022-02-27 17:45    [W:0.034 / U:0.272 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site