Fail early if configuration module can not initialize properly

In the case that the config module cannot load the driver for libconfig
or yaml, currently, there might be a cascade of errors that are
difficult for users to understand. For instance (partially redacted for
clarity):

    [CONFIG] Error calling dlopen(libparams_libconfig.so): libparams_libconfig.so: cannot open shared object file: No such file or directory
    [CONFIG] config module "libconfig" couldn't be loaded
    [CONFIG] config_get, section log_config skipped, config module not properly initialized
    [LOG] init aborted, configuration couldn't be performed
    [CONFIG] config_get, section (null) skipped, config module not properly initialized
    [CONFIG] /home/francesco/openairinterface5g/common/config/config_userapi.c 68 nfapi has no processed integer availablle
    [CONFIG] config_get, section (null) skipped, config module not properly initialized

    Assertion (get_softmodem_params()->default_pdu_session_id == -1) failed!
    In get_common_options() /home/francesco/openairinterface5g/executables/softmodem-common.c:161
    Use uicc0.pdu_sessions.[0].id to change the requested PDU session ID (is 0)

Here, the error is the missing shared object, but a user is more likely
to look at the last error instead of the first.

This commit addresses it by checking early for
CONFIG_ISFLAGSET(CONFIG_ABORT), and stopping if it is set. Additionally
changes include making functions static, removing late
CONFIG_ISFLAGSET() checks, and the CONFIG_ISFLAGSET() in
load_configmodule(), because at that time "uniqCfg" is not set yet and
thus does not do anything (this is likely a regression of an earlier
cleanup).

See-also: f50d5f5a9b ("make multiple config instead of one implicit
  global")
This commit is contained in:
Robert Schmidt
2026-02-19 17:06:29 +01:00
parent 40e61d59a6
commit 82315ead3e
3 changed files with 5 additions and 14 deletions
+3 -7
View File
@@ -63,7 +63,8 @@ static paramdef_t Config_Params[] = {
};
// clang-format on
int load_config_sharedlib(configmodule_interface_t *cfgptr) {
static int load_config_sharedlib(configmodule_interface_t *cfgptr)
{
void *lib_handle;
char fname[128];
char libname[FILENAME_MAX];
@@ -380,7 +381,7 @@ configmodule_interface_t *load_configmodule(int argc,
Config_Params[idx].strptr = &(cfgptr->tmpdir);
config_get(cfgptr, Config_Params, sizeofArray(Config_Params), CONFIG_SECTIONNAME);
} else {
fprintf(stderr,"[CONFIG] %s %d config module \"%s\" couldn't be loaded\n", __FILE__, __LINE__,cfgmode);
fprintf(stderr, "[CONFIG] config module \"%s\" couldn't be loaded\n", cfgmode);
cfgptr->rtflags = cfgptr->rtflags | CONFIG_HELP | CONFIG_ABORT;
}
} else {
@@ -396,11 +397,6 @@ configmodule_interface_t *load_configmodule(int argc,
if (cfgmode != NULL) free(cfgmode);
if (CONFIG_ISFLAGSET(CONFIG_ABORT)) {
config_printhelp(Config_Params, sizeofArray(Config_Params), CONFIG_SECTIONNAME);
// exit(-1);
}
return cfgptr;
}