]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: Stop checking the pointer before calling `task_free()`
authorTim Duesterhus <tim@bastelstu.be>
Sat, 22 Apr 2023 15:47:34 +0000 (17:47 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 22 Apr 2023 22:28:25 +0000 (00:28 +0200)
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);

src/connection.c
src/dns.c
src/hlua.c
src/mworker.c
src/resolvers.c

index 29197ad9469977dcdf9f06fdb765fca163219316..f8a0a421546a583d075df9cb9fbbb8aa4512251d 100644 (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);
index b103c860232a34417708248efc480dd57d76ed42..8855f37f3d7649c6fee4279b6ee530434a392867 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
@@ -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);
 
index 5c29bc5ac1402616d59ea3cd6be3734f4337bdaf..a758f627f143de866c2f053f80d78732577a1380 100644 (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);
index 11d61a236edbc4658cb7ce4d30fcf1633156695f..b1115cc6e5627918730186717e522003035e3904 100644 (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;
        }
index a3f328d7a74be9852b45dc14c54e9ec8dbb996bf..ee70e45ca395f00d5467d410a35a9f515d0641bd 100644 (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);