summaryrefslogtreecommitdiffstats
path: root/ripd
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@users.noreply.github.com>2020-03-05 23:38:13 +0100
committerGitHub <noreply@github.com>2020-03-05 23:38:13 +0100
commit5d2724ec2564b648bf93dc7b164a1398cde3c214 (patch)
tree92976c12468fcce1c582152d059e4bb4b0514e5d /ripd
parentMerge pull request #5918 from ton31337/fix/__func__everywhere (diff)
parent*: use gmtime_r, localtime_r exclusively (diff)
downloadfrr-5d2724ec2564b648bf93dc7b164a1398cde3c214.tar.xz
frr-5d2724ec2564b648bf93dc7b164a1398cde3c214.zip
Merge pull request #5916 from mjstapp/fix_gmtime
*: use gmtime_r exclusively
Diffstat (limited to 'ripd')
-rw-r--r--ripd/rip_peer.c16
-rw-r--r--ripd/ripd.c10
2 files changed, 13 insertions, 13 deletions
diff --git a/ripd/rip_peer.c b/ripd/rip_peer.c
index 4ad7309c4..55dafd7c1 100644
--- a/ripd/rip_peer.c
+++ b/ripd/rip_peer.c
@@ -131,7 +131,7 @@ void rip_peer_bad_packet(struct rip *rip, struct sockaddr_in *from)
static char *rip_peer_uptime(struct rip_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) {
@@ -142,17 +142,17 @@ static char *rip_peer_uptime(struct rip_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;
}
diff --git a/ripd/ripd.c b/ripd/ripd.c
index 5ccefac17..5009b788f 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -3020,20 +3020,20 @@ void rip_ecmp_disable(struct rip *rip)
static void rip_vty_out_uptime(struct vty *vty, struct rip_info *rinfo)
{
time_t clock;
- struct tm *tm;
+ struct tm tm;
#define TIME_BUF 25
char timebuf[TIME_BUF];
struct thread *thread;
if ((thread = rinfo->t_timeout) != NULL) {
clock = thread_timer_remain_second(thread);
- tm = gmtime(&clock);
- strftime(timebuf, TIME_BUF, "%M:%S", tm);
+ gmtime_r(&clock, &tm);
+ strftime(timebuf, TIME_BUF, "%M:%S", &tm);
vty_out(vty, "%5s", timebuf);
} else if ((thread = rinfo->t_garbage_collect) != NULL) {
clock = thread_timer_remain_second(thread);
- tm = gmtime(&clock);
- strftime(timebuf, TIME_BUF, "%M:%S", tm);
+ gmtime_r(&clock, &tm);
+ strftime(timebuf, TIME_BUF, "%M:%S", &tm);
vty_out(vty, "%5s", timebuf);
}
}