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 <[email protected]>
---
 kexec/kexec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kexec/kexec.c b/kexec/kexec.c
index fd7c8d2b7a7977f9..c5a8dec1f09f35ca 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);
-- 
2.25.1


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

Reply via email to