>From 5dc2333c009583f5ce7338d5d67f857a4e8f4c74 Mon Sep 17 00:00:00 2001 From: Liam Merwick
Date: Mon, 11 Feb 2019 13:15:17 +0000 Subject: [PATCH v2 3/3] tpm_tis: fix format string specifier in tpm_tis_show_buffer() cppcheck reports: [hw/tpm/tpm_tis.c:113]: (warning) %d in format string (no. 2) requires 'int' but the argument type is 'unsigned int' Fix this by converting it, and the other calls to printf in tpm_tis_show_buffer(), to use trace points. Signed-off-by: Liam Merwick --- hw/tpm/tpm_tis.c | 11 ++++++----- hw/tpm/trace-events | 3 +++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c index 860c2ace7d99..5d85b1cf61b1 100644 --- a/hw/tpm/tpm_tis.c +++ b/hw/tpm/tpm_tis.c @@ -107,17 +107,18 @@ static uint8_t tpm_tis_locality_from_addr(hwaddr addr) static void tpm_tis_show_buffer(const unsigned char *buffer, size_t buffer_size, const char *string) { - uint32_t len, i; + size_t len; + uint32_t i; len = MIN(tpm_cmd_get_size(buffer), buffer_size); - printf("tpm_tis: %s length = %d\n", string, len); + trace_tpm_tis_show_buffer_hdr(string, len); for (i = 0; i < len; i++) { if (i && !(i % 16)) { - printf("\n"); + trace_tpm_tis_show_buffer_newline(); } - printf("%.2X ", buffer[i]); + trace_tpm_tis_show_buffer_entry(buffer[i]); } - printf("\n"); + trace_tpm_tis_show_buffer_newline(); } /* diff --git a/hw/tpm/trace-events b/hw/tpm/trace-events index 920d32ad5514..41d99d489097 100644 --- a/hw/tpm/trace-events +++ b/hw/tpm/trace-events @@ -36,6 +36,9 @@ tpm_emulator_pre_save(void) "" tpm_emulator_inst_init(void) "" # hw/tpm/tpm_tis.c +tpm_tis_show_buffer_hdr(const char *string, size_t buffer_size) ": %s length = %zu" +tpm_tis_show_buffer_entry(const unsigned char entry) "%.2X " +tpm_tis_show_buffer_newline(void) "\n" tpm_tis_raise_irq(uint32_t irqmask) "Raising IRQ for flag 0x%08x" tpm_tis_new_active_locality(uint8_t locty) "Active locality is now %d" tpm_tis_abort(uint8_t locty) "New active locality is %d" -- 1.8.3.1