mirror of
https://github.com/libretro/RetroArch.git
synced 2025-01-23 18:06:36 +00:00
use strlcpy_literal for string literal copies
This commit is contained in:
parent
7b600d46ad
commit
1296fc4745
@ -37,7 +37,7 @@ int database_info_build_query_enum(char *s, size_t len,
|
||||
bool add_quotes = true;
|
||||
bool add_glob = false;
|
||||
|
||||
strlcpy(s, "{'", len);
|
||||
strcpy_literal(s, "{'");
|
||||
|
||||
switch (type)
|
||||
{
|
||||
|
@ -172,56 +172,56 @@ bool frontend_driver_get_core_extension(char *s, size_t len)
|
||||
#ifdef HAVE_DYNAMIC
|
||||
|
||||
#ifdef _WIN32
|
||||
strlcpy(s, "dll", len);
|
||||
strcpy_literal(s, "dll");
|
||||
return true;
|
||||
#elif defined(__APPLE__) || defined(__MACH__)
|
||||
strlcpy(s, "dylib", len);
|
||||
strcpy_literal(s, "dylib");
|
||||
return true;
|
||||
#else
|
||||
strlcpy(s, "so", len);
|
||||
strcpy_literal(s, "so");
|
||||
return true;
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#if defined(__CELLOS_LV2__)
|
||||
strlcpy(s, "self|bin", len);
|
||||
strcpy_literal(s, "self|bin");
|
||||
return true;
|
||||
#elif defined(PSP)
|
||||
strlcpy(s, "pbp", len);
|
||||
strcpy_literal(s, "pbp");
|
||||
return true;
|
||||
#elif defined(VITA)
|
||||
strlcpy(s, "self|bin", len);
|
||||
strcpy_literal(s, "self|bin");
|
||||
return true;
|
||||
#elif defined(PS2)
|
||||
strlcpy(s, "elf", len);
|
||||
strcpy_literal(s, "elf");
|
||||
return true;
|
||||
#elif defined(_XBOX1)
|
||||
strlcpy(s, "xbe", len);
|
||||
strcpy_literal(s, "xbe");
|
||||
return true;
|
||||
#elif defined(_XBOX360)
|
||||
strlcpy(s, "xex", len);
|
||||
strcpy_literal(s, "xex");
|
||||
return true;
|
||||
#elif defined(GEKKO)
|
||||
strlcpy(s, "dol", len);
|
||||
strcpy_literal(s, "dol");
|
||||
return true;
|
||||
#elif defined(HW_WUP)
|
||||
strlcpy(s, "rpx|elf", len);
|
||||
strcpy_literal(s, "rpx|elf");
|
||||
return true;
|
||||
#elif defined(__linux__)
|
||||
strlcpy(s, "elf", len);
|
||||
strcpy_literal(s, "elf");
|
||||
return true;
|
||||
#elif defined(HAVE_LIBNX)
|
||||
strlcpy(s, "nro", len);
|
||||
strcpy_literal(s, "nro");
|
||||
return true;
|
||||
#elif defined(DJGPP)
|
||||
strlcpy(s, "exe", len);
|
||||
strcpy_literal(s, "exe");
|
||||
return true;
|
||||
#elif defined(_3DS)
|
||||
if (envIsHomebrew())
|
||||
strlcpy(s, "3dsx", len);
|
||||
strcpy_literal(s, "3dsx");
|
||||
else
|
||||
strlcpy(s, "cia", len);
|
||||
strcpy_literal(s, "cia");
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
@ -237,37 +237,37 @@ bool frontend_driver_get_salamander_basename(char *s, size_t len)
|
||||
#else
|
||||
|
||||
#if defined(__CELLOS_LV2__)
|
||||
strlcpy(s, "EBOOT.BIN", len);
|
||||
strcpy_literal(s, "EBOOT.BIN");
|
||||
return true;
|
||||
#elif defined(PSP)
|
||||
strlcpy(s, "EBOOT.PBP", len);
|
||||
strcpy_literal(s, "EBOOT.PBP");
|
||||
return true;
|
||||
#elif defined(VITA)
|
||||
strlcpy(s, "eboot.bin", len);
|
||||
strcpy_literal(s, "eboot.bin");
|
||||
return true;
|
||||
#elif defined(PS2)
|
||||
strlcpy(s, "eboot.elf", len);
|
||||
strcpy_literal(s, "eboot.elf");
|
||||
return true;
|
||||
#elif defined(_XBOX1)
|
||||
strlcpy(s, "default.xbe", len);
|
||||
strcpy_literal(s, "default.xbe");
|
||||
return true;
|
||||
#elif defined(_XBOX360)
|
||||
strlcpy(s, "default.xex", len);
|
||||
strcpy_literal(s, "default.xex");
|
||||
return true;
|
||||
#elif defined(HW_RVL)
|
||||
strlcpy(s, "boot.dol", len);
|
||||
strcpy_literal(s, "boot.dol");
|
||||
return true;
|
||||
#elif defined(HW_WUP)
|
||||
strlcpy(s, "retroarch.rpx", len);
|
||||
strcpy_literal(s, "retroarch.rpx");
|
||||
return true;
|
||||
#elif defined(_3DS)
|
||||
strlcpy(s, "retroarch.core", len);
|
||||
strcpy_literal(s, "retroarch.core");
|
||||
return true;
|
||||
#elif defined(DJGPP)
|
||||
strlcpy(s, "retrodos.exe", len);
|
||||
strcpy_literal(s, "retrodos.exe");
|
||||
return true;
|
||||
#elif defined(SWITCH)
|
||||
strlcpy(s, "retroarch_switch.nro", len);
|
||||
strcpy_literal(s, "retroarch_switch.nro");
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
|
@ -67,7 +67,7 @@ static std::string build_stage_source(
|
||||
|
||||
expected[0] = '\0';
|
||||
|
||||
strlcpy(expected, "#pragma stage ", sizeof(expected));
|
||||
strcpy_literal(expected, "#pragma stage ");
|
||||
strlcat(expected, stage, sizeof(expected));
|
||||
|
||||
active = string_is_equal(expected, line);
|
||||
|
@ -35,6 +35,8 @@
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
|
||||
#define strcpy_literal(a, b) strcpy(a, b)
|
||||
|
||||
static INLINE bool string_is_empty(const char *data)
|
||||
{
|
||||
return !data || (*data == '\0');
|
||||
|
@ -290,7 +290,7 @@ static void query_raise_unknown_function(
|
||||
if (len < (_len - n - 3))
|
||||
strncpy(s + n, name, len);
|
||||
|
||||
strlcpy(s + n + len, "'", _len);
|
||||
strcpy_literal(s + n + len, "'");
|
||||
*error = s;
|
||||
}
|
||||
|
||||
@ -452,7 +452,7 @@ static struct buffer query_parse_string(
|
||||
|
||||
if (!value->val.string.buff)
|
||||
{
|
||||
strlcpy(s, "Out of memory", len);
|
||||
strcpy_literal(s, "Out of memory");
|
||||
*error = s;
|
||||
}
|
||||
else if (is_binstr)
|
||||
@ -692,8 +692,8 @@ static struct buffer query_parse_method_call(
|
||||
{
|
||||
if (argi >= QUERY_MAX_ARGS)
|
||||
{
|
||||
strlcpy(s,
|
||||
"Too many arguments in function call.", len);
|
||||
strcpy_literal(s,
|
||||
"Too many arguments in function call.");
|
||||
*error = s;
|
||||
goto clean;
|
||||
}
|
||||
@ -725,7 +725,7 @@ static struct buffer query_parse_method_call(
|
||||
|
||||
if (!invocation->argv)
|
||||
{
|
||||
strlcpy(s, "Out of memory", len);
|
||||
strcpy_literal(s, "Out of memory");
|
||||
*error = s;
|
||||
goto clean;
|
||||
}
|
||||
@ -817,8 +817,8 @@ static struct buffer query_parse_table(
|
||||
{
|
||||
if (argi >= QUERY_MAX_ARGS)
|
||||
{
|
||||
strlcpy(s,
|
||||
"Too many arguments in function call.", len);
|
||||
strcpy_literal(s,
|
||||
"Too many arguments in function call.");
|
||||
*error = s;
|
||||
goto clean;
|
||||
}
|
||||
@ -866,8 +866,8 @@ static struct buffer query_parse_table(
|
||||
|
||||
if (argi >= QUERY_MAX_ARGS)
|
||||
{
|
||||
strlcpy(s,
|
||||
"Too many arguments in function call.", len);
|
||||
strcpy_literal(s,
|
||||
"Too many arguments in function call.");
|
||||
*error = s;
|
||||
goto clean;
|
||||
}
|
||||
@ -900,7 +900,7 @@ static struct buffer query_parse_table(
|
||||
|
||||
if (!invocation->argv)
|
||||
{
|
||||
strlcpy(s, "Out of memory", len);
|
||||
strcpy_literal(s, "Out of memory");
|
||||
*error = s;
|
||||
goto clean;
|
||||
}
|
||||
|
53
retroarch.c
53
retroarch.c
@ -5525,27 +5525,27 @@ int menu_entries_get_core_title(char *s, size_t len)
|
||||
: msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_CORE);
|
||||
const char *core_version = (system && system->library_version) ? system->library_version : "";
|
||||
#if _MSC_VER == 1200
|
||||
strlcpy(s, PACKAGE_VERSION " msvc6" " - ", len);
|
||||
strcpy_literal(s, PACKAGE_VERSION " msvc6" " - ");
|
||||
#elif _MSC_VER == 1300
|
||||
strlcpy(s, PACKAGE_VERSION " msvc2002" " - ", len);
|
||||
strcpy_literal(s, PACKAGE_VERSION " msvc2002" " - ");
|
||||
#elif _MSC_VER == 1310
|
||||
strlcpy(s, PACKAGE_VERSION " msvc2003" " - ", len);
|
||||
strcpy_literal(s, PACKAGE_VERSION " msvc2003" " - ");
|
||||
#elif _MSC_VER == 1400
|
||||
strlcpy(s, PACKAGE_VERSION " msvc2005" " - ", len);
|
||||
strcpy_literal(s, PACKAGE_VERSION " msvc2005" " - ");
|
||||
#elif _MSC_VER == 1500
|
||||
strlcpy(s, PACKAGE_VERSION " msvc2008" " - ", len);
|
||||
strcpy_literal(s, PACKAGE_VERSION " msvc2008" " - ");
|
||||
#elif _MSC_VER == 1600
|
||||
strlcpy(s, PACKAGE_VERSION " msvc2010" " - ", len);
|
||||
strcpy_literal(s, PACKAGE_VERSION " msvc2010" " - ");
|
||||
#elif _MSC_VER == 1700
|
||||
strlcpy(s, PACKAGE_VERSION " msvc2012" " - ", len);
|
||||
strcpy_literal(s, PACKAGE_VERSION " msvc2012" " - ");
|
||||
#elif _MSC_VER == 1800
|
||||
strlcpy(s, PACKAGE_VERSION " msvc2013" " - ", len);
|
||||
strcpy_literal(s, PACKAGE_VERSION " msvc2013" " - ");
|
||||
#elif _MSC_VER == 1900
|
||||
strlcpy(s, PACKAGE_VERSION " msvc2015" " - ", len);
|
||||
strcpy_literal(s, PACKAGE_VERSION " msvc2015" " - ");
|
||||
#elif _MSC_VER >= 1910 && _MSC_VER < 2000
|
||||
strlcpy(s, PACKAGE_VERSION " msvc2017" " - ", len);
|
||||
strcpy_literal(s, PACKAGE_VERSION " msvc2017" " - ");
|
||||
#else
|
||||
strlcpy(s, PACKAGE_VERSION " - ", len);
|
||||
strcpy_literal(s, PACKAGE_VERSION " - ");
|
||||
#endif
|
||||
strlcat(s, core_name, len);
|
||||
if (!string_is_empty(core_version))
|
||||
@ -9165,7 +9165,7 @@ static void discord_init(
|
||||
strlcat(command, args, sizeof(command));
|
||||
}
|
||||
#else
|
||||
strlcpy(command, "sh -c ", sizeof(command));
|
||||
strcpy_literal(command, "sh -c ");
|
||||
strlcat(command, args, sizeof(command));
|
||||
#endif
|
||||
RARCH_LOG("[DISCORD]: Registering startup command: %s\n", command);
|
||||
@ -11489,7 +11489,7 @@ static bool path_init_subsystem(struct rarch_state *p_rarch)
|
||||
|
||||
path[0] = ext[0] = '\0';
|
||||
|
||||
strlcpy(ext, ".", sizeof(ext));
|
||||
strcpy_literal(ext, ".");
|
||||
strlcat(ext, mem->extension, sizeof(ext));
|
||||
strlcpy(savename,
|
||||
p_rarch->subsystem_fullpaths->elems[i].data,
|
||||
@ -12781,7 +12781,7 @@ static bool command_get_status(const char* arg)
|
||||
content_get_status(&contentless, &is_inited);
|
||||
|
||||
if (!is_inited)
|
||||
strlcpy(reply, "GET_STATUS CONTENTLESS", sizeof(reply));
|
||||
strcpy_literal(reply, "GET_STATUS CONTENTLESS");
|
||||
else
|
||||
{
|
||||
/* add some content info */
|
||||
@ -15403,7 +15403,7 @@ static bool command_event_save_config(
|
||||
msg_hash_to_str(MSG_SAVED_NEW_CONFIG_TO),
|
||||
config_path);
|
||||
|
||||
strlcpy(log, "[config] ", sizeof(log));
|
||||
strcpy_literal(log, "[config] ");
|
||||
strlcat(log, s, sizeof(log));
|
||||
RARCH_LOG("%s\n", log);
|
||||
return true;
|
||||
@ -15415,7 +15415,7 @@ static bool command_event_save_config(
|
||||
msg_hash_to_str(MSG_FAILED_SAVING_CONFIG_TO),
|
||||
str);
|
||||
|
||||
strlcpy(log, "[config] ", sizeof(log));
|
||||
strcpy_literal(log, "[config] ");
|
||||
strlcat(log, s, sizeof(log));
|
||||
RARCH_ERR("%s\n", log);
|
||||
}
|
||||
@ -15545,8 +15545,7 @@ static void command_event_save_current_config(
|
||||
{
|
||||
case OVERRIDE_NONE:
|
||||
if (path_is_empty(RARCH_PATH_CONFIG))
|
||||
strlcpy(msg, "[config] Config directory not set, cannot save configuration.",
|
||||
sizeof(msg));
|
||||
strcpy_literal(msg, "[config] Config directory not set, cannot save configuration.");
|
||||
else
|
||||
command_event_save_config(path_get(RARCH_PATH_CONFIG), msg, sizeof(msg));
|
||||
break;
|
||||
@ -41046,32 +41045,32 @@ const void *frontend_driver_get_cpu_architecture_str(
|
||||
switch (arch)
|
||||
{
|
||||
case FRONTEND_ARCH_X86:
|
||||
strlcpy(architecture, "x86", size);
|
||||
strcpy_literal(architecture, "x86");
|
||||
break;
|
||||
case FRONTEND_ARCH_X86_64:
|
||||
strlcpy(architecture, "x64", size);
|
||||
strcpy_literal(architecture, "x64");
|
||||
break;
|
||||
case FRONTEND_ARCH_PPC:
|
||||
strlcpy(architecture, "PPC", size);
|
||||
strcpy_literal(architecture, "PPC");
|
||||
break;
|
||||
case FRONTEND_ARCH_ARM:
|
||||
strlcpy(architecture, "ARM", size);
|
||||
strcpy_literal(architecture, "ARM");
|
||||
break;
|
||||
case FRONTEND_ARCH_ARMV7:
|
||||
strlcpy(architecture, "ARMv7", size);
|
||||
strcpy_literal(architecture, "ARMv7");
|
||||
break;
|
||||
case FRONTEND_ARCH_ARMV8:
|
||||
strlcpy(architecture, "ARMv8", size);
|
||||
strcpy_literal(architecture, "ARMv8");
|
||||
break;
|
||||
case FRONTEND_ARCH_MIPS:
|
||||
strlcpy(architecture, "MIPS", size);
|
||||
strcpy_literal(architecture, "MIPS");
|
||||
break;
|
||||
case FRONTEND_ARCH_TILE:
|
||||
strlcpy(architecture, "Tilera", size);
|
||||
strcpy_literal(architecture, "Tilera");
|
||||
break;
|
||||
case FRONTEND_ARCH_NONE:
|
||||
default:
|
||||
strlcpy(architecture, "N/A", size);
|
||||
strcpy_literal(architecture, "N/A");
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user