diff --git a/lib/dns/iptable.c b/lib/dns/iptable.c index f479d71d84..36209bf36f 100644 --- a/lib/dns/iptable.c +++ b/lib/dns/iptable.c @@ -28,7 +28,6 @@ destroy_iptable(dns_iptable_t *dtab); */ isc_result_t dns_iptable_create(isc_mem_t *mctx, dns_iptable_t **target) { - isc_result_t result; dns_iptable_t *tab; tab = isc_mem_get(mctx, sizeof(*tab)); @@ -38,17 +37,10 @@ dns_iptable_create(isc_mem_t *mctx, dns_iptable_t **target) { tab->radix = NULL; tab->magic = DNS_IPTABLE_MAGIC; - result = isc_radix_create(mctx, &tab->radix, RADIX_MAXBITS); - if (result != ISC_R_SUCCESS) { - goto cleanup; - } + isc_radix_create(mctx, &tab->radix, RADIX_MAXBITS); *target = tab; return (ISC_R_SUCCESS); - -cleanup: - dns_iptable_detach(&tab); - return (result); } static bool dns_iptable_neg = false; diff --git a/lib/isc/include/isc/radix.h b/lib/isc/include/isc/radix.h index 9a91118090..3bb01fbd80 100644 --- a/lib/isc/include/isc/radix.h +++ b/lib/isc/include/isc/radix.h @@ -100,8 +100,8 @@ typedef struct isc_radix_node { * nodes */ } isc_radix_node_t; -#define RADIX_TREE_MAGIC ISC_MAGIC('R', 'd', 'x', 'T'); -#define RADIX_TREE_VALID(a) ISC_MAGIC_VALID(a, RADIX_TREE_MAGIC); +#define RADIX_TREE_MAGIC ISC_MAGIC('R', 'd', 'x', 'T') +#define RADIX_TREE_VALID(a) ISC_MAGIC_VALID(a, RADIX_TREE_MAGIC) typedef struct isc_radix_tree { unsigned int magic; @@ -157,7 +157,7 @@ isc_radix_remove(isc_radix_tree_t *radix, isc_radix_node_t *node); * \li 'node' to be valid. */ -isc_result_t +void isc_radix_create(isc_mem_t *mctx, isc_radix_tree_t **target, int maxbits); /*%< * Create a radix tree with a maximum depth of 'maxbits'; diff --git a/lib/isc/radix.c b/lib/isc/radix.c index 54c03832f1..f688a75255 100644 --- a/lib/isc/radix.c +++ b/lib/isc/radix.c @@ -131,24 +131,18 @@ _comp_with_mask(void *addr, void *dest, u_int mask) { return (0); } -isc_result_t +void isc_radix_create(isc_mem_t *mctx, isc_radix_tree_t **target, int maxbits) { - isc_radix_tree_t *radix; - REQUIRE(target != NULL && *target == NULL); + RUNTIME_CHECK(maxbits <= RADIX_MAXBITS); - radix = isc_mem_get(mctx, sizeof(isc_radix_tree_t)); - - radix->mctx = NULL; + isc_radix_tree_t *radix = isc_mem_get(mctx, sizeof(isc_radix_tree_t)); + *radix = (isc_radix_tree_t){ + .maxbits = maxbits, + .magic = RADIX_TREE_MAGIC, + }; isc_mem_attach(mctx, &radix->mctx); - radix->maxbits = maxbits; - radix->head = NULL; - radix->num_active_node = 0; - radix->num_added_node = 0; - RUNTIME_CHECK(maxbits <= RADIX_MAXBITS); /* XXX */ - radix->magic = RADIX_TREE_MAGIC; *target = radix; - return (ISC_R_SUCCESS); } /* diff --git a/tests/isc/radix_test.c b/tests/isc/radix_test.c index fe589fe2b7..def5e9cf58 100644 --- a/tests/isc/radix_test.c +++ b/tests/isc/radix_test.c @@ -41,8 +41,7 @@ ISC_RUN_TEST_IMPL(isc_radix_remove) { UNUSED(state); - result = isc_radix_create(mctx, &radix, 32); - assert_int_equal(result, ISC_R_SUCCESS); + isc_radix_create(mctx, &radix, 32); in_addr.s_addr = inet_addr("1.1.1.1"); isc_netaddr_fromin(&netaddr, &in_addr); @@ -90,8 +89,7 @@ ISC_RUN_TEST_IMPL(isc_radix_search) { UNUSED(state); - result = isc_radix_create(mctx, &radix, 32); - assert_int_equal(result, ISC_R_SUCCESS); + isc_radix_create(mctx, &radix, 32); in_addr.s_addr = inet_addr("3.3.3.0"); isc_netaddr_fromin(&netaddr, &in_addr);