From: Thomas Huth <thuth@redhat.com>
To: Roman Bolshakov <r.bolshakov@yadro.com>, kvm@vger.kernel.org
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
"Andrew Jones" <drjones@redhat.com>,
"Cameron Esfahani" <dirty@apple.com>
Subject: Re: [kvm-unit-tests PATCH 5/7] lib: x86: Use portable format macros for uint32_t
Date: Fri, 28 Aug 2020 07:49:57 +0200 [thread overview]
Message-ID: <e22f11ca-3927-9dd5-d381-7886c82603cd@redhat.com> (raw)
In-Reply-To: <20200810130618.16066-6-r.bolshakov@yadro.com>
On 10/08/2020 15.06, Roman Bolshakov wrote:
> 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>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
> ---
> lib/pci.c | 2 +-
> x86/asyncpf.c | 2 +-
> x86/msr.c | 3 ++-
> x86/s3.c | 2 +-
> 4 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/lib/pci.c b/lib/pci.c
> index daa33e1..175caf0 100644
> --- a/lib/pci.c
> +++ b/lib/pci.c
> @@ -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);
> }
>
> diff --git a/x86/asyncpf.c b/x86/asyncpf.c
> index 305a923..8239e16 100644
> --- a/x86/asyncpf.c
> +++ b/x86/asyncpf.c
> @@ -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;
> }
> }
> diff --git a/x86/msr.c b/x86/msr.c
> index f7539c3..ce5dabe 100644
> --- a/x86/msr.c
> +++ b/x86/msr.c
> @@ -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);
> diff --git a/x86/s3.c b/x86/s3.c
> index da2d00c..6e41d0c 100644
> --- a/x86/s3.c
> +++ b/x86/s3.c
> @@ -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. */
>
Reviewed-by: Thomas Huth <thuth@redhat.com>
next prev parent reply other threads:[~2020-08-28 5:50 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-10 13:06 [kvm-unit-tests PATCH 0/7] Add support for generic ELF cross-compiler Roman Bolshakov
2020-08-10 13:06 ` [kvm-unit-tests PATCH 1/7] x86: Makefile: Allow division on x86_64-elf binutils Roman Bolshakov
2020-08-28 5:00 ` Thomas Huth
2020-08-28 6:54 ` Roman Bolshakov
2020-08-28 7:24 ` Thomas Huth
2020-08-28 7:47 ` Roman Bolshakov
2020-08-28 7:56 ` Thomas Huth
2020-08-28 8:37 ` Roman Bolshakov
2020-08-31 17:30 ` Roman Bolshakov
2020-08-31 20:33 ` Thomas Huth
2020-08-10 13:06 ` [kvm-unit-tests PATCH 2/7] x86: Replace instruction prefixes with spaces Roman Bolshakov
2020-08-28 4:34 ` Thomas Huth
2020-08-10 13:06 ` [kvm-unit-tests PATCH 3/7] x86: Makefile: Fix linkage of realmode on x86_64-elf binutils Roman Bolshakov
2020-08-28 5:44 ` Thomas Huth
2020-08-10 13:06 ` [kvm-unit-tests PATCH 4/7] lib: Bundle debugreg.h from the kernel Roman Bolshakov
2020-08-28 4:56 ` Thomas Huth
2020-08-10 13:06 ` [kvm-unit-tests PATCH 5/7] lib: x86: Use portable format macros for uint32_t Roman Bolshakov
2020-08-28 5:49 ` Thomas Huth [this message]
2020-08-10 13:06 ` [kvm-unit-tests PATCH 6/7] configure: Add an option to specify getopt Roman Bolshakov
2020-08-28 5:55 ` Thomas Huth
2020-08-28 7:12 ` Roman Bolshakov
2020-08-28 7:34 ` Thomas Huth
2020-08-10 13:06 ` [kvm-unit-tests PATCH 7/7] README: Update build instructions for macOS Roman Bolshakov
2020-08-26 16:52 ` [kvm-unit-tests PATCH 0/7] Add support for generic ELF cross-compiler Roman Bolshakov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e22f11ca-3927-9dd5-d381-7886c82603cd@redhat.com \
--to=thuth@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=dirty@apple.com \
--cc=drjones@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=r.bolshakov@yadro.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox