mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 22:20:21 +00:00
- Avoid some repeated strlcpy/strlcat calls one after another; replace
it with a single snprintf call under the assumption it will probably still be faster - In some instances, the first time the string was manipulated on was with a strlcat call instead of an strlcpy - change this
This commit is contained in:
parent
e784cc1aaf
commit
0e7ff6ea4e
61
retroarch.c
61
retroarch.c
@ -5899,11 +5899,8 @@ static bool menu_shader_manager_save_preset_internal(
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy_literal(fullname, "retroarch");
|
||||
strlcat(fullname,
|
||||
video_shader_get_preset_extension(type), sizeof(fullname));
|
||||
}
|
||||
snprintf(fullname, sizeof(fullname), "retroarch%s",
|
||||
video_shader_get_preset_extension(type));
|
||||
|
||||
if (path_is_absolute(fullname))
|
||||
{
|
||||
@ -7643,7 +7640,8 @@ static void netplay_announce(struct rarch_state *p_rarch)
|
||||
uint32_t content_crc = content_get_crc();
|
||||
struct string_list *subsystem = path_get_subsystem_list();
|
||||
|
||||
buf[0] = '\0';
|
||||
frontend_architecture[0] = '\0';
|
||||
buf[0] = '\0';
|
||||
|
||||
if (subsystem)
|
||||
{
|
||||
@ -7672,12 +7670,11 @@ static void netplay_announce(struct rarch_state *p_rarch)
|
||||
frontend_drv =
|
||||
(const frontend_ctx_driver_t*)frontend_driver_get_cpu_architecture_str(
|
||||
frontend_architecture_tmp, sizeof(frontend_architecture_tmp));
|
||||
strlcpy(frontend_architecture, frontend_drv->ident,
|
||||
sizeof(frontend_architecture));
|
||||
strlcat(frontend_architecture, " ",
|
||||
sizeof(frontend_architecture));
|
||||
strlcat(frontend_architecture, frontend_architecture_tmp,
|
||||
sizeof(frontend_architecture));
|
||||
snprintf(frontend_architecture,
|
||||
sizeof(frontend_architecture),
|
||||
"%s %s",
|
||||
frontend_drv->ident,
|
||||
frontend_architecture_tmp);
|
||||
|
||||
#ifdef HAVE_DISCORD
|
||||
if (discord_is_ready())
|
||||
@ -10785,11 +10782,11 @@ static bool retroarch_apply_shader(
|
||||
msg_hash_to_str(MSG_SHADER),
|
||||
preset_file);
|
||||
else
|
||||
{
|
||||
strlcpy(msg, msg_hash_to_str(MSG_SHADER), sizeof(msg));
|
||||
strlcat(msg, ": ", sizeof(msg));
|
||||
strlcat(msg, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NONE), sizeof(msg));
|
||||
}
|
||||
snprintf(msg, sizeof(msg),
|
||||
"%s: %s",
|
||||
msg_hash_to_str(MSG_SHADER),
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NONE)
|
||||
);
|
||||
#ifdef HAVE_GFX_WIDGETS
|
||||
if (p_rarch->widgets_active)
|
||||
gfx_widget_set_generic_message(&p_rarch->dispwidget_st,
|
||||
@ -12826,7 +12823,6 @@ static bool command_event_save_config(
|
||||
const char *config_path,
|
||||
char *s, size_t len)
|
||||
{
|
||||
char log[PATH_MAX_LENGTH];
|
||||
bool path_exists = !string_is_empty(config_path);
|
||||
const char *str = path_exists ? config_path :
|
||||
path_get(RARCH_PATH_CONFIG);
|
||||
@ -12836,10 +12832,7 @@ static bool command_event_save_config(
|
||||
snprintf(s, len, "%s \"%s\".",
|
||||
msg_hash_to_str(MSG_SAVED_NEW_CONFIG_TO),
|
||||
config_path);
|
||||
|
||||
strcpy_literal(log, "[Config]: ");
|
||||
strlcat(log, s, sizeof(log));
|
||||
RARCH_LOG("%s\n", log);
|
||||
RARCH_LOG("[Config]: %s\n", s);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -12848,10 +12841,7 @@ static bool command_event_save_config(
|
||||
snprintf(s, len, "%s \"%s\".",
|
||||
msg_hash_to_str(MSG_FAILED_SAVING_CONFIG_TO),
|
||||
str);
|
||||
|
||||
strcpy_literal(log, "[Config]: ");
|
||||
strlcat(log, s, sizeof(log));
|
||||
RARCH_ERR("%s\n", log);
|
||||
RARCH_ERR("[Config]: %s\n", s);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -20861,11 +20851,8 @@ static bool runloop_check_movie_init(struct rarch_state *p_rarch,
|
||||
p_rarch->bsv_movie_state.movie_path,
|
||||
state_slot);
|
||||
else
|
||||
{
|
||||
strlcpy(path, p_rarch->bsv_movie_state.movie_path, sizeof(path));
|
||||
strlcat(path, ".bsv", sizeof(path));
|
||||
}
|
||||
|
||||
snprintf(path, sizeof(path), "%s.bsv",
|
||||
p_rarch->bsv_movie_state.movie_path);
|
||||
|
||||
snprintf(msg, sizeof(msg), "%s \"%s\".",
|
||||
msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO),
|
||||
@ -34259,7 +34246,7 @@ static void retroarch_print_features(void)
|
||||
buf[0] = '\0';
|
||||
frontend_driver_attach_console();
|
||||
|
||||
strlcat(buf, "\nFeatures:\n", sizeof(buf));
|
||||
strlcpy(buf, "\nFeatures:\n", sizeof(buf));
|
||||
|
||||
_PSUPP_BUF(buf, SUPPORTS_LIBRETRODB, "LibretroDB", "LibretroDB support");
|
||||
_PSUPP_BUF(buf, SUPPORTS_COMMAND, "Command", "Command interface support");
|
||||
@ -35443,7 +35430,7 @@ bool retroarch_main_init(int argc, char *argv[])
|
||||
|
||||
cpu_model = frontend_driver_get_cpu_model_name();
|
||||
|
||||
strlcat(str_output,
|
||||
strlcpy(str_output,
|
||||
"=== Build =======================================\n",
|
||||
sizeof(str_output));
|
||||
|
||||
@ -35463,10 +35450,10 @@ bool retroarch_main_init(int argc, char *argv[])
|
||||
|
||||
retroarch_get_capabilities(RARCH_CAPABILITIES_CPU, str, sizeof(str));
|
||||
|
||||
strlcat(str_output, msg_hash_to_str(MSG_CAPABILITIES),
|
||||
sizeof(str_output));
|
||||
strlcat(str_output, ": ", sizeof(str_output));
|
||||
strlcat(str_output, str, sizeof(str_output));
|
||||
snprintf(str_output, sizeof(str_output),
|
||||
"%s: %s",
|
||||
msg_hash_to_str(MSG_CAPABILITIES),
|
||||
str);
|
||||
strlcat(str_output, "\n" FILE_PATH_LOG_INFO " Built: " __DATE__ "\n" FILE_PATH_LOG_INFO " Version: " PACKAGE_VERSION "\n", sizeof(str_output));
|
||||
#ifdef HAVE_GIT_VERSION
|
||||
strlcat(str_output, FILE_PATH_LOG_INFO " Git: ", sizeof(str_output));
|
||||
|
Loading…
x
Reference in New Issue
Block a user