btrfs-progs: send dump: use reentrant variant of localtime
authorDavid Sterba <dsterba@suse.com>
Mon, 7 Nov 2016 11:00:28 +0000 (12:00 +0100)
committerDavid Sterba <dsterba@suse.com>
Wed, 14 Dec 2016 14:06:34 +0000 (15:06 +0100)
Signed-off-by: David Sterba <dsterba@suse.com>
send-dump.c

index 064c914..4c44246 100644 (file)
@@ -271,16 +271,15 @@ static int print_chown(const char *path, u64 uid, u64 gid, void *user)
 
 static int sprintf_timespec(struct timespec *ts, char *dest, int max_size)
 {
-       struct tm *tm;
+       struct tm tm;
        int ret;
 
-       tm = localtime(&ts->tv_sec);
-       if (!tm) {
+       if (!localtime_r(&ts->tv_sec, &tm)) {
                error("failed to convert time %lld.%.9ld to local time",
                      (long long)ts->tv_sec, ts->tv_nsec);
                return -EINVAL;
        }
-       ret = strftime(dest, max_size, "%FT%T%z", tm);
+       ret = strftime(dest, max_size, "%FT%T%z", &tm);
        if (ret == 0) {
                error(
                "time %lld.%ld is too long to convert into readable string",