Re: [kvm-unit-tests PATCH] arm: Fix compilation errors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
> CC: Alexander Graf <graf@xxxxxxxxxx>
> CC: Andre Przywara <andre.przywara@xxxxxxx>
> CC: Andrew Jones <drjones@xxxxxxxxxx>
> Signed-off-by: Alexandru Elisei <alexandru.elisei@xxxxxxx>
> ---

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

_______________________________________________
kvmarm mailing list
kvmarm@xxxxxxxxxxxxxxxxxxxxx
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm



[Index of Archives]     [Linux KVM]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux