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

@@ -23,7 +23,7 @@
do { \
isc_result_t _r = (x); \
if (_r != ISC_R_SUCCESS) \
return (_r); \
return ((_r)); \
} while (0)
/*@{*/
@@ -48,8 +48,9 @@ isc_base64_totext(isc_region_t *source, int wordlength, const char *wordbreak,
char buf[5];
unsigned int loops = 0;
if (wordlength < 4)
if (wordlength < 4) {
wordlength = 4;
}
memset(buf, 0, sizeof(buf));
while (source->length > 2) {
@@ -112,46 +113,55 @@ base64_decode_char(base64_decode_ctx_t *ctx, int c)
{
const char *s;
if (ctx->seen_end)
if (ctx->seen_end) {
return (ISC_R_BADBASE64);
if ((s = strchr(base64, c)) == NULL)
}
if ((s = strchr(base64, c)) == NULL) {
return (ISC_R_BADBASE64);
}
ctx->val[ctx->digits++] = (int)(s - base64);
if (ctx->digits == 4) {
int n;
unsigned char buf[3];
if (ctx->val[0] == 64 || ctx->val[1] == 64)
if (ctx->val[0] == 64 || ctx->val[1] == 64) {
return (ISC_R_BADBASE64);
if (ctx->val[2] == 64 && ctx->val[3] != 64)
}
if (ctx->val[2] == 64 && ctx->val[3] != 64) {
return (ISC_R_BADBASE64);
}
/*
* Check that bits that should be zero are.
*/
if (ctx->val[2] == 64 && (ctx->val[1] & 0xf) != 0)
if (ctx->val[2] == 64 && (ctx->val[1] & 0xf) != 0) {
return (ISC_R_BADBASE64);
}
/*
* We don't need to test for ctx->val[2] != 64 as
* the bottom two bits of 64 are zero.
*/
if (ctx->val[3] == 64 && (ctx->val[2] & 0x3) != 0)
if (ctx->val[3] == 64 && (ctx->val[2] & 0x3) != 0) {
return (ISC_R_BADBASE64);
}
n = (ctx->val[2] == 64) ? 1 : (ctx->val[3] == 64) ? 2 : 3;
if (n != 3) {
ctx->seen_end = true;
if (ctx->val[2] == 64)
if (ctx->val[2] == 64) {
ctx->val[2] = 0;
if (ctx->val[3] == 64)
}
if (ctx->val[3] == 64) {
ctx->val[3] = 0;
}
}
buf[0] = (ctx->val[0] << 2) | (ctx->val[1] >> 4);
buf[1] = (ctx->val[1] << 4) | (ctx->val[2] >> 2);
buf[2] = (ctx->val[2] << 6) | (ctx->val[3]);
RETERR(mem_tobuffer(ctx->target, buf, n));
if (ctx->length >= 0) {
if (n > ctx->length)
if (n > ctx->length) {
return (ISC_R_BADBASE64);
else
} else {
ctx->length -= n;
}
}
ctx->digits = 0;
}
@@ -161,10 +171,12 @@ base64_decode_char(base64_decode_ctx_t *ctx, int c)
static inline isc_result_t
base64_decode_finish(base64_decode_ctx_t *ctx)
{
if (ctx->length > 0)
if (ctx->length > 0) {
return (ISC_R_UNEXPECTEDEND);
if (ctx->digits != 0)
}
if (ctx->digits != 0) {
return (ISC_R_BADBASE64);
}
return (ISC_R_SUCCESS);
}
@@ -219,10 +231,12 @@ isc_base64_decodestring(const char *cstr, isc_buffer_t *target)
base64_decode_init(&ctx, -1, target);
for (;;) {
int c = *cstr++;
if (c == '\0')
if (c == '\0') {
break;
if (c == ' ' || c == '\t' || c == '\n' || c == '\r')
}
if (c == ' ' || c == '\t' || c == '\n' || c == '\r') {
continue;
}
RETERR(base64_decode_char(&ctx, c));
}
RETERR(base64_decode_finish(&ctx));
@@ -238,8 +252,9 @@ str_totext(const char *source, isc_buffer_t *target)
isc_buffer_availableregion(target, &region);
l = strlen(source);
if (l > region.length)
if (l > region.length) {
return (ISC_R_NOSPACE);
}
memmove(region.base, source, l);
isc_buffer_add(target, l);
@@ -252,8 +267,9 @@ mem_tobuffer(isc_buffer_t *target, void *base, unsigned int length)
isc_region_t tr;
isc_buffer_availableregion(target, &tr);
if (length > tr.length)
if (length > tr.length) {
return (ISC_R_NOSPACE);
}
memmove(tr.base, base, length);
isc_buffer_add(target, length);
return (ISC_R_SUCCESS);