From 9185303b32b370762f12d405b6752166bb5ced47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Mon, 4 Apr 2022 14:07:26 +0200 Subject: [PATCH] libspl: zed: event: use localtime_r() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Brian Behlendorf Signed-off-by: Ahelenia ZiemiaƄska Closes #13284 --- cmd/zed/zed_event.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/zed/zed_event.c b/cmd/zed/zed_event.c index 9eaad0e92f..d5cafdaff0 100644 --- a/cmd/zed/zed_event.c +++ b/cmd/zed/zed_event.c @@ -884,21 +884,21 @@ _zed_event_get_subclass(const char *class) static void _zed_event_add_time_strings(uint64_t eid, zed_strings_t *zsp, int64_t etime[]) { - struct tm *stp; + struct tm stp; char buf[32]; assert(zsp != NULL); assert(etime != NULL); _zed_event_add_var(eid, zsp, ZEVENT_VAR_PREFIX, "TIME_SECS", - "%lld", (long long int) etime[0]); + "%" PRId64, etime[0]); _zed_event_add_var(eid, zsp, ZEVENT_VAR_PREFIX, "TIME_NSECS", - "%lld", (long long int) etime[1]); + "%" PRId64, etime[1]); - if (!(stp = localtime((const time_t *) &etime[0]))) { + if (!localtime_r((const time_t *) &etime[0], &stp)) { zed_log_msg(LOG_WARNING, "Failed to add %s%s for eid=%llu: %s", ZEVENT_VAR_PREFIX, "TIME_STRING", eid, "localtime error"); - } else if (!strftime(buf, sizeof (buf), "%Y-%m-%d %H:%M:%S%z", stp)) { + } else if (!strftime(buf, sizeof (buf), "%Y-%m-%d %H:%M:%S%z", &stp)) { zed_log_msg(LOG_WARNING, "Failed to add %s%s for eid=%llu: %s", ZEVENT_VAR_PREFIX, "TIME_STRING", eid, "strftime error"); } else {