lkml.org 
[lkml]   [2016]   [Oct]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/2] perf: cast some printf() arguments to fix x32 build
Date
Fix a few printf() format warnings regarding struct timeval fields on x32
(a.k.a AMD64 ILP32). As those warnings are treated as errors, they break
the build.

This fixes this kind of build warning:

bench/sched-pipe.c:160:20: error: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type '__time_t {aka long long int}' [-Werror=format=]
printf(" %14s: %lu.%03lu [sec]\n\n", "Total time",
^

Signed-off-by: Vincent Stehlé <vincent.stehle@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
---
tools/perf/bench/sched-messaging.c | 4 ++--
tools/perf/bench/sched-pipe.c | 4 ++--
tools/perf/builtin-kvm.c | 2 +-
tools/perf/builtin-stat.c | 3 ++-
4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/tools/perf/bench/sched-messaging.c b/tools/perf/bench/sched-messaging.c
index 6a111e77..7ad91c1 100644
--- a/tools/perf/bench/sched-messaging.c
+++ b/tools/perf/bench/sched-messaging.c
@@ -312,11 +312,11 @@ int bench_sched_messaging(int argc, const char **argv,
num_groups, num_groups * 2 * num_fds,
thread_mode ? "threads" : "processes");
printf(" %14s: %lu.%03lu [sec]\n", "Total time",
- diff.tv_sec,
+ (unsigned long) diff.tv_sec,
(unsigned long) (diff.tv_usec / USEC_PER_MSEC));
break;
case BENCH_FORMAT_SIMPLE:
- printf("%lu.%03lu\n", diff.tv_sec,
+ printf("%lu.%03lu\n", (unsigned long) diff.tv_sec,
(unsigned long) (diff.tv_usec / USEC_PER_MSEC));
break;
default:
diff --git a/tools/perf/bench/sched-pipe.c b/tools/perf/bench/sched-pipe.c
index 2243f01..62277fb 100644
--- a/tools/perf/bench/sched-pipe.c
+++ b/tools/perf/bench/sched-pipe.c
@@ -158,7 +158,7 @@ int bench_sched_pipe(int argc, const char **argv, const char *prefix __maybe_unu
result_usec += diff.tv_usec;

printf(" %14s: %lu.%03lu [sec]\n\n", "Total time",
- diff.tv_sec,
+ (unsigned long) diff.tv_sec,
(unsigned long) (diff.tv_usec / USEC_PER_MSEC));

printf(" %14lf usecs/op\n",
@@ -170,7 +170,7 @@ int bench_sched_pipe(int argc, const char **argv, const char *prefix __maybe_unu

case BENCH_FORMAT_SIMPLE:
printf("%lu.%03lu\n",
- diff.tv_sec,
+ (unsigned long) diff.tv_sec,
(unsigned long) (diff.tv_usec / USEC_PER_MSEC));
break;

diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 08fa88f..9a6489f 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -566,7 +566,7 @@ static void show_timeofday(void)
gettimeofday(&tv, NULL);
if (localtime_r(&tv.tv_sec, &ltime)) {
strftime(date, sizeof(date), "%H:%M:%S", &ltime);
- pr_info("%s.%06ld", date, tv.tv_usec);
+ pr_info("%s.%06ld", date, (long) tv.tv_usec);
} else
pr_info("00:00:00.000000");

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 688dea7..ab86bc6 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -1393,7 +1393,8 @@ static void print_interval(char *prefix, struct timespec *ts)
FILE *output = stat_config.output;
static int num_print_interval;

- sprintf(prefix, "%6lu.%09lu%s", ts->tv_sec, ts->tv_nsec, csv_sep);
+ sprintf(prefix, "%6lu.%09lu%s", (unsigned long) ts->tv_sec,
+ (unsigned long) ts->tv_nsec, csv_sep);

if (num_print_interval == 0 && !csv_output) {
switch (stat_config.aggr_mode) {
--
2.9.3
\
 
 \ /
  Last update: 2016-10-06 16:48    [W:0.031 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site