diff options
author | Geert Uytterhoeven <geert+renesas@glider.be> | 2021-03-17 13:14:50 +0100 |
---|---|---|
committer | Simon Horman <horms@verge.net.au> | 2021-04-02 11:57:48 +0200 |
commit | 82f7de2724c42a6aecc0cff93881b3dfd09363ce (patch) | |
tree | fc2466647e480bb2154d1bb6c303ea16d25815b3 | |
parent | 07b272a07164b902acd7d12794f7be033ebf4525 (diff) |
printk: Use %zu to format size_t
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>
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 7c0a2c3..676926c 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); } |