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

add DNS_RDATASET_FOREACH macro

replace the pattern `for (result = dns_rdataset_first(x); result ==
ISC_R_SUCCES; result = dns_rdataset_next(x)` with a new
`DNS_RDATASET_FOREACH` macro throughout BIND.
This commit is contained in:
Evan Hunt
2025-03-21 23:32:27 -07:00
parent 6a6ef103dd
commit f10f5572ac
38 changed files with 695 additions and 1390 deletions

View File

@@ -506,18 +506,15 @@ static isc_result_t
ncache_summary(dns_rdataset_t *rdataset, bool omit_final_dot,
dns_totext_ctx_t *ctx, isc_buffer_t *target) {
isc_result_t result = ISC_R_SUCCESS;
dns_rdataset_t rds;
dns_rdataset_t rds = DNS_RDATASET_INIT;
dns_name_t name;
char *start = NULL;
dns_rdataset_init(&rds);
dns_name_init(&name);
do {
dns_ncache_current(rdataset, &name, &rds);
for (result = dns_rdataset_first(&rds); result == ISC_R_SUCCESS;
result = dns_rdataset_next(&rds))
{
DNS_RDATASET_FOREACH (&rds) {
if ((ctx->style.flags & DNS_STYLEFLAG_INDENT) != 0 ||
(ctx->style.flags & DNS_STYLEFLAG_YAML) != 0)
{
@@ -599,8 +596,6 @@ rdataset_totext(dns_rdataset_t *rdataset, const dns_name_t *owner_name,
REQUIRE(DNS_RDATASET_VALID(rdataset));
result = dns_rdataset_first(rdataset);
current_ttl = ctx->current_ttl;
current_ttl_valid = ctx->current_ttl_valid;
@@ -610,7 +605,7 @@ rdataset_totext(dns_rdataset_t *rdataset, const dns_name_t *owner_name,
dns_rdataset_getownercase(rdataset, name);
}
while (result == ISC_R_SUCCESS) {
DNS_RDATASET_FOREACH (rdataset) {
column = 0;
/*
@@ -805,11 +800,6 @@ rdataset_totext(dns_rdataset_t *rdataset, const dns_name_t *owner_name,
}
first = false;
result = dns_rdataset_next(rdataset);
}
if (result != ISC_R_NOMORE) {
return result;
}
/*
@@ -1262,7 +1252,7 @@ restart:
isc_buffer_copyregion(buffer, &r);
totallen += sizeof(dlen) + r.length;
do {
DNS_RDATASET_FOREACH (rdataset) {
dns_rdata_t rdata = DNS_RDATA_INIT;
dns_rdataset_current(rdataset, &rdata);
@@ -1291,13 +1281,7 @@ restart:
isc_buffer_putuint16(buffer, dlen);
isc_buffer_copyregion(buffer, &r);
totallen += sizeof(dlen) + r.length;
result = dns_rdataset_next(rdataset);
} while (result == ISC_R_SUCCESS);
if (result != ISC_R_NOMORE) {
return result;
}
};
/*
* Fill in the total length field.