From e675ea7e29dbf950a4be4d17a6fd57895cdf6c86 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Mon, 9 Sep 2024 15:22:08 +0200 Subject: [PATCH] Variable cleanups - add TODO/FIXME notes for spurious variable sizes --- core_info.c | 3 +- file_path_special.c | 18 +- gfx/gfx_thumbnail.c | 6 +- gfx/gfx_thumbnail_path.c | 108 ++++---- gfx/video_shader_parse.c | 137 +++++----- gfx/widgets/gfx_widget_leaderboard_display.c | 5 +- .../gfx_widget_load_content_animation.c | 10 +- input/input_driver.c | 5 +- menu/cbs/menu_cbs_ok.c | 32 ++- menu/drivers/materialui.c | 40 +-- menu/drivers/ozone.c | 44 ++-- menu/drivers/rgui.c | 20 +- menu/drivers/xmb.c | 16 +- menu/menu_contentless_cores.c | 4 +- menu/menu_driver.c | 84 ++++--- menu/menu_entries.h | 10 +- menu/menu_setting.c | 2 +- runloop.h | 20 +- tasks/task_content.c | 234 +++++++++--------- tasks/task_pl_thumbnail_download.c | 4 +- tasks/task_playlist_manager.c | 210 ++++++++-------- tasks/task_translation.c | 13 +- 22 files changed, 517 insertions(+), 508 deletions(-) diff --git a/core_info.c b/core_info.c index 86b08e8ace..c720a20478 100644 --- a/core_info.c +++ b/core_info.c @@ -2032,8 +2032,7 @@ static core_info_list_t *core_info_list_new(const char *path, /* Read core info cache, if enabled */ if (enable_cache) { - core_info_cache_list = core_info_cache_read(info_dir); - if (!core_info_cache_list) + if (!(core_info_cache_list = core_info_cache_read(info_dir))) goto error; } #endif diff --git a/file_path_special.c b/file_path_special.c index d81cf70e41..68a71eca18 100644 --- a/file_path_special.c +++ b/file_path_special.c @@ -210,13 +210,13 @@ void fill_pathname_application_special(char *s, case APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS: #ifdef HAVE_XMB { - char temp_path[PATH_MAX_LENGTH]; - char temp_dir[DIR_MAX_LENGTH]; + char tmp_path[PATH_MAX_LENGTH]; + char tmp_dir[DIR_MAX_LENGTH]; settings_t *settings = config_get_ptr(); const char *dir_assets = settings->paths.directory_assets; - fill_pathname_join_special(temp_dir, dir_assets, "xmb", sizeof(temp_dir)); - fill_pathname_join_special(temp_path, temp_dir, xmb_theme_ident(), sizeof(temp_path)); - fill_pathname_join_special(s, temp_path, "png", len); + fill_pathname_join_special(tmp_dir, dir_assets, "xmb", sizeof(tmp_dir)); + fill_pathname_join_special(tmp_path, tmp_dir, xmb_theme_ident(), sizeof(tmp_path)); + fill_pathname_join_special(s, tmp_path, "png", len); } #endif break; @@ -231,13 +231,13 @@ void fill_pathname_application_special(char *s, else { char tmp_dir[DIR_MAX_LENGTH]; + char tmp_dir2[DIR_MAX_LENGTH]; char tmp_path[PATH_MAX_LENGTH]; - char tmp_path2[PATH_MAX_LENGTH]; const char *dir_assets = settings->paths.directory_assets; fill_pathname_join_special(tmp_dir, dir_assets, "xmb", sizeof(tmp_dir)); - fill_pathname_join_special(tmp_path, tmp_dir, xmb_theme_ident(), sizeof(tmp_path)); - fill_pathname_join_special(tmp_path2, tmp_path, "png", sizeof(tmp_path2)); - fill_pathname_join_special(s, tmp_path2, FILE_PATH_BACKGROUND_IMAGE, len); + fill_pathname_join_special(tmp_dir2, tmp_dir, xmb_theme_ident(), sizeof(tmp_dir2)); + fill_pathname_join_special(tmp_path, tmp_dir2, "png", sizeof(tmp_path)); + fill_pathname_join_special(s, tmp_path, FILE_PATH_BACKGROUND_IMAGE, len); } } #endif diff --git a/gfx/gfx_thumbnail.c b/gfx/gfx_thumbnail.c index 0e1c48ec30..5996843b8c 100644 --- a/gfx/gfx_thumbnail.c +++ b/gfx/gfx_thumbnail.c @@ -289,11 +289,11 @@ void gfx_thumbnail_request( /* Handle on demand thumbnail downloads */ else if (network_on_demand_thumbnails) { + enum playlist_thumbnail_name_flags curr_flag; const char *system = NULL; const char *img_name = NULL; - static char last_img_name[PATH_MAX_LENGTH] = {0}; + static char last_img_name[NAME_MAX_LENGTH] = {0}; settings_t *settings = config_get_ptr(); - enum playlist_thumbnail_name_flags curr_flag; if (!playlist) goto end; @@ -328,7 +328,7 @@ void gfx_thumbnail_request( if (curr_flag & PLAYLIST_THUMBNAIL_FLAG_NONE || curr_flag & PLAYLIST_THUMBNAIL_FLAG_SHORT_NAME) goto end; /* Do not try to fetch full names here, if it is not explicitly wanted */ - if (!settings->bools.playlist_use_filename && + if (!settings->bools.playlist_use_filename && !playlist_thumbnail_match_with_filename(playlist) && curr_flag == PLAYLIST_THUMBNAIL_FLAG_INVALID) playlist_update_thumbnail_name_flag(playlist, idx, PLAYLIST_THUMBNAIL_FLAG_FULL_NAME); diff --git a/gfx/gfx_thumbnail_path.c b/gfx/gfx_thumbnail_path.c index b484f35992..4374a433c7 100644 --- a/gfx/gfx_thumbnail_path.c +++ b/gfx/gfx_thumbnail_path.c @@ -39,17 +39,15 @@ * content_label field (for internal use only) */ static void gfx_thumbnail_fill_content_img(char *s, size_t len, const char *src, bool shorten) { - const char *cut = " ("; char *scrub_char_ptr = NULL; /* Copy source label string */ size_t _len = strlcpy(s, src, len); - int bracketpos = -1; /* Shortening logic: up to first space + bracket */ if (shorten) { - bracketpos = string_find_index_substring_string(src, cut); - if (bracketpos > 0) + int bracketpos = -1; + if ((bracketpos = string_find_index_substring_string(src, " (")) > 0) _len = bracketpos; /* Explicit zero if short name is same as standard name - saves some queries later. */ else @@ -265,7 +263,7 @@ bool gfx_thumbnail_set_system(gfx_thumbnail_path_data_t *path_data, * i.e. check whether the cached playlist file * matches the database name */ char *playlist_name = NULL; - char tmp[PATH_MAX_LENGTH]; + char tmp[NAME_MAX_LENGTH]; strlcpy(tmp, playlist_file, sizeof(tmp)); playlist_name = path_remove_extension(tmp); playlist_valid = string_is_equal(playlist_name, system); @@ -482,7 +480,7 @@ bool gfx_thumbnail_set_content_playlist( /* Determine content image name */ { char* content_name_no_ext = NULL; - char tmp_buf[PATH_MAX_LENGTH]; + char tmp_buf[NAME_MAX_LENGTH]; /* Remove rom file extension * > path_remove_extension() requires a char * (not const) * so have to use a temporary buffer... */ @@ -497,11 +495,11 @@ bool gfx_thumbnail_set_content_playlist( sizeof(path_data->content_img_full), content_name_no_ext,false); gfx_thumbnail_fill_content_img(path_data->content_img, sizeof(path_data->content_img), path_data->content_label,false); + /* Explicit zero if full name is same as standard name - saves some queries later. */ - if(strcmp(path_data->content_img, path_data->content_img_full) == 0) - { + if(string_is_equal(path_data->content_img, path_data->content_img_full)) path_data->content_img_full[0] = '\0'; - } + gfx_thumbnail_fill_content_img(path_data->content_img_short, sizeof(path_data->content_img_short), path_data->content_label,true); } @@ -530,21 +528,20 @@ bool gfx_thumbnail_set_content_playlist( } else { + char tmp_buf[NAME_MAX_LENGTH]; char *db_name_no_ext = NULL; - char tmp_buf[PATH_MAX_LENGTH]; - const char* pos = strchr(db_name, '|'); + const char *pos = strchr(db_name, '|'); - if (pos && (size_t) (pos - db_name)+1 < sizeof(tmp_buf)) { - /* If db_name comes from core info, and there are multiple - * databases mentioned separated by |, use only first one */ - strlcpy(tmp_buf, db_name, (size_t) (pos - db_name)+1); - } - else { + /* If db_name comes from core info, and there are multiple + * databases mentioned separated by |, use only first one */ + if (pos && (size_t) (pos - db_name) + 1 < sizeof(tmp_buf)) + strlcpy(tmp_buf, db_name, (size_t)(pos - db_name) + 1); + else /* Remove .lpl extension * > path_remove_extension() requires a char * (not const) * so have to use a temporary buffer... */ strlcpy(tmp_buf, db_name, sizeof(tmp_buf)); - } + db_name_no_ext = path_remove_extension(tmp_buf); if (!string_is_empty(db_name_no_ext)) @@ -643,7 +640,7 @@ bool gfx_thumbnail_set_icon_playlist( /* Determine content image name */ { - char tmp_buf[PATH_MAX_LENGTH]; + char tmp_buf[NAME_MAX_LENGTH]; char* content_name_no_ext = NULL; /* Remove rom file extension * > path_remove_extension() requires a char * (not const) @@ -658,11 +655,11 @@ bool gfx_thumbnail_set_icon_playlist( sizeof(path_data->content_img_full), content_name_no_ext,false); gfx_thumbnail_fill_content_img(path_data->content_img, sizeof(path_data->content_img), path_data->content_label,false); + /* Explicit zero if full name is same as standard name - saves some queries later. */ - if(strcmp(path_data->content_img, path_data->content_img_full) == 0) - { + if(string_is_equal(path_data->content_img, path_data->content_img_full)) path_data->content_img_full[0] = '\0'; - } + gfx_thumbnail_fill_content_img(path_data->content_img_short, sizeof(path_data->content_img_short), path_data->content_label,true); } @@ -691,22 +688,19 @@ bool gfx_thumbnail_set_icon_playlist( } else { + char tmp_buf[NAME_MAX_LENGTH]; char *db_name_no_ext = NULL; - char tmp_buf[PATH_MAX_LENGTH]; - const char* pos = strchr(db_name, '|'); + const char* pos = strchr(db_name, '|'); - if (pos && (size_t) (pos - db_name)+1 < sizeof(tmp_buf)) { - /* If db_name comes from core info, and there are multiple - * databases mentioned separated by |, use only first one */ + /* If db_name comes from core info, and there are multiple + * databases mentioned separated by |, use only first one */ + if (pos && (size_t) (pos - db_name)+1 < sizeof(tmp_buf)) strlcpy(tmp_buf, db_name, (size_t) (pos - db_name)+1); - } else - { /* Remove .lpl extension * > path_remove_extension() requires a char * (not const) * so have to use a temporary buffer... */ strlcpy(tmp_buf, db_name, sizeof(tmp_buf)); - } db_name_no_ext = path_remove_extension(tmp_buf); if (!string_is_empty(db_name_no_ext)) @@ -824,7 +818,7 @@ bool gfx_thumbnail_update_path( } else { - char tmp_buf[PATH_MAX_LENGTH]; + char tmp_buf[DIR_MAX_LENGTH]; const char *type = gfx_thumbnail_get_type(settings, path_data, thumbnail_id); int i; @@ -840,50 +834,53 @@ bool gfx_thumbnail_update_path( thumbnail_path[0] = '\0'; /* >> Add content image - first try with full file name */ - if(path_data->content_img_full[0] != '\0') { + if (path_data->content_img_full[0] != '\0') fill_pathname_join_special(thumbnail_path, tmp_buf, path_data->content_img_full, PATH_MAX_LENGTH * sizeof(char)); - } thumbnail_found = path_is_valid(thumbnail_path); /* Try alternative file extensions in turn, if wanted */ - for( i=1 ; - settings->bools.playlist_allow_non_png && - !thumbnail_found && - thumbnail_path[0]!='\0' && - ibools.playlist_allow_non_png + && !thumbnail_found + && thumbnail_path[0]!='\0' + && i < MAX_SUPPORTED_THUMBNAIL_EXTENSIONS; i++ ) { strlcpy(path_get_extension_mutable(thumbnail_path),SUPPORTED_THUMBNAIL_EXTENSIONS[i],6); thumbnail_found = path_is_valid(thumbnail_path); } + /* >> Add content image - second try with label (database name) */ - if(!thumbnail_found && path_data->content_img[0] != '\0') + if (!thumbnail_found && path_data->content_img[0] != '\0') { thumbnail_path[0] = '\0'; fill_pathname_join_special(thumbnail_path, tmp_buf, path_data->content_img, PATH_MAX_LENGTH * sizeof(char)); thumbnail_found = path_is_valid(thumbnail_path); } - for( i=1 ; - settings->bools.playlist_allow_non_png && - !thumbnail_found && - ibools.playlist_allow_non_png + && !thumbnail_found + && i < MAX_SUPPORTED_THUMBNAIL_EXTENSIONS ; i++ ) { strlcpy(path_get_extension_mutable(thumbnail_path),SUPPORTED_THUMBNAIL_EXTENSIONS[i],6); thumbnail_found = path_is_valid(thumbnail_path); } + /* >> Add content image - third try with shortened name (title only) */ - if(!thumbnail_found && path_data->content_img_short[0] != '\0') + if (!thumbnail_found && path_data->content_img_short[0] != '\0') { thumbnail_path[0] = '\0'; fill_pathname_join_special(thumbnail_path, tmp_buf, path_data->content_img_short, PATH_MAX_LENGTH * sizeof(char)); thumbnail_found = path_is_valid(thumbnail_path); } - for( i=1 ; - settings->bools.playlist_allow_non_png && - !thumbnail_found && - ibools.playlist_allow_non_png + && !thumbnail_found + && i < MAX_SUPPORTED_THUMBNAIL_EXTENSIONS ; i++ ) { strlcpy(path_get_extension_mutable(thumbnail_path),SUPPORTED_THUMBNAIL_EXTENSIONS[i],6); thumbnail_found = path_is_valid(thumbnail_path); @@ -997,22 +994,23 @@ bool gfx_thumbnail_get_img_name( { if (!path_data || !img_name || name_flags == PLAYLIST_THUMBNAIL_FLAG_NONE) return false; - if (name_flags & PLAYLIST_THUMBNAIL_FLAG_SHORT_NAME) { + + if (name_flags & PLAYLIST_THUMBNAIL_FLAG_SHORT_NAME) + { if (string_is_empty(path_data->content_img_short)) return false; - *img_name = path_data->content_img_short; } - else if (name_flags & PLAYLIST_THUMBNAIL_FLAG_STD_NAME) { + else if (name_flags & PLAYLIST_THUMBNAIL_FLAG_STD_NAME) + { if (string_is_empty(path_data->content_img)) return false; - *img_name = path_data->content_img; } - else if (name_flags & PLAYLIST_THUMBNAIL_FLAG_FULL_NAME) { + else if (name_flags & PLAYLIST_THUMBNAIL_FLAG_FULL_NAME) + { if (string_is_empty(path_data->content_img_full)) return false; - *img_name = path_data->content_img_full; } else @@ -1027,7 +1025,7 @@ bool gfx_thumbnail_get_content_dir( gfx_thumbnail_path_data_t *path_data, char *content_dir, size_t len) { size_t path_length; - char tmp_buf[PATH_MAX_LENGTH]; + char tmp_buf[NAME_MAX_LENGTH]; const char *last_slash = NULL; if (!path_data || string_is_empty(path_data->content_path)) diff --git a/gfx/video_shader_parse.c b/gfx/video_shader_parse.c index 272de3a37c..306ec57b46 100644 --- a/gfx/video_shader_parse.c +++ b/gfx/video_shader_parse.c @@ -222,7 +222,7 @@ static void video_shader_replace_wildcards(char *inout_absolute_path, /* If the wildcard text is in the path then process it */ if (strstr(replaced_path, wildcard_tokens[i].token_name)) { - char replace_text[PATH_MAX_LENGTH] = ""; + char replace_text[PATH_MAX_LENGTH]; switch (wildcard_tokens[i].token_id) { @@ -243,6 +243,8 @@ static void video_shader_replace_wildcards(char *inout_absolute_path, if (string_is_not_equal_fast(content_dir_name, "", sizeof(""))) strlcpy(replace_text, content_dir_name, sizeof(replace_text)); + else + replace_text[0] = '\0'; } break; case RARCH_WILDCARD_CORE: @@ -255,6 +257,8 @@ static void video_shader_replace_wildcards(char *inout_absolute_path, path_basename = path_basename_nocompression(path_basename); if (path_basename) strlcpy(replace_text, path_basename, sizeof(replace_text)); + else + replace_text[0] = '\0'; } break; case RARCH_WILDCARD_VIDEO_DRIVER: @@ -343,16 +347,20 @@ static void video_shader_replace_wildcards(char *inout_absolute_path, path_remove_extension(preset_dir_name); if (string_is_not_equal_fast(preset_dir_name, "", sizeof(""))) strlcpy(replace_text, preset_dir_name, sizeof(replace_text)); + else + replace_text[0] = '\0'; } break; case RARCH_WILDCARD_PRESET: { - char preset_name[PATH_MAX_LENGTH]; + char preset_name[NAME_MAX_LENGTH]; strlcpy(preset_name, path_basename_nocompression(in_preset_path), sizeof(preset_name)); if (string_is_not_equal_fast(preset_name, "", sizeof(""))) path_remove_extension(preset_name); if (string_is_not_equal_fast(preset_name, "", sizeof(""))) strlcpy(replace_text, preset_name, sizeof(replace_text)); + else + replace_text[0] = '\0'; } break; case RARCH_WILDCARD_VIDEO_DRIVER_SHADER_EXT: @@ -362,6 +370,8 @@ static void video_shader_replace_wildcards(char *inout_absolute_path, strlcpy(replace_text, "glsl", sizeof(replace_text)); else if (video_shader_is_supported(RARCH_SHADER_SLANG)) strlcpy(replace_text, "slang", sizeof(replace_text)); + else + replace_text[0] = '\0'; break; case RARCH_WILDCARD_VIDEO_DRIVER_PRESET_EXT: if (video_shader_is_supported(RARCH_SHADER_CG)) @@ -370,10 +380,14 @@ static void video_shader_replace_wildcards(char *inout_absolute_path, strlcpy(replace_text, "glslp", sizeof(replace_text)); else if (video_shader_is_supported(RARCH_SHADER_SLANG)) strlcpy(replace_text, "slangp", sizeof(replace_text)); + else + replace_text[0] = '\0'; break; } { - char *replace_output = string_replace_substring(replaced_path, + char *replace_output; + replace_text[0] = '\0'; + replace_output = string_replace_substring(replaced_path, wildcard_tokens[i].token_name, strlen(wildcard_tokens[i].token_name), replace_text, @@ -1155,7 +1169,7 @@ static bool video_shader_write_root_preset(const struct video_shader *shader, if (shader->luts) { - char textures[4096]; + char textures[4096]; /* TODO/FIXME - check size */ /* Names of the textures */ size_t _len = strlcpy(textures, shader->lut[0].id, sizeof(textures)); @@ -1884,10 +1898,10 @@ static bool video_shader_load_root_config_into_shader( { union string_list_elem_attr attr; int flags = - PATH_CHANGE_TYPE_MODIFIED | - PATH_CHANGE_TYPE_WRITE_FILE_CLOSED | - PATH_CHANGE_TYPE_FILE_MOVED | - PATH_CHANGE_TYPE_FILE_DELETED; + PATH_CHANGE_TYPE_MODIFIED + | PATH_CHANGE_TYPE_WRITE_FILE_CLOSED + | PATH_CHANGE_TYPE_FILE_MOVED + | PATH_CHANGE_TYPE_FILE_DELETED; struct string_list file_list = {0}; attr.i = 0; @@ -2394,10 +2408,10 @@ bool video_shader_any_supported(void) video_context_driver_get_flags(&flags); return - BIT32_GET(flags.flags, GFX_CTX_FLAGS_SHADERS_SLANG) || - BIT32_GET(flags.flags, GFX_CTX_FLAGS_SHADERS_GLSL) || - BIT32_GET(flags.flags, GFX_CTX_FLAGS_SHADERS_CG) || - BIT32_GET(flags.flags, GFX_CTX_FLAGS_SHADERS_HLSL); + BIT32_GET(flags.flags, GFX_CTX_FLAGS_SHADERS_SLANG) + || BIT32_GET(flags.flags, GFX_CTX_FLAGS_SHADERS_GLSL) + || BIT32_GET(flags.flags, GFX_CTX_FLAGS_SHADERS_CG) + || BIT32_GET(flags.flags, GFX_CTX_FLAGS_SHADERS_HLSL); } enum rarch_shader_type video_shader_get_type_from_ext( @@ -2411,25 +2425,22 @@ enum rarch_shader_type video_shader_get_type_from_ext( if (is_preset) *is_preset = - string_is_equal_case_insensitive(ext, "cgp") || - string_is_equal_case_insensitive(ext, "glslp") || - string_is_equal_case_insensitive(ext, "slangp"); + string_is_equal_case_insensitive(ext, "cgp") + || string_is_equal_case_insensitive(ext, "glslp") + || string_is_equal_case_insensitive(ext, "slangp"); - if (string_is_equal_case_insensitive(ext, "cgp") || - string_is_equal_case_insensitive(ext, "cg") + if ( string_is_equal_case_insensitive(ext, "cgp") + || string_is_equal_case_insensitive(ext, "cg") ) return RARCH_SHADER_CG; - - if (string_is_equal_case_insensitive(ext, "glslp") || - string_is_equal_case_insensitive(ext, "glsl") + if ( string_is_equal_case_insensitive(ext, "glslp") + || string_is_equal_case_insensitive(ext, "glsl") ) return RARCH_SHADER_GLSL; - - if (string_is_equal_case_insensitive(ext, "slangp") || - string_is_equal_case_insensitive(ext, "slang") + if ( string_is_equal_case_insensitive(ext, "slangp") + || string_is_equal_case_insensitive(ext, "slang") ) return RARCH_SHADER_SLANG; - return RARCH_SHADER_NONE; } @@ -2472,8 +2483,8 @@ static bool video_shader_dir_init_shader_internal( size_t i; struct string_list *new_list = dir_list_new_special( shader_dir, DIR_LIST_SHADERS, NULL, show_hidden_files); - bool search_file_name = shader_remember_last_dir && - !string_is_empty(shader_file_name); + bool search_file_name = shader_remember_last_dir + && !string_is_empty(shader_file_name); if (!new_list) return false; @@ -2536,13 +2547,13 @@ static void video_shader_dir_init_shader( const char *last_shader_preset_dir = NULL; const char *last_shader_preset_file_name = NULL; video_driver_state_t *video_st = video_state_get_ptr(); + enum rarch_shader_type last_shader_preset_type = RARCH_SHADER_NONE; #if defined(HAVE_MENU) menu_handle_t *menu = (menu_handle_t*)menu_driver_data_; - enum rarch_shader_type last_shader_preset_type = menu ? menu->last_shader_selection.preset_type : RARCH_SHADER_NONE; + if (menu) + last_shader_preset_type = menu->last_shader_selection.preset_type; menu_driver_get_last_shader_preset_path( &last_shader_preset_dir, &last_shader_preset_file_name); -#else - enum rarch_shader_type last_shader_preset_type = RARCH_SHADER_NONE; #endif /* Always free existing shader list */ @@ -2550,10 +2561,10 @@ static void video_shader_dir_init_shader( video_shader_remember_last_dir); /* Try directory of last selected shader preset */ - if (shader_remember_last_dir && - (last_shader_preset_type != RARCH_SHADER_NONE) && - !string_is_empty(last_shader_preset_dir) && - video_shader_dir_init_shader_internal( + if ( shader_remember_last_dir + && (last_shader_preset_type != RARCH_SHADER_NONE) + && !string_is_empty(last_shader_preset_dir) + && video_shader_dir_init_shader_internal( video_shader_remember_last_dir, dir_list, last_shader_preset_dir, @@ -2564,26 +2575,26 @@ static void video_shader_dir_init_shader( /* Try directory of shader given as command line parameter */ if (!string_is_empty(video_st->cli_shader_path)) { - char cli_path[PATH_MAX_LENGTH]; - fill_pathname_basedir(cli_path, video_st->cli_shader_path, sizeof(cli_path)); - if (video_shader_dir_init_shader_internal( - video_shader_remember_last_dir, - dir_list, - cli_path, NULL, show_hidden_files)) - return; + char cli_path[PATH_MAX_LENGTH]; + fill_pathname_basedir(cli_path, video_st->cli_shader_path, sizeof(cli_path)); + if (video_shader_dir_init_shader_internal( + video_shader_remember_last_dir, + dir_list, + cli_path, NULL, show_hidden_files)) + return; } /* Try video shaders directory */ - if (!string_is_empty(directory_video_shader) && - video_shader_dir_init_shader_internal( + if ( !string_is_empty(directory_video_shader) + && video_shader_dir_init_shader_internal( video_shader_remember_last_dir, dir_list, directory_video_shader, NULL, show_hidden_files)) return; /* Try config directory */ - if (!string_is_empty(directory_menu_config) && - video_shader_dir_init_shader_internal( + if ( !string_is_empty(directory_menu_config) + && video_shader_dir_init_shader_internal( video_shader_remember_last_dir, dir_list, directory_menu_config, NULL, show_hidden_files)) @@ -2618,31 +2629,31 @@ void video_shader_dir_check_shader( const char *last_shader_preset_file_name = NULL; const char *set_shader_path = NULL; bool dir_list_initialised = false; + enum rarch_shader_type last_shader_preset_type = RARCH_SHADER_NONE; #if defined(HAVE_MENU) void *menu_ptr = menu_driver_data_; menu_handle_t *menu = (menu_handle_t*)menu_ptr; - enum rarch_shader_type last_shader_preset_type = menu ? menu->last_shader_selection.preset_type : RARCH_SHADER_NONE; + if (menu) + last_shader_preset_type = menu->last_shader_selection.preset_type; menu_driver_get_last_shader_preset_path( &last_shader_preset_dir, &last_shader_preset_file_name); #else void *menu_ptr = NULL; - enum rarch_shader_type last_shader_preset_type = RARCH_SHADER_NONE; #endif - /* Check whether shader list needs to be - * (re)initialised */ - if (!dir_list->shader_list || - (dir_list->remember_last_preset_dir != video_shader_remember_last_dir) || - (video_shader_remember_last_dir && - (last_shader_preset_type != RARCH_SHADER_NONE) && - !string_is_equal(dir_list->directory, last_shader_preset_dir))) + /* Check whether shader list needs to be (re)initialised */ + if ( !dir_list->shader_list + || (dir_list->remember_last_preset_dir != video_shader_remember_last_dir) + || (video_shader_remember_last_dir + && (last_shader_preset_type != RARCH_SHADER_NONE) + && !string_is_equal(dir_list->directory, last_shader_preset_dir))) { video_shader_dir_init_shader(menu_ptr, settings, dir_list); dir_list_initialised = true; } - if (!dir_list->shader_list || - (dir_list->shader_list->size < 1)) + if ( !dir_list->shader_list + || (dir_list->shader_list->size < 1)) return; /* Check whether a 'last used' shader file @@ -2652,10 +2663,10 @@ void video_shader_dir_check_shader( * twice. This is wasteful, but we cannot safely cache * the first result since video_shader_dir_init_shader() is called * in-between the two invocations... */ - if (video_shader_remember_last_dir && - (last_shader_preset_type != RARCH_SHADER_NONE) && - string_is_equal(dir_list->directory, last_shader_preset_dir) && - !string_is_empty(last_shader_preset_file_name)) + if ( video_shader_remember_last_dir + && (last_shader_preset_type != RARCH_SHADER_NONE) + && string_is_equal(dir_list->directory, last_shader_preset_dir) + && !string_is_empty(last_shader_preset_file_name)) { /* Ensure that we start with a dir_list selection * index matching the last used shader */ @@ -2670,8 +2681,8 @@ void video_shader_dir_check_shader( if (!string_is_empty(current_file_path)) current_file_name = path_basename(current_file_path); - if (!string_is_empty(current_file_name) && - !string_is_equal(current_file_name, last_shader_preset_file_name)) + if ( !string_is_empty(current_file_name) + && !string_is_equal(current_file_name, last_shader_preset_file_name)) { size_t i; for (i = 0; i < dir_list->shader_list->size; i++) @@ -2821,6 +2832,7 @@ static bool video_shader_load_shader_preset_internal( static bool video_shader_load_auto_shader_preset(settings_t *settings, const char *core_name, char *s, size_t len) { + size_t i; const char *video_shader_directory = settings->paths.directory_video_shader; const char *menu_config_directory = settings->paths.directory_menu_config; const char *rarch_path_basename = path_get(RARCH_PATH_BASENAME); @@ -2828,7 +2840,6 @@ static bool video_shader_load_auto_shader_preset(settings_t *settings, const cha const char *game_name = NULL; const char *dirs[3] = {0}; - size_t i = 0; char shader_path[PATH_MAX_LENGTH]; char content_dir_name[DIR_MAX_LENGTH]; @@ -2911,7 +2922,7 @@ bool video_shader_combine_preset_and_apply( { bool ret = false; char combined_preset_path[PATH_MAX_LENGTH]; - char combined_preset_name[PATH_MAX_LENGTH]; + char combined_preset_name[NAME_MAX_LENGTH]; const char *preset_ext = video_shader_get_preset_extension(type); struct video_shader *shader_to_append = (struct video_shader*) calloc(1, sizeof(*shader_to_append)); struct video_shader *combined_shader = (struct video_shader*) calloc(1, sizeof(*combined_shader)); diff --git a/gfx/widgets/gfx_widget_leaderboard_display.c b/gfx/widgets/gfx_widget_leaderboard_display.c index 74aa8fb4fb..e65cd6ab1a 100644 --- a/gfx/widgets/gfx_widget_leaderboard_display.c +++ b/gfx/widgets/gfx_widget_leaderboard_display.c @@ -15,11 +15,12 @@ * If not, see . */ +#include + #include "../gfx_display.h" #include "../gfx_widgets.h" #include "../../cheevos/cheevos.h" -#include #define CHEEVO_LBOARD_ARRAY_SIZE 4 #define CHEEVO_CHALLENGE_ARRAY_SIZE 8 @@ -79,7 +80,7 @@ static bool gfx_widget_leaderboard_display_init( gfx_animation_t *p_anim, bool video_is_threaded, bool fullscreen) { - gfx_widget_leaderboard_display_state_t *state = + gfx_widget_leaderboard_display_state_t *state = &p_w_leaderboard_display_st; memset(state, 0, sizeof(*state)); state->dispwidget_ptr = (const dispgfx_widget_t*) diff --git a/gfx/widgets/gfx_widget_load_content_animation.c b/gfx/widgets/gfx_widget_load_content_animation.c index 4d3cf869d1..4af32b4388 100644 --- a/gfx/widgets/gfx_widget_load_content_animation.c +++ b/gfx/widgets/gfx_widget_load_content_animation.c @@ -354,8 +354,8 @@ bool gfx_widget_start_load_content_animation(void) entry->core_path); /* Check whether core matches... */ - if (string_is_empty(entry_core_file) || - !string_starts_with(entry_core_file, + if ( string_is_empty(entry_core_file) + || !string_starts_with(entry_core_file, core_info->core_file_id.str)) entry = NULL; } @@ -404,9 +404,9 @@ bool gfx_widget_start_load_content_animation(void) state->system_name, new_system_name, sizeof(state->system_name)); /* Exclude history and favourites playlists */ - if (string_ends_with_size(state->system_name, "_history", - state->system_name_len, STRLEN_CONST("_history")) || - string_ends_with_size(state->system_name, "_favorites", + if ( string_ends_with_size(state->system_name, "_history", + state->system_name_len, STRLEN_CONST("_history")) + || string_ends_with_size(state->system_name, "_favorites", state->system_name_len, STRLEN_CONST("_favorites"))) state->system_name[0] = '\0'; diff --git a/input/input_driver.c b/input/input_driver.c index d877e23290..9c87944e59 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -541,7 +541,7 @@ float input_driver_get_sensor( void *current_data = input_driver_st.current_data; return current_driver->get_sensor_input(current_data, port, id); } - else if (sensors_enable && input_driver_st.primary_joypad && + else if (sensors_enable && input_driver_st.primary_joypad && input_driver_st.primary_joypad->get_sensor_input) { return input_driver_st.primary_joypad->get_sensor_input(NULL, @@ -3742,6 +3742,7 @@ size_t input_config_get_bind_string_joykey( && input_descriptor_label_show) return fill_pathname_join_delim(s, bind->joykey_label, suffix, ' ', len); + /* TODO/FIXME - localize */ _len = snprintf(s, len, "Hat #%u ", (unsigned)GET_HAT(bind->joykey)); switch (GET_HAT_DIR(bind->joykey)) @@ -3770,6 +3771,7 @@ size_t input_config_get_bind_string_joykey( && input_descriptor_label_show) return fill_pathname_join_delim(s, bind->joykey_label, suffix, ' ', len); + /* TODO/FIXME - localize */ _len = strlcpy(s, "Button ", len); _len += snprintf(s + _len, len - _len, "%u", (unsigned)bind->joykey); @@ -3788,6 +3790,7 @@ size_t input_config_get_bind_string_joyaxis( && input_descriptor_label_show) return fill_pathname_join_delim(s, bind->joyaxis_label, suffix, ' ', len); + /* TODO/FIXME - localize */ _len = strlcpy(s, "Axis ", len); if (AXIS_NEG_GET(bind->joyaxis) != AXIS_DIR_NONE) _len += snprintf(s + _len, len - _len, "-%u", diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 351454200c..f878230e09 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -2158,6 +2158,9 @@ static int generic_action_ok(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx, unsigned id, enum msg_hash_enums flush_id) { +#if IOS + char tmp_path[PATH_MAX_LENGTH]; +#endif char action_path[PATH_MAX_LENGTH]; unsigned flush_type = 0; int ret = 0; @@ -2182,7 +2185,6 @@ static int generic_action_ok(const char *path, &menu_label, NULL, &enum_idx, NULL); #if IOS - char tmp_path[PATH_MAX_LENGTH]; fill_pathname_expand_special(tmp_path, menu_path, sizeof(tmp_path)); menu_path = tmp_path; #endif @@ -2313,13 +2315,13 @@ static int generic_action_ok(const char *path, #ifdef HAVE_CONFIGFILE { char conf_key[64]; - config_file_t *conf = config_file_new_from_path_to_string( - action_path); retro_ctx_controller_info_t pad; unsigned current_device = 0; unsigned port = 0; int conf_val = 0; flush_char = msg_hash_to_str(flush_id); + config_file_t *conf = config_file_new_from_path_to_string( + action_path); conf_key[0] = '\0'; @@ -2605,9 +2607,7 @@ static bool playlist_entry_path_is_valid(const char *entry_path) * path_get_archive_delim() returns a const char * * (this cast is safe, though, and is done in many * places throughout the codebase...) */ - archive_delim = (char *)path_get_archive_delim(file_path); - - if (archive_delim) + if ((archive_delim = (char *)path_get_archive_delim(file_path))) { *archive_delim = '\0'; if (string_is_empty(file_path)) @@ -2670,30 +2670,28 @@ static int action_ok_playlist_entry_collection(const char *path, /* Get playlist */ if (!(tmp_playlist = playlist_get_cached())) { + enum playlist_sort_mode current_sort_mode; /* If playlist is not cached, have to load * it here * > Since the menu will always sort playlists * based on current user config, have to do * the same here - otherwise entry_idx may * go out of sync... */ - bool is_content_history = string_is_equal(menu->db_playlist_file, path_content_history) || - string_is_equal(menu->db_playlist_file, path_content_image_history) || - string_is_equal(menu->db_playlist_file, path_content_music_history) || - string_is_equal(menu->db_playlist_file, path_content_video_history); - - enum playlist_sort_mode current_sort_mode; + bool is_content_history = string_is_equal(menu->db_playlist_file, path_content_history) + || string_is_equal(menu->db_playlist_file, path_content_image_history) + || string_is_equal(menu->db_playlist_file, path_content_music_history) + || string_is_equal(menu->db_playlist_file, path_content_video_history); playlist_config_set_path(&playlist_config, menu->db_playlist_file); - tmp_playlist = playlist_init(&playlist_config); - if (!tmp_playlist) + if (!(tmp_playlist = playlist_init(&playlist_config))) goto error; current_sort_mode = playlist_get_sort_mode(tmp_playlist); - if (!is_content_history && - ((playlist_sort_alphabetical && (current_sort_mode == PLAYLIST_SORT_MODE_DEFAULT)) || - (current_sort_mode == PLAYLIST_SORT_MODE_ALPHABETICAL))) + if ( !is_content_history + && ((playlist_sort_alphabetical && (current_sort_mode == PLAYLIST_SORT_MODE_DEFAULT)) + || (current_sort_mode == PLAYLIST_SORT_MODE_ALPHABETICAL))) playlist_qsort(tmp_playlist); playlist_initialized = true; diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index dc0ee1d1c9..0743016f3b 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -515,7 +515,7 @@ typedef struct unsigned height; float delay_timer; float alpha; - char str[MENU_SUBLABEL_MAX_LENGTH]; + char str[MENU_LABEL_MAX_LENGTH]; char runtime_fallback_str[NAME_MAX_LENGTH]; char last_played_fallback_str[NAME_MAX_LENGTH]; } materialui_status_bar_t; @@ -2596,7 +2596,7 @@ static void materialui_render_messagebox( int usable_width = 0; int longest_width = 0; struct string_list list = {0}; - char wrapped_message[MENU_SUBLABEL_MAX_LENGTH]; + char wrapped_message[MENU_LABEL_MAX_LENGTH]; wrapped_message[0] = '\0'; @@ -2752,7 +2752,7 @@ static uint8_t materialui_count_sublabel_lines( size_t entry_idx, bool has_icon) { menu_entry_t entry; - char wrapped_sublabel_str[MENU_SUBLABEL_MAX_LENGTH]; + char wrapped_sublabel_str[MENU_LABEL_MAX_LENGTH]; int sublabel_width_max = 0; settings_t *settings = config_get_ptr(); @@ -4204,7 +4204,7 @@ static void materialui_render_menu_entry_default( * (rounded up) */ int vertical_margin = ((node->entry_height - node->text_height) / 2.0f) - (float)mui->sublabel_gap + 1.0f; int sublabel_y; - char wrapped_sublabel[MENU_SUBLABEL_MAX_LENGTH]; + char wrapped_sublabel[MENU_LABEL_MAX_LENGTH]; wrapped_sublabel[0] = '\0'; @@ -4564,7 +4564,7 @@ static void materialui_render_menu_entry_playlist_list( * (rounded up) */ int vertical_margin = ((node->entry_height - node->text_height) / 2.0f) - (float)mui->sublabel_gap + 1.0f; int sublabel_y; - char wrapped_sublabel[MENU_SUBLABEL_MAX_LENGTH]; + char wrapped_sublabel[MENU_LABEL_MAX_LENGTH]; wrapped_sublabel[0] = '\0'; @@ -5169,13 +5169,13 @@ static void materialui_render_selected_entry_aux_playlist_desktop( bool draw_text_outside = (x_offset != 0); uint32_t text_color = mui->colors.status_bar_text; float text_x = 0.0f; - char metadata_buf[MENU_SUBLABEL_MAX_LENGTH]; + char metadata_buf[MENU_LABEL_MAX_LENGTH]; metadata_buf[0] = '\0'; /* Set text opacity */ - text_color = (text_color & 0xFFFFFF00) | - (unsigned)((255.0f * mui->transition_alpha * mui->status_bar.alpha) + 0.5f); + text_color = (text_color & 0xFFFFFF00) + | (unsigned)((255.0f * mui->transition_alpha * mui->status_bar.alpha) + 0.5f); /* Apply ticker */ if (mui->flags & MUI_FLAG_USE_SMOOTH_TICKER) @@ -7910,7 +7910,7 @@ static void materialui_init_font( const char *str_latin ) { - char s1[PATH_MAX_LENGTH]; + char tmp_dir[DIR_MAX_LENGTH]; char fontpath[PATH_MAX_LENGTH]; const char *wideglyph_str = msg_hash_get_wideglyph_str(); settings_t *settings = config_get_ptr(); @@ -7930,27 +7930,27 @@ static void materialui_init_font( { case RETRO_LANGUAGE_ARABIC: case RETRO_LANGUAGE_PERSIAN: - fill_pathname_join_special(s1, - settings->paths.directory_assets, "pkg", sizeof(s1)); - fill_pathname_join_special(fontpath, s1, "fallback-font.ttf", + fill_pathname_join_special(tmp_dir, + settings->paths.directory_assets, "pkg", sizeof(tmp_dir)); + fill_pathname_join_special(fontpath, tmp_dir, "fallback-font.ttf", sizeof(fontpath)); break; case RETRO_LANGUAGE_CHINESE_SIMPLIFIED: case RETRO_LANGUAGE_CHINESE_TRADITIONAL: - fill_pathname_join_special(s1, - settings->paths.directory_assets, "pkg", sizeof(s1)); - fill_pathname_join_special(fontpath, s1, "chinese-fallback-font.ttf", + fill_pathname_join_special(tmp_dir, + settings->paths.directory_assets, "pkg", sizeof(tmp_dir)); + fill_pathname_join_special(fontpath, tmp_dir, "chinese-fallback-font.ttf", sizeof(fontpath)); break; case RETRO_LANGUAGE_KOREAN: - fill_pathname_join_special(s1, - settings->paths.directory_assets, "pkg", sizeof(s1)); - fill_pathname_join_special(fontpath, s1, "korean-fallback-font.ttf", + fill_pathname_join_special(tmp_dir, + settings->paths.directory_assets, "pkg", sizeof(tmp_dir)); + fill_pathname_join_special(fontpath, tmp_dir, "korean-fallback-font.ttf", sizeof(fontpath)); break; default: - fill_pathname_join_special(s1, dir_assets, "glui", sizeof(s1)); - fill_pathname_join_special(fontpath, s1, FILE_PATH_TTF_FONT, + fill_pathname_join_special(tmp_dir, dir_assets, "glui", sizeof(tmp_dir)); + fill_pathname_join_special(fontpath, tmp_dir, FILE_PATH_TTF_FONT, sizeof(fontpath)); break; } diff --git a/menu/drivers/ozone.c b/menu/drivers/ozone.c index 2f56216cd4..058a7195d2 100644 --- a/menu/drivers/ozone.c +++ b/menu/drivers/ozone.c @@ -3711,13 +3711,13 @@ static void ozone_update_savestate_thumbnail_path(void *data, unsigned i) if (!string_is_empty(entry.label)) { - if (string_to_unsigned(entry.label) == MENU_ENUM_LABEL_STATE_SLOT || - string_is_equal(entry.label, "state_slot") || - string_is_equal(entry.label, "loadstate") || - string_is_equal(entry.label, "savestate")) + if ( string_to_unsigned(entry.label) == MENU_ENUM_LABEL_STATE_SLOT + || string_is_equal(entry.label, "state_slot") + || string_is_equal(entry.label, "loadstate") + || string_is_equal(entry.label, "savestate")) { size_t _len; - char path[8204]; + char path[8204]; /* TODO/FIXME - check size */ runloop_state_t *runloop_st = runloop_state_get_ptr(); /* State slot dropdown */ @@ -4973,7 +4973,7 @@ static void ozone_context_reset_horizontal_list(ozone_handle_t *ozone) { size_t len, syslen; struct texture_image ti; - char sysname[PATH_MAX_LENGTH]; + char sysname[NAME_MAX_LENGTH]; char texturepath[PATH_MAX_LENGTH]; char content_texturepath[PATH_MAX_LENGTH]; @@ -5507,7 +5507,7 @@ static void ozone_compute_entries_position( { if (!string_is_empty(entry.sublabel)) { - char wrapped_sublabel_str[MENU_SUBLABEL_MAX_LENGTH]; + char wrapped_sublabel_str[MENU_LABEL_MAX_LENGTH]; wrapped_sublabel_str[0] = '\0'; @@ -5746,7 +5746,7 @@ border_iterate: { char rich_label[NAME_MAX_LENGTH]; char entry_value_ticker[NAME_MAX_LENGTH]; - char wrapped_sublabel_str[MENU_SUBLABEL_MAX_LENGTH]; + char wrapped_sublabel_str[MENU_LABEL_MAX_LENGTH]; uintptr_t texture; menu_entry_t entry; gfx_animation_ctx_ticker_t ticker; @@ -6953,7 +6953,7 @@ static void ozone_draw_messagebox( math_matrix_4x4 *mymat) { size_t x, y; - char wrapped_message[MENU_SUBLABEL_MAX_LENGTH]; + char wrapped_message[MENU_LABEL_MAX_LENGTH]; int longest_width = 0; int usable_width = 0; struct string_list list = {0}; @@ -9162,7 +9162,7 @@ static void ozone_set_layout( bool ozone_collapse_sidebar, bool is_threaded) { - char s1[PATH_MAX_LENGTH]; + char tmp_dir[DIR_MAX_LENGTH]; char font_path[PATH_MAX_LENGTH]; settings_t *settings = config_get_ptr(); bool font_inited = false; @@ -9225,17 +9225,17 @@ static void ozone_set_layout( { case RETRO_LANGUAGE_ARABIC: case RETRO_LANGUAGE_PERSIAN: - fill_pathname_join_special(s1, settings->paths.directory_assets, "pkg", sizeof(s1)); - fill_pathname_join_special(font_path, s1, "fallback-font.ttf", sizeof(font_path)); + fill_pathname_join_special(tmp_dir, settings->paths.directory_assets, "pkg", sizeof(tmp_dir)); + fill_pathname_join_special(font_path, tmp_dir, "fallback-font.ttf", sizeof(font_path)); break; case RETRO_LANGUAGE_CHINESE_SIMPLIFIED: case RETRO_LANGUAGE_CHINESE_TRADITIONAL: - fill_pathname_join_special(s1, settings->paths.directory_assets, "pkg", sizeof(s1)); - fill_pathname_join_special(font_path, s1, "chinese-fallback-font.ttf", sizeof(font_path)); + fill_pathname_join_special(tmp_dir, settings->paths.directory_assets, "pkg", sizeof(tmp_dir)); + fill_pathname_join_special(font_path, tmp_dir, "chinese-fallback-font.ttf", sizeof(font_path)); break; case RETRO_LANGUAGE_KOREAN: - fill_pathname_join_special(s1, settings->paths.directory_assets, "pkg", sizeof(s1)); - fill_pathname_join_special(font_path, s1, "korean-fallback-font.ttf", sizeof(font_path)); + fill_pathname_join_special(tmp_dir, settings->paths.directory_assets, "pkg", sizeof(tmp_dir)); + fill_pathname_join_special(font_path, tmp_dir, "korean-fallback-font.ttf", sizeof(font_path)); break; default: fill_pathname_join_special(font_path, ozone->assets_path, "bold.ttf", sizeof(font_path)); @@ -9251,17 +9251,17 @@ static void ozone_set_layout( { case RETRO_LANGUAGE_ARABIC: case RETRO_LANGUAGE_PERSIAN: - fill_pathname_join_special(s1, settings->paths.directory_assets, "pkg", sizeof(s1)); - fill_pathname_join_special(font_path, s1, "fallback-font.ttf", sizeof(font_path)); + fill_pathname_join_special(tmp_dir, settings->paths.directory_assets, "pkg", sizeof(tmp_dir)); + fill_pathname_join_special(font_path, tmp_dir, "fallback-font.ttf", sizeof(font_path)); break; case RETRO_LANGUAGE_CHINESE_SIMPLIFIED: case RETRO_LANGUAGE_CHINESE_TRADITIONAL: - fill_pathname_join_special(s1, settings->paths.directory_assets, "pkg", sizeof(s1)); - fill_pathname_join_special(font_path, s1, "chinese-fallback-font.ttf", sizeof(font_path)); + fill_pathname_join_special(tmp_dir, settings->paths.directory_assets, "pkg", sizeof(tmp_dir)); + fill_pathname_join_special(font_path, tmp_dir, "chinese-fallback-font.ttf", sizeof(font_path)); break; case RETRO_LANGUAGE_KOREAN: - fill_pathname_join_special(s1, settings->paths.directory_assets, "pkg", sizeof(s1)); - fill_pathname_join_special(font_path, s1, "korean-fallback-font.ttf", sizeof(font_path)); + fill_pathname_join_special(tmp_dir, settings->paths.directory_assets, "pkg", sizeof(tmp_dir)); + fill_pathname_join_special(font_path, tmp_dir, "korean-fallback-font.ttf", sizeof(font_path)); break; default: fill_pathname_join_special(font_path, ozone->assets_path, "regular.ttf", sizeof(font_path)); diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 580975cc8f..c0cca980f6 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -348,15 +348,15 @@ typedef struct * has a hard-coded size of 8192... * (the extra space here is required to silence compiler * warnings...) */ - char savestate_thumbnail_file_path[8204]; - char prev_savestate_thumbnail_file_path[8204]; + char savestate_thumbnail_file_path[8204]; /* TODO/FIXME - check size */ + char prev_savestate_thumbnail_file_path[8204]; /* TODO/FIXME - check size */ char menu_title[NAME_MAX_LENGTH]; /* Must be a fixed length array... */ char msgbox[1024]; char theme_preset_path[PATH_MAX_LENGTH]; /* Must be a fixed length array... */ char theme_dynamic_path[PATH_MAX_LENGTH]; /* Must be a fixed length array... */ char last_theme_dynamic_path[PATH_MAX_LENGTH]; /* Must be a fixed length array... */ - char menu_sublabel[MENU_SUBLABEL_MAX_LENGTH]; /* Must be a fixed length array... */ + char menu_sublabel[MENU_LABEL_MAX_LENGTH]; /* Must be a fixed length array... */ } rgui_t; static const rgui_theme_t rgui_theme_classic_red = { @@ -4440,7 +4440,7 @@ static void rgui_render_messagebox( { int x, y; size_t i; - char wrapped_message[MENU_SUBLABEL_MAX_LENGTH]; + char wrapped_message[MENU_LABEL_MAX_LENGTH]; unsigned width = 0; unsigned glyphs_width = 0; unsigned height = 0; @@ -5714,7 +5714,7 @@ static void rgui_render( /* Print menu sublabel/core name (if required) */ if (menu_show_sublabels && !string_is_empty(rgui->menu_sublabel)) { - char sublabel_buf[MENU_SUBLABEL_MAX_LENGTH]; + char sublabel_buf[MENU_LABEL_MAX_LENGTH]; sublabel_buf[0] = '\0'; if (use_smooth_ticker) @@ -6886,13 +6886,13 @@ static void rgui_update_savestate_thumbnail_path(void *data, unsigned i) if (!string_is_empty(entry.label)) { - if (string_to_unsigned(entry.label) == MENU_ENUM_LABEL_STATE_SLOT || - string_is_equal(entry.label, "state_slot") || - string_is_equal(entry.label, "loadstate") || - string_is_equal(entry.label, "savestate")) + if ( string_to_unsigned(entry.label) == MENU_ENUM_LABEL_STATE_SLOT + || string_is_equal(entry.label, "state_slot") + || string_is_equal(entry.label, "loadstate") + || string_is_equal(entry.label, "savestate")) { size_t _len; - char path[8204]; + char path[8204]; /* TODO/FIXME - check size */ runloop_state_t *runloop_st = runloop_state_get_ptr(); /* State slot dropdown */ diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 6f3f23cc94..1eca06e49e 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -437,8 +437,8 @@ typedef struct xmb_handle * has a hard-coded size of 8192... * (the extra space here is required to silence compiler * warnings...) */ - char savestate_thumbnail_file_path[8204]; - char prev_savestate_thumbnail_file_path[8204]; + char savestate_thumbnail_file_path[8204]; /* TODO/FIXME - check size */ + char prev_savestate_thumbnail_file_path[8204]; /* TODO/FIXME - check size */ char fullscreen_thumbnail_label[NAME_MAX_LENGTH]; bool allow_horizontal_animation; @@ -1045,7 +1045,7 @@ static void xmb_render_messagebox_internal( int usable_width = 0; struct string_list list = {0}; bool input_dialog_display_kb = false; - char wrapped_message[MENU_SUBLABEL_MAX_LENGTH]; + char wrapped_message[MENU_LABEL_MAX_LENGTH]; wrapped_message[0] = '\0'; @@ -1264,7 +1264,7 @@ static void xmb_update_savestate_thumbnail_path(void *data, unsigned i) || string_is_equal(entry.label, "savestate")) { size_t _len; - char path[8204]; + char path[8204]; /* TODO/FIXME - check size */ runloop_state_t *runloop_st = runloop_state_get_ptr(); /* State slot dropdown */ @@ -2604,7 +2604,7 @@ static void xmb_context_reset_horizontal_list(xmb_handle_t *xmb) { size_t len, syslen; struct texture_image ti; - char sysname[PATH_MAX_LENGTH]; + char sysname[NAME_MAX_LENGTH]; char texturepath[PATH_MAX_LENGTH]; char content_texturepath[PATH_MAX_LENGTH]; const char *console_name = NULL; @@ -4635,9 +4635,9 @@ static int xmb_draw_item( && width > 320 && height > 240 && !string_is_empty(entry.sublabel)) { - char entry_sublabel[MENU_SUBLABEL_MAX_LENGTH]; - char entry_sublabel_top_fade[MENU_SUBLABEL_MAX_LENGTH >> 2]; - char entry_sublabel_bottom_fade[MENU_SUBLABEL_MAX_LENGTH >> 2]; + char entry_sublabel[MENU_LABEL_MAX_LENGTH]; + char entry_sublabel_top_fade[MENU_LABEL_MAX_LENGTH >> 2]; + char entry_sublabel_bottom_fade[MENU_LABEL_MAX_LENGTH >> 2]; gfx_animation_ctx_line_ticker_t line_ticker; gfx_animation_ctx_line_ticker_smooth_t line_ticker_smooth; float ticker_y_offset = 0.0f; diff --git a/menu/menu_contentless_cores.c b/menu/menu_contentless_cores.c index cbecad6a77..037f65cfcf 100644 --- a/menu/menu_contentless_cores.c +++ b/menu/menu_contentless_cores.c @@ -121,7 +121,7 @@ static void contentless_cores_init_info_entries( if ( core_info && core_info->supports_no_game) { - char licenses_str[MENU_SUBLABEL_MAX_LENGTH]; + char licenses_str[MENU_LABEL_MAX_LENGTH]; contentless_core_info_entry_t *entry = (contentless_core_info_entry_t*)malloc(sizeof(*entry)); size_t _len = strlcpy(licenses_str, @@ -134,7 +134,7 @@ static void contentless_cores_init_info_entries( /* Populate licences string */ if (core_info->licenses_list) { - char tmp_str[MENU_SUBLABEL_MAX_LENGTH - 2]; + char tmp_str[MENU_LABEL_MAX_LENGTH - 2]; tmp_str[0] = '\0'; string_list_join_concat(tmp_str, sizeof(tmp_str), core_info->licenses_list, ", "); diff --git a/menu/menu_driver.c b/menu/menu_driver.c index e153e2053b..d25efe59ea 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -2949,8 +2949,7 @@ static bool menu_shader_manager_save_preset_internal( size_t num_target_dirs) { size_t _len; - char fullname[PATH_MAX_LENGTH]; - char buffer[PATH_MAX_LENGTH]; + char fullname[NAME_MAX_LENGTH]; const char *preset_ext = NULL; bool ret = false; enum rarch_shader_type type = RARCH_SHADER_NONE; @@ -2980,6 +2979,7 @@ static bool menu_shader_manager_save_preset_internal( else { char basedir[DIR_MAX_LENGTH]; + char buffer[DIR_MAX_LENGTH]; for (i = 0; i < num_target_dirs; i++) { @@ -3074,10 +3074,9 @@ static bool menu_shader_manager_operate_auto_preset( const char *dir_menu_config, enum auto_shader_type type, bool apply) { + char file[PATH_MAX_LENGTH]; char old_presets_directory[DIR_MAX_LENGTH]; char config_directory[DIR_MAX_LENGTH]; - char tmp[PATH_MAX_LENGTH]; - char file[PATH_MAX_LENGTH]; settings_t *settings = config_get_ptr(); bool video_shader_preset_save_reference_enable = settings->bools.video_shader_preset_save_reference_enable; struct retro_system_info *sysinfo = &runloop_state_get_ptr()->system.info; @@ -3090,7 +3089,7 @@ static bool menu_shader_manager_operate_auto_preset( const char *auto_preset_dirs[3] = {0}; bool has_content = !string_is_empty(rarch_path_basename); - old_presets_directory[0] = config_directory[0] = tmp[0] = file[0] = '\0'; + old_presets_directory[0] = config_directory[0] = file[0] = '\0'; if (type != SHADER_PRESET_GLOBAL && string_is_empty(core_name)) return false; @@ -3130,9 +3129,12 @@ static bool menu_shader_manager_operate_auto_preset( fill_pathname_join_special(file, core_name, core_name, sizeof(file)); break; case SHADER_PRESET_PARENT: - fill_pathname_parent_dir_name(tmp, - rarch_path_basename, sizeof(tmp)); - fill_pathname_join_special(file, core_name, tmp, sizeof(file)); + { + char tmp_dir[DIR_MAX_LENGTH]; + fill_pathname_parent_dir_name(tmp_dir, + rarch_path_basename, sizeof(tmp_dir)); + fill_pathname_join_special(file, core_name, tmp_dir, sizeof(file)); + } break; case SHADER_PRESET_GAME: { @@ -3313,22 +3315,22 @@ static enum action_iterate_type action_iterate_type(const char *label) return ITERATE_TYPE_INFO; if (string_starts_with_size(label, "help", STRLEN_CONST("help"))) if ( - string_is_equal(label, "help") || - string_is_equal(label, "help_controls") || - string_is_equal(label, "help_what_is_a_core") || - string_is_equal(label, "help_loading_content") || - string_is_equal(label, "help_scanning_content") || - string_is_equal(label, "help_change_virtual_gamepad") || - string_is_equal(label, "help_audio_video_troubleshooting") + string_is_equal(label, "help") + || string_is_equal(label, "help_controls") + || string_is_equal(label, "help_what_is_a_core") + || string_is_equal(label, "help_loading_content") + || string_is_equal(label, "help_scanning_content") + || string_is_equal(label, "help_change_virtual_gamepad") + || string_is_equal(label, "help_audio_video_troubleshooting") ) return ITERATE_TYPE_HELP; if (string_is_equal(label, "cheevos_description")) return ITERATE_TYPE_HELP; if (string_starts_with_size(label, "custom_bind", STRLEN_CONST("custom_bind"))) if ( - string_is_equal(label, "custom_bind") || - string_is_equal(label, "custom_bind_all") || - string_is_equal(label, "custom_bind_defaults") + string_is_equal(label, "custom_bind") + || string_is_equal(label, "custom_bind_all") + || string_is_equal(label, "custom_bind_defaults") ) return ITERATE_TYPE_BIND; @@ -3342,38 +3344,38 @@ bool menu_driver_search_filter_enabled(const char *label, unsigned type) bool filter_enabled = false; /* > Check for playlists */ - filter_enabled = (type == MENU_SETTING_HORIZONTAL_MENU) || - (type == MENU_HISTORY_TAB) || - (type == MENU_FAVORITES_TAB) || - (type == MENU_IMAGES_TAB) || - (type == MENU_MUSIC_TAB) || - (type == MENU_VIDEO_TAB) || - (type == FILE_TYPE_PLAYLIST_COLLECTION); + filter_enabled = (type == MENU_SETTING_HORIZONTAL_MENU) + || (type == MENU_HISTORY_TAB) + || (type == MENU_FAVORITES_TAB) + || (type == MENU_IMAGES_TAB) + || (type == MENU_MUSIC_TAB) + || (type == MENU_VIDEO_TAB) + || (type == FILE_TYPE_PLAYLIST_COLLECTION); if (!filter_enabled && !string_is_empty(label)) - filter_enabled = string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_LOAD_CONTENT_HISTORY)) || - string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_FAVORITES_LIST)) || - string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_IMAGES_LIST)) || - string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_MUSIC_LIST)) || - string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_VIDEO_LIST)) || + filter_enabled = string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_LOAD_CONTENT_HISTORY)) + || string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_FAVORITES_LIST)) + || string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_IMAGES_LIST)) + || string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_MUSIC_LIST)) + || string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_VIDEO_LIST)) /* > Core updater */ - string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_CORE_UPDATER_LIST)) || + || string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_CORE_UPDATER_LIST)) /* > File browser (Load Content) */ - string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_FAVORITES)) || + || string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_FAVORITES)) /* > Shader presets/passes */ - string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET)) || - string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_PREPEND)) || - string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_APPEND)) || - string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PASS)) || + || string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET)) + || string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_PREPEND)) + || string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_APPEND)) + || string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PASS)) /* > Cheat files */ - string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_CHEAT_FILE_LOAD)) || - string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_CHEAT_FILE_LOAD_APPEND)) || + || string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_CHEAT_FILE_LOAD)) + || string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_CHEAT_FILE_LOAD_APPEND)) /* > Cheats */ - string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_CORE_CHEAT_OPTIONS)) || + || string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_CORE_CHEAT_OPTIONS)) /* > Overlays */ - string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_INPUT_OVERLAY)) || + || string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_INPUT_OVERLAY)) /* > Manage Cores */ - string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_CORE_MANAGER_LIST)); + || string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_CORE_MANAGER_LIST)); return filter_enabled; } diff --git a/menu/menu_entries.h b/menu/menu_entries.h index 43ad76c33f..dc576ed3b9 100644 --- a/menu/menu_entries.h +++ b/menu/menu_entries.h @@ -31,7 +31,7 @@ RETRO_BEGIN_DECLS -#define MENU_SUBLABEL_MAX_LENGTH 1024 +#define MENU_LABEL_MAX_LENGTH 1024 #define MENU_SEARCH_FILTER_MAX_TERMS 8 #define MENU_SEARCH_FILTER_MAX_LENGTH 64 @@ -113,10 +113,10 @@ typedef struct menu_entry enum msg_hash_enums enum_idx; uint8_t setting_type; uint8_t flags; - char sublabel[MENU_SUBLABEL_MAX_LENGTH]; + char sublabel[MENU_LABEL_MAX_LENGTH]; char path[NAME_MAX_LENGTH]; - char label[NAME_MAX_LENGTH]; - char rich_label[NAME_MAX_LENGTH]; + char label[MENU_LABEL_MAX_LENGTH]; + char rich_label[MENU_LABEL_MAX_LENGTH]; char value[NAME_MAX_LENGTH]; char password_value[NAME_MAX_LENGTH]; } menu_entry_t; @@ -156,7 +156,7 @@ typedef struct menu_file_list_cbs char *path_buf, size_t path_buf_size); menu_search_terms_t search; enum msg_hash_enums enum_idx; - char action_sublabel_cache[MENU_SUBLABEL_MAX_LENGTH]; + char action_sublabel_cache[MENU_LABEL_MAX_LENGTH]; char action_title_cache [512]; bool checked; } menu_file_list_cbs_t; diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 618e33542e..c05b587a7c 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -23133,7 +23133,7 @@ static bool setting_append_list( msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETWORK_USER_REMOTE_ENABLE); for (user = 0; user < max_users; user++) { - char s1[64], s2[64]; + char s1[32], s2[64]; size_t _len = strlcpy(s1, lbl_network_remote_enable, sizeof(s1)); snprintf(s1 + _len, sizeof(s1) - _len, "_user_p%d", user + 1); snprintf(s2, sizeof(s2), val_network_remote_enable, user + 1); diff --git a/runloop.h b/runloop.h index 4192fcec27..c385ace277 100644 --- a/runloop.h +++ b/runloop.h @@ -269,7 +269,7 @@ struct runloop uint32_t flags; int8_t run_frames_and_pause; - char runtime_content_path_basename[8192]; + char runtime_content_path_basename[8192]; /* TODO/FIXME - check size */ char current_library_name[NAME_MAX_LENGTH]; char current_library_version[256]; char current_valid_extensions[256]; @@ -288,15 +288,15 @@ struct runloop struct { char *remapfile; - char savefile[8192]; - char savestate[8192]; - char replay[8192]; - char cheatfile[8192]; - char ups[8192]; - char bps[8192]; - char ips[8192]; - char xdelta[8192]; - char label[8192]; + char savefile[8192]; /* TODO/FIXME - check size */ + char savestate[8192]; /* TODO/FIXME - check size */ + char replay[8192]; /* TODO/FIXME - check size */ + char cheatfile[8192]; /* TODO/FIXME - check size */ + char ups[8192]; /* TODO/FIXME - check size */ + char bps[8192]; /* TODO/FIXME - check size */ + char ips[8192]; /* TODO/FIXME - check size */ + char xdelta[8192]; /* TODO/FIXME - check size */ + char label[8192]; /* TODO/FIXME - check size */ } name; bool missing_bios; diff --git a/tasks/task_content.c b/tasks/task_content.c index 75df380bc3..1b38d0fbbd 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -189,8 +189,8 @@ static bool content_file_override_get_ext( content_file_override_t *content_override = &p_content->content_override_list[i]; - if (!content_override || - !content_override->ext) + if ( !content_override + || !content_override->ext) continue; if (string_is_equal_noncase( @@ -226,7 +226,7 @@ bool content_file_override_set( char *overrides_ext_cpy = strdup(overrides[i].extensions); /* Get list of extensions affected by overrides */ - for (tok = strtok_r(overrides_ext_cpy, "|", &save); tok; + for ( tok = strtok_r(overrides_ext_cpy, "|", &save); tok; tok = strtok_r(NULL, "|", &save)) { size_t num_entries; @@ -254,7 +254,7 @@ bool content_file_override_set( RARCH_LOG("[Content Override]: File Extension: '%3s' - need_fullpath: %s, persistent_data: %s\n", ext, overrides[i].need_fullpath ? "TRUE" : "FALSE", - overrides[i].persistent_data ? "TRUE" : "FALSE"); + overrides[i].persistent_data ? "TRUE" : "FALSE"); override = &p_content->content_override_list[num_entries]; override->ext = strdup(ext); @@ -347,7 +347,7 @@ static void content_file_list_free_entry( free((void*)file_info->data); file_info->data = NULL; } - file_info->data_size = 0; + file_info->data_size = 0; file_info->file_in_archive = false; file_info->persistent_data = false; @@ -454,8 +454,8 @@ static const char *content_file_list_append_temporary( { union string_list_elem_attr attr; - if (!file_list || - string_is_empty(path)) + if ( !file_list + || string_is_empty(path)) return NULL; attr.i = 0; @@ -515,8 +515,8 @@ static bool content_file_list_set_info( game_info_ext->persistent_data = false; /* Assign data */ - if (( data && !data_size) || - (!data && data_size)) + if ( ( data && !data_size) + || (!data && data_size)) return false; file_info->data = data; @@ -771,9 +771,9 @@ static bool content_file_extract_from_archive( const char **content_path, char **error_string) { + char msg[1024]; const char *tmp_path_ptr = NULL; char tmp_path[PATH_MAX_LENGTH]; - char msg[1024]; tmp_path[0] = '\0'; msg[0] = '\0'; @@ -821,9 +821,9 @@ static void content_file_get_path( const char **path, bool *path_is_compressed) { - const char *content_path = content->elems[idx].data; bool path_is_archive; bool path_is_inside_archive; + const char *content_path = content->elems[idx].data; *path = NULL; *path_is_compressed = false; @@ -844,16 +844,16 @@ static void content_file_get_path( * > file_archive_compressed_read() requires * a 'complete' file path: * # */ - if (!CONTENT_FILE_ATTR_GET_BLOCK_EXTRACT(content->elems[idx].attr) && - path_is_archive && - !path_is_inside_archive) + if (!CONTENT_FILE_ATTR_GET_BLOCK_EXTRACT(content->elems[idx].attr) + && path_is_archive + && !path_is_inside_archive) { /* Get internal archive file list */ struct string_list *archive_list = file_archive_get_file_list(content_path, valid_exts); - if (archive_list && - (archive_list->size > 0)) + if ( archive_list + && (archive_list->size > 0)) { const char *archive_file = NULL; @@ -1168,11 +1168,11 @@ static const struct retro_subsystem_info *content_file_init_subsystem( char **error_string, bool *ret) { + char msg[1024]; struct string_list *subsystem = path_get_subsystem_list(); const struct retro_subsystem_info *special = libretro_find_subsystem_info( subsystem_data, (unsigned)subsystem_current_count, path_get(RARCH_PATH_SUBSYSTEM)); - char msg[1024]; msg[0] = '\0'; @@ -1410,7 +1410,7 @@ static void content_load_init_wrap( static bool content_load(content_ctx_info_t *info, content_state_t *p_content) { - unsigned i = 0; + unsigned i; bool success = false; int rarch_argc = 0; char *rarch_argv[MAX_ARGS] = {NULL}; @@ -1722,9 +1722,9 @@ static bool task_push_to_history_list_from_playlist_pre_load_static( menu_handle_t *menu = menu_state_get_ptr()->driver_data; #endif - if (!settings || - !settings->bools.history_list_enable || - string_is_empty(content_path)) + if ( !settings + || !settings->bools.history_list_enable + || string_is_empty(content_path)) return false; switch (path_is_media_type(content_path)) @@ -1752,8 +1752,8 @@ static bool task_push_to_history_list_from_playlist_pre_load_static( { core_info_t *core_info = NULL; - if (!string_is_empty(core) && - core_info_find(core, &core_info)) + if ( !string_is_empty(core) + && core_info_find(core, &core_info)) { /* Set core path and core display name */ core_path = core_info->path; @@ -1920,15 +1920,15 @@ static bool firmware_update_status( bool task_push_start_dummy_core(content_ctx_info_t *content_info) { content_information_ctx_t content_ctx; - content_state_t *p_content = content_state_get_ptr(); - bool ret = true; - settings_t *settings = config_get_ptr(); - runloop_state_t *runloop_st = runloop_state_get_ptr(); - rarch_system_info_t *sys_info = &runloop_st->system; - const char *path_dir_system = settings->paths.directory_system; - bool check_firmware_before_loading = settings->bools.check_firmware_before_loading; + content_state_t *p_content = content_state_get_ptr(); + bool ret = true; + settings_t *settings = config_get_ptr(); + runloop_state_t *runloop_st = runloop_state_get_ptr(); + rarch_system_info_t *sys_info = &runloop_st->system; + const char *path_dir_system = settings->paths.directory_system; + bool check_firmware_before_loading = settings->bools.check_firmware_before_loading; #ifdef HAVE_PATCH - uint16_t rarch_flags = retroarch_get_flags(); + uint16_t rarch_flags = retroarch_get_flags(); #endif if (!content_info) @@ -1954,16 +1954,16 @@ bool task_push_start_dummy_core(content_ctx_info_t *content_info) #endif if (runloop_st->missing_bios) content_ctx.flags |= CONTENT_INFO_FLAG_BIOS_IS_MISSING; - content_ctx.directory_system = NULL; - content_ctx.directory_cache = NULL; - content_ctx.name_ips = NULL; - content_ctx.name_bps = NULL; - content_ctx.name_ups = NULL; - content_ctx.name_xdelta = NULL; - content_ctx.valid_extensions = NULL; + content_ctx.directory_system = NULL; + content_ctx.directory_cache = NULL; + content_ctx.name_ips = NULL; + content_ctx.name_bps = NULL; + content_ctx.name_ups = NULL; + content_ctx.name_xdelta = NULL; + content_ctx.valid_extensions = NULL; - content_ctx.subsystem.data = NULL; - content_ctx.subsystem.size = 0; + content_ctx.subsystem.data = NULL; + content_ctx.subsystem.size = 0; if (!string_is_empty(runloop_st->name.ips)) content_ctx.name_ips = strdup(runloop_st->name.ips); @@ -1975,7 +1975,7 @@ bool task_push_start_dummy_core(content_ctx_info_t *content_info) content_ctx.name_xdelta = strdup(runloop_st->name.xdelta); if (!string_is_empty(path_dir_system)) - content_ctx.directory_system = strdup(path_dir_system); + content_ctx.directory_system = strdup(path_dir_system); if (!content_info->environ_get) content_info->environ_get = menu_content_environment_get; @@ -2246,8 +2246,8 @@ bool task_push_start_current_core(content_ctx_info_t *content_info) * will be loaded; the 'start core' operation can * therefore only be considered successful if the * dummy core is not running following 'content_load()' */ - if (!(ret = content_load(content_info, p_content)) || - !(ret = (runloop_st->current_core_type != CORE_TYPE_DUMMY))) + if ( !(ret = content_load(content_info, p_content)) + || !(ret = (runloop_st->current_core_type != CORE_TYPE_DUMMY))) { #ifdef HAVE_MENU retroarch_menu_running(); @@ -2354,8 +2354,8 @@ bool task_push_load_contentless_core_from_menu( * will be loaded; the 'start core' operation can * therefore only be considered successful if the * dummy core is not running following 'content_load()' */ - if (!(ret = content_load(&content_info, p_content)) || - !(ret = (runloop_st->current_core_type != CORE_TYPE_DUMMY))) + if ( !(ret = content_load(&content_info, p_content)) + || !(ret = (runloop_st->current_core_type != CORE_TYPE_DUMMY))) { retroarch_menu_running(); goto end; @@ -2378,8 +2378,8 @@ bool task_push_load_contentless_core_from_menu( menu_entries_get_last_stack(NULL, &menu_label, NULL, NULL, NULL); - if (string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_CONTENTLESS_CORES_TAB)) || - string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_CONTENTLESS_CORES_LIST))) + if ( string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_CONTENTLESS_CORES_TAB)) + || string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_CONTENTLESS_CORES_LIST))) flush_menu = false; /* Push Quick Menu onto menu stack */ @@ -2411,15 +2411,13 @@ bool task_push_load_content_with_new_core_from_menu( const char *path_dir_system = settings->paths.directory_system; #ifndef HAVE_DYNAMIC bool force_core_reload = settings->bools.always_reload_core_on_run_content; - /* Check whether specified core is already loaded * > If so, we can skip loading the core and * just load the content directly */ - if (!force_core_reload && - (type == CORE_TYPE_PLAIN) && - retroarch_ctl(RARCH_CTL_IS_CORE_LOADED, (void*)core_path)) - return task_push_load_content_with_core( - fullpath, content_info, + if ( !force_core_reload + && (type == CORE_TYPE_PLAIN) + && retroarch_ctl(RARCH_CTL_IS_CORE_LOADED, (void*)core_path)) + return task_push_load_content_with_core(fullpath, content_info, type, cb, user_data); #endif @@ -2429,7 +2427,7 @@ bool task_push_load_content_with_new_core_from_menu( content_ctx.flags |= CONTENT_INFO_FLAG_CHECK_FW_BEFORE_LOADING; #ifdef HAVE_PATCH { - uint16_t rarch_flags = retroarch_get_flags(); + uint16_t rarch_flags = retroarch_get_flags(); if (rarch_flags & RARCH_FLAGS_IPS_PREF) content_ctx.flags |= CONTENT_INFO_FLAG_IS_IPS_PREF; if (rarch_flags & RARCH_FLAGS_BPS_PREF) @@ -2445,17 +2443,17 @@ bool task_push_load_content_with_new_core_from_menu( } #endif if (runloop_st->missing_bios) - content_ctx.flags |= CONTENT_INFO_FLAG_BIOS_IS_MISSING; - content_ctx.directory_system = NULL; - content_ctx.directory_cache = NULL; - content_ctx.name_ips = NULL; - content_ctx.name_bps = NULL; - content_ctx.name_ups = NULL; - content_ctx.name_xdelta = NULL; - content_ctx.valid_extensions = NULL; + content_ctx.flags |= CONTENT_INFO_FLAG_BIOS_IS_MISSING; + content_ctx.directory_system = NULL; + content_ctx.directory_cache = NULL; + content_ctx.name_ips = NULL; + content_ctx.name_bps = NULL; + content_ctx.name_ups = NULL; + content_ctx.name_xdelta = NULL; + content_ctx.valid_extensions = NULL; - content_ctx.subsystem.data = NULL; - content_ctx.subsystem.size = 0; + content_ctx.subsystem.data = NULL; + content_ctx.subsystem.size = 0; if (!string_is_empty(runloop_st->name.ips)) content_ctx.name_ips = strdup(runloop_st->name.ips); @@ -2466,10 +2464,10 @@ bool task_push_load_content_with_new_core_from_menu( if (!string_is_empty(runloop_st->name.xdelta)) content_ctx.name_xdelta = strdup(runloop_st->name.xdelta); - runloop_st->name.label[0] = '\0'; + runloop_st->name.label[0] = '\0'; if (!string_is_empty(path_dir_system)) - content_ctx.directory_system = strdup(path_dir_system); + content_ctx.directory_system = strdup(path_dir_system); path_set(RARCH_PATH_CONTENT, fullpath); path_set(RARCH_PATH_CORE, core_path); @@ -2530,19 +2528,19 @@ static bool task_load_content_internal( { content_information_ctx_t content_ctx; - content_state_t *p_content = content_state_get_ptr(); - bool ret = false; - runloop_state_t *runloop_st = runloop_state_get_ptr(); - rarch_system_info_t *sys_info = &runloop_st->system; - settings_t *settings = config_get_ptr(); - bool check_firmware_before_loading = settings->bools.check_firmware_before_loading; - bool set_supports_no_game_enable = settings->bools.set_supports_no_game_enable; - const char *path_dir_system = settings->paths.directory_system; - const char *path_dir_cache = settings->paths.directory_cache; + content_state_t *p_content = content_state_get_ptr(); + bool ret = false; + runloop_state_t *runloop_st = runloop_state_get_ptr(); + rarch_system_info_t *sys_info = &runloop_st->system; + settings_t *settings = config_get_ptr(); + bool check_firmware_before_loading = settings->bools.check_firmware_before_loading; + bool set_supports_no_game_enable = settings->bools.set_supports_no_game_enable; + const char *path_dir_system = settings->paths.directory_system; + const char *path_dir_cache = settings->paths.directory_cache; #ifdef HAVE_PATCH - uint16_t rarch_flags = retroarch_get_flags(); + uint16_t rarch_flags = retroarch_get_flags(); #endif - content_ctx.flags = 0; + content_ctx.flags = 0; if (check_firmware_before_loading) content_ctx.flags |= CONTENT_INFO_FLAG_CHECK_FW_BEFORE_LOADING; @@ -2561,37 +2559,37 @@ static bool task_load_content_internal( content_ctx.flags |= CONTENT_INFO_FLAG_PATCH_IS_BLOCKED; #endif if (runloop_st->missing_bios) - content_ctx.flags |= CONTENT_INFO_FLAG_BIOS_IS_MISSING; - content_ctx.directory_system = NULL; - content_ctx.directory_cache = NULL; - content_ctx.name_ips = NULL; - content_ctx.name_bps = NULL; - content_ctx.name_ups = NULL; - content_ctx.name_xdelta = NULL; - content_ctx.valid_extensions = NULL; + content_ctx.flags |= CONTENT_INFO_FLAG_BIOS_IS_MISSING; + content_ctx.directory_system = NULL; + content_ctx.directory_cache = NULL; + content_ctx.name_ips = NULL; + content_ctx.name_bps = NULL; + content_ctx.name_ups = NULL; + content_ctx.name_xdelta = NULL; + content_ctx.valid_extensions = NULL; - content_ctx.subsystem.data = NULL; - content_ctx.subsystem.size = 0; + content_ctx.subsystem.data = NULL; + content_ctx.subsystem.size = 0; if (sys_info) { - struct retro_system_info *sysinfo = &runloop_st->system.info; + struct retro_system_info *sysinfo = &runloop_st->system.info; if (set_supports_no_game_enable) content_ctx.flags |= CONTENT_INFO_FLAG_SET_SUPPORTS_NO_GAME_ENABLE; if (!string_is_empty(path_dir_cache)) - content_ctx.directory_cache = strdup(path_dir_cache); + content_ctx.directory_cache = strdup(path_dir_cache); if (!string_is_empty(sysinfo->valid_extensions)) - content_ctx.valid_extensions = strdup(sysinfo->valid_extensions); + content_ctx.valid_extensions = strdup(sysinfo->valid_extensions); if (sysinfo->block_extract) content_ctx.flags |= CONTENT_INFO_FLAG_BLOCK_EXTRACT; if (sysinfo->need_fullpath) content_ctx.flags |= CONTENT_INFO_FLAG_NEED_FULLPATH; - content_ctx.subsystem.data = sys_info->subsystem.data; - content_ctx.subsystem.size = sys_info->subsystem.size; + content_ctx.subsystem.data = sys_info->subsystem.data; + content_ctx.subsystem.size = sys_info->subsystem.size; } if (!string_is_empty(runloop_st->name.ips)) @@ -2604,10 +2602,10 @@ static bool task_load_content_internal( content_ctx.name_xdelta = strdup(runloop_st->name.xdelta); if (!string_is_empty(path_dir_system)) - content_ctx.directory_system = strdup(path_dir_system); + content_ctx.directory_system = strdup(path_dir_system); if (!content_info->environ_get) - content_info->environ_get = menu_content_environment_get; + content_info->environ_get = menu_content_environment_get; if (firmware_update_status(&content_ctx)) goto end; @@ -2846,9 +2844,9 @@ void content_set_subsystem(unsigned idx) /* Sets the subsystem by name */ bool content_set_subsystem_by_name(const char* subsystem_name) { + unsigned i; runloop_state_t *runloop_st = runloop_state_get_ptr(); rarch_system_info_t *sys_info = &runloop_st->system; - unsigned i = 0; /* Core not loaded completely, use the data we peeked on load core */ const struct retro_subsystem_info *subsystem = runloop_st->subsystem_data; @@ -2981,11 +2979,11 @@ uint32_t content_get_crc(void) content_state_t *p_content = content_state_get_ptr(); if (p_content->flags & CONTENT_ST_FLAG_PENDING_ROM_CRC) { - p_content->flags &= ~CONTENT_ST_FLAG_PENDING_ROM_CRC; + p_content->flags &= ~CONTENT_ST_FLAG_PENDING_ROM_CRC; /* TODO/FIXME - file_crc32 has a 64MB max limit - * get rid of this function and find a better * way to calculate CRC based on the file */ - p_content->rom_crc = file_crc32(0, + p_content->rom_crc = file_crc32(0, (const char*)p_content->pending_rom_crc_path); RARCH_LOG("[Content]: CRC32: 0x%x.\n", (unsigned)p_content->rom_crc); @@ -3015,8 +3013,8 @@ void content_deinit(void) p_content->content_list = NULL; p_content->rom_crc = 0; p_content->flags &= ~(CONTENT_ST_FLAG_PENDING_ROM_CRC - | CONTENT_ST_FLAG_CORE_DOES_NOT_NEED_CONTENT - | CONTENT_ST_FLAG_IS_INITED); + | CONTENT_ST_FLAG_CORE_DOES_NOT_NEED_CONTENT + | CONTENT_ST_FLAG_IS_INITED); } /* Set environment variables before a subsystem load */ @@ -3074,16 +3072,16 @@ bool content_init(void) if (runloop_st->flags & RUNLOOP_FLAG_PATCH_BLOCKED) content_ctx.flags |= CONTENT_INFO_FLAG_PATCH_IS_BLOCKED; #endif /* HAVE_PATCH */ - content_ctx.directory_system = NULL; - content_ctx.directory_cache = NULL; - content_ctx.name_ips = NULL; - content_ctx.name_bps = NULL; - content_ctx.name_ups = NULL; - content_ctx.name_xdelta = NULL; - content_ctx.valid_extensions = NULL; + content_ctx.directory_system = NULL; + content_ctx.directory_cache = NULL; + content_ctx.name_ips = NULL; + content_ctx.name_bps = NULL; + content_ctx.name_ups = NULL; + content_ctx.name_xdelta = NULL; + content_ctx.valid_extensions = NULL; - content_ctx.subsystem.data = NULL; - content_ctx.subsystem.size = 0; + content_ctx.subsystem.data = NULL; + content_ctx.subsystem.size = 0; if (!string_is_empty(runloop_st->name.ips)) content_ctx.name_ips = strdup(runloop_st->name.ips); @@ -3096,28 +3094,28 @@ bool content_init(void) if (sys_info) { - struct retro_system_info *sysinfo = &runloop_st->system.info; + struct retro_system_info *sysinfo = &runloop_st->system.info; if (set_supports_no_game_enable) - content_ctx.flags |= CONTENT_INFO_FLAG_SET_SUPPORTS_NO_GAME_ENABLE; + content_ctx.flags |= CONTENT_INFO_FLAG_SET_SUPPORTS_NO_GAME_ENABLE; if (!string_is_empty(path_dir_system)) - content_ctx.directory_system = strdup(path_dir_system); + content_ctx.directory_system = strdup(path_dir_system); if (!string_is_empty(path_dir_cache)) - content_ctx.directory_cache = strdup(path_dir_cache); + content_ctx.directory_cache = strdup(path_dir_cache); if (!string_is_empty(sysinfo->valid_extensions)) - content_ctx.valid_extensions = strdup(sysinfo->valid_extensions); + content_ctx.valid_extensions = strdup(sysinfo->valid_extensions); if (sysinfo->block_extract) - content_ctx.flags |= CONTENT_INFO_FLAG_BLOCK_EXTRACT; + content_ctx.flags |= CONTENT_INFO_FLAG_BLOCK_EXTRACT; if (sysinfo->need_fullpath) - content_ctx.flags |= CONTENT_INFO_FLAG_NEED_FULLPATH; + content_ctx.flags |= CONTENT_INFO_FLAG_NEED_FULLPATH; - content_ctx.subsystem.data = sys_info->subsystem.data; - content_ctx.subsystem.size = sys_info->subsystem.size; + content_ctx.subsystem.data = sys_info->subsystem.data; + content_ctx.subsystem.size = sys_info->subsystem.size; } - p_content->flags |= CONTENT_ST_FLAG_IS_INITED; + p_content->flags |= CONTENT_ST_FLAG_IS_INITED; if (string_list_initialize(&content)) { diff --git a/tasks/task_pl_thumbnail_download.c b/tasks/task_pl_thumbnail_download.c index dfb74e33b7..9636666a70 100644 --- a/tasks/task_pl_thumbnail_download.c +++ b/tasks/task_pl_thumbnail_download.c @@ -139,7 +139,7 @@ static bool get_thumbnail_paths( { char content_dir[DIR_MAX_LENGTH]; char tmp_buf[PATH_MAX_LENGTH]; - size_t raw_url_len = sizeof(char) * 8192; + size_t raw_url_len = sizeof(char) * 8192; /* TODO/FIXME - check size */ char *raw_url = NULL; const char *system = NULL; const char *db_name = NULL; @@ -196,7 +196,7 @@ static bool get_thumbnail_paths( if (string_is_empty(path)) return false; - if (!(raw_url = (char*)malloc(8192 * sizeof(char)))) + if (!(raw_url = (char*)malloc(8192 * sizeof(char)))) /* TODO/FIXME - check size */ return false; raw_url[0] = '\0'; diff --git a/tasks/task_playlist_manager.c b/tasks/task_playlist_manager.c index 103f213f9e..545d5145eb 100644 --- a/tasks/task_playlist_manager.c +++ b/tasks/task_playlist_manager.c @@ -66,25 +66,25 @@ static void free_pl_manager_handle(pl_manager_handle_t *pl_manager) { if (!pl_manager) return; - + if (pl_manager->m3u_list) { string_list_free(pl_manager->m3u_list); pl_manager->m3u_list = NULL; } - + if (!string_is_empty(pl_manager->playlist_name)) { free(pl_manager->playlist_name); pl_manager->playlist_name = NULL; } - + if (pl_manager->playlist) { playlist_free(pl_manager->playlist); pl_manager->playlist = NULL; } - + free(pl_manager); pl_manager = NULL; } @@ -150,18 +150,18 @@ static void task_pl_manager_free(retro_task_t *task) static void task_pl_manager_reset_cores_handler(retro_task_t *task) { pl_manager_handle_t *pl_manager = NULL; - + if (!task) goto task_finished; - + pl_manager = (pl_manager_handle_t*)task->state; - + if (!pl_manager) goto task_finished; - + if (task_get_cancelled(task)) goto task_finished; - + switch (pl_manager->status) { case PL_MANAGER_BEGIN: @@ -185,11 +185,11 @@ static void task_pl_manager_reset_cores_handler(retro_task_t *task) case PL_MANAGER_ITERATE_ENTRY_RESET_CORE: { const struct playlist_entry *entry = NULL; - + /* Get current entry */ playlist_get_index( pl_manager->playlist, pl_manager->list_index, &entry); - + if (entry) { size_t _len; @@ -200,7 +200,7 @@ static void task_pl_manager_reset_cores_handler(retro_task_t *task) _len = strlcpy(task_title, msg_hash_to_str(MSG_PLAYLIST_MANAGER_RESETTING_CORES), sizeof(task_title)); - + if (!string_is_empty(entry->label)) strlcpy(task_title + _len, entry->label, sizeof(task_title) - _len); else if (!string_is_empty(entry->path)) @@ -210,20 +210,20 @@ static void task_pl_manager_reset_cores_handler(retro_task_t *task) path_remove_extension(entry_name); strlcpy(task_title + _len, entry_name, sizeof(task_title) - _len); } - + task_set_title(task, strdup(task_title)); task_set_progress(task, (pl_manager->list_index * 100) / pl_manager->list_size); - + /* Reset core association * > The update function reads our entry as const, * so these casts are safe */ update_entry.core_path = (char*)"DETECT"; update_entry.core_name = (char*)"DETECT"; - + playlist_update( pl_manager->playlist, pl_manager->list_index, &update_entry); } - + /* Increment entry index */ pl_manager->list_index++; if (pl_manager->list_index >= pl_manager->list_size) @@ -242,7 +242,7 @@ static void task_pl_manager_reset_cores_handler(retro_task_t *task) msg_hash_to_str(MSG_PLAYLIST_MANAGER_CORES_RESET), sizeof(task_title)); strlcpy(task_title + _len, pl_manager->playlist_name, sizeof(task_title) - _len); - + task_set_title(task, strdup(task_title)); } /* fall-through */ @@ -250,11 +250,11 @@ static void task_pl_manager_reset_cores_handler(retro_task_t *task) task_set_progress(task, 100); goto task_finished; } - + return; - + task_finished: - + if (task) task_set_finished(task, true); } @@ -263,16 +263,16 @@ static bool task_pl_manager_reset_cores_finder( retro_task_t *task, void *user_data) { pl_manager_handle_t *pl_manager = NULL; - + if (!task || !user_data) return false; - + if (task->handler != task_pl_manager_reset_cores_handler) return false; - + if (!(pl_manager = (pl_manager_handle_t*)task->state)) return false; - + return string_is_equal((const char*)user_data, pl_manager->playlist_config.path); } @@ -282,7 +282,7 @@ bool task_push_pl_manager_reset_cores(const playlist_config_t *playlist_config) size_t _len; task_finder_data_t find_data; char task_title[128]; - char playlist_name[PATH_MAX_LENGTH]; + char playlist_name[NAME_MAX_LENGTH]; retro_task_t *task = task_init(); pl_manager_handle_t *pl_manager = (pl_manager_handle_t*) calloc(1, sizeof(pl_manager_handle_t)); @@ -291,26 +291,26 @@ bool task_push_pl_manager_reset_cores(const playlist_config_t *playlist_config) goto error; if (string_is_empty(playlist_config->path)) goto error; - + fill_pathname_base(playlist_name, playlist_config->path, sizeof(playlist_name)); path_remove_extension(playlist_name); - + if (string_is_empty(playlist_name)) goto error; - + /* Concurrent management of the same playlist * is not allowed */ find_data.func = task_pl_manager_reset_cores_finder; find_data.userdata = (void*)playlist_config->path; - + if (task_queue_find(&find_data)) goto error; - + /* Configure handle */ if (!playlist_config_copy(playlist_config, &pl_manager->playlist_config)) goto error; - + pl_manager->playlist_name = strdup(playlist_name); pl_manager->playlist = NULL; pl_manager->list_size = 0; @@ -318,13 +318,13 @@ bool task_push_pl_manager_reset_cores(const playlist_config_t *playlist_config) pl_manager->m3u_list = NULL; pl_manager->m3u_index = 0; pl_manager->status = PL_MANAGER_BEGIN; - + /* Configure task */ _len = strlcpy(task_title, msg_hash_to_str(MSG_PLAYLIST_MANAGER_RESETTING_CORES), sizeof(task_title)); strlcpy(task_title + _len, playlist_name, sizeof(task_title) - _len); - + task->handler = task_pl_manager_reset_cores_handler; task->state = pl_manager; task->title = strdup(task_title); @@ -332,22 +332,22 @@ bool task_push_pl_manager_reset_cores(const playlist_config_t *playlist_config) task->progress = 0; task->callback = cb_task_pl_manager; task->cleanup = task_pl_manager_free; - + task_queue_push(task); - + return true; - + error: - + if (task) { free(task); task = NULL; } - + free_pl_manager_handle(pl_manager); pl_manager = NULL; - + return false; } @@ -360,17 +360,17 @@ static void pl_manager_validate_core_association( const char *core_path, const char *core_name) { struct playlist_entry update_entry = {0}; - + /* Sanity check */ if (!playlist) return; - + if (entry_index >= playlist_size(playlist)) return; - + if (string_is_empty(core_path)) goto reset_core; - + /* Handle 'DETECT' entries */ if (string_is_equal(core_path, "DETECT")) { @@ -390,7 +390,7 @@ static void pl_manager_validate_core_association( { char core_display_name[PATH_MAX_LENGTH]; core_info_t *core_info = NULL; - + /* Search core info */ if ( core_info_find(core_path, &core_info) && !string_is_empty(core_info->display_name)) @@ -398,12 +398,12 @@ static void pl_manager_validate_core_association( sizeof(core_display_name)); else core_display_name[0] = '\0'; - + /* If core_display_name string is empty, it means the * core wasn't found -> reset association */ if (string_is_empty(core_display_name)) goto reset_core; - + /* ...Otherwise, check that playlist entry * core name is correct */ if (!string_is_equal(core_name, core_display_name)) @@ -412,33 +412,33 @@ static void pl_manager_validate_core_association( playlist_update(playlist, entry_index, &update_entry); } } - + return; - + reset_core: /* The update function reads our entry as const, * so these casts are safe */ update_entry.core_path = (char*)"DETECT"; update_entry.core_name = (char*)"DETECT"; - + playlist_update(playlist, entry_index, &update_entry); } static void task_pl_manager_clean_playlist_handler(retro_task_t *task) { pl_manager_handle_t *pl_manager = NULL; - + if (!task) goto task_finished; - + pl_manager = (pl_manager_handle_t*)task->state; - + if (!pl_manager) goto task_finished; - + if (task_get_cancelled(task)) goto task_finished; - + switch (pl_manager->status) { case PL_MANAGER_BEGIN: @@ -446,17 +446,17 @@ static void task_pl_manager_clean_playlist_handler(retro_task_t *task) /* Load playlist */ if (!path_is_valid(pl_manager->playlist_config.path)) goto task_finished; - + pl_manager->playlist = playlist_init(&pl_manager->playlist_config); - + if (!pl_manager->playlist) goto task_finished; - + pl_manager->list_size = playlist_size(pl_manager->playlist); - + if (pl_manager->list_size < 1) goto task_finished; - + /* All good - can start iterating */ pl_manager->status = PL_MANAGER_ITERATE_ENTRY_VALIDATE; } @@ -465,14 +465,14 @@ static void task_pl_manager_clean_playlist_handler(retro_task_t *task) { const struct playlist_entry *entry = NULL; bool entry_deleted = false; - + /* Update progress display */ task_set_progress(task, (pl_manager->list_index * 100) / pl_manager->list_size); - + /* Get current entry */ playlist_get_index( pl_manager->playlist, pl_manager->list_index, &entry); - + if (entry) { /* Check whether playlist content exists on @@ -482,7 +482,7 @@ static void task_pl_manager_clean_playlist_handler(retro_task_t *task) /* Invalid content - delete entry */ playlist_delete_index(pl_manager->playlist, pl_manager->list_index); entry_deleted = true; - + /* Update list_size */ pl_manager->list_size = playlist_size(pl_manager->playlist); } @@ -492,13 +492,13 @@ static void task_pl_manager_clean_playlist_handler(retro_task_t *task) pl_manager->playlist, pl_manager->list_index, entry->core_path, entry->core_name); } - + /* Increment entry index *if* current entry still * exists (i.e. if entry was deleted, current index * will already point to the *next* entry) */ if (!entry_deleted) pl_manager->list_index++; - + if (pl_manager->list_index >= pl_manager->list_size) pl_manager->status = PL_MANAGER_VALIDATE_END; } @@ -522,10 +522,10 @@ static void task_pl_manager_clean_playlist_handler(retro_task_t *task) { bool entry_deleted = false; size_t i; - + /* Update progress display */ task_set_progress(task, (pl_manager->list_index * 100) / pl_manager->list_size); - + /* Check whether the content + core paths of the * current entry match those of any subsequent * entry */ @@ -537,19 +537,19 @@ static void task_pl_manager_clean_playlist_handler(retro_task_t *task) /* Duplicate found - delete entry */ playlist_delete_index(pl_manager->playlist, pl_manager->list_index); entry_deleted = true; - + /* Update list_size */ pl_manager->list_size = playlist_size(pl_manager->playlist); break; } } - + /* Increment entry index *if* current entry still * exists (i.e. if entry was deleted, current index * will already point to the *next* entry) */ if (!entry_deleted) pl_manager->list_index++; - + if (pl_manager->list_index + 1 >= pl_manager->list_size) pl_manager->status = PL_MANAGER_CHECK_DUPLICATE_END; } @@ -572,14 +572,14 @@ static void task_pl_manager_clean_playlist_handler(retro_task_t *task) case PL_MANAGER_ITERATE_FETCH_M3U: { const struct playlist_entry *entry = NULL; - + /* Update progress display */ task_set_progress(task, (pl_manager->list_index * 100) / pl_manager->list_size); - + /* Get current entry */ playlist_get_index( pl_manager->playlist, pl_manager->list_index, &entry); - + if (entry) { /* If this is an M3U file, add it to the @@ -595,10 +595,10 @@ static void task_pl_manager_clean_playlist_handler(retro_task_t *task) pl_manager->m3u_list, entry->path, attr); } } - + /* Increment entry index */ pl_manager->list_index++; - + if (pl_manager->list_index >= pl_manager->list_size) { /* Check whether we have any M3U files @@ -614,21 +614,21 @@ static void task_pl_manager_clean_playlist_handler(retro_task_t *task) { const char *m3u_path = pl_manager->m3u_list->elems[pl_manager->m3u_index].data; - + if (!string_is_empty(m3u_path)) { m3u_file_t *m3u_file = NULL; - + /* Update progress display */ task_set_progress(task, (pl_manager->m3u_index * 100) / pl_manager->m3u_list->size); - + /* Load M3U file */ m3u_file = m3u_file_init(m3u_path); - + if (m3u_file) { size_t i; - + /* Loop over M3U entries */ for (i = 0; i < m3u_file_get_size(m3u_file); i++) { @@ -640,11 +640,11 @@ static void task_pl_manager_clean_playlist_handler(retro_task_t *task) playlist_delete_by_path( pl_manager->playlist, m3u_entry->full_path); } - + m3u_file_free(m3u_file); } } - + /* Increment M3U file index */ pl_manager->m3u_index++; if (pl_manager->m3u_index >= pl_manager->m3u_list->size) @@ -664,7 +664,7 @@ static void task_pl_manager_clean_playlist_handler(retro_task_t *task) sizeof(task_title)); strlcpy(task_title + _len, pl_manager->playlist_name, sizeof(task_title) - _len); - + task_set_title(task, strdup(task_title)); } /* fall-through */ @@ -672,11 +672,11 @@ static void task_pl_manager_clean_playlist_handler(retro_task_t *task) task_set_progress(task, 100); goto task_finished; } - + return; - + task_finished: - + if (task) task_set_finished(task, true); } @@ -685,17 +685,17 @@ static bool task_pl_manager_clean_playlist_finder( retro_task_t *task, void *user_data) { pl_manager_handle_t *pl_manager = NULL; - + if (!task || !user_data) return false; - + if (task->handler != task_pl_manager_clean_playlist_handler) return false; - + pl_manager = (pl_manager_handle_t*)task->state; if (!pl_manager) return false; - + return string_is_equal((const char*)user_data, pl_manager->playlist_config.path); } @@ -715,26 +715,26 @@ bool task_push_pl_manager_clean_playlist( goto error; if (string_is_empty(playlist_config->path)) goto error; - + fill_pathname_base(playlist_name, playlist_config->path, sizeof(playlist_name)); path_remove_extension(playlist_name); - + if (string_is_empty(playlist_name)) goto error; - + /* Concurrent management of the same playlist * is not allowed */ find_data.func = task_pl_manager_clean_playlist_finder; find_data.userdata = (void*)playlist_config->path; - + if (task_queue_find(&find_data)) goto error; - + /* Configure handle */ if (!playlist_config_copy(playlist_config, &pl_manager->playlist_config)) goto error; - + pl_manager->playlist_name = strdup(playlist_name); pl_manager->playlist = NULL; pl_manager->list_size = 0; @@ -742,16 +742,16 @@ bool task_push_pl_manager_clean_playlist( pl_manager->m3u_list = string_list_new(); pl_manager->m3u_index = 0; pl_manager->status = PL_MANAGER_BEGIN; - + if (!pl_manager->m3u_list) goto error; - + /* Configure task */ _len = strlcpy(task_title, msg_hash_to_str(MSG_PLAYLIST_MANAGER_CLEANING_PLAYLIST), sizeof(task_title)); strlcpy(task_title + _len, playlist_name, sizeof(task_title) - _len); - + task->handler = task_pl_manager_clean_playlist_handler; task->state = pl_manager; task->title = strdup(task_title); @@ -759,21 +759,21 @@ bool task_push_pl_manager_clean_playlist( task->progress = 0; task->callback = cb_task_pl_manager; task->cleanup = task_pl_manager_free; - + task_queue_push(task); - + return true; - + error: - + if (task) { free(task); task = NULL; } - + free_pl_manager_handle(pl_manager); pl_manager = NULL; - + return false; } diff --git a/tasks/task_translation.c b/tasks/task_translation.c index 1202d429da..2ff1be3077 100644 --- a/tasks/task_translation.c +++ b/tasks/task_translation.c @@ -141,7 +141,7 @@ static void handle_translation_cb( void *user_data, const char *error) { uint8_t* raw_output_data = NULL; - char* raw_image_file_data = NULL; + char *raw_image_file_data = NULL; struct scaler_ctx* scaler = NULL; http_transfer_data_t *data = (http_transfer_data_t*)task_data; int new_image_size = 0; @@ -153,10 +153,10 @@ static void handle_translation_cb( void* raw_sound_data = NULL; rjson_t *json = NULL; int json_current_key = 0; - char* err_str = NULL; - char* txt_str = NULL; - char* auto_str = NULL; - char* key_str = NULL; + char *err_str = NULL; + char *txt_str = NULL; + char *auto_str = NULL; + char *key_str = NULL; settings_t* settings = config_get_ptr(); uint32_t runloop_flags = runloop_get_flags(); #ifdef HAVE_ACCESSIBILITY @@ -198,8 +198,7 @@ static void handle_translation_cb( /* Parse JSON body for the image and sound data */ for (;;) { - static const char* keys[] = { "image", "sound", "text", "error", "auto", "press" }; - + static const char *keys[] = { "image", "sound", "text", "error", "auto", "press" }; const char *str = NULL; size_t str_len = 0; enum rjson_type json_type = rjson_next(json);