Skip to content

Commit f5a2401

Browse files
committed
CDRIVER-366: Cast allocations to correct types
1 parent 1f87486 commit f5a2401

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+79
-75
lines changed

src/mongoc/mongoc-array.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ _mongoc_array_init (mongoc_array_t *array,
2828
array->len = 0;
2929
array->element_size = element_size;
3030
array->allocated = 128;
31-
array->data = bson_malloc0(array->allocated);
31+
array->data = (void *)bson_malloc0(array->allocated);
3232
}
3333

3434

@@ -57,7 +57,7 @@ _mongoc_array_copy (mongoc_array_t *dst,
5757
dst->len = src->len;
5858
dst->element_size = src->element_size;
5959
dst->allocated = src->allocated;
60-
dst->data = bson_malloc (dst->allocated);
60+
dst->data = (void *)bson_malloc (dst->allocated);
6161
memcpy (dst->data, src->data, dst->allocated);
6262
}
6363

@@ -87,7 +87,7 @@ _mongoc_array_append_vals (mongoc_array_t *array,
8787
len = (size_t)n_elements * array->element_size;
8888
if ((off + len) > array->allocated) {
8989
next_size = bson_next_power_of_two(off + len);
90-
array->data = bson_realloc(array->data, next_size);
90+
array->data = (void *)bson_realloc(array->data, next_size);
9191
array->allocated = next_size;
9292
}
9393

src/mongoc/mongoc-async-cmd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ mongoc_async_cmd_new (mongoc_async_t *async,
170170
bson_return_val_if_fail(dbname, NULL);
171171
bson_return_val_if_fail(stream, NULL);
172172

173-
acmd = bson_malloc0 (sizeof (*acmd));
173+
acmd = (mongoc_async_cmd_t *)bson_malloc0 (sizeof (*acmd));
174174
acmd->async = async;
175175
acmd->expire_at = bson_get_monotonic_time () + (timeout_msec * 1000);
176176
acmd->stream = stream;

src/mongoc/mongoc-async.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ mongoc_async_cmd (mongoc_async_t *async,
4242
mongoc_async_t *
4343
mongoc_async_new ()
4444
{
45-
mongoc_async_t *async = bson_malloc0 (sizeof (*async));
45+
mongoc_async_t *async = (mongoc_async_t *)bson_malloc0 (sizeof (*async));
4646

4747
return async;
4848
}
@@ -106,7 +106,7 @@ mongoc_async_run (mongoc_async_t *async,
106106
}
107107

108108
if (poll_size < async->ncmds) {
109-
poller = bson_realloc (poller, sizeof (*poller) * async->ncmds);
109+
poller = (mongoc_stream_poll_t *)bson_realloc (poller, sizeof (*poller) * async->ncmds);
110110
poll_size = async->ncmds;
111111
}
112112

src/mongoc/mongoc-buffer.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ _mongoc_buffer_init (mongoc_buffer_t *buffer,
6767
}
6868

6969
if (!buf) {
70-
buf = realloc_func (NULL, buflen, NULL);
70+
buf = (uint8_t *)realloc_func (NULL, buflen, NULL);
7171
}
7272

7373
memset (buffer, 0, sizeof *buffer);
@@ -164,7 +164,7 @@ _mongoc_buffer_append_from_stream (mongoc_buffer_t *buffer,
164164
buffer->off = 0;
165165
if (!SPACE_FOR (buffer, size)) {
166166
buffer->datalen = bson_next_power_of_two (size + buffer->len + buffer->off);
167-
buffer->data = buffer->realloc_func (buffer->data, buffer->datalen, NULL);
167+
buffer->data = (uint8_t *)buffer->realloc_func (buffer->data, buffer->datalen, NULL);
168168
}
169169
}
170170

@@ -231,7 +231,7 @@ _mongoc_buffer_fill (mongoc_buffer_t *buffer,
231231

232232
if (!SPACE_FOR (buffer, min_bytes)) {
233233
buffer->datalen = bson_next_power_of_two (buffer->len + min_bytes);
234-
buffer->data = buffer->realloc_func (buffer->data, buffer->datalen,
234+
buffer->data = (uint8_t *)buffer->realloc_func (buffer->data, buffer->datalen,
235235
buffer->realloc_data);
236236
}
237237

@@ -307,7 +307,7 @@ _mongoc_buffer_try_append_from_stream (mongoc_buffer_t *buffer,
307307
buffer->off = 0;
308308
if (!SPACE_FOR (buffer, size)) {
309309
buffer->datalen = bson_next_power_of_two (size + buffer->len + buffer->off);
310-
buffer->data = buffer->realloc_func (buffer->data, buffer->datalen, NULL);
310+
buffer->data = (uint8_t *)buffer->realloc_func (buffer->data, buffer->datalen, NULL);
311311
}
312312
}
313313

src/mongoc/mongoc-bulk-operation.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ mongoc_bulk_operation_new (bool ordered)
4949
{
5050
mongoc_bulk_operation_t *bulk;
5151

52-
bulk = bson_malloc0 (sizeof *bulk);
52+
bulk = (mongoc_bulk_operation_t *)bson_malloc0 (sizeof *bulk);
5353
bulk->ordered = ordered;
5454

5555
_mongoc_array_init (&bulk->commands, sizeof (mongoc_write_command_t));

src/mongoc/mongoc-client-pool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ mongoc_client_pool_new (const mongoc_uri_t *uri)
7979

8080
bson_return_val_if_fail(uri, NULL);
8181

82-
pool = bson_malloc0(sizeof *pool);
82+
pool = (mongoc_client_pool_t *)bson_malloc0(sizeof *pool);
8383
mongoc_mutex_init(&pool->mutex);
8484
_mongoc_queue_init(&pool->queue);
8585
pool->uri = mongoc_uri_copy(uri);

src/mongoc/mongoc-client.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ _mongoc_client_new_from_uri (const mongoc_uri_t *uri, mongoc_topology_t *topolog
785785

786786
bson_return_val_if_fail(uri, NULL);
787787

788-
client = bson_malloc0(sizeof *client);
788+
client = (mongoc_client_t *)bson_malloc0(sizeof *client);
789789
client->uri = mongoc_uri_copy (uri);
790790
client->request_id = rand ();
791791
client->initiator = mongoc_client_default_stream_initiator;
@@ -1328,14 +1328,14 @@ mongoc_client_get_database_names (mongoc_client_t *client,
13281328
BSON_ITER_HOLDS_UTF8 (&iter) &&
13291329
(name = bson_iter_utf8 (&iter, NULL)) &&
13301330
(0 != strcmp (name, "local"))) {
1331-
ret = bson_realloc (ret, sizeof(char*) * (i + 2));
1331+
ret = (char **)bson_realloc (ret, sizeof(char*) * (i + 2));
13321332
ret [i] = bson_strdup (name);
13331333
ret [++i] = NULL;
13341334
}
13351335
}
13361336

13371337
if (!ret && !mongoc_cursor_error (cursor, error)) {
1338-
ret = bson_malloc0 (sizeof (void*));
1338+
ret = (char **)bson_malloc0 (sizeof (void*));
13391339
}
13401340

13411341
mongoc_cursor_destroy (cursor);

src/mongoc/mongoc-cluster.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,7 @@ _mongoc_cluster_node_new (mongoc_stream_t *stream)
11081108
return NULL;
11091109
}
11101110

1111-
node = bson_malloc0(sizeof *node);
1111+
node = (mongoc_cluster_node_t *)bson_malloc0(sizeof *node);
11121112

11131113
node->stream = stream;
11141114
node->timestamp = bson_get_monotonic_time ();

src/mongoc/mongoc-collection.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ _mongoc_collection_new (mongoc_client_t *client,
109109
bson_return_val_if_fail(db, NULL);
110110
bson_return_val_if_fail(collection, NULL);
111111

112-
col = bson_malloc0(sizeof *col);
112+
col = (mongoc_collection_t *)bson_malloc0(sizeof *col);
113113
col->client = client;
114114
col->write_concern = write_concern ?
115115
mongoc_write_concern_copy(write_concern) :

src/mongoc/mongoc-counters.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ mongoc_counters_alloc (size_t size)
201201
MONGOC_WARNING("Falling back to malloc for counters.");
202202
#endif
203203

204-
gCounterFallback = bson_malloc0 (size);
204+
gCounterFallback = (void *)bson_malloc0 (size);
205205

206206
return gCounterFallback;
207207
}
@@ -283,7 +283,7 @@ _mongoc_counters_init (void)
283283
char *segment;
284284

285285
size = mongoc_counters_calc_size();
286-
segment = mongoc_counters_alloc(size);
286+
segment = (char *)mongoc_counters_alloc(size);
287287
infos_size = LAST_COUNTER * sizeof *info;
288288

289289
counters = (mongoc_counters_t *)segment;

0 commit comments

Comments
 (0)