]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: config: Warn only if warnif_cond_conflicts report a conflict
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 24 Mar 2026 17:16:52 +0000 (18:16 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 27 Mar 2026 06:35:25 +0000 (07:35 +0100)
When warnif_cond_conflicts() is called, we must take care to emit a warning
only when a conflict is reported. We cannot rely on the err_code variable
because some warnings may have been already reported. We now rely on the
errmsg variable. If it contains something, a warning is emitted. It is good
enough becasue warnif_cond_conflicts() only reports warnings.

This patch should fix the issue #3305. It is a 3.4-dev specific issue. No
backport needed.

src/cfgparse-listen.c

index 1b28fbd8e7c03a086feaf821db94cbce710e26c7..eac047051c3c8f050549badf97226e3dfcdc22e8 100644 (file)
@@ -1365,7 +1365,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
                if (curproxy->cap & PR_CAP_BE)
                        where |= SMP_VAL_BE_HRQ_HDR;
                err_code |= warnif_cond_conflicts(rule->cond, where, &errmsg);
-               if (err_code)
+               if (errmsg && *errmsg)
                        ha_warning("parsing [%s:%d] : '%s.\n'", file, linenum, errmsg);
 
                LIST_APPEND(&curproxy->http_req_rules, &rule->list);
@@ -1400,7 +1400,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
                if (curproxy->cap & PR_CAP_BE)
                        where |= SMP_VAL_BE_HRS_HDR;
                err_code |= warnif_cond_conflicts(rule->cond, where, &errmsg);
-               if (err_code)
+               if (errmsg && *errmsg)
                        ha_warning("parsing [%s:%d] : '%s.\n'", file, linenum, errmsg);
 
                LIST_APPEND(&curproxy->http_res_rules, &rule->list);
@@ -1434,7 +1434,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
                if (curproxy->cap & PR_CAP_BE)
                        where |= SMP_VAL_BE_HRS_HDR;
                err_code |= warnif_cond_conflicts(rule->cond, where, &errmsg);
-               if (err_code)
+               if (errmsg && *errmsg)
                        ha_warning("parsing [%s:%d] : '%s.\n'", file, linenum, errmsg);
 
                LIST_APPEND(&curproxy->http_after_res_rules, &rule->list);
@@ -1498,7 +1498,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
                if (curproxy->cap & PR_CAP_BE)
                        where |= SMP_VAL_BE_HRQ_HDR;
                err_code |= warnif_cond_conflicts(rule->cond, where, &errmsg);
-               if (err_code)
+               if (errmsg && *errmsg)
                        ha_warning("parsing [%s:%d] : '%s.\n'", file, linenum, errmsg);
        }
        else if (strcmp(args[0], "use_backend") == 0) {
@@ -1528,7 +1528,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
                        }
 
                        err_code |= warnif_cond_conflicts(cond, SMP_VAL_FE_SET_BCK, &errmsg);
-                       if (err_code)
+                       if (errmsg && *errmsg)
                                ha_warning("parsing [%s:%d] : '%s.\n'", file, linenum, errmsg);
                }
                else if (*args[2]) {
@@ -1591,7 +1591,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
                }
 
                err_code |= warnif_cond_conflicts(cond, SMP_VAL_BE_SET_SRV, &errmsg);
-               if (err_code)
+               if (errmsg && *errmsg)
                        ha_warning("parsing [%s:%d] : '%s.\n'", file, linenum, errmsg);
 
                rule = calloc(1, sizeof(*rule));
@@ -1646,7 +1646,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
                 * where force-persist is applied.
                 */
                err_code |= warnif_cond_conflicts(cond, SMP_VAL_BE_REQ_CNT, &errmsg);
-               if (err_code)
+               if (errmsg && *errmsg)
                        ha_warning("parsing [%s:%d] : '%s.\n'", file, linenum, errmsg);
 
                rule = calloc(1, sizeof(*rule));
@@ -1814,7 +1814,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
                        err_code |= warnif_cond_conflicts(cond, SMP_VAL_BE_STO_RUL, &errmsg);
                else
                        err_code |= warnif_cond_conflicts(cond, SMP_VAL_BE_SET_SRV, &errmsg);
-               if (err_code)
+               if (errmsg && *errmsg)
                        ha_warning("parsing [%s:%d] : '%s.\n'", file, linenum, errmsg);
 
                rule = calloc(1, sizeof(*rule));
@@ -1872,7 +1872,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
                        if (curproxy->cap & PR_CAP_BE)
                                where |= SMP_VAL_BE_HRQ_HDR;
                        err_code |= warnif_cond_conflicts(cond, where, &errmsg);
-                       if (err_code)
+                       if (errmsg && *errmsg)
                                ha_warning("parsing [%s:%d] : '%s.\n'", file, linenum, errmsg);
 
                        rule = calloc(1, sizeof(*rule));
@@ -1952,7 +1952,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
                        if (curproxy->cap & PR_CAP_BE)
                                where |= SMP_VAL_BE_HRQ_HDR;
                        err_code |= warnif_cond_conflicts(rule->cond, where, &errmsg);
-                       if (err_code)
+                       if (errmsg && *errmsg)
                                ha_warning("parsing [%s:%d] : '%s.\n'", file, linenum, errmsg);
                        LIST_APPEND(&curproxy->uri_auth->http_req_rules, &rule->list);