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 9b22d77..0443fe1 100644
--- a/include/common/net_helper.h
+++ b/include/common/net_helper.h
@@ -172,7 +172,7 @@
{
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 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 @@
{
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 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);