All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lib: x86: Use portable format macros for uint32_t
@ 2022-11-24 12:31 Like Xu
  2022-11-25 10:33 ` Thomas Huth
  0 siblings, 1 reply; 2+ messages in thread
From: Like Xu @ 2022-11-24 12:31 UTC (permalink / raw)
  To: Thomas Huth; +Cc: Paolo Bonzini, kvm

From: Like Xu <likexu@tencent.com>

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.

Reported-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Like Xu <likexu@tencent.com>
---
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(-)

diff --git a/lib/x86/processor.h b/lib/x86/processor.h
index 7a9e8c8..3d58ef7 100644
--- a/lib/x86/processor.h
+++ b/lib/x86/processor.h
@@ -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;
 }
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] lib: x86: Use portable format macros for uint32_t
  2022-11-24 12:31 [PATCH] lib: x86: Use portable format macros for uint32_t Like Xu
@ 2022-11-25 10:33 ` Thomas Huth
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Huth @ 2022-11-25 10:33 UTC (permalink / raw)
  To: Like Xu; +Cc: Paolo Bonzini, kvm

On 24/11/2022 13.31, Like Xu wrote:
> From: Like Xu <likexu@tencent.com>
> 
> 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.
> 
> Reported-by: Thomas Huth <thuth@redhat.com>
> Signed-off-by: Like Xu <likexu@tencent.com>
> ---
> 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



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-25 10:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-24 12:31 [PATCH] lib: x86: Use portable format macros for uint32_t Like Xu
2022-11-25 10:33 ` Thomas Huth

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.