diff options
author | Mark Stapp <mjs@voltanet.io> | 2020-03-05 17:42:12 +0100 |
---|---|---|
committer | Mark Stapp <mjs@voltanet.io> | 2020-03-05 19:26:16 +0100 |
commit | a2700b5071e53a78be2f8098765dcca58c2b6ee5 (patch) | |
tree | e32654991ac297bd3917401ae429ee54da385e5e /bgpd/bgp_damp.c | |
parent | Merge pull request #5890 from mjstapp/zapi_allow_label_num (diff) | |
download | frr-a2700b5071e53a78be2f8098765dcca58c2b6ee5.tar.xz frr-a2700b5071e53a78be2f8098765dcca58c2b6ee5.zip |
*: use gmtime_r, localtime_r exclusively
Stop using gmtime() or localtime() everywhere.
Signed-off-by: Mark Stapp <mjs@voltanet.io>
Diffstat (limited to 'bgpd/bgp_damp.c')
-rw-r--r-- | bgpd/bgp_damp.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/bgpd/bgp_damp.c b/bgpd/bgp_damp.c index b0fee079d..792f3cea7 100644 --- a/bgpd/bgp_damp.c +++ b/bgpd/bgp_damp.c @@ -501,7 +501,7 @@ static const char *bgp_get_reuse_time(unsigned int penalty, char *buf, bool use_json, json_object *json) { time_t reuse_time = 0; - struct tm *tm = NULL; + struct tm tm; int time_store = 0; if (penalty > damp[afi][safi].reuse_limit) { @@ -513,7 +513,7 @@ static const char *bgp_get_reuse_time(unsigned int penalty, char *buf, if (reuse_time > damp[afi][safi].max_suppress_time) reuse_time = damp[afi][safi].max_suppress_time; - tm = gmtime(&reuse_time); + gmtime_r(&reuse_time, &tm); } else reuse_time = 0; @@ -525,39 +525,39 @@ static const char *bgp_get_reuse_time(unsigned int penalty, char *buf, snprintf(buf, len, "00:00:00"); } else if (reuse_time < ONE_DAY_SECOND) { if (use_json) { - time_store = (3600000 * tm->tm_hour) - + (60000 * tm->tm_min) - + (1000 * tm->tm_sec); + time_store = (3600000 * tm.tm_hour) + + (60000 * tm.tm_min) + + (1000 * tm.tm_sec); json_object_int_add(json, "reuseTimerMsecs", time_store); } else - 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 (reuse_time < ONE_WEEK_SECOND) { if (use_json) { - time_store = (86400000 * tm->tm_yday) - + (3600000 * tm->tm_hour) - + (60000 * tm->tm_min) - + (1000 * tm->tm_sec); + time_store = (86400000 * tm.tm_yday) + + (3600000 * tm.tm_hour) + + (60000 * tm.tm_min) + + (1000 * tm.tm_sec); json_object_int_add(json, "reuseTimerMsecs", time_store); } else - 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 { if (use_json) { time_store = - (604800000 * tm->tm_yday / 7) + (604800000 * tm.tm_yday / 7) + (86400000 - * (tm->tm_yday - ((tm->tm_yday / 7) * 7))) - + (3600000 * tm->tm_hour) + (60000 * tm->tm_min) - + (1000 * tm->tm_sec); + * (tm.tm_yday - ((tm.tm_yday / 7) * 7))) + + (3600000 * tm.tm_hour) + (60000 * tm.tm_min) + + (1000 * tm.tm_sec); json_object_int_add(json, "reuseTimerMsecs", time_store); } 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; |