From 3b5faf90f30c8b470527e7cf498cbabf161559e9 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Sun, 16 Jan 2022 21:19:34 -0800 Subject: [PATCH 1/8] =?UTF-8?q?FifoAnalyzer:=20Fix=20"enumeration=20value?= =?UTF-8?q?=20=E2=80=98NotPresent=E2=80=99=20not=20handled=20in=20switch"?= =?UTF-8?q?=20warning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp b/Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp index be9daf57d3..4227e2af38 100644 --- a/Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp +++ b/Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp @@ -704,6 +704,8 @@ public: case VertexComponentFormat::Direct: process_simple_component(component_sizes[vtx_attr.GetColorFormat(c)]); break; + case VertexComponentFormat::NotPresent: + break; } } for (u32 t = 0; t < vtx_desc.high.TexCoord.Size(); t++) From a720596771c448744ee3c069524630a3e343de1a Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Sun, 16 Jan 2022 21:20:56 -0800 Subject: [PATCH 2/8] GDB Stub: Fix typo mixing ppcState.spr and ppcState.sr This resulted in an out-of-bounds array access, since sr is only 16 entries long and SPR_IBAT0U evaluates to 528. --- Source/Core/Core/PowerPC/GDBStub.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Core/PowerPC/GDBStub.cpp b/Source/Core/Core/PowerPC/GDBStub.cpp index 91bc4a465d..f097135940 100644 --- a/Source/Core/Core/PowerPC/GDBStub.cpp +++ b/Source/Core/Core/PowerPC/GDBStub.cpp @@ -633,7 +633,7 @@ static void WriteRegister() } else if (id >= 88 && id < 104) { - PowerPC::ppcState.sr[SPR_IBAT0U + id - 88] = re32hex(bufptr); + PowerPC::ppcState.spr[SPR_IBAT0U + id - 88] = re32hex(bufptr); } else { From 0e23dfbb256783a41a0f400251d64d5f4c2c3474 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Sun, 16 Jan 2022 21:28:44 -0800 Subject: [PATCH 3/8] FifoDataFile: Stop ignoring size The size variable started to be unused when I created std::array variants of ReadArray, but we should follow it in case any files have fewer registers stored than they should (otherwise the remaining registers would end up with garbage data from later in the fifolog). Though, there probably aren't many fifologs where this is relevant. --- Source/Core/Core/FifoPlayer/FifoDataFile.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Core/Core/FifoPlayer/FifoDataFile.cpp b/Source/Core/Core/FifoPlayer/FifoDataFile.cpp index 7bfdff7833..119e19d861 100644 --- a/Source/Core/Core/FifoPlayer/FifoDataFile.cpp +++ b/Source/Core/Core/FifoPlayer/FifoDataFile.cpp @@ -285,19 +285,19 @@ std::unique_ptr FifoDataFile::Load(const std::string& filename, bo u32 size = std::min(BP_MEM_SIZE, header.bpMemSize); file.Seek(header.bpMemOffset, File::SeekOrigin::Begin); - file.ReadArray(&dataFile->m_BPMem); + file.ReadArray(dataFile->m_BPMem.data(), size); size = std::min(CP_MEM_SIZE, header.cpMemSize); file.Seek(header.cpMemOffset, File::SeekOrigin::Begin); - file.ReadArray(&dataFile->m_CPMem); + file.ReadArray(dataFile->m_CPMem.data(), size); size = std::min(XF_MEM_SIZE, header.xfMemSize); file.Seek(header.xfMemOffset, File::SeekOrigin::Begin); - file.ReadArray(&dataFile->m_XFMem); + file.ReadArray(dataFile->m_XFMem.data(), size); size = std::min(XF_REGS_SIZE, header.xfRegsSize); file.Seek(header.xfRegsOffset, File::SeekOrigin::Begin); - file.ReadArray(&dataFile->m_XFRegs); + file.ReadArray(dataFile->m_XFRegs.data(), size); // Texture memory saving was added in version 4. dataFile->m_TexMem.fill(0); From a6d516dc9442faa24646bb4d09b5e190a7a5c0e0 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Sun, 16 Jan 2022 21:30:53 -0800 Subject: [PATCH 4/8] Fix shadowing variables in labmdas GCC generates warnings about these, although the variable being shadowed is not captured by the lambda. --- Source/Core/Core/NetPlayClient.cpp | 26 ++++++++++--------- .../Core/DolphinQt/RiivolutionBootWidget.cpp | 8 +++--- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/Source/Core/Core/NetPlayClient.cpp b/Source/Core/Core/NetPlayClient.cpp index 54aeb83e83..6dcbb2e353 100644 --- a/Source/Core/Core/NetPlayClient.cpp +++ b/Source/Core/Core/NetPlayClient.cpp @@ -1747,18 +1747,20 @@ bool NetPlayClient::StartGame(const std::string& path) // boot game auto boot_session_data = std::make_unique(); - boot_session_data->SetWiiSyncData( - std::move(m_wii_sync_fs), std::move(m_wii_sync_titles), std::move(m_wii_sync_redirect_folder), - [] { - // on emulation end clean up the Wii save sync directory -- see OnSyncSaveDataWii() - const std::string path = File::GetUserPath(D_USER_IDX) + "Wii" GC_MEMCARD_NETPLAY DIR_SEP; - if (File::Exists(path)) - File::DeleteDirRecursively(path); - const std::string redirect_path = - File::GetUserPath(D_USER_IDX) + "Redirect" GC_MEMCARD_NETPLAY DIR_SEP; - if (File::Exists(redirect_path)) - File::DeleteDirRecursively(redirect_path); - }); + boot_session_data->SetWiiSyncData(std::move(m_wii_sync_fs), std::move(m_wii_sync_titles), + std::move(m_wii_sync_redirect_folder), [] { + // on emulation end clean up the Wii save sync directory -- + // see OnSyncSaveDataWii() + const std::string wii_path = File::GetUserPath(D_USER_IDX) + + "Wii" GC_MEMCARD_NETPLAY DIR_SEP; + if (File::Exists(wii_path)) + File::DeleteDirRecursively(wii_path); + const std::string redirect_path = + File::GetUserPath(D_USER_IDX) + + "Redirect" GC_MEMCARD_NETPLAY DIR_SEP; + if (File::Exists(redirect_path)) + File::DeleteDirRecursively(redirect_path); + }); m_dialog->BootGame(path, std::move(boot_session_data)); UpdateDevices(); diff --git a/Source/Core/DolphinQt/RiivolutionBootWidget.cpp b/Source/Core/DolphinQt/RiivolutionBootWidget.cpp index c70df8e770..ff19d8597a 100644 --- a/Source/Core/DolphinQt/RiivolutionBootWidget.cpp +++ b/Source/Core/DolphinQt/RiivolutionBootWidget.cpp @@ -207,10 +207,10 @@ void RiivolutionBootWidget::MakeGUIForParsedFile(std::string path, std::string r connect(selection, qOverload(&QComboBox::currentIndexChanged), this, [this, selection](int idx) { const auto gui_index = selection->currentData().value(); - auto& disc = m_discs[gui_index.m_disc_index].disc; - auto& section = disc.m_sections[gui_index.m_section_index]; - auto& option = section.m_options[gui_index.m_option_index]; - option.m_selected_choice = static_cast(gui_index.m_choice_index); + auto& selected_disc = m_discs[gui_index.m_disc_index].disc; + auto& selected_section = selected_disc.m_sections[gui_index.m_section_index]; + auto& selected_option = selected_section.m_options[gui_index.m_option_index]; + selected_option.m_selected_choice = static_cast(gui_index.m_choice_index); }); grid_layout->addWidget(label, row, 0, 1, 1); From 15f80f72342b7f8dcf24dd27fdc0d10c92f86914 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Sun, 16 Jan 2022 23:32:27 -0800 Subject: [PATCH 5/8] MathUtil: Mark lo in SaturatingCast as [[maybe_unused]] It's unused in the case that T is unsigned and dest is signed (e.g. SaturatingCast which appears SetIsoPaths in MainSettings.cpp) --- Source/Core/Common/MathUtil.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Common/MathUtil.h b/Source/Core/Common/MathUtil.h index 9b31a9acd5..4f3af04dc5 100644 --- a/Source/Core/Common/MathUtil.h +++ b/Source/Core/Common/MathUtil.h @@ -37,7 +37,7 @@ constexpr Dest SaturatingCast(T value) { static_assert(std::is_integral()); - constexpr Dest lo = std::numeric_limits::lowest(); + [[maybe_unused]] constexpr Dest lo = std::numeric_limits::lowest(); constexpr Dest hi = std::numeric_limits::max(); // T being a signed integer and Dest unsigned is a problematic case because the value will From 5f9e04be1d73b3c9ec8aa66defcedbc6f7106c46 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Sun, 16 Jan 2022 23:55:23 -0800 Subject: [PATCH 6/8] DSPJit: Suppress offsetof conditionally-supported warnings The DSP JIT only applies on x64, so if it doesn't work on esoteric compilers then that's not a problem. (And if it fails to compile, then it'll still produce an error on that platform, just no warnings on other platforms) --- Source/Core/Core/DSP/Jit/x64/DSPEmitter.cpp | 7 +++++++ Source/Core/Core/DSP/Jit/x64/DSPJitMultiplier.cpp | 7 +++++++ Source/Core/Core/DSP/Jit/x64/DSPJitRegCache.cpp | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/Source/Core/Core/DSP/Jit/x64/DSPEmitter.cpp b/Source/Core/Core/DSP/Jit/x64/DSPEmitter.cpp index bfe7d117ec..4960c4c992 100644 --- a/Source/Core/Core/DSP/Jit/x64/DSPEmitter.cpp +++ b/Source/Core/Core/DSP/Jit/x64/DSPEmitter.cpp @@ -470,6 +470,10 @@ void DSPEmitter::CompileDispatcher() RET(); } +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Winvalid-offsetof" +#endif Gen::OpArg DSPEmitter::M_SDSP_pc() { return MDisp(R15, static_cast(offsetof(SDSP, pc))); @@ -503,5 +507,8 @@ Gen::OpArg DSPEmitter::M_SDSP_reg_stack_ptrs(size_t index) return MDisp(R15, static_cast(offsetof(SDSP, reg_stack_ptrs) + sizeof(SDSP::reg_stack_ptrs[0]) * index)); } +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif } // namespace DSP::JIT::x64 diff --git a/Source/Core/Core/DSP/Jit/x64/DSPJitMultiplier.cpp b/Source/Core/Core/DSP/Jit/x64/DSPJitMultiplier.cpp index d37e7fd460..617c92462a 100644 --- a/Source/Core/Core/DSP/Jit/x64/DSPJitMultiplier.cpp +++ b/Source/Core/Core/DSP/Jit/x64/DSPJitMultiplier.cpp @@ -149,7 +149,14 @@ void DSPEmitter::multiply_mulx(u8 axh0, u8 axh1) // direct use of prod regs by AX/AXWII (look @that part of ucode). void DSPEmitter::clrp(const UDSPInstruction opc) { +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Winvalid-offsetof" +#endif int offset = static_cast(offsetof(SDSP, r.prod.val)); +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif // 64bit move to memory does not work. use 2 32bits MOV(32, MDisp(R15, offset + 0 * sizeof(u32)), Imm32(0xfff00000U)); MOV(32, MDisp(R15, offset + 1 * sizeof(u32)), Imm32(0x001000ffU)); diff --git a/Source/Core/Core/DSP/Jit/x64/DSPJitRegCache.cpp b/Source/Core/Core/DSP/Jit/x64/DSPJitRegCache.cpp index 9e69daafab..31becddf8d 100644 --- a/Source/Core/Core/DSP/Jit/x64/DSPJitRegCache.cpp +++ b/Source/Core/Core/DSP/Jit/x64/DSPJitRegCache.cpp @@ -20,6 +20,10 @@ namespace DSP::JIT::x64 constexpr std::array s_allocation_order = { {R8, R9, R10, R11, R12, R13, R14, R15, RSI, RDI, RBX, RCX, RDX, RAX, RBP}}; +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Winvalid-offsetof" +#endif static Gen::OpArg GetRegisterPointer(size_t reg) { switch (reg) @@ -95,6 +99,9 @@ static Gen::OpArg GetRegisterPointer(size_t reg) return M(static_cast(nullptr)); } } +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif #define STATIC_REG_ACCS //#undef STATIC_REG_ACCS From 50d93499269fb3d8a444cea6ae4da6daad2a2c10 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Mon, 17 Jan 2022 00:21:58 -0800 Subject: [PATCH 7/8] Fix integer sign difference comparison warnings --- Source/Core/Core/Core.cpp | 2 +- Source/Core/DiscIO/VolumeVerifier.cpp | 7 ++++--- Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index a945d72276..08b615f5bf 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -1031,7 +1031,7 @@ int AddOnStateChangedCallback(StateChangedCallbackFunc callback) bool RemoveOnStateChangedCallback(int* handle) { - if (handle && *handle >= 0 && s_on_state_changed_callbacks.size() > *handle) + if (handle && *handle >= 0 && s_on_state_changed_callbacks.size() > static_cast(*handle)) { s_on_state_changed_callbacks[*handle] = StateChangedCallbackFunc(); *handle = -1; diff --git a/Source/Core/DiscIO/VolumeVerifier.cpp b/Source/Core/DiscIO/VolumeVerifier.cpp index 252cf427b6..593fb49b33 100644 --- a/Source/Core/DiscIO/VolumeVerifier.cpp +++ b/Source/Core/DiscIO/VolumeVerifier.cpp @@ -1113,10 +1113,11 @@ void VolumeVerifier::Process() bytes_to_read = Common::AlignUp(content.size, 0x40); content_read = true; - if (m_content_index + 1 < m_content_offsets.size() && - m_content_offsets[m_content_index + 1] < m_progress + bytes_to_read) + const u16 next_content_index = m_content_index + 1; + if (next_content_index < m_content_offsets.size() && + m_content_offsets[next_content_index] < m_progress + bytes_to_read) { - excess_bytes = m_progress + bytes_to_read - m_content_offsets[m_content_index + 1]; + excess_bytes = m_progress + bytes_to_read - m_content_offsets[next_content_index]; } } else if (m_content_index < m_content_offsets.size() && diff --git a/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp b/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp index 77bb8c8bd3..fb300a370f 100644 --- a/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp @@ -376,7 +376,7 @@ void CodeViewWidget::Update() void CodeViewWidget::CalculateBranchIndentation() { - const size_t rows = rowCount(); + const u32 rows = rowCount(); const size_t columns = m_branches.size(); if (rows < 1 || columns < 1) return; @@ -442,7 +442,7 @@ void CodeViewWidget::CalculateBranchIndentation() }; const u32 first_visible_addr = AddressForRow(0); - const u32 last_visible_addr = AddressForRow(static_cast(rows - 1)); + const u32 last_visible_addr = AddressForRow(rows - 1); if (first_visible_addr <= last_visible_addr) { @@ -456,7 +456,7 @@ void CodeViewWidget::CalculateBranchIndentation() // first_visible_addr to fffffffc, and the second for 00000000 to last_visible_addr. // That means we need to find the row corresponding to 00000000. int addr_zero_row = -1; - for (int row = 0; row < rows; row++) + for (u32 row = 0; row < rows; row++) { if (AddressForRow(row) == 0) { From d2ebbfb91a7d50b0db12010392a594c12bbf1c44 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Mon, 17 Jan 2022 00:40:46 -0800 Subject: [PATCH 8/8] GDB Stub: Make s_socket_context static --- Source/Core/Core/PowerPC/GDBStub.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Core/PowerPC/GDBStub.cpp b/Source/Core/Core/PowerPC/GDBStub.cpp index f097135940..2fe39b75fd 100644 --- a/Source/Core/Core/PowerPC/GDBStub.cpp +++ b/Source/Core/Core/PowerPC/GDBStub.cpp @@ -40,7 +40,7 @@ typedef SSIZE_T ssize_t; namespace GDBStub { -std::optional s_socket_context; +static std::optional s_socket_context; #define GDB_BFR_MAX 10000