*: Use proper semantics for turning off thread

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>
This commit is contained in:
Donald Sharp 2020-10-12 08:35:18 -04:00
parent 8b6b6b694d
commit 28ef0ee121
11 changed files with 15 additions and 36 deletions

View file

@ -31,7 +31,6 @@
#define BGP_TIMER_OFF(T) \
do { \
if (T) \
THREAD_TIMER_OFF(T); \
} while (0)

View file

@ -3960,7 +3960,6 @@ 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);
/* rmap_update_timer of 0 means don't do route updates */

View file

@ -795,16 +795,13 @@ 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);
if (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);
sync_delete(subgrp);

View file

@ -331,7 +331,6 @@ int eigrp_if_down(struct eigrp_interface *ei)
return 0;
/* Shutdown packet reception and sending */
if (ei->t_hello)
THREAD_OFF(ei->t_hello);
eigrp_if_stream_unset(ei);

View 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;
}
ldp_sync_info->state = LDP_IGP_SYNC_STATE_REQUIRED_NOT_UP;
isis_ldp_sync_set_if_metric(circuit, true);
}
@ -326,7 +323,6 @@ 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);
ldp_sync_info->state = LDP_IGP_SYNC_STATE_NOT_REQUIRED;
isis_ldp_sync_set_if_metric(circuit, true);

View 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;
}
if (ldp_sync_info->state == LDP_IGP_SYNC_STATE_REQUIRED_UP)
ldp_sync_info->state =
LDP_IGP_SYNC_STATE_REQUIRED_NOT_UP;

View 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;

View 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;
}
ldp_sync_info->state = LDP_IGP_SYNC_STATE_REQUIRED_NOT_UP;
ospf_if_recalculate_output_cost(ifp);
}
@ -340,7 +337,6 @@ 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);
ldp_sync_info->state = LDP_IGP_SYNC_STATE_NOT_REQUIRED;
ospf_if_recalculate_output_cost(ifp);

View file

@ -117,7 +117,6 @@ 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);
XFREE(MTYPE_PIM_BSRP_NODE, bsrp_info);
}

View 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);
}
group_timer_off(group);
igmp_group_count_decr(group->group_igmp_sock);

View file

@ -585,7 +585,6 @@ static void restart_done(struct daemon *dmn)
dmn->name, state_str[dmn->state]);
return;
}
if (dmn->t_wakeup)
THREAD_OFF(dmn->t_wakeup);
if (try_connect(dmn) < 0)
SET_WAKEUP_DOWN(dmn);