Messages in this thread Patch in this message | | | Subject | [PATCH] perf: Fix time formatting for Y2038-compliant 32-bit architectures | From | Ben Hutchings <> | Date | Thu, 01 Oct 2015 01:44:51 +0100 |
| |
Fixes compiler errors such as this on x32:
builtin-stat.c: In function ‘print_interval’: builtin-stat.c:909:18: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘__time_t {aka long long int}’ [-Werror=format=] sprintf(prefix, "%6lu.%09lu%s", ts->tv_sec, ts->tv_nsec, csv_sep); ^
This isn't sufficient to make perf build for x32, but it gets us closer and helps to prepare for Y2038 support on other 32-bit architectures.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk> --- tools/perf/bench/sched-messaging.c | 6 +++--- tools/perf/bench/sched-pipe.c | 8 ++++---- tools/perf/builtin-kvm.c | 2 +- tools/perf/builtin-stat.c | 4 +++- 4 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/tools/perf/bench/sched-messaging.c b/tools/perf/bench/sched-messaging.c index d7f281c..f71c41d 100644 --- a/tools/perf/bench/sched-messaging.c +++ b/tools/perf/bench/sched-messaging.c @@ -310,12 +310,12 @@ int bench_sched_messaging(int argc, const char **argv, printf("# %d groups == %d %s run\n\n", num_groups, num_groups * 2 * num_fds, thread_mode ? "threads" : "processes"); - printf(" %14s: %lu.%03lu [sec]\n", "Total time", - diff.tv_sec, + printf(" %14s: %llu.%03lu [sec]\n", "Total time", + (unsigned long long) diff.tv_sec, (unsigned long) (diff.tv_usec/1000)); break; case BENCH_FORMAT_SIMPLE: - printf("%lu.%03lu\n", diff.tv_sec, + printf("%llu.%03lu\n", (unsigned long 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 005cc28..69ce697 100644 --- a/tools/perf/bench/sched-pipe.c +++ b/tools/perf/bench/sched-pipe.c @@ -156,8 +156,8 @@ int bench_sched_pipe(int argc, const char **argv, const char *prefix __maybe_unu result_usec = diff.tv_sec * 1000000; result_usec += diff.tv_usec; - printf(" %14s: %lu.%03lu [sec]\n\n", "Total time", - diff.tv_sec, + printf(" %14s: %llu.%03lu [sec]\n\n", "Total time", + (unsigned long long) diff.tv_sec, (unsigned long) (diff.tv_usec/1000)); printf(" %14lf usecs/op\n", @@ -168,8 +168,8 @@ int bench_sched_pipe(int argc, const char **argv, const char *prefix __maybe_unu break; case BENCH_FORMAT_SIMPLE: - printf("%lu.%03lu\n", - diff.tv_sec, + printf("%llu.%03lu\n", + (unsigned long 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 fc1cffb..26dff61 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, <ime)) { strftime(date, sizeof(date), "%H:%M:%S", <ime); - pr_info("%s.%06ld", date, tv.tv_usec); + pr_info("%s.%06lu", date, (unsigned 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 d46dbb1..fca784f 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -780,7 +780,9 @@ 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, "%6llu.%09lu%s", + (unsigned long long) ts->tv_sec, (unsigned long) ts->tv_nsec, + csv_sep); if (num_print_interval == 0 && !csv_output) { switch (stat_config.aggr_mode) { -- Ben Hutchings Knowledge is power. France is bacon.[unhandled content-type:application/pgp-signature] | |