Skip to content

Commit 1941a0a

Browse files
committed
CDRIVER-697 don't use bson_return functions.
BSON_ASSERT will become a release-build runtime check, so use it everywhere.
1 parent 05a6bcd commit 1941a0a

33 files changed

+346
-361
lines changed

src/mongoc/mongoc-array.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ void
2222
_mongoc_array_init (mongoc_array_t *array,
2323
size_t element_size)
2424
{
25-
bson_return_if_fail(array);
26-
bson_return_if_fail(element_size);
25+
BSON_ASSERT (array);
26+
BSON_ASSERT (element_size);
2727

2828
array->len = 0;
2929
array->element_size = element_size;
@@ -80,8 +80,8 @@ _mongoc_array_append_vals (mongoc_array_t *array,
8080
size_t off;
8181
size_t next_size;
8282

83-
bson_return_if_fail(array);
84-
bson_return_if_fail(data);
83+
BSON_ASSERT (array);
84+
BSON_ASSERT (data);
8585

8686
off = array->element_size * array->len;
8787
len = (size_t)n_elements * array->element_size;

src/mongoc/mongoc-async-cmd.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,9 @@ mongoc_async_cmd_new (mongoc_async_t *async,
172172
mongoc_async_cmd_t *tmp;
173173
bool found = false;
174174

175-
bson_return_val_if_fail(cmd, NULL);
176-
bson_return_val_if_fail(dbname, NULL);
177-
bson_return_val_if_fail(stream, NULL);
175+
BSON_ASSERT (cmd);
176+
BSON_ASSERT (dbname);
177+
BSON_ASSERT (stream);
178178

179179
acmd = (mongoc_async_cmd_t *)bson_malloc0 (sizeof (*acmd));
180180
acmd->async = async;
@@ -217,7 +217,7 @@ mongoc_async_cmd_new (mongoc_async_t *async,
217217
void
218218
mongoc_async_cmd_destroy (mongoc_async_cmd_t *acmd)
219219
{
220-
bson_return_if_fail (acmd);
220+
BSON_ASSERT (acmd);
221221

222222
DL_DELETE (acmd->async->cmds, acmd);
223223
acmd->async->ncmds--;

src/mongoc/mongoc-buffer.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ _mongoc_buffer_init (mongoc_buffer_t *buffer,
5454
bson_realloc_func realloc_func,
5555
void *realloc_data)
5656
{
57-
bson_return_if_fail (buffer);
58-
bson_return_if_fail (buflen || !buf);
57+
BSON_ASSERT (buffer);
58+
BSON_ASSERT (buflen || !buf);
5959

6060
if (!realloc_func) {
6161
realloc_func = bson_realloc_ctx;
@@ -89,7 +89,7 @@ _mongoc_buffer_init (mongoc_buffer_t *buffer,
8989
void
9090
_mongoc_buffer_destroy (mongoc_buffer_t *buffer)
9191
{
92-
bson_return_if_fail(buffer);
92+
BSON_ASSERT (buffer);
9393

9494
if (buffer->data && buffer->realloc_func) {
9595
buffer->realloc_func (buffer->data, 0, buffer->realloc_data);
@@ -112,7 +112,7 @@ void
112112
_mongoc_buffer_clear (mongoc_buffer_t *buffer,
113113
bool zero)
114114
{
115-
bson_return_if_fail(buffer);
115+
BSON_ASSERT (buffer);
116116

117117
if (zero) {
118118
memset(buffer->data, 0, buffer->datalen);
@@ -149,9 +149,9 @@ _mongoc_buffer_append_from_stream (mongoc_buffer_t *buffer,
149149

150150
ENTRY;
151151

152-
bson_return_val_if_fail (buffer, false);
153-
bson_return_val_if_fail (stream, false);
154-
bson_return_val_if_fail (size, false);
152+
BSON_ASSERT (buffer);
153+
BSON_ASSERT (stream);
154+
BSON_ASSERT (size);
155155

156156
BSON_ASSERT (buffer->datalen);
157157
BSON_ASSERT ((buffer->datalen + size) < INT_MAX);
@@ -210,8 +210,8 @@ _mongoc_buffer_fill (mongoc_buffer_t *buffer,
210210

211211
ENTRY;
212212

213-
bson_return_val_if_fail(buffer, false);
214-
bson_return_val_if_fail(stream, false);
213+
BSON_ASSERT (buffer);
214+
BSON_ASSERT (stream);
215215

216216
BSON_ASSERT (buffer->data);
217217
BSON_ASSERT (buffer->datalen);
@@ -292,9 +292,9 @@ _mongoc_buffer_try_append_from_stream (mongoc_buffer_t *buffer,
292292

293293
ENTRY;
294294

295-
bson_return_val_if_fail (buffer, false);
296-
bson_return_val_if_fail (stream, false);
297-
bson_return_val_if_fail (size, false);
295+
BSON_ASSERT (buffer);
296+
BSON_ASSERT (stream);
297+
BSON_ASSERT (size);
298298

299299
BSON_ASSERT (buffer->datalen);
300300
BSON_ASSERT ((buffer->datalen + size) < INT_MAX);

src/mongoc/mongoc-bulk-operation.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ mongoc_bulk_operation_remove (mongoc_bulk_operation_t *bulk, /* IN */
119119

120120
ENTRY;
121121

122-
bson_return_if_fail (bulk);
123-
bson_return_if_fail (selector);
122+
BSON_ASSERT (bulk);
123+
BSON_ASSERT (selector);
124124

125125
if (bulk->commands.len) {
126126
last = &_mongoc_array_index (&bulk->commands,
@@ -150,8 +150,8 @@ mongoc_bulk_operation_remove_one (mongoc_bulk_operation_t *bulk, /* IN */
150150

151151
ENTRY;
152152

153-
bson_return_if_fail (bulk);
154-
bson_return_if_fail (selector);
153+
BSON_ASSERT (bulk);
154+
BSON_ASSERT (selector);
155155

156156
if (bulk->commands.len) {
157157
last = &_mongoc_array_index (&bulk->commands,
@@ -205,8 +205,8 @@ mongoc_bulk_operation_insert (mongoc_bulk_operation_t *bulk,
205205

206206
ENTRY;
207207

208-
bson_return_if_fail (bulk);
209-
bson_return_if_fail (document);
208+
BSON_ASSERT (bulk);
209+
BSON_ASSERT (document);
210210

211211
if (bulk->commands.len) {
212212
last = &_mongoc_array_index (&bulk->commands,
@@ -240,9 +240,9 @@ mongoc_bulk_operation_replace_one (mongoc_bulk_operation_t *bulk,
240240
mongoc_write_command_t *last;
241241
int flags = BSON_VALIDATE_DOT_KEYS|BSON_VALIDATE_DOLLAR_KEYS;
242242

243-
bson_return_if_fail (bulk);
244-
bson_return_if_fail (selector);
245-
bson_return_if_fail (document);
243+
BSON_ASSERT (bulk);
244+
BSON_ASSERT (selector);
245+
BSON_ASSERT (document);
246246

247247
ENTRY;
248248

@@ -282,9 +282,9 @@ mongoc_bulk_operation_update (mongoc_bulk_operation_t *bulk,
282282
bson_iter_t iter;
283283
mongoc_write_command_t *last;
284284

285-
bson_return_if_fail (bulk);
286-
bson_return_if_fail (selector);
287-
bson_return_if_fail (document);
285+
BSON_ASSERT (bulk);
286+
BSON_ASSERT (selector);
287+
BSON_ASSERT (document);
288288

289289
ENTRY;
290290

@@ -325,9 +325,9 @@ mongoc_bulk_operation_update_one (mongoc_bulk_operation_t *bulk,
325325
bson_iter_t iter;
326326
mongoc_write_command_t *last;
327327

328-
bson_return_if_fail (bulk);
329-
bson_return_if_fail (selector);
330-
bson_return_if_fail (document);
328+
BSON_ASSERT (bulk);
329+
BSON_ASSERT (selector);
330+
BSON_ASSERT (document);
331331

332332
ENTRY;
333333

@@ -370,7 +370,7 @@ mongoc_bulk_operation_execute (mongoc_bulk_operation_t *bulk, /* IN */
370370

371371
ENTRY;
372372

373-
bson_return_val_if_fail (bulk, false);
373+
BSON_ASSERT (bulk);
374374

375375
if (bulk->executed) {
376376
_mongoc_write_result_destroy (&bulk->result);
@@ -443,7 +443,7 @@ void
443443
mongoc_bulk_operation_set_write_concern (mongoc_bulk_operation_t *bulk,
444444
const mongoc_write_concern_t *write_concern)
445445
{
446-
bson_return_if_fail (bulk);
446+
BSON_ASSERT (bulk);
447447

448448
if (bulk->write_concern) {
449449
mongoc_write_concern_destroy (bulk->write_concern);
@@ -459,7 +459,7 @@ mongoc_bulk_operation_set_write_concern (mongoc_bulk_operation_t *bulk,
459459
const mongoc_write_concern_t *
460460
mongoc_bulk_operation_get_write_concern (const mongoc_bulk_operation_t *bulk)
461461
{
462-
bson_return_val_if_fail (bulk, NULL);
462+
BSON_ASSERT (bulk);
463463

464464
return bulk->write_concern;
465465
}
@@ -469,7 +469,7 @@ void
469469
mongoc_bulk_operation_set_database (mongoc_bulk_operation_t *bulk,
470470
const char *database)
471471
{
472-
bson_return_if_fail (bulk);
472+
BSON_ASSERT (bulk);
473473

474474
if (bulk->database) {
475475
bson_free (bulk->database);
@@ -483,7 +483,7 @@ void
483483
mongoc_bulk_operation_set_collection (mongoc_bulk_operation_t *bulk,
484484
const char *collection)
485485
{
486-
bson_return_if_fail (bulk);
486+
BSON_ASSERT (bulk);
487487

488488
if (bulk->collection) {
489489
bson_free (bulk->collection);
@@ -497,7 +497,7 @@ void
497497
mongoc_bulk_operation_set_client (mongoc_bulk_operation_t *bulk,
498498
void *client)
499499
{
500-
bson_return_if_fail (bulk);
500+
BSON_ASSERT (bulk);
501501

502502
bulk->client = (mongoc_client_t *)client;
503503
}
@@ -507,7 +507,7 @@ void
507507
mongoc_bulk_operation_set_hint (mongoc_bulk_operation_t *bulk,
508508
uint32_t hint)
509509
{
510-
bson_return_if_fail (bulk);
510+
BSON_ASSERT (bulk);
511511

512512
bulk->hint = hint;
513513
}

src/mongoc/mongoc-client-pool.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void
4747
mongoc_client_pool_set_ssl_opts (mongoc_client_pool_t *pool,
4848
const mongoc_ssl_opt_t *opts)
4949
{
50-
bson_return_if_fail (pool);
50+
BSON_ASSERT (pool);
5151

5252
mongoc_mutex_lock (&pool->mutex);
5353

@@ -77,7 +77,7 @@ mongoc_client_pool_new (const mongoc_uri_t *uri)
7777

7878
ENTRY;
7979

80-
bson_return_val_if_fail(uri, NULL);
80+
BSON_ASSERT (uri);
8181

8282
pool = (mongoc_client_pool_t *)bson_malloc0(sizeof *pool);
8383
mongoc_mutex_init(&pool->mutex);
@@ -117,7 +117,7 @@ mongoc_client_pool_destroy (mongoc_client_pool_t *pool)
117117

118118
ENTRY;
119119

120-
bson_return_if_fail(pool);
120+
BSON_ASSERT (pool);
121121

122122
while ((client = (mongoc_client_t *)_mongoc_queue_pop_head(&pool->queue))) {
123123
mongoc_client_destroy(client);
@@ -144,7 +144,7 @@ mongoc_client_pool_pop (mongoc_client_pool_t *pool)
144144

145145
ENTRY;
146146

147-
bson_return_val_if_fail(pool, NULL);
147+
BSON_ASSERT (pool);
148148

149149
mongoc_mutex_lock(&pool->mutex);
150150

@@ -177,7 +177,7 @@ mongoc_client_pool_try_pop (mongoc_client_pool_t *pool)
177177

178178
ENTRY;
179179

180-
bson_return_val_if_fail(pool, NULL);
180+
BSON_ASSERT (pool);
181181

182182
mongoc_mutex_lock(&pool->mutex);
183183

@@ -205,8 +205,8 @@ mongoc_client_pool_push (mongoc_client_pool_t *pool,
205205
{
206206
ENTRY;
207207

208-
bson_return_if_fail(pool);
209-
bson_return_if_fail(client);
208+
BSON_ASSERT (pool);
209+
BSON_ASSERT (client);
210210

211211
mongoc_mutex_lock(&pool->mutex);
212212
if (pool->size > pool->min_pool_size) {

0 commit comments

Comments
 (0)