From: Thierry FOURNIER / OZON.IO Date: Sat, 12 Nov 2016 16:39:58 +0000 (+0100) Subject: BUG/MEDIUM: channel: bad unlikely macro X-Git-Tag: v1.7.0~94 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=500d11e65d276e304fa6d7f7100b2e2157cbe277;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: channel: bad unlikely macro The unlikely macro doesn't take in acount the condition, but only one variable. Must be backported in 1.6 [wt: with gcc 3.x, unlikely(x) is defined as __builtin_expect((x) != 0, 0) so the condition is wrong for negative numbers, which correspond to the case where bi_getblk_nc() has reached the end of the buffer and the channel is already closed. With gcc 4.x, the output is cast to unsigned long so the <=0 will not match negative values either. This is only used in Lua for now so that may explain why it hasn't hit yet] --- diff --git a/src/channel.c b/src/channel.c index 46921b856d..fe65895c7e 100644 --- a/src/channel.c +++ b/src/channel.c @@ -441,7 +441,7 @@ int bi_getline_nc(struct channel *chn, int l; retcode = bi_getblk_nc(chn, blk1, len1, blk2, len2); - if (unlikely(retcode) <= 0) + if (unlikely(retcode <= 0)) return retcode; for (l = 0; l < *len1 && (*blk1)[l] != '\n'; l++);