kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Jones <drjones@redhat.com>
To: Alexandru Elisei <alexandru.elisei@arm.com>
Cc: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu,
	pbonzini@redhat.com, Eric Auger <eric.auger@redhat.com>,
	Alexander Graf <graf@amazon.com>,
	Andre Przywara <andre.przywara@arm.com>
Subject: Re: [kvm-unit-tests PATCH] arm: Fix compilation errors
Date: Mon, 9 Nov 2020 17:00:20 +0100	[thread overview]
Message-ID: <20201109160020.atjjurkh3mwteork@kamzik.brq.redhat.com> (raw)
In-Reply-To: <20201105135936.55088-1-alexandru.elisei@arm.com>

On Thu, Nov 05, 2020 at 01:59:36PM +0000, Alexandru Elisei wrote:
> Using arm-none-eabi-gcc triggers the following compilation errors:
> 
> $ ./configure --arch=arm --cross-prefix=arm-none-eabi-
> $ make clean
> $ make -j8
> [..]
> arm/pmu.c: In function 'pmu_probe':
> arm/pmu.c:1000:47: error: format '%c' expects argument of type 'int', but argument 3 has type 'long unsigned int' [-Werror=format=]
>  1000 |  report_info("PMU implementer/ID code: %#x(\"%c\")/%#x",
>       |                                              ~^
>       |                                               |
>       |                                               int
>       |                                              %ld
>  1001 |       (pmcr >> PMU_PMCR_IMP_SHIFT) & PMU_PMCR_IMP_MASK,
>  1002 |       ((pmcr >> PMU_PMCR_IMP_SHIFT) & PMU_PMCR_IMP_MASK) ? : ' ',
>       |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>       |                                                            |
>       |                                                            long unsigned int
> [..]
> arm/gic.c: In function 'test_byte_access':
> arm/gic.c:460:31: error: format '%x' expects argument of type 'unsigned int', but argument 2 has type 'u32' {aka 'long unsigned int'} [-Werror=format=]
>   460 |   report_info("byte 1 of 0x%08x => 0x%02x", pattern & mask, reg);
>       |                            ~~~^             ~~~~~~~~~~~~~~
>       |                               |                     |
>       |                               unsigned int          u32 {aka long unsigned int}
>       |                            %08lx
> [..]
> arm/pl031.c: In function 'irq_handler':
> arm/pl031.c:153:39: error: format '%d' expects argument of type 'int', but argument 2 has type 'u32' {aka 'long unsigned int'} [-Werror=format=]
>   153 |   report_info("Unexpected interrupt: %d\n", irqnr);
>       |                                      ~^     ~~~~~
>       |                                       |     |
>       |                                       int   u32 {aka long unsigned int}
>       |                                      %ld
> 
> The errors were observed when using arm-none-eabi-gcc versions 10.2.0 and
> 9.2.0. No errors were found when using arm-linux-gnu-gcc version 10.2.1.
> 
> Replace the offending printf format specifiers with their PRIxxx
> counterparts defined by C99 and available in libcflat.h. Also remove the
> unnecessary call to get_pmcr() in pmu_probe(), as the pmcr value hasn't
> changed since initialization.
> 
> Nu functional changes intended by this patch.

  ^ I've fixed this typo

> 
> CC: Eric Auger <eric.auger@redhat.com>
> CC: Alexander Graf <graf@amazon.com>
> CC: Andre Przywara <andre.przywara@arm.com>
> CC: Andrew Jones <drjones@redhat.com>
> Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
> ---

Thanks Alex. I've queued this for the next Arm pull request.

> 
> Andre suggested that we drop using gcc's stdint.h and implement our own to avoid
> such errors in the future. The distro that I'm using on my desktop doesn't have
> the arm-linux-gnu toolchain in the default repos, so I figured I should send
> this fix to get things compiling again.
> 
> I have no preference for, or against, implementing our own types.h header file.
> I imagine it's not going to be easy to change the code to use it (possibly for
> all architectures), and it should be worth it in the long run.

I'd keep gcc's stdint.h for now, but it might be a good idea to post a
travis patch that tests compiling with your preferred toolchain.

Thanks,
drew


      reply	other threads:[~2020-11-09 16:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-05 13:59 [kvm-unit-tests PATCH] arm: Fix compilation errors Alexandru Elisei
2020-11-09 16:00 ` Andrew Jones [this message]

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=20201109160020.atjjurkh3mwteork@kamzik.brq.redhat.com \
    --to=drjones@redhat.com \
    --cc=alexandru.elisei@arm.com \
    --cc=andre.przywara@arm.com \
    --cc=eric.auger@redhat.com \
    --cc=graf@amazon.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=pbonzini@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).