qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2] es1370: Fix compiler warnings for debug code


From: Stefan Weil
Subject: Re: [Qemu-devel] [PATCH v2] es1370: Fix compiler warnings for debug code
Date: Sat, 02 Oct 2010 11:46:24 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.12) Gecko/20100913 Iceowl/1.0b1 Icedove/3.0.7

Am 01.10.2010 20:22, schrieb Markus Armbruster:
Stefan Weil <address@hidden> writes:
The patch fixes these gcc warnings:

./hw/es1370.c: In function ‘es1370_update_voices’:
./hw/es1370.c:411: error: format ‘%d’ expects type ‘int’, but argument 3 has type ‘size_t’
./hw/es1370.c: In function ‘es1370_writel’:
./hw/es1370.c:579: error: format ‘%d’ expects type ‘int’, but argument 3 has type ‘long int’ ./hw/es1370.c:589: error: format ‘%d’ expects type ‘int’, but argument 3 has type ‘long int’ ./hw/es1370.c:606: error: format ‘%d’ expects type ‘int’, but argument 3 has type ‘long int’
./hw/es1370.c: In function ‘es1370_readl’:
./hw/es1370.c:748: error: suggest braces around empty body in an ‘if’ statement

v2

* Use %zd for pointer differences (ptrdiff_t or ssize_t).
The gcc error message ("long int") was misleading.
Malc, thank you for this hint.

The correct length modifier for ptrdiff_t is 't', not 'z'.
ISO/IEC 9899:1999 7.19.6.1:

z Specifies that a following d, i, o, u, x, or X
conversion specifier applies to a size_t or the
corresponding signed integer type argument; or
that a following n conversion specifier applies
to a pointer to a signed integer type
corresponding to size_t argument.

t Specifies that a following d, i, o, u, x, or X
conversion specifier applies to a ptrdiff_t or
the corresponding unsigned integer type
argument; or that a following n conversion
specifier applies to a pointer to a ptrdiff_t
argument.

Not that it makes a difference in practice.


It's always good to learn more. I must admit that I never
used %td before, but it exists, it is obviously supported,
so it should be used.

Therefore I'll send a third version of my patch, and also
patches which fix the other locations in qemu which use
%zd instead of %td for ptrdiff_t.

Thanks,
Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]