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 3/3] printk: Use %zu to format size_t
Date: Wed, 17 Mar 2021 14:19:36 +0100 [thread overview]
Message-ID: <87h7l9zzmf.fsf@jogness.linutronix.de> (raw)
In-Reply-To: <20210317121450.2556349-4-geert+renesas@glider.be> (Geert Uytterhoeven's message of "Wed, 17 Mar 2021 13:14:50 +0100")
On 2021-03-17, Geert Uytterhoeven <geert+renesas@glider.be> wrote:
> When compiling for 32-bit:
>
> util_lib/elf_info.c: In function ‘dump_dmesg_lockless’:
> util_lib/elf_info.c:1095:39: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘size_t’ {aka ‘unsigned int’} [-Wformat=]
> 1095 | fprintf(stderr, "Failed to malloc %lu bytes for prb: %s\n",
> | ~~^
> | |
> | long unsigned int
> | %u
> 1096 | printk_ringbuffer_sz, strerror(errno));
> | ~~~~~~~~~~~~~~~~~~~~
> | |
> | size_t {aka unsigned int}
> util_lib/elf_info.c:1101:49: warning: format ‘%lu’ expects
> argument of type ‘long unsigned int’, but argument 3 has type ‘size_t’
> {aka ‘unsigned int’} [-Wformat=]
> 1101 | fprintf(stderr, "Failed to read prb of size %lu bytes: %s\n",
> | ~~^
> | |
> | long unsigned int
> | %u
> 1102 | printk_ringbuffer_sz, strerror(errno));
> | ~~~~~~~~~~~~~~~~~~~~
> | |
> | size_t {aka unsigned int}
>
> Indeed, "size_t" is "unsigned int" on 32-bit platforms, and "unsigned
> long" on 64-bit platforms.
>
> Fix this by formatting using "%zu".
>
> 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 7c0a2c345379a7ca..676926ca8c5f3766 100644
> --- a/util_lib/elf_info.c
> +++ b/util_lib/elf_info.c
> @@ -1092,13 +1092,13 @@ static void dump_dmesg_lockless(int fd, void (*handler)(char*, unsigned int))
> kaddr = read_file_pointer(fd, vaddr_to_offset(prb_vaddr));
> m.prb = calloc(1, printk_ringbuffer_sz);
> if (!m.prb) {
> - fprintf(stderr, "Failed to malloc %lu bytes for prb: %s\n",
> + fprintf(stderr, "Failed to malloc %zu bytes for prb: %s\n",
> printk_ringbuffer_sz, strerror(errno));
> exit(64);
> }
> ret = pread(fd, m.prb, printk_ringbuffer_sz, vaddr_to_offset(kaddr));
> if (ret != printk_ringbuffer_sz) {
> - fprintf(stderr, "Failed to read prb of size %lu bytes: %s\n",
> + fprintf(stderr, "Failed to read prb of size %zu bytes: %s\n",
> printk_ringbuffer_sz, strerror(errno));
> exit(65);
> }
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next prev parent reply other threads:[~2021-03-17 13:19 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
2021-03-17 12:14 ` [PATCH 3/3] printk: Use %zu to format size_t Geert Uytterhoeven
2021-03-17 13:19 ` John Ogness [this message]
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=87h7l9zzmf.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