Replace more snprintf usage

This commit is contained in:
twinaphex 2019-09-17 07:30:29 +02:00
parent 7d58bb9799
commit b6a6127509
3 changed files with 22 additions and 11 deletions

View File

@ -997,8 +997,9 @@ static int action_bind_sublabel_playlist_entry(
const char *label, const char *path,
char *s, size_t len)
{
settings_t *settings = config_get_ptr();
playlist_t *playlist = NULL;
size_t written;
settings_t *settings = config_get_ptr();
playlist_t *playlist = NULL;
const struct playlist_entry *entry = NULL;
if (!settings->bools.playlist_show_sublabels || string_is_equal(settings->arrays.menu_driver, "ozone"))
@ -1021,9 +1022,10 @@ static int action_bind_sublabel_playlist_entry(
return 0;
/* Add core name */
snprintf(s, len, "%s %s",
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_CORE),
entry->core_name);
written = strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_CORE), len);
s[written ] = ' ';
s[written+1] = '\0';
written = strlcat(s, entry->core_name, len);
/* Get runtime info *if* required runtime log is enabled
* *and* this is a valid playlist type */

View File

@ -293,14 +293,22 @@ static int action_get_title_generic(char *s, size_t len, const char *path,
if (list_path)
{
char elem0_path[255];
size_t written;
elem0_path[0] = '\0';
if (list_path->size > 0)
strlcpy(elem0_path, list_path->elems[0].data, sizeof(elem0_path));
string_list_free(list_path);
snprintf(s, len, "%s - %s", text,
(string_is_empty(elem0_path)) ? "" : path_basename(elem0_path));
written = strlcpy(s, text, len);
s[written ] = '\n';
if (!string_is_empty(elem0_path))
{
s[written ] = '-';
s[written+1] = ' ';
strlcat(s, path_basename(elem0_path), len);
}
}
else
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), len);
@ -335,7 +343,10 @@ default_title_generic_macro(action_get_title_list_rdb_entry_database_info,MENU_E
static int action_get_title_default(const char *path, const char *label,
unsigned menu_type, char *s, size_t len)
{
snprintf(s, len, "%s %s", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SELECT_FILE), path);
size_t written = strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SELECT_FILE), len);
s[written] = ' ';
s[written+1] = '\0';
strlcat(s, path, len);
return 0;
}

View File

@ -5904,9 +5904,7 @@ static void get_string_representation_bind_device(rarch_setting_t *setting, char
device_name,
idx);
else
snprintf(s, len,
"%s",
device_name);
strlcpy(s, device_name, len);
}
else
snprintf(s, len,