diff --git a/src/common/src/mlib/ckdint.h b/src/common/src/mlib/ckdint.h index 85e0b75641..608510c13f 100644 --- a/src/common/src/mlib/ckdint.h +++ b/src/common/src/mlib/ckdint.h @@ -5,9 +5,6 @@ * * This file implements the C23 checked-integer-arithmetic functions as macros. * - * The implementation is nearly perfect: The macros necessarily evaluate the - * operand expressions more than once, so callers should be aware of this caveat. - * * The function-like macros are defined: * * - `mlib_add(Dst, L, R)` / `mlib_add(Dst, A)` @@ -159,7 +156,7 @@ mlib_extern_c_begin (); * @param T A type specifier for a target integral type for the cast. * @param Operand The integral value to be converted. * - * If the cast would result in the operand value chaning, the program will be + * If the cast would result in the operand value changing, the program will be * terminated with a diagnostic. */ #define mlib_assert_narrow(T, Operand) \ diff --git a/src/common/src/mlib/ckdint.test.cpp b/src/common/src/mlib/ckdint.test.cpp index dbd94303d7..24434c218a 100644 --- a/src/common/src/mlib/ckdint.test.cpp +++ b/src/common/src/mlib/ckdint.test.cpp @@ -14,6 +14,9 @@ #endif // __has_builtin #endif +static_assert (mlib_upsize_integer (42ll).is_signed, "mlib_upsize_integer yielded the wrong answer"); +static_assert (!mlib_upsize_integer (42ull).is_signed, "mlib_upsize_integer yielded the wrong answer"); + template struct typelist { }; using integer_types = typelistuser, scram->pass); hashed_password = _mongoc_hex_md5 (tmp); + BSON_ASSERT (hashed_password); bson_zero_free (tmp, strlen (tmp)); } else if (scram->crypto.algorithm == MONGOC_CRYPTO_ALGORITHM_SHA_256) { /* Auth spec for SCRAM-SHA-256: "Passwords MUST be prepared with SASLprep, @@ -743,9 +744,7 @@ _mongoc_scram_step2 (mongoc_scram_t *scram, } /* Save the presecrets for caching */ - if (hashed_password) { - bson_strncpy (scram->hashed_password, hashed_password, sizeof (scram->hashed_password)); - } + bson_strncpy (scram->hashed_password, hashed_password, sizeof (scram->hashed_password)); scram->iterations = iterations; memcpy (scram->decoded_salt, decoded_salt, sizeof (scram->decoded_salt));