From: Thomas Huth <thuth@redhat.com>
To: Andrew Jones <drjones@redhat.com>, kvm@vger.kernel.org
Cc: pbonzini@redhat.com, rkrcmar@redhat.com
Subject: Re: [kvm-unit-tests PATCH 2/4] lib/alloc: fix format warnings, add/use PRIx64
Date: Tue, 1 Mar 2016 05:58:52 +0100 [thread overview]
Message-ID: <56D5218C.8040204@redhat.com> (raw)
In-Reply-To: <1456777155-8599-3-git-send-email-drjones@redhat.com>
On 29.02.2016 21:19, Andrew Jones wrote:
> Signed-off-by: Andrew Jones <drjones@redhat.com>
> ---
> lib/alloc.c | 13 +++++++------
> lib/libcflat.h | 12 ++++++++++++
> 2 files changed, 19 insertions(+), 6 deletions(-)
>
> diff --git a/lib/alloc.c b/lib/alloc.c
> index 34f71a337d868..e345843b7fe53 100644
> --- a/lib/alloc.c
> +++ b/lib/alloc.c
> @@ -28,13 +28,13 @@ void phys_alloc_show(void)
> int i;
>
> spin_lock(&lock);
> - printf("phys_alloc minimum alignment: 0x%llx\n", align_min);
> + printf("phys_alloc minimum alignment: 0x%" PRIx64 "\n", align_min);
> for (i = 0; i < nr_regions; ++i)
> - printf("%016llx-%016llx [%s]\n",
> + printf("%016" PRIx64 "-%016" PRIx64 " [%s]\n",
> regions[i].base,
> regions[i].base + regions[i].size - 1,
> "USED");
> - printf("%016llx-%016llx [%s]\n", base, top - 1, "FREE");
> + printf("%016" PRIx64 "-%016" PRIx64 " [%s]\n", base, top - 1, "FREE");
> spin_unlock(&lock);
> }
>
> @@ -76,9 +76,10 @@ static phys_addr_t phys_alloc_aligned_safe(phys_addr_t size,
> size += addr - base;
>
> if ((top_safe - base) < size) {
> - printf("phys_alloc: requested=0x%llx (align=0x%llx), "
> - "need=0x%llx, but free=0x%llx. "
> - "top=0x%llx, top_safe=0x%llx\n",
> + printf("phys_alloc: requested=0x%" PRIx64
> + " (align=0x%" PRIx64 "), "
> + "need=0x%" PRIx64 ", but free=0x%" PRIx64 ". "
> + "top=0x%" PRIx64 ", top_safe=0x%" PRIx64 "\n",
> size_orig, align, size, top_safe - base,
> top, top_safe);
> spin_unlock(&lock);
> diff --git a/lib/libcflat.h b/lib/libcflat.h
> index ce09d34e658b3..36e300bf4d0ff 100644
> --- a/lib/libcflat.h
> +++ b/lib/libcflat.h
> @@ -48,6 +48,18 @@ typedef _Bool bool;
> #define false 0
> #define true 1
>
> +#if __SIZEOF_LONG__ == 8
> +# define __PRI64_PREFIX "l"
> +# define __PRIPTR_PREFIX "l"
> +#else
> +# define __PRI64_PREFIX "ll"
> +# define __PRIPTR_PREFIX
> +#endif
> +#define PRId64 __PRI64_PREFIX "d"
> +#define PRIu64 __PRI64_PREFIX "u"
> +#define PRIx64 __PRI64_PREFIX "x"
> +#define PRIxPTR __PRIPTR_PREFIX "x"
So libcflat uses the header stdint.h from the standard gcc installation
to get the uint64_t and friends, but you define the PRIx64 etc. here
manually? That sounds strange... You could simply include "inttypes.h"
instead of "stdint.h" in this libcflat.h header file, then you would get
PRIx64 and friends automatically instead.
OTOH, for a stand-alone binary like kvm-unit-tests, it's also somewhat
risky to compile without "-nostdinc" since unwanted headers might be
included that way (e.g. what happens if someone writes "#include
<stdio.h>" by accident? You likely get some nice confusion...). So maybe
it would be better to compile with "-nostdinc" instead and define all
necessary things manually here?
Thomas
next prev parent reply other threads:[~2016-03-01 4:58 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-29 20:19 [kvm-unit-tests PATCH 0/4] add fmt warnings to printf, and fix bad uses Andrew Jones
2016-02-29 20:19 ` [kvm-unit-tests PATCH 1/4] lib: *printf: warn on format/arg mismatch Andrew Jones
2016-03-01 10:43 ` Paolo Bonzini
2016-03-01 11:01 ` Andrew Jones
2016-02-29 20:19 ` [kvm-unit-tests PATCH 2/4] lib/alloc: fix format warnings, add/use PRIx64 Andrew Jones
2016-03-01 4:58 ` Thomas Huth [this message]
2016-03-01 9:15 ` Andrew Jones
2016-03-01 11:04 ` Paolo Bonzini
2016-03-01 12:22 ` Andrew Jones
2016-03-01 10:47 ` Paolo Bonzini
2016-02-29 20:19 ` [kvm-unit-tests PATCH 3/4] arm64: fix printf format warnings Andrew Jones
2016-03-01 5:01 ` Thomas Huth
2016-03-01 9:17 ` Andrew Jones
2016-02-29 20:19 ` [kvm-unit-tests PATCH 4/4] x86: " Andrew Jones
2016-03-01 5:30 ` Thomas Huth
2016-03-01 9:24 ` Andrew Jones
2016-03-01 10:52 ` Paolo Bonzini
2016-03-01 11:02 ` Andrew Jones
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=56D5218C.8040204@redhat.com \
--to=thuth@redhat.com \
--cc=drjones@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.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 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.