Fixed compile warnings.
authorArmin Novak <armin.novak@thincast.com>
Tue, 14 Nov 2017 12:52:52 +0000 (13:52 +0100)
committerArmin Novak <armin.novak@thincast.com>
Wed, 15 Nov 2017 14:54:38 +0000 (15:54 +0100)
winpr/libwinpr/utils/ssl.c

index 78cbab1..322bb49 100644 (file)
@@ -93,7 +93,8 @@ static struct CRYPTO_dynlock_value* _winpr_openssl_dynlock_create(const char* fi
        return dynlock;
 }
 
-static void _winpr_openssl_dynlock_lock(int mode, struct CRYPTO_dynlock_value* dynlock, const char* file, int line)
+static void _winpr_openssl_dynlock_lock(int mode, struct CRYPTO_dynlock_value* dynlock,
+                                        const char* file, int line)
 {
        if (mode & CRYPTO_LOCK)
        {
@@ -105,7 +106,8 @@ static void _winpr_openssl_dynlock_lock(int mode, struct CRYPTO_dynlock_value* d
        }
 }
 
-static void _winpr_openssl_dynlock_destroy(struct CRYPTO_dynlock_value* dynlock, const char* file, int line)
+static void _winpr_openssl_dynlock_destroy(struct CRYPTO_dynlock_value* dynlock, const char* file,
+        int line)
 {
        CloseHandle(dynlock->mutex);
        free(dynlock);
@@ -159,8 +161,8 @@ static BOOL _winpr_openssl_initialize_locking(void)
        /* OpenSSL dynamic locking */
 
        if (CRYPTO_get_dynlock_create_callback() ||
-                       CRYPTO_get_dynlock_lock_callback()   ||
-                       CRYPTO_get_dynlock_destroy_callback())
+           CRYPTO_get_dynlock_lock_callback()   ||
+           CRYPTO_get_dynlock_destroy_callback())
        {
                WLog_WARN(TAG, "dynamic locking callbacks are already set");
        }
@@ -246,6 +248,7 @@ static BOOL CALLBACK _winpr_openssl_initialize(PINIT_ONCE once, PVOID param, PVO
        }
 
 #ifdef WINPR_OPENSSL_LOCKING_REQUIRED
+
        if (flags & WINPR_SSL_INIT_ENABLE_LOCKING)
        {
                if (!_winpr_openssl_initialize_locking())
@@ -253,6 +256,7 @@ static BOOL CALLBACK _winpr_openssl_initialize(PINIT_ONCE once, PVOID param, PVO
                        return FALSE;
                }
        }
+
 #endif
        /* SSL_load_error_strings() is void */
 #if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
@@ -262,12 +266,14 @@ static BOOL CALLBACK _winpr_openssl_initialize(PINIT_ONCE once, PVOID param, PVO
        OpenSSL_add_all_digests();
        OpenSSL_add_all_ciphers();
 #else
+
        if (OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS |
-                               OPENSSL_INIT_LOAD_CRYPTO_STRINGS |
-                               OPENSSL_INIT_ADD_ALL_CIPHERS |
-                               OPENSSL_INIT_ADD_ALL_DIGESTS |
-                               OPENSSL_INIT_ENGINE_ALL_BUILTIN, NULL) != 1)
+                            OPENSSL_INIT_LOAD_CRYPTO_STRINGS |
+                            OPENSSL_INIT_ADD_ALL_CIPHERS |
+                            OPENSSL_INIT_ADD_ALL_DIGESTS |
+                            OPENSSL_INIT_ENGINE_ALL_BUILTIN, NULL) != 1)
                return FALSE;
+
 #endif
        g_winpr_openssl_initialized_by_winpr = TRUE;
        return TRUE;
@@ -301,10 +307,13 @@ BOOL winpr_CleanupSSL(DWORD flags)
                ERR_free_strings();
                EVP_cleanup();
 #endif
+#ifdef WINPR_OPENSSL_LOCKING_REQUIRED
                flags |= WINPR_SSL_CLEANUP_THREAD;
+#endif
        }
 
 #ifdef WINPR_OPENSSL_LOCKING_REQUIRED
+
        if (flags & WINPR_SSL_CLEANUP_THREAD)
        {
 #if (OPENSSL_VERSION_NUMBER < 0x10000000L) || defined(LIBRESSL_VERSION_NUMBER)
@@ -313,6 +322,7 @@ BOOL winpr_CleanupSSL(DWORD flags)
                ERR_remove_thread_state(NULL);
 #endif
        }
+
 #endif
        return TRUE;
 }