Prefer to use string_starts_with_size/string_ends_with_size (less strlen

calls)
This commit is contained in:
LibretroAdmin 2022-08-26 17:27:55 +02:00
parent be9b4031d9
commit c3a1c578b6
4 changed files with 9 additions and 9 deletions

View File

@ -215,8 +215,8 @@ static void frontend_gx_get_env(int *argc, char *argv[],
/* When using external loaders (Wiiflow, etc),
getcwd doesn't return the path correctly and as a result,
the cfg file is not found. */
if (string_starts_with(argv[0], "usb1") ||
string_starts_with(argv[0], "usb2"))
if ( string_starts_with_size(argv[0], "usb1", STRLEN_CONST("usb1")) ||
string_starts_with_size(argv[0], "usb2", STRLEN_CONST("usb2")))
{
strcpy_literal(g_defaults.dirs[DEFAULT_DIR_CORE], "usb");
strlcat(g_defaults.dirs[DEFAULT_DIR_CORE], argv[0] + 4,

View File

@ -1246,7 +1246,7 @@ static enum frontend_architecture frontend_unix_get_arch(void)
string_is_equal(val, "armv7b")
)
return FRONTEND_ARCH_ARMV7;
else if (string_starts_with(val, "arm"))
else if (string_starts_with_size(val, "arm", STRLEN_CONST("arm")))
return FRONTEND_ARCH_ARM;
else if (string_is_equal(val, "x86_64"))
return FRONTEND_ARCH_X86_64;

View File

@ -141,10 +141,10 @@ static void dol_copy_raw_argv(const char *dolpath,
strlcpy(cmdline, __system_argv->argv[0],
strchr(__system_argv->argv[0], ':') - __system_argv->argv[0] + 2);
/* a relative path */
else if (!string_starts_with(dolpath, "sd:/") &&
!string_starts_with(dolpath, "usb:/") &&
!string_starts_with(dolpath, "carda:/") &&
!string_starts_with(dolpath, "cardb:/"))
else if ( !string_starts_with_size(dolpath, "sd:/", STRLEN_CONST("sd:/"))
&& !string_starts_with_size(dolpath, "usb:/", STRLEN_CONST("usb:/"))
&& !string_starts_with_size(dolpath, "carda:/", STRLEN_CONST("carda:/"))
&& !string_starts_with_size(dolpath, "cardb:/", STRLEN_CONST("cardb:/")))
fill_pathname_parent_dir(cmdline, __system_argv->argv[0],
PATH_MAX_LENGTH);
/* fullpath */

View File

@ -12213,8 +12213,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
* a single instance where this case is met... */
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list);
if ( string_starts_with(info->path, "content_")
&& string_ends_with(info->path, ".lpl"))
if ( string_starts_with_size(info->path, "content_", STRLEN_CONST("content_"))
&& string_ends_with_size(info->path, ".lpl", strlen(info->path), STRLEN_CONST(".lpl")))
{
if (string_is_equal(info->path,
FILE_PATH_CONTENT_HISTORY))