mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-27 10:10:57 +00:00
Fix the snprintf warnings for everyone this time
== DETAILS So, basically this back-and-forth is because we used fixed-size data types (i.e. `uint32_t`) which maps to different primitive data types on different platforms. So `uint32_t` might be a `long` on some platforms (e.g. Wii U), while it's just a plain integer on others (PC). And the format specifier works off primitive data type, not data type size. So, to resolve this, we: - keep `%lx` as the format specifier - cast the parameter to printf to unsigned long This is better than the alternatives that could cause problems trying to cast a long down to an int.
This commit is contained in:
parent
a3241aa9b2
commit
fb86ca6e33
@ -160,7 +160,7 @@ bool core_backup_get_backup_path(
|
||||
(unsigned)time_info.tm_hour,
|
||||
(unsigned)time_info.tm_min,
|
||||
(unsigned)time_info.tm_sec,
|
||||
crc,
|
||||
(unsigned long)crc,
|
||||
(unsigned)backup_mode,
|
||||
FILE_PATH_CORE_BACKUP_EXTENSION);
|
||||
|
||||
@ -748,6 +748,6 @@ bool core_backup_list_get_entry_crc_str(
|
||||
if (!entry || (len < 9))
|
||||
return false;
|
||||
|
||||
snprintf(crc, len, "%08lx", entry->crc);
|
||||
snprintf(crc, len, "%08lx", (unsigned long)entry->crc);
|
||||
return true;
|
||||
}
|
||||
|
@ -1345,7 +1345,7 @@ static int action_bind_sublabel_netplay_room(
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CONTENT_INFO_CORE_NAME),
|
||||
corename, core_ver,
|
||||
!string_is_equal(gamename, na) ? gamename : na,
|
||||
gamecrc);
|
||||
(unsigned long)gamecrc);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1389,7 +1389,7 @@ static int action_bind_sublabel_netplay_room(
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CONTENT_INFO_CORE_NAME),
|
||||
corename, core_ver, subsystem,
|
||||
!string_is_equal(gamename, na) ? gamename : na,
|
||||
gamecrc);
|
||||
(unsigned long)gamecrc);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -2149,7 +2149,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
|
||||
|
||||
crc_str[0] = tmp[0] = thumbnail_content[0] = '\0';
|
||||
|
||||
snprintf(crc_str, sizeof(crc_str), "%08lX", db_info_entry->crc32);
|
||||
snprintf(crc_str, sizeof(crc_str), "%08lX", (unsigned long)db_info_entry->crc32);
|
||||
|
||||
/* This allows thumbnails to be shown while viewing database
|
||||
* entries...
|
||||
|
@ -623,7 +623,7 @@ bool netplay_lan_ad_server(netplay_t *netplay)
|
||||
NETPLAY_HOST_STR_LEN);
|
||||
}
|
||||
|
||||
snprintf(s, sizeof(s), "%ld", content_crc);
|
||||
snprintf(s, sizeof(s), "%ld", (long)content_crc);
|
||||
strlcpy(ad_packet_buffer.content_crc, s,
|
||||
NETPLAY_HOST_STR_LEN);
|
||||
|
||||
@ -851,7 +851,7 @@ static void handshake_password(void *ignore, const char *line)
|
||||
netplay_t *netplay = handshake_password_netplay;
|
||||
struct netplay_connection *connection = &netplay->connections[0];
|
||||
|
||||
snprintf(password, sizeof(password), "%08lX", connection->salt);
|
||||
snprintf(password, sizeof(password), "%08lX", (unsigned long)connection->salt);
|
||||
if (!string_is_empty(line))
|
||||
strlcpy(password + 8, line, sizeof(password)-8);
|
||||
|
||||
@ -1363,7 +1363,7 @@ static bool netplay_handshake_pre_password(netplay_t *netplay,
|
||||
|
||||
/* Calculate the correct password hash(es) and compare */
|
||||
correct = false;
|
||||
snprintf(password, sizeof(password), "%08lX", connection->salt);
|
||||
snprintf(password, sizeof(password), "%08lX", (unsigned long)connection->salt);
|
||||
|
||||
if (settings->paths.netplay_password[0])
|
||||
{
|
||||
|
@ -2969,7 +2969,7 @@ static void netplay_announce(struct rarch_state *p_rarch)
|
||||
"game_name=%s&game_crc=%08lX&port=%d&mitm_server=%s"
|
||||
"&has_password=%d&has_spectate_password=%d&force_mitm=%d"
|
||||
"&retroarch_version=%s&frontend=%s&subsystem_name=%s",
|
||||
username, corename, coreversion, gamename, content_crc,
|
||||
username, corename, coreversion, gamename, (unsigned long)content_crc,
|
||||
settings->uints.netplay_port,
|
||||
settings->arrays.netplay_mitm_server,
|
||||
*settings->paths.netplay_password ? 1 : 0,
|
||||
|
@ -743,7 +743,7 @@ static int database_info_list_iterate_found_match(
|
||||
playlist_config_set_path(&_db->playlist_config, db_playlist_path);
|
||||
playlist = playlist_init(&_db->playlist_config);
|
||||
|
||||
snprintf(db_crc, str_len, "%08lX|crc", db_info_entry->crc32);
|
||||
snprintf(db_crc, str_len, "%08lX|crc", (unsigned long)db_info_entry->crc32);
|
||||
|
||||
if (entry_path)
|
||||
strlcpy(entry_path_str, entry_path, str_len);
|
||||
@ -904,7 +904,7 @@ static int task_database_iterate_crc_lookup(
|
||||
|
||||
snprintf(query, sizeof(query),
|
||||
"{crc:or(b\"%08lX\",b\"%08lX\")}",
|
||||
db_state->crc, db_state->archive_crc);
|
||||
(unsigned long)db_state->crc, (unsigned long)db_state->archive_crc);
|
||||
|
||||
database_info_list_iterate_new(db_state, query);
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ static void task_netplay_crc_scan_handler(retro_task_t *task)
|
||||
|
||||
RARCH_LOG("[Lobby]: Testing CRC matching for: %s\n", state->content_crc);
|
||||
|
||||
snprintf(current, sizeof(current), "%lX|crc", content_get_crc());
|
||||
snprintf(current, sizeof(current), "%lX|crc", (unsigned long)content_get_crc());
|
||||
RARCH_LOG("[Lobby]: Current content CRC: %s\n", current);
|
||||
|
||||
if (string_is_equal(current, state->content_crc))
|
||||
@ -448,7 +448,7 @@ bool task_push_netplay_crc_scan(uint32_t crc, char* name,
|
||||
|
||||
snprintf(state->content_crc,
|
||||
sizeof(state->content_crc),
|
||||
"%08lX|crc", crc);
|
||||
"%08lX|crc", (unsigned long)crc);
|
||||
|
||||
strlcpy(state->content_path,
|
||||
name, sizeof(state->content_path));
|
||||
|
Loading…
Reference in New Issue
Block a user