Skip to content

Reduce Warnings: address -Wextra-semi-stmt warnings #1988

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/common/tests/test-mlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ _test_foreach (void)
++n_loops;
(void) i;
ASSERT (n_loops <= 10);
};
}
ASSERT (n_loops == 10);

n_loops = 0;
Expand Down
90 changes: 52 additions & 38 deletions src/libbson/src/jsonsl/jsonsl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -186,27 +196,27 @@ 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.
*/
#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
Expand Down Expand Up @@ -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 "<UNKNOWN_ERROR>";
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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] != '"')) {
Expand Down
2 changes: 1 addition & 1 deletion src/libmongoc/tests/unified/operation.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
2 changes: 1 addition & 1 deletion src/libmongoc/tests/unified/runner.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down