diff --git a/Source/Core/Common/FilesystemWatcher.cpp b/Source/Core/Common/FilesystemWatcher.cpp index 646e2467ed..94970232b2 100644 --- a/Source/Core/Common/FilesystemWatcher.cpp +++ b/Source/Core/Common/FilesystemWatcher.cpp @@ -31,13 +31,13 @@ void FilesystemWatcher::Watch(const std::string& path) if (e.effect_type == wtr::event::effect_type::create) { - const auto path = WithUnifiedPathSeparators(watched_path); - PathAdded(path); + const auto unified_path = WithUnifiedPathSeparators(watched_path); + PathAdded(unified_path); } else if (e.effect_type == wtr::event::effect_type::modify) { - const auto path = WithUnifiedPathSeparators(watched_path); - PathModified(path); + const auto unified_path = WithUnifiedPathSeparators(watched_path); + PathModified(unified_path); } else if (e.effect_type == wtr::event::effect_type::rename) { @@ -53,8 +53,8 @@ void FilesystemWatcher::Watch(const std::string& path) } else if (e.effect_type == wtr::event::effect_type::destroy) { - const auto path = WithUnifiedPathSeparators(watched_path); - PathDeleted(path); + const auto unified_path = WithUnifiedPathSeparators(watched_path); + PathDeleted(unified_path); } }); } diff --git a/Source/Core/Core/ARDecrypt.cpp b/Source/Core/Core/ARDecrypt.cpp index 46ca74d159..98f49cfc41 100644 --- a/Source/Core/Core/ARDecrypt.cpp +++ b/Source/Core/Core/ARDecrypt.cpp @@ -459,7 +459,7 @@ static int alphatobin(u32* dst, const std::vector& alpha, int size) void DecryptARCode(std::vector vCodes, std::vector* ops) { - std::array uCodes; + std::array uCodes{}; for (std::string& s : vCodes) { diff --git a/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp b/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp index 3b308891c6..0394ae9236 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp @@ -67,7 +67,7 @@ void SpeakerLogic::SpeakerData(const u8* data, int length, float speaker_pan) // Potentially 40 resulting samples. std::array samples; - assert(length * 2 <= samples.size()); + assert(length * 2 <= static_cast(samples.size())); unsigned int sample_rate_dividend, sample_length; u8 volume_divisor; diff --git a/Source/Core/Core/IOS/Network/IP/Top.cpp b/Source/Core/Core/IOS/Network/IP/Top.cpp index 08008f97b7..c99f3d0511 100644 --- a/Source/Core/Core/IOS/Network/IP/Top.cpp +++ b/Source/Core/Core/IOS/Network/IP/Top.cpp @@ -256,7 +256,7 @@ static std::vector GetSystemInterfaceRouting() } // read response - int msg_len = 0; + unsigned int msg_len = 0; msg_buffer.fill(0); do @@ -270,9 +270,10 @@ static std::vector GetSystemInterfaceRouting() } nl_msg = reinterpret_cast(buf_ptr); - if (NLMSG_OK(nl_msg, read_len) == 0) + if (NLMSG_OK(nl_msg, static_cast(read_len)) == 0) { - ERROR_LOG_FMT(IOS_NET, "Received netlink error response ({})", NLMSG_OK(nl_msg, read_len)); + ERROR_LOG_FMT(IOS_NET, "Received netlink error response ({})", + NLMSG_OK(nl_msg, static_cast(read_len))); return {}; } diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_RegCache.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_RegCache.cpp index 465d0257af..20a86c0389 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_RegCache.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_RegCache.cpp @@ -176,7 +176,10 @@ Arm64GPRCache::GuestRegInfo Arm64GPRCache::GetGuestCR(size_t preg) Arm64GPRCache::GuestRegInfo Arm64GPRCache::GetGuestByIndex(size_t index) { - if (index >= GUEST_GPR_OFFSET && index < GUEST_GPR_OFFSET + GUEST_GPR_COUNT) + // We do not need to test for `index >= GUEST_GPR_OFFSET` because + // GUEST_GPR_OFFSET is always 0. This otherwise raises a warning. + static_assert(GUEST_GPR_OFFSET == 0); + if (index < GUEST_GPR_OFFSET + GUEST_GPR_COUNT) return GetGuestGPR(index - GUEST_GPR_OFFSET); if (index >= GUEST_CR_OFFSET && index < GUEST_CR_OFFSET + GUEST_CR_COUNT) return GetGuestCR(index - GUEST_CR_OFFSET); diff --git a/Source/Core/Core/State.h b/Source/Core/Core/State.h index 1e4ba0029b..4b100b214c 100644 --- a/Source/Core/Core/State.h +++ b/Source/Core/Core/State.h @@ -107,7 +107,7 @@ void SaveAs(Core::System& system, const std::string& filename, bool wait = false void LoadAs(Core::System& system, const std::string& filename); void SaveToBuffer(Core::System& system, Common::UniqueBuffer& buffer); -void LoadFromBuffer(Core::System& system, const Common::UniqueBuffer& buffer); +void LoadFromBuffer(Core::System& system, Common::UniqueBuffer& buffer); void LoadLastSaved(Core::System& system, int i = 1); void SaveFirstSaved(Core::System& system); diff --git a/Source/Core/DolphinQt/CheatSearchWidget.cpp b/Source/Core/DolphinQt/CheatSearchWidget.cpp index bbd8675f3e..c18e8cb6a6 100644 --- a/Source/Core/DolphinQt/CheatSearchWidget.cpp +++ b/Source/Core/DolphinQt/CheatSearchWidget.cpp @@ -531,7 +531,7 @@ void CheatSearchWidget::GenerateARCodes() return; bool had_success = false; - bool had_error = false; + bool had_multiple_errors = false; std::optional error_code; for (auto* const item : m_address_table->selectedItems()) @@ -546,23 +546,24 @@ void CheatSearchWidget::GenerateARCodes() else { const auto new_error_code = result.Error(); - if (!had_error) + if (!error_code.has_value()) { error_code = new_error_code; } else if (error_code != new_error_code) { - // If we have a different error code signify multiple errors with an empty optional<>. - error_code.reset(); + had_multiple_errors = true; } - - had_error = true; } } - if (had_error) + if (error_code.has_value()) { - if (error_code.has_value()) + if (had_multiple_errors) + { + m_info_label_1->setText(tr("Multiple errors occurred while generating AR codes.")); + } + else { switch (*error_code) { @@ -577,10 +578,6 @@ void CheatSearchWidget::GenerateARCodes() break; } } - else - { - m_info_label_1->setText(tr("Multiple errors while generating AR codes.")); - } } else if (had_success) { diff --git a/Source/Core/DolphinQt/Config/WiimoteControllersWidget.cpp b/Source/Core/DolphinQt/Config/WiimoteControllersWidget.cpp index ef6989ad9b..11c98ee883 100644 --- a/Source/Core/DolphinQt/Config/WiimoteControllersWidget.cpp +++ b/Source/Core/DolphinQt/Config/WiimoteControllersWidget.cpp @@ -309,8 +309,15 @@ void WiimoteControllersWidget::OnBluetoothPassthroughDeviceChanged(int index) return; } - auto device_info = - m_bluetooth_adapters->itemData(index).value(); + const QVariant item_data = m_bluetooth_adapters->itemData(index); + + if (!item_data.isValid() || !item_data.canConvert()) + { + ERROR_LOG_FMT(COMMON, "Invalid Bluetooth device info selected in WiimoteControllersWidget"); + return; + } + + const auto& device_info = item_data.value(); Config::SetBaseOrCurrent(Config::MAIN_BLUETOOTH_PASSTHROUGH_PID, device_info.pid); Config::SetBaseOrCurrent(Config::MAIN_BLUETOOTH_PASSTHROUGH_VID, device_info.vid); diff --git a/Source/Core/InputCommon/ControllerInterface/SDL/SDLGamepad.cpp b/Source/Core/InputCommon/ControllerInterface/SDL/SDLGamepad.cpp index 345bef00a3..38358999b7 100644 --- a/Source/Core/InputCommon/ControllerInterface/SDL/SDLGamepad.cpp +++ b/Source/Core/InputCommon/ControllerInterface/SDL/SDLGamepad.cpp @@ -13,7 +13,7 @@ namespace ciface::SDL { -bool IsTriggerAxis(int index) +static bool IsTriggerAxis(int index) { // First 4 axes are for the analog sticks, the rest are for the triggers return index >= 4; diff --git a/Source/Core/VideoBackends/Metal/MRCHelpers.h b/Source/Core/VideoBackends/Metal/MRCHelpers.h index 1da2e0c8d1..839b24cf60 100644 --- a/Source/Core/VideoBackends/Metal/MRCHelpers.h +++ b/Source/Core/VideoBackends/Metal/MRCHelpers.h @@ -20,7 +20,7 @@ template class MRCOwned { T ptr; - MRCOwned(T ptr) : ptr(ptr) {} + MRCOwned(T raw_ptr) : ptr(raw_ptr) {} public: MRCOwned() : ptr(nullptr) {} diff --git a/Source/Core/VideoBackends/Metal/MTLStateTracker.mm b/Source/Core/VideoBackends/Metal/MTLStateTracker.mm index c2cd685a82..755da35249 100644 --- a/Source/Core/VideoBackends/Metal/MTLStateTracker.mm +++ b/Source/Core/VideoBackends/Metal/MTLStateTracker.mm @@ -32,7 +32,7 @@ struct Metal::StateTracker::Backref { std::mutex mtx; StateTracker* state_tracker; - explicit Backref(StateTracker* state_tracker) : state_tracker(state_tracker) {} + explicit Backref(StateTracker* tracker) : state_tracker(tracker) {} }; struct Metal::StateTracker::PerfQueryTracker diff --git a/Source/UnitTests/Common/SPSCQueueTest.cpp b/Source/UnitTests/Common/SPSCQueueTest.cpp index 13848bd95f..ddc57c8d1a 100644 --- a/Source/UnitTests/Common/SPSCQueueTest.cpp +++ b/Source/UnitTests/Common/SPSCQueueTest.cpp @@ -32,7 +32,7 @@ TEST(SPSCQueue, Simple) EXPECT_EQ(1000u, q.Size()); for (u32 i = 0; i < 1000; ++i) { - u32 v2; + u32 v2 = 0; q.Pop(v2); EXPECT_EQ(i, v2); } diff --git a/Source/UnitTests/Common/StringUtilTest.cpp b/Source/UnitTests/Common/StringUtilTest.cpp index 5c21610a13..2be462a1b5 100644 --- a/Source/UnitTests/Common/StringUtilTest.cpp +++ b/Source/UnitTests/Common/StringUtilTest.cpp @@ -57,7 +57,7 @@ static void DoRoundTripTest(const std::vector& data) for (const T& e : data) { const std::string s = ValueToString(e); - T out; + T out = T(); EXPECT_TRUE(TryParse(s, &out)); EXPECT_EQ(e, out); }