less string copies

This commit is contained in:
libretroadmin 2024-12-24 05:10:09 +01:00
parent 02bcbffbab
commit de8f979cb7
29 changed files with 214 additions and 314 deletions

View File

@ -1434,7 +1434,6 @@ void command_event_load_auto_state(void)
static void scan_states(settings_t *settings, static void scan_states(settings_t *settings,
unsigned *last_index, char *file_to_delete) unsigned *last_index, char *file_to_delete)
{ {
runloop_state_t *runloop_st = runloop_state_get_ptr(); runloop_state_t *runloop_st = runloop_state_get_ptr();
bool show_hidden_files = settings->bools.show_hidden_files; bool show_hidden_files = settings->bools.show_hidden_files;
unsigned savestate_max_keep = settings->uints.savestate_max_keep; unsigned savestate_max_keep = settings->uints.savestate_max_keep;

View File

@ -568,12 +568,11 @@ static enum frontend_powerstate frontend_ctr_get_powerstate(
return FRONTEND_POWERSTATE_ON_POWER_SOURCE; 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 cver;
OS_VersionBin nver; OS_VersionBin nver;
size_t _len = strlcpy(s, "3DS OS", len);
strlcpy(s, "3DS OS", len);
Result data_invalid = osGetSystemVersionData(&nver, &cver); Result data_invalid = osGetSystemVersionData(&nver, &cver);
if (data_invalid == 0) 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; *major = 0;
*minor = 0; *minor = 0;
} }
return _len;
} }
static void frontend_ctr_get_name(char* s, size_t len) static void frontend_ctr_get_name(char* s, size_t len)

View File

@ -280,31 +280,24 @@ static void frontend_darwin_get_name(char *s, size_t len)
#endif #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) #if defined(IOS)
get_ios_version(major, minor); get_ios_version(major, minor);
#if TARGET_OS_TV #if TARGET_OS_TV
s[0] = 't'; _len = strlcpy(s, "tvOS", len);
s[1] = 'v';
s[2] = 'O';
s[3] = 'S';
s[4] = '\0';
#else #else
s[0] = 'i'; _len = strlcpy(s, "iOS", len);
s[1] = 'O';
s[2] = 'S';
s[3] = '\0';
#endif #endif
#elif defined(OSX) #elif defined(OSX)
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101300 /* MAC_OS_X_VERSION_10_13 */ #if MAC_OS_X_VERSION_MIN_REQUIRED >= 101300 /* MAC_OS_X_VERSION_10_13 */
NSOperatingSystemVersion version = NSProcessInfo.processInfo.operatingSystemVersion; NSOperatingSystemVersion version = NSProcessInfo.processInfo.operatingSystemVersion;
*major = (int)version.majorVersion; *major = (int)version.majorVersion;
*minor = (int)version.minorVersion; *minor = (int)version.minorVersion;
#else #else
/* MacOS 10.9 includes the [NSProcessInfo operatingSystemVersion] function, but it's not in the 10.9 SDK. So, call it via NSInvocation */ /* 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) */ /* Credit: OpenJDK (https://github.com/openjdk/jdk/commit/d4c7db50) */
if ([[NSProcessInfo processInfo] respondsToSelector:@selector(operatingSystemVersion)]) if ([[NSProcessInfo processInfo] respondsToSelector:@selector(operatingSystemVersion)])
{ {
typedef struct typedef struct
@ -313,12 +306,12 @@ static void frontend_darwin_get_os(char *s, size_t len, int *major, int *minor)
NSInteger minorVersion; NSInteger minorVersion;
NSInteger patchVersion; NSInteger patchVersion;
} NSMyOSVersion; } NSMyOSVersion;
NSMyOSVersion version; NSMyOSVersion version;
NSMethodSignature *sig = [[NSProcessInfo processInfo] methodSignatureForSelector:@selector(operatingSystemVersion)]; NSMethodSignature *sig = [[NSProcessInfo processInfo] methodSignatureForSelector:@selector(operatingSystemVersion)];
NSInvocation *invoke = [NSInvocation invocationWithMethodSignature:sig]; NSInvocation *invoke = [NSInvocation invocationWithMethodSignature:sig];
invoke.selector = @selector(operatingSystemVersion); invoke.selector = @selector(operatingSystemVersion);
[invoke invokeWithTarget:[NSProcessInfo processInfo]]; [invoke invokeWithTarget:[NSProcessInfo processInfo]];
[invoke getReturnValue:&version]; [invoke getReturnValue:&version];
*major = (int)version.majorVersion; *major = (int)version.majorVersion;
*minor = (int)version.minorVersion; *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); Gestalt(gestaltSystemVersionMajor, (SInt32*)major);
} }
#endif #endif
s[0] = 'O'; _len = strlcpy(s, "OSX", len);
s[1] = 'S';
s[2] = 'X';
s[3] = '\0';
#endif #endif
return _len;
} }
static void frontend_darwin_get_env(int *argc, char *argv[], static void frontend_darwin_get_env(int *argc, char *argv[],

View File

@ -86,7 +86,7 @@ extern bool nxlink_connected;
void libnx_apply_overclock(void) 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]); / sizeof(SWITCH_CPU_PROFILES[1]);
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
unsigned libnx_overclock = settings->uints.libnx_overclock; unsigned libnx_overclock = settings->uints.libnx_overclock;
@ -565,7 +565,7 @@ static void frontend_switch_init(void *data)
bool recording_supported = false; bool recording_supported = false;
nifmInitialize(NifmServiceType_User); nifmInitialize(NifmServiceType_User);
if (hosversionBefore(8, 0, 0)) if (hosversionBefore(8, 0, 0))
pcvInitialize(); pcvInitialize();
else else
@ -609,8 +609,8 @@ static int frontend_switch_parse_drive_list(void *data, bool load_content)
{ {
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER
file_list_t *list = (file_list_t *)data; file_list_t *list = (file_list_t *)data;
enum msg_hash_enums enum_idx = load_content enum msg_hash_enums enum_idx = load_content
? MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR ? MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR
: MENU_ENUM_LABEL_FILE_BROWSER_DIRECTORY; : MENU_ENUM_LABEL_FILE_BROWSER_DIRECTORY;
if (!list) if (!list)
@ -637,7 +637,7 @@ static uint64_t frontend_switch_get_total_mem(void)
return mem_info.usmblks; return mem_info.usmblks;
} }
static enum frontend_powerstate static enum frontend_powerstate
frontend_switch_get_powerstate(int *seconds, int *percent) frontend_switch_get_powerstate(int *seconds, int *percent)
{ {
uint32_t pct; uint32_t pct;
@ -671,9 +671,10 @@ frontend_switch_get_powerstate(int *seconds, int *percent)
return FRONTEND_POWERSTATE_NO_SOURCE; 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) char *s, size_t len, int *major, int *minor)
{ {
size_t _len;
#ifdef HAVE_LIBNX #ifdef HAVE_LIBNX
u32 hosVersion; u32 hosVersion;
#else #else
@ -684,7 +685,7 @@ static void frontend_switch_get_os(
ipc_request_t rq; ipc_request_t rq;
#endif #endif
strlcpy(s, "Horizon OS", len); _len = strlcpy(s, "Horizon OS", len);
#ifdef HAVE_LIBNX #ifdef HAVE_LIBNX
*major = 0; *major = 0;
@ -716,8 +717,8 @@ fail_object:
fail_sm: fail_sm:
sm_finalize(); sm_finalize();
fail: fail:
return;
#endif #endif
return _len;
} }
static void frontend_switch_get_name(char *s, size_t len) static void frontend_switch_get_name(char *s, size_t len)

View File

@ -1240,39 +1240,38 @@ static enum frontend_architecture frontend_unix_get_arch(void)
return FRONTEND_ARCH_NONE; 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, int *major, int *minor)
{ {
size_t _len = 0;
#ifdef ANDROID #ifdef ANDROID
int rel; int rel;
frontend_android_get_version(major, minor, &rel); frontend_android_get_version(major, minor, &rel);
_len = strlcpy(s, "Android", len);
strlcpy(s, "Android", len);
#else #else
char *ptr; char *ptr;
struct utsname buffer; struct utsname buffer;
if (uname(&buffer) != 0) if (uname(&buffer) != 0)
return; return;
*major = (int)strtol(buffer.release, &ptr, 10); *major = (int)strtol(buffer.release, &ptr, 10);
*minor = (int)strtol(++ptr, NULL, 10); *minor = (int)strtol(++ptr, NULL, 10);
#if defined(__FreeBSD__) #if defined(__FreeBSD__)
strlcpy(s, "FreeBSD", len); _len = strlcpy(s, "FreeBSD", len);
#elif defined(__NetBSD__) #elif defined(__NetBSD__)
strlcpy(s, "NetBSD", len); _len = strlcpy(s, "NetBSD", len);
#elif defined(__OpenBSD__) #elif defined(__OpenBSD__)
strlcpy(s, "OpenBSD", len); _len = strlcpy(s, "OpenBSD", len);
#elif defined(__DragonFly__) #elif defined(__DragonFly__)
strlcpy(s, "DragonFly BSD", len); _len = strlcpy(s, "DragonFly BSD", len);
#elif defined(BSD) #elif defined(BSD)
strlcpy(s, "BSD", len); _len = strlcpy(s, "BSD", len);
#elif defined(__HAIKU__) #elif defined(__HAIKU__)
strlcpy(s, "Haiku", len); _len = strlcpy(s, "Haiku", len);
#else #else
strlcpy(s, "Linux", len); _len = strlcpy(s, "Linux", len);
#endif #endif
#endif #endif
return _len;
} }
#ifdef HAVE_LAKKA #ifdef HAVE_LAKKA

View File

@ -47,7 +47,7 @@
#include "../../uwp/uwp_func.h" #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; size_t _len;
char build_str[11] = {0}; 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); _len += strlcpy(s + _len, " ", len - _len);
strlcpy(s + _len, uwp_device_family, len - _len); strlcpy(s + _len, uwp_device_family, len - _len);
} }
return _len;
} }
static void frontend_uwp_init(void *data) { } static void frontend_uwp_init(void *data) { }

View File

@ -267,7 +267,7 @@ static void gfx_set_dwm(void)
g_plat_win32_flags |= PLAT_WIN32_FLAG_DWM_COMPOSITION_DISABLED; 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; size_t _len = 0;
char build_str[11] = {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); _len += strlcpy(s + _len, " ", len - _len);
strlcpy(s + _len, vi.szCSDVersion, len - _len); strlcpy(s + _len, vi.szCSDVersion, len - _len);
} }
return _len;
} }
static void frontend_win32_init(void *data) static void frontend_win32_init(void *data)

View File

@ -88,7 +88,7 @@ typedef struct frontend_ctx_driver
bool (*set_fork)(enum frontend_fork fork_mode); bool (*set_fork)(enum frontend_fork fork_mode);
void (*shutdown)(bool); void (*shutdown)(bool);
void (*get_name)(char *, size_t); 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); int (*get_rating)(void);
void (*content_loaded)(void); void (*content_loaded)(void);
enum frontend_architecture (*get_architecture)(void); enum frontend_architecture (*get_architecture)(void);

View File

@ -670,7 +670,7 @@ static bool win32_browser(
* FIXME: We should really handle the * FIXME: We should really handle the
* error case when this isn't big enough. */ * error case when this isn't big enough. */
char new_title[PATH_MAX]; 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_title[0] = '\0';
new_file[0] = '\0'; new_file[0] = '\0';

View File

@ -1063,7 +1063,7 @@ void Pass::reflect_parameter_array(const char *name, std::vector<slang_texture_s
frag = glGetUniformLocation(pipeline, frag_n); frag = glGetUniformLocation(pipeline, frag_n);
if (vert >= 0) if (vert >= 0)
m->location.push_vertex = vert; m->location.push_vertex = vert;
if (frag >= 0) if (frag >= 0)
m->location.push_fragment = frag; m->location.push_fragment = frag;
} }

View File

@ -177,8 +177,6 @@ typedef struct gfx_display_ctx_coord_draw
typedef struct gfx_display_ctx_datetime typedef struct gfx_display_ctx_datetime
{ {
char *s;
size_t len;
unsigned time_mode; unsigned time_mode;
unsigned date_separator; unsigned date_separator;
} gfx_display_ctx_datetime_t; } gfx_display_ctx_datetime_t;
@ -297,7 +295,7 @@ bool gfx_display_reset_icon_texture(
const char *texture_path, const char *texture_path,
uintptr_t *item, enum texture_filter_type filter_type, uintptr_t *item, enum texture_filter_type filter_type,
unsigned *width, unsigned *height); unsigned *width, unsigned *height);
bool gfx_display_reset_textures_list_buffer( bool gfx_display_reset_textures_list_buffer(
uintptr_t *item, uintptr_t *item,
enum texture_filter_type filter_type, enum texture_filter_type filter_type,

View File

@ -375,9 +375,9 @@ bool gfx_thumbnail_set_content_image(
img_dir, img_name, sizeof(path_data->content_path)); img_dir, img_name, sizeof(path_data->content_path));
/* Set core name to "imageviewer" */ /* Set core name to "imageviewer" */
strlcpy( strlcpy(path_data->content_core_name,
path_data->content_core_name, "imageviewer",
"imageviewer", sizeof(path_data->content_core_name)); sizeof(path_data->content_core_name));
/* Set database name (arbitrarily) to "_images_" /* Set database name (arbitrarily) to "_images_"
* (required for compatibility with gfx_thumbnail_update_path(), * (required for compatibility with gfx_thumbnail_update_path(),

View File

@ -469,8 +469,8 @@ bool gfx_widget_start_load_content_animation(void)
/* We can only use the core db_name if the /* We can only use the core db_name if the
* core is associated with exactly one database */ * core is associated with exactly one database */
if (databases_list && if ( databases_list
(databases_list->size == 1)) && (databases_list->size == 1))
core_db_name = databases_list->elems[0].data; core_db_name = databases_list->elems[0].data;
if ( !string_is_empty(core_db_name) 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) ? state->system_name_width = (system_name_width > 0) ?
(unsigned)system_name_width : 0; (unsigned)system_name_width : 0;
text_width = (state->content_name_width > state->system_name_width) ? text_width = (state->content_name_width > state->system_name_width)
(int)state->content_name_width : (int)state->system_name_width; ? (int)state->content_name_width
: (int)state->system_name_width;
/* Now we have the text width, can determine /* Now we have the text width, can determine
* final icon/text x draw positions */ * 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) ? state->system_name_width = (system_name_width > 0) ?
(unsigned)system_name_width : 0; (unsigned)system_name_width : 0;
text_width = (state->content_name_width > state->system_name_width) ? text_width = (state->content_name_width > state->system_name_width)
(int)state->content_name_width : (int)state->system_name_width; ? (int)state->content_name_width
: (int)state->system_name_width;
/* Now we have the text width, can determine /* Now we have the text width, can determine
* final icon/text x draw positions */ * final icon/text x draw positions */

View File

@ -443,14 +443,13 @@ static int general_push(menu_displaylist_info_t *info,
else else
{ {
char tmp_path[PATH_MAX_LENGTH]; char tmp_path[PATH_MAX_LENGTH];
fill_pathname_expand_special(tmp_path, menu->scratch2_buf, sizeof(tmp_path)); fill_pathname_expand_special(tmp_path,
const char *menu_path = tmp_path; menu->scratch2_buf, sizeof(tmp_path));
fill_pathname_join_special(tmp_str, menu_path, fill_pathname_join_special(tmp_str, tmp_path,
menu->scratch_buf, sizeof(tmp_str)); menu->scratch_buf, sizeof(tmp_str));
} }
#else #else
const char *menu_path = menu->scratch2_buf; fill_pathname_join_special(tmp_str, menu->scratch2_buf,
fill_pathname_join_special(tmp_str, menu_path,
menu->scratch_buf, sizeof(tmp_str)); menu->scratch_buf, sizeof(tmp_str));
#endif #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; bool filter_by_current_core = settings->bools.filter_by_current_core;
if (sysinfo && !string_is_empty(sysinfo->valid_extensions)) if (sysinfo && !string_is_empty(sysinfo->valid_extensions))
{
_len += strlcpy(newstr2 + _len, _len += strlcpy(newstr2 + _len,
sysinfo->valid_extensions, sysinfo->valid_extensions,
sizeof(newstr2) - _len); sizeof(newstr2) - _len);
}
if (!filter_by_current_core) if (!filter_by_current_core)
{ {

View File

@ -567,8 +567,8 @@ static void action_ok_get_file_browser_start_path(
/* If current path is invalid, use default path */ /* If current path is invalid, use default path */
if (!current_path_valid) if (!current_path_valid)
{ {
if (string_is_empty(default_path) || if ( string_is_empty(default_path)
!path_is_directory(default_path)) || !path_is_directory(default_path))
{ {
start_path[0] = '\0'; start_path[0] = '\0';
return; return;
@ -5001,23 +5001,18 @@ finish:
STRLEN_CONST(FILE_PATH_INDEX_DIRS_URL) STRLEN_CONST(FILE_PATH_INDEX_DIRS_URL)
)) ))
{ {
char parent_dir[DIR_MAX_LENGTH];
char parent_dir_encoded[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'; parent_dir_encoded[0] = '\0';
fill_pathname_parent_dir(parent_dir, transf->enum_idx = MSG_UNKNOWN;
state->path, sizeof(parent_dir));
strlcat(parent_dir, FILE_PATH_INDEX_DIRS_URL,
sizeof(parent_dir));
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; net_http_urlencode_full(parent_dir_encoded, transf->path,
strlcpy(transf->path, parent_dir, sizeof(transf->path));
net_http_urlencode_full(parent_dir_encoded, parent_dir,
sizeof(parent_dir_encoded)); sizeof(parent_dir_encoded));
task_push_http_transfer_file(parent_dir_encoded, true, task_push_http_transfer_file(parent_dir_encoded, true,
"index_dirs", cb_net_generic_subdir, transf); "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) const char *label, unsigned type, size_t idx, size_t entry_idx)
{ {
menu_entry_t entry; menu_entry_t entry;
#if IOS
char tmp[PATH_MAX_LENGTH];
#endif
char current_value[PATH_MAX_LENGTH]; char current_value[PATH_MAX_LENGTH];
struct menu_state *menu_st = menu_state_get_ptr(); struct menu_state *menu_st = menu_state_get_ptr();
menu_handle_t *menu = menu_st->driver_data; 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); menu_entry_get(&entry, 0, menu_st->selection_ptr, NULL, true);
strlcpy(current_value, entry.value, sizeof(current_value)); strlcpy(current_value, entry.value, sizeof(current_value));
#if IOS #if IOS
char tmp[PATH_MAX_LENGTH];
fill_pathname_expand_special(tmp, current_value, sizeof(tmp)); fill_pathname_expand_special(tmp, current_value, sizeof(tmp));
if (!path_is_directory(tmp)) if (!path_is_directory(tmp))
current_value[0] = '\0'; 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, 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 *label, unsigned type, size_t idx, size_t entry_idx)
{ {
const char *menu_path = NULL;
enum msg_hash_enums enum_idx; enum msg_hash_enums enum_idx;
rarch_setting_t *setting; rarch_setting_t *setting;
const char *menu_path = NULL;
menu_entries_get_last_stack(&menu_path, NULL, NULL, NULL, NULL); menu_entries_get_last_stack(&menu_path, NULL, NULL, NULL, NULL);
enum_idx = (enum msg_hash_enums)atoi(menu_path); enum_idx = (enum msg_hash_enums)atoi(menu_path);
setting = menu_setting_find_enum(enum_idx); 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) if (!setting)
return -1; return -1;
strlcpy(setting->value.target.string, strlcpy(setting->value.target.string, label, setting->size);
label, setting->size);
return action_cancel_pop_default(NULL, NULL, 0, 0); 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, static int action_ok_disk_image_append(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx) 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; rarch_system_info_t *sys_info = &runloop_state_get_ptr()->system;
struct menu_state *menu_st = menu_state_get_ptr(); struct menu_state *menu_st = menu_state_get_ptr();
menu_handle_t *menu = menu_st->driver_data; menu_handle_t *menu = menu_st->driver_data;
@ -7993,8 +7988,6 @@ static int action_ok_disk_image_append(const char *path,
#endif #endif
bool menu_insert_disk_resume = settings->bools.menu_insert_disk_resume; bool menu_insert_disk_resume = settings->bools.menu_insert_disk_resume;
image_path[0] = '\0';
if (!menu) if (!menu)
return -1; return -1;
@ -8009,6 +8002,7 @@ static int action_ok_disk_image_append(const char *path,
if (!string_is_empty(menu_path)) if (!string_is_empty(menu_path))
{ {
char image_path[PATH_MAX_LENGTH];
bool is_dir = (entry_idx == FILE_TYPE_USE_DIRECTORY bool is_dir = (entry_idx == FILE_TYPE_USE_DIRECTORY
&& string_is_equal(label, && string_is_equal(label,
msg_hash_to_str(MENU_ENUM_LABEL_USE_THIS_DIRECTORY))); 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; size_t past_slash;
strlcpy(image_path, menu_path, sizeof(image_path)); strlcpy(image_path, menu_path, sizeof(image_path));
past_slash = fill_pathname_slash(image_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)) else if (!string_is_empty(path))
fill_pathname_join_special(image_path, fill_pathname_join_special(image_path,
menu_path, path, sizeof(image_path)); menu_path, path, sizeof(image_path));
else else
strlcpy(image_path, menu_path, sizeof(image_path)); 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 */ /* In all cases, return to the disk options menu */
menu_entries_flush_stack(msg_hash_to_str(MENU_ENUM_LABEL_DISK_OPTIONS), 0); 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, 1, 480, true, NULL,
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
#endif #endif
menu_input_dialog_end(); menu_input_dialog_end();
} }
else else

View File

@ -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) 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))
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"))
{ {
/* Handle content history */ const char *playlist_file = path_basename_nocompression(path);
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 */ if (!string_is_empty(playlist_file))
menu_entries_search_append_terms_string(s, len); {
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; return 0;
} }

View File

@ -5857,15 +5857,10 @@ static void materialui_render_header(
{ {
gfx_display_ctx_datetime_t datetime; gfx_display_ctx_datetime_t datetime;
char timedate_str[MUI_TIMEDATE_MAX_LENGTH]; 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.time_mode = menu_timedate_style;
datetime.date_separator = menu_timedate_date_separator; 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 /* Need to determine pixel width of time string
* > This is somewhat expensive, so utilise a cache * > This is somewhat expensive, so utilise a cache

View File

@ -10576,12 +10576,10 @@ static void ozone_draw_header(
gfx_display_ctx_datetime_t datetime; gfx_display_ctx_datetime_t datetime;
char timedate[256]; char timedate[256];
datetime.s = timedate;
datetime.time_mode = settings->uints.menu_timedate_style; datetime.time_mode = settings->uints.menu_timedate_style;
datetime.date_separator = settings->uints.menu_timedate_date_separator; 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( gfx_display_draw_text(
ozone->fonts.time.font, ozone->fonts.time.font,

View File

@ -5785,17 +5785,12 @@ static void rgui_render(
/* Print clock (if required) */ /* Print clock (if required) */
if (menu_timedate_enable) if (menu_timedate_enable)
{ {
gfx_display_ctx_datetime_t datetime;
char timedate[16]; char timedate[16];
gfx_display_ctx_datetime_t datetime;
timedate[0] = '\0';
datetime.s = timedate;
datetime.len = sizeof(timedate);
datetime.time_mode = MENU_TIMEDATE_STYLE_HM; datetime.time_mode = MENU_TIMEDATE_STYLE_HM;
datetime.date_separator = MENU_TIMEDATE_DATE_SEPARATOR_HYPHEN; datetime.date_separator = MENU_TIMEDATE_DATE_SEPARATOR_HYPHEN;
menu_display_timedate(&datetime); menu_display_timedate(&datetime, timedate, sizeof(timedate));
rgui_blit_line(rgui, rgui_blit_line(rgui,
fb_width, fb_width,

View File

@ -6998,14 +6998,9 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
dispctx->blend_end(userdata); dispctx->blend_end(userdata);
} }
timedate[0] = '\0';
datetime.s = timedate;
datetime.len = sizeof(timedate);
datetime.time_mode = settings->uints.menu_timedate_style; datetime.time_mode = settings->uints.menu_timedate_style;
datetime.date_separator = settings->uints.menu_timedate_date_separator; datetime.date_separator = settings->uints.menu_timedate_date_separator;
_len = menu_display_timedate(&datetime, timedate, sizeof(timedate));
_len = menu_display_timedate(&datetime);
title_header_max_width = x_pos + font_driver_get_message_width( title_header_max_width = x_pos + font_driver_get_message_width(
xmb->font, timedate, _len, 1.0f); xmb->font, timedate, _len, 1.0f);

View File

@ -757,13 +757,13 @@ static int menu_displaylist_parse_core_info(
if (core_info->firmware_count > 0) if (core_info->firmware_count > 0)
{ {
char tmp_path[PATH_MAX_LENGTH];
core_info_ctx_firmware_t firmware_info; core_info_ctx_firmware_t firmware_info;
uint8_t flags = content_get_flags(); uint8_t flags = content_get_flags();
bool update_missing_firmware = false; bool update_missing_firmware = false;
bool set_missing_firmware = false; bool set_missing_firmware = false;
bool systemfiles_in_content_dir = settings->bools.systemfiles_in_content_dir; bool systemfiles_in_content_dir = settings->bools.systemfiles_in_content_dir;
bool content_is_inited = flags & CONTENT_ST_FLAG_IS_INITED; bool content_is_inited = flags & CONTENT_ST_FLAG_IS_INITED;
char tmp_path[PATH_MAX_LENGTH];
firmware_info.path = core_info->path; 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 */ * adjust the path to check for firmware files */
if (systemfiles_in_content_dir && content_is_inited) if (systemfiles_in_content_dir && content_is_inited)
{ {
strlcpy(tmp_path, path_get(RARCH_PATH_CONTENT), sizeof(tmp_path)); fill_pathname_basedir(tmp_path,
path_basedir(tmp_path); path_get(RARCH_PATH_CONTENT),
sizeof(tmp_path));
/* If content path is empty, fall back to global system dir path */ /* If content path is empty, fall back to global system dir path */
if (string_is_empty(tmp_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 */ /* Show relevant note row and skip showing it later */
if (core_info->notes) if (core_info->notes)
{ {
unsigned pos;
unsigned j; unsigned j;
char firmware_basename[64]; 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'; firmware_basename[string_find_index_substring_string(firmware_basename, " ")] = '\0';
for (j = 0; j < core_info->note_list->size; j++) for (j = 0; j < core_info->note_list->size; j++)
{ {
unsigned pos;
if ( !strstr(core_info->note_list->elems[j].data, firmware_basename) if ( !strstr(core_info->note_list->elems[j].data, firmware_basename)
|| !strstr(core_info->note_list->elems[j].data, "(md5)")) || !strstr(core_info->note_list->elems[j].data, "(md5)"))
continue; continue;
@ -884,7 +885,7 @@ static int menu_displaylist_parse_core_info(
core_info_list_hide[j] = true; core_info_list_hide[j] = true;
len = strlcpy(tmp, "- ", sizeof(tmp)); 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, "", if (menu_entries_append(list, tmp, "",
MENU_ENUM_LABEL_CORE_INFO_ENTRY, MENU_ENUM_LABEL_CORE_INFO_ENTRY,
@ -2043,15 +2044,13 @@ static unsigned menu_displaylist_parse_system_info(file_list_t *list)
/* Lakka Version */ /* Lakka Version */
if (frontend->get_lakka_version) if (frontend->get_lakka_version)
{ {
char lakka_ver[64];
frontend->get_lakka_version(lakka_ver, sizeof(lakka_ver));
_len = strlcpy(entry, _len = strlcpy(entry,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_LAKKA_VERSION), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_LAKKA_VERSION),
sizeof(entry)); sizeof(entry));
entry[ _len] = ':'; entry[ _len] = ':';
entry[++_len] = ' '; entry[++_len] = ' ';
entry[++_len] = '\0'; 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, "", if (menu_entries_append(list, entry, "",
MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE,
0, 0, NULL)) 0, 0, NULL))
@ -2061,15 +2060,13 @@ static unsigned menu_displaylist_parse_system_info(file_list_t *list)
/* Frontend name */ /* Frontend name */
if (frontend->get_name) if (frontend->get_name)
{ {
char frontend_name[64];
frontend->get_name(frontend_name, sizeof(frontend_name));
_len = strlcpy(entry, _len = strlcpy(entry,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_FRONTEND_NAME), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_FRONTEND_NAME),
sizeof(entry)); sizeof(entry));
entry[ _len] = ':'; entry[ _len] = ':';
entry[++_len] = ' '; entry[++_len] = ' ';
entry[++_len] = '\0'; 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, "", if (menu_entries_append(list, entry, "",
MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE,
0, 0, NULL)) 0, 0, NULL))
@ -2079,17 +2076,16 @@ static unsigned menu_displaylist_parse_system_info(file_list_t *list)
/* Frontend OS */ /* Frontend OS */
if (frontend->get_os) if (frontend->get_os)
{ {
char os_ver[64];
int major = 0; int major = 0;
int minor = 0; int minor = 0;
frontend->get_os(os_ver, sizeof(os_ver), &major, &minor);
_len = strlcpy(entry, _len = strlcpy(entry,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_FRONTEND_OS), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_FRONTEND_OS),
sizeof(entry)); sizeof(entry));
entry[ _len] = ':'; entry[ _len] = ':';
entry[++_len] = ' '; entry[++_len] = ' ';
entry[++_len] = '\0'; 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, snprintf(entry + _len,
sizeof(entry) - _len, sizeof(entry) - _len,
" (v%d.%d)", major, minor); " (v%d.%d)", major, minor);
@ -2750,6 +2746,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
settings_t *settings, settings_t *settings,
menu_displaylist_info_t *info) menu_displaylist_info_t *info)
{ {
size_t _len;
size_t path_len; size_t path_len;
unsigned i, j, k; unsigned i, j, k;
char query[256]; 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))) if (!(db_info = database_info_list_new(info->path, query)))
return -1; return -1;
fill_pathname(path_base, path_basename(info->path), "", _len = fill_pathname(path_base, path_basename(info->path), "",
sizeof(path_base)); sizeof(path_base));
gfx_thumbnail_set_system(menu_st->thumbnail_path_data, gfx_thumbnail_set_system(menu_st->thumbnail_path_data,
path_base, playlist_get_cached()); 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, fill_pathname_join_special(menu->db_playlist_file,
dir_playlist, path_base, dir_playlist, path_base,
@ -4132,17 +4129,17 @@ static int menu_displaylist_parse_horizontal_content_actions(
{ {
const char *tmp; const char *tmp;
char sys_thumb[64]; char sys_thumb[64];
size_t sys_len = 0; size_t __len = 0;
if (gfx_thumbnail_get_system(menu_st->thumbnail_path_data, &tmp)) 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)) if (!string_is_empty(sys_thumb))
remove_entry_enabled = remove_entry_enabled =
string_is_equal(sys_thumb, "history") string_is_equal(sys_thumb, "history")
|| string_is_equal(sys_thumb, "favorites") || string_is_equal(sys_thumb, "favorites")
|| string_ends_with_size(sys_thumb, "_history", || 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, /* An annoyance: if the user navigates to the information menu,
* then to the database entry, the thumbnail system will be changed. * 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 */ /* Only show 'Download Thumbnails' on supported playlists */
char sys_thumb[64]; char sys_thumb[64];
const char *tmp = NULL; const char *tmp = NULL;
size_t sys_len = 0; size_t __len = 0;
if (gfx_thumbnail_get_system(menu_st->thumbnail_path_data, &tmp)) 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)) if (!string_is_empty(sys_thumb))
download_enabled = !string_ends_with_size( download_enabled = !string_ends_with_size(
sys_thumb, "_history", sys_len, STRLEN_CONST("_history")); sys_thumb, "_history", __len, STRLEN_CONST("_history"));
else else
download_enabled = false; download_enabled = false;
} }
@ -5201,25 +5198,18 @@ static unsigned menu_displaylist_parse_content_information(
/* Database */ /* Database */
if (!string_is_empty(db_name)) if (!string_is_empty(db_name))
{ {
char db_name_no_ext_buff[NAME_MAX_LENGTH]; size_t _len = strlcpy(tmp,
fill_pathname(db_name_no_ext_buff, db_name, "", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CONTENT_INFO_DATABASE),
sizeof(db_name_no_ext_buff)); sizeof(tmp));
tmp[ _len] = ':';
if (!string_is_empty(db_name_no_ext_buff)) tmp[++_len] = ' ';
{ tmp[++_len] = '\0';
size_t _len = strlcpy(tmp, fill_pathname(tmp + _len, db_name, "", sizeof(tmp) - _len);
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CONTENT_INFO_DATABASE), if (menu_entries_append(info_list, tmp,
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,
msg_hash_to_str(MENU_ENUM_LABEL_CONTENT_INFO_DATABASE), msg_hash_to_str(MENU_ENUM_LABEL_CONTENT_INFO_DATABASE),
MENU_ENUM_LABEL_CONTENT_INFO_DATABASE, MENU_ENUM_LABEL_CONTENT_INFO_DATABASE,
0, 0, 0, NULL)) 0, 0, 0, NULL))
count++; count++;
}
} }
/* If content path is empty and core supports /* If content path is empty and core supports
@ -7245,12 +7235,12 @@ unsigned menu_displaylist_build_list(
break; break;
case DISPLAYLIST_INPUT_HAPTIC_FEEDBACK_SETTINGS_LIST: case DISPLAYLIST_INPUT_HAPTIC_FEEDBACK_SETTINGS_LIST:
{ {
char os_ver[64];
int major, minor;
input_driver_t *current_input = input_driver_t *current_input =
input_state_get_ptr()->current_driver; input_state_get_ptr()->current_driver;
const frontend_ctx_driver_t *frontend = const frontend_ctx_driver_t *frontend =
frontend_get_ptr(); frontend_get_ptr();
char os_ver[64] = {0};
int major, minor;
if (frontend && frontend->get_os) if (frontend && frontend->get_os)
frontend->get_os(os_ver, sizeof(os_ver), &major, &minor); 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 #ifdef HAVE_AUDIOMIXER
{ {
char lbl[128]; char lbl[128];
char mixer_stream_str[128];
unsigned id = info->type - MENU_SETTINGS_AUDIO_MIXER_STREAM_ACTIONS_BEGIN; unsigned id = info->type - MENU_SETTINGS_AUDIO_MIXER_STREAM_ACTIONS_BEGIN;
size_t _len = strlcpy(mixer_stream_str, "mixer_stream_", sizeof(mixer_stream_str)); size_t _len = strlcpy(lbl, "mixer_stream_", sizeof(lbl));
_len += snprintf(lbl + _len, sizeof(lbl) - _len, "%d", id);
lbl[0] = '\0';
snprintf(mixer_stream_str + _len, sizeof(mixer_stream_str) - _len, "%d", id);
_len = strlcpy(lbl, mixer_stream_str, sizeof(lbl));
strlcpy(lbl + _len, "_action_play", sizeof(lbl) - _len); strlcpy(lbl + _len, "_action_play", sizeof(lbl) - _len);
if (menu_entries_append(info->list, if (menu_entries_append(info->list,

View File

@ -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 /* Display the date and time - time_mode will influence how
* the time representation will look like. * 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 /* Storage container for current menu datetime
* representation string */ * representation string */
@ -1008,10 +1008,9 @@ size_t menu_display_timedate(gfx_display_ctx_datetime_t *datetime)
strftime(datetime_cache, sizeof(datetime_cache), strftime(datetime_cache, sizeof(datetime_cache),
format_str, &tm_); format_str, &tm_);
} }
/* Copy cached datetime string to input /* Copy cached datetime string to input
* menu_display_ctx_datetime_t struct */ * 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 */ /* 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) struct menu_state *menu_st, char *s, size_t len)
{ {
menu_entry_t entry; menu_entry_t entry;
const char* entry_label;
MENU_ENTRY_INITIALIZE(entry); MENU_ENTRY_INITIALIZE(entry);
entry.flags |= MENU_ENTRY_FLAG_VALUE_ENABLED; entry.flags |= MENU_ENTRY_FLAG_VALUE_ENABLED;
menu_entry_get(&entry, 0, menu_st->selection_ptr, NULL, true); menu_entry_get(&entry, 0, menu_st->selection_ptr, NULL, true);
if (entry.enum_idx == MENU_ENUM_LABEL_CHEEVOS_PASSWORD) if (entry.enum_idx == MENU_ENUM_LABEL_CHEEVOS_PASSWORD)
entry_label = entry.password_value; return strlcpy(s, entry.password_value, len);
else return strlcpy(s, entry.value, len);
entry_label = entry.value;
strlcpy(s, entry_label, len);
} }
#ifdef HAVE_ACCESSIBILITY #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) char *s, size_t len)
{ {
menu_entry_t entry; menu_entry_t entry;
const char* entry_label;
MENU_ENTRY_INITIALIZE(entry); MENU_ENTRY_INITIALIZE(entry);
entry.flags |= MENU_ENTRY_FLAG_PATH_ENABLED entry.flags |= MENU_ENTRY_FLAG_PATH_ENABLED
| MENU_ENTRY_FLAG_LABEL_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_VALUE_ENABLED
| MENU_ENTRY_FLAG_SUBLABEL_ENABLED; | MENU_ENTRY_FLAG_SUBLABEL_ENABLED;
menu_entry_get(&entry, 0, menu_st->selection_ptr, NULL, true); menu_entry_get(&entry, 0, menu_st->selection_ptr, NULL, true);
if (!string_is_empty(entry.rich_label)) if (!string_is_empty(entry.rich_label))
entry_label = entry.rich_label; return strlcpy(s, entry.rich_label, len);
else return strlcpy(s, entry.path, len);
entry_label = entry.path;
strlcpy(s, entry_label, len);
} }
#endif #endif
static void menu_driver_get_current_menu_sublabel( static size_t menu_driver_get_current_menu_sublabel(
struct menu_state *menu_st, struct menu_state *menu_st,
char *s, size_t len) char *s, size_t len)
{ {
menu_entry_t entry; menu_entry_t entry;
MENU_ENTRY_INITIALIZE(entry); MENU_ENTRY_INITIALIZE(entry);
entry.flags |= MENU_ENTRY_FLAG_SUBLABEL_ENABLED; entry.flags |= MENU_ENTRY_FLAG_SUBLABEL_ENABLED;
menu_entry_get(&entry, 0, menu_st->selection_ptr, NULL, true); 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, 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, char *s, size_t len,
bool is_quick_menu, const char *title) bool is_quick_menu, const char *title)
{ {
char tmpstr[64];
menu_entry_t selected_entry; menu_entry_t selected_entry;
struct menu_state *menu_st = &menu_driver_state; struct menu_state *menu_st = &menu_driver_state;
const char *thumbnail_label = NULL;
/* > Get menu entry */ /* > Get menu entry */
MENU_ENTRY_INITIALIZE(selected_entry); MENU_ENTRY_INITIALIZE(selected_entry);
selected_entry.flags |= MENU_ENTRY_FLAG_LABEL_ENABLED selected_entry.flags |= MENU_ENTRY_FLAG_LABEL_ENABLED
| MENU_ENTRY_FLAG_RICH_LABEL_ENABLED; | MENU_ENTRY_FLAG_RICH_LABEL_ENABLED;
menu_entry_get(&selected_entry, 0, menu_st->selection_ptr, NULL, true); menu_entry_get(&selected_entry, 0, menu_st->selection_ptr, NULL, true);
/* > Get entry label */ /* > Get entry label */
if (!string_is_empty(selected_entry.rich_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 */ /* > State slot label */
else if ( is_quick_menu 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), size_t _len = strlcpy(s,
sizeof(tmpstr)); msg_hash_to_str(MENU_ENUM_LABEL_VALUE_STATE_SLOT),
snprintf(tmpstr + _len, sizeof(tmpstr) - _len, " %d", len);
_len += snprintf(s + _len, len - _len, " %d",
config_get_ptr()->ints.state_slot); config_get_ptr()->ints.state_slot);
thumbnail_label = tmpstr; return _len;
} }
else if ( is_quick_menu else if ( is_quick_menu
&& ( && (
@ -8075,41 +8058,41 @@ size_t menu_update_fullscreen_thumbnail_label(
|| string_is_equal(selected_entry.label, "halt_replay") || string_is_equal(selected_entry.label, "halt_replay")
)) ))
{ {
size_t _len = strlcpy(tmpstr, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_REPLAY_SLOT), size_t _len = strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_REPLAY_SLOT),
sizeof(tmpstr)); len);
snprintf(tmpstr + _len, sizeof(tmpstr) - _len, " %d", _len += snprintf(s + _len, len - _len, " %d",
config_get_ptr()->ints.replay_slot); config_get_ptr()->ints.replay_slot);
thumbnail_label = tmpstr; return _len;
} }
else if (string_to_unsigned(selected_entry.label) == MENU_ENUM_LABEL_STATE_SLOT) 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), size_t _len = strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_STATE_SLOT),
sizeof(tmpstr)); len);
snprintf(tmpstr + _len, sizeof(tmpstr) - _len, " %d", _len += snprintf(s + _len, len - _len, " %d",
string_to_unsigned(selected_entry.path)); string_to_unsigned(selected_entry.path));
thumbnail_label = tmpstr; return _len;
} }
/* > Quick Menu playlist label */ /* > Quick Menu playlist label */
else if (is_quick_menu && title) else if (is_quick_menu && title)
thumbnail_label = title; {
if (!string_is_empty(title))
return strlcpy(s, title, len);
}
else else
thumbnail_label = selected_entry.path; {
if (!string_is_empty(selected_entry.path))
/* > Sanity check */ return strlcpy(s, selected_entry.path, len);
if (!string_is_empty(thumbnail_label)) }
return strlcpy(s, thumbnail_label, len);
return 0; return 0;
} }
bool menu_is_running_quick_menu(void) bool menu_is_running_quick_menu(void)
{ {
menu_entry_t entry; menu_entry_t entry;
MENU_ENTRY_INITIALIZE(entry); MENU_ENTRY_INITIALIZE(entry);
entry.flags |= MENU_ENTRY_FLAG_LABEL_ENABLED entry.flags |= MENU_ENTRY_FLAG_LABEL_ENABLED
| MENU_ENTRY_FLAG_RICH_LABEL_ENABLED; | MENU_ENTRY_FLAG_RICH_LABEL_ENABLED;
menu_entry_get(&entry, 0, 0, NULL, true); menu_entry_get(&entry, 0, 0, NULL, true);
return string_is_equal(entry.label, "resume_content") return string_is_equal(entry.label, "resume_content")
|| string_is_equal(entry.label, "state_slot"); || string_is_equal(entry.label, "state_slot");
} }

View File

@ -628,7 +628,7 @@ bool menu_driver_init(bool video_is_threaded);
retro_time_t menu_driver_get_current_time(void); 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); void menu_display_powerstate(gfx_display_ctx_powerstate_t *powerstate);

View File

@ -7665,8 +7665,9 @@ bool retroarch_main_init(int argc, char *argv[])
_len += strlcpy(str_output + _len, _len += strlcpy(str_output + _len,
FILE_PATH_LOG_INFO " CPU Model Name: ", FILE_PATH_LOG_INFO " CPU Model Name: ",
sizeof(str_output) - _len); sizeof(str_output) - _len);
_len += strlcpy(str_output + _len, cpu_model, _len += strlcpy(str_output + _len,
sizeof(str_output) - _len); cpu_model,
sizeof(str_output) - _len);
str_output[ _len] = '\n'; str_output[ _len] = '\n';
str_output[++_len] = '\0'; 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(). /* We cannot longjmp unless we're in retroarch_main_init().
* If not, something went very wrong, and we should * If not, something went very wrong, and we should
* just exit right away. */ * just exit right away. */
strlcpy(global->error_string, strlcpy(global->error_string, error,
error, sizeof(global->error_string)); sizeof(global->error_string));
longjmp(global->error_sjlj_context, error_code); longjmp(global->error_sjlj_context, error_code);
} }

View File

@ -1127,23 +1127,17 @@ static bool validate_game_options(
* @return true if a game specific core * @return true if a game specific core
* options path has been found, otherwise false. * 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; runloop_state_t *runloop_st = &runloop_state;
game_options_path[0] = '\0';
if (!validate_game_options( if (!validate_game_options(
runloop_st->system.info.library_name, runloop_st->system.info.library_name,
game_options_path, s, len, false)
sizeof(game_options_path), false) || !path_is_valid(s))
|| !path_is_valid(game_options_path))
return false; return false;
RARCH_LOG("[Core]: %s \"%s\".\n", RARCH_LOG("[Core]: %s \"%s\".\n",
msg_hash_to_str(MSG_GAME_SPECIFIC_CORE_OPTIONS_FOUND_AT), msg_hash_to_str(MSG_GAME_SPECIFIC_CORE_OPTIONS_FOUND_AT),
game_options_path); s);
*output = strdup(game_options_path);
return true; return true;
} }
@ -1172,22 +1166,14 @@ static bool validate_folder_options(
* @return true if a folder specific core * @return true if a folder specific core
* options path has been found, otherwise false. * options path has been found, otherwise false.
**/ **/
static bool validate_folder_specific_options( static bool validate_folder_specific_options(char *s, size_t len)
char **output)
{ {
char folder_options_path[PATH_MAX_LENGTH]; if (!validate_folder_options(s, len, false)
folder_options_path[0] ='\0'; || !path_is_valid(s))
if (!validate_folder_options(
folder_options_path,
sizeof(folder_options_path), false)
|| !path_is_valid(folder_options_path))
return false; return false;
RARCH_LOG("[Core]: %s \"%s\".\n", RARCH_LOG("[Core]: %s \"%s\".\n",
msg_hash_to_str(MSG_FOLDER_SPECIFIC_CORE_OPTIONS_FOUND_AT), msg_hash_to_str(MSG_FOLDER_SPECIFIC_CORE_OPTIONS_FOUND_AT),
folder_options_path); s);
*output = strdup(folder_options_path);
return true; return true;
} }
@ -1207,39 +1193,31 @@ static bool validate_folder_specific_options(
**/ **/
static void runloop_init_core_options_path( static void runloop_init_core_options_path(
settings_t *settings, settings_t *settings,
char *path, size_t len, char *s, size_t len,
char *src_path, size_t src_len) char *src_path, size_t src_len)
{ {
char *options_path = NULL;
runloop_state_t *runloop_st = &runloop_state; runloop_state_t *runloop_st = &runloop_state;
bool game_specific_options = settings->bools.game_specific_options; bool game_specific_options = settings->bools.game_specific_options;
/* Check whether game-specific options exist */ /* Check whether game-specific options exist */
if ( game_specific_options 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 /* Notify system that we have a valid core options
* override */ * 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_FOLDER_OPTIONS_ACTIVE;
runloop_st->flags |= RUNLOOP_FLAG_GAME_OPTIONS_ACTIVE; runloop_st->flags |= RUNLOOP_FLAG_GAME_OPTIONS_ACTIVE;
strlcpy(path, options_path, len);
free(options_path);
} }
/* Check whether folder-specific options exist */ /* Check whether folder-specific options exist */
else if ( game_specific_options else if ( game_specific_options
&& validate_folder_specific_options( && validate_folder_specific_options(s, len))
&options_path))
{ {
/* Notify system that we have a valid core options /* Notify system that we have a valid core options
* override */ * 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_GAME_OPTIONS_ACTIVE;
runloop_st->flags |= RUNLOOP_FLAG_FOLDER_OPTIONS_ACTIVE; runloop_st->flags |= RUNLOOP_FLAG_FOLDER_OPTIONS_ACTIVE;
strlcpy(path, options_path, len);
free(options_path);
} }
else else
{ {
@ -1287,13 +1265,13 @@ static void runloop_init_core_options_path(
/* Allocate correct path/src_path strings */ /* Allocate correct path/src_path strings */
if (per_core_options) if (per_core_options)
{ {
strlcpy(path, per_core_options_path, len); strlcpy(s, per_core_options_path, len);
if (!per_core_options_exist) if (!per_core_options_exist)
strlcpy(src_path, global_options_path, src_len); strlcpy(src_path, global_options_path, src_len);
} }
else else
strlcpy(path, global_options_path, len); strlcpy(s, global_options_path, len);
/* Notify system that we *do not* have a valid core options /* Notify system that we *do not* have a valid core options
* options override */ * options override */

View File

@ -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; unsigned reset = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
size_t _len = strlcpy(string, " ", sizeof(string)); size_t _len = strlcpy(string, " ", sizeof(string));
_len += strlcpy(string + _len, prefix, sizeof(string) - _len); _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); SetConsoleTextAttribute(con, (add) ? green : (db_name) ? yellow : red);
WriteConsole(con, string, strlen(string), NULL, NULL); WriteConsole(con, string, _len, NULL, NULL);
SetConsoleTextAttribute(con, reset); SetConsoleTextAttribute(con, reset);
} }
#else #else

View File

@ -434,7 +434,7 @@ void* task_push_http_transfer_file(const char* url, bool mute,
const char* type, const char* type,
retro_task_callback_t cb, file_transfer_t* transfer_data) retro_task_callback_t cb, file_transfer_t* transfer_data)
{ {
size_t len; size_t _len;
const char *s = NULL; const char *s = NULL;
char tmp[NAME_MAX_LENGTH] = ""; char tmp[NAME_MAX_LENGTH] = "";
retro_task_t *t = NULL; retro_task_t *t = NULL;
@ -449,19 +449,19 @@ void* task_push_http_transfer_file(const char* url, bool mute,
return NULL; return NULL;
if (transfer_data) if (transfer_data)
s = transfer_data->path; s = transfer_data->path;
else else
s = url; s = url;
len = strlcpy(tmp, msg_hash_to_str(MSG_DOWNLOADING), sizeof(tmp)); _len = strlcpy(tmp, msg_hash_to_str(MSG_DOWNLOADING), sizeof(tmp));
tmp[ len] = ' '; tmp[ _len] = ' ';
tmp[++len] = '\0'; tmp[++_len] = '\0';
if (string_ends_with_size(s, ".index", if (string_ends_with_size(s, ".index",
strlen(s), STRLEN_CONST(".index"))) strlen(s), STRLEN_CONST(".index")))
s = msg_hash_to_str(MSG_INDEX_FILE); 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); t->title = strdup(tmp);
return t; return t;

View File

@ -139,7 +139,7 @@ static void gfx_thumbnail_get_db_name(
/* Fetches local and remote paths for current thumbnail /* Fetches local and remote paths for current thumbnail
* of current type */ * of current type */
static bool get_thumbnail_paths( static bool task_pl_thumbnail_get_thumbnail_paths(
pl_thumb_handle_t *pl_thumb, pl_thumb_handle_t *pl_thumb,
char *path, size_t path_size, char *path, size_t path_size,
char *url, size_t url_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'; url[0] = '\0';
/* Check if paths are valid */ /* 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 */ /* Only download missing thumbnails */
if (!path_is_valid(path) || (pl_thumb->flags & PL_THUMB_FLAG_OVERWRITE)) if (!path_is_valid(path) || (pl_thumb->flags & PL_THUMB_FLAG_OVERWRITE))

View File

@ -306,13 +306,8 @@ static bool screenshot_dump(
if (!fullpath) if (!fullpath)
{ {
if (savestate) if (savestate)
{ fill_pathname(state->filename,
size_t len = strlcpy(state->filename, name_base, ".png", sizeof(state->filename));
name_base, sizeof(state->filename));
strlcpy(state->filename + len,
".png",
sizeof(state->filename) - len);
}
else else
{ {
char new_screenshot_dir[DIR_MAX_LENGTH]; char new_screenshot_dir[DIR_MAX_LENGTH];
@ -365,14 +360,9 @@ static bool screenshot_dump(
IMG_EXT, sizeof(state->shotname)); IMG_EXT, sizeof(state->shotname));
} }
else else
{ fill_pathname(state->shotname,
size_t len = strlcpy(state->shotname,
path_basename_nocompression(name_base), path_basename_nocompression(name_base),
sizeof(state->shotname)); ".png", sizeof(state->shotname));
strlcpy(state->shotname + len,
".png",
sizeof(state->shotname) - len);
}
if ( string_is_empty(new_screenshot_dir) if ( string_is_empty(new_screenshot_dir)
|| settings->bools.screenshots_in_content_dir) || settings->bools.screenshots_in_content_dir)