diff --git a/src/common/tests/test-mlib.c b/src/common/tests/test-mlib.c index 8cc13ec5b6d..ab6e1db034c 100644 --- a/src/common/tests/test-mlib.c +++ b/src/common/tests/test-mlib.c @@ -447,7 +447,7 @@ _test_foreach (void) ++n_loops; (void) i; ASSERT (n_loops <= 10); - }; + } ASSERT (n_loops == 10); n_loops = 0; diff --git a/src/libbson/src/jsonsl/jsonsl.c b/src/libbson/src/jsonsl/jsonsl.c index 7f5bf36d0a7..730c3166ae6 100644 --- a/src/libbson/src/jsonsl/jsonsl.c +++ b/src/libbson/src/jsonsl/jsonsl.c @@ -144,34 +144,44 @@ jsonsl_feed(jsonsl_t jsn, const jsonsl_char_t *bytes, size_t nbytes) { #define INVOKE_ERROR(eb) \ - if (jsn->error_callback(jsn, JSONSL_ERROR_##eb, state, (char*)c)) { \ - goto GT_AGAIN; \ - } \ - return; + if (1) { \ + if (jsn->error_callback(jsn, JSONSL_ERROR_##eb, state, (char*)c)) { \ + goto GT_AGAIN; \ + } \ + return; \ + } else ((void)0) #define STACK_PUSH \ - if (jsn->level >= (levels_max-1)) { \ - jsn->error_callback(jsn, JSONSL_ERROR_LEVELS_EXCEEDED, state, (char*)c); \ - return; \ - } \ - state = jsn->stack + (++jsn->level); \ - state->ignore_callback = jsn->stack[jsn->level-1].ignore_callback; \ - state->pos_begin = jsn->pos; + if (1) { \ + if (jsn->level >= (levels_max-1)) { \ + jsn->error_callback(jsn, JSONSL_ERROR_LEVELS_EXCEEDED, state, (char*)c); \ + return; \ + } \ + state = jsn->stack + (++jsn->level); \ + state->ignore_callback = jsn->stack[jsn->level-1].ignore_callback; \ + state->pos_begin = jsn->pos; \ + } else ((void)0) #define CALLBACK_AND_POP_NOPOS(T) \ + if (1) { \ state->pos_cur = jsn->pos; \ DO_CALLBACK(T, POP); \ state->nescapes = 0; \ - state = jsn->stack + (--jsn->level); + state = jsn->stack + (--jsn->level); \ + } else ((void)0) #define CALLBACK_AND_POP(T) \ + if (1) { \ CALLBACK_AND_POP_NOPOS(T); \ - state->pos_cur = jsn->pos; + state->pos_cur = jsn->pos; \ + } else ((void)0) #define SPECIAL_POP \ - CALLBACK_AND_POP(SPECIAL); \ - jsn->expecting = 0; \ - jsn->tok_last = 0; \ + if (1) { \ + CALLBACK_AND_POP(SPECIAL); \ + jsn->expecting = 0; \ + jsn->tok_last = 0; \ + } else ((void)0) #define CUR_CHAR (*(jsonsl_uchar_t*)c) @@ -186,7 +196,7 @@ jsonsl_feed(jsonsl_t jsn, const jsonsl_char_t *bytes, size_t nbytes) jsn->action_callback(jsn, JSONSL_ACTION_##action, state, (jsonsl_char_t*)c); \ } \ if (jsn->stopfl) { return; } \ - } + } else ((void)0) /** * Verifies that we are able to insert the (non-string) item into a hash. @@ -194,19 +204,19 @@ jsonsl_feed(jsonsl_t jsn, const jsonsl_char_t *bytes, size_t nbytes) #define ENSURE_HVAL \ if (state->nelem % 2 == 0 && state->type == JSONSL_T_OBJECT) { \ INVOKE_ERROR(HKEY_EXPECTED); \ - } + } else ((void)0) #define VERIFY_SPECIAL(lit, lit_len) \ - if ((jsn->pos - state->pos_begin) > lit_len \ - || CUR_CHAR != (lit)[jsn->pos - state->pos_begin]) { \ - INVOKE_ERROR(SPECIAL_EXPECTED); \ - } + if ((jsn->pos - state->pos_begin) > lit_len \ + || CUR_CHAR != (lit)[jsn->pos - state->pos_begin]) { \ + INVOKE_ERROR(SPECIAL_EXPECTED); \ + } else ((void)0) #define VERIFY_SPECIAL_CI(lit, lit_len) \ - if ((jsn->pos - state->pos_begin) > lit_len \ - || tolower(CUR_CHAR) != (lit)[jsn->pos - state->pos_begin]) { \ - INVOKE_ERROR(SPECIAL_EXPECTED); \ - } + if ((jsn->pos - state->pos_begin) > lit_len \ + || tolower(CUR_CHAR) != (lit)[jsn->pos - state->pos_begin]) { \ + INVOKE_ERROR(SPECIAL_EXPECTED); \ + } else ((void)0) #define STATE_SPECIAL_LENGTH \ (state)->nescapes @@ -663,7 +673,7 @@ const char* jsonsl_strerror(jsonsl_error_t err) #define X(t) \ if (err == JSONSL_ERROR_##t) \ return #t; - JSONSL_XERR; + JSONSL_XERR #undef X return ""; } @@ -787,7 +797,7 @@ jsonsl_jpr_new(const char *path, jsonsl_error_t *errp) size_t origlen; jsonsl_error_t errstacked; -#define JPR_BAIL(err) *errp = err; goto GT_ERROR; +#define JPR_BAIL(err) if (1) { *errp = err; goto GT_ERROR; } else ((void)0) if (errp == NULL) { errp = &errstacked; @@ -1157,7 +1167,7 @@ const char *jsonsl_strmatchtype(jsonsl_jpr_match_t match) static char * jsonsl__writeutf8(uint32_t pt, char *out) { - #define ADD_OUTPUT(c) *out = (char)(c); out++; + #define ADD_OUTPUT(c) if (1) { *out = (char)(c); out++; } else ((void)0) if (pt < 0x80) { ADD_OUTPUT(pt); @@ -1204,9 +1214,11 @@ jsonsl__get_uescape_16(const char *s) int cur; #define GET_DIGIT(off) \ - cur = jsonsl__digit2int(s[off]); \ - if (cur == -1) { return -1; } \ - ret |= (cur << (12 - (off * 4))); + if (1) { \ + cur = jsonsl__digit2int(s[off]); \ + if (cur == -1) { return -1; } \ + ret |= (cur << (12 - (off * 4))); \ + } else ((void)0) GET_DIGIT(0); GET_DIGIT(1); @@ -1238,11 +1250,13 @@ size_t jsonsl_util_unescape_ex(const char *in, *oflags = 0; #define UNESCAPE_BAIL(e,offset) \ - *err = JSONSL_ERROR_##e; \ - if (errat) { \ - *errat = (const char*)(c+ (ptrdiff_t)(offset)); \ - } \ - return 0; + if (1) { \ + *err = JSONSL_ERROR_##e; \ + if (errat) { \ + *errat = (const char*)(c+ (ptrdiff_t)(offset)); \ + } \ + return 0; \ + } else ((void)0) for (; len; len--, c++, out++) { int uescval; @@ -1255,7 +1269,7 @@ size_t jsonsl_util_unescape_ex(const char *in, UNESCAPE_BAIL(ESCAPE_INVALID, 0); } if (!is_allowed_escape(c[1])) { - UNESCAPE_BAIL(ESCAPE_INVALID, 1) + UNESCAPE_BAIL(ESCAPE_INVALID, 1); } if ((toEscape && toEscape[(unsigned char)c[1] & 0x7f] == 0 && c[1] != '\\' && c[1] != '"')) { diff --git a/src/libmongoc/tests/unified/operation.c b/src/libmongoc/tests/unified/operation.c index 5d4b94be100..fda829dc18f 100644 --- a/src/libmongoc/tests/unified/operation.c +++ b/src/libmongoc/tests/unified/operation.c @@ -3961,7 +3961,7 @@ operation_wait_for_event (test_t *test, operation_t *op, result_t *result, bson_ (int) (duration / 1000), (int) WAIT_FOR_EVENT_TIMEOUT_MS); goto done; - }; + } _operation_hidden_wait (test, client, "waitForEvent"); } diff --git a/src/libmongoc/tests/unified/runner.c b/src/libmongoc/tests/unified/runner.c index 03fe06c17cf..e2d302ee423 100644 --- a/src/libmongoc/tests/unified/runner.c +++ b/src/libmongoc/tests/unified/runner.c @@ -1516,7 +1516,7 @@ test_check_log_message (bson_t *expected, log_message_t *actual, bson_error_t *e if (!bson_iter_init_find (&failure_iter, actual->message, "failure")) { test_set_error (error, "expected log 'failure' to exist"); goto done; - }; + } if (*failure_is_redacted) { if (!check_failure_is_redacted (&failure_iter, error)) { test_diagnostics_error_info ("actual log message: %s", tmp_json (actual->message));