[PATCH] perf tools: Fix build failures on ppc64le

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



  util/evsel.c: In function 'store_event':
  util/evsel.c:138:50: error: format '%llu' expects argument of type 'long long unsigned int',
                       but argument 6 has type '__u64' {aka 'long unsigned int'} [-Werror=format=]
    138 |         snprintf(path, PATH_MAX, "%s/event-%d-%llu-%d", dir,
        |                                               ~~~^
        |                                                  |
        |                                                  long long unsigned int
        |                                               %lu
    139 |                  attr->type, attr->config, fd);
        |                              ~~~~~~~~~~~~
        |                                  |
        |                                  __u64 {aka long unsigned int}
  util/evsel.c:147:41: error: format '%llu' expects argument of type 'long long unsigned int',
                       but argument 4 has type '__u64' {aka 'long unsigned int'} [-Werror=format=]
    147 |         if (fprintf(file, "[event-%d-%llu-%d]\n",
        |                                      ~~~^
        |                                         |
        |                                         long long unsigned int
        |                                      %lu
    148 |                     attr->type, attr->config, fd) < 0) {
        |                                 ~~~~~~~~~~~~
        |                                     |
        |                                     __u64 {aka long unsigned int}
  util/evsel.c:164:33: error: format '%llu' expects argument of type 'long long unsigned int',
                       but argument 3 has type '__u64' {aka 'long unsigned int'} [-Werror=format=]
    164 |         WRITE_ASS(config,  "llu");
        |                                 ^
  util/evsel.c:122:28: note: in definition of macro '__WRITE_ASS'
    122 |         if (fprintf(file, #str "=%"fmt "\n", data) < 0) {               \
        |                            ^~~
  util/evsel.c:164:9: note: in expansion of macro 'WRITE_ASS'
    164 |         WRITE_ASS(config,  "llu");
        |         ^~~~~~~~~
  ...
    cc1: all warnings being treated as errors

Fixes: f90a291448877ab45 ("perf test: Remove C test wrapper for attr.py")
Reported-by: Stephen Rothwell <sfr@xxxxxxxxxxxxxxxx>
Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
---
Hi Stephen, can you please test if this patch fixes it?

Thanks,
Namhyung

 tools/perf/util/evsel.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 37c338b0f8b2bb04..88e98c0b10528a63 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -108,7 +108,7 @@ static int store_event(struct perf_event_attr *attr, pid_t pid, struct perf_cpu
 	char path[PATH_MAX];
 	char *dir = getenv("PERF_TEST_ATTR");
 
-	snprintf(path, PATH_MAX, "%s/event-%d-%llu-%d", dir,
+	snprintf(path, PATH_MAX, "%s/event-%d-%"PRI_lu64"-%d", dir,
 		 attr->type, attr->config, fd);
 
 	file = fopen(path, "w+");
@@ -117,7 +117,7 @@ static int store_event(struct perf_event_attr *attr, pid_t pid, struct perf_cpu
 		return -1;
 	}
 
-	if (fprintf(file, "[event-%d-%llu-%d]\n",
+	if (fprintf(file, "[event-%d-%"PRI_lu64"-%d]\n",
 		    attr->type, attr->config, fd) < 0) {
 		perror("test attr - failed to write event file");
 		fclose(file);
@@ -134,10 +134,10 @@ static int store_event(struct perf_event_attr *attr, pid_t pid, struct perf_cpu
 	/* struct perf_event_attr */
 	WRITE_ASS(type,   PRIu32);
 	WRITE_ASS(size,   PRIu32);
-	WRITE_ASS(config,  "llu");
-	WRITE_ASS(sample_period, "llu");
-	WRITE_ASS(sample_type,   "llu");
-	WRITE_ASS(read_format,   "llu");
+	WRITE_ASS(config,  PRI_lu64);
+	WRITE_ASS(sample_period, PRI_lu64);
+	WRITE_ASS(sample_type,   PRI_lu64);
+	WRITE_ASS(read_format,   PRI_lu64);
 	WRITE_ASS(disabled,       "d");
 	WRITE_ASS(inherit,        "d");
 	WRITE_ASS(pinned,         "d");
@@ -168,10 +168,10 @@ static int store_event(struct perf_event_attr *attr, pid_t pid, struct perf_cpu
 	WRITE_ASS(use_clockid,    "d");
 	WRITE_ASS(wakeup_events, PRIu32);
 	WRITE_ASS(bp_type, PRIu32);
-	WRITE_ASS(config1, "llu");
-	WRITE_ASS(config2, "llu");
-	WRITE_ASS(branch_sample_type, "llu");
-	WRITE_ASS(sample_regs_user,   "llu");
+	WRITE_ASS(config1, PRI_lu64);
+	WRITE_ASS(config2, PRI_lu64);
+	WRITE_ASS(branch_sample_type, PRI_lu64);
+	WRITE_ASS(sample_regs_user,   PRI_lu64);
 	WRITE_ASS(sample_stack_user,  PRIu32);
 
 	fclose(file);
-- 
2.47.0.rc1.288.g06298d1525-goog





[Index of Archives]     [Linux Kernel]     [Linux USB Development]     [Yosemite News]     [Linux SCSI]

  Powered by Linux