gitlab.arm.com will be in the maintainance mode on Wednesday June 29th 01:00 - 10:00 (UTC+1). Repositories is read only during the maintainance.

Commit d26193a0 authored by Roman Bolshakov's avatar Roman Bolshakov Committed by Paolo Bonzini
Browse files

lib: x86: Use portable format macros for uint32_t



Compilation of the files fails on ARCH=i386 with i686-elf gcc because
they use "%x" or "%d" format specifier that does not match the actual
size of uint32_t:

x86/s3.c: In function ‘main’:
x86/s3.c:53:35: error: format ‘%x’ expects argument of type ‘unsigned int’, but argument 2 has type ‘u32’ {aka ‘long unsigned int’}
[-Werror=format=]
   53 |  printf("PM1a event registers at %x\n", fadt->pm1a_evt_blk);
      |                                  ~^     ~~~~~~~~~~~~~~~~~~
      |                                   |         |
      |                                   |         u32 {aka long unsigned int}
      |                                   unsigned int
      |                                  %lx

Use PRIx32 instead of "x" and PRId32 instead of "d" to take into account
u32_long case.

Cc: Alex Bennée <alex.bennee@linaro.org>
Cc: Andrew Jones <drjones@redhat.com>
Cc: Cameron Esfahani <dirty@apple.com>
Signed-off-by: default avatarRoman Bolshakov <r.bolshakov@yadro.com>
Message-Id: <20200901085056.33391-6-r.bolshakov@yadro.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent a991ed2f
......@@ -248,7 +248,7 @@ void pci_bar_print(struct pci_dev *dev, int bar_num)
printf("BAR#%d,%d [%" PRIx64 "-%" PRIx64 " ",
bar_num, bar_num + 1, start, end);
} else {
printf("BAR#%d [%02x-%02x ",
printf("BAR#%d [%02" PRIx32 "-%02" PRIx32 " ",
bar_num, (uint32_t)start, (uint32_t)end);
}
......
......@@ -78,7 +78,7 @@ static void pf_isr(struct ex_regs *r)
phys = 0;
break;
default:
report(false, "unexpected async pf reason %d", reason);
report(false, "unexpected async pf reason %" PRId32, reason);
break;
}
}
......
......@@ -89,7 +89,8 @@ static void test_msr_rw(int msr_index, unsigned long long input, unsigned long l
wrmsr(msr_index, input);
r = rdmsr(msr_index);
if (expected != r) {
printf("testing %s: output = %#x:%#x expected = %#x:%#x\n", sptr,
printf("testing %s: output = %#" PRIx32 ":%#" PRIx32
" expected = %#" PRIx32 ":%#" PRIx32 "\n", sptr,
(u32)(r >> 32), (u32)r, (u32)(expected >> 32), (u32)expected);
}
report(expected == r, "%s", sptr);
......
......@@ -50,7 +50,7 @@ int main(int argc, char **argv)
*resume_vec++ = *addr;
printf("copy resume code from %p\n", &resume_start);
printf("PM1a event registers at %x\n", fadt->pm1a_evt_blk);
printf("PM1a event registers at %" PRIx32 "\n", fadt->pm1a_evt_blk);
outw(0x400, fadt->pm1a_evt_blk + 2);
/* Setup RTC alarm to wake up on the next second. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment