>From add6a709f79e20e8b4eaa6ded2bd1af043f8a235 Mon Sep 17 00:00:00 2001 From: Thomas Richter Date: Wed, 8 Aug 2018 07:11:23 +0100 Subject: [PATCH] perf report: Fix build error for s390 auxiliary trace support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 73eeeea48b7e ("perf report: Add raw report support for s390 auxiliary trace") introduced a compile errors on powerpc: util/s390-cpumsf.c: In function ‘trailer_timestamp’: util/s390-cpumsf.c:222:2: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing] return *((unsigned long long *) &te->timestamp[te->t]); ^ In file included from util/cpumap.h:10:0, from util/s390-cpumsf.c:150: util/s390-cpumsf.c: In function ‘s390_cpumsf_basic_show’: util/s390-cpumsf.c:187:10: error: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘size_t {aka unsigned int}’ [-Werror=format=] pr_err("Invalid AUX trace basic entry [%#08lx]\n", pos); ^ Fix these errors: 1. Use memcpy to extract value from character array. 2. Use %zu as format string in pr_err Fixes: 73eeeea48b7e Signed-off-by: Thomas Richter --- tools/perf/util/s390-cpumsf.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/s390-cpumsf.c b/tools/perf/util/s390-cpumsf.c index 15555604ddb3..2bcb160a08f0 100644 --- a/tools/perf/util/s390-cpumsf.c +++ b/tools/perf/util/s390-cpumsf.c @@ -184,7 +184,7 @@ static bool s390_cpumsf_basic_show(const char *color, size_t pos, struct hws_basic_entry *basic) { if (basic->def != 1) { - pr_err("Invalid AUX trace basic entry [%#08lx]\n", pos); + pr_err("Invalid AUX trace basic entry [%#08zx]\n", pos); return false; } color_fprintf(stdout, color, " [%#08x] Basic Def:%04x Inst:%#04x" @@ -219,7 +219,10 @@ static unsigned long long trailer_timestamp(struct hws_trailer_entry *te) /* te->t set: TOD in STCKE format, bytes 8-15 * to->t not set: TOD in STCK format, bytes 0-7 */ - return *((unsigned long long *) &te->timestamp[te->t]); + unsigned long long ts; + + memcpy(&ts, &te->timestamp[te->t], sizeof(ts)); + return ts; } /* Display s390 CPU measurement facility trailer entry */ -- 2.14.3