lib: x86: Use portable format macros for uint32_t
PATCH 1/1 lib: x86: Use portable format macros for uint32_t
From: Like Xu <[email protected]>
Compilation of the files fails on ARCH=i386 with i686-elf gcc on macos_i386 because they use "%d" format specifier that does not match the actual size of uint32_t:
In function 'rdpmc':lib/libcflat.h:141:24: error: format '%d' expects argument of type 'int', but argument 6 has type 'uint32_t' {aka 'long unsigned int'} [-Werror=format=]
141 | printf("%s:%d: assert failed: %s: " fmt "\n", \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~Use PRId32 instead of "d" to take into account macos_i386 case.
---
Nit, tested on macOS 13.0.1 only instead of cirrus-ci-macos-i386.
lib/x86/processor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/x86/processor.h +1 -1
@@ -457,7 +457,7 @@ static inline uint64_t rdpmc(uint32_t index)uint64_t val;int vector =rdpmc_safe (index, &val); -assert_msg (!vector,"Unexpected %s on RDPMC(%d)" , +assert_msg (!vector,"Unexpected %s on RDPMC(%" PRId32")" ,exception_mnemonic (vector), index);return val; }
Signature · 1 line
2.38.1
Quoted 12 lines · Like Xu
From: Like Xu <[email protected]>
Compilation of the files fails on ARCH=i386 with i686-elf gcc on
macos_i386because they use "%d" format specifier that does not match the actual size ofuint32_t:In function 'rdpmc':
lib/libcflat.h:141:24: error: format '%d' expects argument of type 'int', but argument 6 has type 'uint32_t' {aka 'long unsigned int'} [-Werror=format=]141 | printf("%s:%d: assert failed: %s: " fmt "\n", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 6 lines
Use PRId32 instead of "d" to take into account
macos_i386case.Reported-by Thomas Huth <[email protected]>Signed-off-by Like Xu <[email protected]>---
Nit, tested on macOS 13.0.1 only instead of cirrus-ci-macos-i386.
Thanks, this fixed the cirrus-ci job, indeed, too:
https://gitlab.com/kvm-unit-tests/kvm-unit-tests/-/jobs/3379034443
Thomas