CMakeLists: Specify -Wextra on linux builds
Allows reporting more cases where logic errors may exist, such as implicit fallthrough cases, etc. We currently ignore unused parameters, since we currently have many cases where this is intentional (virtual interfaces). While we're at it, we can also tidy up any existing code that causes warnings. This also uncovered a few bugs as well.
This commit is contained in:
parent
e33196d4e7
commit
1c340c6efa
26 changed files with 93 additions and 70 deletions
|
@ -284,17 +284,17 @@ ResultCode HLERequestContext::WriteToOutgoingCommandBuffer(Thread& thread) {
|
|||
|
||||
std::vector<u8> HLERequestContext::ReadBuffer(int buffer_index) const {
|
||||
std::vector<u8> buffer;
|
||||
const bool is_buffer_a{BufferDescriptorA().size() > buffer_index &&
|
||||
const bool is_buffer_a{BufferDescriptorA().size() > std::size_t(buffer_index) &&
|
||||
BufferDescriptorA()[buffer_index].Size()};
|
||||
auto& memory = Core::System::GetInstance().Memory();
|
||||
|
||||
if (is_buffer_a) {
|
||||
ASSERT_MSG(BufferDescriptorA().size() > buffer_index,
|
||||
ASSERT_MSG(BufferDescriptorA().size() > std::size_t(buffer_index),
|
||||
"BufferDescriptorA invalid buffer_index {}", buffer_index);
|
||||
buffer.resize(BufferDescriptorA()[buffer_index].Size());
|
||||
memory.ReadBlock(BufferDescriptorA()[buffer_index].Address(), buffer.data(), buffer.size());
|
||||
} else {
|
||||
ASSERT_MSG(BufferDescriptorX().size() > buffer_index,
|
||||
ASSERT_MSG(BufferDescriptorX().size() > std::size_t(buffer_index),
|
||||
"BufferDescriptorX invalid buffer_index {}", buffer_index);
|
||||
buffer.resize(BufferDescriptorX()[buffer_index].Size());
|
||||
memory.ReadBlock(BufferDescriptorX()[buffer_index].Address(), buffer.data(), buffer.size());
|
||||
|
@ -310,7 +310,7 @@ std::size_t HLERequestContext::WriteBuffer(const void* buffer, std::size_t size,
|
|||
return 0;
|
||||
}
|
||||
|
||||
const bool is_buffer_b{BufferDescriptorB().size() > buffer_index &&
|
||||
const bool is_buffer_b{BufferDescriptorB().size() > std::size_t(buffer_index) &&
|
||||
BufferDescriptorB()[buffer_index].Size()};
|
||||
const std::size_t buffer_size{GetWriteBufferSize(buffer_index)};
|
||||
if (size > buffer_size) {
|
||||
|
@ -321,13 +321,13 @@ std::size_t HLERequestContext::WriteBuffer(const void* buffer, std::size_t size,
|
|||
|
||||
auto& memory = Core::System::GetInstance().Memory();
|
||||
if (is_buffer_b) {
|
||||
ASSERT_MSG(BufferDescriptorB().size() > buffer_index,
|
||||
ASSERT_MSG(BufferDescriptorB().size() > std::size_t(buffer_index),
|
||||
"BufferDescriptorB invalid buffer_index {}", buffer_index);
|
||||
ASSERT_MSG(BufferDescriptorB()[buffer_index].Size() >= size,
|
||||
"BufferDescriptorB buffer_index {} is not large enough", buffer_index);
|
||||
memory.WriteBlock(BufferDescriptorB()[buffer_index].Address(), buffer, size);
|
||||
} else {
|
||||
ASSERT_MSG(BufferDescriptorC().size() > buffer_index,
|
||||
ASSERT_MSG(BufferDescriptorC().size() > std::size_t(buffer_index),
|
||||
"BufferDescriptorC invalid buffer_index {}", buffer_index);
|
||||
ASSERT_MSG(BufferDescriptorC()[buffer_index].Size() >= size,
|
||||
"BufferDescriptorC buffer_index {} is not large enough", buffer_index);
|
||||
|
@ -338,16 +338,16 @@ std::size_t HLERequestContext::WriteBuffer(const void* buffer, std::size_t size,
|
|||
}
|
||||
|
||||
std::size_t HLERequestContext::GetReadBufferSize(int buffer_index) const {
|
||||
const bool is_buffer_a{BufferDescriptorA().size() > buffer_index &&
|
||||
const bool is_buffer_a{BufferDescriptorA().size() > std::size_t(buffer_index) &&
|
||||
BufferDescriptorA()[buffer_index].Size()};
|
||||
if (is_buffer_a) {
|
||||
ASSERT_MSG(BufferDescriptorA().size() > buffer_index,
|
||||
ASSERT_MSG(BufferDescriptorA().size() > std::size_t(buffer_index),
|
||||
"BufferDescriptorA invalid buffer_index {}", buffer_index);
|
||||
ASSERT_MSG(BufferDescriptorA()[buffer_index].Size() > 0,
|
||||
"BufferDescriptorA buffer_index {} is empty", buffer_index);
|
||||
return BufferDescriptorA()[buffer_index].Size();
|
||||
} else {
|
||||
ASSERT_MSG(BufferDescriptorX().size() > buffer_index,
|
||||
ASSERT_MSG(BufferDescriptorX().size() > std::size_t(buffer_index),
|
||||
"BufferDescriptorX invalid buffer_index {}", buffer_index);
|
||||
ASSERT_MSG(BufferDescriptorX()[buffer_index].Size() > 0,
|
||||
"BufferDescriptorX buffer_index {} is empty", buffer_index);
|
||||
|
@ -356,14 +356,14 @@ std::size_t HLERequestContext::GetReadBufferSize(int buffer_index) const {
|
|||
}
|
||||
|
||||
std::size_t HLERequestContext::GetWriteBufferSize(int buffer_index) const {
|
||||
const bool is_buffer_b{BufferDescriptorB().size() > buffer_index &&
|
||||
const bool is_buffer_b{BufferDescriptorB().size() > std::size_t(buffer_index) &&
|
||||
BufferDescriptorB()[buffer_index].Size()};
|
||||
if (is_buffer_b) {
|
||||
ASSERT_MSG(BufferDescriptorB().size() > buffer_index,
|
||||
ASSERT_MSG(BufferDescriptorB().size() > std::size_t(buffer_index),
|
||||
"BufferDescriptorB invalid buffer_index {}", buffer_index);
|
||||
return BufferDescriptorB()[buffer_index].Size();
|
||||
} else {
|
||||
ASSERT_MSG(BufferDescriptorC().size() > buffer_index,
|
||||
ASSERT_MSG(BufferDescriptorC().size() > std::size_t(buffer_index),
|
||||
"BufferDescriptorC invalid buffer_index {}", buffer_index);
|
||||
return BufferDescriptorC()[buffer_index].Size();
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ private:
|
|||
LOG_DEBUG(Service_Audio, "called. rendering_time_limit_percent={}",
|
||||
rendering_time_limit_percent);
|
||||
|
||||
ASSERT(rendering_time_limit_percent >= 0 && rendering_time_limit_percent <= 100);
|
||||
ASSERT(rendering_time_limit_percent <= 100);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
|
|
|
@ -451,7 +451,8 @@ FileSys::SaveDataSize FileSystemController::ReadSaveDataSize(FileSys::SaveDataTy
|
|||
|
||||
if (res != Loader::ResultStatus::Success) {
|
||||
FileSys::PatchManager pm{system.CurrentProcess()->GetTitleID()};
|
||||
auto [nacp_unique, discard] = pm.GetControlMetadata();
|
||||
const auto metadata = pm.GetControlMetadata();
|
||||
const auto& nacp_unique = metadata.first;
|
||||
|
||||
if (nacp_unique != nullptr) {
|
||||
new_size = {nacp_unique->GetDefaultNormalSaveSize(),
|
||||
|
|
|
@ -575,6 +575,7 @@ private:
|
|||
0,
|
||||
user_id->GetSize(),
|
||||
{},
|
||||
{},
|
||||
});
|
||||
|
||||
continue;
|
||||
|
@ -595,6 +596,7 @@ private:
|
|||
stoull_be(title_id->GetName()),
|
||||
title_id->GetSize(),
|
||||
{},
|
||||
{},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -619,6 +621,7 @@ private:
|
|||
stoull_be(title_id->GetName()),
|
||||
title_id->GetSize(),
|
||||
{},
|
||||
{},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -309,7 +309,7 @@ static bool ParsePosixName(const char* name, TimeZoneRule& rule) {
|
|||
offset = GetTZName(name, offset);
|
||||
std_len = offset;
|
||||
}
|
||||
if (!std_len) {
|
||||
if (std_len == 0) {
|
||||
return {};
|
||||
}
|
||||
if (!GetOffset(name, offset, std_offset)) {
|
||||
|
@ -320,7 +320,7 @@ static bool ParsePosixName(const char* name, TimeZoneRule& rule) {
|
|||
int dest_len{};
|
||||
int dest_offset{};
|
||||
const char* dest_name{name + offset};
|
||||
if (rule.chars.size() < char_count) {
|
||||
if (rule.chars.size() < std::size_t(char_count)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -343,7 +343,7 @@ static bool ParsePosixName(const char* name, TimeZoneRule& rule) {
|
|||
return {};
|
||||
}
|
||||
char_count += dest_len + 1;
|
||||
if (rule.chars.size() < char_count) {
|
||||
if (rule.chars.size() < std::size_t(char_count)) {
|
||||
return {};
|
||||
}
|
||||
if (name[offset] != '\0' && name[offset] != ',' && name[offset] != ';') {
|
||||
|
@ -414,7 +414,7 @@ static bool ParsePosixName(const char* name, TimeZoneRule& rule) {
|
|||
if (is_reversed ||
|
||||
(start_time < end_time &&
|
||||
(end_time - start_time < (year_seconds + (std_offset - dest_offset))))) {
|
||||
if (rule.ats.size() - 2 < time_count) {
|
||||
if (rule.ats.size() - 2 < std::size_t(time_count)) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -609,7 +609,7 @@ static bool ParseTimeZoneBinary(TimeZoneRule& time_zone_rule, FileSys::VirtualFi
|
|||
}
|
||||
|
||||
const u64 position{(read_offset - sizeof(TzifHeader))};
|
||||
const std::size_t bytes_read{vfs_file->GetSize() - sizeof(TzifHeader) - position};
|
||||
const s64 bytes_read = s64(vfs_file->GetSize() - sizeof(TzifHeader) - position);
|
||||
if (bytes_read < 0) {
|
||||
return {};
|
||||
}
|
||||
|
@ -621,11 +621,11 @@ static bool ParseTimeZoneBinary(TimeZoneRule& time_zone_rule, FileSys::VirtualFi
|
|||
std::array<char, time_zone_name_max + 1> temp_name{};
|
||||
vfs_file->ReadArray(temp_name.data(), bytes_read, read_offset);
|
||||
if (bytes_read > 2 && temp_name[0] == '\n' && temp_name[bytes_read - 1] == '\n' &&
|
||||
time_zone_rule.type_count + 2 <= time_zone_rule.ttis.size()) {
|
||||
std::size_t(time_zone_rule.type_count) + 2 <= time_zone_rule.ttis.size()) {
|
||||
temp_name[bytes_read - 1] = '\0';
|
||||
|
||||
std::array<char, time_zone_name_max> name{};
|
||||
std::memcpy(name.data(), temp_name.data() + 1, bytes_read - 1);
|
||||
std::memcpy(name.data(), temp_name.data() + 1, std::size_t(bytes_read - 1));
|
||||
|
||||
TimeZoneRule temp_rule;
|
||||
if (ParsePosixName(name.data(), temp_rule)) {
|
||||
|
|
|
@ -101,8 +101,8 @@ public:
|
|||
}
|
||||
|
||||
std::u16string ReadInterfaceToken() {
|
||||
u32 unknown = Read<u32_le>();
|
||||
u32 length = Read<u32_le>();
|
||||
[[maybe_unused]] const u32 unknown = Read<u32_le>();
|
||||
const u32 length = Read<u32_le>();
|
||||
|
||||
std::u16string token{};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue