bufferevent_pair: fix infer warnings due to upcast() return NULL

The only user that is care about this is bufferevent_pair_get_partner(),
so let's move the check there.
This commit is contained in:
Azat Khuzhin 2024-02-18 18:00:57 +01:00
parent 92ea8476b4
commit 05ed7c8c7e

View File

@ -56,8 +56,6 @@ static inline struct bufferevent_pair *
upcast(struct bufferevent *bev)
{
struct bufferevent_pair *bev_p;
if (!BEV_IS_PAIR(bev))
return NULL;
bev_p = EVUTIL_UPCAST(bev, struct bufferevent_pair, bev.bev);
EVUTIL_ASSERT(BEV_IS_PAIR(&bev_p->bev.bev));
return bev_p;
@ -341,10 +339,9 @@ bufferevent_pair_get_partner(struct bufferevent *bev)
{
struct bufferevent_pair *bev_p;
struct bufferevent *partner = NULL;
bev_p = upcast(bev);
if (! bev_p)
if (!BEV_IS_PAIR(bev))
return NULL;
bev_p = upcast(bev);
incref_and_lock(bev);
if (bev_p->partner)
partner = downcast(bev_p->partner);