diff --git a/command.c b/command.c index 5cbd3edb01..035c350887 100644 --- a/command.c +++ b/command.c @@ -1434,7 +1434,6 @@ void command_event_load_auto_state(void) static void scan_states(settings_t *settings, unsigned *last_index, char *file_to_delete) { - runloop_state_t *runloop_st = runloop_state_get_ptr(); bool show_hidden_files = settings->bools.show_hidden_files; unsigned savestate_max_keep = settings->uints.savestate_max_keep; diff --git a/frontend/drivers/platform_ctr.c b/frontend/drivers/platform_ctr.c index 7200007175..aa36b99b36 100644 --- a/frontend/drivers/platform_ctr.c +++ b/frontend/drivers/platform_ctr.c @@ -568,12 +568,11 @@ static enum frontend_powerstate frontend_ctr_get_powerstate( return FRONTEND_POWERSTATE_ON_POWER_SOURCE; } -static void frontend_ctr_get_os(char* s, size_t len, int* major, int* minor) +static size_t frontend_ctr_get_os(char* s, size_t len, int* major, int* minor) { OS_VersionBin cver; OS_VersionBin nver; - - strlcpy(s, "3DS OS", len); + size_t _len = strlcpy(s, "3DS OS", len); Result data_invalid = osGetSystemVersionData(&nver, &cver); if (data_invalid == 0) { @@ -585,7 +584,7 @@ static void frontend_ctr_get_os(char* s, size_t len, int* major, int* minor) *major = 0; *minor = 0; } - + return _len; } static void frontend_ctr_get_name(char* s, size_t len) diff --git a/frontend/drivers/platform_darwin.m b/frontend/drivers/platform_darwin.m index 524be2992a..0e2cd1bcc9 100644 --- a/frontend/drivers/platform_darwin.m +++ b/frontend/drivers/platform_darwin.m @@ -280,31 +280,24 @@ static void frontend_darwin_get_name(char *s, size_t len) #endif } -static void frontend_darwin_get_os(char *s, size_t len, int *major, int *minor) +static size_t frontend_darwin_get_os(char *s, size_t len, int *major, int *minor) { + size_t _len; #if defined(IOS) get_ios_version(major, minor); #if TARGET_OS_TV - s[0] = 't'; - s[1] = 'v'; - s[2] = 'O'; - s[3] = 'S'; - s[4] = '\0'; + _len = strlcpy(s, "tvOS", len); #else - s[0] = 'i'; - s[1] = 'O'; - s[2] = 'S'; - s[3] = '\0'; + _len = strlcpy(s, "iOS", len); #endif #elif defined(OSX) - #if MAC_OS_X_VERSION_MIN_REQUIRED >= 101300 /* MAC_OS_X_VERSION_10_13 */ NSOperatingSystemVersion version = NSProcessInfo.processInfo.operatingSystemVersion; *major = (int)version.majorVersion; *minor = (int)version.minorVersion; #else - /* MacOS 10.9 includes the [NSProcessInfo operatingSystemVersion] function, but it's not in the 10.9 SDK. So, call it via NSInvocation */ - /* Credit: OpenJDK (https://github.com/openjdk/jdk/commit/d4c7db50) */ + /* MacOS 10.9 includes the [NSProcessInfo operatingSystemVersion] function, but it's not in the 10.9 SDK. So, call it via NSInvocation */ + /* Credit: OpenJDK (https://github.com/openjdk/jdk/commit/d4c7db50) */ if ([[NSProcessInfo processInfo] respondsToSelector:@selector(operatingSystemVersion)]) { typedef struct @@ -313,12 +306,12 @@ static void frontend_darwin_get_os(char *s, size_t len, int *major, int *minor) NSInteger minorVersion; NSInteger patchVersion; } NSMyOSVersion; - NSMyOSVersion version; - NSMethodSignature *sig = [[NSProcessInfo processInfo] methodSignatureForSelector:@selector(operatingSystemVersion)]; - NSInvocation *invoke = [NSInvocation invocationWithMethodSignature:sig]; - invoke.selector = @selector(operatingSystemVersion); - [invoke invokeWithTarget:[NSProcessInfo processInfo]]; - [invoke getReturnValue:&version]; + NSMyOSVersion version; + NSMethodSignature *sig = [[NSProcessInfo processInfo] methodSignatureForSelector:@selector(operatingSystemVersion)]; + NSInvocation *invoke = [NSInvocation invocationWithMethodSignature:sig]; + invoke.selector = @selector(operatingSystemVersion); + [invoke invokeWithTarget:[NSProcessInfo processInfo]]; + [invoke getReturnValue:&version]; *major = (int)version.majorVersion; *minor = (int)version.minorVersion; } @@ -328,11 +321,9 @@ static void frontend_darwin_get_os(char *s, size_t len, int *major, int *minor) Gestalt(gestaltSystemVersionMajor, (SInt32*)major); } #endif - s[0] = 'O'; - s[1] = 'S'; - s[2] = 'X'; - s[3] = '\0'; + _len = strlcpy(s, "OSX", len); #endif + return _len; } static void frontend_darwin_get_env(int *argc, char *argv[], diff --git a/frontend/drivers/platform_switch.c b/frontend/drivers/platform_switch.c index 78d04bc4d7..ed9bb7ce45 100644 --- a/frontend/drivers/platform_switch.c +++ b/frontend/drivers/platform_switch.c @@ -86,7 +86,7 @@ extern bool nxlink_connected; void libnx_apply_overclock(void) { - const size_t profiles_count = sizeof(SWITCH_CPU_PROFILES) + const size_t profiles_count = sizeof(SWITCH_CPU_PROFILES) / sizeof(SWITCH_CPU_PROFILES[1]); settings_t *settings = config_get_ptr(); unsigned libnx_overclock = settings->uints.libnx_overclock; @@ -565,7 +565,7 @@ static void frontend_switch_init(void *data) bool recording_supported = false; nifmInitialize(NifmServiceType_User); - + if (hosversionBefore(8, 0, 0)) pcvInitialize(); else @@ -609,8 +609,8 @@ static int frontend_switch_parse_drive_list(void *data, bool load_content) { #ifndef IS_SALAMANDER file_list_t *list = (file_list_t *)data; - enum msg_hash_enums enum_idx = load_content - ? MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR + enum msg_hash_enums enum_idx = load_content + ? MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR : MENU_ENUM_LABEL_FILE_BROWSER_DIRECTORY; if (!list) @@ -637,7 +637,7 @@ static uint64_t frontend_switch_get_total_mem(void) return mem_info.usmblks; } -static enum frontend_powerstate +static enum frontend_powerstate frontend_switch_get_powerstate(int *seconds, int *percent) { uint32_t pct; @@ -671,9 +671,10 @@ frontend_switch_get_powerstate(int *seconds, int *percent) return FRONTEND_POWERSTATE_NO_SOURCE; } -static void frontend_switch_get_os( +static size_t frontend_switch_get_os( char *s, size_t len, int *major, int *minor) { + size_t _len; #ifdef HAVE_LIBNX u32 hosVersion; #else @@ -684,7 +685,7 @@ static void frontend_switch_get_os( ipc_request_t rq; #endif - strlcpy(s, "Horizon OS", len); + _len = strlcpy(s, "Horizon OS", len); #ifdef HAVE_LIBNX *major = 0; @@ -716,8 +717,8 @@ fail_object: fail_sm: sm_finalize(); fail: - return; #endif + return _len; } static void frontend_switch_get_name(char *s, size_t len) diff --git a/frontend/drivers/platform_unix.c b/frontend/drivers/platform_unix.c index 7410f2cc7d..89b5080829 100644 --- a/frontend/drivers/platform_unix.c +++ b/frontend/drivers/platform_unix.c @@ -1240,39 +1240,38 @@ static enum frontend_architecture frontend_unix_get_arch(void) return FRONTEND_ARCH_NONE; } -static void frontend_unix_get_os(char *s, +static size_t frontend_unix_get_os(char *s, size_t len, int *major, int *minor) { + size_t _len = 0; #ifdef ANDROID int rel; frontend_android_get_version(major, minor, &rel); - - strlcpy(s, "Android", len); + _len = strlcpy(s, "Android", len); #else char *ptr; struct utsname buffer; - if (uname(&buffer) != 0) return; - *major = (int)strtol(buffer.release, &ptr, 10); *minor = (int)strtol(++ptr, NULL, 10); #if defined(__FreeBSD__) - strlcpy(s, "FreeBSD", len); + _len = strlcpy(s, "FreeBSD", len); #elif defined(__NetBSD__) - strlcpy(s, "NetBSD", len); + _len = strlcpy(s, "NetBSD", len); #elif defined(__OpenBSD__) - strlcpy(s, "OpenBSD", len); + _len = strlcpy(s, "OpenBSD", len); #elif defined(__DragonFly__) - strlcpy(s, "DragonFly BSD", len); + _len = strlcpy(s, "DragonFly BSD", len); #elif defined(BSD) - strlcpy(s, "BSD", len); + _len = strlcpy(s, "BSD", len); #elif defined(__HAIKU__) - strlcpy(s, "Haiku", len); + _len = strlcpy(s, "Haiku", len); #else - strlcpy(s, "Linux", len); + _len = strlcpy(s, "Linux", len); #endif #endif + return _len; } #ifdef HAVE_LAKKA diff --git a/frontend/drivers/platform_uwp.c b/frontend/drivers/platform_uwp.c index 745e6061b6..bbde128d53 100644 --- a/frontend/drivers/platform_uwp.c +++ b/frontend/drivers/platform_uwp.c @@ -47,7 +47,7 @@ #include "../../uwp/uwp_func.h" -static void frontend_uwp_get_os(char *s, size_t len, int *major, int *minor) +static size_t frontend_uwp_get_os(char *s, size_t len, int *major, int *minor) { size_t _len; char build_str[11] = {0}; @@ -134,6 +134,7 @@ static void frontend_uwp_get_os(char *s, size_t len, int *major, int *minor) _len += strlcpy(s + _len, " ", len - _len); strlcpy(s + _len, uwp_device_family, len - _len); } + return _len; } static void frontend_uwp_init(void *data) { } diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index 26ed25c04f..adb27b425c 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -267,7 +267,7 @@ static void gfx_set_dwm(void) g_plat_win32_flags |= PLAT_WIN32_FLAG_DWM_COMPOSITION_DISABLED; } -static void frontend_win32_get_os(char *s, size_t len, int *major, int *minor) +static size_t frontend_win32_get_os(char *s, size_t len, int *major, int *minor) { size_t _len = 0; char build_str[11] = {0}; @@ -424,6 +424,7 @@ static void frontend_win32_get_os(char *s, size_t len, int *major, int *minor) _len += strlcpy(s + _len, " ", len - _len); strlcpy(s + _len, vi.szCSDVersion, len - _len); } + return _len; } static void frontend_win32_init(void *data) diff --git a/frontend/frontend_driver.h b/frontend/frontend_driver.h index 79d63c0a22..01caeb27cf 100644 --- a/frontend/frontend_driver.h +++ b/frontend/frontend_driver.h @@ -88,7 +88,7 @@ typedef struct frontend_ctx_driver bool (*set_fork)(enum frontend_fork fork_mode); void (*shutdown)(bool); void (*get_name)(char *, size_t); - void (*get_os)(char *, size_t, int *major, int *minor); + size_t (*get_os)(char *, size_t, int *major, int *minor); int (*get_rating)(void); void (*content_loaded)(void); enum frontend_architecture (*get_architecture)(void); diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index 0cb211ba3e..3783657616 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -670,7 +670,7 @@ static bool win32_browser( * FIXME: We should really handle the * error case when this isn't big enough. */ char new_title[PATH_MAX]; - char new_file[32768]; + char new_file[32768]; /* TODO/FIXME - is this not way too big? */ new_title[0] = '\0'; new_file[0] = '\0'; diff --git a/gfx/drivers_shader/shader_gl3.cpp b/gfx/drivers_shader/shader_gl3.cpp index d07029fc17..741d6cb311 100644 --- a/gfx/drivers_shader/shader_gl3.cpp +++ b/gfx/drivers_shader/shader_gl3.cpp @@ -1063,7 +1063,7 @@ void Pass::reflect_parameter_array(const char *name, std::vector= 0) - m->location.push_vertex = vert; + m->location.push_vertex = vert; if (frag >= 0) m->location.push_fragment = frag; } diff --git a/gfx/gfx_display.h b/gfx/gfx_display.h index 09282fe695..1913890bab 100644 --- a/gfx/gfx_display.h +++ b/gfx/gfx_display.h @@ -177,8 +177,6 @@ typedef struct gfx_display_ctx_coord_draw typedef struct gfx_display_ctx_datetime { - char *s; - size_t len; unsigned time_mode; unsigned date_separator; } gfx_display_ctx_datetime_t; @@ -297,7 +295,7 @@ bool gfx_display_reset_icon_texture( const char *texture_path, uintptr_t *item, enum texture_filter_type filter_type, unsigned *width, unsigned *height); - + bool gfx_display_reset_textures_list_buffer( uintptr_t *item, enum texture_filter_type filter_type, diff --git a/gfx/gfx_thumbnail_path.c b/gfx/gfx_thumbnail_path.c index 6dac018f90..31e8c1fbdb 100644 --- a/gfx/gfx_thumbnail_path.c +++ b/gfx/gfx_thumbnail_path.c @@ -375,9 +375,9 @@ bool gfx_thumbnail_set_content_image( img_dir, img_name, sizeof(path_data->content_path)); /* Set core name to "imageviewer" */ - strlcpy( - path_data->content_core_name, - "imageviewer", sizeof(path_data->content_core_name)); + strlcpy(path_data->content_core_name, + "imageviewer", + sizeof(path_data->content_core_name)); /* Set database name (arbitrarily) to "_images_" * (required for compatibility with gfx_thumbnail_update_path(), diff --git a/gfx/widgets/gfx_widget_load_content_animation.c b/gfx/widgets/gfx_widget_load_content_animation.c index 8d2112eb77..13f1dd2ce7 100644 --- a/gfx/widgets/gfx_widget_load_content_animation.c +++ b/gfx/widgets/gfx_widget_load_content_animation.c @@ -469,8 +469,8 @@ bool gfx_widget_start_load_content_animation(void) /* We can only use the core db_name if the * core is associated with exactly one database */ - if (databases_list && - (databases_list->size == 1)) + if ( databases_list + && (databases_list->size == 1)) core_db_name = databases_list->elems[0].data; if ( !string_is_empty(core_db_name) @@ -580,8 +580,9 @@ static void gfx_widget_load_content_animation_layout( state->system_name_width = (system_name_width > 0) ? (unsigned)system_name_width : 0; - text_width = (state->content_name_width > state->system_name_width) ? - (int)state->content_name_width : (int)state->system_name_width; + text_width = (state->content_name_width > state->system_name_width) + ? (int)state->content_name_width + : (int)state->system_name_width; /* Now we have the text width, can determine * final icon/text x draw positions */ @@ -637,8 +638,9 @@ static void gfx_widget_load_content_animation_iterate(void *user_data, state->system_name_width = (system_name_width > 0) ? (unsigned)system_name_width : 0; - text_width = (state->content_name_width > state->system_name_width) ? - (int)state->content_name_width : (int)state->system_name_width; + text_width = (state->content_name_width > state->system_name_width) + ? (int)state->content_name_width + : (int)state->system_name_width; /* Now we have the text width, can determine * final icon/text x draw positions */ diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index 5fe6cdd825..a486e98186 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -443,14 +443,13 @@ static int general_push(menu_displaylist_info_t *info, else { char tmp_path[PATH_MAX_LENGTH]; - fill_pathname_expand_special(tmp_path, menu->scratch2_buf, sizeof(tmp_path)); - const char *menu_path = tmp_path; - fill_pathname_join_special(tmp_str, menu_path, + fill_pathname_expand_special(tmp_path, + menu->scratch2_buf, sizeof(tmp_path)); + fill_pathname_join_special(tmp_str, tmp_path, menu->scratch_buf, sizeof(tmp_str)); } #else - const char *menu_path = menu->scratch2_buf; - fill_pathname_join_special(tmp_str, menu_path, + fill_pathname_join_special(tmp_str, menu->scratch2_buf, menu->scratch_buf, sizeof(tmp_str)); #endif @@ -517,11 +516,9 @@ static int general_push(menu_displaylist_info_t *info, bool filter_by_current_core = settings->bools.filter_by_current_core; if (sysinfo && !string_is_empty(sysinfo->valid_extensions)) - { _len += strlcpy(newstr2 + _len, sysinfo->valid_extensions, sizeof(newstr2) - _len); - } if (!filter_by_current_core) { diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 8dcbd6859a..14faf82f74 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -567,8 +567,8 @@ static void action_ok_get_file_browser_start_path( /* If current path is invalid, use default path */ if (!current_path_valid) { - if (string_is_empty(default_path) || - !path_is_directory(default_path)) + if ( string_is_empty(default_path) + || !path_is_directory(default_path)) { start_path[0] = '\0'; return; @@ -5001,23 +5001,18 @@ finish: STRLEN_CONST(FILE_PATH_INDEX_DIRS_URL) )) { - char parent_dir[DIR_MAX_LENGTH]; char parent_dir_encoded[DIR_MAX_LENGTH]; - file_transfer_t *transf = NULL; - + file_transfer_t *transf = (file_transfer_t*)malloc(sizeof(*transf)); parent_dir_encoded[0] = '\0'; - fill_pathname_parent_dir(parent_dir, - state->path, sizeof(parent_dir)); - strlcat(parent_dir, FILE_PATH_INDEX_DIRS_URL, - sizeof(parent_dir)); + transf->enum_idx = MSG_UNKNOWN; - transf = (file_transfer_t*)malloc(sizeof(*transf)); + fill_pathname_parent_dir(transf->path, + state->path, sizeof(transf->path)); + strlcat(transf->path, FILE_PATH_INDEX_DIRS_URL, + sizeof(transf->path)); - transf->enum_idx = MSG_UNKNOWN; - strlcpy(transf->path, parent_dir, sizeof(transf->path)); - - net_http_urlencode_full(parent_dir_encoded, parent_dir, + net_http_urlencode_full(parent_dir_encoded, transf->path, sizeof(parent_dir_encoded)); task_push_http_transfer_file(parent_dir_encoded, true, "index_dirs", cb_net_generic_subdir, transf); @@ -6781,6 +6776,9 @@ int action_ok_push_filebrowser_list_dir_select(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { menu_entry_t entry; +#if IOS + char tmp[PATH_MAX_LENGTH]; +#endif char current_value[PATH_MAX_LENGTH]; struct menu_state *menu_st = menu_state_get_ptr(); menu_handle_t *menu = menu_st->driver_data; @@ -6794,7 +6792,6 @@ int action_ok_push_filebrowser_list_dir_select(const char *path, menu_entry_get(&entry, 0, menu_st->selection_ptr, NULL, true); strlcpy(current_value, entry.value, sizeof(current_value)); #if IOS - char tmp[PATH_MAX_LENGTH]; fill_pathname_expand_special(tmp, current_value, sizeof(tmp)); if (!path_is_directory(tmp)) current_value[0] = '\0'; @@ -7287,9 +7284,9 @@ static int action_ok_push_dropdown_item_disk_index(const char *path, static int action_ok_push_dropdown_item_audio_device(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - const char *menu_path = NULL; enum msg_hash_enums enum_idx; rarch_setting_t *setting; + const char *menu_path = NULL; menu_entries_get_last_stack(&menu_path, NULL, NULL, NULL, NULL); enum_idx = (enum msg_hash_enums)atoi(menu_path); setting = menu_setting_find_enum(enum_idx); @@ -7549,8 +7546,7 @@ static int action_ok_push_dropdown_item_netplay_mitm_server(const char *path, if (!setting) return -1; - strlcpy(setting->value.target.string, - label, setting->size); + strlcpy(setting->value.target.string, label, setting->size); return action_cancel_pop_default(NULL, NULL, 0, 0); } @@ -7981,7 +7977,6 @@ static int action_ok_disk_cycle_tray_status(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[PATH_MAX_LENGTH]; rarch_system_info_t *sys_info = &runloop_state_get_ptr()->system; struct menu_state *menu_st = menu_state_get_ptr(); menu_handle_t *menu = menu_st->driver_data; @@ -7993,8 +7988,6 @@ static int action_ok_disk_image_append(const char *path, #endif bool menu_insert_disk_resume = settings->bools.menu_insert_disk_resume; - image_path[0] = '\0'; - if (!menu) return -1; @@ -8009,6 +8002,7 @@ static int action_ok_disk_image_append(const char *path, if (!string_is_empty(menu_path)) { + char image_path[PATH_MAX_LENGTH]; bool is_dir = (entry_idx == FILE_TYPE_USE_DIRECTORY && string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_USE_THIS_DIRECTORY))); @@ -8017,18 +8011,18 @@ static int action_ok_disk_image_append(const char *path, size_t past_slash; strlcpy(image_path, menu_path, sizeof(image_path)); past_slash = fill_pathname_slash(image_path, sizeof(image_path)); - if (past_slash > 1) image_path[past_slash - 1] = '\0'; + if (past_slash > 1) + image_path[past_slash - 1] = '\0'; } else if (!string_is_empty(path)) fill_pathname_join_special(image_path, menu_path, path, sizeof(image_path)); else strlcpy(image_path, menu_path, sizeof(image_path)); + /* Append image */ + command_event(CMD_EVENT_DISK_APPEND_IMAGE, image_path); } - /* Append image */ - command_event(CMD_EVENT_DISK_APPEND_IMAGE, image_path); - /* In all cases, return to the disk options menu */ menu_entries_flush_stack(msg_hash_to_str(MENU_ENUM_LABEL_DISK_OPTIONS), 0); @@ -8104,7 +8098,6 @@ static void action_ok_netplay_enable_client_hostname_cb(void *userdata, 1, 480, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); #endif - menu_input_dialog_end(); } else diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index 7db14f1669..5a135269e6 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -391,36 +391,34 @@ static int action_get_title_mixer_stream_actions(const char *path, const char *l static int action_get_title_deferred_playlist_list(const char *path, const char *label, unsigned menu_type, char *s, size_t len) { - const char *playlist_file = NULL; - - if (string_is_empty(path)) - return 0; - - playlist_file = path_basename_nocompression(path); - - if (string_is_empty(playlist_file)) - return 0; - - if (string_is_equal_noncase(path_get_extension(playlist_file), - "lpl")) + if (!string_is_empty(path)) { - /* Handle content history */ - if (string_is_equal(playlist_file, FILE_PATH_CONTENT_HISTORY)) - strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_HISTORY_TAB), len); - /* Handle favourites */ - else if (string_is_equal(playlist_file, FILE_PATH_CONTENT_FAVORITES)) - strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_FAVORITES_TAB), len); - /* Handle collection playlists */ - else - fill_pathname(s, playlist_file, "", len); - } - /* This should never happen, but if it does just set - * the label to the file name (it's better than nothing...) */ - else - strlcpy(s, playlist_file, len); + const char *playlist_file = path_basename_nocompression(path); - /* Add current search terms */ - menu_entries_search_append_terms_string(s, len); + if (!string_is_empty(playlist_file)) + { + if (string_is_equal_noncase(path_get_extension(playlist_file), + "lpl")) + { + /* Handle content history */ + if (string_is_equal(playlist_file, FILE_PATH_CONTENT_HISTORY)) + strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_HISTORY_TAB), len); + /* Handle favourites */ + else if (string_is_equal(playlist_file, FILE_PATH_CONTENT_FAVORITES)) + strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_FAVORITES_TAB), len); + /* Handle collection playlists */ + else + fill_pathname(s, playlist_file, "", len); + } + /* This should never happen, but if it does just set + * the label to the file name (it's better than nothing...) */ + else + strlcpy(s, playlist_file, len); + + /* Add current search terms */ + menu_entries_search_append_terms_string(s, len); + } + } return 0; } diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 20a50b1511..a4ef10b6ad 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -5857,15 +5857,10 @@ static void materialui_render_header( { gfx_display_ctx_datetime_t datetime; char timedate_str[MUI_TIMEDATE_MAX_LENGTH]; - - timedate_str[0] = '\0'; - - datetime.s = timedate_str; - datetime.len = sizeof(timedate_str); datetime.time_mode = menu_timedate_style; datetime.date_separator = menu_timedate_date_separator; - menu_display_timedate(&datetime); + menu_display_timedate(&datetime, timedate_str, sizeof(timedate_str)); /* Need to determine pixel width of time string * > This is somewhat expensive, so utilise a cache diff --git a/menu/drivers/ozone.c b/menu/drivers/ozone.c index a1ca115187..41442ead0e 100644 --- a/menu/drivers/ozone.c +++ b/menu/drivers/ozone.c @@ -10576,12 +10576,10 @@ static void ozone_draw_header( gfx_display_ctx_datetime_t datetime; char timedate[256]; - datetime.s = timedate; datetime.time_mode = settings->uints.menu_timedate_style; datetime.date_separator = settings->uints.menu_timedate_date_separator; - datetime.len = sizeof(timedate); - menu_display_timedate(&datetime); + menu_display_timedate(&datetime, timedate, sizeof(timedate)); gfx_display_draw_text( ozone->fonts.time.font, diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index ab6644f9fc..ee881f3541 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -5785,17 +5785,12 @@ static void rgui_render( /* Print clock (if required) */ if (menu_timedate_enable) { - gfx_display_ctx_datetime_t datetime; char timedate[16]; - - timedate[0] = '\0'; - - datetime.s = timedate; - datetime.len = sizeof(timedate); + gfx_display_ctx_datetime_t datetime; datetime.time_mode = MENU_TIMEDATE_STYLE_HM; datetime.date_separator = MENU_TIMEDATE_DATE_SEPARATOR_HYPHEN; - menu_display_timedate(&datetime); + menu_display_timedate(&datetime, timedate, sizeof(timedate)); rgui_blit_line(rgui, fb_width, diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 4ef3de2c62..8a6effb6a5 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -6998,14 +6998,9 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) dispctx->blend_end(userdata); } - timedate[0] = '\0'; - - datetime.s = timedate; - datetime.len = sizeof(timedate); datetime.time_mode = settings->uints.menu_timedate_style; datetime.date_separator = settings->uints.menu_timedate_date_separator; - - _len = menu_display_timedate(&datetime); + _len = menu_display_timedate(&datetime, timedate, sizeof(timedate)); title_header_max_width = x_pos + font_driver_get_message_width( xmb->font, timedate, _len, 1.0f); diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 122b815dc7..9cde3aae7d 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -757,13 +757,13 @@ static int menu_displaylist_parse_core_info( if (core_info->firmware_count > 0) { + char tmp_path[PATH_MAX_LENGTH]; core_info_ctx_firmware_t firmware_info; uint8_t flags = content_get_flags(); bool update_missing_firmware = false; bool set_missing_firmware = false; bool systemfiles_in_content_dir = settings->bools.systemfiles_in_content_dir; bool content_is_inited = flags & CONTENT_ST_FLAG_IS_INITED; - char tmp_path[PATH_MAX_LENGTH]; firmware_info.path = core_info->path; @@ -771,8 +771,9 @@ static int menu_displaylist_parse_core_info( * adjust the path to check for firmware files */ if (systemfiles_in_content_dir && content_is_inited) { - strlcpy(tmp_path, path_get(RARCH_PATH_CONTENT), sizeof(tmp_path)); - path_basedir(tmp_path); + fill_pathname_basedir(tmp_path, + path_get(RARCH_PATH_CONTENT), + sizeof(tmp_path)); /* If content path is empty, fall back to global system dir path */ if (string_is_empty(tmp_path)) @@ -866,16 +867,16 @@ static int menu_displaylist_parse_core_info( /* Show relevant note row and skip showing it later */ if (core_info->notes) { - unsigned pos; unsigned j; char firmware_basename[64]; + fill_pathname_base(firmware_basename, + core_info->firmware[i].desc, sizeof(firmware_basename)); - strlcpy(firmware_basename, core_info->firmware[i].desc, sizeof(firmware_basename)); - path_basename(firmware_basename); firmware_basename[string_find_index_substring_string(firmware_basename, " ")] = '\0'; for (j = 0; j < core_info->note_list->size; j++) { + unsigned pos; if ( !strstr(core_info->note_list->elems[j].data, firmware_basename) || !strstr(core_info->note_list->elems[j].data, "(md5)")) continue; @@ -884,7 +885,7 @@ static int menu_displaylist_parse_core_info( core_info_list_hide[j] = true; len = strlcpy(tmp, "- ", sizeof(tmp)); - strlcat(tmp, core_info->note_list->elems[j].data + pos, sizeof(tmp)); + strlcpy(tmp + len, core_info->note_list->elems[j].data + pos, sizeof(tmp) - len); if (menu_entries_append(list, tmp, "", MENU_ENUM_LABEL_CORE_INFO_ENTRY, @@ -2043,15 +2044,13 @@ static unsigned menu_displaylist_parse_system_info(file_list_t *list) /* Lakka Version */ if (frontend->get_lakka_version) { - char lakka_ver[64]; - frontend->get_lakka_version(lakka_ver, sizeof(lakka_ver)); _len = strlcpy(entry, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_LAKKA_VERSION), sizeof(entry)); entry[ _len] = ':'; entry[++_len] = ' '; entry[++_len] = '\0'; - strlcpy(entry + _len, lakka_ver, sizeof(entry) - _len); + frontend->get_lakka_version(entry + _len, sizeof(entry) - _len); if (menu_entries_append(list, entry, "", MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, 0, 0, NULL)) @@ -2061,15 +2060,13 @@ static unsigned menu_displaylist_parse_system_info(file_list_t *list) /* Frontend name */ if (frontend->get_name) { - char frontend_name[64]; - frontend->get_name(frontend_name, sizeof(frontend_name)); _len = strlcpy(entry, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_FRONTEND_NAME), sizeof(entry)); entry[ _len] = ':'; entry[++_len] = ' '; entry[++_len] = '\0'; - strlcpy(entry + _len, frontend_name, sizeof(entry) - _len); + frontend->get_name(entry + _len, sizeof(entry) - _len); if (menu_entries_append(list, entry, "", MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, 0, 0, NULL)) @@ -2079,17 +2076,16 @@ static unsigned menu_displaylist_parse_system_info(file_list_t *list) /* Frontend OS */ if (frontend->get_os) { - char os_ver[64]; int major = 0; int minor = 0; - frontend->get_os(os_ver, sizeof(os_ver), &major, &minor); _len = strlcpy(entry, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_FRONTEND_OS), sizeof(entry)); entry[ _len] = ':'; entry[++_len] = ' '; entry[++_len] = '\0'; - _len += strlcpy (entry + _len, os_ver, sizeof(entry) - _len); + _len += frontend->get_os(entry + _len, + sizeof(entry) - _len, &major, &minor); snprintf(entry + _len, sizeof(entry) - _len, " (v%d.%d)", major, minor); @@ -2750,6 +2746,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, settings_t *settings, menu_displaylist_info_t *info) { + size_t _len; size_t path_len; unsigned i, j, k; char query[256]; @@ -2777,13 +2774,13 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, if (!(db_info = database_info_list_new(info->path, query))) return -1; - fill_pathname(path_base, path_basename(info->path), "", + _len = fill_pathname(path_base, path_basename(info->path), "", sizeof(path_base)); gfx_thumbnail_set_system(menu_st->thumbnail_path_data, path_base, playlist_get_cached()); - strlcat(path_base, ".lpl", sizeof(path_base)); + strlcpy(path_base + _len, ".lpl", sizeof(path_base) - _len); fill_pathname_join_special(menu->db_playlist_file, dir_playlist, path_base, @@ -4132,17 +4129,17 @@ static int menu_displaylist_parse_horizontal_content_actions( { const char *tmp; char sys_thumb[64]; - size_t sys_len = 0; + size_t __len = 0; if (gfx_thumbnail_get_system(menu_st->thumbnail_path_data, &tmp)) - sys_len = strlcpy(sys_thumb, tmp, sizeof(sys_thumb)); + __len = strlcpy(sys_thumb, tmp, sizeof(sys_thumb)); if (!string_is_empty(sys_thumb)) remove_entry_enabled = string_is_equal(sys_thumb, "history") || string_is_equal(sys_thumb, "favorites") || string_ends_with_size(sys_thumb, "_history", - sys_len, STRLEN_CONST("_history")); + __len, STRLEN_CONST("_history")); /* An annoyance: if the user navigates to the information menu, * then to the database entry, the thumbnail system will be changed. @@ -4231,14 +4228,14 @@ static int menu_displaylist_parse_horizontal_content_actions( /* Only show 'Download Thumbnails' on supported playlists */ char sys_thumb[64]; const char *tmp = NULL; - size_t sys_len = 0; + size_t __len = 0; if (gfx_thumbnail_get_system(menu_st->thumbnail_path_data, &tmp)) - sys_len = strlcpy(sys_thumb, tmp, sizeof(sys_thumb)); + __len = strlcpy(sys_thumb, tmp, sizeof(sys_thumb)); if (!string_is_empty(sys_thumb)) download_enabled = !string_ends_with_size( - sys_thumb, "_history", sys_len, STRLEN_CONST("_history")); + sys_thumb, "_history", __len, STRLEN_CONST("_history")); else download_enabled = false; } @@ -5201,25 +5198,18 @@ static unsigned menu_displaylist_parse_content_information( /* Database */ if (!string_is_empty(db_name)) { - char db_name_no_ext_buff[NAME_MAX_LENGTH]; - fill_pathname(db_name_no_ext_buff, db_name, "", - sizeof(db_name_no_ext_buff)); - - if (!string_is_empty(db_name_no_ext_buff)) - { - size_t _len = strlcpy(tmp, - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CONTENT_INFO_DATABASE), - sizeof(tmp)); - tmp[ _len] = ':'; - tmp[++_len] = ' '; - tmp[++_len] = '\0'; - strlcpy(tmp + _len, db_name_no_ext_buff, sizeof(tmp) - _len); - if (menu_entries_append(info_list, tmp, + size_t _len = strlcpy(tmp, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CONTENT_INFO_DATABASE), + sizeof(tmp)); + tmp[ _len] = ':'; + tmp[++_len] = ' '; + tmp[++_len] = '\0'; + fill_pathname(tmp + _len, db_name, "", sizeof(tmp) - _len); + if (menu_entries_append(info_list, tmp, msg_hash_to_str(MENU_ENUM_LABEL_CONTENT_INFO_DATABASE), MENU_ENUM_LABEL_CONTENT_INFO_DATABASE, 0, 0, 0, NULL)) - count++; - } + count++; } /* If content path is empty and core supports @@ -7245,12 +7235,12 @@ unsigned menu_displaylist_build_list( break; case DISPLAYLIST_INPUT_HAPTIC_FEEDBACK_SETTINGS_LIST: { + char os_ver[64]; + int major, minor; input_driver_t *current_input = input_state_get_ptr()->current_driver; const frontend_ctx_driver_t *frontend = frontend_get_ptr(); - char os_ver[64] = {0}; - int major, minor; if (frontend && frontend->get_os) frontend->get_os(os_ver, sizeof(os_ver), &major, &minor); @@ -12984,15 +12974,9 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, #ifdef HAVE_AUDIOMIXER { char lbl[128]; - char mixer_stream_str[128]; unsigned id = info->type - MENU_SETTINGS_AUDIO_MIXER_STREAM_ACTIONS_BEGIN; - size_t _len = strlcpy(mixer_stream_str, "mixer_stream_", sizeof(mixer_stream_str)); - - lbl[0] = '\0'; - - snprintf(mixer_stream_str + _len, sizeof(mixer_stream_str) - _len, "%d", id); - - _len = strlcpy(lbl, mixer_stream_str, sizeof(lbl)); + size_t _len = strlcpy(lbl, "mixer_stream_", sizeof(lbl)); + _len += snprintf(lbl + _len, sizeof(lbl) - _len, "%d", id); strlcpy(lbl + _len, "_action_play", sizeof(lbl) - _len); if (menu_entries_append(info->list, diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 0e9027f08e..94b431b0aa 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -640,7 +640,7 @@ bool menu_entries_list_search(const char *needle, size_t *idx) /* Display the date and time - time_mode will influence how * the time representation will look like. * */ -size_t menu_display_timedate(gfx_display_ctx_datetime_t *datetime) +size_t menu_display_timedate(gfx_display_ctx_datetime_t *datetime, char *s, size_t len) { /* Storage container for current menu datetime * representation string */ @@ -1008,10 +1008,9 @@ size_t menu_display_timedate(gfx_display_ctx_datetime_t *datetime) strftime(datetime_cache, sizeof(datetime_cache), format_str, &tm_); } - /* Copy cached datetime string to input * menu_display_ctx_datetime_t struct */ - return strlcpy(datetime->s, datetime_cache, datetime->len); + return strlcpy(s, datetime_cache, len); } /* Display current (battery) power state */ @@ -4053,31 +4052,23 @@ void menu_entries_search_append_terms_string(char *s, size_t len) } } -static void get_current_menu_value( +static size_t get_current_menu_value( struct menu_state *menu_st, char *s, size_t len) { menu_entry_t entry; - const char* entry_label; - MENU_ENTRY_INITIALIZE(entry); entry.flags |= MENU_ENTRY_FLAG_VALUE_ENABLED; menu_entry_get(&entry, 0, menu_st->selection_ptr, NULL, true); - if (entry.enum_idx == MENU_ENUM_LABEL_CHEEVOS_PASSWORD) - entry_label = entry.password_value; - else - entry_label = entry.value; - - strlcpy(s, entry_label, len); + return strlcpy(s, entry.password_value, len); + return strlcpy(s, entry.value, len); } #ifdef HAVE_ACCESSIBILITY -static void menu_driver_get_current_menu_label(struct menu_state *menu_st, +static size_t menu_driver_get_current_menu_label(struct menu_state *menu_st, char *s, size_t len) { menu_entry_t entry; - const char* entry_label; - MENU_ENTRY_INITIALIZE(entry); entry.flags |= MENU_ENTRY_FLAG_PATH_ENABLED | MENU_ENTRY_FLAG_LABEL_ENABLED @@ -4085,26 +4076,21 @@ static void menu_driver_get_current_menu_label(struct menu_state *menu_st, | MENU_ENTRY_FLAG_VALUE_ENABLED | MENU_ENTRY_FLAG_SUBLABEL_ENABLED; menu_entry_get(&entry, 0, menu_st->selection_ptr, NULL, true); - if (!string_is_empty(entry.rich_label)) - entry_label = entry.rich_label; - else - entry_label = entry.path; - - strlcpy(s, entry_label, len); + return strlcpy(s, entry.rich_label, len); + return strlcpy(s, entry.path, len); } #endif -static void menu_driver_get_current_menu_sublabel( +static size_t menu_driver_get_current_menu_sublabel( struct menu_state *menu_st, char *s, size_t len) { menu_entry_t entry; - MENU_ENTRY_INITIALIZE(entry); entry.flags |= MENU_ENTRY_FLAG_SUBLABEL_ENABLED; menu_entry_get(&entry, 0, menu_st->selection_ptr, NULL, true); - strlcpy(s, entry.sublabel, len); + return strlcpy(s, entry.sublabel, len); } void menu_entries_get_last_stack(const char **path, const char **label, @@ -8038,20 +8024,16 @@ size_t menu_update_fullscreen_thumbnail_label( char *s, size_t len, bool is_quick_menu, const char *title) { - char tmpstr[64]; menu_entry_t selected_entry; struct menu_state *menu_st = &menu_driver_state; - const char *thumbnail_label = NULL; - /* > Get menu entry */ MENU_ENTRY_INITIALIZE(selected_entry); selected_entry.flags |= MENU_ENTRY_FLAG_LABEL_ENABLED | MENU_ENTRY_FLAG_RICH_LABEL_ENABLED; menu_entry_get(&selected_entry, 0, menu_st->selection_ptr, NULL, true); - /* > Get entry label */ if (!string_is_empty(selected_entry.rich_label)) - thumbnail_label = selected_entry.rich_label; + return strlcpy(s, selected_entry.rich_label, len); /* > State slot label */ else if ( is_quick_menu && ( @@ -8061,11 +8043,12 @@ size_t menu_update_fullscreen_thumbnail_label( ) ) { - size_t _len = strlcpy(tmpstr, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_STATE_SLOT), - sizeof(tmpstr)); - snprintf(tmpstr + _len, sizeof(tmpstr) - _len, " %d", + size_t _len = strlcpy(s, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_STATE_SLOT), + len); + _len += snprintf(s + _len, len - _len, " %d", config_get_ptr()->ints.state_slot); - thumbnail_label = tmpstr; + return _len; } else if ( is_quick_menu && ( @@ -8075,41 +8058,41 @@ size_t menu_update_fullscreen_thumbnail_label( || string_is_equal(selected_entry.label, "halt_replay") )) { - size_t _len = strlcpy(tmpstr, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_REPLAY_SLOT), - sizeof(tmpstr)); - snprintf(tmpstr + _len, sizeof(tmpstr) - _len, " %d", + size_t _len = strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_REPLAY_SLOT), + len); + _len += snprintf(s + _len, len - _len, " %d", config_get_ptr()->ints.replay_slot); - thumbnail_label = tmpstr; + return _len; } else if (string_to_unsigned(selected_entry.label) == MENU_ENUM_LABEL_STATE_SLOT) { - size_t _len = strlcpy(tmpstr, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_STATE_SLOT), - sizeof(tmpstr)); - snprintf(tmpstr + _len, sizeof(tmpstr) - _len, " %d", + size_t _len = strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_STATE_SLOT), + len); + _len += snprintf(s + _len, len - _len, " %d", string_to_unsigned(selected_entry.path)); - thumbnail_label = tmpstr; + return _len; } /* > Quick Menu playlist label */ else if (is_quick_menu && title) - thumbnail_label = title; + { + if (!string_is_empty(title)) + return strlcpy(s, title, len); + } else - thumbnail_label = selected_entry.path; - - /* > Sanity check */ - if (!string_is_empty(thumbnail_label)) - return strlcpy(s, thumbnail_label, len); + { + if (!string_is_empty(selected_entry.path)) + return strlcpy(s, selected_entry.path, len); + } return 0; } bool menu_is_running_quick_menu(void) { menu_entry_t entry; - MENU_ENTRY_INITIALIZE(entry); entry.flags |= MENU_ENTRY_FLAG_LABEL_ENABLED | MENU_ENTRY_FLAG_RICH_LABEL_ENABLED; menu_entry_get(&entry, 0, 0, NULL, true); - return string_is_equal(entry.label, "resume_content") || string_is_equal(entry.label, "state_slot"); } diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 3e16d88e7d..38290e5088 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -628,7 +628,7 @@ bool menu_driver_init(bool video_is_threaded); retro_time_t menu_driver_get_current_time(void); -size_t menu_display_timedate(gfx_display_ctx_datetime_t *datetime); +size_t menu_display_timedate(gfx_display_ctx_datetime_t *datetime, char *s, size_t len); void menu_display_powerstate(gfx_display_ctx_powerstate_t *powerstate); diff --git a/retroarch.c b/retroarch.c index 83ed8c6b06..a1160b0cdb 100644 --- a/retroarch.c +++ b/retroarch.c @@ -7665,8 +7665,9 @@ bool retroarch_main_init(int argc, char *argv[]) _len += strlcpy(str_output + _len, FILE_PATH_LOG_INFO " CPU Model Name: ", sizeof(str_output) - _len); - _len += strlcpy(str_output + _len, cpu_model, - sizeof(str_output) - _len); + _len += strlcpy(str_output + _len, + cpu_model, + sizeof(str_output) - _len); str_output[ _len] = '\n'; str_output[++_len] = '\0'; } @@ -8350,8 +8351,8 @@ void retroarch_fail(int error_code, const char *error) /* We cannot longjmp unless we're in retroarch_main_init(). * If not, something went very wrong, and we should * just exit right away. */ - strlcpy(global->error_string, - error, sizeof(global->error_string)); + strlcpy(global->error_string, error, + sizeof(global->error_string)); longjmp(global->error_sjlj_context, error_code); } diff --git a/runloop.c b/runloop.c index d7033073e3..62c6487629 100644 --- a/runloop.c +++ b/runloop.c @@ -1127,23 +1127,17 @@ static bool validate_game_options( * @return true if a game specific core * options path has been found, otherwise false. **/ -static bool validate_game_specific_options(char **output) +static bool validate_game_specific_options(char *s, size_t len) { - char game_options_path[PATH_MAX_LENGTH]; runloop_state_t *runloop_st = &runloop_state; - game_options_path[0] = '\0'; - if (!validate_game_options( runloop_st->system.info.library_name, - game_options_path, - sizeof(game_options_path), false) - || !path_is_valid(game_options_path)) + s, len, false) + || !path_is_valid(s)) return false; - RARCH_LOG("[Core]: %s \"%s\".\n", msg_hash_to_str(MSG_GAME_SPECIFIC_CORE_OPTIONS_FOUND_AT), - game_options_path); - *output = strdup(game_options_path); + s); return true; } @@ -1172,22 +1166,14 @@ static bool validate_folder_options( * @return true if a folder specific core * options path has been found, otherwise false. **/ -static bool validate_folder_specific_options( - char **output) +static bool validate_folder_specific_options(char *s, size_t len) { - char folder_options_path[PATH_MAX_LENGTH]; - folder_options_path[0] ='\0'; - - if (!validate_folder_options( - folder_options_path, - sizeof(folder_options_path), false) - || !path_is_valid(folder_options_path)) + if (!validate_folder_options(s, len, false) + || !path_is_valid(s)) return false; - RARCH_LOG("[Core]: %s \"%s\".\n", msg_hash_to_str(MSG_FOLDER_SPECIFIC_CORE_OPTIONS_FOUND_AT), - folder_options_path); - *output = strdup(folder_options_path); + s); return true; } @@ -1207,39 +1193,31 @@ static bool validate_folder_specific_options( **/ static void runloop_init_core_options_path( settings_t *settings, - char *path, size_t len, + char *s, size_t len, char *src_path, size_t src_len) { - char *options_path = NULL; runloop_state_t *runloop_st = &runloop_state; bool game_specific_options = settings->bools.game_specific_options; /* Check whether game-specific options exist */ if ( game_specific_options - && validate_game_specific_options(&options_path)) + && validate_game_specific_options(s, len)) { /* Notify system that we have a valid core options * override */ - path_set(RARCH_PATH_CORE_OPTIONS, options_path); + path_set(RARCH_PATH_CORE_OPTIONS, s); runloop_st->flags &= ~RUNLOOP_FLAG_FOLDER_OPTIONS_ACTIVE; runloop_st->flags |= RUNLOOP_FLAG_GAME_OPTIONS_ACTIVE; - - strlcpy(path, options_path, len); - free(options_path); } /* Check whether folder-specific options exist */ else if ( game_specific_options - && validate_folder_specific_options( - &options_path)) + && validate_folder_specific_options(s, len)) { /* Notify system that we have a valid core options * override */ - path_set(RARCH_PATH_CORE_OPTIONS, options_path); + path_set(RARCH_PATH_CORE_OPTIONS, s); runloop_st->flags &= ~RUNLOOP_FLAG_GAME_OPTIONS_ACTIVE; runloop_st->flags |= RUNLOOP_FLAG_FOLDER_OPTIONS_ACTIVE; - - strlcpy(path, options_path, len); - free(options_path); } else { @@ -1287,13 +1265,13 @@ static void runloop_init_core_options_path( /* Allocate correct path/src_path strings */ if (per_core_options) { - strlcpy(path, per_core_options_path, len); + strlcpy(s, per_core_options_path, len); if (!per_core_options_exist) strlcpy(src_path, global_options_path, src_len); } else - strlcpy(path, global_options_path, len); + strlcpy(s, global_options_path, len); /* Notify system that we *do not* have a valid core options * options override */ diff --git a/tasks/task_database.c b/tasks/task_database.c index 7d48fd24ca..6080af7e2d 100644 --- a/tasks/task_database.c +++ b/tasks/task_database.c @@ -124,9 +124,9 @@ static void task_database_scan_console_output(const char *label, const char *db_ unsigned reset = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; size_t _len = strlcpy(string, " ", sizeof(string)); _len += strlcpy(string + _len, prefix, sizeof(string) - _len); - strlcpy(string + _len, " ", sizeof(string) - _len); + _len += strlcpy(string + _len, " ", sizeof(string) - _len); SetConsoleTextAttribute(con, (add) ? green : (db_name) ? yellow : red); - WriteConsole(con, string, strlen(string), NULL, NULL); + WriteConsole(con, string, _len, NULL, NULL); SetConsoleTextAttribute(con, reset); } #else diff --git a/tasks/task_http.c b/tasks/task_http.c index f6753e4090..64e72aa586 100644 --- a/tasks/task_http.c +++ b/tasks/task_http.c @@ -434,7 +434,7 @@ void* task_push_http_transfer_file(const char* url, bool mute, const char* type, retro_task_callback_t cb, file_transfer_t* transfer_data) { - size_t len; + size_t _len; const char *s = NULL; char tmp[NAME_MAX_LENGTH] = ""; retro_task_t *t = NULL; @@ -449,19 +449,19 @@ void* task_push_http_transfer_file(const char* url, bool mute, return NULL; if (transfer_data) - s = transfer_data->path; + s = transfer_data->path; else - s = url; + s = url; - len = strlcpy(tmp, msg_hash_to_str(MSG_DOWNLOADING), sizeof(tmp)); - tmp[ len] = ' '; - tmp[++len] = '\0'; + _len = strlcpy(tmp, msg_hash_to_str(MSG_DOWNLOADING), sizeof(tmp)); + tmp[ _len] = ' '; + tmp[++_len] = '\0'; if (string_ends_with_size(s, ".index", strlen(s), STRLEN_CONST(".index"))) s = msg_hash_to_str(MSG_INDEX_FILE); - strlcpy(tmp + len, s, sizeof(tmp) - len); + strlcpy(tmp + _len, s, sizeof(tmp) - _len); t->title = strdup(tmp); return t; diff --git a/tasks/task_pl_thumbnail_download.c b/tasks/task_pl_thumbnail_download.c index c7b39b7de7..1bb1d3413f 100644 --- a/tasks/task_pl_thumbnail_download.c +++ b/tasks/task_pl_thumbnail_download.c @@ -139,7 +139,7 @@ static void gfx_thumbnail_get_db_name( /* Fetches local and remote paths for current thumbnail * of current type */ -static bool get_thumbnail_paths( +static bool task_pl_thumbnail_get_thumbnail_paths( pl_thumb_handle_t *pl_thumb, char *path, size_t path_size, char *url, size_t url_size) @@ -301,7 +301,9 @@ static void download_pl_thumbnail(pl_thumb_handle_t *pl_thumb) url[0] = '\0'; /* Check if paths are valid */ - if (get_thumbnail_paths(pl_thumb, path, sizeof(path), url, sizeof(url))) + if (task_pl_thumbnail_get_thumbnail_paths(pl_thumb, + path, sizeof(path), + url, sizeof(url))) { /* Only download missing thumbnails */ if (!path_is_valid(path) || (pl_thumb->flags & PL_THUMB_FLAG_OVERWRITE)) diff --git a/tasks/task_screenshot.c b/tasks/task_screenshot.c index 49aa1c2508..ce3399531b 100644 --- a/tasks/task_screenshot.c +++ b/tasks/task_screenshot.c @@ -306,13 +306,8 @@ static bool screenshot_dump( if (!fullpath) { if (savestate) - { - size_t len = strlcpy(state->filename, - name_base, sizeof(state->filename)); - strlcpy(state->filename + len, - ".png", - sizeof(state->filename) - len); - } + fill_pathname(state->filename, + name_base, ".png", sizeof(state->filename)); else { char new_screenshot_dir[DIR_MAX_LENGTH]; @@ -365,14 +360,9 @@ static bool screenshot_dump( IMG_EXT, sizeof(state->shotname)); } else - { - size_t len = strlcpy(state->shotname, + fill_pathname(state->shotname, path_basename_nocompression(name_base), - sizeof(state->shotname)); - strlcpy(state->shotname + len, - ".png", - sizeof(state->shotname) - len); - } + ".png", sizeof(state->shotname)); if ( string_is_empty(new_screenshot_dir) || settings->bools.screenshots_in_content_dir)