From 39ca97ef4d6364f5a63baafca30ac337cb0fdc0d Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Sat, 31 Oct 2020 22:27:18 +0300 Subject: [PATCH 1/3] Remove reduntant BEV_IS_MBEDTLS --- bufferevent-internal.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/bufferevent-internal.h b/bufferevent-internal.h index 0404d4ff..2aa4e1c9 100644 --- a/bufferevent-internal.h +++ b/bufferevent-internal.h @@ -313,13 +313,6 @@ extern const struct bufferevent_ops bufferevent_ops_ssl; #define BEV_IS_SSL(bevp) 0 #endif -#if defined(EVENT__HAVE_MBEDTLS) -extern const struct bufferevent_ops bufferevent_ops_mbedtls; -#define BEV_IS_MBEDTLS(bevp) ((bevp)->be_ops == &bufferevent_ops_mbedtls) -#else -#define BEV_IS_MBEDTLS(bevp) 0 -#endif - #ifdef _WIN32 extern const struct bufferevent_ops bufferevent_ops_async; #define BEV_IS_ASYNC(bevp) ((bevp)->be_ops == &bufferevent_ops_async) From db6e22c7db5f69bd34e1f2a247c7db7700f16cca Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Sat, 31 Oct 2020 22:41:16 +0300 Subject: [PATCH 2/3] Fix preprocessor condition for BEV_IS_SSL() --- bufferevent-internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bufferevent-internal.h b/bufferevent-internal.h index 2aa4e1c9..da567594 100644 --- a/bufferevent-internal.h +++ b/bufferevent-internal.h @@ -306,7 +306,7 @@ extern const struct bufferevent_ops bufferevent_ops_pair; #define BEV_IS_FILTER(bevp) ((bevp)->be_ops == &bufferevent_ops_filter) #define BEV_IS_PAIR(bevp) ((bevp)->be_ops == &bufferevent_ops_pair) -#if defined(EVENT__HAVE_OPENSSL) | defined(EVENT__HAVE_MBEDTLS) +#if defined(EVENT__HAVE_OPENSSL) || defined(EVENT__HAVE_MBEDTLS) extern const struct bufferevent_ops bufferevent_ops_ssl; #define BEV_IS_SSL(bevp) ((bevp)->be_ops == &bufferevent_ops_ssl) #else From 2484500ac285501fa32defa747f6c79e3190126f Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Sat, 31 Oct 2020 22:48:37 +0300 Subject: [PATCH 3/3] Fix BEV_IS_SSL() macro We cannot use the same trick with external declaration, since there are copy of bufferevent_ops_ssl in each library: - openssl - mbedlts However we can just compare the name of the bufferevent type for now. (It is totally fine to use memcmp() here since it will be optimized by the compiler). --- bufferevent-internal.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bufferevent-internal.h b/bufferevent-internal.h index da567594..3ad0acf0 100644 --- a/bufferevent-internal.h +++ b/bufferevent-internal.h @@ -307,8 +307,15 @@ extern const struct bufferevent_ops bufferevent_ops_pair; #define BEV_IS_PAIR(bevp) ((bevp)->be_ops == &bufferevent_ops_pair) #if defined(EVENT__HAVE_OPENSSL) || defined(EVENT__HAVE_MBEDTLS) -extern const struct bufferevent_ops bufferevent_ops_ssl; -#define BEV_IS_SSL(bevp) ((bevp)->be_ops == &bufferevent_ops_ssl) +/* We cannot use the same trick with external declaration, + * since there are copy of bufferevent_ops_ssl in each library: + * - openssl + * - mbedlts + * + * However we can just compare the name of the bufferevent type for now. + * (It is totally fine to use memcmp() here since it will be optimized by the compiler). + */ +#define BEV_IS_SSL(bevp) (!memcmp((bevp)->be_ops->type, "ssl", 3)) #else #define BEV_IS_SSL(bevp) 0 #endif