]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Refactor dns_zone_create() to return void
authorOndřej Surý <ondrej@isc.org>
Mon, 26 Jun 2023 09:09:26 +0000 (11:09 +0200)
committerOndřej Surý <ondrej@isc.org>
Thu, 27 Jul 2023 09:37:44 +0000 (11:37 +0200)
After isc_stats_create() change, the dns_zone_create() cannot fail, so
refactor the function to return void and fix all its uses.

bin/check/check-tool.c
bin/named/server.c
bin/tests/system/dyndb/driver/zone.c
fuzz/dns_message_checksig.c
lib/dns/dlz.c
lib/dns/include/dns/zone.h
lib/dns/zone.c
tests/libtest/dns.c

index 77aecccc70edf29e5b5a717f3a963f25ea0da039..93cde4055046fb31f80c9945ef3e27e796859815 100644 (file)
@@ -595,7 +595,7 @@ load_zone(isc_mem_t *mctx, const char *zonename, const char *filename,
                        zonename, filename, classname);
        }
 
-       CHECK(dns_zone_create(&zone, mctx, 0));
+       dns_zone_create(&zone, mctx, 0);
 
        dns_zone_settype(zone, dns_zone_primary);
 
index 3c63b4d843ac803e990a1ba55c5e1d633024b5cd..ca4a5b3260c242bf580ed85e93474a0a8d74a71e 100644 (file)
@@ -1938,7 +1938,7 @@ dns64_reverse(dns_view_t *view, isc_mem_t *mctx, isc_netaddr_t *na,
        isc_buffer_constinit(&b, reverse, strlen(reverse));
        isc_buffer_add(&b, strlen(reverse));
        CHECK(dns_name_fromtext(name, &b, dns_rootname, 0, NULL));
-       CHECK(dns_zone_create(&zone, mctx, 0));
+       dns_zone_create(&zone, mctx, 0);
        CHECK(dns_zone_setorigin(zone, name));
        dns_zone_setview(zone, view);
        CHECK(dns_zonemgr_managezone(named_g_server->zonemgr, zone));
@@ -3613,7 +3613,7 @@ create_ipv4only_zone(dns_zone_t *pzone, dns_view_t *view,
                /*
                 * Create the actual zone.
                 */
-               CHECK(dns_zone_create(&zone, mctx, 0));
+               dns_zone_create(&zone, mctx, 0);
                CHECK(dns_zone_setorigin(zone, name));
                CHECK(dns_zonemgr_managezone(named_g_server->zonemgr, zone));
                dns_zone_setclass(zone, view->rdclass);
@@ -6793,8 +6793,8 @@ configure_zone(const cfg_obj_t *config, const cfg_obj_t *zconfig,
        if (inline_signing) {
                dns_zone_getraw(zone, &raw);
                if (raw == NULL) {
-                       CHECK(dns_zone_create(&raw, dns_zone_getmem(zone),
-                                             dns_zone_gettid(zone)));
+                       dns_zone_create(&raw, dns_zone_getmem(zone),
+                                       dns_zone_gettid(zone));
                        CHECK(dns_zone_setorigin(raw, origin));
                        dns_zone_setview(raw, view);
                        dns_zone_setstats(raw, named_g_server->zonestats);
index 595b01da6a6721fe01432ae60ab9df7c4ecf4d9f..caa615b4dfba985b1ffe975c47184cc0fd203b6b 100644 (file)
@@ -66,12 +66,8 @@ create_zone(sample_instance_t *const inst, dns_name_t *const name,
 
        zone_argv[0] = inst->db_name;
 
-       result = dns_zone_create(&raw, inst->mctx, 0); /* FIXME */
-       if (result != ISC_R_SUCCESS) {
-               log_write(ISC_LOG_ERROR, "create_zone: dns_zone_create -> %s\n",
-                         isc_result_totext(result));
-               goto cleanup;
-       }
+       dns_zone_create(&raw, inst->mctx, 0); /* FIXME: all zones are assigned
+                                                to loop 0 */
        result = dns_zone_setorigin(raw, name);
        if (result != ISC_R_SUCCESS) {
                log_write(ISC_LOG_ERROR,
index 15a61995e166dc215be55bbcfe325a3626703e65..a6544b80dc2800f8c80d62329dbb5986741c2b5d 100644 (file)
@@ -274,12 +274,7 @@ LLVMFuzzerInitialize(int *argc ISC_ATTR_UNUSED, char ***argv ISC_ATTR_UNUSED) {
                return (1);
        }
 
-       result = dns_zone_create(&zone, mctx, 0);
-       if (result != ISC_R_SUCCESS) {
-               fprintf(stderr, "dns_zone_create failed: %s\n",
-                       isc_result_totext(result));
-               return (1);
-       }
+       dns_zone_create(&zone, mctx, 0);
 
        result = dns_zone_setorigin(zone, name);
        if (result != ISC_R_SUCCESS) {
index de22dd3a838b5e5d3dfc7f2f3a95a6c56c3690f0..475d6849cda49c47e974fc37d6ce1cc1d52a27ff 100644 (file)
@@ -450,10 +450,7 @@ dns_dlz_writeablezone(dns_view_t *view, dns_dlzdb_t *dlzdb,
        INSIST(dupzone == NULL);
 
        /* Create it */
-       result = dns_zone_create(&zone, view->mctx, 0);
-       if (result != ISC_R_SUCCESS) {
-               goto cleanup;
-       }
+       dns_zone_create(&zone, view->mctx, 0);
        result = dns_zone_setorigin(zone, origin);
        if (result != ISC_R_SUCCESS) {
                goto cleanup;
index 467dc4007a8a09f9d7c3d167ad51bd41a69babb7..b7084676db6944d745a4f820b710bf23bf0e5ed0 100644 (file)
@@ -149,7 +149,7 @@ ISC_LANG_BEGINDECLS
  ***   Functions
  ***/
 
-isc_result_t
+void
 dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx, unsigned int tid);
 /*%<
  *     Creates a new empty zone and attach '*zonep' to it.
@@ -160,11 +160,6 @@ dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx, unsigned int tid);
  *
  * Ensures:
  *\li  '*zonep' refers to a valid zone.
- *
- * Returns:
- *\li  #ISC_R_SUCCESS
- *\li  #ISC_R_NOMEMORY
- *\li  #ISC_R_UNEXPECTED
  */
 
 void
index 8dd5d661183b43c2a553d9b4fe0de1a1eef40b6d..8e2416a1717988e0ee0e92d6871fd07f089b860b 100644 (file)
@@ -1080,7 +1080,7 @@ inc_stats(dns_zone_t *zone, isc_statscounter_t counter) {
  ***   Public functions.
  ***/
 
-isc_result_t
+void
 dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx, unsigned int tid) {
        isc_time_t now;
        dns_zone_t *zone = NULL;
@@ -1165,7 +1165,6 @@ dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx, unsigned int tid) {
        dns_zone_setdbtype(zone, dbargc_default, dbargv_default);
 
        *zonep = zone;
-       return (ISC_R_SUCCESS);
 }
 
 static void
@@ -18242,7 +18241,6 @@ dns_zonemgr_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, isc_nm_t *netmgr,
 
 isc_result_t
 dns_zonemgr_createzone(dns_zonemgr_t *zmgr, dns_zone_t **zonep) {
-       isc_result_t result;
        isc_mem_t *mctx = NULL;
        dns_zone_t *zone = NULL;
        unsigned int tid;
@@ -18261,13 +18259,11 @@ dns_zonemgr_createzone(dns_zonemgr_t *zmgr, dns_zone_t **zonep) {
                return (ISC_R_FAILURE);
        }
 
-       result = dns_zone_create(&zone, mctx, tid);
+       dns_zone_create(&zone, mctx, tid);
 
-       if (result == ISC_R_SUCCESS) {
-               *zonep = zone;
-       }
+       *zonep = zone;
 
-       return (result);
+       return (ISC_R_SUCCESS);
 }
 
 isc_result_t
index d398c5c954f36fdb86459b0c521e336aad99c9b0..4c8880fea7976b76499d49c71033e50776299a08 100644 (file)
@@ -104,10 +104,7 @@ dns_test_makezone(const char *name, dns_zone_t **zonep, dns_view_t *view,
        /*
         * Create the zone structure.
         */
-       result = dns_zone_create(&zone, mctx, 0);
-       if (result != ISC_R_SUCCESS) {
-               return (result);
-       }
+       dns_zone_create(&zone, mctx, 0);
 
        /*
         * Set zone type and origin.