iio: accel: bma400: Fix smatch warning based on use of unintialized value.
Subsystems (2)
Jonathan Cameron
maintainerPATCH 1/1 iio: accel: bma400: Fix smatch warning based on use of unintialized value.
From: Jonathan Cameron <[email protected]>
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'.
--- drivers/iio/accel/bma400_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/accel/bma400_core.c +2 -1
@@ -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 :
Signature · 1 line
2.37.2
Hi Jonathan,
Thank you for sending this patch.
If you need a tag for this fix.
double tap events")
Thank you
Jagath
Quoted 36 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
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:1287bma400_tap_event_en()
error: uninitialized symbol 'field_value'.Reported-by Dan Carpenter <[email protected]>Cc Jagath Jog J <[email protected]>Cc Alexander Potapenko <[email protected]>Signed-off-by Jonathan Cameron <[email protected]>--- drivers/iio/accel/bma400_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/iio/accel/bma400_core.c +2
-2@@ -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
Jonathan Cameron
maintainerQuoted 7 lines · On Sun, 18 Sep 2022 20:05:48 +0530 Jagath Jog J <[email protected]> wrote:
Hi Jonathan,
Thank you for sending this patch.
If you need a tag for this fix.Fixes 961db2da159d ("iio: accel: bma400: Add support for single anddouble tap events")
Good point. I'm careful about fixes tags to stuff still not upstream because they tend to be a little unstable. This should be fine. I'll see if it's valid when I rebase the tree (hopefully in a few days time).
Also helpful if you give an Acked-by!
Thanks,
Jonathan
Quoted 41 lines
Thank you
JagathQuoted 36 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
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:1287bma400_tap_event_en()
error: uninitialized symbol 'field_value'.Reported-by Dan Carpenter <[email protected]>Cc Jagath Jog J <[email protected]>Cc Alexander Potapenko <[email protected]>Signed-off-by Jonathan Cameron <[email protected]>--- drivers/iio/accel/bma400_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/iio/accel/bma400_core.c +2
-2@@ -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
Quoted 10 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
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:1287bma400_tap_event_en()
error: uninitialized symbol 'field_value'.
Quoted 26 lines
Reported-by Dan Carpenter <[email protected]>Cc Jagath Jog J <[email protected]>Cc Alexander Potapenko <[email protected]>Signed-off-by Jonathan Cameron <[email protected]>--- drivers/iio/accel/bma400_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/iio/accel/bma400_core.c +2
-2@@ -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
Quoted 8 lines · Jonathan Cameron
Quoted 5 lines · On Sun, 18 Sep 2022 20:05:48 +0530 Jagath Jog J <[email protected]> wrote:
Hi Jonathan,
Thank you for sending this patch.
If you need a tag for this fix.
Quoted 6 lines
Quoted 2 lines
Fixes 961db2da159d ("iio: accel: bma400: Add support for single anddouble tap events")
Good point. I'm careful about fixes tags to stuff still not upstream because they tend to be a little unstable. This should be fine. I'll see if it's valid when I rebase the tree (hopefully in a few days time).
If you forget to update the tags after a rebase then Stephen Rothwell will let you know. It's best to not make Stephen's job more difficult, but it's some comfort to know that mistakes will get caught.
regards,
dan carpenter
Jonathan Cameron
maintainerQuoted 16 lines · On Mon, 19 Sep 2022 09:10:52 +0300 Dan Carpenter <[email protected]>…
Quoted 8 lines · Jonathan Cameron
Quoted 5 lines · On Sun, 18 Sep 2022 20:05:48 +0530 Jagath Jog J <[email protected]> wrote:
Hi Jonathan,
Thank you for sending this patch.
If you need a tag for this fix.Quoted 6 lines
Quoted 2 lines
Fixes 961db2da159d ("iio: accel: bma400: Add support for single anddouble tap events")
Good point. I'm careful about fixes tags to stuff still not upstream because they tend to be a little unstable. This should be fine. I'll see if it's valid when I rebase the tree (hopefully in a few days time).
Quoted 7 lines
If you forget to update the tags after a rebase then Stephen Rothwell will let you know. It's best to not make Stephen's job more difficult, but it's some comfort to know that mistakes will get caught.
regards,
dan carpenter
Hi Dan,
Having messed this up and caused Stephen pointless work several times I now have scripting (thanks to Greg KH's scripts and some local modes to make sure the tag is in the upstream of the fix) to check this but some how I still mess it up from time to time :(
Jonathan
Jonathan Cameron
maintainerQuoted 8 lines · On Sun, 18 Sep 2022 23:50:44 +0530 Jagath Jog J <[email protected]> wrote:
Quoted 7 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
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.
Quoted 5 lines
Quoted 3 lines
Smatch warning:
drivers/iio/accel/bma400_core.c:1287bma400_tap_event_en()
error: uninitialized symbol 'field_value'.Acked-by Jagath Jog J <[email protected]>
Applied to the togreg branch of iio.git and pushed out as testing for all the normal reasons.
Thanks,
Jonathan
Quoted 27 lines
Quoted 27 lines
Reported-by Dan Carpenter <[email protected]>Cc Jagath Jog J <[email protected]>Cc Alexander Potapenko <[email protected]>Signed-off-by Jonathan Cameron <[email protected]>--- drivers/iio/accel/bma400_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/iio/accel/bma400_core.c +2
-2@@ -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