2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 22:45:39 +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:
Ondřej Surý
2020-02-13 21:48:23 +01:00
parent d14bb71319
commit 056e133c4c
637 changed files with 28926 additions and 16901 deletions

View File

@@ -150,11 +150,13 @@ dns_compress_invalidate(dns_compress_t *cctx)
while (cctx->table[i] != NULL) {
node = cctx->table[i];
cctx->table[i] = cctx->table[i]->next;
if ((node->offset & 0x8000) != 0)
if ((node->offset & 0x8000) != 0) {
isc_mem_put(cctx->mctx, node->r.base,
node->r.length);
if (node->count < DNS_COMPRESS_INITIALNODES)
}
if (node->count < DNS_COMPRESS_INITIALNODES) {
continue;
}
isc_mem_put(cctx->mctx, node, sizeof(*node));
}
}
@@ -192,10 +194,11 @@ dns_compress_setsensitive(dns_compress_t *cctx, bool sensitive)
{
REQUIRE(VALID_CCTX(cctx));
if (sensitive)
if (sensitive) {
cctx->allowed |= DNS_COMPRESS_CASESENSITIVE;
else
} else {
cctx->allowed &= ~DNS_COMPRESS_CASESENSITIVE;
}
}
bool
@@ -232,11 +235,13 @@ dns_compress_findglobal(dns_compress_t *cctx, const dns_name_t *name,
REQUIRE(dns_name_isabsolute(name) == true);
REQUIRE(offset != NULL);
if (ISC_UNLIKELY((cctx->allowed & DNS_COMPRESS_ENABLED) == 0))
if (ISC_UNLIKELY((cctx->allowed & DNS_COMPRESS_ENABLED) == 0)) {
return (false);
}
if (cctx->count == 0)
if (cctx->count == 0) {
return (false);
}
labels = dns_name_countlabels(name);
INSIST(labels > 0);
@@ -263,12 +268,14 @@ dns_compress_findglobal(dns_compress_t *cctx, const dns_name_t *name,
0)) {
for (node = cctx->table[i]; node != NULL;
node = node->next) {
if (ISC_UNLIKELY(node->name.length != length))
if (ISC_UNLIKELY(node->name.length != length)) {
continue;
}
if (ISC_LIKELY(memcmp(node->name.ndata, p,
length) == 0))
length) == 0)) {
goto found;
}
}
} else {
for (node = cctx->table[i]; node != NULL;
@@ -277,19 +284,22 @@ dns_compress_findglobal(dns_compress_t *cctx, const dns_name_t *name,
unsigned char c;
unsigned char *label1, *label2;
if (ISC_UNLIKELY(node->name.length != length))
if (ISC_UNLIKELY(node->name.length != length)) {
continue;
}
l = labels - n;
if (ISC_UNLIKELY(node->name.labels != l))
if (ISC_UNLIKELY(node->name.labels != l)) {
continue;
}
label1 = node->name.ndata;
label2 = p;
while (ISC_LIKELY(l-- > 0)) {
count = *label1++;
if (count != *label2++)
if (count != *label2++) {
goto cont1;
}
/* no bitstring support */
INSIST(count <= 63);
@@ -297,25 +307,35 @@ dns_compress_findglobal(dns_compress_t *cctx, const dns_name_t *name,
/* Loop unrolled for performance */
while (ISC_LIKELY(count > 3)) {
c = maptolower[label1[0]];
if (c != maptolower[label2[0]])
if (c !=
maptolower[label2[0]]) {
goto cont1;
}
c = maptolower[label1[1]];
if (c != maptolower[label2[1]])
if (c !=
maptolower[label2[1]]) {
goto cont1;
}
c = maptolower[label1[2]];
if (c != maptolower[label2[2]])
if (c !=
maptolower[label2[2]]) {
goto cont1;
}
c = maptolower[label1[3]];
if (c != maptolower[label2[3]])
if (c !=
maptolower[label2[3]]) {
goto cont1;
}
count -= 4;
label1 += 4;
label2 += 4;
}
while (ISC_LIKELY(count-- > 0)) {
c = maptolower[*label1++];
if (c != maptolower[*label2++])
if (c !=
maptolower[*label2++]) {
goto cont1;
}
}
}
break;
@@ -324,8 +344,9 @@ dns_compress_findglobal(dns_compress_t *cctx, const dns_name_t *name,
}
}
if (node != NULL)
if (node != NULL) {
break;
}
llen = *p;
p += llen + 1;
@@ -335,13 +356,15 @@ found:
/*
* If node == NULL, we found no match at all.
*/
if (node == NULL)
if (node == NULL) {
return (false);
}
if (n == 0)
if (n == 0) {
dns_name_reset(prefix);
else
} else {
dns_name_getlabelsequence(name, 0, n, prefix);
}
*offset = (node->offset & 0x7fff);
return (true);
@@ -374,20 +397,24 @@ dns_compress_add(dns_compress_t *cctx, const dns_name_t *name,
REQUIRE(VALID_CCTX(cctx));
REQUIRE(dns_name_isabsolute(name));
if (ISC_UNLIKELY((cctx->allowed & DNS_COMPRESS_ENABLED) == 0))
if (ISC_UNLIKELY((cctx->allowed & DNS_COMPRESS_ENABLED) == 0)) {
return;
}
if (offset >= 0x4000)
if (offset >= 0x4000) {
return;
}
dns_name_init(&tname, NULL);
dns_name_init(&xname, NULL);
n = dns_name_countlabels(name);
count = dns_name_countlabels(prefix);
if (dns_name_isabsolute(prefix))
if (dns_name_isabsolute(prefix)) {
count--;
if (count == 0)
}
if (count == 0) {
return;
}
start = 0;
dns_name_toregion(name, &r);
length = r.length;
@@ -399,8 +426,9 @@ dns_compress_add(dns_compress_t *cctx, const dns_name_t *name,
r.base = tmp;
dns_name_fromregion(&xname, &r);
if (count > 2U)
if (count > 2U) {
count = 2U;
}
while (count > 0) {
unsigned char ch;
@@ -414,14 +442,15 @@ dns_compress_add(dns_compress_t *cctx, const dns_name_t *name,
i = tableindex[ch];
tlength = name_length(&tname);
toffset = (uint16_t)(offset + (length - tlength));
if (toffset >= 0x4000)
if (toffset >= 0x4000) {
break;
}
/*
* Create a new node and add it.
*/
if (cctx->count < DNS_COMPRESS_INITIALNODES)
if (cctx->count < DNS_COMPRESS_INITIALNODES) {
node = &cctx->initialnodes[cctx->count];
else {
} else {
node = isc_mem_get(cctx->mctx,
sizeof(dns_compressnode_t));
}
@@ -430,8 +459,9 @@ dns_compress_add(dns_compress_t *cctx, const dns_name_t *name,
* 'node->r.base' becomes 'tmp' when start == 0.
* Record this by setting 0x8000 so it can be freed later.
*/
if (start == 0)
if (start == 0) {
toffset |= 0x8000;
}
node->offset = toffset;
dns_name_toregion(&tname, &node->r);
dns_name_init(&node->name, NULL);
@@ -446,8 +476,9 @@ dns_compress_add(dns_compress_t *cctx, const dns_name_t *name,
count--;
}
if (start == 0)
if (start == 0) {
isc_mem_put(cctx->mctx, tmp, length);
}
}
void
@@ -458,8 +489,9 @@ dns_compress_rollback(dns_compress_t *cctx, uint16_t offset)
REQUIRE(VALID_CCTX(cctx));
if (ISC_UNLIKELY((cctx->allowed & DNS_COMPRESS_ENABLED) == 0))
if (ISC_UNLIKELY((cctx->allowed & DNS_COMPRESS_ENABLED) == 0)) {
return;
}
for (i = 0; i < DNS_COMPRESS_TABLESIZE; i++) {
node = cctx->table[i];
@@ -471,11 +503,13 @@ dns_compress_rollback(dns_compress_t *cctx, uint16_t offset)
*/
while (node != NULL && (node->offset & 0x7fff) >= offset) {
cctx->table[i] = node->next;
if ((node->offset & 0x8000) != 0)
if ((node->offset & 0x8000) != 0) {
isc_mem_put(cctx->mctx, node->r.base,
node->r.length);
if (node->count >= DNS_COMPRESS_INITIALNODES)
}
if (node->count >= DNS_COMPRESS_INITIALNODES) {
isc_mem_put(cctx->mctx, node, sizeof(*node));
}
cctx->count--;
node = cctx->table[i];
}