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

Add couple missing braces around single-line statements

The clang-format-15 has new option InsertBraces that could add missing
branches around single line statements.  Use that to our advantage
without switching to not-yet-released LLVM version to add missing braces
in couple of places.
This commit is contained in:
Ondřej Surý
2022-03-13 13:05:27 +01:00
parent 8495edc31d
commit ff22498849
10 changed files with 33 additions and 16 deletions

View File

@@ -490,10 +490,12 @@ dns64prefix_answer(dns_message_t *msg, isc_buffer_t *buf) {
}
result = dns_dns64_findprefix(rdataset, prefix, &count);
if (result == ISC_R_NOTFOUND)
if (result == ISC_R_NOTFOUND) {
return (ISC_R_SUCCESS);
if (count > 10)
}
if (count > 10) {
count = 10;
}
for (i = 0; i < count; i++) {
result = isc_netaddr_totext(&prefix[i].addr, buf);
if (result != ISC_R_SUCCESS) {
@@ -903,8 +905,9 @@ repopulate_buffer:
check_result(result, "dns_message_sectiontotext");
} else if (dns64prefix) {
result = dns64prefix_answer(msg, buf);
if (result == ISC_R_NOSPACE)
if (result == ISC_R_NOSPACE) {
goto buftoosmall;
}
check_result(result, "dns64prefix_answer");
} else {
result = short_answer(msg, flags, buf, query);

View File

@@ -474,8 +474,9 @@ dlz_lookup(const char *zone, const char *name, void *dbdata,
}
if (strcmp(name, "too-long") == 0) {
for (i = 0; i < 511; i++)
for (i = 0; i < 511; i++) {
buf[i] = 'x';
}
buf[i] = '\0';
found = true;
result = state->putrr(lookup, "TXT", 0, buf);

View File

@@ -468,8 +468,9 @@ mysql_process_rs(mysql_instance_t *db, dns_sdlzlookup_t *lookup,
* ones together. figure out how long to make
* string.
*/
for (j = 2; j < fields; j++)
for (j = 2; j < fields; j++) {
len += strlen(safeGet(row[j])) + 1;
}
/*
* allocate string memory, allow for NULL to
@@ -668,8 +669,9 @@ dlz_allnodes(const char *zone, void *dbdata, dns_sdlzallnodes_t *allnodes) {
* more than 4 fields, concatenate the last
* ones together.
*/
for (j = 3; j < fields; j++)
for (j = 3; j < fields; j++) {
len += strlen(safeGet(row[j])) + 1;
}
tmpString = malloc(len + 1);
if (tmpString == NULL) {

View File

@@ -706,8 +706,9 @@ make_notify(const char *zone, int *packetlen) {
/* Make the question into labels */
j = 12;
while (packet[j]) {
for (i = j + 1; packet[i] != '\0' && packet[i] != '.'; i++)
for (i = j + 1; packet[i] != '\0' && packet[i] != '.'; i++) {
;
}
packet[j] = i - j - 1;
j = i;
}

View File

@@ -537,8 +537,9 @@ sqlite3_process_rs(sqlite3_instance_t *db, dns_sdlzlookup_t *lookup,
* ones together. figure out how long to make
* string.
*/
for (j = 2; j < fields; j++)
for (j = 2; j < fields; j++) {
len += strlen(safeGet(row[j])) + 1;
}
/*
* allocate string memory, allow for NULL to
@@ -739,8 +740,9 @@ dlz_allnodes(const char *zone, void *dbdata, dns_sdlzallnodes_t *allnodes) {
* more than 4 fields, concatenate the last
* ones together.
*/
for (j = 3; j < fields; j++)
for (j = 3; j < fields; j++) {
len += strlen(safeGet(row[j])) + 1;
}
tmpString = malloc(len + 1);
if (tmpString == NULL) {

View File

@@ -585,7 +585,7 @@ fnmatch(const char *pattern, const char *string, int flags) {
char *newp;
char c, test;
for (stringstart = string;;)
for (stringstart = string;;) {
switch (c = *pattern++) {
case EOS:
if ((flags & FNM_LEADING_DIR) && *string == '/') {
@@ -698,6 +698,7 @@ fnmatch(const char *pattern, const char *string, int flags) {
string++;
break;
}
}
/* NOTREACHED */
}

View File

@@ -394,8 +394,9 @@ openssleddsa_todns(const dst_key_t *key, isc_buffer_t *data) {
return (ISC_R_NOSPACE);
}
if (EVP_PKEY_get_raw_public_key(pkey, r.base, &len) != 1)
if (EVP_PKEY_get_raw_public_key(pkey, r.base, &len) != 1) {
return (dst__openssl_toresult(ISC_R_FAILURE));
}
isc_buffer_add(data, len);
return (ISC_R_SUCCESS);
@@ -418,8 +419,9 @@ openssleddsa_fromdns(dst_key_t *key, isc_buffer_t *data) {
len = r.length;
ret = raw_key_to_ossl(key->key_alg, 0, r.base, &len, &pkey);
if (ret != ISC_R_SUCCESS)
if (ret != ISC_R_SUCCESS) {
return ret;
}
isc_buffer_forward(data, len);
key->keydata.pkey = pkey;
@@ -457,8 +459,9 @@ openssleddsa_tofile(const dst_key_t *key, const char *directory) {
}
buf = isc_mem_get(key->mctx, len);
if (EVP_PKEY_get_raw_private_key(key->keydata.pkey, buf,
&len) != 1)
&len) != 1) {
DST_RET(dst__openssl_toresult(ISC_R_FAILURE));
}
priv.elements[i].tag = TAG_EDDSA_PRIVATEKEY;
priv.elements[i].length = len;
priv.elements[i].data = buf;

View File

@@ -72,8 +72,9 @@ fromwire_gpos(ARGS_FROMWIRE) {
UNUSED(rdclass);
UNUSED(options);
for (i = 0; i < 3; i++)
for (i = 0; i < 3; i++) {
RETERR(txt_fromwire(source, target));
}
return (ISC_R_SUCCESS);
}

View File

@@ -290,7 +290,9 @@ fromstruct_hip(ARGS_FROMSTRUCT) {
myhip = *hip;
for (result = dns_rdata_hip_first(&myhip); result == ISC_R_SUCCESS;
result = dns_rdata_hip_next(&myhip))
/* empty */;
{
/* initialize the names */
}
return (mem_tobuffer(target, hip->servers, hip->servers_len));
}

View File

@@ -473,8 +473,9 @@ mem_thread(isc_threadarg_t arg) {
isc_mem_t *mctx = (isc_mem_t *)arg;
void *items[NUM_ITEMS];
size_t size = atomic_load(&mem_size);
while (!atomic_compare_exchange_weak(&mem_size, &size, size / 2))
while (!atomic_compare_exchange_weak(&mem_size, &size, size / 2)) {
;
}
for (int i = 0; i < ITERS; i++) {
for (int j = 0; j < NUM_ITEMS; j++) {