From e3a30ccc7c8a556224cb5608c9442b841f02117b Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 18 Jul 2018 20:21:25 -0400 Subject: [PATCH 1/3] loader/nso: Resolve sign mismatch warnings --- src/core/loader/nso.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp index 2beb85fbf..4ae9d55dd 100644 --- a/src/core/loader/nso.cpp +++ b/src/core/loader/nso.cpp @@ -113,7 +113,7 @@ VAddr AppLoader_NSO::LoadModule(FileSys::VirtualFile file, VAddr load_base) { // Build program image Kernel::SharedPtr codeset = Kernel::CodeSet::Create(""); std::vector program_image; - for (int i = 0; i < nso_header.segments.size(); ++i) { + for (std::size_t i = 0; i < nso_header.segments.size(); ++i) { const std::vector compressed_data = file->ReadBytes(nso_header.segments_compressed_size[i], nso_header.segments[i].offset); std::vector data = DecompressSegment(compressed_data, nso_header.segments[i]); From 1831b5ef62da69f45f6e677898c6b7be10ded804 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 18 Jul 2018 20:24:33 -0400 Subject: [PATCH 2/3] loader/nso: Remove unnecessary vector resizes We can just initialize these vectors directly via their constructor. --- src/core/loader/nso.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp index 4ae9d55dd..f7752e0e3 100644 --- a/src/core/loader/nso.cpp +++ b/src/core/loader/nso.cpp @@ -66,8 +66,7 @@ FileType AppLoader_NSO::IdentifyType(const FileSys::VirtualFile& file) { static std::vector DecompressSegment(const std::vector& compressed_data, const NsoSegmentHeader& header) { - std::vector uncompressed_data; - uncompressed_data.resize(header.size); + std::vector uncompressed_data(header.size); const int bytes_uncompressed = LZ4_decompress_safe( reinterpret_cast(compressed_data.data()), reinterpret_cast(uncompressed_data.data()), compressed_data.size(), header.size); @@ -80,8 +79,7 @@ static std::vector DecompressSegment(const std::vector& compressed_data, static std::vector ReadSegment(FileUtil::IOFile& file, const NsoSegmentHeader& header, size_t compressed_size) { - std::vector compressed_data; - compressed_data.resize(compressed_size); + std::vector compressed_data(compressed_size); file.Seek(header.offset, SEEK_SET); if (compressed_size != file.ReadBytes(compressed_data.data(), compressed_size)) { From 55ab3690435af91589284c3dcac5ef5c1fd944c8 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 18 Jul 2018 20:29:04 -0400 Subject: [PATCH 3/3] loader/nro: Resolve sign mismatch warnings --- src/core/loader/nro.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/loader/nro.cpp b/src/core/loader/nro.cpp index a007d3e6e..465b827bb 100644 --- a/src/core/loader/nro.cpp +++ b/src/core/loader/nro.cpp @@ -82,7 +82,7 @@ bool AppLoader_NRO::LoadNro(FileSys::VirtualFile file, VAddr load_base) { if (program_image.size() != PageAlignSize(nro_header.file_size)) return {}; - for (int i = 0; i < nro_header.segments.size(); ++i) { + for (std::size_t i = 0; i < nro_header.segments.size(); ++i) { codeset->segments[i].addr = nro_header.segments[i].offset; codeset->segments[i].offset = nro_header.segments[i].offset; codeset->segments[i].size = PageAlignSize(nro_header.segments[i].size);