libzfs: sendrecv: send_progress_thread: use localtime_r()

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13284
This commit is contained in:
наб 2022-04-04 13:56:16 +02:00 committed by Brian Behlendorf
parent d5036491e6
commit 8ab279484f
1 changed files with 6 additions and 6 deletions

View File

@ -910,7 +910,7 @@ send_progress_thread(void *arg)
uint64_t blocks; uint64_t blocks;
char buf[16]; char buf[16];
time_t t; time_t t;
struct tm *tm; struct tm tm;
int err; int err;
if (!pa->pa_parsable) { if (!pa->pa_parsable) {
@ -934,28 +934,28 @@ send_progress_thread(void *arg)
} }
(void) time(&t); (void) time(&t);
tm = localtime(&t); localtime_r(&t, &tm);
if (pa->pa_verbosity >= 2 && pa->pa_parsable) { if (pa->pa_verbosity >= 2 && pa->pa_parsable) {
(void) fprintf(stderr, (void) fprintf(stderr,
"%02d:%02d:%02d\t%llu\t%llu\t%s\n", "%02d:%02d:%02d\t%llu\t%llu\t%s\n",
tm->tm_hour, tm->tm_min, tm->tm_sec, tm.tm_hour, tm.tm_min, tm.tm_sec,
(u_longlong_t)bytes, (u_longlong_t)blocks, (u_longlong_t)bytes, (u_longlong_t)blocks,
zhp->zfs_name); zhp->zfs_name);
} else if (pa->pa_verbosity >= 2) { } else if (pa->pa_verbosity >= 2) {
zfs_nicenum(bytes, buf, sizeof (buf)); zfs_nicenum(bytes, buf, sizeof (buf));
(void) fprintf(stderr, (void) fprintf(stderr,
"%02d:%02d:%02d %5s %8llu %s\n", "%02d:%02d:%02d %5s %8llu %s\n",
tm->tm_hour, tm->tm_min, tm->tm_sec, tm.tm_hour, tm.tm_min, tm.tm_sec,
buf, (u_longlong_t)blocks, zhp->zfs_name); buf, (u_longlong_t)blocks, zhp->zfs_name);
} else if (pa->pa_parsable) { } else if (pa->pa_parsable) {
(void) fprintf(stderr, "%02d:%02d:%02d\t%llu\t%s\n", (void) fprintf(stderr, "%02d:%02d:%02d\t%llu\t%s\n",
tm->tm_hour, tm->tm_min, tm->tm_sec, tm.tm_hour, tm.tm_min, tm.tm_sec,
(u_longlong_t)bytes, zhp->zfs_name); (u_longlong_t)bytes, zhp->zfs_name);
} else { } else {
zfs_nicebytes(bytes, buf, sizeof (buf)); zfs_nicebytes(bytes, buf, sizeof (buf));
(void) fprintf(stderr, "%02d:%02d:%02d %5s %s\n", (void) fprintf(stderr, "%02d:%02d:%02d %5s %s\n",
tm->tm_hour, tm->tm_min, tm->tm_sec, tm.tm_hour, tm.tm_min, tm.tm_sec,
buf, zhp->zfs_name); buf, zhp->zfs_name);
} }
} }