From 340827c819f905a772dce1c41da4d9f07bd16b02 Mon Sep 17 00:00:00 2001 From: Norbert Pocs Date: Thu, 3 Jul 2025 16:16:34 +0200 Subject: [PATCH] crypto/init.c optimize ossl_(un)likely Signed-off-by: Norbert Pocs Reviewed-by: Neil Horman Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/27961) --- crypto/init.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crypto/init.c b/crypto/init.c index 2da4914707b..e2fe479db5f 100644 --- a/crypto/init.c +++ b/crypto/init.c @@ -502,7 +502,7 @@ int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings) int aloaddone = 0; /* Applications depend on 0 being returned when cleanup was already done */ - if (stopped) { + if (ossl_unlikely(stopped)) { if (!(opts & OPENSSL_INIT_BASE_ONLY)) ERR_raise(ERR_LIB_CRYPTO, ERR_R_INIT_FAIL); return 0; @@ -521,7 +521,7 @@ int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings) * unnecessarily - but all the critical code is contained in RUN_ONCE * functions anyway so we are safe. */ - if (CRYPTO_atomic_load(&optsdone, &tmp, NULL)) { + if (ossl_likely(CRYPTO_atomic_load(&optsdone, &tmp, NULL))) { if ((tmp & opts) == opts) return 1; aloaddone = 1; @@ -541,7 +541,7 @@ int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings) * If we remain the only caller of err_shelve_state() the recursion should * perhaps be removed, but if in doubt, it can be left in place. */ - if (!RUN_ONCE(&base, ossl_init_base)) + if (ossl_unlikely(!RUN_ONCE(&base, ossl_init_base))) return 0; if (opts & OPENSSL_INIT_BASE_ONLY) -- 2.47.2