From: Amaury Denoyelle Date: Wed, 4 Jun 2025 09:26:27 +0000 (+0200) Subject: BUG/MINOR: config: emit warning for empty args only in discovery mode X-Git-Tag: v3.3-dev1~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5f1fad169063e3ff5c1b41bc387cb9e7a1070320;p=thirdparty%2Fhaproxy.git BUG/MINOR: config: emit warning for empty args only in discovery mode Hide warning about empty argument outside of discovery mode. This is necessary, else the message will be displayed twice, which hampers haproxy output lisibility. This should fix github isue #2995. This should be backported up to 3.2. --- diff --git a/src/cfgparse.c b/src/cfgparse.c index d0b86d65a..eff0c0296 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -2066,28 +2066,31 @@ next_line: goto next_line; } - for (check_arg = 0; check_arg < arg; check_arg++) { - if (!*args[check_arg]) { - size_t newpos; - - /* if an empty arg was found, its pointer should be in , except - * for rare cases such as '\x00' etc. We need to check errptr in any case - * and if it's not set, we'll fall back to args's position in the output - * string instead (less accurate but still useful). - */ - if (!errptr) { - newpos = args[check_arg] - outline; - if (newpos >= strlen(line)) - newpos = 0; // impossible to report anything, start at the beginning. - errptr = line + newpos; - } + if ((global.mode & MODE_DISCOVERY)) { + /* Only print empty arg warning in discovery mode to prevent double display. */ + for (check_arg = 0; check_arg < arg; check_arg++) { + if (!*args[check_arg]) { + size_t newpos; + + /* if an empty arg was found, its pointer should be in , except + * for rare cases such as '\x00' etc. We need to check errptr in any case + * and if it's not set, we'll fall back to args's position in the output + * string instead (less accurate but still useful). + */ + if (!errptr) { + newpos = args[check_arg] - outline; + if (newpos >= strlen(line)) + newpos = 0; // impossible to report anything, start at the beginning. + errptr = line + newpos; + } - /* sanitize input line in-place */ - newpos = sanitize_for_printing(line, errptr - line, 80); - ha_warning("parsing [%s:%d]: argument number %d at position %d is empty and marks the end of the " - "argument list; all subsequent arguments will be ignored:\n %s\n %*s\n", - file, linenum, check_arg + 1, (int)(errptr - thisline + 1), line, (int)(newpos+1), "^"); - break; + /* sanitize input line in-place */ + newpos = sanitize_for_printing(line, errptr - line, 80); + ha_warning("parsing [%s:%d]: argument number %d at position %d is empty and marks the end of the " + "argument list; all subsequent arguments will be ignored:\n %s\n %*s\n", + file, linenum, check_arg + 1, (int)(errptr - thisline + 1), line, (int)(newpos+1), "^"); + break; + } } }