]> git.proxmox.com Git - mirror_frr.git/blobdiff - ripngd/ripng_peer.c
*: use gmtime_r, localtime_r exclusively
[mirror_frr.git] / ripngd / ripng_peer.c
index 109524e2129091f51c5977f07bffaadcd4be65f7..c038bfccf021794fb4d3e29ee0128d72379cfcba 100644 (file)
@@ -141,7 +141,7 @@ void ripng_peer_bad_packet(struct ripng *ripng, struct sockaddr_in6 *from)
 static char *ripng_peer_uptime(struct ripng_peer *peer, char *buf, size_t len)
 {
        time_t uptime;
-       struct tm *tm;
+       struct tm tm;
 
        /* If there is no connection has been done before print `never'. */
        if (peer->uptime == 0) {
@@ -152,17 +152,17 @@ static char *ripng_peer_uptime(struct ripng_peer *peer, char *buf, size_t len)
        /* Get current time. */
        uptime = time(NULL);
        uptime -= peer->uptime;
-       tm = gmtime(&uptime);
+       gmtime_r(&uptime, &tm);
 
        if (uptime < ONE_DAY_SECOND)
-               snprintf(buf, len, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min,
-                        tm->tm_sec);
+               snprintf(buf, len, "%02d:%02d:%02d", tm.tm_hour, tm.tm_min,
+                        tm.tm_sec);
        else if (uptime < ONE_WEEK_SECOND)
-               snprintf(buf, len, "%dd%02dh%02dm", tm->tm_yday, tm->tm_hour,
-                        tm->tm_min);
+               snprintf(buf, len, "%dd%02dh%02dm", tm.tm_yday, tm.tm_hour,
+                        tm.tm_min);
        else
-               snprintf(buf, len, "%02dw%dd%02dh", tm->tm_yday / 7,
-                        tm->tm_yday - ((tm->tm_yday / 7) * 7), tm->tm_hour);
+               snprintf(buf, len, "%02dw%dd%02dh", tm.tm_yday / 7,
+                        tm.tm_yday - ((tm.tm_yday / 7) * 7), tm.tm_hour);
        return buf;
 }