]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Refactor dns_iptable_create() to return void
authorOndřej Surý <ondrej@isc.org>
Fri, 13 Oct 2023 06:05:30 +0000 (08:05 +0200)
committerOndřej Surý <ondrej@isc.org>
Fri, 13 Oct 2023 12:44:40 +0000 (14:44 +0200)
The dns_iptable_create() cannot fail now, so change it to return void.

lib/dns/acl.c
lib/dns/include/dns/iptable.h
lib/dns/iptable.c

index 8dacc2aa2d37459435b7184572189fc868623697..7f48193143d8388b951131c80b880d1a7a3e42cc 100644 (file)
@@ -34,7 +34,6 @@
  */
 isc_result_t
 dns_acl_create(isc_mem_t *mctx, int n, dns_acl_t **target) {
-       isc_result_t result;
        dns_acl_t *acl;
 
        /*
@@ -53,11 +52,7 @@ dns_acl_create(isc_mem_t *mctx, int n, dns_acl_t **target) {
 
        isc_refcount_init(&acl->refcount, 1);
 
-       result = dns_iptable_create(mctx, &acl->iptable);
-       if (result != ISC_R_SUCCESS) {
-               isc_mem_put(mctx, acl, sizeof(*acl));
-               return (result);
-       }
+       dns_iptable_create(mctx, &acl->iptable);
 
        acl->elements = NULL;
        acl->alloc = 0;
index 5ad667b4159c03078751ff54481411efe7878d36..60bc7030784cd679bbeb83fdcf46a50f72b7af7c 100644 (file)
@@ -39,7 +39,7 @@ struct dns_iptable {
 
 ISC_LANG_BEGINDECLS
 
-isc_result_t
+void
 dns_iptable_create(isc_mem_t *mctx, dns_iptable_t **target);
 /*
  * Create a new IP table and the underlying radix structure
index 36209bf36f4f503a907f78e6d390b579d66ba24d..f0ebef7ac8f9219be338167e88a696bcf2354455 100644 (file)
@@ -26,21 +26,18 @@ destroy_iptable(dns_iptable_t *dtab);
 /*
  * Create a new IP table and the underlying radix structure
  */
-isc_result_t
+void
 dns_iptable_create(isc_mem_t *mctx, dns_iptable_t **target) {
-       dns_iptable_t *tab;
-
-       tab = isc_mem_get(mctx, sizeof(*tab));
-       tab->mctx = NULL;
+       dns_iptable_t *tab = isc_mem_get(mctx, sizeof(*tab));
+       *tab = (dns_iptable_t){
+               .refcount = 1,
+               .magic = DNS_IPTABLE_MAGIC,
+       };
        isc_mem_attach(mctx, &tab->mctx);
-       isc_refcount_init(&tab->refcount, 1);
-       tab->radix = NULL;
-       tab->magic = DNS_IPTABLE_MAGIC;
 
        isc_radix_create(mctx, &tab->radix, RADIX_MAXBITS);
 
        *target = tab;
-       return (ISC_R_SUCCESS);
 }
 
 static bool dns_iptable_neg = false;