summaryrefslogtreecommitdiffstats
path: root/crypto/init.c
diff options
context:
space:
mode:
authorPauli <pauli@openssl.org>2022-06-09 10:23:58 +1000
committerPauli <pauli@openssl.org>2022-06-14 11:26:31 +1000
commit979575c6ef10ab9b8d74d8c00852b2250eb78f29 (patch)
tree695326c8882dd56aa2995562fb1b1660865b19e0 /crypto/init.c
parentd2399d8cd29f56e6614f0b3db4e7e563a745902a (diff)
init: fix defined but unused warning/error
The #ifdefs weren't quite correct at times. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18503)
Diffstat (limited to 'crypto/init.c')
-rw-r--r--crypto/init.c58
1 files changed, 30 insertions, 28 deletions
diff --git a/crypto/init.c b/crypto/init.c
index 5c5985fc42..ed6a6bb084 100644
--- a/crypto/init.c
+++ b/crypto/init.c
@@ -650,28 +650,26 @@ int OPENSSL_atexit(void (*handler)(void))
#if !defined(OPENSSL_USE_NODELETE)\
&& !defined(OPENSSL_NO_PINSHARED)
{
+# if defined(DSO_WIN32) && !defined(_WIN32_WCE)
+ HMODULE handle = NULL;
+ BOOL ret;
union {
void *sym;
void (*func)(void);
} handlersym;
handlersym.func = handler;
-# if defined(DSO_WIN32) && !defined(_WIN32_WCE)
- {
- HMODULE handle = NULL;
- BOOL ret;
-
- /*
- * We don't use the DSO route for WIN32 because there is a better
- * way
- */
- ret = GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
- | GET_MODULE_HANDLE_EX_FLAG_PIN,
- handlersym.sym, &handle);
-
- if (!ret)
- return 0;
- }
+
+ /*
+ * We don't use the DSO route for WIN32 because there is a better
+ * way
+ */
+ ret = GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
+ | GET_MODULE_HANDLE_EX_FLAG_PIN,
+ handlersym.sym, &handle);
+
+ if (!ret)
+ return 0;
# elif !defined(DSO_NONE)
/*
* Deliberately leak a reference to the handler. This will force the
@@ -679,18 +677,22 @@ int OPENSSL_atexit(void (*handler)(void))
* atexit handler. If -znodelete has been used then this is
* unnecessary.
*/
- {
- DSO *dso = NULL;
-
- ERR_set_mark();
- dso = DSO_dsobyaddr(handlersym.sym, DSO_FLAG_NO_UNLOAD_ON_FREE);
- /* See same code above in ossl_init_base() for an explanation. */
- OSSL_TRACE1(INIT,
- "atexit: obtained DSO reference? %s\n",
- (dso == NULL ? "No!" : "Yes."));
- DSO_free(dso);
- ERR_pop_to_mark();
- }
+ DSO *dso = NULL;
+ union {
+ void *sym;
+ void (*func)(void);
+ } handlersym;
+
+ handlersym.func = handler;
+
+ ERR_set_mark();
+ dso = DSO_dsobyaddr(handlersym.sym, DSO_FLAG_NO_UNLOAD_ON_FREE);
+ /* See same code above in ossl_init_base() for an explanation. */
+ OSSL_TRACE1(INIT,
+ "atexit: obtained DSO reference? %s\n",
+ (dso == NULL ? "No!" : "Yes."));
+ DSO_free(dso);
+ ERR_pop_to_mark();
# endif
}
#endif