Skip to content
Extraits de code Groupes Projets
Vérifiée Valider 87e9caad rédigé par Kubat's avatar Kubat
Parcourir les fichiers

FIX: Do the check for the creation of the default config file the right way

parent 5c4bc31f
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Pipeline #3377 en échec
......@@ -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;
}
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter