From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50319) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ycwwf-0002m7-A4 for qemu-devel@nongnu.org; Tue, 31 Mar 2015 10:15:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ycwwb-000877-7Y for qemu-devel@nongnu.org; Tue, 31 Mar 2015 10:15:09 -0400 Message-ID: <551AABE5.1020509@redhat.com> Date: Tue, 31 Mar 2015 08:15:01 -0600 From: Eric Blake MIME-Version: 1.0 References: <1427808437-535644-1-git-send-email-stefanb@linux.vnet.ibm.com> <551AAA82.9090608@redhat.com> In-Reply-To: <551AAA82.9090608@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="XbAxFs2MForgD5sfw7LIsOjGJMIpePNgl" Subject: Re: [Qemu-devel] [PATCH] tpm_tis: fix format for 64bit variable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Berger , qemu-trivial@nongnu.org Cc: qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --XbAxFs2MForgD5sfw7LIsOjGJMIpePNgl Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 03/31/2015 08:09 AM, Eric Blake wrote: > On 03/31/2015 07:27 AM, Stefan Berger wrote: >> Signed-off-by: Stefan Berger >> --- >> hw/tpm/tpm_tis.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c >> index 815c8ea..52e0148 100644 >> --- a/hw/tpm/tpm_tis.c >> +++ b/hw/tpm/tpm_tis.c >> @@ -814,7 +814,7 @@ static void tpm_tis_mmio_write_intern(void *opaque= , hwaddr addr, >> tis->loc[locty].state =3D=3D TPM_TIS_STATE_COMPLETION) { >> /* drop the byte */ >> } else { >> - DPRINTF("tpm_tis: Data to send to TPM: %08x (size=3D%d)\n= ", >> + DPRINTF("tpm_tis: Data to send to TPM: %08lx (size=3D%d)\= n", >=20 > NACK. When printing uint64_t val, you HAVE to use PRIx64, not lx, for > the sake of 32-bit platforms. Furthermore, you could have caught this much sooner if you fix the definition of DPRINTF. This file used: #ifdef DEBUG_TIS #define DPRINTF(fmt, ...) \ do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0) #else #define DPRINTF(fmt, ...) \ do { } while (0) #endif which is bad, because the compiler CAN'T see the type mismatch unless you turn debugging on (alas, we have a LOT of files in the code base with similar bad patterns). A better example is hw/display/cg3.c: /* Change to 1 to enable debugging */ #define DEBUG_CG3 0 =2E.. #define DPRINTF(fmt, ...) do { \ if (DEBUG_CG3) { \ printf("CG3: " fmt , ## __VA_ARGS__); \ } \ } while (0); where now the compiler can unconditionally do -Wformat checking and avoid bit-rot, even if debug printing is never turned on, and without penalizing code size when debugging is off. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --XbAxFs2MForgD5sfw7LIsOjGJMIpePNgl Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJVGqvlAAoJEKeha0olJ0Nq/EUH/2Tv2Hyk81bbTJUVbG/eTxqx LBG8333RHn5ajlU/7q3+DHk+hlnsXsMST8snP7xYbQZAaEXdE3wFIB47TTjP2OFJ 6IE0+jaHZM9keGDu6b261V6wGeoauzAeYlLNtyJyDvwtdGAdpsl/RoIqzChHy5ow SIhg/rv3iIvJ0XZU/GzULkpz2MKpQ+LOFZ8lZjrWopp6rhpKQX/Iy4XXiHfORNgt Xv52nw0lZQD+ChJAfvPn1FL4695MNe+HgfNOADi7FlBH6E7MPZVbs51H/zmS8Lad c3sGkW/oOwgsXHqe5MJxPnDNTrrBKNvPzrYBiDg/72u+mk1cbIMBlcnsvy/YYJQ= =Mqz9 -----END PGP SIGNATURE----- --XbAxFs2MForgD5sfw7LIsOjGJMIpePNgl--