diff --git a/src/common/cd_image_cue.cpp b/src/common/cd_image_cue.cpp index e5a301e0c..12d68a549 100644 --- a/src/common/cd_image_cue.cpp +++ b/src/common/cd_image_cue.cpp @@ -7,6 +7,7 @@ #include "log.h" #include #include +#include #include Log_SetChannel(CDImageCueSheet); @@ -140,11 +141,11 @@ bool CDImageCueSheet::OpenAndParse(const char* filename, Common::Error* error) file_size /= track_sector_size; if (track_start >= file_size) { - Log_ErrorPrintf("Failed to open track %u in '%s': track start is out of range (%ld vs %ld)", track_num, + Log_ErrorPrintf("Failed to open track %u in '%s': track start is out of range (%u vs %" PRIu64 ")", track_num, filename, track_start, file_size); if (error) { - error->SetFormattedMessage("Failed to open track %u in '%s': track start is out of range (%ld vs %ld)", + error->SetFormattedMessage("Failed to open track %u in '%s': track start is out of range (%u vs %" PRIu64 ")", track_num, filename, track_start, file_size); } return false; diff --git a/src/common/cd_image_ecm.cpp b/src/common/cd_image_ecm.cpp index 999fc7973..dcf9252e9 100644 --- a/src/common/cd_image_ecm.cpp +++ b/src/common/cd_image_ecm.cpp @@ -40,7 +40,6 @@ static constexpr std::array ComputeEDCLUT() std::array edc_lut{}; for (u32 i = 0; i < 256; i++) { - u32 j = (i << 1) ^ (i & 0x80 ? 0x11D : 0); u32 edc = i; for (u32 k = 0; k < 8; k++) edc = (edc >> 1) ^ (edc & 1 ? 0xD8018001 : 0); @@ -252,7 +251,6 @@ bool CDImageEcm::Open(const char* filename, Common::Error* error) for (;;) { - long n = std::ftell(m_fp); int bits = std::fgetc(m_fp); if (bits == EOF) { diff --git a/src/common/cd_image_pbp.cpp b/src/common/cd_image_pbp.cpp index 595b8e3e7..d8a656298 100644 --- a/src/common/cd_image_pbp.cpp +++ b/src/common/cd_image_pbp.cpp @@ -98,7 +98,7 @@ static constexpr bool HostIsLittleEndian() { u8 a[4]; u32 b; - } test_val = {1}; + } test_val = {{1}}; return test_val.a[0] == 1; } diff --git a/src/common/cd_image_ppf.cpp b/src/common/cd_image_ppf.cpp index ef2c1120d..c32bd0412 100644 --- a/src/common/cd_image_ppf.cpp +++ b/src/common/cd_image_ppf.cpp @@ -77,11 +77,11 @@ bool CDImagePPF::Open(const char* filename, std::unique_ptr parent_imag m_indices = parent_image->GetIndices(); m_parent_image = std::move(parent_image); - if (magic == '3FPP') + if (magic == 0x33465050) // PPF3 return ReadV3Patch(fp.get()); - else if (magic == '2FPP') + else if (magic == 0x32465050) // PPF2 return ReadV2Patch(fp.get()); - else if (magic == '1FPP') + else if (magic == 0x31465050) // PPF1 return ReadV1Patch(fp.get()); Log_ErrorPrintf("Unknown PPF magic %08X", magic); @@ -99,7 +99,7 @@ u32 CDImagePPF::ReadFileIDDiz(std::FILE* fp, u32 version) return 0; } - if (magic != 'ZID.') + if (magic != 0x5A49442E) // .DIZ return 0; u32 dlen = 0; diff --git a/src/common/cue_parser.cpp b/src/common/cue_parser.cpp index acfa2faef..a0b32e863 100644 --- a/src/common/cue_parser.cpp +++ b/src/common/cue_parser.cpp @@ -120,8 +120,6 @@ std::string_view File::GetToken(const char*& line) std::optional File::GetMSF(const std::string_view& token) { - const u32 len = static_cast(token.length()); - static const s32 max_values[] = {std::numeric_limits::max(), 60, 75}; u32 parts[3] = {}; @@ -190,7 +188,7 @@ bool File::ParseLine(const char* line, u32 line_number, Common::Error* error) if (TokenMatch(command, "POSTGAP")) { - Log_WarningPrintf("Ignoring '*%s' command", static_cast(command.size()), command.data()); + Log_WarningPrintf("Ignoring '%*s' command", static_cast(command.size()), command.data()); return true; } diff --git a/src/common/file_system.cpp b/src/common/file_system.cpp index a3ee5e19b..76761993d 100644 --- a/src/common/file_system.cpp +++ b/src/common/file_system.cpp @@ -221,7 +221,6 @@ static bool FindUriFiles(const char* path, const char* pattern, u32 flags, FindR // small speed optimization for '*' case bool hasWildCards = false; bool wildCardMatchAll = false; - u32 nFiles = 0; if (std::strpbrk(pattern, "*?") != nullptr) { hasWildCards = true; diff --git a/src/common/gl/context_egl_wayland.cpp b/src/common/gl/context_egl_wayland.cpp index 49596e152..2046c44f8 100644 --- a/src/common/gl/context_egl_wayland.cpp +++ b/src/common/gl/context_egl_wayland.cpp @@ -1,7 +1,5 @@ #include "context_egl_wayland.h" -#include "../log.h" #include -Log_SetChannel(GL::ContextEGLWayland); namespace GL { ContextEGLWayland::ContextEGLWayland(const WindowInfo& wi) : ContextEGL(wi) {} diff --git a/src/common/memory_arena.cpp b/src/common/memory_arena.cpp index 74e15092a..a53b8f1b8 100644 --- a/src/common/memory_arena.cpp +++ b/src/common/memory_arena.cpp @@ -143,6 +143,9 @@ bool MemoryArena::Create(size_t size, bool writable, bool executable) return false; } + m_size = size; + m_writable = writable; + m_executable = executable; return true; #elif defined(__ANDROID__) m_shmem_fd = AshmemCreateFileMapping(file_mapping_name.c_str(), size); @@ -152,6 +155,9 @@ bool MemoryArena::Create(size_t size, bool writable, bool executable) return false; } + m_size = size; + m_writable = writable; + m_executable = executable; return true; #elif defined(__linux__) m_shmem_fd = shm_open(file_mapping_name.c_str(), O_CREAT | O_EXCL | (writable ? O_RDWR : O_RDONLY), 0600); @@ -171,6 +177,9 @@ bool MemoryArena::Create(size_t size, bool writable, bool executable) return false; } + m_size = size; + m_writable = writable; + m_executable = executable; return true; #elif defined(__APPLE__) || defined(__FreeBSD__) #if defined(__APPLE__) @@ -197,6 +206,9 @@ bool MemoryArena::Create(size_t size, bool writable, bool executable) return false; } + m_size = size; + m_writable = writable; + m_executable = executable; return true; #else return false; diff --git a/src/common/memory_arena.h b/src/common/memory_arena.h index fee8ae214..0d6a262f5 100644 --- a/src/common/memory_arena.h +++ b/src/common/memory_arena.h @@ -37,6 +37,10 @@ public: static void* FindBaseAddressForMapping(size_t size); + ALWAYS_INLINE size_t GetSize() const { return m_size; } + ALWAYS_INLINE bool IsWritable() const { return m_writable; } + ALWAYS_INLINE bool IsExecutable() const { return m_executable; } + bool IsValid() const; bool Create(size_t size, bool writable, bool executable); void Destroy(); diff --git a/src/common/shiftjis.cpp b/src/common/shiftjis.cpp index 6dead7883..669a9bb13 100644 --- a/src/common/shiftjis.cpp +++ b/src/common/shiftjis.cpp @@ -212,7 +212,7 @@ char* sjis2utf8(char* input) // Simplify the input and decode standard ASCII characters sjis2ascii(input); - int len = static_cast(std::strlen(input)); + size_t len = static_cast(std::strlen(input)); char* output = reinterpret_cast( std::malloc(3 * len)); // ShiftJis won't give 4byte UTF8, so max. 3 byte per input char are needed size_t indexInput = 0, indexOutput = 0; diff --git a/src/core/cpu_recompiler_code_generator_aarch32.cpp b/src/core/cpu_recompiler_code_generator_aarch32.cpp index 76bc5e2be..2cb83f2ba 100644 --- a/src/core/cpu_recompiler_code_generator_aarch32.cpp +++ b/src/core/cpu_recompiler_code_generator_aarch32.cpp @@ -23,7 +23,6 @@ constexpr HostReg RARG2 = 1; constexpr HostReg RARG3 = 2; constexpr HostReg RARG4 = 3; constexpr HostReg RSCRATCH = 12; -constexpr u32 FUNCTION_CALL_STACK_ALIGNMENT = 16; constexpr u32 FUNCTION_CALL_SHADOW_SPACE = 32; constexpr u32 FUNCTION_CALLEE_SAVED_SPACE_RESERVE = 80; // 8 registers constexpr u32 FUNCTION_CALLER_SAVED_SPACE_RESERVE = 144; // 18 registers -> 224 bytes @@ -174,12 +173,14 @@ void CodeGenerator::EmitBeginBlock() // Save the link register, since we'll be calling functions. const bool link_reg_allocated = m_register_cache.AllocateHostReg(14); DebugAssert(link_reg_allocated); + UNREFERENCED_VARIABLE(link_reg_allocated); m_register_cache.AssumeCalleeSavedRegistersAreSaved(); // Store the CPU struct pointer. TODO: make this better. const bool cpu_reg_allocated = m_register_cache.AllocateHostReg(RCPUPTR); // m_emit->Mov(GetCPUPtrReg(), reinterpret_cast(&g_state)); DebugAssert(cpu_reg_allocated); + UNREFERENCED_VARIABLE(cpu_reg_allocated); } void CodeGenerator::EmitEndBlock() diff --git a/src/core/cpu_recompiler_code_generator_aarch64.cpp b/src/core/cpu_recompiler_code_generator_aarch64.cpp index 15f77cfc9..52f3fc32e 100644 --- a/src/core/cpu_recompiler_code_generator_aarch64.cpp +++ b/src/core/cpu_recompiler_code_generator_aarch64.cpp @@ -21,7 +21,6 @@ constexpr HostReg RARG2 = 1; constexpr HostReg RARG3 = 2; constexpr HostReg RARG4 = 3; constexpr HostReg RSCRATCH = 8; -constexpr u64 FUNCTION_CALL_STACK_ALIGNMENT = 16; constexpr u64 FUNCTION_CALL_SHADOW_SPACE = 32; constexpr u64 FUNCTION_CALLEE_SAVED_SPACE_RESERVE = 80; // 8 registers constexpr u64 FUNCTION_CALLER_SAVED_SPACE_RESERVE = 144; // 18 registers -> 224 bytes diff --git a/src/core/cpu_recompiler_code_generator_x64.cpp b/src/core/cpu_recompiler_code_generator_x64.cpp index 7606f7c65..d08c766a6 100644 --- a/src/core/cpu_recompiler_code_generator_x64.cpp +++ b/src/core/cpu_recompiler_code_generator_x64.cpp @@ -213,6 +213,7 @@ void CodeGenerator::EmitBeginBlock() // Store the CPU struct pointer. const bool cpu_reg_allocated = m_register_cache.AllocateHostReg(RCPUPTR); DebugAssert(cpu_reg_allocated); + UNREFERENCED_VARIABLE(cpu_reg_allocated); // m_emit->mov(GetCPUPtrReg(), reinterpret_cast(&g_state)); // If there's loadstore instructions, preload the fastmem base. @@ -220,6 +221,7 @@ void CodeGenerator::EmitBeginBlock() { const bool fastmem_reg_allocated = m_register_cache.AllocateHostReg(RMEMBASEPTR); Assert(fastmem_reg_allocated); + UNREFERENCED_VARIABLE(fastmem_reg_allocated); m_emit->mov(GetFastmemBasePtrReg(), m_emit->qword[GetCPUPtrReg() + offsetof(CPU::State, fastmem_base)]); } } diff --git a/src/core/gpu_hw_opengl.cpp b/src/core/gpu_hw_opengl.cpp index 290f08665..5489b4d16 100644 --- a/src/core/gpu_hw_opengl.cpp +++ b/src/core/gpu_hw_opengl.cpp @@ -334,7 +334,7 @@ void GPU_HW_OpenGL::SetCapabilities(HostDisplay* host_display) GLint max_texel_buffer_size; glGetIntegerv(GL_MAX_TEXTURE_BUFFER_SIZE, reinterpret_cast(&max_texel_buffer_size)); Log_InfoPrintf("Max texel buffer size: %u", max_texel_buffer_size); - if (max_texel_buffer_size < VRAM_WIDTH * VRAM_HEIGHT) + if (max_texel_buffer_size < static_cast(VRAM_WIDTH * VRAM_HEIGHT)) { Log_WarningPrintf("Maximum texture buffer size is less than VRAM size, not using texel buffers."); m_use_texture_buffer_for_vram_writes = false; diff --git a/src/core/negcon.cpp b/src/core/negcon.cpp index 1c109df0b..4a9846698 100644 --- a/src/core/negcon.cpp +++ b/src/core/negcon.cpp @@ -293,8 +293,8 @@ u32 NeGcon::StaticGetVibrationMotorCount() Controller::SettingList NeGcon::StaticGetSettings() { static constexpr std::array settings = { - {SettingInfo::Type::Float, "SteeringDeadzone", TRANSLATABLE("NeGcon", "Steering Axis Deadzone"), - TRANSLATABLE("NeGcon", "Sets deadzone size for steering axis."), "0.00f", "0.00f", "0.99f", "0.01f"}}; + {{SettingInfo::Type::Float, "SteeringDeadzone", TRANSLATABLE("NeGcon", "Steering Axis Deadzone"), + TRANSLATABLE("NeGcon", "Sets deadzone size for steering axis."), "0.00f", "0.00f", "0.99f", "0.01f"}}}; return SettingList(settings.begin(), settings.end()); } diff --git a/src/core/pad.cpp b/src/core/pad.cpp index 8ce4151b6..8f9e09847 100644 --- a/src/core/pad.cpp +++ b/src/core/pad.cpp @@ -82,8 +82,8 @@ bool Pad::DoStateController(StateWrapper& sw, u32 i) // dev-friendly untranslated console log. Log_DevPrintf("Controller type mismatch in slot %u: state=%s(%u) ui=%s(%u) load_from_state=%s", i + 1u, - Settings::GetControllerTypeName(state_controller_type), state_controller_type, - Settings::GetControllerTypeName(controller_type), controller_type, + Settings::GetControllerTypeName(state_controller_type), static_cast(state_controller_type), + Settings::GetControllerTypeName(controller_type), static_cast(controller_type), g_settings.load_devices_from_save_states ? "yes" : "no"); if (g_settings.load_devices_from_save_states) diff --git a/src/core/pgxp.cpp b/src/core/pgxp.cpp index 9ebb8f7bd..4bec5bc45 100644 --- a/src/core/pgxp.cpp +++ b/src/core/pgxp.cpp @@ -212,10 +212,7 @@ double ALWAYS_INLINE_RELEASE f16Overflow(double in) // pgxp_mem.c static void PGXP_InitMem(); -static const u32 UserMemOffset = 0; static const u32 ScratchOffset = 2048 * 1024 / 4; -static const u32 RegisterOffset = 2 * 2048 * 1024 / 4; -static const u32 InvalidAddress = 3 * 2048 * 1024 / 4; void PGXP_InitMem() { diff --git a/src/core/system.cpp b/src/core/system.cpp index 4e814f4e5..43b69f4e3 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -1906,9 +1906,6 @@ void UpdateMemoryCardTypes() void UpdatePerGameMemoryCards() { - // Disable memory cards when running PSFs. - const bool is_running_psf = !s_running_game_path.empty() && IsPsfFileName(s_running_game_path.c_str()); - for (u32 i = 0; i < NUM_CONTROLLER_AND_CARD_PORTS; i++) { const MemoryCardType type = g_settings.memory_card_types[i]; diff --git a/src/duckstation-nogui/evdev_key_names.h b/src/duckstation-nogui/evdev_key_names.h index 208d19bba..27b920ab2 100644 --- a/src/duckstation-nogui/evdev_key_names.h +++ b/src/duckstation-nogui/evdev_key_names.h @@ -258,13 +258,13 @@ static const std::map s_evdev_key_names = {{KEY_ESC, "Escape"} {KEY_RFKILL, "Rfkill"}, {KEY_MICMUTE, "Micmute"}}; -static const char* GetKeyName(int key) +static inline const char* GetKeyName(int key) { const auto it = s_evdev_key_names.find(key); return it == s_evdev_key_names.end() ? nullptr : it->second; } -static std::optional GetKeyCodeForName(const std::string_view key_name) +static inline std::optional GetKeyCodeForName(const std::string_view key_name) { for (const auto& it : s_evdev_key_names) { diff --git a/src/duckstation-qt/achievementsettingswidget.cpp b/src/duckstation-qt/achievementsettingswidget.cpp index eec6cee1f..c2a62bb2b 100644 --- a/src/duckstation-qt/achievementsettingswidget.cpp +++ b/src/duckstation-qt/achievementsettingswidget.cpp @@ -57,7 +57,6 @@ AchievementSettingsWidget::~AchievementSettingsWidget() = default; void AchievementSettingsWidget::updateEnableState() { const bool enabled = m_host_interface->GetBoolSettingValue("Cheevos", "Enabled", false); - const bool challenge_mode = m_host_interface->GetBoolSettingValue("Cheevos", "ChallengeMode", false); m_ui.testMode->setEnabled(enabled); m_ui.useFirstDiscFromPlaylist->setEnabled(enabled); m_ui.richPresence->setEnabled(enabled); diff --git a/src/duckstation-qt/qtutils.cpp b/src/duckstation-qt/qtutils.cpp index 4d014b5b7..94a2922d7 100644 --- a/src/duckstation-qt/qtutils.cpp +++ b/src/duckstation-qt/qtutils.cpp @@ -57,7 +57,6 @@ ALWAYS_INLINE_RELEASE static void ResizeColumnsForView(T* view, const std::initi header = view->header(); const int min_column_width = header->minimumSectionSize(); - const int max_column_width = header->maximumSectionSize(); const int scrollbar_width = ((view->verticalScrollBar() && view->verticalScrollBar()->isVisible()) || view->verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOn) ? view->verticalScrollBar()->width() : diff --git a/src/frontend-common/common_host_interface.cpp b/src/frontend-common/common_host_interface.cpp index a15186785..744b2d4fb 100644 --- a/src/frontend-common/common_host_interface.cpp +++ b/src/frontend-common/common_host_interface.cpp @@ -1098,7 +1098,6 @@ void CommonHostInterface::DrawFPSWindow() position_y += text_size.y + spacing; \ } while (0) - const System::State state = System::GetState(); if (System::GetState() == System::State::Running) { const float speed = System::GetEmulationSpeed(); @@ -2015,7 +2014,7 @@ void CommonHostInterface::RegisterGeneralHotkeys() }); RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "General")), StaticString("ChangeDisc"), - StaticString(TRANSLATABLE("Hotkeys", "Change Disc")), [this](bool pressed) { + StaticString(TRANSLATABLE("Hotkeys", "Change Disc")), [](bool pressed) { if (pressed && System::IsValid() && System::HasMediaSubImages()) { const u32 current = System::GetMediaSubImageIndex(); @@ -2887,7 +2886,6 @@ void CommonHostInterface::LoadSettings(SettingsInterface& si) } const bool input_display_enabled = si.GetBoolValue("Display", "ShowInputs", false); - const bool input_display_state = static_cast(s_input_overlay_ui); if (input_display_enabled && !s_input_overlay_ui) s_input_overlay_ui = std::make_unique(); else if (!input_display_enabled && s_input_overlay_ui) diff --git a/src/frontend-common/fullscreen_ui.cpp b/src/frontend-common/fullscreen_ui.cpp index b0756aa78..69b99add6 100644 --- a/src/frontend-common/fullscreen_ui.cpp +++ b/src/frontend-common/fullscreen_ui.cpp @@ -2988,8 +2988,7 @@ void DrawGameListWindow() if (BeginFullscreenColumnWindow(0.0f, 450.0f, "game_list_info", ImVec4(0.11f, 0.15f, 0.17f, 1.00f))) { - const auto* window = ImGui::GetCurrentWindow(); - const ImVec2 base_pos(window->DC.CursorPos); + const ImGuiWindow* window = ImGui::GetCurrentWindow(); ImGui::SetCursorPos(LayoutScale(ImVec2(50.0f, 50.0f))); ImGui::Image(selected_entry ? GetGameListCover(selected_entry)->GetHandle() : @@ -4118,7 +4117,6 @@ void DrawAchievementWindow() const ImVec4 background(0.13f, 0.13f, 0.13f, alpha); const ImVec2 display_size(ImGui::GetIO().DisplaySize); - const float window_width = LayoutScale(LAYOUT_SCREEN_WIDTH); const float heading_height = LayoutScale(heading_height_unscaled); if (BeginFullscreenWindow( @@ -4129,6 +4127,8 @@ void DrawAchievementWindow() bool visible, hovered; bool pressed = MenuButtonFrame("achievements_heading", false, heading_height_unscaled, &visible, &hovered, &bb.Min, &bb.Max, 0, alpha); + UNREFERENCED_VARIABLE(pressed); + if (visible) { const float padding = LayoutScale(10.0f);