From 39c8d18feba8eafcd43fbb55e73ae150a1947aad Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 13 Oct 2020 08:10:50 -0400 Subject: core/CMakeLists: Make some warnings errors Makes our error coverage a little more consistent across the board by applying it to Linux side of things as well. This also makes it more consistent with the warning settings in other libraries in the project. This also updates httplib to 0.7.9, as there are several warning cleanups made that allow us to enable several warnings as errors. --- src/core/file_sys/ips_layer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/file_sys/ips_layer.cpp') diff --git a/src/core/file_sys/ips_layer.cpp b/src/core/file_sys/ips_layer.cpp index dd779310f..a6101f1c0 100644 --- a/src/core/file_sys/ips_layer.cpp +++ b/src/core/file_sys/ips_layer.cpp @@ -299,7 +299,7 @@ void IPSwitchCompiler::Parse() { patch_text->GetName(), offset, Common::HexToString(replace)); } - patch.records.insert_or_assign(offset, std::move(replace)); + patch.records.insert_or_assign(static_cast(offset), std::move(replace)); } patches.push_back(std::move(patch)); -- cgit v1.2.3 From be1954e04cb5a0c3a526f78ed5490a5e65310280 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 15 Oct 2020 14:49:45 -0400 Subject: core: Fix clang build Recent changes to the build system that made more warnings be flagged as errors caused building via clang to break. Fixes #4795 --- src/core/file_sys/ips_layer.cpp | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) (limited to 'src/core/file_sys/ips_layer.cpp') diff --git a/src/core/file_sys/ips_layer.cpp b/src/core/file_sys/ips_layer.cpp index a6101f1c0..91dc69373 100644 --- a/src/core/file_sys/ips_layer.cpp +++ b/src/core/file_sys/ips_layer.cpp @@ -66,12 +66,14 @@ static bool IsEOF(IPSFileType type, const std::vector& data) { } VirtualFile PatchIPS(const VirtualFile& in, const VirtualFile& ips) { - if (in == nullptr || ips == nullptr) + if (in == nullptr || ips == nullptr) { return nullptr; + } const auto type = IdentifyMagic(ips->ReadBytes(0x5)); - if (type == IPSFileType::Error) + if (type == IPSFileType::Error) { return nullptr; + } auto in_data = in->ReadAllBytes(); @@ -84,37 +86,46 @@ VirtualFile PatchIPS(const VirtualFile& in, const VirtualFile& ips) { } u32 real_offset{}; - if (type == IPSFileType::IPS32) - real_offset = (temp[0] << 24) | (temp[1] << 16) | (temp[2] << 8) | temp[3]; - else - real_offset = (temp[0] << 16) | (temp[1] << 8) | temp[2]; + if (type == IPSFileType::IPS32) { + real_offset = static_cast(temp[0] << 24) | static_cast(temp[1] << 16) | + static_cast(temp[2] << 8) | temp[3]; + } else { + real_offset = + static_cast(temp[0] << 16) | static_cast(temp[1] << 8) | temp[2]; + } u16 data_size{}; - if (ips->ReadObject(&data_size, offset) != sizeof(u16)) + if (ips->ReadObject(&data_size, offset) != sizeof(u16)) { return nullptr; + } data_size = Common::swap16(data_size); offset += sizeof(u16); if (data_size == 0) { // RLE u16 rle_size{}; - if (ips->ReadObject(&rle_size, offset) != sizeof(u16)) + if (ips->ReadObject(&rle_size, offset) != sizeof(u16)) { return nullptr; + } rle_size = Common::swap16(rle_size); offset += sizeof(u16); const auto data = ips->ReadByte(offset++); - if (!data) + if (!data) { return nullptr; + } - if (real_offset + rle_size > in_data.size()) + if (real_offset + rle_size > in_data.size()) { rle_size = static_cast(in_data.size() - real_offset); + } std::memset(in_data.data() + real_offset, *data, rle_size); } else { // Standard Patch auto read = data_size; - if (real_offset + read > in_data.size()) + if (real_offset + read > in_data.size()) { read = static_cast(in_data.size() - real_offset); - if (ips->Read(in_data.data() + real_offset, read, offset) != data_size) + } + if (ips->Read(in_data.data() + real_offset, read, offset) != data_size) { return nullptr; + } offset += data_size; } } @@ -182,14 +193,16 @@ void IPSwitchCompiler::ParseFlag(const std::string& line) { void IPSwitchCompiler::Parse() { const auto bytes = patch_text->ReadAllBytes(); std::stringstream s; - s.write(reinterpret_cast(bytes.data()), bytes.size()); + s.write(reinterpret_cast(bytes.data()), + static_cast(bytes.size())); std::vector lines; std::string stream_line; while (std::getline(s, stream_line)) { // Remove a trailing \r - if (!stream_line.empty() && stream_line.back() == '\r') + if (!stream_line.empty() && stream_line.back() == '\r') { stream_line.pop_back(); + } lines.push_back(std::move(stream_line)); } -- cgit v1.2.3 From 3d592972dc3fd61cc88771b889eff237e4e03e0f Mon Sep 17 00:00:00 2001 From: bunnei Date: Tue, 20 Oct 2020 19:07:39 -0700 Subject: Revert "core: Fix clang build" --- src/core/file_sys/ips_layer.cpp | 41 ++++++++++++++--------------------------- 1 file changed, 14 insertions(+), 27 deletions(-) (limited to 'src/core/file_sys/ips_layer.cpp') diff --git a/src/core/file_sys/ips_layer.cpp b/src/core/file_sys/ips_layer.cpp index 91dc69373..a6101f1c0 100644 --- a/src/core/file_sys/ips_layer.cpp +++ b/src/core/file_sys/ips_layer.cpp @@ -66,14 +66,12 @@ static bool IsEOF(IPSFileType type, const std::vector& data) { } VirtualFile PatchIPS(const VirtualFile& in, const VirtualFile& ips) { - if (in == nullptr || ips == nullptr) { + if (in == nullptr || ips == nullptr) return nullptr; - } const auto type = IdentifyMagic(ips->ReadBytes(0x5)); - if (type == IPSFileType::Error) { + if (type == IPSFileType::Error) return nullptr; - } auto in_data = in->ReadAllBytes(); @@ -86,46 +84,37 @@ VirtualFile PatchIPS(const VirtualFile& in, const VirtualFile& ips) { } u32 real_offset{}; - if (type == IPSFileType::IPS32) { - real_offset = static_cast(temp[0] << 24) | static_cast(temp[1] << 16) | - static_cast(temp[2] << 8) | temp[3]; - } else { - real_offset = - static_cast(temp[0] << 16) | static_cast(temp[1] << 8) | temp[2]; - } + if (type == IPSFileType::IPS32) + real_offset = (temp[0] << 24) | (temp[1] << 16) | (temp[2] << 8) | temp[3]; + else + real_offset = (temp[0] << 16) | (temp[1] << 8) | temp[2]; u16 data_size{}; - if (ips->ReadObject(&data_size, offset) != sizeof(u16)) { + if (ips->ReadObject(&data_size, offset) != sizeof(u16)) return nullptr; - } data_size = Common::swap16(data_size); offset += sizeof(u16); if (data_size == 0) { // RLE u16 rle_size{}; - if (ips->ReadObject(&rle_size, offset) != sizeof(u16)) { + if (ips->ReadObject(&rle_size, offset) != sizeof(u16)) return nullptr; - } rle_size = Common::swap16(rle_size); offset += sizeof(u16); const auto data = ips->ReadByte(offset++); - if (!data) { + if (!data) return nullptr; - } - if (real_offset + rle_size > in_data.size()) { + if (real_offset + rle_size > in_data.size()) rle_size = static_cast(in_data.size() - real_offset); - } std::memset(in_data.data() + real_offset, *data, rle_size); } else { // Standard Patch auto read = data_size; - if (real_offset + read > in_data.size()) { + if (real_offset + read > in_data.size()) read = static_cast(in_data.size() - real_offset); - } - if (ips->Read(in_data.data() + real_offset, read, offset) != data_size) { + if (ips->Read(in_data.data() + real_offset, read, offset) != data_size) return nullptr; - } offset += data_size; } } @@ -193,16 +182,14 @@ void IPSwitchCompiler::ParseFlag(const std::string& line) { void IPSwitchCompiler::Parse() { const auto bytes = patch_text->ReadAllBytes(); std::stringstream s; - s.write(reinterpret_cast(bytes.data()), - static_cast(bytes.size())); + s.write(reinterpret_cast(bytes.data()), bytes.size()); std::vector lines; std::string stream_line; while (std::getline(s, stream_line)) { // Remove a trailing \r - if (!stream_line.empty() && stream_line.back() == '\r') { + if (!stream_line.empty() && stream_line.back() == '\r') stream_line.pop_back(); - } lines.push_back(std::move(stream_line)); } -- cgit v1.2.3