Merge pull request #5817 from zhaowenlan1779/ncch-fix

Replace `&vec[0]` with `vec.data()`
master
Pengfei Zhu 2021-07-19 06:41:06 +07:00 committed by GitHub
commit 647a6f8d82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 6 deletions

@ -784,7 +784,7 @@ std::size_t ReadFileToString(bool text_file, const std::string& filename, std::s
return 0; return 0;
str.resize(static_cast<u32>(file.GetSize())); str.resize(static_cast<u32>(file.GetSize()));
return file.ReadArray(&str[0], str.size()); return file.ReadArray(str.data(), str.size());
} }
void SplitFilename83(const std::string& filename, std::array<char, 9>& short_name, void SplitFilename83(const std::string& filename, std::array<char, 9>& short_name,

@ -554,15 +554,16 @@ Loader::ResultStatus NCCHContainer::LoadSectionExeFS(const char* name, std::vect
// Decompress .code section... // Decompress .code section...
u32 decompressed_size = LZSS_GetDecompressedSize(&temp_buffer[0], section.size); u32 decompressed_size = LZSS_GetDecompressedSize(&temp_buffer[0], section.size);
buffer.resize(decompressed_size); buffer.resize(decompressed_size);
if (!LZSS_Decompress(&temp_buffer[0], section.size, &buffer[0], decompressed_size)) if (!LZSS_Decompress(&temp_buffer[0], section.size, buffer.data(),
decompressed_size))
return Loader::ResultStatus::ErrorInvalidFormat; return Loader::ResultStatus::ErrorInvalidFormat;
} else { } else {
// Section is uncompressed... // Section is uncompressed...
buffer.resize(section.size); buffer.resize(section.size);
if (exefs_file.ReadBytes(&buffer[0], section.size) != section.size) if (exefs_file.ReadBytes(buffer.data(), section.size) != section.size)
return Loader::ResultStatus::Error; return Loader::ResultStatus::Error;
if (is_encrypted) { if (is_encrypted) {
dec.ProcessData(&buffer[0], &buffer[0], section.size); dec.ProcessData(buffer.data(), buffer.data(), section.size);
} }
} }
@ -641,7 +642,7 @@ Loader::ResultStatus NCCHContainer::LoadOverrideExeFSSection(const char* name,
buffer.resize(section_size); buffer.resize(section_size);
section_file.Seek(0, SEEK_SET); section_file.Seek(0, SEEK_SET);
if (section_file.ReadBytes(&buffer[0], section_size) == section_size) { if (section_file.ReadBytes(buffer.data(), section_size) == section_size) {
LOG_WARNING(Service_FS, "File {} overriding built-in ExeFS file", path); LOG_WARNING(Service_FS, "File {} overriding built-in ExeFS file", path);
return Loader::ResultStatus::Success; return Loader::ResultStatus::Success;
} }

@ -342,7 +342,7 @@ ResultStatus AppLoader_THREEDSX::ReadIcon(std::vector<u8>& buffer) {
file.Seek(hdr.smdh_offset, SEEK_SET); file.Seek(hdr.smdh_offset, SEEK_SET);
buffer.resize(hdr.smdh_size); buffer.resize(hdr.smdh_size);
if (file.ReadBytes(&buffer[0], hdr.smdh_size) != hdr.smdh_size) if (file.ReadBytes(buffer.data(), hdr.smdh_size) != hdr.smdh_size)
return ResultStatus::Error; return ResultStatus::Error;
return ResultStatus::Success; return ResultStatus::Success;