]> git.kaiwu.me - haproxy.git/commit
MINOR: trace: always pretend to use args when disabled
authorWilly Tarreau <w@1wt.eu>
Wed, 1 Jul 2026 12:42:58 +0000 (14:42 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 3 Jul 2026 14:32:28 +0000 (16:32 +0200)
commitb17a16b3e2e534f4736e3c911c64f550d9b34def
tree2cbdf8b36eb562132a481eb864990b161609364a
parent7fc3a52aaf606ff2e55279216676f0419e11d429
MINOR: trace: always pretend to use args when disabled

When traces are disabled, we used to make TRACE() and other macros just
emit a "do { } while (0)" statement, which has the unfortunate limitation
of explicitly marking the arguments as not used. As such, all variables
that are initialized in functions for the sole purpose of being passed
to the trace calls end up emitting warnings about "foo defined but not
used". It is difficult to keep these in a clean state all the time, and
to always think about adding __maybe_unused after each declaration, and
the traces try hard to be developer-friendly in order to gain in adoption.

Let's just remap all macros to __eat_all_args() which will mark all
arguments as used. No code is emitted, the output binary is the same
as with the while(0) stuff, but syntactically speaking the argument is
used and the compiler is happy.

It may be useful to backport this to 3.4 as it's already expected that
some future fixes will trigger build warnings there otherwise. This
commit requires these two ones:

  CLEANUP: traces: get rid of a few rare empty args in TRACE calls
  MINOR: compiler: add a macro to ignore all arguments
include/haproxy/trace.h