]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
mem,str,datum: rename _steal_* to _take_*
authorDaiki Ueno <ueno@gnu.org>
Thu, 26 Mar 2026 03:39:56 +0000 (12:39 +0900)
committerDaiki Ueno <ueno@gnu.org>
Thu, 26 Mar 2026 11:05:59 +0000 (20:05 +0900)
While the name of _gnutls_steal_* functions was inspired by GLib's
g_steal_* family, it doesn't seem to be intuitive at first glance,
possibly because of the negative meaning of the word "steal". Let's
call it _gnutls_take_*, following the example of TAKE_* macros in
systemd and Option::take in Rust.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
lib/datum.h
lib/mem.h
lib/nettle/pk.c
lib/nettle/rnd.c
lib/pkcs11/p11_provider.c
lib/str.h
lib/x509/privkey_pkcs8.c

index e92f4016f22a209bcf7d6781525c18c6bf587a5d..783a6a2aee886559d70cbcdb10ff873b64030ca4 100644 (file)
@@ -58,7 +58,7 @@ inline static ATTRIBUTE_NONNULL() void _gnutls_free_key_datum(
 }
 
 inline static ATTRIBUTE_NONNULL() gnutls_datum_t
-       _gnutls_steal_datum(gnutls_datum_t *src)
+       _gnutls_take_datum(gnutls_datum_t *src)
 {
        gnutls_datum_t dst = *src;
 
index b0e661e9424fd59ac0b83ae804a991af9accbde1..4d9c7c6acfe15cefc009bd5b4616627fc163bbe0 100644 (file)
--- a/lib/mem.h
+++ b/lib/mem.h
@@ -82,7 +82,7 @@ static inline void _gnutls_memory_mark_defined(void *addr, size_t size)
 #endif
 }
 
-static inline ATTRIBUTE_NONNULL() void *_gnutls_steal_pointer(void **src)
+static inline ATTRIBUTE_NONNULL() void *_gnutls_take_pointer(void **src)
 {
        void *dst = *src;
        *src = NULL;
index 8a92cbc4aea47b3c1eb323dfe4ab68fc746c1525..e4f93c43e56dd8403d48a269d5574a91a8ad8e24 100644 (file)
@@ -779,8 +779,8 @@ static int ml_kem_encaps(gnutls_pk_algorithm_t algo, gnutls_datum_t *ciphertext,
                goto cleanup;
        }
 
-       *ciphertext = _gnutls_steal_datum(&tmp_ciphertext);
-       *shared_secret = _gnutls_steal_datum(&tmp_shared_secret);
+       *ciphertext = _gnutls_take_datum(&tmp_ciphertext);
+       *shared_secret = _gnutls_take_datum(&tmp_shared_secret);
 
        ret = 0;
 
@@ -839,7 +839,7 @@ static int ml_kem_decaps(gnutls_pk_algorithm_t algo,
                goto cleanup;
        }
 
-       *shared_secret = _gnutls_steal_datum(&tmp_shared_secret);
+       *shared_secret = _gnutls_take_datum(&tmp_shared_secret);
 
        ret = 0;
 
@@ -897,8 +897,8 @@ static int ml_kem_generate_keypair(gnutls_pk_algorithm_t algo,
                goto cleanup;
        }
 
-       *raw_priv = _gnutls_steal_datum(&tmp_raw_priv);
-       *raw_pub = _gnutls_steal_datum(&tmp_raw_pub);
+       *raw_priv = _gnutls_take_datum(&tmp_raw_priv);
+       *raw_pub = _gnutls_take_datum(&tmp_raw_pub);
 
        ret = 0;
 
@@ -1713,7 +1713,7 @@ static int ml_dsa_sign(gnutls_pk_algorithm_t algo, gnutls_datum_t *signature,
        if (ret < 0)
                goto cleanup;
 
-       *signature = _gnutls_steal_datum(&tmp_signature);
+       *signature = _gnutls_take_datum(&tmp_signature);
 
        ret = 0;
 
@@ -1812,8 +1812,8 @@ static int ml_dsa_generate_keypair(gnutls_pk_algorithm_t algo,
                goto cleanup;
        }
 
-       *raw_priv = _gnutls_steal_datum(&tmp_raw_priv);
-       *raw_pub = _gnutls_steal_datum(&tmp_raw_pub);
+       *raw_priv = _gnutls_take_datum(&tmp_raw_priv);
+       *raw_pub = _gnutls_take_datum(&tmp_raw_pub);
 
        ret = 0;
 
index 1607addb52e24afd7f80552168a34a10e3d93804..c539aa7ed4b81db2f4ce3026cb289f400219bb4e 100644 (file)
@@ -159,7 +159,7 @@ static int wrap_nettle_rnd_init(void **_ctx)
                goto cleanup;
        }
 
-       *_ctx = _gnutls_steal_pointer((void **)&ctx);
+       *_ctx = _gnutls_take_pointer((void **)&ctx);
 
 cleanup:
        zeroize_key(new_key, sizeof(new_key));
index c786d9fa8c1b8712aa908dea49f913bafd9d1f03..8f4d882858b3001539c2be8394d2b099b6f4a4c5 100644 (file)
@@ -85,7 +85,7 @@ int _p11_provider_init(const char *url, const uint8_t *pin_data,
 
        p11_provider.module = module;
        p11_provider.slot = slot;
-       p11_provider.pin = _gnutls_steal_datum(&pin);
+       p11_provider.pin = _gnutls_take_datum(&pin);
        p11_provider.initialized = true;
        return 0;
 
index 4e305c4200aebbbb4f9f577e99bfb98a22c39444..652d3d65b7e5f3178ea138002293f20a1659ed1a 100644 (file)
--- a/lib/str.h
+++ b/lib/str.h
@@ -99,7 +99,7 @@ inline static void _gnutls_buffer_reset(gnutls_buffer_st *buf)
 }
 
 inline static ATTRIBUTE_NONNULL() gnutls_buffer_st
-       _gnutls_steal_buffer(gnutls_buffer_st *src)
+       _gnutls_take_buffer(gnutls_buffer_st *src)
 {
        gnutls_buffer_st dst = *src;
 
index 5d18e6685e4974ea957f55238ef80b0815e61ccf..4a8e33c4860f3a343d521cb8cdbb18fcc0764aa5 100644 (file)
@@ -1689,7 +1689,7 @@ static int decode_ml_dsa_inner_private_key(const gnutls_datum_t *raw_key,
        if (pkey->params.raw_seed.data) {
                /* For checking any inconsistency */
                gnutls_datum_t raw_priv =
-                       _gnutls_steal_datum(&pkey->params.raw_priv);
+                       _gnutls_take_datum(&pkey->params.raw_priv);
 
                pkey->params.pkflags |= GNUTLS_PK_FLAG_EXPAND_KEYS_FROM_SEED;
                ret = _gnutls_pk_generate_keys(pkey->params.algo, 0,
@@ -1774,7 +1774,7 @@ static int _decode_pkcs8_ml_dsa_key(asn1_node pkcs8_asn,
        if (version == 1) {
                /* For checking any inconsistency */
                gnutls_datum_t raw_pub =
-                       _gnutls_steal_datum(&pkey->params.raw_pub);
+                       _gnutls_take_datum(&pkey->params.raw_pub);
 
                ret = _gnutls_x509_read_value(pkcs8_asn, "publicKey",
                                              &pkey->params.raw_pub);