Blame SOURCES/kexec-tools-2.0.20-3-printk-Use-zu-to-format-size_t.patch

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