From: Azat Khuzhin Date: Sat, 31 Oct 2020 19:48:37 +0000 (+0300) Subject: Fix BEV_IS_SSL() macro X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2484500ac285501fa32defa747f6c79e3190126f;p=libevent 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). --- 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