Skip to content

Commit 096972f

Browse files
robherringacmel
authored andcommitted
libperf: Fix 32-bit build for tests uint64_t printf
Commit a7f3713 ("libperf tests: Add test_stat_multiplexing test") added printf's of 64-bit ints using %lu which doesn't work on 32-bit builds: tests/test-evlist.c:529:29: error: format ‘%lu’ expects argument of type \ ‘long unsigned int’, but argument 4 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=] Use PRIu64 instead which works on both 32-bit and 64-bit systems. Fixes: a7f3713 ("libperf tests: Add test_stat_multiplexing test") Signed-off-by: Rob Herring <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Shunsuke Nakamura <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 714b8b7 commit 096972f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

tools/lib/perf/tests/test-evlist.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0
22
#define _GNU_SOURCE // needed for sched.h to get sched_[gs]etaffinity and CPU_(ZERO,SET)
3+
#include <inttypes.h>
34
#include <sched.h>
45
#include <stdio.h>
56
#include <stdarg.h>
@@ -526,12 +527,12 @@ static int test_stat_multiplexing(void)
526527

527528
min = counts[0].val;
528529
for (i = 0; i < EVENT_NUM; i++) {
529-
__T_VERBOSE("Event %2d -- Raw count = %lu, run = %lu, enable = %lu\n",
530+
__T_VERBOSE("Event %2d -- Raw count = %" PRIu64 ", run = %" PRIu64 ", enable = %" PRIu64 "\n",
530531
i, counts[i].val, counts[i].run, counts[i].ena);
531532

532533
perf_counts_values__scale(&counts[i], true, &scaled);
533534
if (scaled == 1) {
534-
__T_VERBOSE("\t Scaled count = %lu (%.2lf%%, %lu/%lu)\n",
535+
__T_VERBOSE("\t Scaled count = %" PRIu64 " (%.2lf%%, %" PRIu64 "/%" PRIu64 ")\n",
535536
counts[i].val,
536537
(double)counts[i].run / (double)counts[i].ena * 100.0,
537538
counts[i].run, counts[i].ena);

0 commit comments

Comments
 (0)