Linux IIO development
 help / color / mirror / Atom feed
* [PATCH] iio: accel: bma400: Fix smatch warning based on use of unintialized value.
@ 2022-09-17 13:14 Jonathan Cameron
  2022-09-18 14:35 ` Jagath Jog J
  2022-09-18 18:20 ` Jagath Jog J
  0 siblings, 2 replies; 7+ messages in thread
From: Jonathan Cameron @ 2022-09-17 13:14 UTC (permalink / raw)
  To: linux-iio
  Cc: Jonathan Cameron, Dan Carpenter, Jagath Jog J,
	Alexander Potapenko

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Only specific bits in this value are ever used and those are initialized,
but that is complex to reason about in a checker. Hence, initialize
the value to zero and avoid the complexity.

Smatch warning:
drivers/iio/accel/bma400_core.c:1287 bma400_tap_event_en()
error: uninitialized symbol 'field_value'.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Jagath Jog J <jagathjog1996@gmail.com>
Cc: Alexander Potapenko <glider@google.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/accel/bma400_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/accel/bma400_core.c b/drivers/iio/accel/bma400_core.c
index eceb1f8d338d..ad8fce3e08cd 100644
--- a/drivers/iio/accel/bma400_core.c
+++ b/drivers/iio/accel/bma400_core.c
@@ -1184,7 +1184,8 @@ static int bma400_activity_event_en(struct bma400_data *data,
 				    enum iio_event_direction dir,
 				    int state)
 {
-	int ret, reg, msk, value, field_value;
+	int ret, reg, msk, value;
+	int field_value = 0;
 
 	switch (dir) {
 	case IIO_EV_DIR_RISING:
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-09-19 16:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-17 13:14 [PATCH] iio: accel: bma400: Fix smatch warning based on use of unintialized value Jonathan Cameron
2022-09-18 14:35 ` Jagath Jog J
2022-09-18 17:45   ` Jonathan Cameron
2022-09-19  6:10     ` Dan Carpenter
2022-09-19 15:41       ` Jonathan Cameron
2022-09-18 18:20 ` Jagath Jog J
2022-09-19 16:06   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox