2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

Merge branch 'each-dupwithoffsets-cannot-fail' into 'main'

dns_name_dupwithoffsets() cannot fail

See merge request isc-projects/bind9!8945
This commit is contained in:
Evan Hunt
2024-04-11 03:25:07 +00:00
6 changed files with 8 additions and 26 deletions

View File

@@ -614,7 +614,7 @@ create_db(isc_mem_t *mctx, const dns_name_t *origin, dns_dbtype_t type,
isc_mem_attach(mctx, &sampledb->common.mctx);
dns_name_init(&sampledb->common.origin, NULL);
CHECK(dns_name_dupwithoffsets(origin, mctx, &sampledb->common.origin));
dns_name_dupwithoffsets(origin, mctx, &sampledb->common.origin);
isc_refcount_init(&sampledb->common.references, 1);

View File

@@ -1078,7 +1078,7 @@ dns_name_dup(const dns_name_t *source, isc_mem_t *mctx, dns_name_t *target);
*\li 'mctx' is a valid memory context.
*/
isc_result_t
void
dns_name_dupwithoffsets(const dns_name_t *source, isc_mem_t *mctx,
dns_name_t *target);
/*%<

View File

@@ -1784,7 +1784,7 @@ dns_name_dup(const dns_name_t *source, isc_mem_t *mctx, dns_name_t *target) {
}
}
isc_result_t
void
dns_name_dupwithoffsets(const dns_name_t *source, isc_mem_t *mctx,
dns_name_t *target) {
/*
@@ -1819,8 +1819,6 @@ dns_name_dupwithoffsets(const dns_name_t *source, isc_mem_t *mctx,
} else {
set_offsets(target, target->offsets, NULL);
}
return (ISC_R_SUCCESS);
}
void
@@ -1999,7 +1997,7 @@ dns_name_fromstring(dns_name_t *target, const char *src,
}
if (name != target) {
result = dns_name_dupwithoffsets(name, mctx, target);
dns_name_dupwithoffsets(name, mctx, target);
}
return (result);
}

View File

@@ -3856,7 +3856,6 @@ dns__qpcache_create(isc_mem_t *mctx, const dns_name_t *origin,
unsigned int argc, char *argv[],
void *driverarg ISC_ATTR_UNUSED, dns_db_t **dbp) {
dns_qpdb_t *qpdb = NULL;
isc_result_t result;
isc_mem_t *hmctx = mctx;
int i;
@@ -3951,11 +3950,7 @@ dns__qpcache_create(isc_mem_t *mctx, const dns_name_t *origin,
/*
* Make a copy of the origin name.
*/
result = dns_name_dupwithoffsets(origin, mctx, &qpdb->common.origin);
if (result != ISC_R_SUCCESS) {
free_qpdb(qpdb, false);
return (result);
}
dns_name_dupwithoffsets(origin, mctx, &qpdb->common.origin);
/*
* Make the qp tries.

View File

@@ -3958,11 +3958,7 @@ dns__rbtdb_create(isc_mem_t *mctx, const dns_name_t *origin, dns_dbtype_t type,
/*
* Make a copy of the origin name.
*/
result = dns_name_dupwithoffsets(origin, mctx, &rbtdb->common.origin);
if (result != ISC_R_SUCCESS) {
free_rbtdb(rbtdb, false);
return (result);
}
dns_name_dupwithoffsets(origin, mctx, &rbtdb->common.origin);
/*
* Make the Red-Black Trees.

View File

@@ -1357,7 +1357,6 @@ static isc_result_t
dns_sdlzcreateDBP(isc_mem_t *mctx, void *driverarg, void *dbdata,
const dns_name_t *name, dns_rdataclass_t rdclass,
dns_db_t **dbp) {
isc_result_t result;
dns_sdlz_db_t *sdlzdb;
dns_sdlzimplementation_t *imp;
@@ -1379,10 +1378,7 @@ dns_sdlzcreateDBP(isc_mem_t *mctx, void *driverarg, void *dbdata,
/* initialize and set origin */
dns_name_init(&sdlzdb->common.origin, NULL);
result = dns_name_dupwithoffsets(name, mctx, &sdlzdb->common.origin);
if (result != ISC_R_SUCCESS) {
goto mem_cleanup;
}
dns_name_dupwithoffsets(name, mctx, &sdlzdb->common.origin);
isc_refcount_init(&sdlzdb->common.references, 1);
@@ -1394,10 +1390,7 @@ dns_sdlzcreateDBP(isc_mem_t *mctx, void *driverarg, void *dbdata,
sdlzdb->common.impmagic = SDLZDB_MAGIC;
*dbp = (dns_db_t *)sdlzdb;
return (result);
mem_cleanup:
isc_mem_put(mctx, sdlzdb, sizeof(*sdlzdb));
return (result);
return (ISC_R_SUCCESS);
}
static isc_result_t