From: William Lallemand Date: Thu, 9 Nov 2023 10:24:26 +0000 (+0100) Subject: MINOR: errors: ha_alert() and ha_warning() uses warn_exec_path() X-Git-Tag: v2.9-dev10~118 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b959b752f9ceca2a7edfa61d22e621ef8d174f69;p=thirdparty%2Fhaproxy.git MINOR: errors: ha_alert() and ha_warning() uses warn_exec_path() Move the code to display the haproxy version and path during starting mode, which is called by the first ha_alert() or ha_warning(). --- diff --git a/src/errors.c b/src/errors.c index 5913cb1d50..bd157a82e7 100644 --- a/src/errors.c +++ b/src/errors.c @@ -420,6 +420,22 @@ static void print_message_args(int use_usermsgs_ctx, const char *label, const ch va_end(argp); } +/* + * Display a notice with the happroxy version and executable path when the + * first message is emitted in starting mode. + */ +static void warn_exec_path() +{ + if (!(warned & WARN_EXEC_PATH) && (global.mode & MODE_STARTING)) { + const char *path = get_exec_path(); + + warned |= WARN_EXEC_PATH; + print_message_args(0, "NOTICE", "haproxy version is %s\n", haproxy_version); + if (path) + print_message_args(0, "NOTICE", "path to executable is %s\n", path); + } +} + /* * Displays the message on stderr with the pid. Overrides the quiet * mode during startup. @@ -430,14 +446,7 @@ void ha_alert(const char *fmt, ...) if (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE) || !(global.mode & MODE_STARTING)) { - if (!(warned & WARN_EXEC_PATH) && (global.mode & MODE_STARTING)) { - const char *path = get_exec_path(); - - warned |= WARN_EXEC_PATH; - print_message_args(0, "NOTICE", "haproxy version is %s\n", haproxy_version); - if (path) - print_message_args(0, "NOTICE", "path to executable is %s\n", path); - } + warn_exec_path(); va_start(argp, fmt); print_message(1, "ALERT", fmt, argp); va_end(argp); @@ -456,14 +465,7 @@ void ha_warning(const char *fmt, ...) if (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE) || !(global.mode & MODE_STARTING)) { - if (!(warned & WARN_EXEC_PATH) && (global.mode & MODE_STARTING)) { - const char *path = get_exec_path(); - - warned |= WARN_EXEC_PATH; - print_message_args(0, "NOTICE", "haproxy version is %s\n", haproxy_version); - if (path) - print_message_args(0, "NOTICE", "path to executable is %s\n", path); - } + warn_exec_path(); va_start(argp, fmt); print_message(1, "WARNING", fmt, argp); va_end(argp);