From 3ef87695dfe9685ded7fe44f45376294230525c8 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Fri, 18 Feb 2022 10:19:04 +0100 Subject: [PATCH] output: fix timestamp missing usecs On ARM 32bit with Musl `tv_usecs` is defined as `int64_t` which lead to CreateIsoTimeString() printing all zeros on the usecs. Work around this by first assigning to a `int64_t` and then updating the expected format string to accept `int64_t`. Bug: #5094. (cherry picked from commit a0c0471f1f51af0171ed5df1e2de0b900651bc19) --- src/util-time.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/util-time.c b/src/util-time.c index 6ea1aebd9e..afb42f7720 100644 --- a/src/util-time.c +++ b/src/util-time.c @@ -222,8 +222,9 @@ void CreateIsoTimeString (const struct timeval *ts, char *str, size_t size) WinStrftime(ts, t, str, size); #else char time_fmt[64] = { 0 }; - strftime(time_fmt, sizeof(time_fmt), "%Y-%m-%dT%H:%M:%S.%%06u%z", t); - snprintf(str, size, time_fmt, ts->tv_usec); + int64_t usec = ts->tv_usec; + strftime(time_fmt, sizeof(time_fmt), "%Y-%m-%dT%H:%M:%S.%%06" PRIi64 "%z", t); + snprintf(str, size, time_fmt, usec); #endif } else { snprintf(str, size, "ts-error"); -- 2.47.2