Skip to content

Commit 493018d

Browse files
committed
CDRIVER-366: Update tests to compile using C++ compiler
Conflicts: tests/test-mongoc-client.c tests/test-mongoc-cluster.c
1 parent bc569bc commit 493018d

21 files changed

+49
-49
lines changed

tests/TestSuite.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ TestSuite_Add (TestSuite *suite, /* IN */
306306
const char *name, /* IN */
307307
TestFunc func) /* IN */
308308
{
309-
TestSuite_AddFull (suite, name, TestSuite_AddHelper, NULL, func, TestSuite_CheckDummy);
309+
TestSuite_AddFull (suite, name, TestSuite_AddHelper, NULL, (void *)func, TestSuite_CheckDummy);
310310
}
311311

312312

@@ -332,7 +332,7 @@ TestSuite_AddFull (TestSuite *suite, /* IN */
332332
Test *test;
333333
Test *iter;
334334

335-
test = calloc (1, sizeof *test);
335+
test = (Test *)calloc (1, sizeof *test);
336336
test->name = strdup (name);
337337
test->func = func;
338338
test->check = check;
@@ -622,7 +622,7 @@ typedef struct
622622
static void *
623623
TestSuite_ParallelWorker (void *data) /* IN */
624624
{
625-
ParallelInfo *info = data;
625+
ParallelInfo *info = (ParallelInfo *)data;
626626

627627
ASSERT (info);
628628

@@ -658,12 +658,12 @@ TestSuite_RunParallel (TestSuite *suite) /* IN */
658658
count++;
659659
}
660660

661-
threads = calloc (count, sizeof *threads);
661+
threads = (Thread *)calloc (count, sizeof *threads);
662662

663663
Memory_Barrier ();
664664

665665
for (test = suite->tests, i = 0; test; test = test->next, i++) {
666-
info = calloc (1, sizeof *info);
666+
info = (ParallelInfo *)calloc (1, sizeof *info);
667667
info->suite = suite;
668668
info->test = test;
669669
info->count = &count;

tests/ha-test.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ ha_node_new (const char *name,
169169
{
170170
ha_node_t *node;
171171

172-
node = bson_malloc0(sizeof *node);
172+
node = (ha_node_t *)bson_malloc0(sizeof *node);
173173
node->name = bson_strdup(name);
174174
node->repl_set = bson_strdup(repl_set);
175175
node->dbpath = bson_strdup(dbpath);
@@ -465,7 +465,7 @@ ha_replica_set_new (const char *name)
465465
{
466466
ha_replica_set_t *repl_set;
467467

468-
repl_set = bson_malloc0(sizeof *repl_set);
468+
repl_set = (ha_replica_set_t *)bson_malloc0(sizeof *repl_set);
469469
repl_set->name = bson_strdup(name);
470470
repl_set->next_port = random_int_range(30000, 40000);
471471

@@ -827,7 +827,7 @@ ha_sharded_cluster_new (const char *name)
827827
{
828828
ha_sharded_cluster_t *cluster;
829829

830-
cluster = bson_malloc0(sizeof *cluster);
830+
cluster = (ha_sharded_cluster_t *)bson_malloc0(sizeof *cluster);
831831
cluster->next_port = random_int_range(40000, 41000);
832832
cluster->name = bson_strdup(name);
833833

tests/json-test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ get_bson_from_json_file(char *filename)
237237
}
238238

239239
/* read entire file into buffer */
240-
buffer = bson_malloc0(length);
240+
buffer = (const char *)bson_malloc0(length);
241241
if (fread((void *)buffer, 1, length, file) != length) {
242242
abort();
243243
}

tests/mock_server/future.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,10 @@ future_new (future_value_type_t return_type, int argc)
272272
{
273273
future_t *future;
274274

275-
future = bson_malloc0 (sizeof *future);
275+
future = (future_t *)bson_malloc0 (sizeof *future);
276276
future->return_value.type = return_type;
277277
future->argc = argc;
278-
future->argv = bson_malloc0 ((size_t) argc * sizeof(future_value_t));
278+
future->argv = (future_value_t *)bson_malloc0 ((size_t) argc * sizeof(future_value_t));
279279
mongoc_cond_init (&future->cond);
280280
mongoc_mutex_init (&future->mutex);
281281

tests/mock_server/mock-rs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ mock_rs_with_autoismaster (int32_t max_wire_version,
118118
int n_secondaries,
119119
int n_arbiters)
120120
{
121-
mock_rs_t *rs = bson_malloc0 (sizeof (mock_rs_t));
121+
mock_rs_t *rs = (mock_rs_t *)bson_malloc0 (sizeof (mock_rs_t));
122122

123123
rs->max_wire_version = max_wire_version;
124124
rs->has_primary = has_primary;

tests/mock_server/mock-server.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ static uint16_t get_port (mongoc_socket_t *sock);
108108
mock_server_t *
109109
mock_server_new ()
110110
{
111-
mock_server_t *server = bson_malloc0 (sizeof (mock_server_t));
111+
mock_server_t *server = (mock_server_t *)bson_malloc0 (sizeof (mock_server_t));
112112

113113
server->request_timeout_msec = 10 * 1000;
114114
_mongoc_array_init (&server->autoresponders,
@@ -1125,7 +1125,7 @@ typedef struct worker_closure_t
11251125
static void *
11261126
main_thread (void *data)
11271127
{
1128-
mock_server_t *server = data;
1128+
mock_server_t *server = (mock_server_t *)data;
11291129
mongoc_socket_t *client_sock;
11301130
bool stopped;
11311131
uint16_t port;
@@ -1172,7 +1172,7 @@ main_thread (void *data)
11721172
}
11731173
}
11741174
#endif
1175-
closure = bson_malloc (sizeof *closure);
1175+
closure = (worker_closure_t *)bson_malloc (sizeof *closure);
11761176
closure->server = server;
11771177
closure->client_stream = client_stream;
11781178
closure->port = port;
@@ -1358,7 +1358,7 @@ mock_server_reply_simple (mock_server_t *server,
13581358
_mongoc_rpc_gather (&r, &ar);
13591359
_mongoc_rpc_swab_to_le (&r);
13601360

1361-
iov = ar.data;
1361+
iov = (mongoc_iovec_t *)ar.data;
13621362
iovcnt = (int) ar.len;
13631363

13641364
for (i = 0; i < iovcnt; i++) {

tests/mock_server/request.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ request_new (const mongoc_buffer_t *buffer,
4141
mongoc_stream_t *client,
4242
uint16_t client_port)
4343
{
44-
request_t *request = bson_malloc0 (sizeof *request);
44+
request_t *request = (request_t *)bson_malloc0 (sizeof *request);
4545
uint8_t *data;
4646

47-
data = bson_malloc ((size_t)msg_len);
47+
data = (uint8_t *)bson_malloc ((size_t)msg_len);
4848
memcpy (data, buffer->data + buffer->off, (size_t) msg_len);
4949
request->data = data;
5050
request->data_len = (size_t) msg_len;
@@ -430,7 +430,7 @@ is_command (const char *ns)
430430
char *
431431
query_flags_str (uint32_t flags)
432432
{
433-
mongoc_query_flags_t flag = (mongoc_query_flags_t) 1;
433+
int flag = 1;
434434
bson_string_t *str = bson_string_new ("");
435435
bool begun = false;
436436

@@ -549,7 +549,7 @@ void
549549
request_from_insert (request_t *request,
550550
const mongoc_rpc_t *rpc)
551551
{
552-
uint8_t *pos = request->request_rpc.insert.documents->iov_base;
552+
uint8_t *pos = (uint8_t *)request->request_rpc.insert.documents->iov_base;
553553
uint8_t *end = request->data + request->data_len;
554554
bson_string_t *insert_as_str = bson_string_new("");
555555
bson_t *doc;

tests/mock_server/sync-queue.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ struct _sync_queue_t {
3030
sync_queue_t *
3131
q_new ()
3232
{
33-
sync_queue_t *q = bson_malloc (sizeof(sync_queue_t));
33+
sync_queue_t *q = (sync_queue_t *)bson_malloc (sizeof(sync_queue_t));
3434

3535
_mongoc_array_init (&q->array, sizeof(void *));
3636
mongoc_cond_init (&q->cond);

tests/ssl-test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ ssl_test_client (void * ptr)
230230
assert(r == wiov.iov_len);
231231

232232
for (i = 0; i < NUM_IOVECS; i++) {
233-
wiov_many[i].iov_base = "foo";
233+
wiov_many[i].iov_base = (void *)"foo";
234234
wiov_many[i].iov_len = 4;
235235
}
236236

tests/test-bulk.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ init_huge_string (mongoc_client_t *client)
3535
max_bson_size = mongoc_cluster_get_max_bson_obj_size(&client->cluster);
3636
assert (max_bson_size > 0);
3737
gHugeStringLength = (size_t) max_bson_size - 37;
38-
gHugeString = bson_malloc (gHugeStringLength);
38+
gHugeString = (char *)bson_malloc (gHugeStringLength);
3939
assert (gHugeString);
4040
memset (gHugeString, 'a', gHugeStringLength - 1);
4141
gHugeString[gHugeStringLength - 1] = '\0';
@@ -63,7 +63,7 @@ void
6363
init_four_mb_string ()
6464
{
6565
if (!gFourMBString) {
66-
gFourMBString = bson_malloc (gFourMB);
66+
gFourMBString = (char *)bson_malloc (gFourMB);
6767
assert (gFourMBString);
6868
memset (gFourMBString, 'a', gFourMB - 1);
6969
gFourMBString[gFourMB - 1] = '\0';

0 commit comments

Comments
 (0)