From 070c7607f62f9623be9ff14623a43b0ca195c572 Mon Sep 17 00:00:00 2001 From: Stefan Berger Date: Tue, 31 Mar 2015 14:49:09 -0400 Subject: tpm: Cast 64bit variables to int when used in DPRINTF Cast 64bit variables to int when used in DPRINTF. They only contain 32bit of data. Signed-off-by: Stefan Berger Reviewed-by: Eric Blake Signed-off-by: Michael Tokarev --- hw/tpm/tpm_tis.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'hw/tpm') diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c index 815c8ea..cb9c7c8 100644 --- a/hw/tpm/tpm_tis.c +++ b/hw/tpm/tpm_tis.c @@ -421,7 +421,7 @@ static void tpm_tis_dump_state(void *opaque, hwaddr addr) for (idx = 0; regs[idx] != 0xfff; idx++) { DPRINTF("tpm_tis: 0x%04x : 0x%08x\n", regs[idx], - (uint32_t)tpm_tis_mmio_read(opaque, base + regs[idx], 4)); + (int)tpm_tis_mmio_read(opaque, base + regs[idx], 4)); } DPRINTF("tpm_tis: read offset : %d\n" @@ -555,7 +555,7 @@ static uint64_t tpm_tis_mmio_read(void *opaque, hwaddr addr, val >>= shift; } - DPRINTF("tpm_tis: read.%u(%08x) = %08x\n", size, (int)addr, (uint32_t)val); + DPRINTF("tpm_tis: read.%u(%08x) = %08x\n", size, (int)addr, (int)val); return val; } @@ -578,7 +578,7 @@ static void tpm_tis_mmio_write_intern(void *opaque, hwaddr addr, uint16_t len; uint32_t mask = (size == 1) ? 0xff : ((size == 2) ? 0xffff : ~0); - DPRINTF("tpm_tis: write.%u(%08x) = %08x\n", size, (int)addr, (uint32_t)val); + DPRINTF("tpm_tis: write.%u(%08x) = %08x\n", size, (int)addr, (int)val); if (locty == 4 && !hw_access) { DPRINTF("tpm_tis: Access to locality 4 only allowed from hardware\n"); @@ -815,7 +815,7 @@ static void tpm_tis_mmio_write_intern(void *opaque, hwaddr addr, /* drop the byte */ } else { DPRINTF("tpm_tis: Data to send to TPM: %08x (size=%d)\n", - val, size); + (int)val, size); if (tis->loc[locty].state == TPM_TIS_STATE_READY) { tis->loc[locty].state = TPM_TIS_STATE_RECEPTION; tpm_tis_sts_set(&tis->loc[locty], -- cgit v1.1 From 4d1ba9c4f8a4d68b9d053946d551ffa8f1006b77 Mon Sep 17 00:00:00 2001 From: Stefan Berger Date: Tue, 31 Mar 2015 14:49:10 -0400 Subject: tpm: Modify DPRINTF to enable -Wformat checking Modify DPRINTF to always enable -Wformat checking. Signed-off-by: Stefan Berger Reviewed-by: Eric Blake Signed-off-by: Michael Tokarev --- hw/tpm/tpm_passthrough.c | 16 +++++++--------- hw/tpm/tpm_tis.c | 14 ++++++-------- 2 files changed, 13 insertions(+), 17 deletions(-) (limited to 'hw/tpm') diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c index 2a45071..73ca906 100644 --- a/hw/tpm/tpm_passthrough.c +++ b/hw/tpm/tpm_passthrough.c @@ -34,15 +34,13 @@ #include "sysemu/tpm_backend_int.h" #include "tpm_tis.h" -/* #define DEBUG_TPM */ - -#ifdef DEBUG_TPM -#define DPRINTF(fmt, ...) \ - do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0) -#else -#define DPRINTF(fmt, ...) \ - do { } while (0) -#endif +#define DEBUG_TPM 0 + +#define DPRINTF(fmt, ...) do { \ + if (DEBUG_TPM) { \ + fprintf(stderr, fmt, ## __VA_ARGS__); \ + } \ +} while (0); #define TYPE_TPM_PASSTHROUGH "tpm-passthrough" #define TPM_PASSTHROUGH(obj) \ diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c index cb9c7c8..4b6d601 100644 --- a/hw/tpm/tpm_tis.c +++ b/hw/tpm/tpm_tis.c @@ -30,15 +30,13 @@ #include "qemu-common.h" #include "qemu/main-loop.h" -/*#define DEBUG_TIS */ +#define DEBUG_TIS 0 -#ifdef DEBUG_TIS -#define DPRINTF(fmt, ...) \ - do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0) -#else -#define DPRINTF(fmt, ...) \ - do { } while (0) -#endif +#define DPRINTF(fmt, ...) do { \ + if (DEBUG_TIS) { \ + printf(fmt, ## __VA_ARGS__); \ + } \ +} while (0); /* whether the STS interrupt is supported */ #define RAISE_STS_IRQ -- cgit v1.1 From 29b558d87710a962203a45d9dd57bf7eab19dca0 Mon Sep 17 00:00:00 2001 From: Stefan Berger Date: Wed, 15 Apr 2015 10:18:55 -0400 Subject: tpm: fix coding style Fix coding style in one instance. Signed-off-by: Stefan Berger Signed-off-by: Michael Tokarev --- hw/tpm/tpm_tis.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'hw/tpm') diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c index 4b6d601..b8235d5 100644 --- a/hw/tpm/tpm_tis.c +++ b/hw/tpm/tpm_tis.c @@ -842,7 +842,7 @@ static void tpm_tis_mmio_write_intern(void *opaque, hwaddr addr, (tis->loc[locty].sts & TPM_TIS_STS_EXPECT)) { /* we have a packet length - see if we have all of it */ #ifdef RAISE_STS_IRQ - bool needIrq = !(tis->loc[locty].sts & TPM_TIS_STS_VALID); + bool need_irq = !(tis->loc[locty].sts & TPM_TIS_STS_VALID); #endif len = tpm_tis_get_size_from_buffer(&tis->loc[locty].w_buffer); if (len > tis->loc[locty].w_offset) { @@ -853,7 +853,7 @@ static void tpm_tis_mmio_write_intern(void *opaque, hwaddr addr, tpm_tis_sts_set(&tis->loc[locty], TPM_TIS_STS_VALID); } #ifdef RAISE_STS_IRQ - if (needIrq) { + if (need_irq) { tpm_tis_raise_irq(s, locty, TPM_TIS_INT_STS_VALID); } #endif -- cgit v1.1