|
From: | Liam Merwick |
Subject: | Re: [Qemu-devel] [PATCH v2 3/3] tpm_tis: fix format string specifier in tpm_tis_show_buffer() |
Date: | Mon, 11 Feb 2019 20:09:56 +0000 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 |
On 11/02/2019 19:56, Stefan Berger wrote:
On 2/11/19 11:02 AM, Philippe Mathieu-Daudé wrote:Hi Liam, On 2/11/19 4:03 PM, Liam Merwick wrote: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 using %u instead of %dLiam, Neither gcc nor cppcheck 1.86 complains about this on my system. What version of cppcheck are you using?
I was using 1.86 too but I had warnings enabled.% cppcheck -j 8 --platform=unix64 --force --inline-suppr --enable=warning --error-exitcode=1 hw/tpm/tpm_tis.c
Checking hw/tpm/tpm_tis.c ...[hw/tpm/tpm_tis.c:112]: (warning) %d in format string (no. 2) requires 'int' but the argument type is 'unsigned int'.
Signed-off-by: Liam Merwick <address@hidden> --- 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 860c2ace7d99..395500e8a61d 100644 --- a/hw/tpm/tpm_tis.c +++ b/hw/tpm/tpm_tis.c@@ -110,7 +110,7 @@ static void tpm_tis_show_buffer(const unsigned char *buffer,uint32_t len, i;If you want to clean this, use a size_t here instead of u32.len = MIN(tpm_cmd_get_size(buffer), buffer_size); - printf("tpm_tis: %s length = %d\n", string, len); + printf("tpm_tis: %s length = %u\n", string, len);So here the format is '%zu'. However in code cleanup we try go get ride of printf() calls and replace them with trace points.This code is only used for debugging if DEBUG_TIS has been #defined. No need to add tracing here.
I'd come up the attached change (but that seems like overkill). Regards, Liam
for (i = 0; i < len; i++) { if (i && !(i % 16)) { printf("\n");
v2-0003-tpm_tis-fix-format-string-specifier-in-tpm_tis_sh.patch
Description: Text Data
[Prev in Thread] | Current Thread | [Next in Thread] |