BUILD: debug: fix build issues in COUNT_IF() with -Wunused-value
authorWilly Tarreau <w@1wt.eu>
Mon, 9 Dec 2024 16:49:08 +0000 (17:49 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 10 Dec 2024 10:09:53 +0000 (11:09 +0100)
commit3f396a99d861529b32aeb2d008a203aad12dfd63
treebaeae71dbe067c2641523d3dbdc2ddf6e91ef3b2
parente723d010c6ef69b807678772e18deeaad45a309d
BUILD: debug: fix build issues in COUNT_IF() with -Wunused-value

Commit 7f64bb79fd ("BUG/MINOR: debug: COUNT_IF() should return true/false")
allowed the COUNT_IF() macro to return the evaluated value. This is handy
to place it in "if ()" conditions and count them at the same time. When
glitches are disabled, the condition is just returned as-is, but most call
places do not use the result, making some compilers complain. In addition,
while reviewing this, it was noticed that when DEBUG_STRICT=0, the macro
would still be replaced by a "do { } while (0)" statement, which not only
does not evaluate the expression, but also cannot return anything. Ditto
for COUNT_IF_HOT().

Let's make sure both are always properly evaluated now.

(cherry picked from commit d6dc8120c0b13f896bf2628e611517701aff7a38)
Signed-off-by: Willy Tarreau <w@1wt.eu>
include/haproxy/bug.h