Skip to contentSkip to conversation

perf session: Fix DEBUG=1 build with clang

tip:perf/urgent tip-bot for Arnaldo Carvalho de Melo 1 participant 1 message Feb 21, 2017 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  8074bf51fe5af68dcbc12bd7fa72dc4be8f41dde
Gitweb:     http://git.kernel.org/tip/8074bf51fe5af68dcbc12bd7fa72dc4be8f41dde
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Fri, 17 Feb 2017 12:27:26 -0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 17 Feb 2017 12:27:26 -0300

perf session: Fix DEBUG=1 build with clang

The struct branch_stack->branch_stack.cycles field is a u64 :16 bitfield, and this somehow confuses clang 4.0 when checking the arguments of a printf format, so cast the :16 to unsigned short to help it.

Silences this:

util/session.c:935:4: error: format specifies type 'unsigned short' but the argument has type 'u64' (aka 'unsigned long') [-Werror,-Wformat]

                          e->flags.cycles,
                          ^~~~~~~~~~~~~~~

1 error generated.

---
 tools/perf/util/session.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/session.c +1 -1
index 4cdbc8f..1dd617d 100644
@@ -932,7 +932,7 @@ static void branch_stack__printf(struct perf_sample *sample)
 
 		printf("..... %2"PRIu64": %016" PRIx64 " -> %016" PRIx64 " %hu cycles %s%s%s%s %x\n",
 			i, e->from, e->to,
-			e->flags.cycles,
+			(unsigned short)e->flags.cycles,
 			e->flags.mispred ? "M" : " ",
 			e->flags.predicted ? "P" : " ",
 			e->flags.abort ? "A" : " ",