-Wmisleading-indentation

32 views
Skip to first unread message

Brendan Doherty

unread,
Feb 9, 2023, 1:38:36 PM2/9/23
to bcm2835
I have static analysis enabled on my builds that use this BCM2835 lib (v1.71). I came across a warning in my build log that indicated a misleading indentation in a couple of spots.

```
/path/to/src/utility/bcm2xxx/bcm2835.c: In function ‘bcm2835_gpio_pad’:
/path/to/src/utility/bcm2xxx/bcm2835.c:512:3: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
  512 |   if (bcm2835_pads == MAP_FAILED)
      |   ^~
/path/to/src/utility/bcm2xxx/bcm2835.c:515:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
  515 |     volatile uint32_t* paddr = bcm2835_pads + BCM2835_PADS_GPIO_0_27/4 + group;
      |     ^~~~~~~~
/path/to/src/utility/bcm2xxx/bcm2835.c: In function ‘bcm2835_gpio_set_pad’:
/path/to/src/utility/bcm2xxx/bcm2835.c:525:3: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
  525 |   if (bcm2835_pads == MAP_FAILED)
      |   ^~
/path/to/src/utility/bcm2xxx/bcm2835.c:528:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
  528 |     volatile uint32_t* paddr = bcm2835_pads + BCM2835_PADS_GPIO_0_27/4 + group;
      |     ^~~~~~~~
```

Brendan Doherty

unread,
Feb 9, 2023, 2:59:43 PM2/9/23
to bcm2835
BTW, I'm also seeing a deadstore warning:

Value stored to 'memfd' is never read C/C++ clang-analyzer-deadcode.DeadStores
bcm2835.c(2069, 5): Value stored to 'memfd' is never read
```
memfd = -1;
```

I think this is technically correct as the stored value `-1` is never used because the `memfd` variable is set on subsequent if conditions:
```
if ((memfd = open(...)) < 0)
```
Its a bit hard to tell because the indentation in `bcm2835_init()` doesn't seem continuous/uniformed.

Mike McCauley

unread,
Feb 9, 2023, 7:33:50 PM2/9/23
to bcm2835, Brendan Doherty
Thanks for reporting these issues.

They have been addressed for the next release.

Cheers.
--
Mike McCauley VK4AMM mi...@airspayce.com
Airspayce Pty Ltd 9 Bulbul Place Currumbin Waters QLD 4223 Australia
http://www.airspayce.com 5R3MRFM2+X6
Phone +61 7 5598-7474



Reply all
Reply to author
Forward
0 new messages