From 4aca7847be8bd9e146de876c2b73fa91ef0aa646 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Wed, 25 Sep 2013 16:05:09 +0000 Subject: [PATCH] Fix open ssl forwarding macros. This patch fixes them in many ways: - use Q_UNLIKELY to mark an error case - reduce QtNetwork library size by 40315 bytes - fix DEFINEFUNC9 which had wrong logic, happily it was not used anywhere Change-Id: Ic46a569f85aa22a00ecd88158e60c52f4665ec4c Reviewed-by: Richard J. Moore --- .../ssl/qsslsocket_openssl_symbols.cpp | 7 ++++ .../ssl/qsslsocket_openssl_symbols_p.h | 33 ++++++++++--------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp index a010075436..7c3cfb2012 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols.cpp +++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp @@ -114,6 +114,13 @@ QT_BEGIN_NAMESPACE possibly with a different version of OpenSSL. */ +namespace { +void qsslSocketUnresolvedSymbolWarning(const char *functionName) +{ + qWarning("QSslSocket: cannot call unresolved function %s", functionName); +} +} + #ifdef SSLEAY_MACROS DEFINEFUNC3(void *, ASN1_dup, i2d_of_void *a, a, d2i_of_void *b, b, char *c, c, return 0, return) #endif diff --git a/src/network/ssl/qsslsocket_openssl_symbols_p.h b/src/network/ssl/qsslsocket_openssl_symbols_p.h index 1fd98cc7fb..7e1a1c983c 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols_p.h +++ b/src/network/ssl/qsslsocket_openssl_symbols_p.h @@ -69,6 +69,7 @@ // #include "qsslsocket_openssl_p.h" +#include QT_BEGIN_NAMESPACE @@ -82,8 +83,8 @@ QT_BEGIN_NAMESPACE typedef ret (*_q_PTR_##func)(arg); \ static _q_PTR_##func _q_##func = 0; \ ret q_##func(arg) { \ - if (!_q_##func) { \ - qWarning("QSslSocket: cannot call unresolved function "#func); \ + if (Q_UNLIKELY(!_q_##func)) { \ + qsslSocketUnresolvedSymbolWarning(#func); \ err; \ } \ funcret _q_##func(a); \ @@ -94,8 +95,8 @@ QT_BEGIN_NAMESPACE typedef ret (*_q_PTR_##func)(arg1, arg2); \ static _q_PTR_##func _q_##func = 0; \ ret q_##func(arg1, arg2) { \ - if (!_q_##func) { \ - qWarning("QSslSocket: cannot call unresolved function "#func);\ + if (Q_UNLIKELY(!_q_##func)) { \ + qsslSocketUnresolvedSymbolWarning(#func);\ err; \ } \ funcret _q_##func(a, b); \ @@ -106,8 +107,8 @@ QT_BEGIN_NAMESPACE typedef ret (*_q_PTR_##func)(arg1, arg2, arg3); \ static _q_PTR_##func _q_##func = 0; \ ret q_##func(arg1, arg2, arg3) { \ - if (!_q_##func) { \ - qWarning("QSslSocket: cannot call unresolved function "#func); \ + if (Q_UNLIKELY(!_q_##func)) { \ + qsslSocketUnresolvedSymbolWarning(#func); \ err; \ } \ funcret _q_##func(a, b, c); \ @@ -118,8 +119,8 @@ QT_BEGIN_NAMESPACE typedef ret (*_q_PTR_##func)(arg1, arg2, arg3, arg4); \ static _q_PTR_##func _q_##func = 0; \ ret q_##func(arg1, arg2, arg3, arg4) { \ - if (!_q_##func) { \ - qWarning("QSslSocket: cannot call unresolved function "#func); \ + if (Q_UNLIKELY(!_q_##func)) { \ + qsslSocketUnresolvedSymbolWarning(#func); \ err; \ } \ funcret _q_##func(a, b, c, d); \ @@ -130,8 +131,8 @@ QT_BEGIN_NAMESPACE typedef ret (*_q_PTR_##func)(arg1, arg2, arg3, arg4, arg5); \ static _q_PTR_##func _q_##func = 0; \ ret q_##func(arg1, arg2, arg3, arg4, arg5) { \ - if (!_q_##func) { \ - qWarning("QSslSocket: cannot call unresolved function "#func); \ + if (Q_UNLIKELY(!_q_##func)) { \ + qsslSocketUnresolvedSymbolWarning(#func); \ err; \ } \ funcret _q_##func(a, b, c, d, e); \ @@ -142,8 +143,8 @@ QT_BEGIN_NAMESPACE typedef ret (*_q_PTR_##func)(arg1, arg2, arg3, arg4, arg5, arg6); \ static _q_PTR_##func _q_##func = 0; \ ret q_##func(arg1, arg2, arg3, arg4, arg5, arg6) { \ - if (!_q_##func) { \ - qWarning("QSslSocket: cannot call unresolved function "#func); \ + if (Q_UNLIKELY(!_q_##func)) { \ + qsslSocketUnresolvedSymbolWarning(#func); \ err; \ } \ funcret _q_##func(a, b, c, d, e, f); \ @@ -154,8 +155,8 @@ QT_BEGIN_NAMESPACE typedef ret (*_q_PTR_##func)(arg1, arg2, arg3, arg4, arg5, arg6, arg7); \ static _q_PTR_##func _q_##func = 0; \ ret q_##func(arg1, arg2, arg3, arg4, arg5, arg6, arg7) { \ - if (!_q_##func) { \ - qWarning("QSslSocket: cannot call unresolved function "#func); \ + if (Q_UNLIKELY(!_q_##func)) { \ + qsslSocketUnresolvedSymbolWarning(#func); \ err; \ } \ funcret _q_##func(a, b, c, d, e, f, g); \ @@ -166,8 +167,8 @@ QT_BEGIN_NAMESPACE typedef ret (*_q_PTR_##func)(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); \ static _q_PTR_##func _q_##func = 0; \ ret q_##func(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) { \ - if (_q_##func) { \ - qWarning("QSslSocket: cannot call unresolved function "#func); \ + if (Q_UNLIKELY(!_q_##func)) { \ + qsslSocketUnresolvedSymbolWarning(#func); \ err; \ } \ funcret _q_##func(a, b, c, d, e, f, g, h, i); \