Skip to content

Commit

Permalink
libspl: print_timestamp: 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 2eda086 commit d72b66e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/libspl/timestamp.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void
print_timestamp(uint_t timestamp_fmt)
{
time_t t = time(NULL);
static char *fmt = NULL;
static const char *fmt = NULL;

/* We only need to retrieve this once per invocation */
if (fmt == NULL)
Expand All @@ -54,9 +54,10 @@ print_timestamp(uint_t timestamp_fmt)
(void) printf("%lld\n", (longlong_t)t);
} else if (timestamp_fmt == DDATE) {
char dstr[64];
struct tm tm;
int len;

len = strftime(dstr, sizeof (dstr), fmt, localtime(&t));
len = strftime(dstr, sizeof (dstr), fmt, localtime_r(&t, &tm));
if (len > 0)
(void) printf("%s\n", dstr);
}
Expand Down

0 comments on commit d72b66e

Please sign in to comment.