Skip to contentSkip to conversation

perf: fix bench numa compilation

PATCH New Yang Shi 1 participant 1 message Oct 17, 2013 perf events

lore
Share & tools
lore

Yang Shi

author
#0 lore raw

PATCH 1/1 perf: fix bench numa compilation

From: Riccardo Magliocchetti <[email protected]>

Taken from: https://lkml.org/lkml/2013/6/20/80

Fix the following errors on gcc 4.8.1 / x86:

bench/numa.c: In function worker_thread:
bench/numa.c:1113:20: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]

    if (diff.tv_sec >= g->p.nr_secs) {
                    ^
bench/numa.c:1161:6: error: format %lx expects argument of type long unsigned int, but argument 5 has type u64 [-Werror=format=]
      process_nr, thread_nr, runtime_ns_max / bytes_done, val);
      ^
---
 tools/perf/bench/numa.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tools/perf/bench/numa.c +3 -2
index 30d1c32..f5c0834 100644
@@ -21,6 +21,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <pthread.h>
+#include <inttypes.h>
 #include <sys/mman.h>
 #include <sys/time.h>
 #include <sys/wait.h>
@@ -1110,7 +1111,7 @@ static void *worker_thread(void *__tdata)
 		/* Check whether our max runtime timed out: */
 		if (g->p.nr_secs) {
 			timersub(&stop, &start0, &diff);
-			if (diff.tv_sec >= g->p.nr_secs) {
+			if (diff.tv_sec >= (long int)g->p.nr_secs) {
 				g->stop_work = true;
 				break;
 			}
@@ -1157,7 +1158,7 @@ static void *worker_thread(void *__tdata)
 			runtime_ns_max += diff.tv_usec * 1000;
 
 			if (details >= 0) {
-				printf(" #%2d / %2d: %14.2lf nsecs/op [val: %016lx]\n",
+				printf(" #%2d / %2d: %14.2lf nsecs/op [val: %016"PRIu64"x]\n",
 					process_nr, thread_nr, runtime_ns_max / bytes_done, val);
 			}
 			fflush(stdout);
Signature · 1 line
1.8.3.4