From cec1f3408f4367fa063ef82be54a535a58d39a33 Mon Sep 17 00:00:00 2001 From: radius Date: Thu, 9 Jul 2015 22:52:52 -0500 Subject: [PATCH] declare variables on top --- input/input_autodetect.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/input/input_autodetect.c b/input/input_autodetect.c index 729b2b02c9..a5b138db36 100644 --- a/input/input_autodetect.c +++ b/input/input_autodetect.c @@ -148,6 +148,9 @@ static bool input_autoconfigure_joypad_from_conf_dir( { size_t i; int ret = 0; + int index = 0; + int current_best = 0; + settings_t *settings = config_get_ptr(); struct string_list *list = settings ? dir_list_new( settings->input.autoconfig_dir, "cfg", false) : NULL; @@ -155,9 +158,6 @@ static bool input_autoconfigure_joypad_from_conf_dir( if (!list) return false; - int current_best = 0; - int index = 0; - config_file_t *conf; for (i = 0; i < list->size; i++) @@ -172,9 +172,14 @@ static bool input_autoconfigure_joypad_from_conf_dir( config_file_free(conf); } - conf = config_file_new(list->elems[index].data); - input_autoconfigure_joypad_add(conf, params); - config_file_free(conf); + if(index) + { + conf = config_file_new(list->elems[index].data); + input_autoconfigure_joypad_add(conf, params); + config_file_free(conf); + } + else + ret = 0; string_list_free(list);