Skip to content

Commit

Permalink
clockdiff: get rid of ctime_r
Browse files Browse the repository at this point in the history
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 <kerolasa@iki.fi>
Signed-off-by: Rosen Penev <rosenp@gmail.com>
  • Loading branch information
neheb authored and kerolasa committed May 25, 2020
1 parent 93dfb95 commit d6e1d77
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions clockdiff.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d6e1d77

Please sign in to comment.