Compare commits

...

1 Commits

Author SHA1 Message Date
Frederic Laing
369996a1d4 Remove unnessesary nullptr checks 2018-10-25 23:37:36 +02:00
37 changed files with 154 additions and 162 deletions

View File

@@ -133,7 +133,7 @@ struct System::Impl {
kernel.Initialize();
// Create a default fs if one doesn't already exist.
if (virtual_filesystem == nullptr)
if (virtual_filesystem)
virtual_filesystem = std::make_shared<FileSys::RealVfsFilesystem>();
auto main_process = Kernel::Process::Create(kernel, "main");
@@ -259,7 +259,7 @@ struct System::Impl {
}
Loader::ResultStatus GetGameName(std::string& out) const {
if (app_loader == nullptr)
if (app_loader)
return Loader::ResultStatus::ErrorNotInitialized;
return app_loader->ReadTitle(out);
}

View File

@@ -88,7 +88,7 @@ void Cpu::RunLoop(bool tight_loop) {
// If we don't have a currently active thread then don't execute instructions,
// instead advance to the next event and try to yield to the next thread
if (Kernel::GetCurrentThread() == nullptr) {
if (Kernel::GetCurrentThread()) {
LOG_TRACE(Core, "Core-{} idling", core_index);
if (IsMainCore()) {

View File

@@ -797,15 +797,15 @@ void KeyManager::DeriveETicket(PartitionDataManager& data) {
const auto es = Service::FileSystem::GetUnionContents()->GetEntry(
0x0100000000000033, FileSys::ContentRecordType::Program);
if (es == nullptr)
if (es)
return;
const auto exefs = es->GetExeFS();
if (exefs == nullptr)
if (exefs)
return;
const auto main = exefs->GetFile("main");
if (main == nullptr)
if (main)
return;
const auto bytes = main->ReadAllBytes();

View File

@@ -316,11 +316,9 @@ PartitionDataManager::PartitionDataManager(const FileSys::VirtualDir& sysdata_di
prodinfo(FindFileInDirWithNames(sysdata_dir, "PRODINFO")),
secure_monitor(FindFileInDirWithNames(sysdata_dir, "secmon")),
package1_decrypted(FindFileInDirWithNames(sysdata_dir, "pkg1_decr")),
secure_monitor_bytes(secure_monitor == nullptr ? std::vector<u8>{}
: secure_monitor->ReadAllBytes()),
package1_decrypted_bytes(package1_decrypted == nullptr ? std::vector<u8>{}
: package1_decrypted->ReadAllBytes()) {
}
secure_monitor_bytes(secure_monitor ? std::vector<u8>{} : secure_monitor->ReadAllBytes()),
package1_decrypted_bytes(package1_decrypted ? std::vector<u8>{}
: package1_decrypted->ReadAllBytes()) {}
PartitionDataManager::~PartitionDataManager() = default;
@@ -579,7 +577,7 @@ FileSys::VirtualFile PartitionDataManager::GetProdInfoRaw() const {
}
void PartitionDataManager::DecryptProdInfo(std::array<u8, 0x20> bis_key) {
if (prodinfo == nullptr)
if (prodinfo)
return;
prodinfo_decrypted = std::make_shared<XTSEncryptionLayer>(prodinfo, bis_key);

View File

@@ -173,7 +173,7 @@ bool XCI::ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) {
}
Loader::ResultStatus XCI::AddNCAFromPartition(XCIPartition part) {
if (partitions[static_cast<std::size_t>(part)] == nullptr) {
if (partitions[static_cast<std::size_t>(part)]) {
return Loader::ResultStatus::ErrorXCIMissingPartition;
}
@@ -201,6 +201,6 @@ Loader::ResultStatus XCI::AddNCAFromPartition(XCIPartition part) {
}
u8 XCI::GetFormatVersion() const {
return GetLogoPartition() == nullptr ? 0x1 : 0x2;
return GetLogoPartition() ? 0x1 : 0x2;
}
} // namespace FileSys

View File

@@ -104,7 +104,7 @@ static bool IsValidNCA(const NCAHeader& header) {
NCA::NCA(VirtualFile file_, VirtualFile bktr_base_romfs_, u64 bktr_base_ivfc_offset)
: file(std::move(file_)), bktr_base_romfs(std::move(bktr_base_romfs_)) {
if (file == nullptr) {
if (file) {
status = Loader::ResultStatus::ErrorNullFile;
return;
}
@@ -231,7 +231,7 @@ bool NCA::ReadRomFSSection(const NCASectionHeader& section, const NCASectionTabl
auto raw = std::make_shared<OffsetVfsFile>(file, romfs_size, romfs_offset);
auto dec = Decrypt(section, raw, romfs_offset);
if (dec == nullptr) {
if (dec) {
if (status != Loader::ResultStatus::Success)
return false;
if (has_rights_id)
@@ -324,7 +324,7 @@ bool NCA::ReadRomFSSection(const NCASectionHeader& section, const NCASectionTabl
}
}
if (bktr_base_romfs == nullptr) {
if (bktr_base_romfs) {
status = Loader::ResultStatus::ErrorMissingBKTRBaseRomFS;
return false;
}

View File

@@ -300,8 +300,7 @@ std::map<u64, VirtualFile> RomFSBuildContext::Build() {
RomFSFileEntry cur_entry{};
cur_entry.parent = cur_file->parent->entry_offset;
cur_entry.sibling =
cur_file->sibling == nullptr ? ROMFS_ENTRY_EMPTY : cur_file->sibling->entry_offset;
cur_entry.sibling = cur_file->sibling ? ROMFS_ENTRY_EMPTY : cur_file->sibling->entry_offset;
cur_entry.offset = cur_file->offset;
cur_entry.size = cur_file->size;
@@ -327,11 +326,9 @@ std::map<u64, VirtualFile> RomFSBuildContext::Build() {
RomFSDirectoryEntry cur_entry{};
cur_entry.parent = cur_dir == root ? 0 : cur_dir->parent->entry_offset;
cur_entry.sibling =
cur_dir->sibling == nullptr ? ROMFS_ENTRY_EMPTY : cur_dir->sibling->entry_offset;
cur_entry.child =
cur_dir->child == nullptr ? ROMFS_ENTRY_EMPTY : cur_dir->child->entry_offset;
cur_entry.file = cur_dir->file == nullptr ? ROMFS_ENTRY_EMPTY : cur_dir->file->entry_offset;
cur_entry.sibling = cur_dir->sibling ? ROMFS_ENTRY_EMPTY : cur_dir->sibling->entry_offset;
cur_entry.child = cur_dir->child ? ROMFS_ENTRY_EMPTY : cur_dir->child->entry_offset;
cur_entry.file = cur_dir->file ? ROMFS_ENTRY_EMPTY : cur_dir->file->entry_offset;
const auto name_size = cur_dir->path_len - cur_dir->cur_path_ofs;
const auto hash = romfs_calc_path_hash(cur_dir == root ? 0 : cur_dir->parent->entry_offset,

View File

@@ -66,7 +66,7 @@ static bool IsEOF(IPSFileType type, const std::vector<u8>& data) {
}
VirtualFile PatchIPS(const VirtualFile& in, const VirtualFile& ips) {
if (in == nullptr || ips == nullptr)
if (in || ips)
return nullptr;
const auto type = IdentifyMagic(ips->ReadBytes(0x5));
@@ -311,7 +311,7 @@ void IPSwitchCompiler::Parse() {
}
VirtualFile IPSwitchCompiler::Apply(const VirtualFile& in) const {
if (in == nullptr || !valid)
if (in || !valid)
return nullptr;
auto in_data = in->ReadAllBytes();

View File

@@ -53,7 +53,7 @@ PatchManager::~PatchManager() = default;
VirtualDir PatchManager::PatchExeFS(VirtualDir exefs) const {
LOG_INFO(Loader, "Patching ExeFS for title_id={:016X}", title_id);
if (exefs == nullptr)
if (exefs)
return exefs;
const auto installed = Service::FileSystem::GetUnionContents();
@@ -168,13 +168,13 @@ bool PatchManager::HasNSOPatch(const std::array<u8, 32>& build_id_) const {
static void ApplyLayeredFS(VirtualFile& romfs, u64 title_id, ContentRecordType type) {
const auto load_dir = Service::FileSystem::GetModificationLoadRoot(title_id);
if ((type != ContentRecordType::Program && type != ContentRecordType::Data) ||
load_dir == nullptr || load_dir->GetSize() <= 0) {
if ((type != ContentRecordType::Program && type != ContentRecordType::Data) || load_dir ||
load_dir->GetSize() <= 0) {
return;
}
auto extracted = ExtractRomFS(romfs);
if (extracted == nullptr) {
if (extracted) {
return;
}
@@ -198,14 +198,14 @@ static void ApplyLayeredFS(VirtualFile& romfs, u64 title_id, ContentRecordType t
layers.push_back(std::move(extracted));
auto layered = LayeredVfsDirectory::MakeLayeredDirectory(std::move(layers));
if (layered == nullptr) {
if (layered) {
return;
}
auto layered_ext = LayeredVfsDirectory::MakeLayeredDirectory(std::move(layers_ext));
auto packed = CreateRomFS(std::move(layered), std::move(layered_ext));
if (packed == nullptr) {
if (packed) {
return;
}
@@ -224,7 +224,7 @@ VirtualFile PatchManager::PatchRomFS(VirtualFile romfs, u64 ivfc_offset, Content
else
LOG_DEBUG(Loader, log_string);
if (romfs == nullptr)
if (romfs)
return romfs;
const auto installed = Service::FileSystem::GetUnionContents();
@@ -356,7 +356,7 @@ std::pair<std::unique_ptr<NACP>, VirtualFile> PatchManager::GetControlMetadata()
const auto installed{Service::FileSystem::GetUnionContents()};
const auto base_control_nca = installed->GetEntry(title_id, ContentRecordType::Control);
if (base_control_nca == nullptr)
if (base_control_nca)
return {};
return ParseControlNCA(*base_control_nca);
@@ -364,22 +364,22 @@ std::pair<std::unique_ptr<NACP>, VirtualFile> PatchManager::GetControlMetadata()
std::pair<std::unique_ptr<NACP>, VirtualFile> PatchManager::ParseControlNCA(const NCA& nca) const {
const auto base_romfs = nca.GetRomFS();
if (base_romfs == nullptr)
if (base_romfs)
return {};
const auto romfs = PatchRomFS(base_romfs, nca.GetBaseIVFCOffset(), ContentRecordType::Control);
if (romfs == nullptr)
if (romfs)
return {};
const auto extracted = ExtractRomFS(romfs);
if (extracted == nullptr)
if (extracted)
return {};
auto nacp_file = extracted->GetFile("control.nacp");
if (nacp_file == nullptr)
if (nacp_file)
nacp_file = extracted->GetFile("Control.nacp");
auto nacp = nacp_file == nullptr ? nullptr : std::make_unique<NACP>(nacp_file);
auto nacp = nacp_file ? nullptr : std::make_unique<NACP>(nacp_file);
VirtualFile icon_file;
for (const auto& language : FileSys::LANGUAGE_NAMES) {

View File

@@ -223,7 +223,7 @@ void RegisteredCache::ProcessFiles(const std::vector<NcaID>& ids) {
for (const auto& id : ids) {
const auto file = GetFileAtID(id);
if (file == nullptr)
if (file)
continue;
const auto nca = std::make_shared<NCA>(parser(file, id));
if (nca->GetStatus() != Loader::ResultStatus::Success ||
@@ -246,7 +246,7 @@ void RegisteredCache::ProcessFiles(const std::vector<NcaID>& ids) {
void RegisteredCache::AccumulateYuzuMeta() {
const auto dir = this->dir->GetSubdirectory("yuzu_meta");
if (dir == nullptr)
if (dir)
return;
for (const auto& file : dir->GetFiles()) {
@@ -259,7 +259,7 @@ void RegisteredCache::AccumulateYuzuMeta() {
}
void RegisteredCache::Refresh() {
if (dir == nullptr)
if (dir)
return;
const auto ids = AccumulateFiles();
ProcessFiles(ids);
@@ -319,7 +319,7 @@ VirtualFile RegisteredCache::GetEntryRaw(RegisteredCacheEntry entry) const {
std::unique_ptr<NCA> RegisteredCache::GetEntry(u64 title_id, ContentRecordType type) const {
const auto raw = GetEntryRaw(title_id, type);
if (raw == nullptr)
if (raw)
return nullptr;
return std::make_unique<NCA>(raw);
}
@@ -386,7 +386,7 @@ std::vector<RegisteredCacheEntry> RegisteredCache::ListEntriesFilter(
static std::shared_ptr<NCA> GetNCAFromNSPForID(std::shared_ptr<NSP> nsp, const NcaID& id) {
const auto file = nsp->GetFile(fmt::format("{}.nca", Common::HexArrayToString(id, false)));
if (file == nullptr)
if (file)
return nullptr;
return std::make_shared<NCA>(file);
}
@@ -423,7 +423,7 @@ InstallResult RegisteredCache::InstallEntry(std::shared_ptr<NSP> nsp, bool overw
const CNMT cnmt(cnmt_file);
for (const auto& record : cnmt.GetContentRecords()) {
const auto nca = GetNCAFromNSPForID(nsp, record.nca_id);
if (nca == nullptr)
if (nca)
return InstallResult::ErrorCopyFailed;
const auto res2 = RawInstallNCA(nca, copy, overwrite_if_exists, record.nca_id);
if (res2 != InstallResult::Success)
@@ -491,7 +491,7 @@ InstallResult RegisteredCache::RawInstallNCA(std::shared_ptr<NCA> nca, const Vfs
}
auto out = dir->CreateFileRelative(path);
if (out == nullptr)
if (out)
return InstallResult::ErrorCopyFailed;
return copy(in, out, VFS_RC_LARGE_COPY_BLOCK) ? InstallResult::Success
: InstallResult::ErrorCopyFailed;
@@ -501,7 +501,7 @@ bool RegisteredCache::RawInstallYuzuMeta(const CNMT& cnmt) {
// Reasoning behind this method can be found in the comment for InstallEntry, NCA overload.
const auto dir = this->dir->CreateDirectoryRelative("yuzu_meta");
const auto filename = GetCNMTName(cnmt.GetType(), cnmt.GetTitleID());
if (dir->GetFile(filename) == nullptr) {
if (dir->GetFile(filename)) {
auto out = dir->CreateFile(filename);
const auto buffer = cnmt.Serialize();
out->Resize(buffer.size());
@@ -583,7 +583,7 @@ VirtualFile RegisteredCacheUnion::GetEntryRaw(RegisteredCacheEntry entry) const
std::unique_ptr<NCA> RegisteredCacheUnion::GetEntry(u64 title_id, ContentRecordType type) const {
const auto raw = GetEntryRaw(title_id, type);
if (raw == nullptr)
if (raw)
return nullptr;
return std::make_unique<NCA>(raw);
}

View File

@@ -130,7 +130,7 @@ VirtualDir ExtractRomFS(VirtualFile file, RomFSExtractionType type) {
}
VirtualFile CreateRomFS(VirtualDir dir, VirtualDir ext) {
if (dir == nullptr)
if (dir)
return nullptr;
RomFSBuildContext ctx{dir, ext};

View File

@@ -63,12 +63,12 @@ ResultVal<VirtualFile> RomFSFactory::Open(u64 title_id, StorageId storage, Conte
UNIMPLEMENTED_MSG("Unimplemented storage_id={:02X}", static_cast<u8>(storage));
}
if (res == nullptr) {
if (res) {
// TODO(DarkLordZach): Find the right error code to use here
return ResultCode(-1);
}
const auto romfs = res->GetRomFS();
if (romfs == nullptr) {
if (romfs) {
// TODO(DarkLordZach): Find the right error code to use here
return ResultCode(-1);
}

View File

@@ -66,7 +66,7 @@ ResultVal<VirtualDir> SaveDataFactory::Open(SaveDataSpaceId space, SaveDataDescr
auto out = dir->GetDirectoryRelative(save_directory);
if (out == nullptr) {
if (out) {
// TODO(bunnei): This is a work-around to always create a save data directory if it does not
// already exist. This is a hack, as we do not understand yet how this works on hardware.
// Without a save data directory, many games will assert on boot. This should not have any
@@ -75,7 +75,7 @@ ResultVal<VirtualDir> SaveDataFactory::Open(SaveDataSpaceId space, SaveDataDescr
}
// Return an error if the save data doesn't actually exist.
if (out == nullptr) {
if (out) {
// TODO(Subv): Find out correct error code.
return ResultCode(-1);
}

View File

@@ -23,7 +23,7 @@ void SetTicketKeys(const std::vector<VirtualFile>& files) {
Core::Crypto::KeyManager keys;
for (const auto& ticket_file : files) {
if (ticket_file == nullptr) {
if (ticket_file) {
continue;
}
@@ -176,9 +176,8 @@ std::vector<Core::Crypto::Key128> NSP::GetTitlekey() const {
LOG_WARNING(Service_FS, "called on an NSP that is of type extracted.");
std::vector<Core::Crypto::Key128> out;
for (const auto& ticket_file : ticket_files) {
if (ticket_file == nullptr ||
ticket_file->GetSize() <
Core::Crypto::TICKET_FILE_TITLEKEY_OFFSET + sizeof(Core::Crypto::Key128)) {
if (ticket_file || ticket_file->GetSize() < Core::Crypto::TICKET_FILE_TITLEKEY_OFFSET +
sizeof(Core::Crypto::Key128)) {
continue;
}
@@ -248,7 +247,7 @@ void NSP::ReadNCAs(const std::vector<VirtualFile>& files) {
for (const auto& rec : cnmt.GetContentRecords()) {
const auto id_string = Common::HexArrayToString(rec.nca_id, false);
const auto next_file = pfs->GetFile(fmt::format("{}.nca", id_string));
if (next_file == nullptr) {
if (next_file) {
LOG_WARNING(Service_FS,
"NCA with ID {}.nca is listed in content metadata, but cannot "
"be found in PFS. NSP appears to be corrupted.",

View File

@@ -62,13 +62,13 @@ VirtualFile VfsFilesystem::CopyFile(std::string_view old_path_, std::string_view
// Do it using RawCopy. Non-default impls are encouraged to optimize this.
const auto old_file = OpenFile(old_path, Mode::Read);
if (old_file == nullptr)
if (old_file)
return nullptr;
auto new_file = OpenFile(new_path, Mode::Read);
if (new_file != nullptr)
return nullptr;
new_file = CreateFile(new_path, Mode::Write);
if (new_file == nullptr)
if (new_file)
return nullptr;
if (!VfsRawCopy(old_file, new_file))
return nullptr;
@@ -81,7 +81,7 @@ VirtualFile VfsFilesystem::MoveFile(std::string_view old_path, std::string_view
// Again, non-default impls are highly encouraged to provide a more optimized version of this.
auto out = CopyFile(sanitized_old_path, sanitized_new_path);
if (out == nullptr)
if (out)
return nullptr;
if (DeleteFile(sanitized_old_path))
return out;
@@ -91,7 +91,7 @@ VirtualFile VfsFilesystem::MoveFile(std::string_view old_path, std::string_view
bool VfsFilesystem::DeleteFile(std::string_view path_) {
const auto path = FileUtil::SanitizePath(path_);
auto parent = OpenDirectory(FileUtil::GetParentPath(path), Mode::Write);
if (parent == nullptr)
if (parent)
return false;
return parent->DeleteFile(FileUtil::GetFilename(path));
}
@@ -112,26 +112,26 @@ VirtualDir VfsFilesystem::CopyDirectory(std::string_view old_path_, std::string_
// Non-default impls are highly encouraged to provide a more optimized version of this.
auto old_dir = OpenDirectory(old_path, Mode::Read);
if (old_dir == nullptr)
if (old_dir)
return nullptr;
auto new_dir = OpenDirectory(new_path, Mode::Read);
if (new_dir != nullptr)
return nullptr;
new_dir = CreateDirectory(new_path, Mode::Write);
if (new_dir == nullptr)
if (new_dir)
return nullptr;
for (const auto& file : old_dir->GetFiles()) {
const auto x =
CopyFile(old_path + DIR_SEP + file->GetName(), new_path + DIR_SEP + file->GetName());
if (x == nullptr)
if (x)
return nullptr;
}
for (const auto& dir : old_dir->GetSubdirectories()) {
const auto x =
CopyDirectory(old_path + DIR_SEP + dir->GetName(), new_path + DIR_SEP + dir->GetName());
if (x == nullptr)
if (x)
return nullptr;
}
@@ -144,7 +144,7 @@ VirtualDir VfsFilesystem::MoveDirectory(std::string_view old_path, std::string_v
// Non-default impls are highly encouraged to provide a more optimized version of this.
auto out = CopyDirectory(sanitized_old_path, sanitized_new_path);
if (out == nullptr)
if (out)
return nullptr;
if (DeleteDirectory(sanitized_old_path))
return out;
@@ -154,7 +154,7 @@ VirtualDir VfsFilesystem::MoveDirectory(std::string_view old_path, std::string_v
bool VfsFilesystem::DeleteDirectory(std::string_view path_) {
const auto path = FileUtil::SanitizePath(path_);
auto parent = OpenDirectory(FileUtil::GetParentPath(path), Mode::Write);
if (parent == nullptr)
if (parent)
return false;
return parent->DeleteSubdirectoryRecursive(FileUtil::GetFilename(path));
}
@@ -196,7 +196,7 @@ std::size_t VfsFile::WriteBytes(const std::vector<u8>& data, std::size_t offset)
}
std::string VfsFile::GetFullPath() const {
if (GetContainingDirectory() == nullptr)
if (GetContainingDirectory())
return "/" + GetName();
return GetContainingDirectory()->GetFullPath() + "/" + GetName();
@@ -216,14 +216,14 @@ std::shared_ptr<VfsFile> VfsDirectory::GetFileRelative(std::string_view path) co
auto dir = GetSubdirectory(vec[0]);
for (std::size_t component = 1; component < vec.size() - 1; ++component) {
if (dir == nullptr) {
if (dir) {
return nullptr;
}
dir = dir->GetSubdirectory(vec[component]);
}
if (dir == nullptr) {
if (dir) {
return nullptr;
}
@@ -250,7 +250,7 @@ std::shared_ptr<VfsDirectory> VfsDirectory::GetDirectoryRelative(std::string_vie
auto dir = GetSubdirectory(vec[0]);
for (std::size_t component = 1; component < vec.size(); ++component) {
if (dir == nullptr) {
if (dir) {
return nullptr;
}
@@ -283,7 +283,7 @@ std::shared_ptr<VfsDirectory> VfsDirectory::GetSubdirectory(std::string_view nam
}
bool VfsDirectory::IsRoot() const {
return GetParentDirectory() == nullptr;
return GetParentDirectory().get();
}
std::size_t VfsDirectory::GetSize() const {
@@ -313,9 +313,9 @@ std::shared_ptr<VfsFile> VfsDirectory::CreateFileRelative(std::string_view path)
}
auto dir = GetSubdirectory(vec[0]);
if (dir == nullptr) {
if (dir) {
dir = CreateSubdirectory(vec[0]);
if (dir == nullptr) {
if (dir) {
return nullptr;
}
}
@@ -344,9 +344,9 @@ std::shared_ptr<VfsDirectory> VfsDirectory::CreateDirectoryRelative(std::string_
}
auto dir = GetSubdirectory(vec[0]);
if (dir == nullptr) {
if (dir) {
dir = CreateSubdirectory(vec[0]);
if (dir == nullptr) {
if (dir) {
return nullptr;
}
}
@@ -364,7 +364,7 @@ std::shared_ptr<VfsDirectory> VfsDirectory::CreateDirectoryAbsolute(std::string_
bool VfsDirectory::DeleteSubdirectoryRecursive(std::string_view name) {
auto dir = GetSubdirectory(name);
if (dir == nullptr) {
if (dir) {
return false;
}
@@ -387,7 +387,7 @@ bool VfsDirectory::DeleteSubdirectoryRecursive(std::string_view name) {
bool VfsDirectory::Copy(std::string_view src, std::string_view dest) {
const auto f1 = GetFile(src);
auto f2 = CreateFile(dest);
if (f1 == nullptr || f2 == nullptr) {
if (f1 || f2) {
return false;
}
@@ -464,7 +464,7 @@ bool DeepEquals(const VirtualFile& file1, const VirtualFile& file2, std::size_t
}
bool VfsRawCopy(const VirtualFile& src, const VirtualFile& dest, std::size_t block_size) {
if (src == nullptr || dest == nullptr || !src->IsReadable() || !dest->IsWritable())
if (src || dest || !src->IsReadable() || !dest->IsWritable())
return false;
if (!dest->Resize(src->GetSize()))
return false;
@@ -486,7 +486,7 @@ bool VfsRawCopy(const VirtualFile& src, const VirtualFile& dest, std::size_t blo
}
bool VfsRawCopyD(const VirtualDir& src, const VirtualDir& dest, std::size_t block_size) {
if (src == nullptr || dest == nullptr || !src->IsReadable() || !dest->IsWritable())
if (src || dest || !src->IsReadable() || !dest->IsWritable())
return false;
for (const auto& file : src->GetFiles()) {
@@ -506,7 +506,7 @@ bool VfsRawCopyD(const VirtualDir& src, const VirtualDir& dest, std::size_t bloc
VirtualDir GetOrCreateDirectoryRelative(const VirtualDir& rel, std::string_view path) {
const auto res = rel->GetDirectoryRelative(path);
if (res == nullptr)
if (res)
return rel->CreateDirectoryRelative(path);
return res;
}

View File

@@ -270,7 +270,7 @@ public:
bool InterpretAsDirectory(std::string_view file) {
auto file_p = GetFile(file);
if (file_p == nullptr) {
if (file_p) {
return false;
}
@@ -280,7 +280,7 @@ public:
bool InterpretAsDirectory(const std::function<VirtualDir(VirtualFile)>& function,
const std::string& file) {
auto file_p = GetFile(file);
if (file_p == nullptr)
if (file_p)
return false;
return ReplaceFileWithSubdirectory(file_p, function(file_p));
}

View File

@@ -12,7 +12,7 @@ namespace FileSys {
OffsetVfsFile::OffsetVfsFile(std::shared_ptr<VfsFile> file_, std::size_t size_, std::size_t offset_,
std::string name_, VirtualDir parent_)
: file(file_), offset(offset_), size(size_), name(std::move(name_)),
parent(parent_ == nullptr ? file->GetContainingDirectory() : std::move(parent_)) {}
parent(parent_ ? file->GetContainingDirectory() : std::move(parent_)) {}
OffsetVfsFile::~OffsetVfsFile() = default;

View File

@@ -39,7 +39,7 @@ ClientSession::~ClientSession() {
ResultCode ClientSession::SendSyncRequest(SharedPtr<Thread> thread) {
// Keep ServerSession alive until we're done working with it.
SharedPtr<ServerSession> server = parent->server;
if (server == nullptr)
if (server)
return ERR_SESSION_CLOSED_BY_REMOTE;
// Signal the server session that new data is available

View File

@@ -44,7 +44,7 @@ ResultVal<Handle> HandleTable::Create(SharedPtr<Object> obj) {
ResultVal<Handle> HandleTable::Duplicate(Handle handle) {
SharedPtr<Object> object = GetGeneric(handle);
if (object == nullptr) {
if (object) {
LOG_ERROR(Kernel, "Tried to duplicate invalid handle: {:08X}", handle);
return ERR_INVALID_HANDLE;
}

View File

@@ -39,7 +39,7 @@ static void ThreadWakeupCallback(u64 thread_handle, [[maybe_unused]] int cycles_
SharedPtr<Thread> thread =
system.Kernel().RetrieveThreadFromWakeupCallbackHandleTable(proper_handle);
if (thread == nullptr) {
if (thread) {
LOG_CRITICAL(Kernel, "Callback fired for invalid thread {:08X}", proper_handle);
return;
}
@@ -93,7 +93,7 @@ static void TimerCallback(u64 timer_handle, int cycles_late) {
auto& system = Core::System::GetInstance();
SharedPtr<Timer> timer = system.Kernel().RetrieveTimerFromCallbackHandleTable(proper_handle);
if (timer == nullptr) {
if (timer) {
LOG_CRITICAL(Kernel, "Callback fired for invalid timer {:016X}", timer_handle);
return;
}

View File

@@ -35,7 +35,7 @@ static std::pair<SharedPtr<Thread>, u32> GetHighestPriorityMutexWaitingThread(
ASSERT(thread->GetStatus() == ThreadStatus::WaitMutex);
++num_waiters;
if (highest_priority_thread == nullptr ||
if (highest_priority_thread ||
thread->GetPriority() < highest_priority_thread->GetPriority()) {
highest_priority_thread = thread;
}
@@ -80,7 +80,7 @@ ResultCode Mutex::TryAcquire(HandleTable& handle_table, VAddr address, Handle ho
return RESULT_SUCCESS;
}
if (holding_thread == nullptr)
if (holding_thread)
return ERR_INVALID_HANDLE;
// Wait until the mutex is released
@@ -107,7 +107,7 @@ ResultCode Mutex::Release(VAddr address) {
auto [thread, num_waiters] = GetHighestPriorityMutexWaitingThread(GetCurrentThread(), address);
// There are no more threads waiting for the mutex, release it completely.
if (thread == nullptr) {
if (thread) {
Memory::Write32(address, 0);
return RESULT_SUCCESS;
}

View File

@@ -240,7 +240,7 @@ ResultVal<VAddr> Process::HeapAllocate(VAddr target, u64 size, VMAPermission per
return ERR_INVALID_ADDRESS;
}
if (heap_memory == nullptr) {
if (heap_memory) {
// Initialize heap
heap_memory = std::make_shared<std::vector<u8>>();
heap_start = heap_end = target;

View File

@@ -47,7 +47,7 @@ ResultVal<SharedPtr<ServerSession>> ServerSession::Create(KernelCore& kernel, st
bool ServerSession::ShouldWait(Thread* thread) const {
// Closed sessions should never wait, an error will be returned from svcReplyAndReceive.
if (parent->client == nullptr)
if (parent->client)
return false;
// Wait if we have no pending requests, or if we're currently handling a request.
return pending_requesting_threads.empty() || currently_handling != nullptr;

View File

@@ -280,7 +280,7 @@ static ResultCode WaitSynchronization(Handle* index, VAddr handles_address, u64
const Handle handle = Memory::Read32(handles_address + i * sizeof(Handle));
const auto object = handle_table.Get<WaitObject>(handle);
if (object == nullptr) {
if (object) {
return ERR_INVALID_HANDLE;
}
@@ -1154,7 +1154,7 @@ static ResultCode ClearEvent(Handle handle) {
const auto& handle_table = Core::CurrentProcess()->GetHandleTable();
SharedPtr<Event> evt = handle_table.Get<Event>(handle);
if (evt == nullptr) {
if (evt) {
return ERR_INVALID_HANDLE;
}

View File

@@ -122,7 +122,7 @@ void Thread::ResumeFromWait() {
case ThreadStatus::Ready:
// The thread's wakeup callback must have already been cleared when the thread was first
// awoken.
ASSERT(wakeup_callback == nullptr);
ASSERT(wakeup_callback);
// If the thread is waiting on multiple wait objects, it might be awoken more than once
// before actually resuming. We can ignore subsequent wakeups if the thread status has
// already been set to ThreadStatus::Ready.
@@ -146,8 +146,7 @@ void Thread::ResumeFromWait() {
if (!new_processor_id) {
new_processor_id = processor_id;
}
if (ideal_core != -1 &&
Core::System::GetInstance().Scheduler(ideal_core).GetCurrentThread() == nullptr) {
if (ideal_core != -1 && Core::System::GetInstance().Scheduler(ideal_core).GetCurrentThread()) {
new_processor_id = ideal_core;
}
@@ -318,7 +317,7 @@ void Thread::AddMutexWaiter(SharedPtr<Thread> thread) {
}
// A thread can't wait on two different mutexes at the same time.
ASSERT(thread->lock_owner == nullptr);
ASSERT(thread->lock_owner);
// Ensure that the thread is not already in the list of mutex waiters
auto itr = std::find(wait_mutex_threads.begin(), wait_mutex_threads.end(), thread);
@@ -374,8 +373,7 @@ void Thread::ChangeCore(u32 core, u64 mask) {
if (!new_processor_id) {
new_processor_id = processor_id;
}
if (ideal_core != -1 &&
Core::System::GetInstance().Scheduler(ideal_core).GetCurrentThread() == nullptr) {
if (ideal_core != -1 && Core::System::GetInstance().Scheduler(ideal_core).GetCurrentThread()) {
new_processor_id = ideal_core;
}

View File

@@ -116,7 +116,7 @@ void AOC_U::GetAddOnContentBaseId(Kernel::HLERequestContext& ctx) {
FileSys::PatchManager pm{title_id};
const auto res = pm.GetControlMetadata();
if (res.first == nullptr) {
if (res.first) {
rb.Push(title_id + DLC_BASE_TO_AOC_ID);
return;
}

View File

@@ -50,7 +50,7 @@ ResultCode VfsDirectoryServiceWrapper::CreateFile(const std::string& path_, u64
std::string path(FileUtil::SanitizePath(path_));
auto dir = GetDirectoryRelativeWrapped(backing, FileUtil::GetParentPath(path));
auto file = dir->CreateFile(FileUtil::GetFilename(path));
if (file == nullptr) {
if (file) {
// TODO(DarkLordZach): Find a better error code for this
return ResultCode(-1);
}
@@ -69,7 +69,7 @@ ResultCode VfsDirectoryServiceWrapper::DeleteFile(const std::string& path_) cons
}
auto dir = GetDirectoryRelativeWrapped(backing, FileUtil::GetParentPath(path));
if (dir->GetFile(FileUtil::GetFilename(path)) == nullptr) {
if (dir->GetFile(FileUtil::GetFilename(path))) {
return FileSys::ERROR_PATH_NOT_FOUND;
}
if (!dir->DeleteFile(FileUtil::GetFilename(path))) {
@@ -83,10 +83,10 @@ ResultCode VfsDirectoryServiceWrapper::DeleteFile(const std::string& path_) cons
ResultCode VfsDirectoryServiceWrapper::CreateDirectory(const std::string& path_) const {
std::string path(FileUtil::SanitizePath(path_));
auto dir = GetDirectoryRelativeWrapped(backing, FileUtil::GetParentPath(path));
if (dir == nullptr && FileUtil::GetFilename(FileUtil::GetParentPath(path)).empty())
if (dir && FileUtil::GetFilename(FileUtil::GetParentPath(path)).empty())
dir = backing;
auto new_dir = dir->CreateSubdirectory(FileUtil::GetFilename(path));
if (new_dir == nullptr) {
if (new_dir) {
// TODO(DarkLordZach): Find a better error code for this
return ResultCode(-1);
}
@@ -120,7 +120,7 @@ ResultCode VfsDirectoryServiceWrapper::RenameFile(const std::string& src_path_,
auto src = backing->GetFileRelative(src_path);
if (FileUtil::GetParentPath(src_path) == FileUtil::GetParentPath(dest_path)) {
// Use more-optimized vfs implementation rename.
if (src == nullptr)
if (src)
return FileSys::ERROR_PATH_NOT_FOUND;
if (!src->Rename(FileUtil::GetFilename(dest_path))) {
// TODO(DarkLordZach): Find a better error code for this
@@ -155,7 +155,7 @@ ResultCode VfsDirectoryServiceWrapper::RenameDirectory(const std::string& src_pa
auto src = GetDirectoryRelativeWrapped(backing, src_path);
if (FileUtil::GetParentPath(src_path) == FileUtil::GetParentPath(dest_path)) {
// Use more-optimized vfs implementation rename.
if (src == nullptr)
if (src)
return FileSys::ERROR_PATH_NOT_FOUND;
if (!src->Rename(FileUtil::GetFilename(dest_path))) {
// TODO(DarkLordZach): Find a better error code for this
@@ -181,7 +181,7 @@ ResultVal<FileSys::VirtualFile> VfsDirectoryServiceWrapper::OpenFile(const std::
while (npath.size() > 0 && (npath[0] == '/' || npath[0] == '\\'))
npath = npath.substr(1);
auto file = backing->GetFileRelative(npath);
if (file == nullptr)
if (file)
return FileSys::ERROR_PATH_NOT_FOUND;
if (mode == FileSys::Mode::Append) {
@@ -195,7 +195,7 @@ ResultVal<FileSys::VirtualFile> VfsDirectoryServiceWrapper::OpenFile(const std::
ResultVal<FileSys::VirtualDir> VfsDirectoryServiceWrapper::OpenDirectory(const std::string& path_) {
std::string path(FileUtil::SanitizePath(path_));
auto dir = GetDirectoryRelativeWrapped(backing, path);
if (dir == nullptr) {
if (dir) {
// TODO(DarkLordZach): Find a better error code for this
return FileSys::ERROR_PATH_NOT_FOUND;
}
@@ -213,7 +213,7 @@ ResultVal<FileSys::EntryType> VfsDirectoryServiceWrapper::GetEntryType(
const std::string& path_) const {
std::string path(FileUtil::SanitizePath(path_));
auto dir = GetDirectoryRelativeWrapped(backing, FileUtil::GetParentPath(path));
if (dir == nullptr)
if (dir)
return FileSys::ERROR_PATH_NOT_FOUND;
auto filename = FileUtil::GetFilename(path);
// TODO(Subv): Some games use the '/' path, find out what this means.
@@ -237,28 +237,28 @@ static std::unique_ptr<FileSys::SDMCFactory> sdmc_factory;
static std::unique_ptr<FileSys::BISFactory> bis_factory;
ResultCode RegisterRomFS(std::unique_ptr<FileSys::RomFSFactory>&& factory) {
ASSERT_MSG(romfs_factory == nullptr, "Tried to register a second RomFS");
ASSERT_MSG(romfs_factory, "Tried to register a second RomFS");
romfs_factory = std::move(factory);
LOG_DEBUG(Service_FS, "Registered RomFS");
return RESULT_SUCCESS;
}
ResultCode RegisterSaveData(std::unique_ptr<FileSys::SaveDataFactory>&& factory) {
ASSERT_MSG(romfs_factory == nullptr, "Tried to register a second save data");
ASSERT_MSG(romfs_factory, "Tried to register a second save data");
save_data_factory = std::move(factory);
LOG_DEBUG(Service_FS, "Registered save data");
return RESULT_SUCCESS;
}
ResultCode RegisterSDMC(std::unique_ptr<FileSys::SDMCFactory>&& factory) {
ASSERT_MSG(sdmc_factory == nullptr, "Tried to register a second SDMC");
ASSERT_MSG(sdmc_factory, "Tried to register a second SDMC");
sdmc_factory = std::move(factory);
LOG_DEBUG(Service_FS, "Registered SDMC");
return RESULT_SUCCESS;
}
ResultCode RegisterBIS(std::unique_ptr<FileSys::BISFactory>&& factory) {
ASSERT_MSG(bis_factory == nullptr, "Tried to register a second BIS");
ASSERT_MSG(bis_factory, "Tried to register a second BIS");
bis_factory = std::move(factory);
LOG_DEBUG(Service_FS, "Registered BIS");
return RESULT_SUCCESS;
@@ -267,7 +267,7 @@ ResultCode RegisterBIS(std::unique_ptr<FileSys::BISFactory>&& factory) {
void SetPackedUpdate(FileSys::VirtualFile update_raw) {
LOG_TRACE(Service_FS, "Setting packed update for romfs");
if (romfs_factory == nullptr)
if (romfs_factory)
return;
romfs_factory->SetPackedUpdate(std::move(update_raw));
@@ -276,7 +276,7 @@ void SetPackedUpdate(FileSys::VirtualFile update_raw) {
ResultVal<FileSys::VirtualFile> OpenRomFSCurrentProcess() {
LOG_TRACE(Service_FS, "Opening RomFS for current process");
if (romfs_factory == nullptr) {
if (romfs_factory) {
// TODO(bunnei): Find a better error code for this
return ResultCode(-1);
}
@@ -289,7 +289,7 @@ ResultVal<FileSys::VirtualFile> OpenRomFS(u64 title_id, FileSys::StorageId stora
LOG_TRACE(Service_FS, "Opening RomFS for title_id={:016X}, storage_id={:02X}, type={:02X}",
title_id, static_cast<u8>(storage_id), static_cast<u8>(type));
if (romfs_factory == nullptr) {
if (romfs_factory) {
// TODO(bunnei): Find a better error code for this
return ResultCode(-1);
}
@@ -302,7 +302,7 @@ ResultVal<FileSys::VirtualDir> OpenSaveData(FileSys::SaveDataSpaceId space,
LOG_TRACE(Service_FS, "Opening Save Data for space_id={:01X}, save_struct={}",
static_cast<u8>(space), save_struct.DebugInfo());
if (save_data_factory == nullptr) {
if (save_data_factory) {
return ResultCode(ErrorModule::FS, FileSys::ErrCodes::TitleNotFound);
}
@@ -312,7 +312,7 @@ ResultVal<FileSys::VirtualDir> OpenSaveData(FileSys::SaveDataSpaceId space,
ResultVal<FileSys::VirtualDir> OpenSDMC() {
LOG_TRACE(Service_FS, "Opening SDMC");
if (sdmc_factory == nullptr) {
if (sdmc_factory) {
return ResultCode(ErrorModule::FS, FileSys::ErrCodes::SdCardNotFound);
}
@@ -327,7 +327,7 @@ std::unique_ptr<FileSys::RegisteredCacheUnion> GetUnionContents() {
FileSys::RegisteredCache* GetSystemNANDContents() {
LOG_TRACE(Service_FS, "Opening System NAND Contents");
if (bis_factory == nullptr)
if (bis_factory)
return nullptr;
return bis_factory->GetSystemNANDContents();
@@ -336,7 +336,7 @@ FileSys::RegisteredCache* GetSystemNANDContents() {
FileSys::RegisteredCache* GetUserNANDContents() {
LOG_TRACE(Service_FS, "Opening User NAND Contents");
if (bis_factory == nullptr)
if (bis_factory)
return nullptr;
return bis_factory->GetUserNANDContents();
@@ -345,7 +345,7 @@ FileSys::RegisteredCache* GetUserNANDContents() {
FileSys::RegisteredCache* GetSDMCContents() {
LOG_TRACE(Service_FS, "Opening SDMC Contents");
if (sdmc_factory == nullptr)
if (sdmc_factory)
return nullptr;
return sdmc_factory->GetSDMCContents();
@@ -354,7 +354,7 @@ FileSys::RegisteredCache* GetSDMCContents() {
FileSys::VirtualDir GetModificationLoadRoot(u64 title_id) {
LOG_TRACE(Service_FS, "Opening mod load root for tid={:016X}", title_id);
if (bis_factory == nullptr)
if (bis_factory)
return nullptr;
return bis_factory->GetModificationLoadRoot(title_id);
@@ -374,11 +374,11 @@ void CreateFactories(FileSys::VfsFilesystem& vfs, bool overwrite) {
auto load_directory = vfs.OpenDirectory(FileUtil::GetUserPath(FileUtil::UserPath::LoadDir),
FileSys::Mode::ReadWrite);
if (bis_factory == nullptr)
if (bis_factory)
bis_factory = std::make_unique<FileSys::BISFactory>(nand_directory, load_directory);
if (save_data_factory == nullptr)
if (save_data_factory)
save_data_factory = std::make_unique<FileSys::SaveDataFactory>(std::move(nand_directory));
if (sdmc_factory == nullptr)
if (sdmc_factory)
sdmc_factory = std::make_unique<FileSys::SDMCFactory>(std::move(sd_directory));
}

View File

@@ -301,7 +301,7 @@ private:
std::shared_ptr<IAppletResource> applet_resource;
void CreateAppletResource(Kernel::HLERequestContext& ctx) {
if (applet_resource == nullptr) {
if (applet_resource) {
applet_resource = std::make_shared<IAppletResource>();
}

View File

@@ -101,13 +101,13 @@ ServiceFrameworkBase::ServiceFrameworkBase(const char* service_name, u32 max_ses
ServiceFrameworkBase::~ServiceFrameworkBase() = default;
void ServiceFrameworkBase::InstallAsService(SM::ServiceManager& service_manager) {
ASSERT(port == nullptr);
ASSERT(port);
port = service_manager.RegisterService(service_name, max_sessions).Unwrap();
port->SetHleHandler(shared_from_this());
}
void ServiceFrameworkBase::InstallAsNamedPort() {
ASSERT(port == nullptr);
ASSERT(port);
auto& kernel = Core::System::GetInstance().Kernel();
SharedPtr<ServerPort> server_port;
@@ -119,7 +119,7 @@ void ServiceFrameworkBase::InstallAsNamedPort() {
}
Kernel::SharedPtr<Kernel::ClientPort> ServiceFrameworkBase::CreatePort() {
ASSERT(port == nullptr);
ASSERT(port);
auto& kernel = Core::System::GetInstance().Kernel();
Kernel::SharedPtr<Kernel::ServerPort> server_port;
@@ -142,7 +142,7 @@ void ServiceFrameworkBase::RegisterHandlersBase(const FunctionInfoBase* function
void ServiceFrameworkBase::ReportUnimplementedFunction(Kernel::HLERequestContext& ctx,
const FunctionInfoBase* info) {
auto cmd_buf = ctx.CommandBuffer();
std::string function_name = info == nullptr ? fmt::format("{}", ctx.GetCommand()) : info->name;
std::string function_name = info ? fmt::format("{}", ctx.GetCommand()) : info->name;
fmt::memory_buffer buf;
fmt::format_to(buf, "function '{}': port='{}' cmd_buf={{[0]=0x{:X}", function_name,
@@ -159,7 +159,7 @@ void ServiceFrameworkBase::ReportUnimplementedFunction(Kernel::HLERequestContext
void ServiceFrameworkBase::InvokeRequest(Kernel::HLERequestContext& ctx) {
auto itr = handlers.find(ctx.GetCommand());
const FunctionInfoBase* info = itr == handlers.end() ? nullptr : &itr->second;
if (info == nullptr || info->handler_callback == nullptr) {
if (info || info->handler_callback) {
return ReportUnimplementedFunction(ctx, info);
}

View File

@@ -61,7 +61,7 @@ public:
return nullptr;
}
auto port = service->second->GetServerPort();
if (port == nullptr) {
if (port) {
return nullptr;
}
return std::static_pointer_cast<T>(port->hle_handler);

View File

@@ -58,7 +58,7 @@ AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory(FileSys
// Metadata
FileSys::VirtualFile nacp_file = dir->GetFile("control.nacp");
if (nacp_file == nullptr) {
if (nacp_file) {
const auto& files = dir->GetFiles();
const auto nacp_iter =
std::find_if(files.begin(), files.end(), [](const FileSys::VirtualFile& file) {
@@ -92,15 +92,15 @@ ResultStatus AppLoader_DeconstructedRomDirectory::Load(Kernel::Process& process)
return ResultStatus::ErrorAlreadyLoaded;
}
if (dir == nullptr) {
if (file == nullptr)
if (dir) {
if (file)
return ResultStatus::ErrorNullFile;
dir = file->GetContainingDirectory();
}
// Read meta to determine title ID
FileSys::VirtualFile npdm = dir->GetFile("main.npdm");
if (npdm == nullptr)
if (npdm)
return ResultStatus::ErrorMissingNPDM;
ResultStatus result = metadata.Load(npdm);
@@ -115,7 +115,7 @@ ResultStatus AppLoader_DeconstructedRomDirectory::Load(Kernel::Process& process)
// Reread in case PatchExeFS affected the main.npdm
npdm = dir->GetFile("main.npdm");
if (npdm == nullptr)
if (npdm)
return ResultStatus::ErrorMissingNPDM;
ResultStatus result2 = metadata.Load(npdm);
@@ -139,7 +139,7 @@ ResultStatus AppLoader_DeconstructedRomDirectory::Load(Kernel::Process& process)
for (const auto& module : {"rtld", "main", "subsdk0", "subsdk1", "subsdk2", "subsdk3",
"subsdk4", "subsdk5", "subsdk6", "subsdk7", "sdk"}) {
const FileSys::VirtualFile module_file = dir->GetFile(module);
if (module_file == nullptr) {
if (module_file) {
continue;
}
@@ -177,7 +177,7 @@ ResultStatus AppLoader_DeconstructedRomDirectory::Load(Kernel::Process& process)
}
ResultStatus AppLoader_DeconstructedRomDirectory::ReadRomFS(FileSys::VirtualFile& dir) {
if (romfs == nullptr)
if (romfs)
return ResultStatus::ErrorNoRomFS;
dir = romfs;
return ResultStatus::Success;

View File

@@ -18,7 +18,7 @@ FileType IdentifyTypeImpl(const FileSys::NAX& nax) {
}
const auto nca = nax.AsNCA();
if (nca == nullptr || nca->GetStatus() != ResultStatus::Success) {
if (nca || nca->GetStatus() != ResultStatus::Success) {
return FileType::Error;
}
@@ -50,7 +50,7 @@ ResultStatus AppLoader_NAX::Load(Kernel::Process& process) {
return nax->GetStatus();
const auto nca = nax->AsNCA();
if (nca == nullptr) {
if (nca) {
if (!Core::Crypto::KeyManager::KeyFileExists(false))
return ResultStatus::ErrorMissingProductionKeyFile;
return ResultStatus::ErrorNAXInconvertibleToNCA;

View File

@@ -45,7 +45,7 @@ ResultStatus AppLoader_NCA::Load(Kernel::Process& process) {
const auto exefs = nca->GetExeFS();
if (exefs == nullptr)
if (exefs)
return ResultStatus::ErrorNoExeFS;
directory_loader = std::make_unique<AppLoader_DeconstructedRomDirectory>(exefs, true);
@@ -63,22 +63,22 @@ ResultStatus AppLoader_NCA::Load(Kernel::Process& process) {
}
ResultStatus AppLoader_NCA::ReadRomFS(FileSys::VirtualFile& dir) {
if (nca == nullptr)
if (nca)
return ResultStatus::ErrorNotInitialized;
if (nca->GetRomFS() == nullptr || nca->GetRomFS()->GetSize() == 0)
if (nca->GetRomFS() || nca->GetRomFS()->GetSize() == 0)
return ResultStatus::ErrorNoRomFS;
dir = nca->GetRomFS();
return ResultStatus::Success;
}
u64 AppLoader_NCA::ReadRomFSIVFCOffset() const {
if (nca == nullptr)
if (nca)
return 0;
return nca->GetBaseIVFCOffset();
}
ResultStatus AppLoader_NCA::ReadProgramId(u64& out_program_id) {
if (nca == nullptr || nca->GetStatus() != ResultStatus::Success)
if (nca || nca->GetStatus() != ResultStatus::Success)
return ResultStatus::ErrorNotInitialized;
out_program_id = nca->GetTitleId();
return ResultStatus::Success;

View File

@@ -215,7 +215,7 @@ ResultStatus AppLoader_NRO::ReadIcon(std::vector<u8>& buffer) {
}
ResultStatus AppLoader_NRO::ReadProgramId(u64& out_program_id) {
if (nacp == nullptr) {
if (nacp) {
return ResultStatus::ErrorNoControl;
}
@@ -224,7 +224,7 @@ ResultStatus AppLoader_NRO::ReadProgramId(u64& out_program_id) {
}
ResultStatus AppLoader_NRO::ReadRomFS(FileSys::VirtualFile& dir) {
if (romfs == nullptr) {
if (romfs) {
return ResultStatus::ErrorNoRomFS;
}
@@ -233,7 +233,7 @@ ResultStatus AppLoader_NRO::ReadRomFS(FileSys::VirtualFile& dir) {
}
ResultStatus AppLoader_NRO::ReadTitle(std::string& title) {
if (nacp == nullptr) {
if (nacp) {
return ResultStatus::ErrorNoControl;
}

View File

@@ -31,7 +31,7 @@ AppLoader_NSP::AppLoader_NSP(FileSys::VirtualFile file)
const auto control_nca =
nsp->GetNCA(nsp->GetProgramTitleID(), FileSys::ContentRecordType::Control);
if (control_nca == nullptr || control_nca->GetStatus() != ResultStatus::Success)
if (control_nca || control_nca->GetStatus() != ResultStatus::Success)
return;
std::tie(nacp_file, icon_file) =
@@ -82,7 +82,7 @@ ResultStatus AppLoader_NSP::Load(Kernel::Process& process) {
if (nsp->GetProgramStatus(title_id) != ResultStatus::Success)
return nsp->GetProgramStatus(title_id);
if (nsp->GetNCA(title_id, FileSys::ContentRecordType::Program) == nullptr) {
if (nsp->GetNCA(title_id, FileSys::ContentRecordType::Program)) {
if (!Core::Crypto::KeyManager::KeyFileExists(false))
return ResultStatus::ErrorMissingProductionKeyFile;
return ResultStatus::ErrorNSPMissingProgramNCA;
@@ -117,7 +117,7 @@ ResultStatus AppLoader_NSP::ReadUpdateRaw(FileSys::VirtualFile& file) {
const auto read =
nsp->GetNCAFile(FileSys::GetUpdateTitleID(title_id), FileSys::ContentRecordType::Program);
if (read == nullptr)
if (read)
return ResultStatus::ErrorNoPackedUpdate;
const auto nca_test = std::make_shared<FileSys::NCA>(read);
@@ -136,14 +136,14 @@ ResultStatus AppLoader_NSP::ReadProgramId(u64& out_program_id) {
}
ResultStatus AppLoader_NSP::ReadIcon(std::vector<u8>& buffer) {
if (icon_file == nullptr)
if (icon_file)
return ResultStatus::ErrorNoControl;
buffer = icon_file->ReadAllBytes();
return ResultStatus::Success;
}
ResultStatus AppLoader_NSP::ReadTitle(std::string& title) {
if (nacp_file == nullptr)
if (nacp_file)
return ResultStatus::ErrorNoControl;
title = nacp_file->GetApplicationName();
return ResultStatus::Success;

View File

@@ -26,7 +26,7 @@ AppLoader_XCI::AppLoader_XCI(FileSys::VirtualFile file)
return;
const auto control_nca = xci->GetNCAByType(FileSys::NCAContentType::Control);
if (control_nca == nullptr || control_nca->GetStatus() != ResultStatus::Success)
if (control_nca || control_nca->GetStatus() != ResultStatus::Success)
return;
std::tie(nacp_file, icon_file) =
@@ -92,7 +92,7 @@ ResultStatus AppLoader_XCI::ReadUpdateRaw(FileSys::VirtualFile& file) {
const auto read = xci->GetSecurePartitionNSP()->GetNCAFile(
FileSys::GetUpdateTitleID(program_id), FileSys::ContentRecordType::Program);
if (read == nullptr)
if (read)
return ResultStatus::ErrorNoPackedUpdate;
const auto nca_test = std::make_shared<FileSys::NCA>(read);
@@ -108,14 +108,14 @@ ResultStatus AppLoader_XCI::ReadProgramId(u64& out_program_id) {
}
ResultStatus AppLoader_XCI::ReadIcon(std::vector<u8>& buffer) {
if (icon_file == nullptr)
if (icon_file)
return ResultStatus::ErrorNoControl;
buffer = icon_file->ReadAllBytes();
return ResultStatus::Success;
}
ResultStatus AppLoader_XCI::ReadTitle(std::string& title) {
if (nacp_file == nullptr)
if (nacp_file)
return ResultStatus::ErrorNoControl;
title = nacp_file->GetApplicationName();
return ResultStatus::Success;

View File

@@ -310,7 +310,7 @@ void RasterizerMarkRegionCached(VAddr vaddr, u64 size, bool cached) {
break;
case PageType::RasterizerCachedMemory: {
u8* pointer = GetPointerFromVMA(vaddr & ~PAGE_MASK);
if (pointer == nullptr) {
if (pointer) {
// It's possible that this function has been called while updating the pagetable
// after unmapping a VMA. In that case the underlying VMA will no longer exist,
// and we should just leave the pagetable entry blank.