From 023649a0c5dcadc6c6045123981e1a4f57054ad6 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 6 Nov 2026 15:57:31 +0100 Subject: [PATCH] BUILD: http: fix build of macro http_harden() with clang 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. --- include/haproxy/http.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/haproxy/http.h b/include/haproxy/http.h index 34befa5bd..2b2832fea 100644 --- a/include/haproxy/http.h +++ b/include/haproxy/http.h @@ -134,9 +134,9 @@ static inline void http_reset_hardening_check(struct http_hdng_chk *chk) 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; \ } \ -- 2.47.3