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,6 +997,7 @@ static int action_bind_sublabel_playlist_entry(
const char *label, const char *path, const char *label, const char *path,
char *s, size_t len) char *s, size_t len)
{ {
size_t written;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
playlist_t *playlist = NULL; playlist_t *playlist = NULL;
const struct playlist_entry *entry = NULL; const struct playlist_entry *entry = NULL;
@ -1021,9 +1022,10 @@ static int action_bind_sublabel_playlist_entry(
return 0; return 0;
/* Add core name */ /* Add core name */
snprintf(s, len, "%s %s", written = strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_CORE), len);
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_CORE), s[written ] = ' ';
entry->core_name); s[written+1] = '\0';
written = strlcat(s, entry->core_name, len);
/* Get runtime info *if* required runtime log is enabled /* Get runtime info *if* required runtime log is enabled
* *and* this is a valid playlist type */ * *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) if (list_path)
{ {
char elem0_path[255]; char elem0_path[255];
size_t written;
elem0_path[0] = '\0'; elem0_path[0] = '\0';
if (list_path->size > 0) if (list_path->size > 0)
strlcpy(elem0_path, list_path->elems[0].data, sizeof(elem0_path)); strlcpy(elem0_path, list_path->elems[0].data, sizeof(elem0_path));
string_list_free(list_path); string_list_free(list_path);
snprintf(s, len, "%s - %s", text, written = strlcpy(s, text, len);
(string_is_empty(elem0_path)) ? "" : path_basename(elem0_path)); s[written ] = '\n';
if (!string_is_empty(elem0_path))
{
s[written ] = '-';
s[written+1] = ' ';
strlcat(s, path_basename(elem0_path), len);
}
} }
else else
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), len); 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, static int action_get_title_default(const char *path, const char *label,
unsigned menu_type, char *s, size_t len) 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; return 0;
} }

View File

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