mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] perf: Fix time formatting for Y2038-compliant 32-bit architectures
@ 2015-10-01  0:44 Ben Hutchings
  0 siblings, 0 replies; only message in thread
From: Ben Hutchings @ 2015-10-01  0:44 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo; +Cc: linux-kernel, y2038

[-- Attachment #1: Type: text/plain, Size: 3767 bytes --]

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, &ltime)) {
 		strftime(date, sizeof(date), "%H:%M:%S", &ltime);
-		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.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-10-01  0:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-01  0:44 [PATCH] perf: Fix time formatting for Y2038-compliant 32-bit architectures Ben Hutchings

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®