Skip to content

Commit 66f23a9

Browse files
authored
Reduce Warnings: address -Wextra-semi-stmt warnings (#1988)
1 parent 1b518a0 commit 66f23a9

File tree

4 files changed

+55
-41
lines changed

4 files changed

+55
-41
lines changed

src/common/tests/test-mlib.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ _test_foreach (void)
447447
++n_loops;
448448
(void) i;
449449
ASSERT (n_loops <= 10);
450-
};
450+
}
451451
ASSERT (n_loops == 10);
452452

453453
n_loops = 0;

src/libbson/src/jsonsl/jsonsl.c

+52-38
Original file line numberDiff line numberDiff line change
@@ -144,34 +144,44 @@ jsonsl_feed(jsonsl_t jsn, const jsonsl_char_t *bytes, size_t nbytes)
144144
{
145145

146146
#define INVOKE_ERROR(eb) \
147-
if (jsn->error_callback(jsn, JSONSL_ERROR_##eb, state, (char*)c)) { \
148-
goto GT_AGAIN; \
149-
} \
150-
return;
147+
if (1) { \
148+
if (jsn->error_callback(jsn, JSONSL_ERROR_##eb, state, (char*)c)) { \
149+
goto GT_AGAIN; \
150+
} \
151+
return; \
152+
} else ((void)0)
151153

152154
#define STACK_PUSH \
153-
if (jsn->level >= (levels_max-1)) { \
154-
jsn->error_callback(jsn, JSONSL_ERROR_LEVELS_EXCEEDED, state, (char*)c); \
155-
return; \
156-
} \
157-
state = jsn->stack + (++jsn->level); \
158-
state->ignore_callback = jsn->stack[jsn->level-1].ignore_callback; \
159-
state->pos_begin = jsn->pos;
155+
if (1) { \
156+
if (jsn->level >= (levels_max-1)) { \
157+
jsn->error_callback(jsn, JSONSL_ERROR_LEVELS_EXCEEDED, state, (char*)c); \
158+
return; \
159+
} \
160+
state = jsn->stack + (++jsn->level); \
161+
state->ignore_callback = jsn->stack[jsn->level-1].ignore_callback; \
162+
state->pos_begin = jsn->pos; \
163+
} else ((void)0)
160164

161165
#define CALLBACK_AND_POP_NOPOS(T) \
166+
if (1) { \
162167
state->pos_cur = jsn->pos; \
163168
DO_CALLBACK(T, POP); \
164169
state->nescapes = 0; \
165-
state = jsn->stack + (--jsn->level);
170+
state = jsn->stack + (--jsn->level); \
171+
} else ((void)0)
166172

167173
#define CALLBACK_AND_POP(T) \
174+
if (1) { \
168175
CALLBACK_AND_POP_NOPOS(T); \
169-
state->pos_cur = jsn->pos;
176+
state->pos_cur = jsn->pos; \
177+
} else ((void)0)
170178

171179
#define SPECIAL_POP \
172-
CALLBACK_AND_POP(SPECIAL); \
173-
jsn->expecting = 0; \
174-
jsn->tok_last = 0; \
180+
if (1) { \
181+
CALLBACK_AND_POP(SPECIAL); \
182+
jsn->expecting = 0; \
183+
jsn->tok_last = 0; \
184+
} else ((void)0)
175185

176186
#define CUR_CHAR (*(jsonsl_uchar_t*)c)
177187

@@ -186,27 +196,27 @@ jsonsl_feed(jsonsl_t jsn, const jsonsl_char_t *bytes, size_t nbytes)
186196
jsn->action_callback(jsn, JSONSL_ACTION_##action, state, (jsonsl_char_t*)c); \
187197
} \
188198
if (jsn->stopfl) { return; } \
189-
}
199+
} else ((void)0)
190200

191201
/**
192202
* Verifies that we are able to insert the (non-string) item into a hash.
193203
*/
194204
#define ENSURE_HVAL \
195205
if (state->nelem % 2 == 0 && state->type == JSONSL_T_OBJECT) { \
196206
INVOKE_ERROR(HKEY_EXPECTED); \
197-
}
207+
} else ((void)0)
198208

199209
#define VERIFY_SPECIAL(lit, lit_len) \
200-
if ((jsn->pos - state->pos_begin) > lit_len \
201-
|| CUR_CHAR != (lit)[jsn->pos - state->pos_begin]) { \
202-
INVOKE_ERROR(SPECIAL_EXPECTED); \
203-
}
210+
if ((jsn->pos - state->pos_begin) > lit_len \
211+
|| CUR_CHAR != (lit)[jsn->pos - state->pos_begin]) { \
212+
INVOKE_ERROR(SPECIAL_EXPECTED); \
213+
} else ((void)0)
204214

205215
#define VERIFY_SPECIAL_CI(lit, lit_len) \
206-
if ((jsn->pos - state->pos_begin) > lit_len \
207-
|| tolower(CUR_CHAR) != (lit)[jsn->pos - state->pos_begin]) { \
208-
INVOKE_ERROR(SPECIAL_EXPECTED); \
209-
}
216+
if ((jsn->pos - state->pos_begin) > lit_len \
217+
|| tolower(CUR_CHAR) != (lit)[jsn->pos - state->pos_begin]) { \
218+
INVOKE_ERROR(SPECIAL_EXPECTED); \
219+
} else ((void)0)
210220

211221
#define STATE_SPECIAL_LENGTH \
212222
(state)->nescapes
@@ -663,7 +673,7 @@ const char* jsonsl_strerror(jsonsl_error_t err)
663673
#define X(t) \
664674
if (err == JSONSL_ERROR_##t) \
665675
return #t;
666-
JSONSL_XERR;
676+
JSONSL_XERR
667677
#undef X
668678
return "<UNKNOWN_ERROR>";
669679
}
@@ -787,7 +797,7 @@ jsonsl_jpr_new(const char *path, jsonsl_error_t *errp)
787797
size_t origlen;
788798
jsonsl_error_t errstacked;
789799

790-
#define JPR_BAIL(err) *errp = err; goto GT_ERROR;
800+
#define JPR_BAIL(err) if (1) { *errp = err; goto GT_ERROR; } else ((void)0)
791801

792802
if (errp == NULL) {
793803
errp = &errstacked;
@@ -1157,7 +1167,7 @@ const char *jsonsl_strmatchtype(jsonsl_jpr_match_t match)
11571167
static char *
11581168
jsonsl__writeutf8(uint32_t pt, char *out)
11591169
{
1160-
#define ADD_OUTPUT(c) *out = (char)(c); out++;
1170+
#define ADD_OUTPUT(c) if (1) { *out = (char)(c); out++; } else ((void)0)
11611171

11621172
if (pt < 0x80) {
11631173
ADD_OUTPUT(pt);
@@ -1204,9 +1214,11 @@ jsonsl__get_uescape_16(const char *s)
12041214
int cur;
12051215

12061216
#define GET_DIGIT(off) \
1207-
cur = jsonsl__digit2int(s[off]); \
1208-
if (cur == -1) { return -1; } \
1209-
ret |= (cur << (12 - (off * 4)));
1217+
if (1) { \
1218+
cur = jsonsl__digit2int(s[off]); \
1219+
if (cur == -1) { return -1; } \
1220+
ret |= (cur << (12 - (off * 4))); \
1221+
} else ((void)0)
12101222

12111223
GET_DIGIT(0);
12121224
GET_DIGIT(1);
@@ -1238,11 +1250,13 @@ size_t jsonsl_util_unescape_ex(const char *in,
12381250
*oflags = 0;
12391251

12401252
#define UNESCAPE_BAIL(e,offset) \
1241-
*err = JSONSL_ERROR_##e; \
1242-
if (errat) { \
1243-
*errat = (const char*)(c+ (ptrdiff_t)(offset)); \
1244-
} \
1245-
return 0;
1253+
if (1) { \
1254+
*err = JSONSL_ERROR_##e; \
1255+
if (errat) { \
1256+
*errat = (const char*)(c+ (ptrdiff_t)(offset)); \
1257+
} \
1258+
return 0; \
1259+
} else ((void)0)
12461260

12471261
for (; len; len--, c++, out++) {
12481262
int uescval;
@@ -1255,7 +1269,7 @@ size_t jsonsl_util_unescape_ex(const char *in,
12551269
UNESCAPE_BAIL(ESCAPE_INVALID, 0);
12561270
}
12571271
if (!is_allowed_escape(c[1])) {
1258-
UNESCAPE_BAIL(ESCAPE_INVALID, 1)
1272+
UNESCAPE_BAIL(ESCAPE_INVALID, 1);
12591273
}
12601274
if ((toEscape && toEscape[(unsigned char)c[1] & 0x7f] == 0 &&
12611275
c[1] != '\\' && c[1] != '"')) {

src/libmongoc/tests/unified/operation.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3961,7 +3961,7 @@ operation_wait_for_event (test_t *test, operation_t *op, result_t *result, bson_
39613961
(int) (duration / 1000),
39623962
(int) WAIT_FOR_EVENT_TIMEOUT_MS);
39633963
goto done;
3964-
};
3964+
}
39653965

39663966
_operation_hidden_wait (test, client, "waitForEvent");
39673967
}

src/libmongoc/tests/unified/runner.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1516,7 +1516,7 @@ test_check_log_message (bson_t *expected, log_message_t *actual, bson_error_t *e
15161516
if (!bson_iter_init_find (&failure_iter, actual->message, "failure")) {
15171517
test_set_error (error, "expected log 'failure' to exist");
15181518
goto done;
1519-
};
1519+
}
15201520
if (*failure_is_redacted) {
15211521
if (!check_failure_is_redacted (&failure_iter, error)) {
15221522
test_diagnostics_error_info ("actual log message: %s", tmp_json (actual->message));

0 commit comments

Comments
 (0)