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

dns/rdata.c: Return void when ISC_R_SUCCESS is only returned value

With isc_mem_get() and dns_name_dup() no longer being able to fail, some
functions can now only return ISC_R_SUCCESS.  Change the return type to
void for the following function(s):

 * name_duporclone()
This commit is contained in:
Ondřej Surý
2021-10-06 12:57:24 +02:00
parent ffd09ec5f0
commit b0a665d947
34 changed files with 40 additions and 94 deletions

View File

@@ -407,14 +407,13 @@ locator_pton(const char *src, unsigned char *dst) {
return (1);
}
static inline isc_result_t
static inline void
name_duporclone(const dns_name_t *source, isc_mem_t *mctx, dns_name_t *target) {
if (mctx != NULL) {
dns_name_dup(source, mctx, target);
} else {
dns_name_clone(source, target);
}
return (ISC_R_SUCCESS);
}
static inline void *

View File

@@ -462,7 +462,7 @@ tostruct_any_tsig(ARGS_TOSTRUCT) {
dns_name_init(&alg, NULL);
dns_name_fromregion(&alg, &sr);
dns_name_init(&tsig->algorithm, NULL);
RETERR(name_duporclone(&alg, mctx, &tsig->algorithm));
name_duporclone(&alg, mctx, &tsig->algorithm);
isc_region_consume(&sr, name_length(&tsig->algorithm));

View File

@@ -234,7 +234,7 @@ tostruct_ch_a(ARGS_TOSTRUCT) {
isc_region_consume(&region, name_length(&name));
dns_name_init(&a->ch_addr_dom, NULL);
RETERR(name_duporclone(&name, mctx, &a->ch_addr_dom));
name_duporclone(&name, mctx, &a->ch_addr_dom);
a->ch_addr = htons(uint16_fromregion(&region));
a->mctx = mctx;
return (ISC_R_SUCCESS);

View File

@@ -219,7 +219,7 @@ tostruct_afsdb(ARGS_TOSTRUCT) {
dns_name_init(&name, NULL);
dns_name_fromregion(&name, &region);
RETERR(name_duporclone(&name, mctx, &afsdb->server));
name_duporclone(&name, mctx, &afsdb->server);
afsdb->mctx = mctx;
return (ISC_R_SUCCESS);
}

View File

@@ -350,7 +350,7 @@ tostruct_amtrelay(ARGS_TOSTRUCT) {
case 3:
dns_name_fromregion(&name, &region);
RETERR(name_duporclone(&name, mctx, &amtrelay->gateway));
name_duporclone(&name, mctx, &amtrelay->gateway);
isc_region_consume(&region, name_length(&name));
break;

View File

@@ -153,7 +153,7 @@ tostruct_cname(ARGS_TOSTRUCT) {
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
dns_name_init(&cname->cname, NULL);
RETERR(name_duporclone(&name, mctx, &cname->cname));
name_duporclone(&name, mctx, &cname->cname);
cname->mctx = mctx;
return (ISC_R_SUCCESS);
}

View File

@@ -153,7 +153,7 @@ tostruct_dname(ARGS_TOSTRUCT) {
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
dns_name_init(&dname->dname, NULL);
RETERR(name_duporclone(&name, mctx, &dname->dname));
name_duporclone(&name, mctx, &dname->dname);
dname->mctx = mctx;
return (ISC_R_SUCCESS);
}

View File

@@ -389,7 +389,7 @@ tostruct_ipseckey(ARGS_TOSTRUCT) {
case 3:
dns_name_init(&ipseckey->gateway, NULL);
dns_name_fromregion(&name, &region);
RETERR(name_duporclone(&name, mctx, &ipseckey->gateway));
name_duporclone(&name, mctx, &ipseckey->gateway);
isc_region_consume(&region, name_length(&name));
break;
}

View File

@@ -164,7 +164,7 @@ tostruct_lp(ARGS_TOSTRUCT) {
isc_region_consume(&region, 2);
dns_name_fromregion(&name, &region);
dns_name_init(&lp->lp, NULL);
RETERR(name_duporclone(&name, mctx, &lp->lp));
name_duporclone(&name, mctx, &lp->lp);
lp->mctx = mctx;
return (ISC_R_SUCCESS);
}

View File

@@ -152,7 +152,7 @@ tostruct_mb(ARGS_TOSTRUCT) {
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
dns_name_init(&mb->mb, NULL);
RETERR(name_duporclone(&name, mctx, &mb->mb));
name_duporclone(&name, mctx, &mb->mb);
mb->mctx = mctx;
return (ISC_R_SUCCESS);
}

View File

@@ -152,7 +152,7 @@ tostruct_md(ARGS_TOSTRUCT) {
dns_rdata_toregion(rdata, &r);
dns_name_fromregion(&name, &r);
dns_name_init(&md->md, NULL);
RETERR(name_duporclone(&name, mctx, &md->md));
name_duporclone(&name, mctx, &md->md);
md->mctx = mctx;
return (ISC_R_SUCCESS);
}

View File

@@ -152,7 +152,7 @@ tostruct_mf(ARGS_TOSTRUCT) {
dns_rdata_toregion(rdata, &r);
dns_name_fromregion(&name, &r);
dns_name_init(&mf->mf, NULL);
RETERR(name_duporclone(&name, mctx, &mf->mf));
name_duporclone(&name, mctx, &mf->mf);
mf->mctx = mctx;
return (ISC_R_SUCCESS);
}

View File

@@ -152,7 +152,7 @@ tostruct_mg(ARGS_TOSTRUCT) {
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
dns_name_init(&mg->mg, NULL);
RETERR(name_duporclone(&name, mctx, &mg->mg));
name_duporclone(&name, mctx, &mg->mg);
mg->mctx = mctx;
return (ISC_R_SUCCESS);
}

View File

@@ -199,7 +199,6 @@ tostruct_minfo(ARGS_TOSTRUCT) {
dns_rdata_minfo_t *minfo = target;
isc_region_t region;
dns_name_t name;
isc_result_t result;
REQUIRE(rdata->type == dns_rdatatype_minfo);
REQUIRE(minfo != NULL);
@@ -213,23 +212,14 @@ tostruct_minfo(ARGS_TOSTRUCT) {
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
dns_name_init(&minfo->rmailbox, NULL);
RETERR(name_duporclone(&name, mctx, &minfo->rmailbox));
name_duporclone(&name, mctx, &minfo->rmailbox);
isc_region_consume(&region, name_length(&name));
dns_name_fromregion(&name, &region);
dns_name_init(&minfo->emailbox, NULL);
result = name_duporclone(&name, mctx, &minfo->emailbox);
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
name_duporclone(&name, mctx, &minfo->emailbox);
minfo->mctx = mctx;
return (ISC_R_SUCCESS);
cleanup:
if (mctx != NULL) {
dns_name_free(&minfo->rmailbox, mctx);
}
return (ISC_R_NOMEMORY);
}
static inline void

View File

@@ -152,7 +152,7 @@ tostruct_mr(ARGS_TOSTRUCT) {
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
dns_name_init(&mr->mr, NULL);
RETERR(name_duporclone(&name, mctx, &mr->mr));
name_duporclone(&name, mctx, &mr->mr);
mr->mctx = mctx;
return (ISC_R_SUCCESS);
}

View File

@@ -238,7 +238,7 @@ tostruct_mx(ARGS_TOSTRUCT) {
isc_region_consume(&region, 2);
dns_name_fromregion(&name, &region);
dns_name_init(&mx->mx, NULL);
RETERR(name_duporclone(&name, mctx, &mx->mx));
name_duporclone(&name, mctx, &mx->mx);
mx->mctx = mctx;
return (ISC_R_SUCCESS);
}

View File

@@ -493,7 +493,6 @@ static inline isc_result_t
tostruct_naptr(ARGS_TOSTRUCT) {
dns_rdata_naptr_t *naptr = target;
isc_region_t r;
isc_result_t result;
dns_name_t name;
REQUIRE(rdata->type == dns_rdatatype_naptr);
@@ -546,10 +545,7 @@ tostruct_naptr(ARGS_TOSTRUCT) {
dns_name_init(&name, NULL);
dns_name_fromregion(&name, &r);
dns_name_init(&naptr->replacement, NULL);
result = name_duporclone(&name, mctx, &naptr->replacement);
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
name_duporclone(&name, mctx, &naptr->replacement);
naptr->mctx = mctx;
return (ISC_R_SUCCESS);

View File

@@ -163,7 +163,7 @@ tostruct_ns(ARGS_TOSTRUCT) {
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
dns_name_init(&ns->name, NULL);
RETERR(name_duporclone(&name, mctx, &ns->name));
name_duporclone(&name, mctx, &ns->name);
ns->mctx = mctx;
return (ISC_R_SUCCESS);
}

View File

@@ -172,7 +172,7 @@ tostruct_nsec(ARGS_TOSTRUCT) {
dns_name_fromregion(&name, &region);
isc_region_consume(&region, name_length(&name));
dns_name_init(&nsec->next, NULL);
RETERR(name_duporclone(&name, mctx, &nsec->next));
name_duporclone(&name, mctx, &nsec->next);
nsec->len = region.length;
nsec->typebits = mem_maybedup(mctx, region.base, region.length);

View File

@@ -251,7 +251,7 @@ tostruct_nxt(ARGS_TOSTRUCT) {
dns_name_fromregion(&name, &region);
isc_region_consume(&region, name_length(&name));
dns_name_init(&nxt->next, NULL);
RETERR(name_duporclone(&name, mctx, &nxt->next));
name_duporclone(&name, mctx, &nxt->next);
nxt->len = region.length;
nxt->typebits = mem_maybedup(mctx, region.base, region.length);

View File

@@ -165,7 +165,7 @@ tostruct_ptr(ARGS_TOSTRUCT) {
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
dns_name_init(&ptr->ptr, NULL);
RETERR(name_duporclone(&name, mctx, &ptr->ptr));
name_duporclone(&name, mctx, &ptr->ptr);
ptr->mctx = mctx;
return (ISC_R_SUCCESS);
}

View File

@@ -195,7 +195,6 @@ fromstruct_rp(ARGS_FROMSTRUCT) {
static inline isc_result_t
tostruct_rp(ARGS_TOSTRUCT) {
isc_result_t result;
isc_region_t region;
dns_rdata_rp_t *rp = target;
dns_name_t name;
@@ -212,23 +211,13 @@ tostruct_rp(ARGS_TOSTRUCT) {
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
dns_name_init(&rp->mail, NULL);
RETERR(name_duporclone(&name, mctx, &rp->mail));
name_duporclone(&name, mctx, &rp->mail);
isc_region_consume(&region, name_length(&name));
dns_name_fromregion(&name, &region);
dns_name_init(&rp->text, NULL);
result = name_duporclone(&name, mctx, &rp->text);
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
name_duporclone(&name, mctx, &rp->text);
rp->mctx = mctx;
return (ISC_R_SUCCESS);
cleanup:
if (mctx != NULL) {
dns_name_free(&rp->mail, mctx);
}
return (ISC_R_NOMEMORY);
}
static inline void

View File

@@ -491,7 +491,7 @@ tostruct_rrsig(ARGS_TOSTRUCT) {
dns_name_init(&signer, NULL);
dns_name_fromregion(&signer, &sr);
dns_name_init(&sig->signer, NULL);
RETERR(name_duporclone(&signer, mctx, &sig->signer));
name_duporclone(&signer, mctx, &sig->signer);
isc_region_consume(&sr, name_length(&sig->signer));
/*

View File

@@ -211,7 +211,7 @@ tostruct_rt(ARGS_TOSTRUCT) {
isc_region_consume(&region, 2);
dns_name_fromregion(&name, &region);
dns_name_init(&rt->host, NULL);
RETERR(name_duporclone(&name, mctx, &rt->host));
name_duporclone(&name, mctx, &rt->host);
rt->mctx = mctx;
return (ISC_R_SUCCESS);

View File

@@ -483,7 +483,7 @@ tostruct_sig(ARGS_TOSTRUCT) {
dns_name_init(&signer, NULL);
dns_name_fromregion(&signer, &sr);
dns_name_init(&sig->signer, NULL);
RETERR(name_duporclone(&signer, mctx, &sig->signer));
name_duporclone(&signer, mctx, &sig->signer);
isc_region_consume(&sr, name_length(&sig->signer));
/*

View File

@@ -302,7 +302,6 @@ tostruct_soa(ARGS_TOSTRUCT) {
isc_region_t region;
dns_rdata_soa_t *soa = target;
dns_name_t name;
isc_result_t result;
REQUIRE(rdata->type == dns_rdatatype_soa);
REQUIRE(soa != NULL);
@@ -318,15 +317,12 @@ tostruct_soa(ARGS_TOSTRUCT) {
dns_name_fromregion(&name, &region);
isc_region_consume(&region, name_length(&name));
dns_name_init(&soa->origin, NULL);
RETERR(name_duporclone(&name, mctx, &soa->origin));
name_duporclone(&name, mctx, &soa->origin);
dns_name_fromregion(&name, &region);
isc_region_consume(&region, name_length(&name));
dns_name_init(&soa->contact, NULL);
result = name_duporclone(&name, mctx, &soa->contact);
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
name_duporclone(&name, mctx, &soa->contact);
soa->serial = uint32_fromregion(&region);
isc_region_consume(&region, 4);
@@ -344,12 +340,6 @@ tostruct_soa(ARGS_TOSTRUCT) {
soa->mctx = mctx;
return (ISC_R_SUCCESS);
cleanup:
if (mctx != NULL) {
dns_name_free(&soa->origin, mctx);
}
return (ISC_R_NOMEMORY);
}
static inline void

View File

@@ -162,7 +162,6 @@ tostruct_talink(ARGS_TOSTRUCT) {
isc_region_t region;
dns_rdata_talink_t *talink = target;
dns_name_t name;
isc_result_t result;
REQUIRE(rdata->type == dns_rdatatype_talink);
REQUIRE(talink != NULL);
@@ -178,24 +177,15 @@ tostruct_talink(ARGS_TOSTRUCT) {
dns_name_fromregion(&name, &region);
isc_region_consume(&region, name_length(&name));
dns_name_init(&talink->prev, NULL);
RETERR(name_duporclone(&name, mctx, &talink->prev));
name_duporclone(&name, mctx, &talink->prev);
dns_name_fromregion(&name, &region);
isc_region_consume(&region, name_length(&name));
dns_name_init(&talink->next, NULL);
result = name_duporclone(&name, mctx, &talink->next);
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
name_duporclone(&name, mctx, &talink->next);
talink->mctx = mctx;
return (ISC_R_SUCCESS);
cleanup:
if (mctx != NULL) {
dns_name_free(&talink->prev, mctx);
}
return (ISC_R_NOMEMORY);
}
static inline void

View File

@@ -434,7 +434,7 @@ tostruct_tkey(ARGS_TOSTRUCT) {
dns_name_init(&alg, NULL);
dns_name_fromregion(&alg, &sr);
dns_name_init(&tkey->algorithm, NULL);
RETERR(name_duporclone(&alg, mctx, &tkey->algorithm));
name_duporclone(&alg, mctx, &tkey->algorithm);
isc_region_consume(&sr, name_length(&tkey->algorithm));
/*

View File

@@ -371,7 +371,7 @@ tostruct_in_a6(ARGS_TOSTRUCT) {
if (a6->prefixlen != 0) {
dns_name_init(&name, NULL);
dns_name_fromregion(&name, &r);
RETERR(name_duporclone(&name, mctx, &a6->prefix));
name_duporclone(&name, mctx, &a6->prefix);
}
a6->mctx = mctx;
return (ISC_R_SUCCESS);

View File

@@ -198,7 +198,7 @@ tostruct_in_kx(ARGS_TOSTRUCT) {
dns_name_fromregion(&name, &region);
dns_name_init(&kx->exchange, NULL);
RETERR(name_duporclone(&name, mctx, &kx->exchange));
name_duporclone(&name, mctx, &kx->exchange);
kx->mctx = mctx;
return (ISC_R_SUCCESS);
}

View File

@@ -160,7 +160,7 @@ tostruct_in_nsap_ptr(ARGS_TOSTRUCT) {
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
dns_name_init(&nsap_ptr->owner, NULL);
RETERR(name_duporclone(&name, mctx, &nsap_ptr->owner));
name_duporclone(&name, mctx, &nsap_ptr->owner);
nsap_ptr->mctx = mctx;
return (ISC_R_SUCCESS);
}

View File

@@ -248,7 +248,6 @@ tostruct_in_px(ARGS_TOSTRUCT) {
dns_rdata_in_px_t *px = target;
dns_name_t name;
isc_region_t region;
isc_result_t result;
REQUIRE(rdata->type == dns_rdatatype_px);
REQUIRE(rdata->rdclass == dns_rdataclass_in);
@@ -268,21 +267,14 @@ tostruct_in_px(ARGS_TOSTRUCT) {
dns_name_fromregion(&name, &region);
dns_name_init(&px->map822, NULL);
RETERR(name_duporclone(&name, mctx, &px->map822));
name_duporclone(&name, mctx, &px->map822);
isc_region_consume(&region, name_length(&px->map822));
dns_name_init(&px->mapx400, NULL);
result = name_duporclone(&name, mctx, &px->mapx400);
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
name_duporclone(&name, mctx, &px->mapx400);
px->mctx = mctx;
return (result);
cleanup:
dns_name_free(&px->map822, mctx);
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
}
static inline void

View File

@@ -279,7 +279,7 @@ tostruct_in_srv(ARGS_TOSTRUCT) {
isc_region_consume(&region, 2);
dns_name_fromregion(&name, &region);
dns_name_init(&srv->target, NULL);
RETERR(name_duporclone(&name, mctx, &srv->target));
name_duporclone(&name, mctx, &srv->target);
srv->mctx = mctx;
return (ISC_R_SUCCESS);
}

View File

@@ -1013,7 +1013,7 @@ generic_tostruct_in_svcb(ARGS_TOSTRUCT) {
dns_name_fromregion(&name, &region);
isc_region_consume(&region, name_length(&name));
RETERR(name_duporclone(&name, mctx, &svcb->svcdomain));
name_duporclone(&name, mctx, &svcb->svcdomain);
svcb->svclen = region.length;
svcb->svc = mem_maybedup(mctx, region.base, region.length);