From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=34440 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P1yg0-00073a-C3 for qemu-devel@nongnu.org; Sat, 02 Oct 2010 05:46:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P1yfy-0006k5-4j for qemu-devel@nongnu.org; Sat, 02 Oct 2010 05:46:43 -0400 Received: from moutng.kundenserver.de ([212.227.126.187]:56920) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P1yfx-0006jk-MF for qemu-devel@nongnu.org; Sat, 02 Oct 2010 05:46:42 -0400 Message-ID: <4CA6FF70.3040902@mail.berlios.de> Date: Sat, 02 Oct 2010 11:46:24 +0200 From: Stefan Weil MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH v2] es1370: Fix compiler warnings for debug code References: <1285956354-5071-1-git-send-email-weil@mail.berlios.de> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: Blue Swirl , QEMU Developers Am 01.10.2010 20:22, schrieb Markus Armbruster: > Stefan Weil 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