diff options
| author | 2018-07-23 17:24:27 -0400 | |
|---|---|---|
| committer | 2018-07-23 17:24:29 -0400 | |
| commit | 2b497e58306b98eddaf74a3a1fecc6fdd8b8c855 (patch) | |
| tree | ae3aff4ac8401c14df31e970d6cf4109ad710112 /src | |
| parent | nro: Make constructor explicit (diff) | |
| download | yuzu-2b497e58306b98eddaf74a3a1fecc6fdd8b8c855.tar.gz yuzu-2b497e58306b98eddaf74a3a1fecc6fdd8b8c855.tar.xz yuzu-2b497e58306b98eddaf74a3a1fecc6fdd8b8c855.zip | |
nro: Make bracing consistent
Makes the code more uniform, and also braces cases where the body of an
unbraced conditional travels more than one line.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/loader/nro.cpp | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/src/core/loader/nro.cpp b/src/core/loader/nro.cpp index 44158655c..f6f12c31c 100644 --- a/src/core/loader/nro.cpp +++ b/src/core/loader/nro.cpp | |||
| @@ -68,22 +68,27 @@ static_assert(sizeof(AssetHeader) == 0x38, "AssetHeader has incorrect size."); | |||
| 68 | 68 | ||
| 69 | AppLoader_NRO::AppLoader_NRO(FileSys::VirtualFile file) : AppLoader(file) { | 69 | AppLoader_NRO::AppLoader_NRO(FileSys::VirtualFile file) : AppLoader(file) { |
| 70 | NroHeader nro_header{}; | 70 | NroHeader nro_header{}; |
| 71 | if (file->ReadObject(&nro_header) != sizeof(NroHeader)) | 71 | if (file->ReadObject(&nro_header) != sizeof(NroHeader)) { |
| 72 | return; | 72 | return; |
| 73 | } | ||
| 73 | 74 | ||
| 74 | if (file->GetSize() >= nro_header.file_size + sizeof(AssetHeader)) { | 75 | if (file->GetSize() >= nro_header.file_size + sizeof(AssetHeader)) { |
| 75 | u64 offset = nro_header.file_size; | 76 | const u64 offset = nro_header.file_size; |
| 76 | AssetHeader asset_header{}; | 77 | AssetHeader asset_header{}; |
| 77 | if (file->ReadObject(&asset_header, offset) != sizeof(AssetHeader)) | 78 | if (file->ReadObject(&asset_header, offset) != sizeof(AssetHeader)) { |
| 78 | return; | 79 | return; |
| 80 | } | ||
| 79 | 81 | ||
| 80 | if (asset_header.format_version != 0) | 82 | if (asset_header.format_version != 0) { |
| 81 | LOG_WARNING(Loader, | 83 | LOG_WARNING(Loader, |
| 82 | "NRO Asset Header has format {}, currently supported format is 0. If " | 84 | "NRO Asset Header has format {}, currently supported format is 0. If " |
| 83 | "strange glitches occur with metadata, check NRO assets.", | 85 | "strange glitches occur with metadata, check NRO assets.", |
| 84 | asset_header.format_version); | 86 | asset_header.format_version); |
| 85 | if (asset_header.magic != Common::MakeMagic('A', 'S', 'E', 'T')) | 87 | } |
| 88 | |||
| 89 | if (asset_header.magic != Common::MakeMagic('A', 'S', 'E', 'T')) { | ||
| 86 | return; | 90 | return; |
| 91 | } | ||
| 87 | 92 | ||
| 88 | if (asset_header.nacp.size > 0) { | 93 | if (asset_header.nacp.size > 0) { |
| 89 | nacp = std::make_unique<FileSys::NACP>(std::make_shared<FileSys::OffsetVfsFile>( | 94 | nacp = std::make_unique<FileSys::NACP>(std::make_shared<FileSys::OffsetVfsFile>( |
| @@ -130,8 +135,9 @@ bool AppLoader_NRO::LoadNro(FileSys::VirtualFile file, VAddr load_base) { | |||
| 130 | // Build program image | 135 | // Build program image |
| 131 | Kernel::SharedPtr<Kernel::CodeSet> codeset = Kernel::CodeSet::Create(""); | 136 | Kernel::SharedPtr<Kernel::CodeSet> codeset = Kernel::CodeSet::Create(""); |
| 132 | std::vector<u8> program_image = file->ReadBytes(PageAlignSize(nro_header.file_size)); | 137 | std::vector<u8> program_image = file->ReadBytes(PageAlignSize(nro_header.file_size)); |
| 133 | if (program_image.size() != PageAlignSize(nro_header.file_size)) | 138 | if (program_image.size() != PageAlignSize(nro_header.file_size)) { |
| 134 | return {}; | 139 | return {}; |
| 140 | } | ||
| 135 | 141 | ||
| 136 | for (std::size_t i = 0; i < nro_header.segments.size(); ++i) { | 142 | for (std::size_t i = 0; i < nro_header.segments.size(); ++i) { |
| 137 | codeset->segments[i].addr = nro_header.segments[i].offset; | 143 | codeset->segments[i].addr = nro_header.segments[i].offset; |
| @@ -187,29 +193,37 @@ ResultStatus AppLoader_NRO::Load(Kernel::SharedPtr<Kernel::Process>& process) { | |||
| 187 | } | 193 | } |
| 188 | 194 | ||
| 189 | ResultStatus AppLoader_NRO::ReadIcon(std::vector<u8>& buffer) { | 195 | ResultStatus AppLoader_NRO::ReadIcon(std::vector<u8>& buffer) { |
| 190 | if (icon_data.empty()) | 196 | if (icon_data.empty()) { |
| 191 | return ResultStatus::ErrorNotUsed; | 197 | return ResultStatus::ErrorNotUsed; |
| 198 | } | ||
| 199 | |||
| 192 | buffer = icon_data; | 200 | buffer = icon_data; |
| 193 | return ResultStatus::Success; | 201 | return ResultStatus::Success; |
| 194 | } | 202 | } |
| 195 | 203 | ||
| 196 | ResultStatus AppLoader_NRO::ReadProgramId(u64& out_program_id) { | 204 | ResultStatus AppLoader_NRO::ReadProgramId(u64& out_program_id) { |
| 197 | if (nacp == nullptr) | 205 | if (nacp == nullptr) { |
| 198 | return ResultStatus::ErrorNotUsed; | 206 | return ResultStatus::ErrorNotUsed; |
| 207 | } | ||
| 208 | |||
| 199 | out_program_id = nacp->GetTitleId(); | 209 | out_program_id = nacp->GetTitleId(); |
| 200 | return ResultStatus::Success; | 210 | return ResultStatus::Success; |
| 201 | } | 211 | } |
| 202 | 212 | ||
| 203 | ResultStatus AppLoader_NRO::ReadRomFS(FileSys::VirtualFile& dir) { | 213 | ResultStatus AppLoader_NRO::ReadRomFS(FileSys::VirtualFile& dir) { |
| 204 | if (romfs == nullptr) | 214 | if (romfs == nullptr) { |
| 205 | return ResultStatus::ErrorNotUsed; | 215 | return ResultStatus::ErrorNotUsed; |
| 216 | } | ||
| 217 | |||
| 206 | dir = romfs; | 218 | dir = romfs; |
| 207 | return ResultStatus::Success; | 219 | return ResultStatus::Success; |
| 208 | } | 220 | } |
| 209 | 221 | ||
| 210 | ResultStatus AppLoader_NRO::ReadTitle(std::string& title) { | 222 | ResultStatus AppLoader_NRO::ReadTitle(std::string& title) { |
| 211 | if (nacp == nullptr) | 223 | if (nacp == nullptr) { |
| 212 | return ResultStatus::ErrorNotUsed; | 224 | return ResultStatus::ErrorNotUsed; |
| 225 | } | ||
| 226 | |||
| 213 | title = nacp->GetApplicationName(); | 227 | title = nacp->GetApplicationName(); |
| 214 | return ResultStatus::Success; | 228 | return ResultStatus::Success; |
| 215 | } | 229 | } |