]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Remove ns_query_init() cannot fail, remove the error paths
authorOndřej Surý <ondrej@isc.org>
Tue, 2 Jul 2024 18:17:49 +0000 (20:17 +0200)
committerOndřej Surý <ondrej@isc.org>
Wed, 3 Jul 2024 07:05:51 +0000 (09:05 +0200)
As ns_query_init() cannot fail now, remove the error paths, especially
in ns__client_setup() where we now don't have to care what to do with
the connection if setting up the client could fail.  It couldn't fail
even before, but now it's formal.

lib/ns/client.c
lib/ns/include/ns/client.h
lib/ns/include/ns/query.h
lib/ns/query.c
tests/include/tests/ns.h
tests/libtest/ns.c
tests/ns/notify_test.c

index 7351c91923fa6c92bf696533605afebd75f12629..6e381d03b46412d111779673ac4fdd960ed17253 100644 (file)
@@ -1838,19 +1838,13 @@ ns_client_request(isc_nmhandle_t *handle, isc_result_t eresult,
 
                client = isc_mem_get(clientmgr->mctx, sizeof(*client));
 
-               result = ns__client_setup(client, clientmgr, true);
-               if (result != ISC_R_SUCCESS) {
-                       return;
-               }
+               ns__client_setup(client, clientmgr, true);
 
                ns_client_log(client, DNS_LOGCATEGORY_SECURITY,
                              NS_LOGMODULE_CLIENT, ISC_LOG_DEBUG(3),
                              "allocate new client");
        } else {
-               result = ns__client_setup(client, NULL, false);
-               if (result != ISC_R_SUCCESS) {
-                       return;
-               }
+               ns__client_setup(client, NULL, false);
        }
 
        client->state = NS_CLIENTSTATE_READY;
@@ -2520,10 +2514,8 @@ ns__client_tcpconn(isc_nmhandle_t *handle, isc_result_t result, void *arg) {
        return (ISC_R_SUCCESS);
 }
 
-isc_result_t
+void
 ns__client_setup(ns_client_t *client, ns_clientmgr_t *mgr, bool new) {
-       isc_result_t result;
-
        /*
         * Note: creating a client does not add the client to the
         * manager's client list, the caller is responsible for that.
@@ -2548,10 +2540,7 @@ ns__client_setup(ns_client_t *client, ns_clientmgr_t *mgr, bool new) {
                 * and the functions it calls will require it.
                 */
                client->magic = NS_CLIENT_MAGIC;
-               result = ns_query_init(client);
-               if (result != ISC_R_SUCCESS) {
-                       goto cleanup;
-               }
+               ns_query_init(client);
        } else {
                REQUIRE(NS_CLIENT_VALID(client));
                REQUIRE(client->manager->tid == isc_tid());
@@ -2583,14 +2572,6 @@ ns__client_setup(ns_client_t *client, ns_clientmgr_t *mgr, bool new) {
        client->magic = NS_CLIENT_MAGIC;
 
        CTRACE("client_setup");
-
-       return (ISC_R_SUCCESS);
-
-cleanup:
-       dns_message_detach(&client->message);
-       ns_clientmgr_detach(&client->manager);
-
-       return (result);
 }
 
 /***
index 1213c6ec3b83fff2897ae8d18da4e6a353b5233b..89ee79a67c928c8d889740ed3b66885f2074f12e 100644 (file)
@@ -543,7 +543,7 @@ ns_client_findversion(ns_client_t *client, dns_db_t *db);
 
 ISC_REFCOUNT_DECL(ns_clientmgr);
 
-isc_result_t
+void
 ns__client_setup(ns_client_t *client, ns_clientmgr_t *manager, bool new);
 /*%<
  * Perform initial setup of an allocated client.
index f6d0712c932790ee13db080ab8189c50b33d63e2..4f2c185b851575dfc9a7fe0e8788c9efd682f938 100644 (file)
@@ -287,7 +287,7 @@ ns_query_hookasync(query_ctx_t *qctx, ns_query_starthookasync_t runasync,
  * other aspects of hook-triggered asynchronous event handling.
  */
 
-isc_result_t
+void
 ns_query_init(ns_client_t *client);
 
 void
index 203ab46257ed76a47c11c530555be814e9cd461d..1a0e74918ce518d43f8849f00559cde28fdc9e1c 100644 (file)
@@ -806,10 +806,8 @@ ns_query_free(ns_client_t *client) {
        query_reset(client, true);
 }
 
-isc_result_t
+void
 ns_query_init(ns_client_t *client) {
-       isc_result_t result = ISC_R_SUCCESS;
-
        REQUIRE(NS_CLIENT_VALID(client));
 
        client->query = (ns_query_t){ 0 };
@@ -827,8 +825,6 @@ ns_query_init(ns_client_t *client) {
        query_reset(client, false);
        ns_client_newdbversion(client, 3);
        ns_client_newnamebuf(client);
-
-       return (result);
 }
 
 /*%
index c313abfa04d4edb2475dbe3d7d99cdf6cbc2366a..831ae8039966f821084839c4021f197ab217742a 100644 (file)
@@ -88,7 +88,7 @@ isc_result_t
 ns_test_getdata(const char *file, unsigned char *buf, size_t bufsiz,
                size_t *sizep);
 
-isc_result_t
+void
 ns_test_getclient(ns_interface_t *ifp0, bool tcp, ns_client_t **clientp);
 
 /*%
index 980ab6b904d67aa911c842dc1231e3ae569a6c06..b6ee7490e45a896fc66522557675eb1e444f3f29 100644 (file)
@@ -216,9 +216,8 @@ ns_test_cleanup_zone(void) {
        dns_zone_detach(&served_zone);
 }
 
-isc_result_t
+void
 ns_test_getclient(ns_interface_t *ifp0, bool tcp, ns_client_t **clientp) {
-       isc_result_t result;
        ns_client_t *client;
        ns_clientmgr_t *clientmgr;
        int i;
@@ -229,7 +228,7 @@ ns_test_getclient(ns_interface_t *ifp0, bool tcp, ns_client_t **clientp) {
        clientmgr = ns_interfacemgr_getclientmgr(interfacemgr);
 
        client = isc_mem_get(clientmgr->mctx, sizeof(*client));
-       result = ns__client_setup(client, clientmgr, true);
+       ns__client_setup(client, clientmgr, true);
 
        for (i = 0; i < 32; i++) {
                if (atomic_load(&client_addrs[i]) == (uintptr_t)NULL ||
@@ -244,8 +243,6 @@ ns_test_getclient(ns_interface_t *ifp0, bool tcp, ns_client_t **clientp) {
        atomic_store(&client_addrs[i], (uintptr_t)client);
        client->handle = (isc_nmhandle_t *)client; /* Hack */
        *clientp = client;
-
-       return (result);
 }
 
 /*%
@@ -438,10 +435,7 @@ ns_test_qctx_create(const ns_test_qctx_create_params_t *params,
        /*
         * Allocate and initialize a client structure.
         */
-       result = ns_test_getclient(NULL, false, &client);
-       if (result != ISC_R_SUCCESS) {
-               return (result);
-       }
+       ns_test_getclient(NULL, false, &client);
        client->tnow = isc_time_now();
 
        /*
index bb2389f2e5640f0f30cc487c59086fb66ceab1b4..806470a62428e6df47a9d2652047adab100888c7 100644 (file)
@@ -67,8 +67,7 @@ ISC_LOOP_TEST_IMPL(notify_start) {
        isc_buffer_t nbuf;
        size_t nsize;
 
-       result = ns_test_getclient(NULL, false, &client);
-       assert_int_equal(result, ISC_R_SUCCESS);
+       ns_test_getclient(NULL, false, &client);
 
        result = dns_test_makeview("view", false, false, &client->view);
        assert_int_equal(result, ISC_R_SUCCESS);