Skip to content

Commit 7ae8fd3

Browse files
authored
Address more scan-build warnings (#1239)
* Address scan-build deadcode.DeadStores warnings * Address scan-build unix.cstring.NullArg warnings * Address scan-build -Wstrict-prototypes warnings * Address scan-build -Wunused-but-set-variable warnings
1 parent 510c1c3 commit 7ae8fd3

File tree

5 files changed

+8
-11
lines changed

5 files changed

+8
-11
lines changed

src/libmongoc/src/mongoc/mongoc-aggregate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ _make_agg_cmd (const char *ns,
9595
{
9696
const char *const dot = strstr (ns, ".");
9797
const char *error = NULL;
98-
const char *error_hint = "";
98+
const char *error_hint = NULL;
9999

100100
bsonBuild (
101101
*command,

src/libmongoc/tests/test-libmongoc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2339,14 +2339,14 @@ test_framework_skip_if_not_replset (void)
23392339

23402340
/* convenience skip functions based on the wire version. */
23412341
#define WIRE_VERSION_CHECKS(wv) \
2342-
int test_framework_skip_if_max_wire_version_more_than_##wv () \
2342+
int test_framework_skip_if_max_wire_version_more_than_##wv (void) \
23432343
{ \
23442344
if (!TestSuite_CheckLive ()) { \
23452345
return 0; \
23462346
} \
23472347
return test_framework_max_wire_version_at_least (wv + 1) ? 0 : 1; \
23482348
} \
2349-
int test_framework_skip_if_max_wire_version_less_than_##wv () \
2349+
int test_framework_skip_if_max_wire_version_less_than_##wv (void) \
23502350
{ \
23512351
if (!TestSuite_CheckLive ()) { \
23522352
return 0; \

src/libmongoc/tests/test-mongoc-client-pool.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,15 +367,13 @@ test_client_pool_destroy_without_pushing (void)
367367
static void
368368
command_started_cb (const mongoc_apm_command_started_t *event)
369369
{
370-
int *count;
371-
372370
if (strcmp (mongoc_apm_command_started_get_command_name (event),
373371
"endSessions") != 0) {
374372
return;
375373
}
376374

377-
count = (int *) mongoc_apm_command_started_get_context (event);
378-
count++;
375+
int *const count = (int *) mongoc_apm_command_started_get_context (event);
376+
(*count)++;
379377
}
380378

381379
/* tests that creating and destroying an unused session

src/libmongoc/tests/test-mongoc-connection-uri.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,6 @@ test_connection_uri_cb (bson_t *scenario)
283283
bson_t auth;
284284
bson_t options;
285285
bool valid;
286-
int c = 0;
287286

288287
BSON_ASSERT (scenario);
289288

@@ -296,7 +295,6 @@ test_connection_uri_cb (bson_t *scenario)
296295
bson_t test_case;
297296

298297
bson_iter_bson (&tests_iter, &test_case);
299-
c++;
300298

301299
if (test_suite_debug_output ()) {
302300
bson_iter_t test_case_iter;

src/libmongoc/tests/test-mongoc-gssapi.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ _getenv (const char *name)
3838
return NULL;
3939
}
4040
#else
41-
if (getenv (name) && strlen (getenv (name))) {
42-
return bson_strdup (getenv (name));
41+
char *const value = getenv (name);
42+
if (value && strlen (value)) {
43+
return bson_strdup (value);
4344
} else {
4445
return NULL;
4546
}

0 commit comments

Comments
 (0)