diff options
author | Geert Uytterhoeven <geert+renesas@glider.be> | 2021-03-17 13:14:49 +0100 |
---|---|---|
committer | Simon Horman <horms@verge.net.au> | 2021-04-02 11:56:41 +0200 |
commit | 07b272a07164b902acd7d12794f7be033ebf4525 (patch) | |
tree | 2a07259aec428f854d9df159bd7805355820ec4d | |
parent | 8519b01f584ff941706ac8b11659e78ef1c5b5f0 (diff) |
printk: Use ULL suffix for 64-bit constants
When compiling for 32-bit:
util_lib/elf_info.c: In function ‘get_desc_state’:
util_lib/elf_info.c:923:31: warning: left shift count >= width of type [-Wshift-count-overflow]
923 | #define DESC_FLAGS_MASK (3UL << DESC_FLAGS_SHIFT)
| ^~
util_lib/elf_info.c:925:25: note: in expansion of macro ‘DESC_FLAGS_MASK’
925 | #define DESC_ID_MASK (~DESC_FLAGS_MASK)
| ^~~~~~~~~~~~~~~
util_lib/elf_info.c:926:30: note: in expansion of macro ‘DESC_ID_MASK’
926 | #define DESC_ID(sv) ((sv) & DESC_ID_MASK)
| ^~~~~~~~~~~~
util_lib/elf_info.c:947:12: note: in expansion of macro ‘DESC_ID’
947 | if (id != DESC_ID(state_val))
| ^~~~~~~
util_lib/elf_info.c: In function ‘id_inc’:
util_lib/elf_info.c:923:31: warning: left shift count >= width of type [-Wshift-count-overflow]
923 | #define DESC_FLAGS_MASK (3UL << DESC_FLAGS_SHIFT)
| ^~
util_lib/elf_info.c:925:25: note: in expansion of macro ‘DESC_FLAGS_MASK’
925 | #define DESC_ID_MASK (~DESC_FLAGS_MASK)
| ^~~~~~~~~~~~~~~
util_lib/elf_info.c:981:15: note: in expansion of macro ‘DESC_ID_MASK’
981 | return (id & DESC_ID_MASK);
| ^~~~~~~~~~~~
Indeed, "unsigned long" constants are 32-bit on 32-bit platforms, and
64-bit on 64-bit platforms.
Fix this by using a "ULL" suffix instead.
Fixes: 4149df9005f2cdd2 ("printk: add support for lockless ringbuffer")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Simon Horman <horms@verge.net.au>
-rw-r--r-- | util_lib/elf_info.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/util_lib/elf_info.c b/util_lib/elf_info.c index 2f23a44..7c0a2c3 100644 --- a/util_lib/elf_info.c +++ b/util_lib/elf_info.c @@ -920,8 +920,8 @@ enum desc_state { #define DESC_SV_BITS (sizeof(uint64_t) * 8) #define DESC_FLAGS_SHIFT (DESC_SV_BITS - 2) -#define DESC_FLAGS_MASK (3UL << DESC_FLAGS_SHIFT) -#define DESC_STATE(sv) (3UL & (sv >> DESC_FLAGS_SHIFT)) +#define DESC_FLAGS_MASK (3ULL << DESC_FLAGS_SHIFT) +#define DESC_STATE(sv) (3ULL & (sv >> DESC_FLAGS_SHIFT)) #define DESC_ID_MASK (~DESC_FLAGS_MASK) #define DESC_ID(sv) ((sv) & DESC_ID_MASK) |