Merge pull request #732 from lioncash/unused

nso: Minor changes
This commit is contained in:
bunnei 2018-07-20 09:14:10 -07:00 committed by GitHub
commit 86d1649b32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 17 deletions

View File

@ -69,29 +69,18 @@ FileType AppLoader_NSO::IdentifyType(const FileSys::VirtualFile& file) {
static std::vector<u8> DecompressSegment(const std::vector<u8>& compressed_data, static std::vector<u8> DecompressSegment(const std::vector<u8>& compressed_data,
const NsoSegmentHeader& header) { const NsoSegmentHeader& header) {
std::vector<u8> uncompressed_data(header.size); std::vector<u8> uncompressed_data(header.size);
const int bytes_uncompressed = LZ4_decompress_safe( const int bytes_uncompressed =
reinterpret_cast<const char*>(compressed_data.data()), LZ4_decompress_safe(reinterpret_cast<const char*>(compressed_data.data()),
reinterpret_cast<char*>(uncompressed_data.data()), compressed_data.size(), header.size); reinterpret_cast<char*>(uncompressed_data.data()),
static_cast<int>(compressed_data.size()), header.size);
ASSERT_MSG(bytes_uncompressed == header.size && bytes_uncompressed == uncompressed_data.size(), ASSERT_MSG(bytes_uncompressed == static_cast<int>(header.size) &&
bytes_uncompressed == static_cast<int>(uncompressed_data.size()),
"{} != {} != {}", bytes_uncompressed, header.size, uncompressed_data.size()); "{} != {} != {}", bytes_uncompressed, header.size, uncompressed_data.size());
return uncompressed_data; return uncompressed_data;
} }
static std::vector<u8> ReadSegment(FileUtil::IOFile& file, const NsoSegmentHeader& header,
size_t compressed_size) {
std::vector<u8> compressed_data(compressed_size);
file.Seek(header.offset, SEEK_SET);
if (compressed_size != file.ReadBytes(compressed_data.data(), compressed_size)) {
LOG_CRITICAL(Loader, "Failed to read {} NSO LZ4 compressed bytes", compressed_size);
return {};
}
return DecompressSegment(compressed_data, header);
}
static constexpr u32 PageAlignSize(u32 size) { static constexpr u32 PageAlignSize(u32 size) {
return (size + Memory::PAGE_MASK) & ~Memory::PAGE_MASK; return (size + Memory::PAGE_MASK) & ~Memory::PAGE_MASK;
} }