From: Ondřej Surý Date: Sat, 14 Mar 2026 11:53:51 +0000 (+0100) Subject: Simplify checkds_create() to return void X-Git-Tag: v9.21.21~41^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=63d3c1f58a347d7d15c1e5477c6f9793cf139787;p=thirdparty%2Fbind9.git Simplify checkds_create() to return void Since memory allocation never fails in BIND 9, checkds_create() cannot fail. Change it to return void and use designated initializers, removing error handling at all call sites. --- diff --git a/lib/dns/zone.c b/lib/dns/zone.c index 8f6ded67174..741e88a5880 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -20289,7 +20290,7 @@ checkds_isqueued(dns_zone_t *zone, dns_name_t *name, isc_sockaddr_t *addr, return false; } -static isc_result_t +static void checkds_create(isc_mem_t *mctx, unsigned int flags, dns_checkds_t **checkdsp) { dns_checkds_t *checkds; @@ -20297,16 +20298,16 @@ checkds_create(isc_mem_t *mctx, unsigned int flags, dns_checkds_t **checkdsp) { checkds = isc_mem_get(mctx, sizeof(*checkds)); *checkds = (dns_checkds_t){ + .magic = CHECKDS_MAGIC, .flags = flags, + .link = ISC_LINK_INITIALIZER, + .mctx = isc_mem_ref(mctx), + .ns = DNS_NAME_INITEMPTY, }; - isc_mem_attach(mctx, &checkds->mctx); isc_sockaddr_any(&checkds->dst); - dns_name_init(&checkds->ns); - ISC_LINK_INIT(checkds, link); - checkds->magic = CHECKDS_MAGIC; + *checkdsp = checkds; - return ISC_R_SUCCESS; } static void @@ -20595,7 +20596,7 @@ checkds_send_tons(dns_checkds_t *checkds) { } newcheckds = NULL; - CHECK(checkds_create(checkds->mctx, 0, &newcheckds)); + checkds_create(checkds->mctx, 0, &newcheckds); zone_iattach(zone, &newcheckds->zone); ISC_LIST_APPEND(newcheckds->zone->checkds_requests, newcheckds, link); @@ -20682,6 +20683,12 @@ checkds_send(dns_zone_t *zone) { INSIST(isc_sockaddr_pf(&src) == isc_sockaddr_pf(&dst)); if (isc_sockaddr_disabled(&dst)) { + if (key != NULL) { + dns_tsigkey_detach(&key); + } + if (transport != NULL) { + dns_transport_detach(&transport); + } goto next; } @@ -20706,14 +20713,7 @@ checkds_send(dns_zone_t *zone) { "parent %d", i); - result = checkds_create(zone->mctx, flags, &checkds); - if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_DEBUG(3), - "checkds: create DS query for " - "parent %d failed", - i); - goto next; - } + checkds_create(zone->mctx, flags, &checkds); zone_iattach(zone, &checkds->zone); dns_name_dup(dns_rootname, checkds->mctx, &checkds->ns); checkds->src = src; @@ -20883,13 +20883,7 @@ nsfetch_checkds(dns_zonefetch_t *fetch, isc_result_t eresult) { if (isqueued) { continue; } - result = checkds_create(zone->mctx, 0, &checkds); - if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_DEBUG(3), - "checkds: checkds_create() failed: %s", - isc_result_totext(result)); - break; - } + checkds_create(zone->mctx, 0, &checkds); if (isc_log_wouldlog(ISC_LOG_DEBUG(3))) { char nsnamebuf[DNS_NAME_FORMATSIZE];