]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Use ControlStatementsExceptControlMacros for SpaceBeforeParens
authorOndřej Surý <ondrej@isc.org>
Tue, 19 Aug 2025 05:14:45 +0000 (07:14 +0200)
committerOndřej Surý <ondrej@isc.org>
Tue, 19 Aug 2025 06:10:58 +0000 (08:10 +0200)
> Put a space before opening parentheses only after control statement
> keywords (for/if/while...) except this option doesn’t apply to ForEach
> and If macros. This is useful in projects where ForEach/If macros are
> treated as function calls instead of control statements.

(cherry picked from commit 42496f3f4a8802c0ba8033a1bcabc8bebf5b0087)

.clang-format
.clang-format.headers
lib/isc/os.c
lib/isc/picohttpparser.c
lib/isc/string.c

index 04c1f8b3a209fb41f9090605b58a92b34397ef1b..02ab139b9628e16edccc7c93ba26dac99a4aa716 100644 (file)
@@ -79,3 +79,4 @@ Standard: Cpp11
 ContinuationIndentWidth: 8
 RemoveParentheses: ReturnStatement
 RemoveSemicolon: true
+SpaceBeforeParens: ControlStatementsExceptControlMacros
index ff9370413efcdca5394df4bee601706dfbb6068f..607196547acc032138ad1074f563cedc4ecac320 100644 (file)
@@ -67,3 +67,4 @@ Standard: Cpp11
 ContinuationIndentWidth: 8
 RemoveParentheses: ReturnStatement
 RemoveSemicolon: true
+SpaceBeforeParens: ControlStatementsExceptControlMacros
index 9465234f969431f0a05c2e94702bcdb4cb5ea60e..aa48c317912cd219db7fbcfd178dc46d741fb4f5 100644 (file)
@@ -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;
        }
index 0545624e547ede0381c428863cbcd323de747fdd..933137714bcae7d6d4cac6d547a500b779097ae9 100644 (file)
@@ -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 */
index c71a9e661e3d942588206665cff546deadb416a5..a9876a67a0ef34eaae7a0584c998db286e76c472 100644 (file)
@@ -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--;
        }