]> git.kaiwu.me - haproxy.git/commit
BUILD: http: fix build of macro http_harden() with clang
authorWilly Tarreau <w@1wt.eu>
Fri, 6 Nov 2026 14:57:31 +0000 (15:57 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 6 Nov 2026 15:00:53 +0000 (16:00 +0100)
commit023649a0c5dcadc6c6045123981e1a4f57054ad6
treeefb9ca62f20416f5910a75654b47803e12de80d8
parent999a26751f06fe48b0959c28439da32a29ddd101
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