tpm_tis: fix format for 64bit variable
PATCH 1/1 tpm_tis: fix format for 64bit variable
--- hw/tpm/tpm_tis.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/tpm/tpm_tis.c +1 -1
@@ -814,7 +814,7 @@ static void tpm_tis_mmio_write_intern(void *opaque, hwaddr addr, tis->loc[locty].state == TPM_TIS_STATE_COMPLETION) { /* drop the byte */ } else { -DPRINTF ("tpm_tis: Data to send to TPM: %08x (size=%d)\n" , +DPRINTF ("tpm_tis: Data to send to TPM: %08lx (size=%d)\n" , val, size);if (tis->loc[locty].state ==TPM_TIS_STATE_READY ) { tis->loc[locty].state =TPM_TIS_STATE_RECEPTION ;
Signature · 1 line
1.9.3
Quoted 10 lines · Stefan Berger
Signed-off-by Stefan Berger <[email protected]>--- hw/tpm/tpm_tis.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/tpm/tpm_tis.c +0
-0
hw/tpm/tpm_tis.c static void tpm_tis_mmio_write_intern(void *opaque, hwaddr addr, · line 817
Quoted 5 lines
hw/tpm/tpm_tis.c +1
-1@@ -814,7 +814,7 @@ static void tpm_tis_mmio_write_intern(void *opaque, hwaddr addr, tis->loc[locty].state == TPM_TIS_STATE_COMPLETION) { /* drop the byte */ } else { - DPRINTF("tpm_tis: Data to send to TPM: %08x (size=%d)\n", + DPRINTF("tpm_tis: Data to send to TPM: %08lx (size=%d)\n",
NACK. When printing uint64_t val, you HAVE to use PRIx64, not lx, for the sake of 32-bit platforms.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 6 lines · Eric Blake
Quoted 5 lines · Stefan Berger
Signed-off-by Stefan Berger <[email protected]>--- hw/tpm/tpm_tis.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines
hw/tpm/tpm_tis.c static void tpm_tis_mmio_write_intern(void *opaque, hwaddr addr, · line 817
Quoted 10 lines
hw/tpm/tpm_tis.c +1
-1@@ -814,7 +814,7 @@ static void tpm_tis_mmio_write_intern(void *opaque, hwaddr addr, tis->loc[locty].state == TPM_TIS_STATE_COMPLETION) { /* drop the byte */ } else { - DPRINTF("tpm_tis: Data to send to TPM: %08x (size=%d)\n", + DPRINTF("tpm_tis: Data to send to TPM: %08lx (size=%d)\n",NACK. When printing
uint64_tval, 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
...
#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.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 34 lines · Eric Blake
Quoted 6 lines · Eric Blake
Quoted 5 lines · Stefan Berger
Signed-off-by Stefan Berger <[email protected]>--- hw/tpm/tpm_tis.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 12 lines
hw/tpm/tpm_tis.c static void tpm_tis_mmio_write_intern(void *opaque, hwaddr addr, · line 817
Quoted 10 lines
hw/tpm/tpm_tis.c +1
-1@@ -814,7 +814,7 @@ static void tpm_tis_mmio_write_intern(void *opaque, hwaddr addr, tis->loc[locty].state == TPM_TIS_STATE_COMPLETION) { /* drop the byte */ } else { - DPRINTF("tpm_tis: Data to send to TPM: %08x (size=%d)\n", + DPRINTF("tpm_tis: Data to send to TPM: %08lx (size=%d)\n",NACK. When printing
uint64_tval, 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:
Quoted 8 lines
/* Change to 1 to enable debugging */
#defineDEBUG_CG30
...#define DPRINTF(fmt, ...) do { \ if (DEBUG_CG3) { \ printf("CG3: " fmt , ## __VA_ARGS__); \ } \ } while (0);
I'll move it towards that after 2.3 is out.
Stefan