From: Ondřej Surý Date: Fri, 13 Oct 2023 06:05:30 +0000 (+0200) Subject: Refactor dns_iptable_create() to return void X-Git-Tag: v9.19.18~41^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=613ada72b6a0ed7e5799a75dc1a03ecb7c9a94af;p=thirdparty%2Fbind9.git Refactor dns_iptable_create() to return void The dns_iptable_create() cannot fail now, so change it to return void. --- diff --git a/lib/dns/acl.c b/lib/dns/acl.c index 8dacc2aa2d3..7f48193143d 100644 --- a/lib/dns/acl.c +++ b/lib/dns/acl.c @@ -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; diff --git a/lib/dns/include/dns/iptable.h b/lib/dns/include/dns/iptable.h index 5ad667b4159..60bc7030784 100644 --- a/lib/dns/include/dns/iptable.h +++ b/lib/dns/include/dns/iptable.h @@ -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 diff --git a/lib/dns/iptable.c b/lib/dns/iptable.c index 36209bf36f4..f0ebef7ac8f 100644 --- a/lib/dns/iptable.c +++ b/lib/dns/iptable.c @@ -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;