From 59f08f65fdb0aa54b99cc8e158a66b28d9052215 Mon Sep 17 00:00:00 2001 From: Aurelien DARRAGON Date: Tue, 27 Feb 2024 16:12:40 +0100 Subject: [PATCH] CLEANUP: tree-wide: use proper ERR_* return values for PRE_CHECK fcts httpclient_precheck(), ssl_ocsp_update_precheck(), and resolvers_create_default() functions are registered through REGISTER_PRE_CHECK() macro to be called by haproxy during init from the pre_check_list list. When calling functions registered in pre_check_list, haproxy expects ERR_* return values. However those 3 functions currently use raw return values, so we better use explicit ERR_* macros to prevent breakage in the future if ERR_* values mapping were to change. --- src/http_client.c | 4 ++-- src/resolvers.c | 8 ++++---- src/ssl_ocsp.c | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/http_client.c b/src/http_client.c index 4f40475ac..4d3415cf0 100644 --- a/src/http_client.c +++ b/src/http_client.c @@ -1343,9 +1343,9 @@ static int httpclient_precheck() httpclient_proxy = httpclient_create_proxy(""); if (!httpclient_proxy) - return 1; + return ERR_RETRYABLE; - return 0; + return ERR_NONE; } /* Initialize the logs for every proxy dedicated to the httpclient */ diff --git a/src/resolvers.c b/src/resolvers.c index fe7ddfb25..85277641e 100644 --- a/src/resolvers.c +++ b/src/resolvers.c @@ -3835,14 +3835,14 @@ out: */ int resolvers_create_default() { - int err_code = 0; + int err_code = ERR_NONE; if (global.mode & MODE_MWORKER_WAIT) /* does not create the section if in wait mode */ - return 0; + return ERR_NONE; /* if the section already exists, do nothing */ if (find_resolvers_by_id("default")) - return 0; + return ERR_NONE; curr_resolvers = NULL; err_code |= resolvers_new(&curr_resolvers, "default", "", 0); @@ -3868,7 +3868,7 @@ err: /* we never return an error there, we only try to create this section * if that's possible */ - return 0; + return ERR_NONE; } int cfg_post_parse_resolvers() diff --git a/src/ssl_ocsp.c b/src/ssl_ocsp.c index 3e7408a66..f3e2812a2 100644 --- a/src/ssl_ocsp.c +++ b/src/ssl_ocsp.c @@ -1357,12 +1357,12 @@ static int ssl_ocsp_update_precheck() /* initialize the OCSP update dedicated httpclient */ httpclient_ocsp_update_px = httpclient_create_proxy(""); if (!httpclient_ocsp_update_px) - return 1; + return ERR_RETRYABLE; httpclient_ocsp_update_px->conf.error_logformat_string = strdup(ocspupdate_log_format); httpclient_ocsp_update_px->conf.logformat_string = httpclient_log_format; httpclient_ocsp_update_px->options2 |= PR_O2_NOLOGNORM; - return 0; + return ERR_NONE; } /* initialize the proxy and servers for the HTTP client */ -- 2.47.3