From: Amaury Denoyelle Date: Fri, 13 Nov 2026 10:42:29 +0000 (+0100) Subject: BUG/MINOR: init: fix missing error on no listener on config check X-Git-Url: https://git.kaiwu.me/web/upload.html?a=commitdiff_plain;h=2cd73b0826ee71a07a245649330ab15e5d9bc929;p=haproxy.git BUG/MINOR: init: fix missing error on no listener on config check Since the conversion of the list of proxies, sinks and logs from a plain linked list to a full struct list type, config check would not report an error anymore if no listener is present. This is caused because iterations are now performed via list_for_each_entry() without producing a final NULL iterator value. Fix this by using a plain boolean set during the loop and check its value at the end instead of inspecting the iterator itself. This should fix github issue #3567. No need to backport. --- diff --git a/src/haproxy.c b/src/haproxy.c index 50584f415..931aaa66d 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -2399,6 +2399,7 @@ static void step_init_2(int argc, char** argv) if (global.mode & MODE_CHECK) { struct peers *pr; struct proxy *px; + int listener_found = 0; if (warned & WARN_ANY) qfprintf(stdout, "Warnings were found.\n"); @@ -2408,19 +2409,23 @@ static void step_init_2(int argc, char** argv) break; list_for_each_entry(px, &main_proxies, el) { - if (!(px->flags & (PR_FL_DISABLED|PR_FL_STOPPED)) && px->li_all) + if (!(px->flags & (PR_FL_DISABLED|PR_FL_STOPPED)) && px->li_all) { + listener_found = 1; break; + } } - if (!px) { + if (!listener_found) { /* We may only have log-forward section */ list_for_each_entry(px, &cfg_log_forward, el) { - if (!(px->flags & (PR_FL_DISABLED|PR_FL_STOPPED)) && px->li_all) + if (!(px->flags & (PR_FL_DISABLED|PR_FL_STOPPED)) && px->li_all) { + listener_found = 1; break; + } } } - if (pr || px) { + if (pr || listener_found) { /* At least one peer or one listener has been found */ if (global.mode & MODE_VERBOSE) qfprintf(stdout, "Configuration file is valid\n");