]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd, ldpd: No need for an explicit NULL check for thread_timer_remain_second
authorDonatas Abraitis <donatas@opensourcerouting.org>
Mon, 18 Jul 2022 13:42:23 +0000 (16:42 +0300)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Mon, 18 Jul 2022 13:44:06 +0000 (16:44 +0300)
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
bgpd/rfapi/rfapi_monitor.c
bgpd/rfapi/rfapi_vty.c
ldpd/adjacency.c
ldpd/interface.c
ldpd/neighbor.c

index 58a0f8dea7ca51c9ac78a1598f9230311d4b501b..8529676118c3042948ebbf4a001b569134990ab0 100644 (file)
@@ -744,19 +744,17 @@ static void rfapiMonitorTimerExpire(struct thread *t)
 
 static void rfapiMonitorTimerRestart(struct rfapi_monitor_vpn *m)
 {
-       if (m->timer) {
-               unsigned long remain = thread_timer_remain_second(m->timer);
+       unsigned long remain = thread_timer_remain_second(m->timer);
 
-               /* unexpected case, but avoid wraparound problems below */
-               if (remain > m->rfd->response_lifetime)
-                       return;
+       /* unexpected case, but avoid wraparound problems below */
+       if (remain > m->rfd->response_lifetime)
+               return;
 
-               /* don't restart if we just restarted recently */
-               if (m->rfd->response_lifetime - remain < 2)
-                       return;
+       /* don't restart if we just restarted recently */
+       if (m->rfd->response_lifetime - remain < 2)
+               return;
 
-               thread_cancel(&m->timer);
-       }
+       THREAD_OFF(m->timer);
 
        {
                char buf[BUFSIZ];
@@ -766,7 +764,7 @@ static void rfapiMonitorTimerRestart(struct rfapi_monitor_vpn *m)
                        rfapi_ntop(m->p.family, m->p.u.val, buf, BUFSIZ),
                        m->rfd->response_lifetime);
        }
-       m->timer = NULL;
+
        thread_add_timer(bm->master, rfapiMonitorTimerExpire, m,
                         m->rfd->response_lifetime, &m->timer);
 }
@@ -1054,19 +1052,17 @@ static void rfapiMonitorEthTimerExpire(struct thread *t)
 
 static void rfapiMonitorEthTimerRestart(struct rfapi_monitor_eth *m)
 {
-       if (m->timer) {
-               unsigned long remain = thread_timer_remain_second(m->timer);
+       unsigned long remain = thread_timer_remain_second(m->timer);
 
-               /* unexpected case, but avoid wraparound problems below */
-               if (remain > m->rfd->response_lifetime)
-                       return;
+       /* unexpected case, but avoid wraparound problems below */
+       if (remain > m->rfd->response_lifetime)
+               return;
 
-               /* don't restart if we just restarted recently */
-               if (m->rfd->response_lifetime - remain < 2)
-                       return;
+       /* don't restart if we just restarted recently */
+       if (m->rfd->response_lifetime - remain < 2)
+               return;
 
-               thread_cancel(&m->timer);
-       }
+       THREAD_OFF(m->timer);
 
        {
                char buf[BUFSIZ];
@@ -1076,7 +1072,7 @@ static void rfapiMonitorEthTimerRestart(struct rfapi_monitor_eth *m)
                        rfapiEthAddr2Str(&m->macaddr, buf, BUFSIZ),
                        m->rfd->response_lifetime);
        }
-       m->timer = NULL;
+
        thread_add_timer(bm->master, rfapiMonitorEthTimerExpire, m,
                         m->rfd->response_lifetime, &m->timer);
 }
index b95bace0d155590c1270344a04d48c1b14db28f7..d50da2bf3943b426c434f51b4c8be07cd9de5d8b 100644 (file)
@@ -928,12 +928,9 @@ int rfapiShowVncQueries(void *stream, struct prefix *pfx_match)
                                } else
                                        fp(out, "%-15s %-15s", "", "");
                                buf_remain[0] = 0;
-                               if (m->timer) {
-                                       rfapiFormatSeconds(
-                                               thread_timer_remain_second(
-                                                       m->timer),
-                                               buf_remain, BUFSIZ);
-                               }
+                               rfapiFormatSeconds(
+                                       thread_timer_remain_second(m->timer),
+                                       buf_remain, BUFSIZ);
                                fp(out, " %-15s %-10s\n",
                                   inet_ntop(m->p.family, &m->p.u.prefix,
                                             buf_pfx, BUFSIZ),
@@ -1005,12 +1002,9 @@ int rfapiShowVncQueries(void *stream, struct prefix *pfx_match)
                                } else
                                        fp(out, "%-15s %-15s", "", "");
                                buf_remain[0] = 0;
-                               if (mon_eth->timer) {
-                                       rfapiFormatSeconds(
-                                               thread_timer_remain_second(
-                                                       mon_eth->timer),
-                                               buf_remain, BUFSIZ);
-                               }
+                               rfapiFormatSeconds(thread_timer_remain_second(
+                                                          mon_eth->timer),
+                                                  buf_remain, BUFSIZ);
                                fp(out, " %-17s %10d %-10s\n",
                                   rfapi_ntop(pfx_mac.family, &pfx_mac.u.prefix,
                                              buf_pfx, BUFSIZ),
index 7eb5663492437cb21569d94f10fe334cef7c4dfe..04a24242dccb074439e0f86d687760a96ec073f1 100644 (file)
@@ -386,9 +386,7 @@ adj_to_ctl(struct adj *adj)
        }
        actl.holdtime = adj->holdtime;
        actl.holdtime_remaining =
-               thread_is_scheduled(adj->inactivity_timer)
-                       ? thread_timer_remain_second(adj->inactivity_timer)
-                       : 0;
+               thread_timer_remain_second(adj->inactivity_timer);
        actl.trans_addr = adj->trans_addr;
        actl.ds_tlv = adj->ds_tlv;
 
index af6e8fd7ecbf9585799f39b00bcd8ae11d2e0dce..ddf6c395ae42f7517cf7fd0fec9cf90e785e3f73 100644 (file)
@@ -543,11 +543,8 @@ ldp_sync_to_ctl(struct iface *iface)
        ictl.wait_time = if_get_wait_for_sync_interval();
        ictl.timer_running = iface->ldp_sync.wait_for_sync_timer ? true : false;
 
-       if (iface->ldp_sync.wait_for_sync_timer)
-               ictl.wait_time_remaining =
+       ictl.wait_time_remaining =
                thread_timer_remain_second(iface->ldp_sync.wait_for_sync_timer);
-       else
-               ictl.wait_time_remaining = 0;
 
        memset(&ictl.peer_ldp_id, 0, sizeof(ictl.peer_ldp_id));
 
index 867ad92e474ee8e6eb6764a653f9059508349d62..514bcee32be7d76f31bd8a0eab5e782698823383 100644 (file)
@@ -847,11 +847,8 @@ nbr_to_ctl(struct nbr *nbr)
        nctl.stats = nbr->stats;
        nctl.flags = nbr->flags;
        nctl.max_pdu_len = nbr->max_pdu_len;
-       if (nbr->keepalive_timer)
-               nctl.hold_time_remaining =
-                   thread_timer_remain_second(nbr->keepalive_timer);
-       else
-               nctl.hold_time_remaining = 0;
+       nctl.hold_time_remaining =
+               thread_timer_remain_second(nbr->keepalive_timer);
 
        gettimeofday(&now, NULL);
        if (nbr->state == NBR_STA_OPER) {