|
|
10c66c |
From 82f7de2724c42a6aecc0cff93881b3dfd09363ce Mon Sep 17 00:00:00 2001
|
|
|
10c66c |
From: Geert Uytterhoeven <geert+renesas@glider.be>
|
|
|
10c66c |
Date: Wed, 17 Mar 2021 13:14:50 +0100
|
|
|
10c66c |
Subject: [PATCH] printk: Use %zu to format size_t
|
|
|
10c66c |
MIME-Version: 1.0
|
|
|
10c66c |
Content-Type: text/plain; charset=UTF-8
|
|
|
10c66c |
Content-Transfer-Encoding: 8bit
|
|
|
10c66c |
|
|
|
10c66c |
When compiling for 32-bit:
|
|
|
10c66c |
|
|
|
10c66c |
util_lib/elf_info.c: In function ‘dump_dmesg_lockless’:
|
|
|
10c66c |
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=]
|
|
|
10c66c |
1095 | fprintf(stderr, "Failed to malloc %lu bytes for prb: %s\n",
|
|
|
10c66c |
| ~~^
|
|
|
10c66c |
| |
|
|
|
10c66c |
| long unsigned int
|
|
|
10c66c |
| %u
|
|
|
10c66c |
1096 | printk_ringbuffer_sz, strerror(errno));
|
|
|
10c66c |
| ~~~~~~~~~~~~~~~~~~~~
|
|
|
10c66c |
| |
|
|
|
10c66c |
| size_t {aka unsigned int}
|
|
|
10c66c |
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=]
|
|
|
10c66c |
1101 | fprintf(stderr, "Failed to read prb of size %lu bytes: %s\n",
|
|
|
10c66c |
| ~~^
|
|
|
10c66c |
| |
|
|
|
10c66c |
| long unsigned int
|
|
|
10c66c |
| %u
|
|
|
10c66c |
1102 | printk_ringbuffer_sz, strerror(errno));
|
|
|
10c66c |
| ~~~~~~~~~~~~~~~~~~~~
|
|
|
10c66c |
| |
|
|
|
10c66c |
| size_t {aka unsigned int}
|
|
|
10c66c |
|
|
|
10c66c |
Indeed, "size_t" is "unsigned int" on 32-bit platforms, and "unsigned
|
|
|
10c66c |
long" on 64-bit platforms.
|
|
|
10c66c |
|
|
|
10c66c |
Fix this by formatting using "%zu".
|
|
|
10c66c |
|
|
|
10c66c |
Fixes: 4149df9005f2cdd2 ("printk: add support for lockless ringbuffer")
|
|
|
10c66c |
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
|
|
|
10c66c |
Reviewed-by: John Ogness <john.ogness@linutronix.de>
|
|
|
10c66c |
Signed-off-by: Simon Horman <horms@verge.net.au>
|
|
|
10c66c |
---
|
|
|
10c66c |
util_lib/elf_info.c | 4 ++--
|
|
|
10c66c |
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
10c66c |
|
|
|
10c66c |
diff --git a/util_lib/elf_info.c b/util_lib/elf_info.c
|
|
|
10c66c |
index 7c0a2c3..676926c 100644
|
|
|
10c66c |
--- a/util_lib/elf_info.c
|
|
|
10c66c |
+++ b/util_lib/elf_info.c
|
|
|
10c66c |
@@ -1092,13 +1092,13 @@ static void dump_dmesg_lockless(int fd, void (*handler)(char*, unsigned int))
|
|
|
10c66c |
kaddr = read_file_pointer(fd, vaddr_to_offset(prb_vaddr));
|
|
|
10c66c |
m.prb = calloc(1, printk_ringbuffer_sz);
|
|
|
10c66c |
if (!m.prb) {
|
|
|
10c66c |
- fprintf(stderr, "Failed to malloc %lu bytes for prb: %s\n",
|
|
|
10c66c |
+ fprintf(stderr, "Failed to malloc %zu bytes for prb: %s\n",
|
|
|
10c66c |
printk_ringbuffer_sz, strerror(errno));
|
|
|
10c66c |
exit(64);
|
|
|
10c66c |
}
|
|
|
10c66c |
ret = pread(fd, m.prb, printk_ringbuffer_sz, vaddr_to_offset(kaddr));
|
|
|
10c66c |
if (ret != printk_ringbuffer_sz) {
|
|
|
10c66c |
- fprintf(stderr, "Failed to read prb of size %lu bytes: %s\n",
|
|
|
10c66c |
+ fprintf(stderr, "Failed to read prb of size %zu bytes: %s\n",
|
|
|
10c66c |
printk_ringbuffer_sz, strerror(errno));
|
|
|
10c66c |
exit(65);
|
|
|
10c66c |
}
|
|
|
10c66c |
--
|
|
|
10c66c |
2.31.1
|
|
|
10c66c |
|