dinhvh / libetpan

Mail Framework for C Language
www.etpan.org
Other
612 stars 284 forks source link

FIX: operator precedence related to poll #447

Open mtasaka opened 5 months ago

mtasaka commented 5 months ago

Fixes the following warnings:

connect.c:162:19: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
mailstream_ssl.c:368:32: warning: self-comparison always evaluates to false [-Wtautological-compare]
mailstream_ssl.c:368:32: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
mtasaka commented 5 months ago

Since C operator precedence says != is higher than & , the code

if (pfd.revents & POLLOUT != POLLOUT)

is interpreted as

if (pfd.revents & (POLLOUT != POLLOUT) )

... which is always false because POLLOUT != POLLOUT is always evaluated as 0. I don't think this is intended.

mones commented 17 hours ago

Hi @dinhvh !

I've also added this to Debian patches [1], would be nice to have it merged before next release. Thanks go to @mtasaka for the patch :smile_cat:

best regards,

[1] https://salsa.debian.org/claws-mail-team/libetpan/-/blob/master/debian/patches/16_fix_precedence_related_to_poll.patch