2014-02-16 03:04:11

by Adam Borowski

[permalink] [raw]
Subject: [PATCH] perf: tools: fix missing casts for printf arguments.

Because of -Werror, they caused build failure at least on x32, as time_t
is of different size than "unsigned long". In another place, __suseconds_t
is not compatible with "long int".

Signed-off-by: Adam Borowski <[email protected]>
---
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 cc1190a..6595e2f 100644
--- a/tools/perf/bench/sched-messaging.c
+++ b/tools/perf/bench/sched-messaging.c
@@ -318,11 +318,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/1000));
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/1000));
break;
default:
diff --git a/tools/perf/bench/sched-pipe.c b/tools/perf/bench/sched-pipe.c
index 07a8d76..d7c1df4 100644
--- a/tools/perf/bench/sched-pipe.c
+++ b/tools/perf/bench/sched-pipe.c
@@ -157,7 +157,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/1000));

printf(" %14lf usecs/op\n",
@@ -169,7 +169,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 / 1000));
break;

diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index a735051..b470f0f 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -730,7 +730,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 int) 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 8b0e1c9..26cfc12 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -455,7 +455,8 @@ static void print_interval(void)

clock_gettime(CLOCK_MONOTONIC, &ts);
diff_timespec(&rs, &ts, &ref_time);
- sprintf(prefix, "%6lu.%09lu%s", rs.tv_sec, rs.tv_nsec, csv_sep);
+ sprintf(prefix, "%6lu.%09lu%s", (unsigned long) rs.tv_sec,
+ (unsigned long) rs.tv_nsec, csv_sep);

if (num_print_interval == 0 && !csv_output) {
switch (aggr_mode) {
--
1.9.0.rc3