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