* [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* Re: [PATCH] iio: accel: bma400: Fix smatch warning based on use of unintialized value.
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-18 18:20 ` Jagath Jog J
1 sibling, 1 reply; 7+ messages in thread
From: Jagath Jog J @ 2022-09-18 14:35 UTC (permalink / raw)
To: Jonathan Cameron
Cc: linux-iio, Jonathan Cameron, Dan Carpenter, Alexander Potapenko
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 and
double tap events")
Thank you
Jagath
On Sat, Sep 17, 2022 at 6:44 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> 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 [flat|nested] 7+ messages in thread* Re: [PATCH] iio: accel: bma400: Fix smatch warning based on use of unintialized value.
2022-09-18 14:35 ` Jagath Jog J
@ 2022-09-18 17:45 ` Jonathan Cameron
2022-09-19 6:10 ` Dan Carpenter
0 siblings, 1 reply; 7+ messages in thread
From: Jonathan Cameron @ 2022-09-18 17:45 UTC (permalink / raw)
To: Jagath Jog J
Cc: linux-iio, Jonathan Cameron, Dan Carpenter, Alexander Potapenko
On Sun, 18 Sep 2022 20:05:48 +0530
Jagath Jog J <jagathjog1996@gmail.com> 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 and
> double 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
>
> Thank you
> Jagath
>
> On Sat, Sep 17, 2022 at 6:44 PM Jonathan Cameron <jic23@kernel.org> wrote:
> >
> > 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 [flat|nested] 7+ messages in thread* Re: [PATCH] iio: accel: bma400: Fix smatch warning based on use of unintialized value.
2022-09-18 17:45 ` Jonathan Cameron
@ 2022-09-19 6:10 ` Dan Carpenter
2022-09-19 15:41 ` Jonathan Cameron
0 siblings, 1 reply; 7+ messages in thread
From: Dan Carpenter @ 2022-09-19 6:10 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Jagath Jog J, linux-iio, Jonathan Cameron, Alexander Potapenko
On Sun, Sep 18, 2022 at 06:45:03PM +0100, Jonathan Cameron wrote:
> On Sun, 18 Sep 2022 20:05:48 +0530
> Jagath Jog J <jagathjog1996@gmail.com> 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 and
> > double 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
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] iio: accel: bma400: Fix smatch warning based on use of unintialized value.
2022-09-19 6:10 ` Dan Carpenter
@ 2022-09-19 15:41 ` Jonathan Cameron
0 siblings, 0 replies; 7+ messages in thread
From: Jonathan Cameron @ 2022-09-19 15:41 UTC (permalink / raw)
To: Dan Carpenter
Cc: Jagath Jog J, linux-iio, Jonathan Cameron, Alexander Potapenko
On Mon, 19 Sep 2022 09:10:52 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:
> On Sun, Sep 18, 2022 at 06:45:03PM +0100, Jonathan Cameron wrote:
> > On Sun, 18 Sep 2022 20:05:48 +0530
> > Jagath Jog J <jagathjog1996@gmail.com> 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 and
> > > double 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
>
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] iio: accel: bma400: Fix smatch warning based on use of unintialized value.
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 18:20 ` Jagath Jog J
2022-09-19 16:06 ` Jonathan Cameron
1 sibling, 1 reply; 7+ messages in thread
From: Jagath Jog J @ 2022-09-18 18:20 UTC (permalink / raw)
To: Jonathan Cameron
Cc: linux-iio, Jonathan Cameron, Dan Carpenter, Alexander Potapenko
On Sat, Sep 17, 2022 at 6:44 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> 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'.
Acked-by: Jagath Jog J <jagathjog1996@gmail.com>
>
> 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 [flat|nested] 7+ messages in thread* Re: [PATCH] iio: accel: bma400: Fix smatch warning based on use of unintialized value.
2022-09-18 18:20 ` Jagath Jog J
@ 2022-09-19 16:06 ` Jonathan Cameron
0 siblings, 0 replies; 7+ messages in thread
From: Jonathan Cameron @ 2022-09-19 16:06 UTC (permalink / raw)
To: Jagath Jog J
Cc: linux-iio, Jonathan Cameron, Dan Carpenter, Alexander Potapenko
On Sun, 18 Sep 2022 23:50:44 +0530
Jagath Jog J <jagathjog1996@gmail.com> wrote:
> On Sat, Sep 17, 2022 at 6:44 PM Jonathan Cameron <jic23@kernel.org> wrote:
> >
> > 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'.
>
> Acked-by: Jagath Jog J <jagathjog1996@gmail.com>
Applied to the togreg branch of iio.git and pushed out as testing
for all the normal reasons.
Thanks,
Jonathan
>
> >
> > 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 [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