diff options
author | bunnei <bunneidev@gmail.com> | 2020-10-21 04:07:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-21 04:07:39 +0200 |
commit | 3d592972dc3fd61cc88771b889eff237e4e03e0f (patch) | |
tree | 0dbc65ac86e609ae22087c7be9d4759ac6b73004 /src/core/file_sys | |
parent | kernel: Fix build with recent compiler flag changes (diff) | |
download | yuzu-3d592972dc3fd61cc88771b889eff237e4e03e0f.tar yuzu-3d592972dc3fd61cc88771b889eff237e4e03e0f.tar.gz yuzu-3d592972dc3fd61cc88771b889eff237e4e03e0f.tar.bz2 yuzu-3d592972dc3fd61cc88771b889eff237e4e03e0f.tar.lz yuzu-3d592972dc3fd61cc88771b889eff237e4e03e0f.tar.xz yuzu-3d592972dc3fd61cc88771b889eff237e4e03e0f.tar.zst yuzu-3d592972dc3fd61cc88771b889eff237e4e03e0f.zip |
Diffstat (limited to 'src/core/file_sys')
-rw-r--r-- | src/core/file_sys/content_archive.cpp | 4 | ||||
-rw-r--r-- | src/core/file_sys/fsmitm_romfsbuild.cpp | 2 | ||||
-rw-r--r-- | src/core/file_sys/ips_layer.cpp | 41 | ||||
-rw-r--r-- | src/core/file_sys/kernel_executable.cpp | 6 | ||||
-rw-r--r-- | src/core/file_sys/nca_patch.cpp | 7 |
5 files changed, 23 insertions, 37 deletions
diff --git a/src/core/file_sys/content_archive.cpp b/src/core/file_sys/content_archive.cpp index 0917f6ebf..76af47ff9 100644 --- a/src/core/file_sys/content_archive.cpp +++ b/src/core/file_sys/content_archive.cpp @@ -201,9 +201,9 @@ bool NCA::HandlePotentialHeaderDecryption() { } std::vector<NCASectionHeader> NCA::ReadSectionHeaders() const { - const auto number_sections = static_cast<std::size_t>( + const std::ptrdiff_t number_sections = std::count_if(std::begin(header.section_tables), std::end(header.section_tables), - [](NCASectionTableEntry entry) { return entry.media_offset > 0; })); + [](NCASectionTableEntry entry) { return entry.media_offset > 0; }); std::vector<NCASectionHeader> sections(number_sections); const auto length_sections = SECTION_HEADER_SIZE * number_sections; diff --git a/src/core/file_sys/fsmitm_romfsbuild.cpp b/src/core/file_sys/fsmitm_romfsbuild.cpp index b2d38f01e..c52fafb6f 100644 --- a/src/core/file_sys/fsmitm_romfsbuild.cpp +++ b/src/core/file_sys/fsmitm_romfsbuild.cpp @@ -103,7 +103,7 @@ static u32 romfs_calc_path_hash(u32 parent, std::string_view path, u32 start, u32 hash = parent ^ 123456789; for (u32 i = 0; i < path_len; i++) { hash = (hash >> 5) | (hash << 27); - hash ^= static_cast<u32>(path[start + i]); + hash ^= path[start + i]; } return hash; 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<u8>& 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<u32>(temp[0] << 24) | static_cast<u32>(temp[1] << 16) | - static_cast<u32>(temp[2] << 8) | temp[3]; - } else { - real_offset = - static_cast<u32>(temp[0] << 16) | static_cast<u32>(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<u16>(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<u16>(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<const char*>(bytes.data()), - static_cast<std::streamsize>(bytes.size())); + s.write(reinterpret_cast<const char*>(bytes.data()), bytes.size()); std::vector<std::string> 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)); } diff --git a/src/core/file_sys/kernel_executable.cpp b/src/core/file_sys/kernel_executable.cpp index fa758b777..ef93ef3ed 100644 --- a/src/core/file_sys/kernel_executable.cpp +++ b/src/core/file_sys/kernel_executable.cpp @@ -36,14 +36,14 @@ bool DecompressBLZ(std::vector<u8>& data) { while (out_index > 0) { --index; auto control = data[index + start_offset]; - for (std::size_t i = 0; i < 8; ++i) { + for (size_t i = 0; i < 8; ++i) { if (((control << i) & 0x80) > 0) { if (index < 2) { return false; } index -= 2; - std::size_t segment_offset = static_cast<u32>(data[index + start_offset]) | - static_cast<u32>(data[index + start_offset + 1] << 8); + std::size_t segment_offset = + data[index + start_offset] | data[index + start_offset + 1] << 8; std::size_t segment_size = ((segment_offset >> 12) & 0xF) + 3; segment_offset &= 0xFFF; segment_offset += 3; diff --git a/src/core/file_sys/nca_patch.cpp b/src/core/file_sys/nca_patch.cpp index 6d3472447..5990a2fd5 100644 --- a/src/core/file_sys/nca_patch.cpp +++ b/src/core/file_sys/nca_patch.cpp @@ -25,9 +25,9 @@ std::pair<std::size_t, std::size_t> SearchBucketEntry(u64 offset, const BlockTyp ASSERT_MSG(offset <= block.size, "Offset is out of bounds in BKTR relocation block."); } - const auto bucket_id = static_cast<std::size_t>(std::count_if( + std::size_t bucket_id = std::count_if( block.base_offsets.begin() + 1, block.base_offsets.begin() + block.number_buckets, - [&offset](u64 base_offset) { return base_offset <= offset; })); + [&offset](u64 base_offset) { return base_offset <= offset; }); const auto& bucket = buckets[bucket_id]; @@ -53,7 +53,6 @@ std::pair<std::size_t, std::size_t> SearchBucketEntry(u64 offset, const BlockTyp } UNREACHABLE_MSG("Offset could not be found in BKTR block."); - return {}; } } // Anonymous namespace @@ -137,7 +136,7 @@ std::size_t BKTR::Read(u8* data, std::size_t length, std::size_t offset) const { const auto block_offset = section_offset & 0xF; if (block_offset != 0) { - auto block = bktr_romfs->ReadBytes(0x10, section_offset & ~0xFU); + auto block = bktr_romfs->ReadBytes(0x10, section_offset & ~0xF); cipher.Transcode(block.data(), block.size(), block.data(), Core::Crypto::Op::Decrypt); if (length + block_offset < 0x10) { std::memcpy(data, block.data() + block_offset, std::min(length, block.size())); |