2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-22 18:19:42 +00:00

Use ControlStatementsExceptControlMacros for SpaceBeforeParens

> 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)
This commit is contained in:
Ondřej Surý 2025-08-19 07:14:45 +02:00
parent a464171243
commit 8339615235
No known key found for this signature in database
GPG Key ID: 2820F37E873DEA41
5 changed files with 36 additions and 17 deletions

View File

@ -79,3 +79,4 @@ Standard: Cpp11
ContinuationIndentWidth: 8 ContinuationIndentWidth: 8
RemoveParentheses: ReturnStatement RemoveParentheses: ReturnStatement
RemoveSemicolon: true RemoveSemicolon: true
SpaceBeforeParens: ControlStatementsExceptControlMacros

View File

@ -67,3 +67,4 @@ Standard: Cpp11
ContinuationIndentWidth: 8 ContinuationIndentWidth: 8
RemoveParentheses: ReturnStatement RemoveParentheses: ReturnStatement
RemoveSemicolon: true RemoveSemicolon: true
SpaceBeforeParens: ControlStatementsExceptControlMacros

View File

@ -87,8 +87,9 @@ sched_affinity_ncpus(void) {
int i, n = 0; int i, n = 0;
for (i = 0; i < CPU_SETSIZE; ++i) { for (i = 0; i < CPU_SETSIZE; ++i) {
if (CPU_ISSET(i, &cpus)) if (CPU_ISSET(i, &cpus)) {
++n; ++n;
}
} }
return n; return n;
#endif #endif
@ -115,8 +116,9 @@ cpuset_affinity_ncpus(void) {
if (result != -1) { if (result != -1) {
int i, n = 0; int i, n = 0;
for (i = 0; i < CPU_SETSIZE; ++i) { for (i = 0; i < CPU_SETSIZE; ++i) {
if (CPU_ISSET(i, &cpus)) if (CPU_ISSET(i, &cpus)) {
++n; ++n;
}
} }
return n; return n;
} }

View File

@ -612,8 +612,9 @@ phr_decode_chunked(struct phr_chunked_decoder *decoder, char *buf,
case CHUNKED_IN_CHUNK_SIZE: case CHUNKED_IN_CHUNK_SIZE:
for (;; ++src) { for (;; ++src) {
int v; int v;
if (src == bufsz) if (src == bufsz) {
goto Exit; goto Exit;
}
if ((v = decode_hex(buf[src])) == -1) { if ((v = decode_hex(buf[src])) == -1) {
if (decoder->_hex_count == 0) { if (decoder->_hex_count == 0) {
ret = -1; 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 /* RFC 7230 A.2 "Line folding in chunk extensions is
* disallowed" */ * disallowed" */
for (;; ++src) { for (;; ++src) {
if (src == bufsz) if (src == bufsz) {
goto Exit; goto Exit;
if (buf[src] == '\012') }
if (buf[src] == '\012') {
break; break;
}
} }
++src; ++src;
if (decoder->bytes_left_in_chunk == 0) { 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: { case CHUNKED_IN_CHUNK_DATA: {
size_t avail = bufsz - src; size_t avail = bufsz - src;
if (avail < decoder->bytes_left_in_chunk) { if (avail < decoder->bytes_left_in_chunk) {
if (dst != src) if (dst != src) {
memmove(buf + dst, buf + src, avail); memmove(buf + dst, buf + src, avail);
}
src += avail; src += avail;
dst += avail; dst += avail;
decoder->bytes_left_in_chunk -= avail; decoder->bytes_left_in_chunk -= avail;
goto Exit; goto Exit;
} }
if (dst != src) if (dst != src) {
memmove(buf + dst, buf + src, memmove(buf + dst, buf + src,
decoder->bytes_left_in_chunk); decoder->bytes_left_in_chunk);
}
src += decoder->bytes_left_in_chunk; src += decoder->bytes_left_in_chunk;
dst += decoder->bytes_left_in_chunk; dst += decoder->bytes_left_in_chunk;
decoder->bytes_left_in_chunk = 0; decoder->bytes_left_in_chunk = 0;
@ -688,10 +693,12 @@ phr_decode_chunked(struct phr_chunked_decoder *decoder, char *buf,
/* fallthru */ /* fallthru */
case CHUNKED_IN_CHUNK_CRLF: case CHUNKED_IN_CHUNK_CRLF:
for (;; ++src) { for (;; ++src) {
if (src == bufsz) if (src == bufsz) {
goto Exit; goto Exit;
if (buf[src] != '\015') }
if (buf[src] != '\015') {
break; break;
}
} }
if (buf[src] != '\012') { if (buf[src] != '\012') {
ret = -1; ret = -1;
@ -702,21 +709,26 @@ phr_decode_chunked(struct phr_chunked_decoder *decoder, char *buf,
break; break;
case CHUNKED_IN_TRAILERS_LINE_HEAD: case CHUNKED_IN_TRAILERS_LINE_HEAD:
for (;; ++src) { for (;; ++src) {
if (src == bufsz) if (src == bufsz) {
goto Exit; goto Exit;
if (buf[src] != '\015') }
if (buf[src] != '\015') {
break; break;
}
} }
if (buf[src++] == '\012') if (buf[src++] == '\012') {
goto Complete; goto Complete;
}
decoder->_state = CHUNKED_IN_TRAILERS_LINE_MIDDLE; decoder->_state = CHUNKED_IN_TRAILERS_LINE_MIDDLE;
/* fallthru */ /* fallthru */
case CHUNKED_IN_TRAILERS_LINE_MIDDLE: case CHUNKED_IN_TRAILERS_LINE_MIDDLE:
for (;; ++src) { for (;; ++src) {
if (src == bufsz) if (src == bufsz) {
goto Exit; goto Exit;
if (buf[src] == '\012') }
if (buf[src] == '\012') {
break; break;
}
} }
++src; ++src;
decoder->_state = CHUNKED_IN_TRAILERS_LINE_HEAD; decoder->_state = CHUNKED_IN_TRAILERS_LINE_HEAD;
@ -729,8 +741,9 @@ phr_decode_chunked(struct phr_chunked_decoder *decoder, char *buf,
Complete: Complete:
ret = bufsz - src; ret = bufsz - src;
Exit: Exit:
if (dst != src) if (dst != src) {
memmove(buf + dst, buf + src, bufsz - src); memmove(buf + dst, buf + src, bufsz - src);
}
*_bufsz = dst; *_bufsz = dst;
/* if incomplete but the overhead of the chunked encoding is >=100KB and /* if incomplete but the overhead of the chunked encoding is >=100KB and
* >80%, signal an error */ * >80%, signal an error */

View File

@ -125,11 +125,13 @@ strnstr(const char *s, const char *find, size_t slen) {
len = strlen(find); len = strlen(find);
do { do {
do { do {
if (slen-- < 1 || (sc = *s++) == '\0') if (slen-- < 1 || (sc = *s++) == '\0') {
return NULL; return NULL;
}
} while (sc != c); } while (sc != c);
if (len > slen) if (len > slen) {
return NULL; return NULL;
}
} while (strncmp(s, find, len) != 0); } while (strncmp(s, find, len) != 0);
s--; s--;
} }