From 0cef78dc0b15b525080d5aaa8d27bb41e83d7dd4 Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Mon, 24 Mar 2025 08:28:02 -0400 Subject: [PATCH 1/2] remove deprecated `bson_copy_to_excluding` --- src/libbson/NEWS | 1 + src/libbson/doc/bson_copy_to_excluding.rst | 39 ------------------- src/libbson/doc/bson_t.rst | 1 - src/libbson/src/bson/bson.c | 16 -------- src/libbson/src/bson/bson.h | 20 +--------- src/libmongoc/tests/json-test.c | 4 +- .../tests/test-mongoc-connection-uri.c | 4 +- src/libmongoc/tests/unified/operation.c | 4 +- 8 files changed, 8 insertions(+), 81 deletions(-) delete mode 100644 src/libbson/doc/bson_copy_to_excluding.rst diff --git a/src/libbson/NEWS b/src/libbson/NEWS index 9819dc74335..c9567455cfa 100644 --- a/src/libbson/NEWS +++ b/src/libbson/NEWS @@ -16,6 +16,7 @@ libbson 2.0.0 (Unreleased) * `bson_t` and `bson_iter_t` are now aligned to the size of a pointer instead of `128`. * `bson_error_t`, `bson_value_t`, and `bson_visitor_t` are now aligned to the size of a pointer instead of `8`. * `BSON_ALIGNED_BEGIN` and `BSON_ALIGNED_END` now unconditionally apply their requested alignment. +* Remove deprecated `bson_copy_to_excluding`. Use `bson_copy_to_excluding_noinit` instead. libbson 1.30.2 diff --git a/src/libbson/doc/bson_copy_to_excluding.rst b/src/libbson/doc/bson_copy_to_excluding.rst deleted file mode 100644 index 13dc43a59b4..00000000000 --- a/src/libbson/doc/bson_copy_to_excluding.rst +++ /dev/null @@ -1,39 +0,0 @@ -:man_page: bson_copy_to_excluding - -bson_copy_to_excluding() -======================== - -.. warning:: - .. deprecated:: 1.1.0 - - Use :symbol:`bson_copy_to_excluding_noinit()` instead. - -Synopsis --------- - -.. code-block:: c - - void - bson_copy_to_excluding (const bson_t *src, - bson_t *dst, - const char *first_exclude, - ...); - -Parameters ----------- - -* ``src``: A :symbol:`bson_t`. -* ``dst``: A :symbol:`bson_t`. -* ``first_exclude``: The first field name to exclude. - -Description ------------ - -The :symbol:`bson_copy_to_excluding()` function shall copy all fields from -``src`` to ``dst`` except those specified by the variadic, NULL terminated list -of keys starting from ``first_exclude``. - -.. warning:: - - :symbol:`bson_init` is called on ``dst``. - diff --git a/src/libbson/doc/bson_t.rst b/src/libbson/doc/bson_t.rst index 66a1cfe3577..e77f7c0c303 100644 --- a/src/libbson/doc/bson_t.rst +++ b/src/libbson/doc/bson_t.rst @@ -204,7 +204,6 @@ BSON document contains duplicate keys. bson_concat bson_copy bson_copy_to - bson_copy_to_excluding bson_copy_to_excluding_noinit bson_copy_to_excluding_noinit_va bson_count_keys diff --git a/src/libbson/src/bson/bson.c b/src/libbson/src/bson/bson.c index 91f74aa80b4..6e0663bbd29 100644 --- a/src/libbson/src/bson/bson.c +++ b/src/libbson/src/bson/bson.c @@ -2184,22 +2184,6 @@ bson_copy_to_excluding_noinit_va (const bson_t *src, bson_t *dst, const char *fi } -void -bson_copy_to_excluding (const bson_t *src, bson_t *dst, const char *first_exclude, ...) -{ - va_list args; - - BSON_ASSERT (src); - BSON_ASSERT (dst); - BSON_ASSERT (first_exclude); - - bson_init (dst); - - va_start (args, first_exclude); - bson_copy_to_excluding_noinit_va (src, dst, first_exclude, args); - va_end (args); -} - void bson_copy_to_excluding_noinit (const bson_t *src, bson_t *dst, const char *first_exclude, ...) { diff --git a/src/libbson/src/bson/bson.h b/src/libbson/src/bson/bson.h index 33563f66672..0cc4eb6308c 100644 --- a/src/libbson/src/bson/bson.h +++ b/src/libbson/src/bson/bson.h @@ -288,31 +288,13 @@ bson_copy (const bson_t *bson); BSON_EXPORT (void) bson_copy_to (const bson_t *src, bson_t *dst); - -/** - * bson_copy_to_excluding: - * @src: A bson_t. - * @dst: A bson_t to initialize and copy into. - * @first_exclude: First field name to exclude. - * - * Copies @src into @dst excluding any field that is provided. - * This is handy for situations when you need to remove one or - * more fields in a bson_t. Note that bson_init() will be called - * on dst. - */ -BSON_DEPRECATED_FOR (bson_copy_to_excluding_noinit) -BSON_EXPORT (void) - bson_copy_to_excluding (const bson_t *src, bson_t *dst, const char *first_exclude, ...) BSON_GNUC_NULL_TERMINATED; - /** * bson_copy_to_excluding_noinit: * @src: A bson_t. * @dst: A bson_t to initialize and copy into. * @first_exclude: First field name to exclude. * - * The same as bson_copy_to_excluding, but does not call bson_init() - * on the dst. This version should be preferred in new code, but the - * old function is left for backwards compatibility. + * Does not call bson_init() on the dst. */ BSON_EXPORT (void) bson_copy_to_excluding_noinit (const bson_t *src, bson_t *dst, const char *first_exclude, ...) diff --git a/src/libmongoc/tests/json-test.c b/src/libmongoc/tests/json-test.c index 11e36f037de..bcb2b35a6cd 100644 --- a/src/libmongoc/tests/json-test.c +++ b/src/libmongoc/tests/json-test.c @@ -1374,12 +1374,12 @@ set_auto_encryption_opts (mongoc_client_t *client, bson_t *test) auto_encryption_opts = mongoc_auto_encryption_opts_new (); if (bson_iter_init_find (&iter, &opts, "kmsProviders")) { - bson_t kms_providers; + bson_t kms_providers = BSON_INITIALIZER; bson_t tls_opts = BSON_INITIALIZER; bson_t tmp; bson_iter_bson (&iter, &tmp); - bson_copy_to_excluding ( + bson_copy_to_excluding_noinit ( &tmp, &kms_providers, "aws", "awsTemporary", "awsTemporaryNoSessionToken", "azure", "gcp", "kmip", NULL); /* AWS credentials are set from environment variables. */ diff --git a/src/libmongoc/tests/test-mongoc-connection-uri.c b/src/libmongoc/tests/test-mongoc-connection-uri.c index 979b8dd63fb..f42fd0fae55 100644 --- a/src/libmongoc/tests/test-mongoc-connection-uri.c +++ b/src/libmongoc/tests/test-mongoc-connection-uri.c @@ -306,8 +306,8 @@ run_uri_test (const char *uri_string, // CDRIVER-4128: CANONICALIZE_HOST_NAME is UTF-8 even when "false" or "true". { - bson_t updated; - bson_copy_to_excluding (&expected_props, &updated, "CANONICALIZE_HOST_NAME", NULL); + bson_t updated = BSON_INITIALIZER; + bson_copy_to_excluding_noinit (&expected_props, &updated, "CANONICALIZE_HOST_NAME", NULL); if (bson_iter_init_find_case (&iter, &expected_props, "CANONICALIZE_HOST_NAME")) { if (BSON_ITER_HOLDS_BOOL (&iter)) { BSON_APPEND_UTF8 ( diff --git a/src/libmongoc/tests/unified/operation.c b/src/libmongoc/tests/unified/operation.c index a22a0040e6d..5d4b94be100 100644 --- a/src/libmongoc/tests/unified/operation.c +++ b/src/libmongoc/tests/unified/operation.c @@ -4325,7 +4325,7 @@ operation_run (test_t *test, bson_t *op_bson, bson_error_t *error) /* Check for a "session" argument in all operations, it can be * an argument for any operation. */ if (op->arguments && bson_has_field (op->arguments, "session")) { - bson_t copied; + bson_t copied = BSON_INITIALIZER; mongoc_client_session_t *session = NULL; op->session_id = bson_strdup (bson_lookup_utf8 (op->arguments, "session")); @@ -4335,7 +4335,7 @@ operation_run (test_t *test, bson_t *op_bson, bson_error_t *error) goto done; } - bson_copy_to_excluding (op->arguments, &copied, "session", NULL); + bson_copy_to_excluding_noinit (op->arguments, &copied, "session", NULL); bson_destroy (op->arguments); op->arguments = bson_copy (&copied); bson_destroy (&copied); From d90658d56ca47ebf41fa0957fe0c5f32fe1d3bae Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Mon, 24 Mar 2025 08:31:33 -0400 Subject: [PATCH 2/2] remove doc references --- src/libbson/doc/bson_copy_to_excluding_noinit.rst | 5 ++--- src/libbson/doc/bson_copy_to_excluding_noinit_va.rst | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/libbson/doc/bson_copy_to_excluding_noinit.rst b/src/libbson/doc/bson_copy_to_excluding_noinit.rst index ea2c285e1cd..80167dc7d86 100644 --- a/src/libbson/doc/bson_copy_to_excluding_noinit.rst +++ b/src/libbson/doc/bson_copy_to_excluding_noinit.rst @@ -27,9 +27,8 @@ Description The :symbol:`bson_copy_to_excluding_noinit()` function shall copy all fields from ``src`` to ``dst`` except those specified by the variadic, NULL terminated list of keys starting from ``first_exclude``. -Works the same way as :symbol:`bson_copy_to_excluding`, except does **not** call -:symbol:`bson_init` on ``dst``. -This function should be preferred in new code over :symbol:`bson_copy_to_excluding`. + +Does **not** call :symbol:`bson_init` on ``dst``. .. warning:: diff --git a/src/libbson/doc/bson_copy_to_excluding_noinit_va.rst b/src/libbson/doc/bson_copy_to_excluding_noinit_va.rst index d48bacaa2f2..13b06fb0c10 100644 --- a/src/libbson/doc/bson_copy_to_excluding_noinit_va.rst +++ b/src/libbson/doc/bson_copy_to_excluding_noinit_va.rst @@ -27,7 +27,7 @@ Description The :symbol:`bson_copy_to_excluding_noinit_va()` function shall copy all fields from ``src`` to ``dst`` except those specified by ``first_exclude`` and ``args``. -This method works the same way as :symbol:`bson_copy_to_excluding_noinit`, except it takes a va_list. This method does not call :symbol:`bson_init` on ``dst``. +Does **not** call :symbol:`bson_init` on ``dst``. .. seealso::