]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: tree-wide: use proper ERR_* return values for PRE_CHECK fcts
authorAurelien DARRAGON <adarragon@haproxy.com>
Tue, 27 Feb 2024 15:12:40 +0000 (16:12 +0100)
committerAurelien DARRAGON <adarragon@haproxy.com>
Thu, 7 Mar 2024 10:48:08 +0000 (11:48 +0100)
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
src/resolvers.c
src/ssl_ocsp.c

index 4f40475aca2fb277dd24a710b8b860424f97307a..4d3415cf0cece2adb1a2a8e43137332985c87302 100644 (file)
@@ -1343,9 +1343,9 @@ static int httpclient_precheck()
 
        httpclient_proxy = httpclient_create_proxy("<HTTPCLIENT>");
        if (!httpclient_proxy)
-               return 1;
+               return ERR_RETRYABLE;
 
-       return 0;
+       return ERR_NONE;
 }
 
 /* Initialize the logs for every proxy dedicated to the httpclient */
index fe7ddfb251b1a6752ad9bdac17c7ec306fd73eb9..85277641ea1858df4b72ca947b7b6bd73f9561d8 100644 (file)
@@ -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", "<internal>", 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()
index 3e7408a667ec9ebabf2bded5f79b22d658246f75..f3e2812a24fb56038dff5f267f6df1c36d868b2c 100644 (file)
@@ -1357,12 +1357,12 @@ static int ssl_ocsp_update_precheck()
        /* initialize the OCSP update dedicated httpclient */
        httpclient_ocsp_update_px = httpclient_create_proxy("<OCSP-UPDATE>");
        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 */