Skip to content

Commit 068e0ad

Browse files
committed
CDRIVER-366: Cast void to the actual types on assignments
1 parent b1e9fad commit 068e0ad

18 files changed

+80
-74
lines changed

src/mongoc/mongoc-async-cmd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ mongoc_async_cmd_tls_setup (mongoc_stream_t *stream,
6363
bson_error_t *error)
6464
{
6565
mongoc_stream_t *tls_stream;
66-
const char *host = ctx;
66+
const char *host = (const char *)ctx;
6767

6868
for (tls_stream = stream; tls_stream->type != MONGOC_STREAM_TLS;
6969
tls_stream = mongoc_stream_get_base_stream (tls_stream)) {

src/mongoc/mongoc-bulk-operation.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ mongoc_bulk_operation_set_client (mongoc_bulk_operation_t *bulk,
499499
{
500500
bson_return_if_fail (bulk);
501501

502-
bulk->client = client;
502+
bulk->client = (mongoc_client_t *)client;
503503
}
504504

505505

src/mongoc/mongoc-client-pool.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ mongoc_client_pool_destroy (mongoc_client_pool_t *pool)
119119

120120
bson_return_if_fail(pool);
121121

122-
while ((client = _mongoc_queue_pop_head(&pool->queue))) {
122+
while ((client = (mongoc_client_t *)_mongoc_queue_pop_head(&pool->queue))) {
123123
mongoc_client_destroy(client);
124124
}
125125

@@ -149,7 +149,7 @@ mongoc_client_pool_pop (mongoc_client_pool_t *pool)
149149
mongoc_mutex_lock(&pool->mutex);
150150

151151
again:
152-
if (!(client = _mongoc_queue_pop_head(&pool->queue))) {
152+
if (!(client = (mongoc_client_t *)_mongoc_queue_pop_head(&pool->queue))) {
153153
if (pool->size < pool->max_pool_size) {
154154
client = _mongoc_client_new_from_uri(pool->uri, pool->topology);
155155
#ifdef MONGOC_ENABLE_SSL
@@ -181,7 +181,7 @@ mongoc_client_pool_try_pop (mongoc_client_pool_t *pool)
181181

182182
mongoc_mutex_lock(&pool->mutex);
183183

184-
if (!(client = _mongoc_queue_pop_head(&pool->queue))) {
184+
if (!(client = (mongoc_client_t *)_mongoc_queue_pop_head(&pool->queue))) {
185185
if (pool->size < pool->max_pool_size) {
186186
client = _mongoc_client_new_from_uri(pool->uri, pool->topology);
187187
#ifdef MONGOC_ENABLE_SSL
@@ -211,7 +211,7 @@ mongoc_client_pool_push (mongoc_client_pool_t *pool,
211211
mongoc_mutex_lock(&pool->mutex);
212212
if (pool->size > pool->min_pool_size) {
213213
mongoc_client_t *old_client;
214-
old_client = _mongoc_queue_pop_head (&pool->queue);
214+
old_client = (mongoc_client_t *)_mongoc_queue_pop_head (&pool->queue);
215215
if (old_client) {
216216
mongoc_client_destroy (old_client);
217217
pool->size--;

src/mongoc/mongoc-client.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ mongoc_client_default_stream_initiator (const mongoc_uri_t *uri,
273273
{
274274
mongoc_stream_t *base_stream = NULL;
275275
#ifdef MONGOC_ENABLE_SSL
276-
mongoc_client_t *client = user_data;
276+
mongoc_client_t *client = (mongoc_client_t *)user_data;
277277
const bson_t *options;
278278
bson_iter_t iter;
279279
const char *mechanism;

src/mongoc/mongoc-cluster.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ _mongoc_cluster_run_command (mongoc_cluster_t *cluster,
132132
_mongoc_rpc_gather(&rpc, &ar);
133133
_mongoc_rpc_swab_to_le(&rpc);
134134

135-
if (!mongoc_stream_writev(stream, ar.data, ar.len,
135+
if (!mongoc_stream_writev(stream, (mongoc_iovec_t *)ar.data, ar.len,
136136
cluster->sockettimeoutms)) {
137137
GOTO(failure);
138138
}
@@ -1094,7 +1094,7 @@ static void
10941094
_mongoc_cluster_node_dtor (void *data_,
10951095
void *ctx_)
10961096
{
1097-
mongoc_cluster_node_t *node = data_;
1097+
mongoc_cluster_node_t *node = (mongoc_cluster_node_t *)data_;
10981098

10991099
_mongoc_cluster_node_destroy (node);
11001100
}
@@ -1278,7 +1278,7 @@ mongoc_cluster_fetch_stream (mongoc_cluster_t *cluster,
12781278
}
12791279

12801280
} else {
1281-
cluster_node = mongoc_set_get(cluster->nodes, server_id);
1281+
cluster_node = (mongoc_cluster_node_t *)mongoc_set_get(cluster->nodes, server_id);
12821282
if (!cluster_node) {
12831283
goto FETCH_FAIL;
12841284
}
@@ -1373,7 +1373,7 @@ mongoc_cluster_init (mongoc_cluster_t *cluster,
13731373
memset (cluster, 0, sizeof *cluster);
13741374

13751375
cluster->uri = mongoc_uri_copy(uri);
1376-
cluster->client = client;
1376+
cluster->client = (mongoc_client_t *)client;
13771377
cluster->requires_auth = (mongoc_uri_get_username(uri) ||
13781378
mongoc_uri_get_auth_mechanism(uri));
13791379

@@ -1603,7 +1603,7 @@ mongoc_cluster_select(mongoc_cluster_t *cluster,
16031603

16041604
/* pick the most restrictive optype */
16051605
for (i = 0; (i < rpcs_len) && (optype == MONGOC_SS_READ); i++) {
1606-
opcode = rpcs[i].header.opcode;
1606+
opcode = (mongoc_opcode_t) rpcs[i].header.opcode;
16071607
if (_mongoc_opcode_needs_primary(opcode)) {
16081608
/* we can run queries on secondaries if given either:
16091609
* - a read mode of secondary
@@ -1740,8 +1740,8 @@ static bool
17401740
_mongoc_cluster_min_of_max_obj_size_sds (void *item,
17411741
void *ctx)
17421742
{
1743-
mongoc_server_description_t *sd = item;
1744-
int32_t *current_min = ctx;
1743+
mongoc_server_description_t *sd = (mongoc_server_description_t *)item;
1744+
int32_t *current_min = (int32_t *)ctx;
17451745

17461746
if (sd->max_bson_obj_size < *current_min) {
17471747
*current_min = sd->max_bson_obj_size;
@@ -1753,8 +1753,8 @@ static bool
17531753
_mongoc_cluster_min_of_max_obj_size_nodes (void *item,
17541754
void *ctx)
17551755
{
1756-
mongoc_cluster_node_t *node = item;
1757-
int32_t *current_min = ctx;
1756+
mongoc_cluster_node_t *node = (mongoc_cluster_node_t *)item;
1757+
int32_t *current_min = (int32_t *)ctx;
17581758

17591759
if (node->max_bson_obj_size < *current_min) {
17601760
*current_min = node->max_bson_obj_size;
@@ -1766,8 +1766,8 @@ static bool
17661766
_mongoc_cluster_min_of_max_msg_size_sds (void *item,
17671767
void *ctx)
17681768
{
1769-
mongoc_server_description_t *sd = item;
1770-
int32_t *current_min = ctx;
1769+
mongoc_server_description_t *sd = (mongoc_server_description_t *)item;
1770+
int32_t *current_min = (int32_t *)ctx;
17711771

17721772
if (sd->max_msg_size < *current_min) {
17731773
*current_min = sd->max_msg_size;
@@ -1779,8 +1779,8 @@ static bool
17791779
_mongoc_cluster_min_of_max_msg_size_nodes (void *item,
17801780
void *ctx)
17811781
{
1782-
mongoc_cluster_node_t *node = item;
1783-
int32_t *current_min = ctx;
1782+
mongoc_cluster_node_t *node = (mongoc_cluster_node_t *)item;
1783+
int32_t *current_min = (int32_t *)ctx;
17841784

17851785
if (node->max_msg_size < *current_min) {
17861786
*current_min = node->max_msg_size;
@@ -1812,7 +1812,7 @@ mongoc_cluster_node_max_bson_obj_size (mongoc_cluster_t *cluster,
18121812
return sd->max_bson_obj_size;
18131813
}
18141814
} else {
1815-
if((node = mongoc_set_get(cluster->nodes, server_id))) {
1815+
if((node = (mongoc_cluster_node_t *)mongoc_set_get(cluster->nodes, server_id))) {
18161816
return node->max_bson_obj_size;
18171817
}
18181818
}
@@ -1845,7 +1845,7 @@ mongoc_cluster_node_max_msg_size (mongoc_cluster_t *cluster,
18451845
return sd->max_msg_size;
18461846
}
18471847
} else {
1848-
if((node = mongoc_set_get(cluster->nodes, server_id))) {
1848+
if((node = (mongoc_cluster_node_t *)mongoc_set_get(cluster->nodes, server_id))) {
18491849
return node->max_msg_size;
18501850
}
18511851
}
@@ -1878,7 +1878,7 @@ mongoc_cluster_node_max_write_batch_size (mongoc_cluster_t *cluster,
18781878
return sd->max_write_batch_size;
18791879
}
18801880
} else {
1881-
if((node = mongoc_set_get(cluster->nodes, server_id))) {
1881+
if((node = (mongoc_cluster_node_t *)mongoc_set_get(cluster->nodes, server_id))) {
18821882
return node->max_write_batch_size;
18831883
}
18841884
}
@@ -1983,7 +1983,7 @@ mongoc_cluster_node_max_wire_version (mongoc_cluster_t *cluster,
19831983
return sd->max_wire_version;
19841984
}
19851985
} else {
1986-
if((node = mongoc_set_get(cluster->nodes, server_id))) {
1986+
if((node = (mongoc_cluster_node_t *)mongoc_set_get(cluster->nodes, server_id))) {
19871987
return node->max_wire_version;
19881988
}
19891989
}
@@ -2016,7 +2016,7 @@ mongoc_cluster_node_min_wire_version (mongoc_cluster_t *cluster,
20162016
return sd->min_wire_version;
20172017
}
20182018
} else {
2019-
if((node = mongoc_set_get(cluster->nodes, server_id))) {
2019+
if((node = (mongoc_cluster_node_t *)mongoc_set_get(cluster->nodes, server_id))) {
20202020
return node->min_wire_version;
20212021
}
20222022
}
@@ -2223,7 +2223,7 @@ mongoc_cluster_sendv_to_server (mongoc_cluster_t *cluster,
22232223
gle.query.collection = cmdname;
22242224
gle.query.skip = 0;
22252225
gle.query.n_return = 1;
2226-
b = _mongoc_write_concern_get_gle((void*)write_concern);
2226+
b = _mongoc_write_concern_get_gle((mongoc_write_concern_t *)write_concern);
22272227
gle.query.query = bson_get_data(b);
22282228
gle.query.fields = NULL;
22292229
_mongoc_rpc_gather(&gle, &cluster->iov);
@@ -2233,7 +2233,7 @@ mongoc_cluster_sendv_to_server (mongoc_cluster_t *cluster,
22332233
_mongoc_rpc_swab_to_le(&rpcs[i]);
22342234
}
22352235

2236-
iov = cluster->iov.data;
2236+
iov = (mongoc_iovec_t *)cluster->iov.data;
22372237
iovcnt = cluster->iov.len;
22382238
errno = 0;
22392239

src/mongoc/mongoc-counters.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ _mongoc_counters_init (void)
296296

297297
#define COUNTER(ident, Category, Name, Desc) \
298298
off = mongoc_counters_register(counters, COUNTER_##ident, Category, Name, Desc); \
299-
__mongoc_counter_##ident.cpus = (void *)(segment + off);
299+
__mongoc_counter_##ident.cpus = (mongoc_counter_slots_t *)(segment + off);
300300
#include "mongoc-counters.defs"
301301
#undef COUNTER
302302

src/mongoc/mongoc-cursor-array.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ _mongoc_cursor_array_destroy (mongoc_cursor_t *cursor)
6464

6565
ENTRY;
6666

67-
arr = cursor->iface_data;
67+
arr = (mongoc_cursor_array_t *)cursor->iface_data;
6868

6969
if (arr->has_synthetic_bson) {
7070
bson_destroy(&arr->bson);
@@ -86,7 +86,7 @@ _mongoc_cursor_array_prime (mongoc_cursor_t *cursor)
8686

8787
ENTRY;
8888

89-
arr = cursor->iface_data;
89+
arr = (mongoc_cursor_array_t *)cursor->iface_data;
9090
if (!arr->has_array) {
9191
arr->has_array = true;
9292

@@ -113,7 +113,7 @@ _mongoc_cursor_array_next (mongoc_cursor_t *cursor,
113113

114114
ENTRY;
115115

116-
arr = cursor->iface_data;
116+
arr = (mongoc_cursor_array_t *)cursor->iface_data;
117117
*bson = NULL;
118118

119119
if (!arr->has_array) {
@@ -143,7 +143,7 @@ _mongoc_cursor_array_clone (const mongoc_cursor_t *cursor)
143143

144144
ENTRY;
145145

146-
arr = cursor->iface_data;
146+
arr = (mongoc_cursor_array_t *)cursor->iface_data;
147147

148148
clone_ = _mongoc_cursor_clone (cursor);
149149
_mongoc_cursor_array_init (clone_, arr->field_name);
@@ -161,7 +161,7 @@ _mongoc_cursor_array_more (mongoc_cursor_t *cursor)
161161

162162
ENTRY;
163163

164-
arr = cursor->iface_data;
164+
arr = (mongoc_cursor_array_t *)cursor->iface_data;
165165

166166
if (arr->has_array) {
167167
memcpy (&iter, &arr->iter, sizeof iter);
@@ -183,7 +183,7 @@ _mongoc_cursor_array_error (mongoc_cursor_t *cursor,
183183

184184
ENTRY;
185185

186-
arr = cursor->iface_data;
186+
arr = (mongoc_cursor_array_t *)cursor->iface_data;
187187

188188
if (arr->has_synthetic_bson) {
189189
return false;
@@ -225,7 +225,7 @@ _mongoc_cursor_array_set_bson (mongoc_cursor_t *cursor,
225225

226226
ENTRY;
227227

228-
arr = cursor->iface_data;
228+
arr = (mongoc_cursor_array_t *)cursor->iface_data;
229229

230230
bson_copy_to(bson, &arr->bson);
231231

src/mongoc/mongoc-cursor-cursorid.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ _mongoc_cursor_cursorid_prime (mongoc_cursor_t *cursor)
6666

6767
ENTRY;
6868

69-
cid = cursor->iface_data;
69+
cid = (mongoc_cursor_cursorid_t *)cursor->iface_data;
7070

7171
if (!cid->has_cursor) {
7272
ret = _mongoc_cursor_next (cursor, &bson);
@@ -112,7 +112,7 @@ _mongoc_cursor_cursorid_next (mongoc_cursor_t *cursor,
112112

113113
ENTRY;
114114

115-
cid = cursor->iface_data;
115+
cid = (mongoc_cursor_cursorid_t *)cursor->iface_data;
116116

117117
if (! cid->has_cursor) {
118118
if (! _mongoc_cursor_cursorid_prime (cursor)) {

src/mongoc/mongoc-cursor-transform.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ _mongoc_cursor_transform_destroy (mongoc_cursor_t *cursor)
6969

7070
ENTRY;
7171

72-
transform = cursor->iface_data;
72+
transform = (mongoc_cursor_transform_t *)cursor->iface_data;
7373

7474
if (transform->dtor) {
7575
transform->dtor (transform->ctx);
@@ -92,7 +92,7 @@ _mongoc_cursor_transform_next (mongoc_cursor_t *cursor,
9292

9393
ENTRY;
9494

95-
transform = cursor->iface_data;
95+
transform = (mongoc_cursor_transform_t *)cursor->iface_data;
9696

9797
for (;; ) {
9898
if (!_mongoc_cursor_next (cursor, bson)) {
@@ -129,7 +129,7 @@ _mongoc_cursor_transform_clone (const mongoc_cursor_t *cursor)
129129

130130
ENTRY;
131131

132-
transform = cursor->iface_data;
132+
transform = (mongoc_cursor_transform_t *)cursor->iface_data;
133133

134134
clone_ = _mongoc_cursor_clone (cursor);
135135
_mongoc_cursor_transform_init (clone_, transform->filter, transform->mutate,

src/mongoc/mongoc-database.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ _mongoc_database_find_collections_legacy_filter (const bson_t *bson,
653653
bson_iter_t iter;
654654
mongoc_database_find_collections_legacy_ctx_t *ctx;
655655

656-
ctx = ctx_;
656+
ctx = (mongoc_database_find_collections_legacy_ctx_t *)ctx_;
657657

658658
if (bson_iter_init_find (&iter, bson, "name")
659659
&& BSON_ITER_HOLDS_UTF8 (&iter)
@@ -673,7 +673,7 @@ _mongoc_database_find_collections_legacy_mutate (const bson_t *bson,
673673
{
674674
mongoc_database_find_collections_legacy_ctx_t *ctx;
675675

676-
ctx = ctx_;
676+
ctx = (mongoc_database_find_collections_legacy_ctx_t *)ctx_;
677677

678678
bson_copy_to_excluding_noinit (bson, out, "name", NULL);
679679
BSON_APPEND_UTF8 (out, "name", ctx->name + (ctx->dbname_len + 1)); /* +1 for the '.' */

0 commit comments

Comments
 (0)