From cc408864af84a060e38afaf4a69ce77602947c17 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Fri, 18 Jul 2025 10:06:16 +0200 Subject: [PATCH] Silence some code analysis warnings --- cheevos/cheevos.c | 5 +++-- deps/discord-rpc/src/discord_register_win.c | 3 +-- menu/menu_displaylist.c | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index 3fc8b8126c..e6428fbd4f 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -946,8 +946,9 @@ void rcheevos_validate_config_settings(void) const char* val = core_option_manager_get_val(coreopts, i); if (!rc_libretro_is_setting_allowed(disallowed_settings, key, val)) { + size_t _len; char buffer[128]; - size_t _len = snprintf(buffer, sizeof(buffer), + snprintf(buffer, sizeof(buffer), msg_hash_to_str_us(MSG_CHEEVOS_HARDCORE_PAUSED_SETTING_NOT_ALLOWED), key, val); CHEEVOS_LOG(RCHEEVOS_TAG "%s\n", buffer); _len = snprintf(buffer, sizeof(buffer), @@ -1270,7 +1271,7 @@ static void rcheevos_show_game_placard(void) { char badge_name[32]; size_t __len = strlcpy(badge_name, "i", sizeof(badge_name)); - __len += strlcpy(badge_name + __len, game->badge_name, + strlcpy(badge_name + __len, game->badge_name, sizeof(badge_name) - __len); gfx_widgets_push_achievement(game->title, msg, badge_name); } diff --git a/deps/discord-rpc/src/discord_register_win.c b/deps/discord-rpc/src/discord_register_win.c index f0b294ce54..345b74c51e 100644 --- a/deps/discord-rpc/src/discord_register_win.c +++ b/deps/discord-rpc/src/discord_register_win.c @@ -114,7 +114,6 @@ static void Discord_RegisterW( if (FAILED(result)) fprintf(stderr, "Error writing description\n"); - len = (DWORD)lstrlenW(protocolDescription) + 1; result = RegSetKeyValueW(key, NULL, L"URL Protocol", REG_SZ, &urlProtocol, sizeof(wchar_t)); if (FAILED(result)) fprintf(stderr, "Error writing description\n"); @@ -142,7 +141,7 @@ void Discord_Register(const char* applicationId, const char* command) if (command && command[0]) { - const int commandBufferLen = + const int commandBufferLen = sizeof(openCommand) / sizeof(*openCommand); MultiByteToWideChar(CP_UTF8, 0, command, -1, openCommand, commandBufferLen); diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index e5eba3027c..aa2d8619aa 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -1741,7 +1741,7 @@ static unsigned menu_displaylist_parse_supported_cores( _len += strlcpy(entry_alt_text + _len, pending_core_name, sizeof(entry_alt_text) - _len); - _len += strlcpy(entry_alt_text + _len, ")", sizeof(entry_alt_text) - _len); + strlcpy(entry_alt_text + _len, ")", sizeof(entry_alt_text) - _len); menu_entries_prepend(info->list, pending_core_path, msg_hash_to_str(current_core_enum_label), @@ -6854,7 +6854,7 @@ static unsigned menu_displaylist_populate_subsystem( _len += strlcpy(s + _len, subsystem->roms[content_get_subsystem_rom_id()].desc, sizeof(s) - _len); - _len += strlcpy(s + _len, "]", sizeof(s) - _len); + strlcpy(s + _len, "]", sizeof(s) - _len); } #endif @@ -15441,7 +15441,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, { if (_len > 0) _len += strlcpy(new_exts + _len, "|", sizeof(new_exts) - _len); - _len += strlcpy(new_exts + _len, "slang", sizeof(new_exts) - _len); + strlcpy(new_exts + _len, "slang", sizeof(new_exts) - _len); } } break; @@ -15485,7 +15485,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, { if (_len > 0) _len += strlcpy(new_exts + _len, "|", sizeof(new_exts) - _len); - _len += strlcpy(new_exts + _len, "slangp", sizeof(new_exts) - _len); + strlcpy(new_exts + _len, "slangp", sizeof(new_exts) - _len); } if (!string_is_empty(info->exts)) free(info->exts); @@ -15523,7 +15523,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, #ifdef HAVE_RTGA if (_len > 0) _len += strlcpy(new_exts + _len, "|", sizeof(new_exts) - _len); - _len += strlcpy(new_exts + _len, "tga", sizeof(new_exts) - _len); + strlcpy(new_exts + _len, "tga", sizeof(new_exts) - _len); #endif if (!string_is_empty(info->exts)) free(info->exts); @@ -15679,7 +15679,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, if (_len > 0) { _len += strlcpy(ext_names + _len, "|", sizeof(ext_names) - _len); - _len += strlcpy(ext_names + _len, FILE_PATH_CORE_BACKUP_EXTENSION_NO_DOT, sizeof(ext_names) - _len); + strlcpy(ext_names + _len, FILE_PATH_CORE_BACKUP_EXTENSION_NO_DOT, sizeof(ext_names) - _len); } else strlcpy(ext_names, FILE_PATH_CORE_BACKUP_EXTENSION_NO_DOT, sizeof(ext_names));