From d6e1d77dd27f8beba0f35f71427da6df33cb38f9 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sun, 12 Apr 2020 22:02:43 -0700 Subject: [PATCH] clockdiff: get rid of ctime_r The ctime_r is deprecated. The function also unsafe to use, see the reference link for details. Reference: https://git.musl-libc.org/cgit/musl/tree/src/time/asctime_r.c#n16 Reviewed-by; Sami Kerola Signed-off-by: Rosen Penev --- clockdiff.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/clockdiff.c b/clockdiff.c index 46bb4b21..911c192d 100644 --- a/clockdiff.c +++ b/clockdiff.c @@ -608,13 +608,13 @@ int main(int argc, char **argv) if (ctl.interactive) { char s[32]; + struct tm tm; + localtime_r(&now, &tm); if (ctl.time_format == time_format_iso) { - struct tm tm; - localtime_r(&now, &tm); strftime(s, sizeof(s), "%Y-%m-%dT%H:%M:%S%z\n", &tm); } else - ctime_r(&now, s); + strftime(s, sizeof(s), "%a %b %e %H:%M:%S %Y", &tm); printf(_("\nhost=%s rtt=%ld(%ld)ms/%ldms delta=%dms/%dms %s"), ctl.hisname, ctl.rtt, ctl.rtt_sigma, ctl.min_rtt, ctl.measure_delta, ctl.measure_delta1, s);