From 0ca71a98fff158d35f5a80b10917bd93f48581b0 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Mon, 5 Oct 2015 22:05:58 +0100 Subject: [PATCH] Clean up init stuff --- openssl-sys/src/lib.rs | 12 ++++++------ openssl-sys/src/openssl_shim.c | 5 ++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/openssl-sys/src/lib.rs b/openssl-sys/src/lib.rs index e5dfdc82..d40d299d 100644 --- a/openssl-sys/src/lib.rs +++ b/openssl-sys/src/lib.rs @@ -252,10 +252,10 @@ extern fn locking_function(mode: c_int, n: c_int, _file: *const c_char, } pub fn init() { - static mut INIT: Once = ONCE_INIT; + static INIT: Once = ONCE_INIT; - unsafe { - INIT.call_once(|| { + INIT.call_once(|| { + unsafe { SSL_library_init(); SSL_load_error_strings(); @@ -270,9 +270,9 @@ pub fn init() { GUARDS = mem::transmute(guards); CRYPTO_set_locking_callback(locking_function); - unsafe{ rust_openssl_set_id_callback(); } - }) - } + rust_openssl_set_id_callback(); + } + }) } pub unsafe fn SSL_CTX_set_options(ssl: *mut SSL_CTX, op: u64) -> u64 { diff --git a/openssl-sys/src/openssl_shim.c b/openssl-sys/src/openssl_shim.c index abfa3918..f0f55b27 100644 --- a/openssl-sys/src/openssl_shim.c +++ b/openssl-sys/src/openssl_shim.c @@ -10,12 +10,11 @@ unsigned long thread_id() { - unsigned long ret = (unsigned long)pthread_self(); - return ret; + return (unsigned long) pthread_self(); } void rust_openssl_set_id_callback() { - CRYPTO_set_id_callback((unsigned long (*)())thread_id); + CRYPTO_set_id_callback(thread_id); } #else