From: Tim Duesterhus Date: Fri, 21 Feb 2020 12:02:04 +0000 (+0100) Subject: CLEANUP: net_helper: Do not negate the result of unlikely X-Git-Tag: v2.2-dev3~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d48ba91d7f8e7d7c1908305ac124830dd414292;p=thirdparty%2Fhaproxy.git CLEANUP: net_helper: Do not negate the result of unlikely This patch turns the double negation of 'not unlikely' into 'likely' and then turns the negation of 'not smaller' into 'greater or equal' in an attempt to improve readability of the condition. [wt: this was not a bug but purposely written like this to improve code generation on older compilers but not needed anymore as described here: https://www.mail-archive.com/haproxy@formilux.org/msg36392.html ] --- diff --git a/include/common/net_helper.h b/include/common/net_helper.h index 9b22d773f6..0443fe1f90 100644 --- a/include/common/net_helper.h +++ b/include/common/net_helper.h @@ -172,7 +172,7 @@ static inline uint32_t readv_u32(const void *p1, size_t s1, const void *p2) { uint32_t u32; - if (!unlikely(s1 < sizeof(u32))) + if (likely(s1 >= sizeof(u32))) u32 = read_u32(p1); else readv_bytes(&u32, sizeof(u32), p1, s1, p2); @@ -186,7 +186,7 @@ static inline uint32_t readv_u32(const void *p1, size_t s1, const void *p2) */ static inline void writev_u32(void *p1, size_t s1, void *p2, const uint32_t u32) { - if (!unlikely(s1 < sizeof(u32))) + if (likely(s1 >= sizeof(u32))) write_u32(p1, u32); else writev_bytes(&u32, sizeof(u32), p1, s1, p2); @@ -201,7 +201,7 @@ static inline uint64_t readv_u64(const void *p1, size_t s1, const void *p2) { uint64_t u64; - if (!unlikely(s1 < sizeof(u64))) + if (likely(s1 >= sizeof(u64))) u64 = read_u64(p1); else readv_bytes(&u64, sizeof(u64), p1, s1, p2); @@ -215,7 +215,7 @@ static inline uint64_t readv_u64(const void *p1, size_t s1, const void *p2) */ static inline void writev_u64(void *p1, size_t s1, void *p2, const uint64_t u64) { - if (!unlikely(s1 < sizeof(u64))) + if (likely(s1 >= sizeof(u64))) write_u64(p1, u64); else writev_bytes(&u64, sizeof(u64), p1, s1, p2);