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: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH v2] es1370: Fix compiler warnings for debug code
Date: Fri, 01 Oct 2010 20:22:18 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

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.



reply via email to

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