From: Bart Van Assche Date: Mon, 12 Mar 2018 21:16:56 +0000 (-0700) Subject: stat: Fix a compiler warning in __show_run_stats() X-Git-Tag: fio-3.6~42^2~1 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=afd74e2aed65786b07daefb67b334c149f584e01 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 --- 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';