Skip to contentSkip to conversation

iio: accel: adxl367: Fix handled initialization in adxl367_irq_handler()

PATCH Applied Nathan Chancellor 3 participants 4 messages Feb 24, 2022 – Feb 27, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: accel: adxl367: Fix handled initialization in adxl367_irq_handler()

Clang warns:

drivers/iio/accel/adxl367.c:887:2: error: variable 'handled' is uninitialized when used here [-Werror,-Wuninitialized]

          handled |= adxl367_push_event(indio_dev, status);
          ^~~~~~~
  drivers/iio/accel/adxl367.c:879:14: note: initialize the variable 'handled' to silence this warning
          bool handled;
                      ^
                       = 0

1 error generated.

This should have used '=' instead of '|='; make that change to resolve the warning.

---
 drivers/iio/accel/adxl367.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/accel/adxl367.c +1 -1
index b452d74b1d4d..350a89b61179 100644
@@ -884,7 +884,7 @@ static irqreturn_t adxl367_irq_handler(int irq, void *private)
 	if (ret)
 		return IRQ_NONE;
 
-	handled |= adxl367_push_event(indio_dev, status);
+	handled = adxl367_push_event(indio_dev, status);
 	handled |= adxl367_push_fifo_data(indio_dev, status, fifo_entries);
 
 	return handled ? IRQ_HANDLED : IRQ_NONE;

base-commit: 2be8795a609800e5071d868d459ce29232fce2c8

Signature · 1 line
2.35.1
maintainer Applied
#1 lore raw
Quoted 11 lines · On Thu, 24 Feb 2022 14:10:34 -0700 Nathan Chancellor <[email protected]> wrote:

Clang warns:

drivers/iio/accel/adxl367.c:887:2: error: variable 'handled' is uninitialized when used here [-Werror,-Wuninitialized]

          handled |= adxl367_push_event(indio_dev, status);
          ^~~~~~~
  drivers/iio/accel/adxl367.c:879:14: note: initialize the variable 'handled' to silence this warning
          bool handled;
                      ^
                       = 0

1 error generated.

Quoted 7 lines

This should have used '=' instead of '|='; make that change to resolve the warning.

Applied to the togreg branch of iio.git.
I also added a second reported-by to reflect the next patch setting in my inbox which was Colin fixing the same thing.

Thanks!

Quoted 19 lines
---
 drivers/iio/accel/adxl367.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/accel/adxl367.c +1 -1
index b452d74b1d4d..350a89b61179 100644
@@ -884,7 +884,7 @@ static irqreturn_t adxl367_irq_handler(int irq, void *private)
 	if (ret)
 		return IRQ_NONE;
 
-	handled |= adxl367_push_event(indio_dev, status);
+	handled = adxl367_push_event(indio_dev, status);
 	handled |= adxl367_push_fifo_data(indio_dev, status, fifo_entries);
 
 	return handled ? IRQ_HANDLED : IRQ_NONE;

base-commit: 2be8795a609800e5071d868d459ce29232fce2c8

#2 lore raw
In reply to Nathan Chancellor

On Thu, Feb 24, 2022 at 11:25 PM Nathan Chancellor <[email protected]> wrote:

...

Quoted 5 lines

drivers/iio/accel/adxl367.c:879:14: note: initialize the variable 'handled' to silence this warning

          bool handled;
                      ^

                       = 0

Bad advice (at minimum it should be false, but in general it might hide a real issue)

Quoted 1 line

1 error generated.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#3 lore raw
Quoted 4 lines · On Sat, 26 Feb 2022 21:49:16 +0200 Andy Shevchenko <[email protected]>…

On Thu, Feb 24, 2022 at 11:25 PM Nathan Chancellor <[email protected]> wrote:

...

Quoted 8 lines
Quoted 5 lines

drivers/iio/accel/adxl367.c:879:14: note: initialize the variable 'handled' to silence this warning

          bool handled;
                      ^  

                       = 0  

Bad advice (at minimum it should be false, but in general it might hide a real issue)

True. Thankfully Nathan did the right thing and looked for the real problem :)

Jonathan

Quoted 3 lines
Quoted 2 lines

1 error generated.