Fix various warnings

This commit is contained in:
Joshua Vandaële
2025-06-09 15:30:26 +02:00
parent f76ab86326
commit 06882bd2dc
13 changed files with 40 additions and 32 deletions

View File

@ -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);
}
});
}

View File

@ -459,7 +459,7 @@ static int alphatobin(u32* dst, const std::vector<std::string>& alpha, int size)
void DecryptARCode(std::vector<std::string> vCodes, std::vector<AREntry>* ops)
{
std::array<u32, 1200> uCodes;
std::array<u32, 1200> uCodes{};
for (std::string& s : vCodes)
{

View File

@ -67,7 +67,7 @@ void SpeakerLogic::SpeakerData(const u8* data, int length, float speaker_pan)
// Potentially 40 resulting samples.
std::array<s16, WiimoteCommon::OutputReportSpeakerData::DATA_SIZE * 2> samples;
assert(length * 2 <= samples.size());
assert(length * 2 <= static_cast<int>(samples.size()));
unsigned int sample_rate_dividend, sample_length;
u8 volume_divisor;

View File

@ -256,7 +256,7 @@ static std::vector<InterfaceRouting> GetSystemInterfaceRouting()
}
// read response
int msg_len = 0;
unsigned int msg_len = 0;
msg_buffer.fill(0);
do
@ -270,9 +270,10 @@ static std::vector<InterfaceRouting> GetSystemInterfaceRouting()
}
nl_msg = reinterpret_cast<nlmsghdr*>(buf_ptr);
if (NLMSG_OK(nl_msg, read_len) == 0)
if (NLMSG_OK(nl_msg, static_cast<unsigned int>(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<unsigned int>(read_len)));
return {};
}

View File

@ -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);

View File

@ -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<u8>& buffer);
void LoadFromBuffer(Core::System& system, const Common::UniqueBuffer<u8>& buffer);
void LoadFromBuffer(Core::System& system, Common::UniqueBuffer<u8>& buffer);
void LoadLastSaved(Core::System& system, int i = 1);
void SaveFirstSaved(Core::System& system);

View File

@ -531,7 +531,7 @@ void CheatSearchWidget::GenerateARCodes()
return;
bool had_success = false;
bool had_error = false;
bool had_multiple_errors = false;
std::optional<Cheats::GenerateActionReplayCodeErrorCode> 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 (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)
{

View File

@ -309,8 +309,15 @@ void WiimoteControllersWidget::OnBluetoothPassthroughDeviceChanged(int index)
return;
}
auto device_info =
m_bluetooth_adapters->itemData(index).value<LibUSBBluetoothAdapter::BluetoothDeviceInfo>();
const QVariant item_data = m_bluetooth_adapters->itemData(index);
if (!item_data.isValid() || !item_data.canConvert<LibUSBBluetoothAdapter::BluetoothDeviceInfo>())
{
ERROR_LOG_FMT(COMMON, "Invalid Bluetooth device info selected in WiimoteControllersWidget");
return;
}
const auto& device_info = item_data.value<LibUSBBluetoothAdapter::BluetoothDeviceInfo>();
Config::SetBaseOrCurrent(Config::MAIN_BLUETOOTH_PASSTHROUGH_PID, device_info.pid);
Config::SetBaseOrCurrent(Config::MAIN_BLUETOOTH_PASSTHROUGH_VID, device_info.vid);

View File

@ -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;

View File

@ -20,7 +20,7 @@ template <typename T>
class MRCOwned
{
T ptr;
MRCOwned(T ptr) : ptr(ptr) {}
MRCOwned(T raw_ptr) : ptr(raw_ptr) {}
public:
MRCOwned() : ptr(nullptr) {}

View File

@ -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

View File

@ -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);
}

View File

@ -57,7 +57,7 @@ static void DoRoundTripTest(const std::vector<T>& 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);
}