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.
This commit is contained in:
Aurelien DARRAGON 2024-02-27 16:12:40 +01:00
parent 2df7e077c7
commit 59f08f65fd
3 changed files with 8 additions and 8 deletions

View File

@ -1343,9 +1343,9 @@ static int httpclient_precheck()
httpclient_proxy = httpclient_create_proxy("<HTTPCLIENT>"); httpclient_proxy = httpclient_create_proxy("<HTTPCLIENT>");
if (!httpclient_proxy) if (!httpclient_proxy)
return 1; return ERR_RETRYABLE;
return 0; return ERR_NONE;
} }
/* Initialize the logs for every proxy dedicated to the httpclient */ /* Initialize the logs for every proxy dedicated to the httpclient */

View File

@ -3835,14 +3835,14 @@ int cfg_parse_resolvers(const char *file, int linenum, char **args, int kwm)
*/ */
int resolvers_create_default() 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 */ 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 the section already exists, do nothing */
if (find_resolvers_by_id("default")) if (find_resolvers_by_id("default"))
return 0; return ERR_NONE;
curr_resolvers = NULL; curr_resolvers = NULL;
err_code |= resolvers_new(&curr_resolvers, "default", "<internal>", 0); err_code |= resolvers_new(&curr_resolvers, "default", "<internal>", 0);
@ -3868,7 +3868,7 @@ int resolvers_create_default()
/* we never return an error there, we only try to create this section /* we never return an error there, we only try to create this section
* if that's possible */ * if that's possible */
return 0; return ERR_NONE;
} }
int cfg_post_parse_resolvers() int cfg_post_parse_resolvers()

View File

@ -1357,12 +1357,12 @@ static int ssl_ocsp_update_precheck()
/* initialize the OCSP update dedicated httpclient */ /* initialize the OCSP update dedicated httpclient */
httpclient_ocsp_update_px = httpclient_create_proxy("<OCSP-UPDATE>"); httpclient_ocsp_update_px = httpclient_create_proxy("<OCSP-UPDATE>");
if (!httpclient_ocsp_update_px) 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.error_logformat_string = strdup(ocspupdate_log_format);
httpclient_ocsp_update_px->conf.logformat_string = httpclient_log_format; httpclient_ocsp_update_px->conf.logformat_string = httpclient_log_format;
httpclient_ocsp_update_px->options2 |= PR_O2_NOLOGNORM; httpclient_ocsp_update_px->options2 |= PR_O2_NOLOGNORM;
return 0; return ERR_NONE;
} }
/* initialize the proxy and servers for the HTTP client */ /* initialize the proxy and servers for the HTTP client */