FIx potential -Wformat-truncation warnings

This commit is contained in:
libretroadmin 2023-06-20 19:06:45 +02:00
parent 3870196efe
commit 2195ac998b

View File

@ -1641,7 +1641,7 @@ static unsigned menu_displaylist_parse_supported_cores(menu_displaylist_info_t *
static unsigned menu_displaylist_parse_system_info(file_list_t *list) static unsigned menu_displaylist_parse_system_info(file_list_t *list)
{ {
char entry[256]; char entry[256];
char tmp[512]; char tmp[128];
unsigned count = 0; unsigned count = 0;
/* RetroArch Version */ /* RetroArch Version */
@ -1831,8 +1831,8 @@ static unsigned menu_displaylist_parse_system_info(file_list_t *list)
_len = strlcpy(entry, _len = strlcpy(entry,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_FRONTEND_IDENTIFIER), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_FRONTEND_IDENTIFIER),
sizeof(entry)); sizeof(entry));
entry[_len++ ] = ':'; entry[_len++ ] = ':';
entry[_len++ ] = ' '; entry[_len++ ] = ' ';
strlcpy(entry + _len, frontend->ident, sizeof(entry) - _len); strlcpy(entry + _len, frontend->ident, sizeof(entry) - _len);
if (menu_entries_append(list, entry, "", if (menu_entries_append(list, entry, "",
MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE,
@ -1842,10 +1842,14 @@ static unsigned menu_displaylist_parse_system_info(file_list_t *list)
/* Lakka Version */ /* Lakka Version */
if (frontend->get_lakka_version) if (frontend->get_lakka_version)
{ {
frontend->get_lakka_version(tmp, sizeof(tmp)); char lakka_ver[64];
snprintf(entry, sizeof(entry), "%s: %s", frontend->get_lakka_version(lakka_ver, sizeof(lakka_ver));
_len = strlcpy(entry,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_LAKKA_VERSION), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_LAKKA_VERSION),
tmp); sizeof(entry));
entry[_len++ ] = ':';
entry[_len++ ] = ' ';
strlcpy(entry + _len, lakka_ver, sizeof(entry) - _len);
if (menu_entries_append(list, entry, "", if (menu_entries_append(list, entry, "",
MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE,
0, 0, NULL)) 0, 0, NULL))
@ -1855,10 +1859,14 @@ static unsigned menu_displaylist_parse_system_info(file_list_t *list)
/* Frontend name */ /* Frontend name */
if (frontend->get_name) if (frontend->get_name)
{ {
frontend->get_name(tmp, sizeof(tmp)); char frontend_name[64];
snprintf(entry, sizeof(entry), "%s: %s", frontend->get_name(frontend_name, sizeof(frontend_name));
_len = strlcpy(entry,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_FRONTEND_NAME), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_FRONTEND_NAME),
tmp); sizeof(entry));
entry[_len++ ] = ':';
entry[_len++ ] = ' ';
strlcpy(entry + _len, frontend_name, sizeof(entry) - _len);
if (menu_entries_append(list, entry, "", if (menu_entries_append(list, entry, "",
MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE,
0, 0, NULL)) 0, 0, NULL))
@ -1868,12 +1876,17 @@ static unsigned menu_displaylist_parse_system_info(file_list_t *list)
/* Frontend OS */ /* Frontend OS */
if (frontend->get_os) if (frontend->get_os)
{ {
char os_ver[64];
int major = 0; int major = 0;
int minor = 0; int minor = 0;
frontend->get_os(tmp, sizeof(tmp), &major, &minor); frontend->get_os(os_ver, sizeof(os_ver), &major, &minor);
snprintf(entry, sizeof(entry), "%s: %s (v%d.%d)", _len = strlcpy(entry,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_FRONTEND_OS), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_FRONTEND_OS),
tmp, major, minor); sizeof(entry));
entry[_len++ ] = ':';
entry[_len++ ] = ' ';
_len += snprintf(entry + _len, sizeof(entry) - _len,
"%s (v%d.%d)", os_ver, major, minor);
if (menu_entries_append(list, entry, "", if (menu_entries_append(list, entry, "",
MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE,
0, 0, NULL)) 0, 0, NULL))