clang doesn't seem to like that COUNT_IF() returns an expression that
produces a result that is not used:
CC src/http_htx.o
src/http_htx.c:2076:16: warning: expression result unused [-Wunused-value]
if (unlikely(http_harden(HTTP_HRD_DEL_ALL_TLR))) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/haproxy/http.h:137:3: note: expanded from macro 'http_harden'
COUNT_IF(1, "hardening " #flag " condition met"); \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/haproxy/bug.h:485:31: note: expanded from macro 'COUNT_IF'
# define COUNT_IF(cond, ...) _COUNT_IF (cond, __FILE__, __LINE__, __VA_ARGS__)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/haproxy/bug.h:388:7: note: expanded from macro '_COUNT_IF'
}) : 0)
^
include/haproxy/compiler.h:351:40: note: expanded from macro 'unlikely'
#define unlikely(x) (__builtin_expect((x) != 0, 0))
^
src/http_htx.c:2076:16: warning: expression result unused [-Wunused-value]
if (unlikely(http_harden(HTTP_HRD_DEL_ALL_TLR))) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/haproxy/http.h:139:4: note: expanded from macro 'http_harden'
COUNT_IF(1, "hardening " #flag " enforced"); \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/haproxy/bug.h:485:31: note: expanded from macro 'COUNT_IF'
# define COUNT_IF(cond, ...) _COUNT_IF (cond, __FILE__, __LINE__, __VA_ARGS__)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/haproxy/bug.h:388:7: note: expanded from macro '_COUNT_IF'
}) : 0)
^
include/haproxy/compiler.h:351:40: note: expanded from macro 'unlikely'
#define unlikely(x) (__builtin_expect((x) != 0, 0))
^
2 warnings generated.
Just placing a (void) in front of COUNT_IF() is sufficient to silence it.
No backport is needed, as this is only in 3.5.
int _ret = 0; \
if (unlikely((http_hdng_chk.rules | ~http_hdng_chk.found) & _flag)) { \
http_hdng_chk.found |= _flag; \
- COUNT_IF(1, "hardening " #flag " condition met"); \
+ (void)COUNT_IF(1, "hardening " #flag " condition met"); \
if (http_hdng_chk.rules & _flag) { \
- COUNT_IF(1, "hardening " #flag " enforced"); \
+ (void)COUNT_IF(1, "hardening " #flag " enforced"); \
http_hdng_chk.fixed |= _flag; \
_ret = 1; \
} \