Skip to content

Commit

Permalink
libspl: zed: event: use localtime_r()
Browse files Browse the repository at this point in the history
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ahelenia Ziemiańska <[email protected]>
Closes openzfs#13284
  • Loading branch information
nabijaczleweli authored and andrewc12 committed Sep 23, 2022
1 parent 8dd8d82 commit 8152fef
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cmd/zed/zed_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 8152fef

Please sign in to comment.