From afd74e2aed65786b07daefb67b334c149f584e01 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 12 Mar 2018 14:16:56 -0700 Subject: [PATCH] stat: Fix a compiler warning in __show_run_stats() Avoid that gcc reports the following warning on NetBSD systems: CC stat.o stat.c: In function '__show_run_stats': stat.c:1868: warning: dereferencing type-punned pointer will break strict-aliasing rules Signed-off-by: Bart Van Assche --- stat.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stat.c b/stat.c index f89913ba..8a242c97 100644 --- a/stat.c +++ b/stat.c @@ -1860,13 +1860,14 @@ void __show_run_stats(void) char time_buf[32]; struct timeval now; unsigned long long ms_since_epoch; + time_t tv_sec; gettimeofday(&now, NULL); ms_since_epoch = (unsigned long long)(now.tv_sec) * 1000 + (unsigned long long)(now.tv_usec) / 1000; - os_ctime_r((const time_t *) &now.tv_sec, time_buf, - sizeof(time_buf)); + tv_sec = now.tv_sec; + os_ctime_r(&tv_sec, time_buf, sizeof(time_buf)); if (time_buf[strlen(time_buf) - 1] == '\n') time_buf[strlen(time_buf) - 1] = '\0'; -- 2.25.1