Skip to content

Commit

Permalink
turbostat: Don't attempt to printf an off_t with %zx
Browse files Browse the repository at this point in the history
turbostat uses the format %zx to print an off_t.  However, %zx wants a
size_t, not an off_t.  On 32-bit targets, those refer to different
types, potentially even with different sizes.  Use %llx and a cast
instead, since printf does not have a length modifier for off_t.

Without this patch, when compiling for a 32-bit target:

turbostat.c: In function 'get_msr':
turbostat.c:231:3: warning: format '%zx' expects argument of type 'size_t', but argument 4 has type 'off_t' [-Wformat]

Signed-off-by: Josh Triplett <[email protected]>
Signed-off-by: Len Brown <[email protected]>
  • Loading branch information
joshtriplett authored and lenb committed Jan 19, 2014
1 parent b731f31 commit 2e9c6bc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/power/x86/turbostat/turbostat.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ int get_msr(int cpu, off_t offset, unsigned long long *msr)
close(fd);

if (retval != sizeof *msr) {
fprintf(stderr, "%s offset 0x%zx read failed\n", pathname, offset);
fprintf(stderr, "%s offset 0x%llx read failed\n", pathname, (unsigned long long)offset);
return -1;
}

Expand Down

0 comments on commit 2e9c6bc

Please sign in to comment.