]> git.puffer.fish Git - mirror/frr.git/commitdiff
*: Use proper semantics for turning off thread 7283/head
authorDonald Sharp <sharpd@nvidia.com>
Mon, 12 Oct 2020 12:35:18 +0000 (08:35 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Mon, 12 Oct 2020 12:35:18 +0000 (08:35 -0400)
We have this pattern in the code base:

if (thread)
THREAD_OFF(thread);

If we look at THREAD_OFF we check to see if thread
is non-null too.  So we have a double check.
This is unnecessary.  Convert to just using THREAD_OFF

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
bgpd/bgp_fsm.h
bgpd/bgp_routemap.c
bgpd/bgp_updgrp.c
eigrpd/eigrp_interface.c
isisd/isis_ldp_sync.c
lib/ldp_sync.c
lib/spf_backoff.c
ospfd/ospf_ldp_sync.c
pimd/pim_bsm.c
pimd/pim_igmp.c
watchfrr/watchfrr.c

index 85c0eccc26371627251d6809ba7284dd4602874c..aa98515c3f041c386029d1ad41da6e4f8686737b 100644 (file)
@@ -31,8 +31,7 @@
 
 #define BGP_TIMER_OFF(T)                                                       \
        do {                                                                   \
-               if (T)                                                         \
-                       THREAD_TIMER_OFF(T);                                   \
+               THREAD_TIMER_OFF(T);                                           \
        } while (0)
 
 #define BGP_EVENT_ADD(P, E)                                                    \
index 09cc775d479550aa4120babb731fc0b7fc79297e..968cda3f100261735a4acb053c4c16d1fb4487d8 100644 (file)
@@ -3960,8 +3960,7 @@ static void bgp_route_map_mark_update(const char *rmap_name)
        /* If new update is received before the current timer timed out,
         * turn it off and start a new timer.
         */
-       if (bm->t_rmap_update != NULL)
-               THREAD_OFF(bm->t_rmap_update);
+       THREAD_OFF(bm->t_rmap_update);
 
        /* rmap_update_timer of 0 means don't do route updates */
        if (bm->rmap_update_timer) {
index d2e563b23700266dd7ff8d19b5d6729bbe7bf580..1685f98181978bc1413213d6551886961772638c 100644 (file)
@@ -795,17 +795,14 @@ static void update_subgroup_delete(struct update_subgroup *subgrp)
        if (subgrp->update_group)
                UPDGRP_INCR_STAT(subgrp->update_group, subgrps_deleted);
 
-       if (subgrp->t_merge_check)
-               THREAD_OFF(subgrp->t_merge_check);
+       THREAD_OFF(subgrp->t_merge_check);
 
-       if (subgrp->t_coalesce)
-               THREAD_TIMER_OFF(subgrp->t_coalesce);
+       THREAD_TIMER_OFF(subgrp->t_coalesce);
 
        bpacket_queue_cleanup(SUBGRP_PKTQ(subgrp));
        subgroup_clear_table(subgrp);
 
-       if (subgrp->t_coalesce)
-               THREAD_TIMER_OFF(subgrp->t_coalesce);
+       THREAD_TIMER_OFF(subgrp->t_coalesce);
        sync_delete(subgrp);
 
        if (BGP_DEBUG(update_groups, UPDATE_GROUPS) && subgrp->update_group)
index 9ef4e8623702ca3e46d92e5862711d51c9aeecef..2f3f3474236747fe5447046fdd89341dac2403d6 100644 (file)
@@ -331,8 +331,7 @@ int eigrp_if_down(struct eigrp_interface *ei)
                return 0;
 
        /* Shutdown packet reception and sending */
-       if (ei->t_hello)
-               THREAD_OFF(ei->t_hello);
+       THREAD_OFF(ei->t_hello);
 
        eigrp_if_stream_unset(ei);
 
index c15b59a8cf51b08329d2631b388656d17d52af30..8360dfc59ea9233dfb06227e8fd4aac274d4d057 100644 (file)
@@ -300,10 +300,7 @@ void isis_ldp_sync_ldp_fail(struct isis_circuit *circuit)
        if (ldp_sync_info &&
            ldp_sync_info->enabled == LDP_IGP_SYNC_ENABLED &&
            ldp_sync_info->state != LDP_IGP_SYNC_STATE_NOT_REQUIRED) {
-               if (ldp_sync_info->t_holddown != NULL) {
-                       THREAD_TIMER_OFF(ldp_sync_info->t_holddown);
-                       ldp_sync_info->t_holddown = NULL;
-               }
+               THREAD_TIMER_OFF(ldp_sync_info->t_holddown);
                ldp_sync_info->state = LDP_IGP_SYNC_STATE_REQUIRED_NOT_UP;
                isis_ldp_sync_set_if_metric(circuit, true);
        }
@@ -326,8 +323,7 @@ void isis_ldp_sync_if_remove(struct isis_circuit *circuit, bool remove)
        ils_debug("ldp_sync: remove if %s", circuit->interface
                  ? circuit->interface->name : "");
 
-       if (ldp_sync_info->t_holddown)
-               THREAD_TIMER_OFF(ldp_sync_info->t_holddown);
+       THREAD_TIMER_OFF(ldp_sync_info->t_holddown);
        ldp_sync_info->state = LDP_IGP_SYNC_STATE_NOT_REQUIRED;
        isis_ldp_sync_set_if_metric(circuit, true);
        if (remove) {
index 5dd045d88d85538d34c2aeffd9c085a71dbc46f6..9657f0b1dfa9f1020ec98c8767579bc2d1a2b5a3 100644 (file)
@@ -79,10 +79,8 @@ bool ldp_sync_if_down(struct ldp_sync_info *ldp_sync_info)
         *   update state
         */
        if (ldp_sync_info && ldp_sync_info->enabled == LDP_IGP_SYNC_ENABLED) {
-               if (ldp_sync_info->t_holddown != NULL) {
-                       THREAD_TIMER_OFF(ldp_sync_info->t_holddown);
-                       ldp_sync_info->t_holddown = NULL;
-               }
+               THREAD_TIMER_OFF(ldp_sync_info->t_holddown);
+
                if (ldp_sync_info->state == LDP_IGP_SYNC_STATE_REQUIRED_UP)
                        ldp_sync_info->state =
                                LDP_IGP_SYNC_STATE_REQUIRED_NOT_UP;
index 4e747144892adcb666f1eea80fdf269118cf6775..acb208e5e73111fa2baa8471419c401ae2eff19f 100644 (file)
@@ -132,7 +132,6 @@ static int spf_backoff_holddown_elapsed(struct thread *thread)
 {
        struct spf_backoff *backoff = THREAD_ARG(thread);
 
-       backoff->t_holddown = NULL;
        THREAD_TIMER_OFF(backoff->t_timetolearn);
        timerclear(&backoff->first_event_time);
        backoff->state = SPF_BACKOFF_QUIET;
index cdb0eae2c40eb499a8d7a367c7a9e68bb6faa510..96fa04b5886d6a2de8808026476030f5a1bfefe3 100644 (file)
@@ -274,10 +274,7 @@ void ospf_ldp_sync_ldp_fail(struct interface *ifp)
        if (ldp_sync_info &&
            ldp_sync_info->enabled == LDP_IGP_SYNC_ENABLED &&
            ldp_sync_info->state != LDP_IGP_SYNC_STATE_NOT_REQUIRED) {
-               if (ldp_sync_info->t_holddown != NULL) {
-                       THREAD_TIMER_OFF(ldp_sync_info->t_holddown);
-                       ldp_sync_info->t_holddown = NULL;
-               }
+               THREAD_TIMER_OFF(ldp_sync_info->t_holddown);
                ldp_sync_info->state = LDP_IGP_SYNC_STATE_REQUIRED_NOT_UP;
                ospf_if_recalculate_output_cost(ifp);
        }
@@ -340,8 +337,7 @@ void ospf_ldp_sync_if_remove(struct interface *ifp, bool remove)
         *  restore cost
         */
        ols_debug("ldp_sync: Removed from if %s", ifp->name);
-       if (ldp_sync_info->t_holddown)
-               THREAD_TIMER_OFF(ldp_sync_info->t_holddown);
+       THREAD_TIMER_OFF(ldp_sync_info->t_holddown);
        ldp_sync_info->state = LDP_IGP_SYNC_STATE_NOT_REQUIRED;
        ospf_if_recalculate_output_cost(ifp);
        if (!CHECK_FLAG(ldp_sync_info->flags, LDP_SYNC_FLAG_IF_CONFIG))
index 1c9005588fe08ea7dce4f8817f05fa0b728805fc..f542b2eafaff0039e3cde20803578650a0f465cd 100644 (file)
@@ -117,8 +117,7 @@ static int pim_g2rp_list_compare(struct bsm_rpinfo *node1,
 
 static void pim_free_bsrp_node(struct bsm_rpinfo *bsrp_info)
 {
-       if (bsrp_info->g2rp_timer)
-               THREAD_OFF(bsrp_info->g2rp_timer);
+       THREAD_OFF(bsrp_info->g2rp_timer);
        XFREE(MTYPE_PIM_BSRP_NODE, bsrp_info);
 }
 
index 04ece6dbb0d85787675de4fc28affa6de53e5b0e..d4d47377bdb87246cfe3c38f25845e2205d05525 100644 (file)
@@ -804,9 +804,7 @@ void igmp_group_delete(struct igmp_group *group)
                igmp_source_delete(src);
        }
 
-       if (group->t_group_query_retransmit_timer) {
-               THREAD_OFF(group->t_group_query_retransmit_timer);
-       }
+       THREAD_OFF(group->t_group_query_retransmit_timer);
 
        group_timer_off(group);
        igmp_group_count_decr(group->group_igmp_sock);
index d1003ad5fac38785672e54710b57a66daa27b380..af243f7ca57f52110ffa8ac1305402be3af6db8e 100644 (file)
@@ -585,8 +585,7 @@ static void restart_done(struct daemon *dmn)
                        dmn->name, state_str[dmn->state]);
                return;
        }
-       if (dmn->t_wakeup)
-               THREAD_OFF(dmn->t_wakeup);
+       THREAD_OFF(dmn->t_wakeup);
        if (try_connect(dmn) < 0)
                SET_WAKEUP_DOWN(dmn);
 }