From 6ad97e5b5ba51ac87ddc1cfd7fc798f5343893f1 Mon Sep 17 00:00:00 2001 From: John Beard Date: Thu, 18 Apr 2019 16:15:19 +0100 Subject: [PATCH] Kicad Curl: Ignore unused functions for OpenSSL >= 1.1.0 In OpenSSL 1.1.0 and newer, the locking callback macros do nothing. This causes unused warnings for the static function lock_callback. Ignore this function on newer OpenSSL builds, but keep the infrastructure for now. When OpenSSL's min version is 1.1 or greater, all the locking infrastructure can be removed. --- common/kicad_curl/kicad_curl.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/common/kicad_curl/kicad_curl.cpp b/common/kicad_curl/kicad_curl.cpp index 8d75df886c..ea32691b2a 100644 --- a/common/kicad_curl/kicad_curl.cpp +++ b/common/kicad_curl/kicad_curl.cpp @@ -46,6 +46,23 @@ static MUTEX s_lock; // for s_initialized static MUTEX* s_crypto_locks; +/* + * From OpenSSL v1.1.0, the CRYPTO_set_locking_callback macro is a no-op. + * + * Once this is the minimum OpenSSL version, the entire s_crypto_locks + * system and related functions can be removed. + * + * In the meantime, use this macro to determine when to use the callback. + * Keep them compiling until then to prevent accidentally breaking older + * version builds. + * + * https://github.com/openssl/openssl/issues/1260 + */ +#if OPENSSL_VERSION_NUMBER < 0x10100000L +#define USE_OPENSSL_LOCKING_CALLBACKS +#endif + + static void lock_callback( int mode, int type, const char* file, int line ) { (void)file; @@ -98,6 +115,11 @@ static void init_locks() */ CRYPTO_set_locking_callback( &lock_callback ); + +#ifndef USE_OPENSSL_LOCKING_CALLBACKS + // Ignore the unused function (the above macro didn't use it) + (void) &lock_callback; +#endif }