From 5f3754e66dbe3b04c71c19fb106a92b30d475ab4 Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Fri, 5 Apr 2013 00:12:21 +0200 Subject: [PATCH] inteltool: cpu.c: Use conversion specifier `u` for unsigned integers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cppcheck [1], a static code analysis tool, warns about the following. $ cppcheck --version Cppcheck 1.59 $ cppcheck --enable=all . […] Checking cpu.c... [cpu.c:951]: (warning) %d in format string (no. 1) requires a signed integer given in the argument list. [cpu.c:962]: (warning) %d in format string (no. 1) requires a signed integer given in the argument list. […] And indeed, `core` is an unsigned integer and `man 3 printf` tells the following about conversion specifiers. d, i The int argument is converted to signed decimal notation. […] o, u, x, X The unsigned int argument is converted to unsigned octal (o), unsigned decimal (u), or unsigned hexadecimal (x and X) notation. So use `u` and Cppcheck does not complain anymore. [1] http://cppcheck.sourceforge.net/ Change-Id: If8dd8d0efe75fcb4af2502ae5100e3f2062649e4 Signed-off-by: Paul Menzel Reviewed-on: http://review.coreboot.org/3026 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer --- util/inteltool/cpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/inteltool/cpu.c b/util/inteltool/cpu.c index e73f0963de..80e1ed69c3 100644 --- a/util/inteltool/cpu.c +++ b/util/inteltool/cpu.c @@ -948,7 +948,7 @@ int print_intel_core_msrs(void) #ifndef __DARWIN__ char msrfilename[64]; memset(msrfilename, 0, 64); - sprintf(msrfilename, "/dev/cpu/%d/msr", core); + sprintf(msrfilename, "/dev/cpu/%u/msr", core); fd_msr = open(msrfilename, O_RDWR); @@ -959,7 +959,7 @@ int print_intel_core_msrs(void) break; #endif if (cpu->num_per_core_msrs) - printf("\n====================== UNIQUE MSRs (core %d) ======================\n", core); + printf("\n====================== UNIQUE MSRs (core %u) ======================\n", core); for (i = 0; i < cpu->num_per_core_msrs; i++) { msr = rdmsr(cpu->per_core_msrs[i].number);