BUILD: trace: silence a bogus build warning at -Og
authorWilly Tarreau <w@1wt.eu>
Fri, 5 Sep 2025 07:15:05 +0000 (09:15 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 1 Oct 2025 14:48:34 +0000 (16:48 +0200)
commit251cf06748fb0d8366ac6bba8125e633dac96678
tree176533c84a4f68ff94c4e294385a581d88cf7773
parent55078fc88ea237b02ad2033489d29dd2ce3cac08
BUILD: trace: silence a bogus build warning at -Og

gcc-13.3 at -Og emits an incorrect build warning in trace.c about a
possibly initialized variable:

  In file included from include/haproxy/api.h:35,
                   from src/trace.c:22:
  src/trace.c: In function 'trace_parse_cmd':
  include/haproxy/bug.h:431:17: warning: 'arg' may be used uninitialized [-Wmaybe-uninitialized]
    431 |                 free(*__x);                                             \
        |                 ^~~~~~~~~~
  src/trace.c:1136:9: note: in expansion of macro 'ha_free'
   1136 |         ha_free(&oarg);
        |         ^~~~~~~
  src/trace.c:1008:15: note: 'arg' was declared here
   1008 |         char *arg, *oarg;
        |               ^~~

The warning is obviously wrong since the field is initialized in one of
the two branches of an "if" whose complementary one returns. But the
compiler doesn't seem to see this because the if is in fact two ifs each
with an opposite condition: "if (arg_src)" then "if (!arg_src)". Let's
just move upwards the default one that returns and eliminate the other
one. Reading the diff with "git diff -b" better shows the tiny change.

It could be backported to 3.0.

(cherry picked from commit abfd6f3b93db72f65015cb3278fe5182bf174493)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 77fda88fd1147d1a7d7daa6618809cb0df454791)
[cf: Remove help message]
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 95fbc12290969eee8b65a29aa4bb070de4039c7c)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
src/trace.c