Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: John Ogness <john.ogness@linutronix.de>
To: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Simon Horman <horms@verge.net.au>, Varad Gautam <vrd@amazon.de>,
	kexec@lists.infradead.org
Subject: Re: [PATCH 2/3] printk: Use ULL suffix for 64-bit constants
Date: Wed, 17 Mar 2021 14:14:27 +0100	[thread overview]
Message-ID: <87lfalzzv0.fsf@jogness.linutronix.de> (raw)
In-Reply-To: <20210317121450.2556349-3-geert+renesas@glider.be> (Geert Uytterhoeven's message of "Wed, 17 Mar 2021 13:14:49 +0100")

On 2021-03-17, Geert Uytterhoeven <geert+renesas@glider.be> wrote:
> 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>

> ---
>  util_lib/elf_info.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/util_lib/elf_info.c b/util_lib/elf_info.c
> index 2f23a448da08ebdd..7c0a2c345379a7ca 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)

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

  reply	other threads:[~2021-03-17 13:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-17 12:14 [PATCH 0/3] Miscellaneous 32-bit fixes Geert Uytterhoeven
2021-03-17 12:14 ` [PATCH 1/3] kexec: Use %llu/%llx and casts to format uint64_t Geert Uytterhoeven
2021-03-17 12:14 ` [PATCH 2/3] printk: Use ULL suffix for 64-bit constants Geert Uytterhoeven
2021-03-17 13:14   ` John Ogness [this message]
2021-03-17 12:14 ` [PATCH 3/3] printk: Use %zu to format size_t Geert Uytterhoeven
2021-03-17 13:19   ` John Ogness
2021-04-02  9:58 ` [PATCH 0/3] Miscellaneous 32-bit fixes Simon Horman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lfalzzv0.fsf@jogness.linutronix.de \
    --to=john.ogness@linutronix.de \
    --cc=geert+renesas@glider.be \
    --cc=horms@verge.net.au \
    --cc=kexec@lists.infradead.org \
    --cc=vrd@amazon.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox