(Menu) Cleanups pt. 4

This commit is contained in:
twinaphex 2015-06-12 17:23:31 +02:00
parent d532fb4979
commit 5789fb44f4
10 changed files with 130 additions and 123 deletions

View File

@ -76,10 +76,11 @@ static int deferred_push_database_manager_list_deferred(menu_displaylist_info_t
static int deferred_push_cursor_manager_list_deferred(menu_displaylist_info_t *info)
{
char *query = NULL, *rdb = NULL;
char rdb_path[PATH_MAX_LENGTH];
settings_t *settings = config_get_ptr();
config_file_t *conf = config_file_new(info->path);
char *query = NULL;
char *rdb = NULL;
char rdb_path[PATH_MAX_LENGTH] = {0};
settings_t *settings = config_get_ptr();
config_file_t *conf = config_file_new(info->path);
if (!conf || !settings)
return -1;
@ -113,7 +114,7 @@ static int deferred_push_cursor_manager_list_deferred_query_subsearch(menu_displ
{
#ifdef HAVE_LIBRETRODB
int ret;
char query[PATH_MAX_LENGTH];
char query[PATH_MAX_LENGTH] = {0};
struct string_list *str_list = string_split(info->path, "|");
database_info_build_query(query, sizeof(query), info->label, str_list->elems[0].data);
@ -229,7 +230,7 @@ size_t core_len;
int cb_core_updater_list(void *data_, size_t len)
{
char *data = (char*)data_;
char *data = (char*)data_;
menu_handle_t *menu = menu_driver_get_ptr();
if (!menu)
return -1;

View File

@ -32,15 +32,15 @@ extern char detect_content_path[PATH_MAX_LENGTH];
static int archive_open(void)
{
char cat_path[PATH_MAX_LENGTH];
menu_displaylist_info_t info = {0};
const char *menu_path = NULL;
const char *menu_label = NULL;
const char* path = NULL;
unsigned int type = 0;
size_t entry_idx = 0;
menu_navigation_t *nav = menu_navigation_get_ptr();
menu_list_t *menu_list = menu_list_get_ptr();
char cat_path[PATH_MAX_LENGTH] = {0};
menu_displaylist_info_t info = {0};
const char *menu_path = NULL;
const char *menu_label = NULL;
const char* path = NULL;
unsigned int type = 0;
size_t entry_idx = 0;
menu_navigation_t *nav = menu_navigation_get_ptr();
menu_list_t *menu_list = menu_list_get_ptr();
if (!menu_list || !nav)
return -1;
@ -165,9 +165,9 @@ static int action_iterate_help(char *s, size_t len, const char *label)
RETRO_DEVICE_ID_JOYPAD_X,
RETRO_DEVICE_ID_JOYPAD_Y,
};
char desc[ARRAY_SIZE(binds)][64];
menu_handle_t *menu = menu_driver_get_ptr();
settings_t *settings = config_get_ptr();
char desc[ARRAY_SIZE(binds)][64] = {0};
menu_handle_t *menu = menu_driver_get_ptr();
settings_t *settings = config_get_ptr();
if (!menu)
return 0;
@ -216,7 +216,7 @@ static int action_iterate_help(char *s, size_t len, const char *label)
static int action_iterate_info(char *s, size_t len, const char *label)
{
int ret = 0;
char needle[PATH_MAX_LENGTH];
char needle[PATH_MAX_LENGTH] = {0};
unsigned info_type = 0;
rarch_setting_t *current_setting = NULL;
file_list_t *list = NULL;
@ -492,10 +492,10 @@ static enum action_iterate_type action_iterate_type(uint32_t hash)
static int action_iterate_main(const char *label, unsigned action)
{
static bool did_messagebox = false;
char msg[PATH_MAX_LENGTH];
enum action_iterate_type iterate_type;
menu_entry_t entry;
static bool did_messagebox = false;
char msg[PATH_MAX_LENGTH] = {0};
enum action_iterate_type iterate_type;
size_t selected, *pop_selected = false;
bool do_messagebox = false;
bool do_pop_stack = false;

View File

@ -360,7 +360,7 @@ static int menu_cbs_init_bind_left_compare_label(menu_file_list_cbs_t *cbs,
for (i = 0; i < MAX_USERS; i++)
{
char label_setting[PATH_MAX_LENGTH];
char label_setting[PATH_MAX_LENGTH] = {0};
snprintf(label_setting, sizeof(label_setting), "input_player%d_joypad_index", i + 1);
if (!strcmp(label, label_setting))

View File

@ -38,7 +38,7 @@ char core_updater_path[PATH_MAX_LENGTH];
static int menu_action_setting_set_current_string_path(
rarch_setting_t *setting, const char *dir, const char *path)
{
char s[PATH_MAX_LENGTH];
char s[PATH_MAX_LENGTH] = {0};
fill_pathname_join(s, dir, path, sizeof(s));
setting_set_with_string_representation(setting, s);
return menu_setting_generic(setting, false);
@ -450,8 +450,8 @@ static int action_ok_video_filter(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
menu_displaylist_info_t info = {0};
menu_handle_t *menu = menu_driver_get_ptr();
settings_t *settings = config_get_ptr();
menu_handle_t *menu = menu_driver_get_ptr();
settings_t *settings = config_get_ptr();
if (!menu)
return -1;
@ -467,11 +467,11 @@ static int action_ok_video_filter(const char *path,
static int action_ok_core_updater_list(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
char url_path[PATH_MAX_LENGTH];
menu_displaylist_info_t info = {0};
driver_t *driver = driver_get_ptr();
menu_handle_t *menu = menu_driver_get_ptr();
settings_t *settings = config_get_ptr();
char url_path[PATH_MAX_LENGTH] = {0};
menu_displaylist_info_t info = {0};
driver_t *driver = driver_get_ptr();
menu_handle_t *menu = menu_driver_get_ptr();
settings_t *settings = config_get_ptr();
if (!menu)
return -1;
@ -504,8 +504,8 @@ static int action_ok_remap_file(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
menu_displaylist_info_t info = {0};
menu_handle_t *menu = menu_driver_get_ptr();
settings_t *settings = config_get_ptr();
menu_handle_t *menu = menu_driver_get_ptr();
settings_t *settings = config_get_ptr();
if (!menu)
return -1;
@ -523,8 +523,8 @@ static int action_ok_record_configfile(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
menu_displaylist_info_t info = {0};
menu_handle_t *menu = menu_driver_get_ptr();
global_t *global = global_get_ptr();
menu_handle_t *menu = menu_driver_get_ptr();
global_t *global = global_get_ptr();
if (!menu)
return -1;
@ -615,9 +615,9 @@ static int action_ok_record_configfile_load(const char *path,
static int action_ok_remap_file_load(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
const char *menu_path = NULL;
char remap_path[PATH_MAX_LENGTH];
menu_handle_t *menu = menu_driver_get_ptr();
const char *menu_path = NULL;
char remap_path[PATH_MAX_LENGTH] = {0};
menu_handle_t *menu = menu_driver_get_ptr();
if (!menu)
return -1;
@ -638,10 +638,10 @@ static int action_ok_remap_file_load(const char *path,
static int action_ok_video_filter_file_load(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
char filter_path[PATH_MAX_LENGTH];
const char *menu_path = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
settings_t *settings = config_get_ptr();
const char *menu_path = NULL;
char filter_path[PATH_MAX_LENGTH] = {0};
menu_handle_t *menu = menu_driver_get_ptr();
settings_t *settings = config_get_ptr();
if (!menu)
return -1;
@ -667,10 +667,10 @@ static int action_ok_video_filter_file_load(const char *path,
static int action_ok_cheat_file_load(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
const char *menu_path = NULL;
char cheat_path[PATH_MAX_LENGTH];
menu_handle_t *menu = menu_driver_get_ptr();
global_t *global = global_get_ptr();
const char *menu_path = NULL;
char cheat_path[PATH_MAX_LENGTH] = {0};
menu_handle_t *menu = menu_driver_get_ptr();
global_t *global = global_get_ptr();
if (!menu)
return -1;
@ -697,12 +697,12 @@ static int action_ok_cheat_file_load(const char *path,
static int action_ok_menu_wallpaper_load(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
char wallpaper_path[PATH_MAX_LENGTH];
const char *menu_label = NULL;
const char *menu_path = NULL;
rarch_setting_t *setting = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
settings_t *settings = config_get_ptr();
char wallpaper_path[PATH_MAX_LENGTH] = {0};
const char *menu_label = NULL;
const char *menu_path = NULL;
rarch_setting_t *setting = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
settings_t *settings = config_get_ptr();
if (!menu)
return -1;
@ -732,9 +732,9 @@ static int action_ok_menu_wallpaper_load(const char *path,
static int action_ok_shader_preset_load(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
const char *menu_path = NULL;
char shader_path[PATH_MAX_LENGTH];
menu_handle_t *menu = menu_driver_get_ptr();
const char *menu_path = NULL;
char shader_path[PATH_MAX_LENGTH] = {0};
menu_handle_t *menu = menu_driver_get_ptr();
if (!menu)
return -1;
@ -790,15 +790,14 @@ static int action_ok_remap_file_save_as(const char *path,
static int action_ok_remap_file_save_core(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
global_t *global = global_get_ptr();
settings_t *settings = config_get_ptr();
char directory[PATH_MAX_LENGTH] = {0};
char file[PATH_MAX_LENGTH] = {0};
const char *core_name = NULL;
global_t *global = global_get_ptr();
settings_t *settings = config_get_ptr();
const char *core_name;
core_name = global->system.info.library_name;
char directory[PATH_MAX_LENGTH];
char file[PATH_MAX_LENGTH];
fill_pathname_join(directory,settings->input_remapping_directory,core_name,PATH_MAX_LENGTH);
fill_pathname_join(file,core_name,core_name,PATH_MAX_LENGTH);
@ -816,18 +815,16 @@ static int action_ok_remap_file_save_core(const char *path,
static int action_ok_remap_file_save_game(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
global_t *global = global_get_ptr();
settings_t *settings = config_get_ptr();
const char *core_name = NULL;
const char *game_name = NULL;
char directory[PATH_MAX_LENGTH] = {0};
char file[PATH_MAX_LENGTH] = {0};
global_t *global = global_get_ptr();
settings_t *settings = config_get_ptr();
const char *core_name;
core_name = global->system.info.library_name;
const char *game_name;
game_name = path_basename(global->basename);
char directory[PATH_MAX_LENGTH];
char file[PATH_MAX_LENGTH];
fill_pathname_join(directory,settings->input_remapping_directory,core_name,PATH_MAX_LENGTH);
fill_pathname_join(file,core_name,game_name,PATH_MAX_LENGTH);
@ -851,7 +848,7 @@ static int action_ok_path_use_directory(const char *path,
static int action_ok_core_deferred_set(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
char core_display_name[PATH_MAX_LENGTH];
char core_display_name[PATH_MAX_LENGTH] = {0};
menu_handle_t *menu = menu_driver_get_ptr();
if (!menu)
return -1;
@ -904,7 +901,7 @@ static int action_ok_database_manager_list_deferred(const char *path,
static int action_ok_rdb_entry(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
char tmp[PATH_MAX_LENGTH];
char tmp[PATH_MAX_LENGTH] = {0};
menu_displaylist_info_t info = {0};
menu_handle_t *menu = menu_driver_get_ptr();
if (!menu)
@ -993,10 +990,10 @@ static int action_ok_compressed_archive_push(const char *path,
static int action_ok_directory_push(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
menu_displaylist_info_t info = {0};
const char *menu_path = NULL;
const char *menu_label = NULL;
char cat_path[PATH_MAX_LENGTH];
menu_displaylist_info_t info = {0};
const char *menu_path = NULL;
const char *menu_label = NULL;
char cat_path[PATH_MAX_LENGTH] = {0};
menu_handle_t *menu = menu_driver_get_ptr();
if (!menu)
return -1;
@ -1021,10 +1018,10 @@ static int action_ok_directory_push(const char *path,
static int action_ok_database_manager_list(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
char rdb_path[PATH_MAX_LENGTH];
menu_displaylist_info_t info = {0};
menu_handle_t *menu = menu_driver_get_ptr();
settings_t *settings = config_get_ptr();
char rdb_path[PATH_MAX_LENGTH] = {0};
menu_displaylist_info_t info = {0};
menu_handle_t *menu = menu_driver_get_ptr();
settings_t *settings = config_get_ptr();
if (!menu)
return -1;
@ -1048,10 +1045,10 @@ static int action_ok_database_manager_list(const char *path,
static int action_ok_cursor_manager_list(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
char cursor_path[PATH_MAX_LENGTH];
menu_displaylist_info_t info = {0};
menu_handle_t *menu = menu_driver_get_ptr();
settings_t *settings = config_get_ptr();
char cursor_path[PATH_MAX_LENGTH] = {0};
menu_displaylist_info_t info = {0};
menu_handle_t *menu = menu_driver_get_ptr();
settings_t *settings = config_get_ptr();
if (!menu)
return -1;
@ -1071,9 +1068,9 @@ static int action_ok_cursor_manager_list(const char *path,
static int action_ok_config_load(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
const char *menu_path = NULL;
char config[PATH_MAX_LENGTH];
menu_handle_t *menu = menu_driver_get_ptr();
const char *menu_path = NULL;
char config[PATH_MAX_LENGTH] = {0};
menu_handle_t *menu = menu_driver_get_ptr();
if (!menu)
return -1;
@ -1096,9 +1093,9 @@ static int action_ok_config_load(const char *path,
static int action_ok_disk_image_append(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
char image[PATH_MAX_LENGTH];
const char *menu_path = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
char image[PATH_MAX_LENGTH] = {0};
const char *menu_path = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
if (!menu)
return -1;
@ -1239,8 +1236,9 @@ static int action_ok_core_updater_download(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
#ifdef HAVE_NETWORKING
char core_path[PATH_MAX_LENGTH], msg[PATH_MAX_LENGTH];
settings_t *settings = config_get_ptr();
char core_path[PATH_MAX_LENGTH] = {0};
char msg[PATH_MAX_LENGTH] = {0};
settings_t *settings = config_get_ptr();
fill_pathname_join(core_path, settings->network.buildbot_url,
path, sizeof(core_path));
@ -1336,13 +1334,13 @@ static int action_ok_rdb_entry_submenu(const char *path,
{
int ret;
union string_list_elem_attr attr;
char new_label[PATH_MAX_LENGTH];
menu_displaylist_info_t info = {0};
char *rdb = NULL;
int len = 0;
struct string_list *str_list = NULL;
struct string_list *str_list2 = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
char new_label[PATH_MAX_LENGTH] = {0};
menu_displaylist_info_t info = {0};
char *rdb = NULL;
int len = 0;
struct string_list *str_list = NULL;
struct string_list *str_list2 = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
if (!menu)
return -1;

View File

@ -432,7 +432,7 @@ static int menu_cbs_init_bind_right_compare_label(menu_file_list_cbs_t *cbs,
for (i = 0; i < MAX_USERS; i++)
{
char label_setting[PATH_MAX_LENGTH];
char label_setting[PATH_MAX_LENGTH] = {0};
snprintf(label_setting, sizeof(label_setting), "input_player%d_joypad_index", i + 1);
if (!strcmp(label, label_setting))

View File

@ -23,10 +23,10 @@
static int action_scan_file(const char *path,
const char *label, unsigned type, size_t idx)
{
char fullpath[PATH_MAX_LENGTH];
const char *menu_label = NULL;
const char *menu_path = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
char fullpath[PATH_MAX_LENGTH] = {0};
const char *menu_label = NULL;
const char *menu_path = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
if (!menu)
return -1;
@ -42,10 +42,10 @@ static int action_scan_file(const char *path,
static int action_scan_directory(const char *path,
const char *label, unsigned type, size_t idx)
{
char fullpath[PATH_MAX_LENGTH];
const char *menu_label = NULL;
const char *menu_path = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
char fullpath[PATH_MAX_LENGTH] = {0};
const char *menu_label = NULL;
const char *menu_path = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
if (!menu)
return -1;

View File

@ -23,8 +23,8 @@
static int action_select_default(const char *path, const char *label, unsigned type,
size_t idx)
{
int ret = 0;
menu_entry_t entry;
int ret = 0;
enum menu_action action = MENU_ACTION_NOOP;
menu_file_list_cbs_t *cbs = NULL;
menu_list_t *menu_list = menu_list_get_ptr();

View File

@ -27,6 +27,9 @@ static int action_start_remap_file_load(unsigned type, const char *label)
{
settings_t *settings = config_get_ptr();
if (!settings)
return -1;
settings->input.remapping_path[0] = '\0';
input_remapping_set_defaults();
return 0;
@ -36,6 +39,9 @@ static int action_start_video_filter_file_load(unsigned type, const char *label)
{
settings_t *settings = config_get_ptr();
if (!settings)
return -1;
settings->video.softfilter_plugin[0] = '\0';
event_command(EVENT_CMD_REINIT);
return 0;
@ -60,7 +66,7 @@ static int action_start_performance_counters_core(unsigned type, const char *lab
static int action_start_input_desc(unsigned type, const char *label)
{
settings_t *settings = config_get_ptr();
settings_t *settings = config_get_ptr();
unsigned inp_desc_index_offset = type - MENU_SETTINGS_INPUT_DESC_BEGIN;
unsigned inp_desc_user = inp_desc_index_offset / (RARCH_FIRST_CUSTOM_BIND + 4);
unsigned inp_desc_button_index_offset = inp_desc_index_offset - (inp_desc_user * (RARCH_FIRST_CUSTOM_BIND + 4));
@ -259,9 +265,7 @@ static int action_start_core_setting(unsigned type,
static int action_start_lookup_setting(unsigned type, const char *label)
{
int ret = menu_setting_set(type, label, MENU_ACTION_START, false);
return ret;
return menu_setting_set(type, label, MENU_ACTION_START, false);
}
int menu_cbs_init_bind_start_compare_label(menu_file_list_cbs_t *cbs,

View File

@ -21,14 +21,15 @@
static INLINE void replace_chars(char *str, char c1, char c2)
{
char *pos;
char *pos = NULL;
while((pos = strchr(str, c1)))
*pos = c2;
}
static INLINE void sanitize_to_string(char *s, const char *label, size_t len)
{
char new_label[PATH_MAX_LENGTH];
char new_label[PATH_MAX_LENGTH] = {0};
strlcpy(new_label, label, sizeof(new_label));
strlcpy(s, string_to_upper(new_label), len);
replace_chars(s, '_', ' ');
@ -135,10 +136,9 @@ static int action_get_title_video_shader_preset(const char *path, const char *la
static int action_get_title_generic(char *s, size_t len, const char *path,
const char *text)
{
char elem0_path[PATH_MAX_LENGTH], elem1_path[PATH_MAX_LENGTH];
struct string_list *list_path = string_split(path, "|");
*elem0_path = *elem1_path = 0;
char elem0_path[PATH_MAX_LENGTH] = {0};
char elem1_path[PATH_MAX_LENGTH] = {0};
struct string_list *list_path = string_split(path, "|");
if (list_path)
{
@ -150,6 +150,7 @@ static int action_get_title_generic(char *s, size_t len, const char *path,
}
string_list_free(list_path);
}
snprintf(s, len, "%s - %s", text,
(elem0_path[0] != '\0') ? path_basename(elem0_path) : "");
@ -293,7 +294,8 @@ static int action_get_title_default(const char *path, const char *label,
static int action_get_title_group_settings(const char *path, const char *label,
unsigned menu_type, char *s, size_t len)
{
char elem0[PATH_MAX_LENGTH], elem1[PATH_MAX_LENGTH];
char elem0[PATH_MAX_LENGTH] = {0};
char elem1[PATH_MAX_LENGTH] = {0};
struct string_list *list_label = string_split(label, "|");
if (list_label)
@ -308,11 +310,13 @@ static int action_get_title_group_settings(const char *path, const char *label,
}
strlcpy(s, string_to_upper(elem0), len);
if (elem1[0] != '\0')
{
strlcat(s, " - ", len);
strlcat(s, string_to_upper(elem1), len);
}
return 0;
}

View File

@ -203,23 +203,23 @@ void menu_display_free_main_font(menu_handle_t *menu)
bool menu_display_init_main_font(menu_handle_t *menu,
const char *font_path, float font_size)
{
bool ret;
driver_t *driver = driver_get_ptr();
void *video = video_driver_get_ptr(NULL);
bool result;
if (menu->font.buf)
menu_display_free_main_font(menu);
result = menu_display_font_init_first(
ret = menu_display_font_init_first(
(const void**)&driver->font_osd_driver, &menu->font.buf, video,
font_path, font_size);
if (result)
if (ret)
menu->font.size = font_size;
else
menu->font.buf = NULL;
return result;
return ret;
}
void menu_display_set_viewport(void)