From 8519b01f584ff941706ac8b11659e78ef1c5b5f0 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Wed, 17 Mar 2021 13:14:48 +0100 Subject: kexec: Use %llu/%llx and casts to format uint64_t MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When compiling for 32-bit: kexec/kexec.c: In function ‘cmdline_add_liveupdate’: kexec/kexec.c:1192:30: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Wformat=] 1192 | sprintf(buf, " liveupdate=%luM@0x%lx", lu_sizeM, lu_start); | ~~^ ~~~~~~~~ | | | | | uint64_t {aka long long unsigned int} | long unsigned int | %llu kexec/kexec.c:1192:37: warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Wformat=] 1192 | sprintf(buf, " liveupdate=%luM@0x%lx", lu_sizeM, lu_start); | ~~^ ~~~~~~~~ | | | | | uint64_t {aka long long unsigned int} | long unsigned int | %llx Indeed, "uint64_t" is "unsigned long long" on 32-bit formats, and "unsigned long" on 64-bit formats. Fix this by casting to "unsigned long long", and formatting using "%llu" or "%llx". Fixes: b13984c6f9ec7fdd ("kexec: Introduce --load-live-update for xen") Signed-off-by: Geert Uytterhoeven Signed-off-by: Simon Horman --- kexec/kexec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kexec/kexec.c b/kexec/kexec.c index fd7c8d2b..c5a8dec1 100644 --- a/kexec/kexec.c +++ b/kexec/kexec.c @@ -1189,7 +1189,8 @@ void cmdline_add_liveupdate(char **base) xen_get_kexec_range(KEXEC_RANGE_MA_LIVEUPDATE, &lu_start, &lu_end); lu_sizeM = (lu_end - lu_start) / (1024 * 1024) + 1; - sprintf(buf, " liveupdate=%luM@0x%lx", lu_sizeM, lu_start); + sprintf(buf, " liveupdate=%lluM@0x%llx", (unsigned long long)lu_sizeM, + (unsigned long long)lu_start); len = strlen(*base) + strlen(buf) + 1; str = xmalloc(len); sprintf(str, "%s%s", *base, buf); -- cgit 1.2.3-korg