]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: cfgparse-listen: do not emit extraneous line in rule order warnings
authorWilly Tarreau <w@1wt.eu>
Mon, 11 May 2026 07:32:41 +0000 (09:32 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 11 May 2026 07:32:41 +0000 (09:32 +0200)
Some functions such as tcp_parse_tcp_req() are able to emit their own
warnings by relying on warnif_misplaced_*() which directly prints the
warning. However when doing so they still increment the warning counter
which makes cfg_parse_listen() try to emit it, except that what's in the
variable is NULL, so we end up with:

  [WARNING]  (260) : config : parsing [/etc/haproxy/haproxy.cfg:17] : (null)

Let's just check the errmsg variable before printing the error. If it's
NULL, it's because the message was already printed.

This can be backported to all branches.

src/cfgparse-listen.c

index 2ef1a1081c22917037d161c50e362999968a5b01..38f2bc4d0f6b0a366f8b10d70ade533e30730ef6 100644 (file)
@@ -3262,12 +3262,14 @@ stats_error_parsing:
                                        /* prepare error message just in case */
                                        rc = kwl->kw[index].parse(args, CFG_LISTEN, curproxy, curr_defproxy, file, linenum, &errmsg);
                                        if (rc < 0) {
-                                               ha_alert("parsing [%s:%d] : %s\n", file, linenum, errmsg);
+                                               if (errmsg)
+                                                       ha_alert("parsing [%s:%d] : %s\n", file, linenum, errmsg);
                                                err_code |= ERR_ALERT | ERR_FATAL;
                                                goto out;
                                        }
                                        else if (rc > 0) {
-                                               ha_warning("parsing [%s:%d] : %s\n", file, linenum, errmsg);
+                                               if (errmsg)
+                                                       ha_warning("parsing [%s:%d] : %s\n", file, linenum, errmsg);
                                                err_code |= ERR_WARN;
                                                goto out;
                                        }