CLEANUP: Stop checking the pointer before calling `task_free()`

Changes performed with this Coccinelle patch:

    @@
    expression e;
    @@

    - if (e != NULL) {
    	task_destroy(e);
    - }

    @@
    expression e;
    @@

    - if (e) {
    	task_destroy(e);
    - }

    @@
    expression e;
    @@

    - if (e)
    	task_destroy(e);

    @@
    expression e;
    @@

    - if (e != NULL)
    	task_destroy(e);
This commit is contained in:
Tim Duesterhus 2023-04-22 17:47:34 +02:00 committed by Willy Tarreau
parent c18e244515
commit fe83f58906
5 changed files with 7 additions and 14 deletions

View File

@ -2451,8 +2451,7 @@ static void deinit_idle_conns(void)
int i;
for (i = 0; i < global.nbthread; i++) {
if (idle_conns[i].cleanup_task)
task_destroy(idle_conns[i].cleanup_task);
task_destroy(idle_conns[i].cleanup_task);
}
}
REGISTER_POST_DEINIT(deinit_idle_conns);

View File

@ -779,8 +779,7 @@ void dns_session_free(struct dns_session *ds)
{
pool_free(dns_msg_buf, ds->rx_msg.area);
pool_free(dns_msg_buf, ds->tx_ring_area);
if (ds->task_exp)
task_destroy(ds->task_exp);
task_destroy(ds->task_exp);
dns_queries_flush(ds);
@ -1080,8 +1079,7 @@ struct dns_session *dns_session_new(struct dns_stream_server *dss)
return ds;
error:
if (ds->task_exp)
task_destroy(ds->task_exp);
task_destroy(ds->task_exp);
pool_free(dns_msg_buf, ds->rx_msg.area);
pool_free(dns_msg_buf, ds->tx_ring_area);

View File

@ -9257,8 +9257,7 @@ static struct event_hdl_sub *hlua_event_subscribe(event_hdl_sub_list *list, stru
mem_error:
if (hlua_sub) {
if (hlua_sub->task)
task_destroy(hlua_sub->task);
task_destroy(hlua_sub->task);
if (hlua_sub->hlua)
hlua_ctx_destroy(hlua_sub->hlua);
pool_free(pool_head_hlua_event_sub, hlua_sub);

View File

@ -502,8 +502,7 @@ void mworker_cleanlisteners()
/* disable this peer section so that it kills itself */
if (curpeers->sighandler)
signal_unregister_handler(curpeers->sighandler);
if (curpeers->sync_task)
task_destroy(curpeers->sync_task);
task_destroy(curpeers->sync_task);
curpeers->sync_task = NULL;
curpeers->peers_fe = NULL;
}

View File

@ -2491,10 +2491,8 @@ static void resolvers_destroy(struct resolvers *resolvers)
if (ns->stream) {
if (ns->stream->ring_req)
ring_free(ns->stream->ring_req);
if (ns->stream->task_req)
task_destroy(ns->stream->task_req);
if (ns->stream->task_rsp)
task_destroy(ns->stream->task_rsp);
task_destroy(ns->stream->task_req);
task_destroy(ns->stream->task_rsp);
free(ns->stream);
}
LIST_DEL_INIT(&ns->list);