[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Tweaks into functions and variables in crypto_openssl_mgt.[ch]



commit b3aa7be26c121d1a1fd6df7ab240745a08b6b406
Author: Fernando Fernandez Mancera <ffernandezmancera@xxxxxxxxx>
Date:   Fri Jan 19 18:07:49 2018 +0100

    Tweaks into functions and variables in crypto_openssl_mgt.[ch]
    
    Renamed free_openssl() to crypto_openssl_free_all(). Also we made variables and
    functions static again.
    
    Follows #24658.
    
    Signed-off-by: Fernando Fernandez Mancera <ffernandezmancera@xxxxxxxxx>
---
 src/common/crypto.c             |  2 +-
 src/common/crypto_openssl_mgt.c | 19 +++++++++++++------
 src/common/crypto_openssl_mgt.h | 10 +---------
 3 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/src/common/crypto.c b/src/common/crypto.c
index 12f4270cc..96a1f7c00 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -3348,7 +3348,7 @@ crypto_global_cleanup(void)
   }
 #endif /* !defined(NEW_THREAD_API) */
 
-  free_openssl();
+  crypto_openssl_free_all();
   return 0;
 }
 
diff --git a/src/common/crypto_openssl_mgt.c b/src/common/crypto_openssl_mgt.c
index ff9052b56..c19da5b9f 100644
--- a/src/common/crypto_openssl_mgt.c
+++ b/src/common/crypto_openssl_mgt.c
@@ -14,15 +14,22 @@
 
 #ifndef NEW_THREAD_API
 /** A number of preallocated mutexes for use by OpenSSL. */
-tor_mutex_t **openssl_mutexes_ = NULL;
+static tor_mutex_t **openssl_mutexes_ = NULL;
 /** How many mutexes have we allocated for use by OpenSSL? */
-int n_openssl_mutexes_ = 0;
+static int n_openssl_mutexes_ = 0;
 #endif /* !defined(NEW_THREAD_API) */
 
+/** Declare STATIC functions */
+STATIC char * parse_openssl_version_str(const char *raw_version);
+#ifndef NEW_THREAD_API
+STATIC void openssl_locking_cb_(int mode, int n, const char *file, int line);
+STATIC void tor_set_openssl_thread_id(CRYPTO_THREADID *threadid);
+#endif
+
 /* Returns a trimmed and human-readable version of an openssl version string
 * <b>raw_version</b>. They are usually in the form of 'OpenSSL 1.0.0b 10
 * May 2012' and this will parse them into a form similar to '1.0.0b' */
-char *
+STATIC char *
 parse_openssl_version_str(const char *raw_version)
 {
   const char *end_of_version = NULL;
@@ -72,7 +79,7 @@ crypto_openssl_get_header_version_str(void)
 
 #ifndef NEW_THREAD_API
 /** Helper: OpenSSL uses this callback to manipulate mutexes. */
-void
+STATIC void
 openssl_locking_cb_(int mode, int n, const char *file, int line)
 {
   (void)file;
@@ -88,7 +95,7 @@ openssl_locking_cb_(int mode, int n, const char *file, int line)
     tor_mutex_release(openssl_mutexes_[n]);
 }
 
-void
+STATIC void
 tor_set_openssl_thread_id(CRYPTO_THREADID *threadid)
 {
   CRYPTO_THREADID_set_numeric(threadid, tor_get_thread_id());
@@ -115,7 +122,7 @@ setup_openssl_threading(void)
 
 /** free OpenSSL variables */
 void
-free_openssl(void)
+crypto_openssl_free_all(void)
 {
   tor_free(crypto_openssl_version_str);
   tor_free(crypto_openssl_header_version_str);
diff --git a/src/common/crypto_openssl_mgt.h b/src/common/crypto_openssl_mgt.h
index 0c6bccad4..9b887abd5 100644
--- a/src/common/crypto_openssl_mgt.h
+++ b/src/common/crypto_openssl_mgt.h
@@ -86,23 +86,15 @@ ENABLE_GCC_WARNING(redundant-decls)
 #define NEW_THREAD_API
 #endif /* OPENSSL_VERSION_NUMBER >= OPENSSL_VER(1,1,0,0,5) && ... */
 
-tor_mutex_t **openssl_mutexes_;
-int n_openssl_mutexes_;
-
 /* global openssl state */
 const char * crypto_openssl_get_version_str(void);
 const char * crypto_openssl_get_header_version_str(void);
 
-/* generics OpenSSL functions */
-char * parse_openssl_version_str(const char *raw_version);
-void openssl_locking_cb_(int mode, int n, const char *file, int line);
-void tor_set_openssl_thread_id(CRYPTO_THREADID *threadid);
-
 /* OpenSSL threading setup function */
 int setup_openssl_threading(void);
 
 /* Tor OpenSSL utility functions */
-void free_openssl(void);
+void crypto_openssl_free_all(void);
 
 #endif /* !defined(TOR_CRYPTO_OPENSSL_H) */
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits