diff options
| author | 2020-10-20 19:07:39 -0700 | |
|---|---|---|
| committer | 2020-10-20 19:07:39 -0700 | |
| commit | 3d592972dc3fd61cc88771b889eff237e4e03e0f (patch) | |
| tree | 0dbc65ac86e609ae22087c7be9d4759ac6b73004 /src/core/file_sys | |
| parent | kernel: Fix build with recent compiler flag changes (diff) | |
| download | yuzu-3d592972dc3fd61cc88771b889eff237e4e03e0f.tar.gz yuzu-3d592972dc3fd61cc88771b889eff237e4e03e0f.tar.xz yuzu-3d592972dc3fd61cc88771b889eff237e4e03e0f.zip | |
Revert "core: Fix clang build"
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() { | |||
| 201 | } | 201 | } |
| 202 | 202 | ||
| 203 | std::vector<NCASectionHeader> NCA::ReadSectionHeaders() const { | 203 | std::vector<NCASectionHeader> NCA::ReadSectionHeaders() const { |
| 204 | const auto number_sections = static_cast<std::size_t>( | 204 | const std::ptrdiff_t number_sections = |
| 205 | std::count_if(std::begin(header.section_tables), std::end(header.section_tables), | 205 | std::count_if(std::begin(header.section_tables), std::end(header.section_tables), |
| 206 | [](NCASectionTableEntry entry) { return entry.media_offset > 0; })); | 206 | [](NCASectionTableEntry entry) { return entry.media_offset > 0; }); |
| 207 | 207 | ||
| 208 | std::vector<NCASectionHeader> sections(number_sections); | 208 | std::vector<NCASectionHeader> sections(number_sections); |
| 209 | const auto length_sections = SECTION_HEADER_SIZE * number_sections; | 209 | 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, | |||
| 103 | u32 hash = parent ^ 123456789; | 103 | u32 hash = parent ^ 123456789; |
| 104 | for (u32 i = 0; i < path_len; i++) { | 104 | for (u32 i = 0; i < path_len; i++) { |
| 105 | hash = (hash >> 5) | (hash << 27); | 105 | hash = (hash >> 5) | (hash << 27); |
| 106 | hash ^= static_cast<u32>(path[start + i]); | 106 | hash ^= path[start + i]; |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | return hash; | 109 | 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) { | |||
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | VirtualFile PatchIPS(const VirtualFile& in, const VirtualFile& ips) { | 68 | VirtualFile PatchIPS(const VirtualFile& in, const VirtualFile& ips) { |
| 69 | if (in == nullptr || ips == nullptr) { | 69 | if (in == nullptr || ips == nullptr) |
| 70 | return nullptr; | 70 | return nullptr; |
| 71 | } | ||
| 72 | 71 | ||
| 73 | const auto type = IdentifyMagic(ips->ReadBytes(0x5)); | 72 | const auto type = IdentifyMagic(ips->ReadBytes(0x5)); |
| 74 | if (type == IPSFileType::Error) { | 73 | if (type == IPSFileType::Error) |
| 75 | return nullptr; | 74 | return nullptr; |
| 76 | } | ||
| 77 | 75 | ||
| 78 | auto in_data = in->ReadAllBytes(); | 76 | auto in_data = in->ReadAllBytes(); |
| 79 | 77 | ||
| @@ -86,46 +84,37 @@ VirtualFile PatchIPS(const VirtualFile& in, const VirtualFile& ips) { | |||
| 86 | } | 84 | } |
| 87 | 85 | ||
| 88 | u32 real_offset{}; | 86 | u32 real_offset{}; |
| 89 | if (type == IPSFileType::IPS32) { | 87 | if (type == IPSFileType::IPS32) |
| 90 | real_offset = static_cast<u32>(temp[0] << 24) | static_cast<u32>(temp[1] << 16) | | 88 | real_offset = (temp[0] << 24) | (temp[1] << 16) | (temp[2] << 8) | temp[3]; |
| 91 | static_cast<u32>(temp[2] << 8) | temp[3]; | 89 | else |
| 92 | } else { | 90 | real_offset = (temp[0] << 16) | (temp[1] << 8) | temp[2]; |
| 93 | real_offset = | ||
| 94 | static_cast<u32>(temp[0] << 16) | static_cast<u32>(temp[1] << 8) | temp[2]; | ||
| 95 | } | ||
| 96 | 91 | ||
| 97 | u16 data_size{}; | 92 | u16 data_size{}; |
| 98 | if (ips->ReadObject(&data_size, offset) != sizeof(u16)) { | 93 | if (ips->ReadObject(&data_size, offset) != sizeof(u16)) |
| 99 | return nullptr; | 94 | return nullptr; |
| 100 | } | ||
| 101 | data_size = Common::swap16(data_size); | 95 | data_size = Common::swap16(data_size); |
| 102 | offset += sizeof(u16); | 96 | offset += sizeof(u16); |
| 103 | 97 | ||
| 104 | if (data_size == 0) { // RLE | 98 | if (data_size == 0) { // RLE |
| 105 | u16 rle_size{}; | 99 | u16 rle_size{}; |
| 106 | if (ips->ReadObject(&rle_size, offset) != sizeof(u16)) { | 100 | if (ips->ReadObject(&rle_size, offset) != sizeof(u16)) |
| 107 | return nullptr; | 101 | return nullptr; |
| 108 | } | ||
| 109 | rle_size = Common::swap16(rle_size); | 102 | rle_size = Common::swap16(rle_size); |
| 110 | offset += sizeof(u16); | 103 | offset += sizeof(u16); |
| 111 | 104 | ||
| 112 | const auto data = ips->ReadByte(offset++); | 105 | const auto data = ips->ReadByte(offset++); |
| 113 | if (!data) { | 106 | if (!data) |
| 114 | return nullptr; | 107 | return nullptr; |
| 115 | } | ||
| 116 | 108 | ||
| 117 | if (real_offset + rle_size > in_data.size()) { | 109 | if (real_offset + rle_size > in_data.size()) |
| 118 | rle_size = static_cast<u16>(in_data.size() - real_offset); | 110 | rle_size = static_cast<u16>(in_data.size() - real_offset); |
| 119 | } | ||
| 120 | std::memset(in_data.data() + real_offset, *data, rle_size); | 111 | std::memset(in_data.data() + real_offset, *data, rle_size); |
| 121 | } else { // Standard Patch | 112 | } else { // Standard Patch |
| 122 | auto read = data_size; | 113 | auto read = data_size; |
| 123 | if (real_offset + read > in_data.size()) { | 114 | if (real_offset + read > in_data.size()) |
| 124 | read = static_cast<u16>(in_data.size() - real_offset); | 115 | read = static_cast<u16>(in_data.size() - real_offset); |
| 125 | } | 116 | if (ips->Read(in_data.data() + real_offset, read, offset) != data_size) |
| 126 | if (ips->Read(in_data.data() + real_offset, read, offset) != data_size) { | ||
| 127 | return nullptr; | 117 | return nullptr; |
| 128 | } | ||
| 129 | offset += data_size; | 118 | offset += data_size; |
| 130 | } | 119 | } |
| 131 | } | 120 | } |
| @@ -193,16 +182,14 @@ void IPSwitchCompiler::ParseFlag(const std::string& line) { | |||
| 193 | void IPSwitchCompiler::Parse() { | 182 | void IPSwitchCompiler::Parse() { |
| 194 | const auto bytes = patch_text->ReadAllBytes(); | 183 | const auto bytes = patch_text->ReadAllBytes(); |
| 195 | std::stringstream s; | 184 | std::stringstream s; |
| 196 | s.write(reinterpret_cast<const char*>(bytes.data()), | 185 | s.write(reinterpret_cast<const char*>(bytes.data()), bytes.size()); |
| 197 | static_cast<std::streamsize>(bytes.size())); | ||
| 198 | 186 | ||
| 199 | std::vector<std::string> lines; | 187 | std::vector<std::string> lines; |
| 200 | std::string stream_line; | 188 | std::string stream_line; |
| 201 | while (std::getline(s, stream_line)) { | 189 | while (std::getline(s, stream_line)) { |
| 202 | // Remove a trailing \r | 190 | // Remove a trailing \r |
| 203 | if (!stream_line.empty() && stream_line.back() == '\r') { | 191 | if (!stream_line.empty() && stream_line.back() == '\r') |
| 204 | stream_line.pop_back(); | 192 | stream_line.pop_back(); |
| 205 | } | ||
| 206 | lines.push_back(std::move(stream_line)); | 193 | lines.push_back(std::move(stream_line)); |
| 207 | } | 194 | } |
| 208 | 195 | ||
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) { | |||
| 36 | while (out_index > 0) { | 36 | while (out_index > 0) { |
| 37 | --index; | 37 | --index; |
| 38 | auto control = data[index + start_offset]; | 38 | auto control = data[index + start_offset]; |
| 39 | for (std::size_t i = 0; i < 8; ++i) { | 39 | for (size_t i = 0; i < 8; ++i) { |
| 40 | if (((control << i) & 0x80) > 0) { | 40 | if (((control << i) & 0x80) > 0) { |
| 41 | if (index < 2) { | 41 | if (index < 2) { |
| 42 | return false; | 42 | return false; |
| 43 | } | 43 | } |
| 44 | index -= 2; | 44 | index -= 2; |
| 45 | std::size_t segment_offset = static_cast<u32>(data[index + start_offset]) | | 45 | std::size_t segment_offset = |
| 46 | static_cast<u32>(data[index + start_offset + 1] << 8); | 46 | data[index + start_offset] | data[index + start_offset + 1] << 8; |
| 47 | std::size_t segment_size = ((segment_offset >> 12) & 0xF) + 3; | 47 | std::size_t segment_size = ((segment_offset >> 12) & 0xF) + 3; |
| 48 | segment_offset &= 0xFFF; | 48 | segment_offset &= 0xFFF; |
| 49 | segment_offset += 3; | 49 | 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 | |||
| 25 | ASSERT_MSG(offset <= block.size, "Offset is out of bounds in BKTR relocation block."); | 25 | ASSERT_MSG(offset <= block.size, "Offset is out of bounds in BKTR relocation block."); |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | const auto bucket_id = static_cast<std::size_t>(std::count_if( | 28 | std::size_t bucket_id = std::count_if( |
| 29 | block.base_offsets.begin() + 1, block.base_offsets.begin() + block.number_buckets, | 29 | block.base_offsets.begin() + 1, block.base_offsets.begin() + block.number_buckets, |
| 30 | [&offset](u64 base_offset) { return base_offset <= offset; })); | 30 | [&offset](u64 base_offset) { return base_offset <= offset; }); |
| 31 | 31 | ||
| 32 | const auto& bucket = buckets[bucket_id]; | 32 | const auto& bucket = buckets[bucket_id]; |
| 33 | 33 | ||
| @@ -53,7 +53,6 @@ std::pair<std::size_t, std::size_t> SearchBucketEntry(u64 offset, const BlockTyp | |||
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | UNREACHABLE_MSG("Offset could not be found in BKTR block."); | 55 | UNREACHABLE_MSG("Offset could not be found in BKTR block."); |
| 56 | return {}; | ||
| 57 | } | 56 | } |
| 58 | } // Anonymous namespace | 57 | } // Anonymous namespace |
| 59 | 58 | ||
| @@ -137,7 +136,7 @@ std::size_t BKTR::Read(u8* data, std::size_t length, std::size_t offset) const { | |||
| 137 | 136 | ||
| 138 | const auto block_offset = section_offset & 0xF; | 137 | const auto block_offset = section_offset & 0xF; |
| 139 | if (block_offset != 0) { | 138 | if (block_offset != 0) { |
| 140 | auto block = bktr_romfs->ReadBytes(0x10, section_offset & ~0xFU); | 139 | auto block = bktr_romfs->ReadBytes(0x10, section_offset & ~0xF); |
| 141 | cipher.Transcode(block.data(), block.size(), block.data(), Core::Crypto::Op::Decrypt); | 140 | cipher.Transcode(block.data(), block.size(), block.data(), Core::Crypto::Op::Decrypt); |
| 142 | if (length + block_offset < 0x10) { | 141 | if (length + block_offset < 0x10) { |
| 143 | std::memcpy(data, block.data() + block_offset, std::min(length, block.size())); | 142 | std::memcpy(data, block.data() + block_offset, std::min(length, block.size())); |