linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] libperf: Fix 32-bit build for tests uint64_t printf
@ 2022-02-01 21:39 Rob Herring
  2022-02-01 23:58 ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 2+ messages in thread
From: Rob Herring @ 2022-02-01 21:39 UTC (permalink / raw)
  To: Shunsuke Nakamura, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, linux-perf-users, linux-kernel

Commit a7f3713f6bf2 ("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: a7f3713f6bf2 ("libperf tests: Add test_stat_multiplexing test")
Cc: Shunsuke Nakamura <nakamura.shun@fujitsu.com>
Signed-off-by: Rob Herring <robh@kernel.org>
---
 tools/lib/perf/tests/test-evlist.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/lib/perf/tests/test-evlist.c b/tools/lib/perf/tests/test-evlist.c
index b3479dfa9a1c..fa854c83b7e7 100644
--- a/tools/lib/perf/tests/test-evlist.c
+++ b/tools/lib/perf/tests/test-evlist.c
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 #define _GNU_SOURCE // needed for sched.h to get sched_[gs]etaffinity and CPU_(ZERO,SET)
+#include <inttypes.h>
 #include <sched.h>
 #include <stdio.h>
 #include <stdarg.h>
@@ -526,12 +527,12 @@ static int test_stat_multiplexing(void)
 
 	min = counts[0].val;
 	for (i = 0; i < EVENT_NUM; i++) {
-		__T_VERBOSE("Event %2d -- Raw count = %lu, run = %lu, enable = %lu\n",
+		__T_VERBOSE("Event %2d -- Raw count = %" PRIu64 ", run = %" PRIu64 ", enable = %" PRIu64 "\n",
 			    i, counts[i].val, counts[i].run, counts[i].ena);
 
 		perf_counts_values__scale(&counts[i], true, &scaled);
 		if (scaled == 1) {
-			__T_VERBOSE("\t Scaled count = %lu (%.2lf%%, %lu/%lu)\n",
+			__T_VERBOSE("\t Scaled count = %" PRIu64 " (%.2lf%%, %" PRIu64 "/%" PRIu64 ")\n",
 				    counts[i].val,
 				    (double)counts[i].run / (double)counts[i].ena * 100.0,
 				    counts[i].run, counts[i].ena);
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] libperf: Fix 32-bit build for tests uint64_t printf
  2022-02-01 21:39 [PATCH] libperf: Fix 32-bit build for tests uint64_t printf Rob Herring
@ 2022-02-01 23:58 ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 2+ messages in thread
From: Arnaldo Carvalho de Melo @ 2022-02-01 23:58 UTC (permalink / raw)
  To: Rob Herring
  Cc: Shunsuke Nakamura, Peter Zijlstra, Ingo Molnar, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Arnaldo Carvalho de Melo, linux-perf-users, linux-kernel

Em Tue, Feb 01, 2022 at 03:39:03PM -0600, Rob Herring escreveu:
> Commit a7f3713f6bf2 ("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.

I´ll apply this tomorrow and as well will check why the existing tests
aren't catching this :-\

Thanks!

- Arnaldo
 
> Fixes: a7f3713f6bf2 ("libperf tests: Add test_stat_multiplexing test")
> Cc: Shunsuke Nakamura <nakamura.shun@fujitsu.com>
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---
>  tools/lib/perf/tests/test-evlist.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/lib/perf/tests/test-evlist.c b/tools/lib/perf/tests/test-evlist.c
> index b3479dfa9a1c..fa854c83b7e7 100644
> --- a/tools/lib/perf/tests/test-evlist.c
> +++ b/tools/lib/perf/tests/test-evlist.c
> @@ -1,5 +1,6 @@
>  // SPDX-License-Identifier: GPL-2.0
>  #define _GNU_SOURCE // needed for sched.h to get sched_[gs]etaffinity and CPU_(ZERO,SET)
> +#include <inttypes.h>
>  #include <sched.h>
>  #include <stdio.h>
>  #include <stdarg.h>
> @@ -526,12 +527,12 @@ static int test_stat_multiplexing(void)
>  
>  	min = counts[0].val;
>  	for (i = 0; i < EVENT_NUM; i++) {
> -		__T_VERBOSE("Event %2d -- Raw count = %lu, run = %lu, enable = %lu\n",
> +		__T_VERBOSE("Event %2d -- Raw count = %" PRIu64 ", run = %" PRIu64 ", enable = %" PRIu64 "\n",
>  			    i, counts[i].val, counts[i].run, counts[i].ena);
>  
>  		perf_counts_values__scale(&counts[i], true, &scaled);
>  		if (scaled == 1) {
> -			__T_VERBOSE("\t Scaled count = %lu (%.2lf%%, %lu/%lu)\n",
> +			__T_VERBOSE("\t Scaled count = %" PRIu64 " (%.2lf%%, %" PRIu64 "/%" PRIu64 ")\n",
>  				    counts[i].val,
>  				    (double)counts[i].run / (double)counts[i].ena * 100.0,
>  				    counts[i].run, counts[i].ena);
> -- 
> 2.32.0

-- 

- Arnaldo

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-01 23:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-01 21:39 [PATCH] libperf: Fix 32-bit build for tests uint64_t printf Rob Herring
2022-02-01 23:58 ` Arnaldo Carvalho de Melo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).