BIT_MASK(32) generate warning on 32 bits processor #42163
Labels
area: API
Changes to public APIs
bug
The issue is a bug, or the PR is fixing a bug
priority: low
Low impact/importance bug
Describe the bug
On ARM 32 bits when using BIT_MASK(32) macro, it generates this warning
/home/julien/src/zephyr/zephyr/include/sys/util_macro.h:44:22: warning: left shift count >= width of type [-Wshift-count-overflow]
44 | #define BIT(n) (1UL << (n))
| ^~
/home/julien/src/zephyr/zephyr/include/sys/util_macro.h:68:22: note: in expansion of macro 'BIT'
68 | #define BIT_MASK(n) (BIT(n) - 1UL)
| ^~~
/home/julien/src/zephyr/zephyr/drivers/interrupt_controller/intc_gicv3.c:418:15: note: in expansion of macro 'BIT_MASK'
418 | sys_write32(BIT_MASK(GIC_NUM_INTR_PER_REG),
From what I understand to have a 32bits mask, we set the 33th bit and then do -1, which result in
0xFFFFFFFF as expected however it's not possible to the the 33th bits on a 32 bit type.
Should we modify BIT_MASK definition in
#define BIT_MASK(n) (BIT64(n) - 1UL) ?
The text was updated successfully, but these errors were encountered: