mirror of
https://github.com/isc-projects/bind9.git
synced 2026-05-28 04:34:54 -04:00
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.
This commit is contained in:
parent
d7e1013741
commit
63d3c1f58a
1 changed files with 16 additions and 22 deletions
|
|
@ -22,6 +22,7 @@
|
|||
#include <isc/file.h>
|
||||
#include <isc/hash.h>
|
||||
#include <isc/hex.h>
|
||||
#include <isc/list.h>
|
||||
#include <isc/log.h>
|
||||
#include <isc/loop.h>
|
||||
#include <isc/md.h>
|
||||
|
|
@ -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];
|
||||
|
|
|
|||
Loading…
Reference in a new issue