diff options
author | наб <[email protected]> | 2022-04-04 13:59:48 +0200 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2022-04-05 09:45:33 -0700 |
commit | ae3683ce11153126ae0d03e89dccef96e21ccdf4 (patch) | |
tree | 7a218698aabcdfaceab4208b4c0b5b8cf6b83ff2 /lib/libspl | |
parent | 8ab279484f9987d26188782149dbed03c11ed1cd (diff) |
libspl: print_timestamp: use localtime_r()
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ahelenia Ziemiańska <[email protected]>
Closes #13284
Diffstat (limited to 'lib/libspl')
-rw-r--r-- | lib/libspl/timestamp.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/libspl/timestamp.c b/lib/libspl/timestamp.c index 22ecb3940..8d14ae645 100644 --- a/lib/libspl/timestamp.c +++ b/lib/libspl/timestamp.c @@ -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) @@ -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); } |