mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-20 21:31:28 +02:00
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.
This commit is contained in:
parent
ef73fe2584
commit
abfd6f3b93
22
src/trace.c
22
src/trace.c
@ -1008,7 +1008,15 @@ int trace_parse_cmd(const char *arg_src, char **errmsg)
|
||||
char *arg, *oarg;
|
||||
char *saveptr;
|
||||
|
||||
if (arg_src) {
|
||||
if (!arg_src) {
|
||||
/* No trace specification, activate all sources on error level. */
|
||||
struct trace_source *src = NULL;
|
||||
|
||||
list_for_each_entry(src, &trace_sources, source_link)
|
||||
_trace_parse_cmd(src, -1, -1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strcmp(arg_src, "help") == 0) {
|
||||
memprintf(errmsg,
|
||||
"-dt activates traces on stderr output via the command-line.\n"
|
||||
@ -1030,19 +1038,9 @@ int trace_parse_cmd(const char *arg_src, char **errmsg)
|
||||
/* keep a copy of the ptr for strtok */
|
||||
oarg = arg = strdup(arg_src);
|
||||
if (!arg) {
|
||||
memprintf(errmsg, "Can't allocate !");
|
||||
memprintf(errmsg, "Can't allocate trace source!");
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
if (!arg_src) {
|
||||
/* No trace specification, activate all sources on error level. */
|
||||
struct trace_source *src = NULL;
|
||||
|
||||
list_for_each_entry(src, &trace_sources, source_link)
|
||||
_trace_parse_cmd(src, -1, -1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
while ((str = strtok_r(arg, ",", &saveptr))) {
|
||||
struct trace_source *src = NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user