diff --git a/src/base/config.c b/src/base/config.c index 0d77197a2bd26160a0db45f4258b20dee0490d02..568a64f9751472b50160b400f93d955d5dc6165f 100644 --- a/src/base/config.c +++ b/src/base/config.c @@ -10,7 +10,7 @@ /* Get the path to the config file that may be red, taking into account the priority between existing files. The returned path is a path to an existing - file. If no file is found, returns a non zero value. Returns 1 otherwise. */ + file. If no file is found, returns a non zero value. Returns 0 otherwise. */ PRIVATE_FUNCTION int config_detect_file(char *conf, size_t conf_len); /* Create and read the configuration in the conf file and write it into @@ -342,9 +342,9 @@ ___mkdir(const char *dir) int config_open(lkt_db *db, char *conf_file, size_t conf_len) { - int retry_config_once = 0; + bool retry_config_once = false; retry_config: - if (conf_file[0] == '\0' && config_detect_file(conf_file, conf_len)) { + if ((conf_file[0] == '\0') && config_detect_file(conf_file, conf_len)) { RETURN_IF(retry_config_once, "Failed to find a config file", 1); LOG_INFO("INIT", "Creating default config file"); @@ -353,7 +353,7 @@ retry_config: errno = 0; FILE *file_desc = fopen(conf_file, "w+"); - if (file_desc != NULL) { + if (file_desc == NULL) { LOG_ERROR("INIT", "Failed to open default config file and initialize it"); LOG_ERROR("INTI", "Conf file is %s, errno is %d: %s", conf_file, errno, strerror(errno)); @@ -363,7 +363,7 @@ retry_config: fclose(file_desc); LOG_INFO("INIT", "Default configuration file has been writen to %s", conf_file); - retry_config_once = 1; + retry_config_once = true; goto retry_config; }