From 2660606f4191b01472e40a0455efac4639dee5d7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 22 Sep 2015 12:58:22 +0200 Subject: [PATCH] (libretro-common) config_file.c - Cleanups --- libretro-common/file/config_file.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/libretro-common/file/config_file.c b/libretro-common/file/config_file.c index 6ed2f4b17c..e0903f7c7c 100644 --- a/libretro-common/file/config_file.c +++ b/libretro-common/file/config_file.c @@ -35,8 +35,6 @@ #include #endif -#include -#include #include #include #include @@ -373,18 +371,11 @@ static config_file_t *config_file_new_internal( return conf; if (path_is_directory(path)) - { - RARCH_ERR("%s is not a regular file.\n", path); - free(conf); - return NULL; - } + goto error; conf->path = strdup(path); if (!conf->path) - { - free(conf); - return NULL; - } + goto error; conf->include_depth = depth; file = fopen(path, "r"); @@ -392,8 +383,7 @@ static config_file_t *config_file_new_internal( if (!file) { free(conf->path); - free(conf); - return NULL; + goto error; } while (!feof(file)) @@ -434,9 +424,15 @@ static config_file_t *config_file_new_internal( if (list != conf->tail) free(list); } + fclose(file); return conf; + +error: + free(conf); + + return NULL; } config_file_t *config_file_new_from_string(const char *from_string)