Skip to content

Commit 224a27e

Browse files
committed
CDRIVER-500 get rid of non-prefixed macros
Namespace MAX, MIN and ABS from libbson. None of those should have been going out over public headers, so we roll that back. This is a small source compatibility break.
1 parent 030eee4 commit 224a27e

File tree

8 files changed

+12
-12
lines changed

8 files changed

+12
-12
lines changed

src/mongoc/mongoc-client-pool.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ mongoc_client_pool_new (const mongoc_uri_t *uri)
8484

8585
if (bson_iter_init_find_case(&iter, b, "minpoolsize")) {
8686
if (BSON_ITER_HOLDS_INT32(&iter)) {
87-
pool->min_pool_size = MAX(0, bson_iter_int32(&iter));
87+
pool->min_pool_size = BSON_MAX(0, bson_iter_int32(&iter));
8888
}
8989
}
9090

9191
if (bson_iter_init_find_case(&iter, b, "maxpoolsize")) {
9292
if (BSON_ITER_HOLDS_INT32(&iter)) {
93-
pool->max_pool_size = MAX(1, bson_iter_int32(&iter));
93+
pool->max_pool_size = BSON_MAX(1, bson_iter_int32(&iter));
9494
}
9595
}
9696

src/mongoc/mongoc-counters.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ mongoc_counters_calc_size (void)
113113
(n_cpu * n_groups * sizeof(mongoc_counter_slots_t)));
114114

115115
#ifdef BSON_OS_UNIX
116-
return MAX(getpagesize(), size);
116+
return BSON_MAX(getpagesize(), size);
117117
#else
118118
return size;
119119
#endif

src/mongoc/mongoc-cursor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ _mongoc_n_return (mongoc_cursor_t * cursor)
8989
uint32_t remaining = cursor->limit - cursor->count;
9090

9191
/* use min of batch or remaining */
92-
r = MIN(r, (int32_t)remaining);
92+
r = BSON_MIN(r, (int32_t)remaining);
9393
}
9494

9595
return r;

src/mongoc/mongoc-gridfs-file-page.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ _mongoc_gridfs_file_page_read (mongoc_gridfs_file_page_t *page,
7979
BSON_ASSERT (page);
8080
BSON_ASSERT (dst);
8181

82-
bytes_read = MIN (len, page->len - page->offset);
82+
bytes_read = BSON_MIN (len, page->len - page->offset);
8383

8484
src = page->read_buf ? page->read_buf : page->buf;
8585

@@ -112,17 +112,17 @@ _mongoc_gridfs_file_page_write (mongoc_gridfs_file_page_t *page,
112112
BSON_ASSERT (page);
113113
BSON_ASSERT (src);
114114

115-
bytes_written = MIN (len, page->chunk_size - page->offset);
115+
bytes_written = BSON_MIN (len, page->chunk_size - page->offset);
116116

117117
if (!page->buf) {
118118
page->buf = bson_malloc (page->chunk_size);
119-
memcpy (page->buf, page->read_buf, MIN (page->chunk_size, page->len));
119+
memcpy (page->buf, page->read_buf, BSON_MIN (page->chunk_size, page->len));
120120
}
121121

122122
memcpy (page->buf + page->offset, src, bytes_written);
123123
page->offset += bytes_written;
124124

125-
page->len = MAX (page->offset, page->len);
125+
page->len = BSON_MAX (page->offset, page->len);
126126

127127
RETURN (bytes_written);
128128
}

src/mongoc/mongoc-gridfs-file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ mongoc_gridfs_file_writev (mongoc_gridfs_file_t *file,
490490
file->pos += r;
491491
bytes_written += r;
492492

493-
file->length = MAX (file->length, (int64_t)file->pos);
493+
file->length = BSON_MAX (file->length, (int64_t)file->pos);
494494

495495
if (iov_pos == iov[i].iov_len) {
496496
/** filled a bucket, keep going */

src/mongoc/mongoc-write-command.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@ _mongoc_write_result_merge (mongoc_write_result_t *result, /* IN */
11231123
* XXX: The following addition to nMatched needs some checking.
11241124
* I'm highly skeptical of it.
11251125
*/
1126-
result->nMatched += MAX (0, (affected - n_upserted));
1126+
result->nMatched += BSON_MAX (0, (affected - n_upserted));
11271127
} else {
11281128
result->nMatched += affected;
11291129
}

tests/test-load.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ main (int argc,
115115
}
116116

117117
if (argc > 2) {
118-
count = MAX(atoi(argv[2]), 1);
118+
count = BSON_MAX(atoi(argv[2]), 1);
119119
}
120120

121121
pool = mongoc_client_pool_new(uri);

0 commit comments

Comments
 (0)