diff --git a/.clang-format b/.clang-format index 04c1f8b3a2..02ab139b96 100644 --- a/.clang-format +++ b/.clang-format @@ -79,3 +79,4 @@ Standard: Cpp11 ContinuationIndentWidth: 8 RemoveParentheses: ReturnStatement RemoveSemicolon: true +SpaceBeforeParens: ControlStatementsExceptControlMacros diff --git a/.clang-format.headers b/.clang-format.headers index ff9370413e..607196547a 100644 --- a/.clang-format.headers +++ b/.clang-format.headers @@ -67,3 +67,4 @@ Standard: Cpp11 ContinuationIndentWidth: 8 RemoveParentheses: ReturnStatement RemoveSemicolon: true +SpaceBeforeParens: ControlStatementsExceptControlMacros diff --git a/lib/isc/os.c b/lib/isc/os.c index 9465234f96..aa48c31791 100644 --- a/lib/isc/os.c +++ b/lib/isc/os.c @@ -87,8 +87,9 @@ sched_affinity_ncpus(void) { int i, n = 0; for (i = 0; i < CPU_SETSIZE; ++i) { - if (CPU_ISSET(i, &cpus)) + if (CPU_ISSET(i, &cpus)) { ++n; + } } return n; #endif @@ -115,8 +116,9 @@ cpuset_affinity_ncpus(void) { if (result != -1) { int i, n = 0; for (i = 0; i < CPU_SETSIZE; ++i) { - if (CPU_ISSET(i, &cpus)) + if (CPU_ISSET(i, &cpus)) { ++n; + } } return n; } diff --git a/lib/isc/picohttpparser.c b/lib/isc/picohttpparser.c index 0545624e54..933137714b 100644 --- a/lib/isc/picohttpparser.c +++ b/lib/isc/picohttpparser.c @@ -612,8 +612,9 @@ phr_decode_chunked(struct phr_chunked_decoder *decoder, char *buf, case CHUNKED_IN_CHUNK_SIZE: for (;; ++src) { int v; - if (src == bufsz) + if (src == bufsz) { goto Exit; + } if ((v = decode_hex(buf[src])) == -1) { if (decoder->_hex_count == 0) { ret = -1; @@ -650,10 +651,12 @@ phr_decode_chunked(struct phr_chunked_decoder *decoder, char *buf, /* RFC 7230 A.2 "Line folding in chunk extensions is * disallowed" */ for (;; ++src) { - if (src == bufsz) + if (src == bufsz) { goto Exit; - if (buf[src] == '\012') + } + if (buf[src] == '\012') { break; + } } ++src; if (decoder->bytes_left_in_chunk == 0) { @@ -670,16 +673,18 @@ phr_decode_chunked(struct phr_chunked_decoder *decoder, char *buf, case CHUNKED_IN_CHUNK_DATA: { size_t avail = bufsz - src; if (avail < decoder->bytes_left_in_chunk) { - if (dst != src) + if (dst != src) { memmove(buf + dst, buf + src, avail); + } src += avail; dst += avail; decoder->bytes_left_in_chunk -= avail; goto Exit; } - if (dst != src) + if (dst != src) { memmove(buf + dst, buf + src, decoder->bytes_left_in_chunk); + } src += decoder->bytes_left_in_chunk; dst += decoder->bytes_left_in_chunk; decoder->bytes_left_in_chunk = 0; @@ -688,10 +693,12 @@ phr_decode_chunked(struct phr_chunked_decoder *decoder, char *buf, /* fallthru */ case CHUNKED_IN_CHUNK_CRLF: for (;; ++src) { - if (src == bufsz) + if (src == bufsz) { goto Exit; - if (buf[src] != '\015') + } + if (buf[src] != '\015') { break; + } } if (buf[src] != '\012') { ret = -1; @@ -702,21 +709,26 @@ phr_decode_chunked(struct phr_chunked_decoder *decoder, char *buf, break; case CHUNKED_IN_TRAILERS_LINE_HEAD: for (;; ++src) { - if (src == bufsz) + if (src == bufsz) { goto Exit; - if (buf[src] != '\015') + } + if (buf[src] != '\015') { break; + } } - if (buf[src++] == '\012') + if (buf[src++] == '\012') { goto Complete; + } decoder->_state = CHUNKED_IN_TRAILERS_LINE_MIDDLE; /* fallthru */ case CHUNKED_IN_TRAILERS_LINE_MIDDLE: for (;; ++src) { - if (src == bufsz) + if (src == bufsz) { goto Exit; - if (buf[src] == '\012') + } + if (buf[src] == '\012') { break; + } } ++src; decoder->_state = CHUNKED_IN_TRAILERS_LINE_HEAD; @@ -729,8 +741,9 @@ phr_decode_chunked(struct phr_chunked_decoder *decoder, char *buf, Complete: ret = bufsz - src; Exit: - if (dst != src) + if (dst != src) { memmove(buf + dst, buf + src, bufsz - src); + } *_bufsz = dst; /* if incomplete but the overhead of the chunked encoding is >=100KB and * >80%, signal an error */ diff --git a/lib/isc/string.c b/lib/isc/string.c index c71a9e661e..a9876a67a0 100644 --- a/lib/isc/string.c +++ b/lib/isc/string.c @@ -125,11 +125,13 @@ strnstr(const char *s, const char *find, size_t slen) { len = strlen(find); do { do { - if (slen-- < 1 || (sc = *s++) == '\0') + if (slen-- < 1 || (sc = *s++) == '\0') { return NULL; + } } while (sc != c); - if (len > slen) + if (len > slen) { return NULL; + } } while (strncmp(s, find, len) != 0); s--; }