From: Pauli Date: Thu, 9 Jun 2022 00:23:58 +0000 (+1000) Subject: init: fix defined but unused warning/error X-Git-Tag: openssl-3.2.0-alpha1~2537 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=979575c6ef10ab9b8d74d8c00852b2250eb78f29;p=thirdparty%2Fopenssl.git init: fix defined but unused warning/error The #ifdefs weren't quite correct at times. Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/18503) --- diff --git a/crypto/init.c b/crypto/init.c index 5c5985fc426..ed6a6bb084e 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