mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 14:35:26 +00:00
Use clang-tidy to add curly braces around one-line statements
The command used to reformat the files in this commit was: ./util/run-clang-tidy \ -clang-tidy-binary clang-tidy-11 -clang-apply-replacements-binary clang-apply-replacements-11 \ -checks=-*,readability-braces-around-statements \ -j 9 \ -fix \ -format \ -style=file \ -quiet clang-format -i --style=format $(git ls-files '*.c' '*.h') uncrustify -c .uncrustify.cfg --replace --no-backup $(git ls-files '*.c' '*.h') clang-format -i --style=format $(git ls-files '*.c' '*.h')
This commit is contained in:
@@ -89,8 +89,9 @@ fillin_offsets(unsigned char *offsetbase, unsigned int *offsettable,
|
||||
unsigned char *raw;
|
||||
|
||||
for (i = 0, j = 0; i < length; i++) {
|
||||
if (offsettable[i] == 0)
|
||||
if (offsettable[i] == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Fill in offset table.
|
||||
@@ -109,7 +110,7 @@ fillin_offsets(unsigned char *offsetbase, unsigned int *offsettable,
|
||||
*raw = j++ & 0xff;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
|
||||
isc_result_t
|
||||
dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx,
|
||||
@@ -124,7 +125,7 @@ dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx,
|
||||
unsigned char * rawbuf;
|
||||
#if DNS_RDATASET_FIXED
|
||||
unsigned char *offsetbase;
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
unsigned int buflen;
|
||||
isc_result_t result;
|
||||
unsigned int nitems;
|
||||
@@ -132,7 +133,7 @@ dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx,
|
||||
unsigned int i;
|
||||
#if DNS_RDATASET_FIXED
|
||||
unsigned int *offsettable;
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
unsigned int length;
|
||||
|
||||
buflen = reservelen + 2;
|
||||
@@ -144,8 +145,9 @@ dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx,
|
||||
* with zero a record count.
|
||||
*/
|
||||
if (nitems == 0) {
|
||||
if (rdataset->type != 0)
|
||||
if (rdataset->type != 0) {
|
||||
return (ISC_R_FAILURE);
|
||||
}
|
||||
rawbuf = isc_mem_get(mctx, buflen);
|
||||
region->base = rawbuf;
|
||||
region->length = buflen;
|
||||
@@ -155,8 +157,9 @@ dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx,
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
if (nitems > 0xffff)
|
||||
if (nitems > 0xffff) {
|
||||
return (ISC_R_NOSPACE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Remember the original number of items.
|
||||
@@ -168,8 +171,9 @@ dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx,
|
||||
* Save all of the rdata members into an array.
|
||||
*/
|
||||
result = dns_rdataset_first(rdataset);
|
||||
if (result != ISC_R_SUCCESS && result != ISC_R_NOMORE)
|
||||
if (result != ISC_R_SUCCESS && result != ISC_R_NOMORE) {
|
||||
goto free_rdatas;
|
||||
}
|
||||
for (i = 0; i < nalloc && result == ISC_R_SUCCESS; i++) {
|
||||
INSIST(result == ISC_R_SUCCESS);
|
||||
dns_rdata_init(&x[i].rdata);
|
||||
@@ -177,7 +181,7 @@ dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx,
|
||||
INSIST(x[i].rdata.data != &removed);
|
||||
#if DNS_RDATASET_FIXED
|
||||
x[i].order = i;
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
result = dns_rdataset_next(rdataset);
|
||||
}
|
||||
if (i != nalloc || result != ISC_R_NOMORE) {
|
||||
@@ -194,8 +198,9 @@ dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx,
|
||||
/*
|
||||
* Put into DNSSEC order.
|
||||
*/
|
||||
if (nalloc > 1U)
|
||||
if (nalloc > 1U) {
|
||||
qsort(x, nalloc, sizeof(struct xrdata), compare_rdata);
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove duplicates and compute the total storage required.
|
||||
@@ -214,21 +219,23 @@ dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx,
|
||||
* Preserve the least order so A, B, A -> A, B
|
||||
* after duplicate removal.
|
||||
*/
|
||||
if (x[i - 1].order < x[i].order)
|
||||
if (x[i - 1].order < x[i].order) {
|
||||
x[i].order = x[i - 1].order;
|
||||
#endif
|
||||
}
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
nitems--;
|
||||
} else {
|
||||
#if DNS_RDATASET_FIXED
|
||||
buflen += (8 + x[i - 1].rdata.length);
|
||||
#else
|
||||
#else /* if DNS_RDATASET_FIXED */
|
||||
buflen += (2 + x[i - 1].rdata.length);
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
/*
|
||||
* Provide space to store the per RR meta data.
|
||||
*/
|
||||
if (rdataset->type == dns_rdatatype_rrsig)
|
||||
if (rdataset->type == dns_rdatatype_rrsig) {
|
||||
buflen++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,14 +244,15 @@ dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx,
|
||||
*/
|
||||
#if DNS_RDATASET_FIXED
|
||||
buflen += (8 + x[i - 1].rdata.length);
|
||||
#else
|
||||
#else /* if DNS_RDATASET_FIXED */
|
||||
buflen += (2 + x[i - 1].rdata.length);
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
/*
|
||||
* Provide space to store the per RR meta data.
|
||||
*/
|
||||
if (rdataset->type == dns_rdatatype_rrsig)
|
||||
if (rdataset->type == dns_rdatatype_rrsig) {
|
||||
buflen++;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ensure that singleton types are actually singletons.
|
||||
@@ -268,7 +276,7 @@ dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx,
|
||||
/* Allocate temporary offset table. */
|
||||
offsettable = isc_mem_get(mctx, nalloc * sizeof(unsigned int));
|
||||
memset(offsettable, 0, nalloc * sizeof(unsigned int));
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
|
||||
region->base = rawbuf;
|
||||
region->length = buflen;
|
||||
@@ -278,7 +286,7 @@ dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx,
|
||||
|
||||
#if DNS_RDATASET_FIXED
|
||||
offsetbase = rawbuf;
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
|
||||
*rawbuf++ = (nitems & 0xff00) >> 8;
|
||||
*rawbuf++ = (nitems & 0x00ff);
|
||||
@@ -286,23 +294,25 @@ dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx,
|
||||
#if DNS_RDATASET_FIXED
|
||||
/* Skip load order table. Filled in later. */
|
||||
rawbuf += nitems * 4;
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
|
||||
for (i = 0; i < nalloc; i++) {
|
||||
if (x[i].rdata.data == &removed)
|
||||
if (x[i].rdata.data == &removed) {
|
||||
continue;
|
||||
}
|
||||
#if DNS_RDATASET_FIXED
|
||||
offsettable[x[i].order] = rawbuf - offsetbase;
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
length = x[i].rdata.length;
|
||||
if (rdataset->type == dns_rdatatype_rrsig)
|
||||
if (rdataset->type == dns_rdatatype_rrsig) {
|
||||
length++;
|
||||
}
|
||||
INSIST(length <= 0xffff);
|
||||
*rawbuf++ = (length & 0xff00) >> 8;
|
||||
*rawbuf++ = (length & 0x00ff);
|
||||
#if DNS_RDATASET_FIXED
|
||||
rawbuf += 2; /* filled in later */
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
/*
|
||||
* Store the per RR meta data.
|
||||
*/
|
||||
@@ -318,7 +328,7 @@ dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx,
|
||||
#if DNS_RDATASET_FIXED
|
||||
fillin_offsets(offsetbase, offsettable, nalloc);
|
||||
isc_mem_put(mctx, offsettable, nalloc * sizeof(unsigned int));
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
|
||||
result = ISC_R_SUCCESS;
|
||||
|
||||
@@ -340,16 +350,16 @@ dns_rdataslab_size(unsigned char *slab, unsigned int reservelen)
|
||||
count += *current++;
|
||||
#if DNS_RDATASET_FIXED
|
||||
current += (4 * count);
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
while (count > 0) {
|
||||
count--;
|
||||
length = *current++ * 256;
|
||||
length += *current++;
|
||||
#if DNS_RDATASET_FIXED
|
||||
current += length + 2;
|
||||
#else
|
||||
#else /* if DNS_RDATASET_FIXED */
|
||||
current += length;
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
}
|
||||
|
||||
return ((unsigned int)(current - slab));
|
||||
@@ -388,20 +398,22 @@ rdata_from_slab(unsigned char **current, dns_rdataclass_t rdclass,
|
||||
length += *tcurrent++;
|
||||
|
||||
if (type == dns_rdatatype_rrsig) {
|
||||
if ((*tcurrent & DNS_RDATASLAB_OFFLINE) != 0)
|
||||
if ((*tcurrent & DNS_RDATASLAB_OFFLINE) != 0) {
|
||||
offline = true;
|
||||
}
|
||||
length--;
|
||||
tcurrent++;
|
||||
}
|
||||
region.length = length;
|
||||
#if DNS_RDATASET_FIXED
|
||||
tcurrent += 2;
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
region.base = tcurrent;
|
||||
tcurrent += region.length;
|
||||
dns_rdata_fromregion(rdata, rdclass, type, ®ion);
|
||||
if (offline)
|
||||
if (offline) {
|
||||
rdata->flags |= DNS_RDATA_OFFLINE;
|
||||
}
|
||||
*current = tcurrent;
|
||||
}
|
||||
|
||||
@@ -426,16 +438,18 @@ rdata_in_slab(unsigned char *slab, unsigned int reservelen,
|
||||
|
||||
#if DNS_RDATASET_FIXED
|
||||
current += (4 * count);
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
rdata_from_slab(¤t, rdclass, type, &trdata);
|
||||
|
||||
n = dns_rdata_compare(&trdata, rdata);
|
||||
if (n == 0)
|
||||
if (n == 0) {
|
||||
return (true);
|
||||
if (n > 0) /* In DNSSEC order. */
|
||||
}
|
||||
if (n > 0) { /* In DNSSEC order. */
|
||||
break;
|
||||
}
|
||||
dns_rdata_reset(&trdata);
|
||||
}
|
||||
return (false);
|
||||
@@ -461,7 +475,7 @@ dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab,
|
||||
unsigned int oorder = 0;
|
||||
unsigned char *offsetbase;
|
||||
unsigned int * offsettable;
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
|
||||
/*
|
||||
* XXX Need parameter to allow "delete rdatasets in nslab" merge,
|
||||
@@ -476,19 +490,19 @@ dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab,
|
||||
ocount += *ocurrent++;
|
||||
#if DNS_RDATASET_FIXED
|
||||
ocurrent += (4 * ocount);
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
ostart = ocurrent;
|
||||
ncurrent = nslab + reservelen;
|
||||
ncount = *ncurrent++ * 256;
|
||||
ncount += *ncurrent++;
|
||||
#if DNS_RDATASET_FIXED
|
||||
ncurrent += (4 * ncount);
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
INSIST(ocount > 0 && ncount > 0);
|
||||
|
||||
#if DNS_RDATASET_FIXED
|
||||
oncount = ncount;
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
|
||||
/*
|
||||
* Yes, this is inefficient!
|
||||
@@ -504,10 +518,10 @@ dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab,
|
||||
#if DNS_RDATASET_FIXED
|
||||
olength += length + 8;
|
||||
ocurrent += length + 2;
|
||||
#else
|
||||
#else /* if DNS_RDATASET_FIXED */
|
||||
olength += length + 2;
|
||||
ocurrent += length;
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -529,11 +543,12 @@ dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab,
|
||||
*/
|
||||
#if DNS_RDATASET_FIXED
|
||||
tlength += nrdata.length + 8;
|
||||
#else
|
||||
#else /* if DNS_RDATASET_FIXED */
|
||||
tlength += nrdata.length + 2;
|
||||
#endif
|
||||
if (type == dns_rdatatype_rrsig)
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
if (type == dns_rdatatype_rrsig) {
|
||||
tlength++;
|
||||
}
|
||||
tcount++;
|
||||
nncount++;
|
||||
added_something = true;
|
||||
@@ -542,11 +557,14 @@ dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab,
|
||||
} while (ncount > 0);
|
||||
ncount = nncount;
|
||||
|
||||
if (((flags & DNS_RDATASLAB_EXACT) != 0) && (tcount != ncount + ocount))
|
||||
if (((flags & DNS_RDATASLAB_EXACT) != 0) &&
|
||||
(tcount != ncount + ocount)) {
|
||||
return (DNS_R_NOTEXACT);
|
||||
}
|
||||
|
||||
if (!added_something && (flags & DNS_RDATASLAB_FORCE) == 0)
|
||||
if (!added_something && (flags & DNS_RDATASLAB_FORCE) == 0) {
|
||||
return (DNS_R_UNCHANGED);
|
||||
}
|
||||
|
||||
/*
|
||||
* Ensure that singleton types are actually singletons.
|
||||
@@ -559,8 +577,9 @@ dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab,
|
||||
return (DNS_R_SINGLETON);
|
||||
}
|
||||
|
||||
if (tcount > 0xffff)
|
||||
if (tcount > 0xffff) {
|
||||
return (ISC_R_NOSPACE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy the reserved area from the new slab.
|
||||
@@ -570,7 +589,7 @@ dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab,
|
||||
tcurrent = tstart + reservelen;
|
||||
#if DNS_RDATASET_FIXED
|
||||
offsetbase = tcurrent;
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
|
||||
/*
|
||||
* Write the new count.
|
||||
@@ -587,7 +606,7 @@ dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab,
|
||||
offsettable =
|
||||
isc_mem_get(mctx, (ocount + oncount) * sizeof(unsigned int));
|
||||
memset(offsettable, 0, (ocount + oncount) * sizeof(unsigned int));
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
|
||||
/*
|
||||
* Merge the two slabs.
|
||||
@@ -597,13 +616,13 @@ dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab,
|
||||
#if DNS_RDATASET_FIXED
|
||||
oorder = ocurrent[2] * 256 + ocurrent[3];
|
||||
INSIST(oorder < ocount);
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
rdata_from_slab(&ocurrent, rdclass, type, &ordata);
|
||||
|
||||
ncurrent = nslab + reservelen + 2;
|
||||
#if DNS_RDATASET_FIXED
|
||||
ncurrent += (4 * oncount);
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
|
||||
if (ncount > 0) {
|
||||
do {
|
||||
@@ -612,7 +631,7 @@ dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab,
|
||||
norder = ncurrent[2] * 256 + ncurrent[3];
|
||||
|
||||
INSIST(norder < oncount);
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
rdata_from_slab(&ncurrent, rdclass, type, &nrdata);
|
||||
} while (rdata_in_slab(oslab, reservelen, rdclass, type,
|
||||
&nrdata));
|
||||
@@ -620,16 +639,17 @@ dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab,
|
||||
|
||||
while (oadded < ocount || nadded < ncount) {
|
||||
bool fromold;
|
||||
if (oadded == ocount)
|
||||
if (oadded == ocount) {
|
||||
fromold = false;
|
||||
else if (nadded == ncount)
|
||||
} else if (nadded == ncount) {
|
||||
fromold = true;
|
||||
else
|
||||
} else {
|
||||
fromold = (dns_rdata_compare(&ordata, &nrdata) < 0);
|
||||
}
|
||||
if (fromold) {
|
||||
#if DNS_RDATASET_FIXED
|
||||
offsettable[oorder] = tcurrent - offsetbase;
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
length = ordata.length;
|
||||
data = ordata.data;
|
||||
if (type == dns_rdatatype_rrsig) {
|
||||
@@ -640,7 +660,7 @@ dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab,
|
||||
*tcurrent++ = (length & 0x00ff);
|
||||
#if DNS_RDATASET_FIXED
|
||||
tcurrent += 2; /* fill in later */
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
memmove(tcurrent, data, length);
|
||||
tcurrent += length;
|
||||
oadded++;
|
||||
@@ -649,14 +669,14 @@ dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab,
|
||||
#if DNS_RDATASET_FIXED
|
||||
oorder = ocurrent[2] * 256 + ocurrent[3];
|
||||
INSIST(oorder < ocount);
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
rdata_from_slab(&ocurrent, rdclass, type,
|
||||
&ordata);
|
||||
}
|
||||
} else {
|
||||
#if DNS_RDATASET_FIXED
|
||||
offsettable[ocount + norder] = tcurrent - offsetbase;
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
length = nrdata.length;
|
||||
data = nrdata.data;
|
||||
if (type == dns_rdatatype_rrsig) {
|
||||
@@ -667,7 +687,7 @@ dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab,
|
||||
*tcurrent++ = (length & 0x00ff);
|
||||
#if DNS_RDATASET_FIXED
|
||||
tcurrent += 2; /* fill in later */
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
memmove(tcurrent, data, length);
|
||||
tcurrent += length;
|
||||
nadded++;
|
||||
@@ -678,7 +698,7 @@ dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab,
|
||||
norder =
|
||||
ncurrent[2] * 256 + ncurrent[3];
|
||||
INSIST(norder < oncount);
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
rdata_from_slab(&ncurrent, rdclass,
|
||||
type, &nrdata);
|
||||
} while (rdata_in_slab(oslab, reservelen,
|
||||
@@ -692,7 +712,7 @@ dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab,
|
||||
|
||||
isc_mem_put(mctx, offsettable,
|
||||
(ocount + oncount) * sizeof(unsigned int));
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
|
||||
INSIST(tcurrent == tstart + tlength);
|
||||
|
||||
@@ -715,7 +735,7 @@ dns_rdataslab_subtract(unsigned char *mslab, unsigned char *sslab,
|
||||
unsigned char *offsetbase;
|
||||
unsigned int * offsettable;
|
||||
unsigned int order;
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
|
||||
REQUIRE(tslabp != NULL && *tslabp == NULL);
|
||||
REQUIRE(mslab != NULL && sslab != NULL);
|
||||
@@ -742,7 +762,7 @@ dns_rdataslab_subtract(unsigned char *mslab, unsigned char *sslab,
|
||||
#if DNS_RDATASET_FIXED
|
||||
mcurrent += 4 * mcount;
|
||||
scurrent += 4 * scount;
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
sstart = scurrent;
|
||||
|
||||
/*
|
||||
@@ -756,8 +776,9 @@ dns_rdataslab_subtract(unsigned char *mslab, unsigned char *sslab,
|
||||
for (count = 0; count < scount; count++) {
|
||||
dns_rdata_reset(&srdata);
|
||||
rdata_from_slab(&scurrent, rdclass, type, &srdata);
|
||||
if (dns_rdata_compare(&mrdata, &srdata) == 0)
|
||||
if (dns_rdata_compare(&mrdata, &srdata) == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (count == scount) {
|
||||
/*
|
||||
@@ -766,33 +787,37 @@ dns_rdataslab_subtract(unsigned char *mslab, unsigned char *sslab,
|
||||
*/
|
||||
tlength += (unsigned int)(mcurrent - mrdatabegin);
|
||||
tcount++;
|
||||
} else
|
||||
} else {
|
||||
rcount++;
|
||||
}
|
||||
dns_rdata_reset(&mrdata);
|
||||
}
|
||||
|
||||
#if DNS_RDATASET_FIXED
|
||||
tlength += (4 * tcount);
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
|
||||
/*
|
||||
* Check that all the records originally existed. The numeric
|
||||
* check only works as rdataslabs do not contain duplicates.
|
||||
*/
|
||||
if (((flags & DNS_RDATASLAB_EXACT) != 0) && (rcount != scount))
|
||||
if (((flags & DNS_RDATASLAB_EXACT) != 0) && (rcount != scount)) {
|
||||
return (DNS_R_NOTEXACT);
|
||||
}
|
||||
|
||||
/*
|
||||
* Don't continue if the new rdataslab would be empty.
|
||||
*/
|
||||
if (tcount == 0)
|
||||
if (tcount == 0) {
|
||||
return (DNS_R_NXRRSET);
|
||||
}
|
||||
|
||||
/*
|
||||
* If nothing is going to change, we can stop.
|
||||
*/
|
||||
if (rcount == 0)
|
||||
if (rcount == 0) {
|
||||
return (DNS_R_UNCHANGED);
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy the reserved area from the mslab.
|
||||
@@ -805,7 +830,7 @@ dns_rdataslab_subtract(unsigned char *mslab, unsigned char *sslab,
|
||||
|
||||
offsettable = isc_mem_get(mctx, mcount * sizeof(unsigned int));
|
||||
memset(offsettable, 0, mcount * sizeof(unsigned int));
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
|
||||
/*
|
||||
* Write the new count.
|
||||
@@ -815,7 +840,7 @@ dns_rdataslab_subtract(unsigned char *mslab, unsigned char *sslab,
|
||||
|
||||
#if DNS_RDATASET_FIXED
|
||||
tcurrent += (4 * tcount);
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
|
||||
/*
|
||||
* Copy the parts of mslab not in sslab.
|
||||
@@ -825,20 +850,21 @@ dns_rdataslab_subtract(unsigned char *mslab, unsigned char *sslab,
|
||||
mcount += *mcurrent++;
|
||||
#if DNS_RDATASET_FIXED
|
||||
mcurrent += (4 * mcount);
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
for (i = 0; i < mcount; i++) {
|
||||
unsigned char *mrdatabegin = mcurrent;
|
||||
#if DNS_RDATASET_FIXED
|
||||
order = mcurrent[2] * 256 + mcurrent[3];
|
||||
INSIST(order < mcount);
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
rdata_from_slab(&mcurrent, rdclass, type, &mrdata);
|
||||
scurrent = sstart;
|
||||
for (count = 0; count < scount; count++) {
|
||||
dns_rdata_reset(&srdata);
|
||||
rdata_from_slab(&scurrent, rdclass, type, &srdata);
|
||||
if (dns_rdata_compare(&mrdata, &srdata) == 0)
|
||||
if (dns_rdata_compare(&mrdata, &srdata) == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (count == scount) {
|
||||
/*
|
||||
@@ -849,7 +875,7 @@ dns_rdataslab_subtract(unsigned char *mslab, unsigned char *sslab,
|
||||
length = (unsigned int)(mcurrent - mrdatabegin);
|
||||
#if DNS_RDATASET_FIXED
|
||||
offsettable[order] = tcurrent - offsetbase;
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
memmove(tcurrent, mrdatabegin, length);
|
||||
tcurrent += length;
|
||||
}
|
||||
@@ -860,7 +886,7 @@ dns_rdataslab_subtract(unsigned char *mslab, unsigned char *sslab,
|
||||
fillin_offsets(offsetbase, offsettable, mcount);
|
||||
|
||||
isc_mem_put(mctx, offsettable, mcount * sizeof(unsigned int));
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
|
||||
INSIST(tcurrent == tstart + tlength);
|
||||
|
||||
@@ -885,13 +911,14 @@ dns_rdataslab_equal(unsigned char *slab1, unsigned char *slab2,
|
||||
count2 = *current2++ * 256;
|
||||
count2 += *current2++;
|
||||
|
||||
if (count1 != count2)
|
||||
if (count1 != count2) {
|
||||
return (false);
|
||||
}
|
||||
|
||||
#if DNS_RDATASET_FIXED
|
||||
current1 += (4 * count1);
|
||||
current2 += (4 * count2);
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
|
||||
while (count1 > 0) {
|
||||
length1 = *current1++ * 256;
|
||||
@@ -903,11 +930,12 @@ dns_rdataslab_equal(unsigned char *slab1, unsigned char *slab2,
|
||||
#if DNS_RDATASET_FIXED
|
||||
current1 += 2;
|
||||
current2 += 2;
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
|
||||
if (length1 != length2 ||
|
||||
memcmp(current1, current2, length1) != 0)
|
||||
memcmp(current1, current2, length1) != 0) {
|
||||
return (false);
|
||||
}
|
||||
|
||||
current1 += length1;
|
||||
current2 += length1;
|
||||
@@ -935,19 +963,21 @@ dns_rdataslab_equalx(unsigned char *slab1, unsigned char *slab2,
|
||||
count2 = *current2++ * 256;
|
||||
count2 += *current2++;
|
||||
|
||||
if (count1 != count2)
|
||||
if (count1 != count2) {
|
||||
return (false);
|
||||
}
|
||||
|
||||
#if DNS_RDATASET_FIXED
|
||||
current1 += (4 * count1);
|
||||
current2 += (4 * count2);
|
||||
#endif
|
||||
#endif /* if DNS_RDATASET_FIXED */
|
||||
|
||||
while (count1-- > 0) {
|
||||
rdata_from_slab(¤t1, rdclass, type, &rdata1);
|
||||
rdata_from_slab(¤t2, rdclass, type, &rdata2);
|
||||
if (dns_rdata_compare(&rdata1, &rdata2) != 0)
|
||||
if (dns_rdata_compare(&rdata1, &rdata2) != 0) {
|
||||
return (false);
|
||||
}
|
||||
dns_rdata_reset(&rdata1);
|
||||
dns_rdata_reset(&rdata2);
|
||||
}
|
||||
|
Reference in New Issue
Block a user