]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
init: fix defined but unused warning/error
authorPauli <pauli@openssl.org>
Thu, 9 Jun 2022 00:23:58 +0000 (10:23 +1000)
committerPauli <pauli@openssl.org>
Tue, 14 Jun 2022 01:26:31 +0000 (11:26 +1000)
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)

crypto/init.c

index 5c5985fc426c2ae05fb48753920c45d8a085f8a1..ed6a6bb084e11f877bf81a640783d8740eaee9ba 100644 (file)
@@ -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