diff options
-rw-r--r-- | common/ini/ini_config.c | 8 | ||||
-rw-r--r-- | common/ini/ini_config_ut.c | 6 |
2 files changed, 11 insertions, 3 deletions
diff --git a/common/ini/ini_config.c b/common/ini/ini_config.c index 8d19b272..4112049f 100644 --- a/common/ini/ini_config.c +++ b/common/ini/ini_config.c @@ -145,7 +145,7 @@ static int ini_to_collection(const char *filename, if (file == NULL) { error = errno; TRACE_ERROR_NUMBER("Failed to open file - but this is OK", error); - return EOK; + return ENOENT; } /* Open the collection of errors */ @@ -416,7 +416,8 @@ int config_for_app(const char *application, TRACE_INFO_STRING("Reading master file:", config_file); error = ini_to_collection(config_file, *ini_config, error_level, pass_common); - if (error != EOK) { + /* ENOENT and EOK are Ok */ + if (error && (error != ENOENT)) { TRACE_ERROR_NUMBER("Failed to read master file", error); /* In case of error when we created collection - delete it */ if(error && created) { @@ -468,7 +469,8 @@ int config_for_app(const char *application, error = ini_to_collection(file_name, *ini_config, error_level, pass_specific); free(file_name); - if (error) { + /* ENOENT and EOK are Ok */ + if (error && (error != ENOENT)) { TRACE_ERROR_NUMBER("Failed to read specific application file", error); /* In case of error when we created collection - delete it */ if (error && created) { diff --git a/common/ini/ini_config_ut.c b/common/ini/ini_config_ut.c index 28560e54..6787c36c 100644 --- a/common/ini/ini_config_ut.c +++ b/common/ini/ini_config_ut.c @@ -61,6 +61,12 @@ int single_file() struct collection_item *ini_config = (struct collection_item *)(NULL); struct collection_item *error_set = (struct collection_item *)(NULL); + error = config_from_file("test", "./ini/not_exist_ini.conf", &ini_config,INI_STOP_ON_NONE,&error_set); + if(error) { + printf("Attempt to read configuration returned error: %d. EXPECTED.\n\n",error); + if(error != ENOENT) return error; + } + error = config_from_file("test", "./ini/ini.conf", &ini_config,INI_STOP_ON_NONE,&error_set); if(error) { printf("Attempt to read configuration returned error: %d\n",error); |