2
0
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:
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

@@ -122,8 +122,9 @@ find_value(const char *s, const unsigned int alg)
for (i = 0; map[i].tag != NULL; i++) {
if (strcasecmp(s, map[i].tag) == 0 &&
(TAG_ALG(map[i].value) == alg))
(TAG_ALG(map[i].value) == alg)) {
return (map[i].value);
}
}
return (-1);
}
@@ -134,10 +135,11 @@ find_tag(const int value)
int i;
for (i = 0;; i++) {
if (map[i].tag == NULL)
if (map[i].tag == NULL) {
return (NULL);
else if (value == map[i].value)
} else if (value == map[i].value) {
return (map[i].tag);
}
}
}
@@ -147,8 +149,9 @@ find_metadata(const char *s, const char *tags[], int ntags)
int i;
for (i = 0; i < ntags; i++) {
if (tags[i] != NULL && strcasecmp(s, tags[i]) == 0)
if (tags[i] != NULL && strcasecmp(s, tags[i]) == 0) {
return (i);
}
}
return (-1);
@@ -174,11 +177,13 @@ check_rsa(const dst_private_t *priv, bool external)
bool ok;
unsigned int mask;
if (external)
if (external) {
return ((priv->nelements == 0) ? 0 : -1);
}
for (i = 0; i < RSA_NTAGS; i++)
for (i = 0; i < RSA_NTAGS; i++) {
have[i] = false;
}
for (j = 0; j < priv->nelements; j++) {
for (i = 0; i < RSA_NTAGS; i++) {
@@ -186,18 +191,19 @@ check_rsa(const dst_private_t *priv, bool external)
break;
}
}
if (i == RSA_NTAGS)
if (i == RSA_NTAGS) {
return (-1);
}
have[i] = true;
}
mask = (1ULL << TAG_SHIFT) - 1;
if (have[TAG_RSA_ENGINE & mask])
if (have[TAG_RSA_ENGINE & mask]) {
ok = have[TAG_RSA_MODULUS & mask] &&
have[TAG_RSA_PUBLICEXPONENT & mask] &&
have[TAG_RSA_LABEL & mask];
else
} else {
ok = have[TAG_RSA_MODULUS & mask] &&
have[TAG_RSA_PUBLICEXPONENT & mask] &&
have[TAG_RSA_PRIVATEEXPONENT & mask] &&
@@ -206,6 +212,7 @@ check_rsa(const dst_private_t *priv, bool external)
have[TAG_RSA_EXPONENT1 & mask] &&
have[TAG_RSA_EXPONENT2 & mask] &&
have[TAG_RSA_COEFFICIENT & mask];
}
return (ok ? 0 : -1);
}
@@ -213,16 +220,18 @@ static int
check_dh(const dst_private_t *priv)
{
int i, j;
if (priv->nelements != DH_NTAGS)
if (priv->nelements != DH_NTAGS) {
return (-1);
}
for (i = 0; i < DH_NTAGS; i++) {
for (j = 0; j < priv->nelements; j++) {
if (priv->elements[j].tag == TAG(DST_ALG_DH, i)) {
break;
}
}
if (j == priv->nelements)
if (j == priv->nelements) {
return (-1);
}
}
return (0);
}
@@ -235,28 +244,32 @@ check_ecdsa(const dst_private_t *priv, bool external)
bool ok;
unsigned int mask;
if (external)
if (external) {
return ((priv->nelements == 0) ? 0 : -1);
}
for (i = 0; i < ECDSA_NTAGS; i++)
for (i = 0; i < ECDSA_NTAGS; i++) {
have[i] = false;
}
for (j = 0; j < priv->nelements; j++) {
for (i = 0; i < ECDSA_NTAGS; i++) {
if (priv->elements[j].tag == TAG(DST_ALG_ECDSA256, i)) {
break;
}
}
if (i == ECDSA_NTAGS)
if (i == ECDSA_NTAGS) {
return (-1);
}
have[i] = true;
}
mask = (1ULL << TAG_SHIFT) - 1;
if (have[TAG_ECDSA_ENGINE & mask])
if (have[TAG_ECDSA_ENGINE & mask]) {
ok = have[TAG_ECDSA_LABEL & mask];
else
} else {
ok = have[TAG_ECDSA_PRIVATEKEY & mask];
}
return (ok ? 0 : -1);
}
@@ -268,28 +281,32 @@ check_eddsa(const dst_private_t *priv, bool external)
bool ok;
unsigned int mask;
if (external)
if (external) {
return ((priv->nelements == 0) ? 0 : -1);
}
for (i = 0; i < EDDSA_NTAGS; i++)
for (i = 0; i < EDDSA_NTAGS; i++) {
have[i] = false;
}
for (j = 0; j < priv->nelements; j++) {
for (i = 0; i < EDDSA_NTAGS; i++) {
if (priv->elements[j].tag == TAG(DST_ALG_ED25519, i)) {
break;
}
}
if (i == EDDSA_NTAGS)
if (i == EDDSA_NTAGS) {
return (-1);
}
have[i] = true;
}
mask = (1ULL << TAG_SHIFT) - 1;
if (have[TAG_EDDSA_ENGINE & mask])
if (have[TAG_EDDSA_ENGINE & mask]) {
ok = have[TAG_EDDSA_LABEL & mask];
else
} else {
ok = have[TAG_EDDSA_PRIVATEKEY & mask];
}
return (ok ? 0 : -1);
}
@@ -304,8 +321,9 @@ check_hmac_md5(const dst_private_t *priv, bool old)
* the old format return success.
*/
if (old && priv->nelements == OLD_HMACMD5_NTAGS &&
priv->elements[0].tag == TAG_HMACMD5_KEY)
priv->elements[0].tag == TAG_HMACMD5_KEY) {
return (0);
}
return (-1);
}
/*
@@ -317,8 +335,9 @@ check_hmac_md5(const dst_private_t *priv, bool old)
break;
}
}
if (j == priv->nelements)
if (j == priv->nelements) {
return (-1);
}
}
return (0);
}
@@ -327,16 +346,18 @@ static int
check_hmac_sha(const dst_private_t *priv, unsigned int ntags, unsigned int alg)
{
unsigned int i, j;
if (priv->nelements != ntags)
if (priv->nelements != ntags) {
return (-1);
}
for (i = 0; i < ntags; i++) {
for (j = 0; j < priv->nelements; j++) {
if (priv->elements[j].tag == TAG(alg, i)) {
break;
}
}
if (j == priv->nelements)
if (j == priv->nelements) {
return (-1);
}
}
return (0);
}
@@ -383,11 +404,13 @@ dst__privstruct_free(dst_private_t *priv, isc_mem_t *mctx)
{
int i;
if (priv == NULL)
if (priv == NULL) {
return;
}
for (i = 0; i < priv->nelements; i++) {
if (priv->elements[i].data == NULL)
if (priv->elements[i].data == NULL) {
continue;
}
memset(priv->elements[i].data, 0, MAXFIELDSIZE);
isc_mem_put(mctx, priv->elements[i].data, MAXFIELDSIZE);
}
@@ -488,10 +511,12 @@ dst__privstruct_parse(dst_key_t *key, unsigned int alg, isc_lex_t *lex,
isc_region_t r;
do {
ret = isc_lex_gettoken(lex, opt, &token);
if (ret == ISC_R_EOF)
if (ret == ISC_R_EOF) {
goto done;
if (ret != ISC_R_SUCCESS)
}
if (ret != ISC_R_SUCCESS) {
goto fail;
}
} while (token.type == isc_tokentype_eol);
if (token.type != isc_tokentype_string) {
@@ -531,8 +556,9 @@ dst__privstruct_parse(dst_key_t *key, unsigned int alg, isc_lex_t *lex,
}
ret = dns_time32_fromtext(DST_AS_STR(token), &when);
if (ret != ISC_R_SUCCESS)
if (ret != ISC_R_SUCCESS) {
goto fail;
}
dst_key_settime(key, tag, when);
@@ -541,9 +567,9 @@ dst__privstruct_parse(dst_key_t *key, unsigned int alg, isc_lex_t *lex,
/* Key data */
tag = find_value(DST_AS_STR(token), alg);
if (tag < 0 && minor > DST_MINOR_VERSION)
if (tag < 0 && minor > DST_MINOR_VERSION) {
goto next;
else if (tag < 0) {
} else if (tag < 0) {
ret = DST_R_INVALIDPRIVATEKEY;
goto fail;
}
@@ -554,8 +580,9 @@ dst__privstruct_parse(dst_key_t *key, unsigned int alg, isc_lex_t *lex,
isc_buffer_init(&b, data, MAXFIELDSIZE);
ret = isc_base64_tobuffer(lex, &b, -1);
if (ret != ISC_R_SUCCESS)
if (ret != ISC_R_SUCCESS) {
goto fail;
}
isc_buffer_usedregion(&b, &r);
priv->elements[n].length = r.length;
@@ -588,8 +615,9 @@ done:
fail:
dst__privstruct_free(priv, mctx);
if (data != NULL)
if (data != NULL) {
isc_mem_put(mctx, data, MAXFIELDSIZE);
}
return (ret);
}
@@ -614,15 +642,17 @@ dst__privstruct_writefile(const dst_key_t *key, const dst_private_t *priv,
REQUIRE(priv != NULL);
ret = check_data(priv, dst_key_alg(key), false, key->external);
if (ret < 0)
if (ret < 0) {
return (DST_R_INVALIDPRIVATEKEY);
else if (ret != ISC_R_SUCCESS)
} else if (ret != ISC_R_SUCCESS) {
return (ret);
}
isc_buffer_init(&b, filename, sizeof(filename));
result = dst_key_buildfilename(key, DST_TYPE_PRIVATE, directory, &b);
if (result != ISC_R_SUCCESS)
if (result != ISC_R_SUCCESS) {
return (result);
}
result = isc_file_mode(filename, &mode);
if (result == ISC_R_SUCCESS && mode != 0600) {
@@ -633,9 +663,9 @@ dst__privstruct_writefile(const dst_key_t *key, const dst_private_t *priv,
/* Windows security model is pretty different,
* e.g., there is no umask... */
level = ISC_LOG_NOTICE;
#else
#else /* ifdef _WIN32 */
level = ISC_LOG_WARNING;
#endif
#endif /* ifdef _WIN32 */
isc_log_write(dns_lctx, DNS_LOGCATEGORY_GENERAL,
DNS_LOGMODULE_DNSSEC, level,
"Permissions on the file %s "
@@ -644,8 +674,9 @@ dst__privstruct_writefile(const dst_key_t *key, const dst_private_t *priv,
filename, (unsigned int)mode);
}
if ((fp = fopen(filename, "w")) == NULL)
if ((fp = fopen(filename, "w")) == NULL) {
return (DST_R_WRITEERROR);
}
access = 0;
isc_fsaccess_add(ISC_FSACCESS_OWNER,
@@ -733,23 +764,26 @@ dst__privstruct_writefile(const dst_key_t *key, const dst_private_t *priv,
fprintf(fp, "%s %.*s\n", s, (int)r.length, r.base);
}
if (key->external)
if (key->external) {
fprintf(fp, "External:\n");
}
/* Add the metadata tags */
if (major > 1 || (major == 1 && minor >= 3)) {
for (i = 0; i < NUMERIC_NTAGS; i++) {
result = dst_key_getnum(key, i, &value);
if (result != ISC_R_SUCCESS)
if (result != ISC_R_SUCCESS) {
continue;
}
if (numerictags[i] != NULL) {
fprintf(fp, "%s %u\n", numerictags[i], value);
}
}
for (i = 0; i < TIMING_NTAGS; i++) {
result = dst_key_gettime(key, i, &when);
if (result != ISC_R_SUCCESS)
if (result != ISC_R_SUCCESS) {
continue;
}
isc_buffer_init(&b, buffer, sizeof(buffer));
result = dns_time32_totext(when, &b);