summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeert Uytterhoeven <geert+renesas@glider.be>2021-03-17 13:14:48 +0100
committerSimon Horman <horms@verge.net.au>2021-04-02 11:56:03 +0200
commit8519b01f584ff941706ac8b11659e78ef1c5b5f0 (patch)
treea23c66aeadca36348adda480856af010a9e844d5
parent84a6ef00376cc179eb555952b08d9bc5bfcfa67a (diff)
downloadkexec-tools-8519b01f584ff941706ac8b11659e78ef1c5b5f0.tar.gz
kexec: Use %llu/%llx and casts to format uint64_t
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 <geert+renesas@glider.be> Signed-off-by: Simon Horman <horms@verge.net.au>
-rw-r--r--kexec/kexec.c3
1 files changed, 2 insertions, 1 deletions
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);