mirror of
https://github.com/libretro/RetroArch
synced 2025-04-01 04:20:27 +00:00
Avoid more snprintf usage
This commit is contained in:
parent
65aa939296
commit
7d58bb9799
@ -978,14 +978,13 @@ static void menu_widgets_draw_task_msg(menu_widget_msg_t *msg, video_frame_info_
|
|||||||
if (msg->task_finished)
|
if (msg->task_finished)
|
||||||
{
|
{
|
||||||
if (msg->task_error)
|
if (msg->task_error)
|
||||||
snprintf(task_percentage, sizeof(task_percentage), "Task failed");
|
strlcpy(task_percentage, "Task failed", sizeof(task_percentage));
|
||||||
else
|
else
|
||||||
snprintf(task_percentage, sizeof(task_percentage), " ");
|
strlcpy(task_percentage, " ", sizeof(task_percentage));
|
||||||
}
|
}
|
||||||
else if (msg->task_progress >= 0 && msg->task_progress <= 100)
|
else if (msg->task_progress >= 0 && msg->task_progress <= 100)
|
||||||
{
|
snprintf(task_percentage, sizeof(task_percentage),
|
||||||
snprintf(task_percentage, sizeof(task_percentage), "%i%%", msg->task_progress);
|
"%i%%", msg->task_progress);
|
||||||
}
|
|
||||||
|
|
||||||
rect_width = simple_widget_padding + msg->width + task_percentage_offset;
|
rect_width = simple_widget_padding + msg->width + task_percentage_offset;
|
||||||
bar_width = rect_width * msg->task_progress/100.0f;
|
bar_width = rect_width * msg->task_progress/100.0f;
|
||||||
@ -2238,6 +2237,7 @@ static void menu_widgets_start_achievement_notification()
|
|||||||
static void menu_widgets_get_badge_texture(menu_texture_item *tex, const char *badge)
|
static void menu_widgets_get_badge_texture(menu_texture_item *tex, const char *badge)
|
||||||
{
|
{
|
||||||
char badge_file[16];
|
char badge_file[16];
|
||||||
|
size_t written;
|
||||||
char fullpath[PATH_MAX_LENGTH];
|
char fullpath[PATH_MAX_LENGTH];
|
||||||
|
|
||||||
if (!badge)
|
if (!badge)
|
||||||
@ -2246,7 +2246,13 @@ static void menu_widgets_get_badge_texture(menu_texture_item *tex, const char *b
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(badge_file, sizeof(badge_file), "%s.png", badge);
|
written = strlcpy(badge_file, badge, sizeof(badge_file));
|
||||||
|
|
||||||
|
badge_file[written] = '.';
|
||||||
|
badge_file[written+1] = 'p';
|
||||||
|
badge_file[written+2] = 'n';
|
||||||
|
badge_file[written+3] = 'g';
|
||||||
|
badge_file[written+4] = '\0';
|
||||||
|
|
||||||
fill_pathname_application_special(fullpath,
|
fill_pathname_application_special(fullpath,
|
||||||
PATH_MAX_LENGTH * sizeof(char),
|
PATH_MAX_LENGTH * sizeof(char),
|
||||||
@ -2290,7 +2296,7 @@ void menu_widgets_set_message(char *msg)
|
|||||||
menu_animation_ctx_tag tag = (uintptr_t) &generic_message_timer;
|
menu_animation_ctx_tag tag = (uintptr_t) &generic_message_timer;
|
||||||
menu_timer_ctx_entry_t timer;
|
menu_timer_ctx_entry_t timer;
|
||||||
|
|
||||||
snprintf(generic_message, GENERIC_MESSAGE_SIZE, "%s", msg);
|
strlcpy(generic_message, msg, GENERIC_MESSAGE_SIZE);
|
||||||
|
|
||||||
generic_message_alpha = DEFAULT_BACKDROP;
|
generic_message_alpha = DEFAULT_BACKDROP;
|
||||||
|
|
||||||
@ -2327,7 +2333,7 @@ void menu_widgets_set_libretro_message(const char *msg, unsigned duration)
|
|||||||
menu_animation_ctx_tag tag = (uintptr_t) &libretro_message_timer;
|
menu_animation_ctx_tag tag = (uintptr_t) &libretro_message_timer;
|
||||||
menu_timer_ctx_entry_t timer;
|
menu_timer_ctx_entry_t timer;
|
||||||
|
|
||||||
snprintf(libretro_message, LIBRETRO_MESSAGE_SIZE, "%s", msg);
|
strlcpy(libretro_message, msg, LIBRETRO_MESSAGE_SIZE);
|
||||||
|
|
||||||
libretro_message_alpha = DEFAULT_BACKDROP;
|
libretro_message_alpha = DEFAULT_BACKDROP;
|
||||||
|
|
||||||
|
14
retroarch.c
14
retroarch.c
@ -4155,20 +4155,30 @@ static bool command_event_save_config(
|
|||||||
|
|
||||||
if (path_exists && config_save_file(config_path))
|
if (path_exists && config_save_file(config_path))
|
||||||
{
|
{
|
||||||
|
size_t written;
|
||||||
|
|
||||||
snprintf(s, len, "%s \"%s\".",
|
snprintf(s, len, "%s \"%s\".",
|
||||||
msg_hash_to_str(MSG_SAVED_NEW_CONFIG_TO),
|
msg_hash_to_str(MSG_SAVED_NEW_CONFIG_TO),
|
||||||
config_path);
|
config_path);
|
||||||
snprintf(log, PATH_MAX_LENGTH, "[config] %s", s);
|
|
||||||
|
written = strlcpy(log, "[config] ", sizeof(log));
|
||||||
|
log[written] = '\0';
|
||||||
|
written = strlcat(log, s, sizeof(log));
|
||||||
RARCH_LOG("%s\n", log);
|
RARCH_LOG("%s\n", log);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string_is_empty(str))
|
if (!string_is_empty(str))
|
||||||
{
|
{
|
||||||
|
size_t written;
|
||||||
|
|
||||||
snprintf(s, len, "%s \"%s\".",
|
snprintf(s, len, "%s \"%s\".",
|
||||||
msg_hash_to_str(MSG_FAILED_SAVING_CONFIG_TO),
|
msg_hash_to_str(MSG_FAILED_SAVING_CONFIG_TO),
|
||||||
str);
|
str);
|
||||||
snprintf(log, PATH_MAX_LENGTH, "[config] %s", s);
|
|
||||||
|
written = strlcpy(log, "[config] ", sizeof(log));
|
||||||
|
log[written] = '\0';
|
||||||
|
written = strlcat(log, s, sizeof(log));
|
||||||
RARCH_ERR("%s\n", log);
|
RARCH_ERR("%s\n", log);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -776,9 +776,10 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
n = snprintf(str, len, "%s %s",
|
n = strlcpy(str, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), len);
|
||||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
|
str[n ] = ' ';
|
||||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_INLINE_CORE_DISPLAY_NEVER));
|
str[n+1] = '\0';
|
||||||
|
n = strlcat(str, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_INLINE_CORE_DISPLAY_NEVER), len);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((n < 0) || (n >= 64))
|
if ((n < 0) || (n >= 64))
|
||||||
|
@ -233,10 +233,14 @@ static void input_autoconfigure_joypad_add(config_file_t *conf,
|
|||||||
if (string_is_equal(device_type, "remote"))
|
if (string_is_equal(device_type, "remote"))
|
||||||
{
|
{
|
||||||
static bool remote_is_bound = false;
|
static bool remote_is_bound = false;
|
||||||
|
const char *autoconfig_str = (string_is_empty(display_name) &&
|
||||||
|
!string_is_empty(params->name)) ? params->name : (!string_is_empty(display_name) ? display_name : "N/A");
|
||||||
|
size_t written = strlcpy(
|
||||||
|
msg, autoconfig_str, sizeof(msg));
|
||||||
|
|
||||||
snprintf(msg, sizeof(msg), "%s configured.",
|
msg[written ] = ' ';
|
||||||
(string_is_empty(display_name) &&
|
msg[written+1] = '\0';
|
||||||
!string_is_empty(params->name)) ? params->name : (!string_is_empty(display_name) ? display_name : "N/A"));
|
strlcat(msg, "configured.", sizeof(msg));
|
||||||
|
|
||||||
if (!remote_is_bound)
|
if (!remote_is_bound)
|
||||||
{
|
{
|
||||||
@ -249,11 +253,13 @@ static void input_autoconfigure_joypad_add(config_file_t *conf,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bool tmp = false;
|
bool tmp = false;
|
||||||
snprintf(msg, sizeof(msg), "%s %s #%u.",
|
const char *autoconfig_str = (string_is_empty(display_name) &&
|
||||||
(string_is_empty(display_name) &&
|
|
||||||
!string_is_empty(params->name))
|
!string_is_empty(params->name))
|
||||||
? params->name : (!string_is_empty(display_name) ? display_name : "N/A"),
|
? params->name : (!string_is_empty(display_name) ? display_name : "N/A");
|
||||||
|
|
||||||
|
snprintf(msg, sizeof(msg), "%s %s #%u.",
|
||||||
|
autoconfig_str,
|
||||||
msg_hash_to_str(MSG_DEVICE_CONFIGURED_IN_PORT),
|
msg_hash_to_str(MSG_DEVICE_CONFIGURED_IN_PORT),
|
||||||
params->idx);
|
params->idx);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user