diff --git a/src/core/core.cpp b/src/core/core.cpp index 7cb86ed922..2075f006d2 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -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(); 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); } diff --git a/src/core/core_cpu.cpp b/src/core/core_cpu.cpp index fffda8a996..407cc69d5c 100644 --- a/src/core/core_cpu.cpp +++ b/src/core/core_cpu.cpp @@ -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()) { diff --git a/src/core/crypto/key_manager.cpp b/src/core/crypto/key_manager.cpp index fefc3c7470..c7d74e19b6 100644 --- a/src/core/crypto/key_manager.cpp +++ b/src/core/crypto/key_manager.cpp @@ -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(); diff --git a/src/core/crypto/partition_data_manager.cpp b/src/core/crypto/partition_data_manager.cpp index ed07754447..0ac655dc98 100644 --- a/src/core/crypto/partition_data_manager.cpp +++ b/src/core/crypto/partition_data_manager.cpp @@ -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{} - : secure_monitor->ReadAllBytes()), - package1_decrypted_bytes(package1_decrypted == nullptr ? std::vector{} - : package1_decrypted->ReadAllBytes()) { -} + secure_monitor_bytes(secure_monitor ? std::vector{} : secure_monitor->ReadAllBytes()), + package1_decrypted_bytes(package1_decrypted ? std::vector{} + : package1_decrypted->ReadAllBytes()) {} PartitionDataManager::~PartitionDataManager() = default; @@ -579,7 +577,7 @@ FileSys::VirtualFile PartitionDataManager::GetProdInfoRaw() const { } void PartitionDataManager::DecryptProdInfo(std::array bis_key) { - if (prodinfo == nullptr) + if (prodinfo) return; prodinfo_decrypted = std::make_shared(prodinfo, bis_key); diff --git a/src/core/file_sys/card_image.cpp b/src/core/file_sys/card_image.cpp index ecdd7505b6..4a70f861d1 100644 --- a/src/core/file_sys/card_image.cpp +++ b/src/core/file_sys/card_image.cpp @@ -173,7 +173,7 @@ bool XCI::ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) { } Loader::ResultStatus XCI::AddNCAFromPartition(XCIPartition part) { - if (partitions[static_cast(part)] == nullptr) { + if (partitions[static_cast(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 diff --git a/src/core/file_sys/content_archive.cpp b/src/core/file_sys/content_archive.cpp index 6c356d85da..1f28b79a01 100644 --- a/src/core/file_sys/content_archive.cpp +++ b/src/core/file_sys/content_archive.cpp @@ -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(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; } diff --git a/src/core/file_sys/fsmitm_romfsbuild.cpp b/src/core/file_sys/fsmitm_romfsbuild.cpp index 47b7526c7d..de923d9c7a 100644 --- a/src/core/file_sys/fsmitm_romfsbuild.cpp +++ b/src/core/file_sys/fsmitm_romfsbuild.cpp @@ -300,8 +300,7 @@ std::map 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 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, diff --git a/src/core/file_sys/ips_layer.cpp b/src/core/file_sys/ips_layer.cpp index 554eae9bca..b0b4af4323 100644 --- a/src/core/file_sys/ips_layer.cpp +++ b/src/core/file_sys/ips_layer.cpp @@ -66,7 +66,7 @@ static bool IsEOF(IPSFileType type, const std::vector& 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(); diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp index 1f49285620..6b445e0014 100644 --- a/src/core/file_sys/patch_manager.cpp +++ b/src/core/file_sys/patch_manager.cpp @@ -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& 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, 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, VirtualFile> PatchManager::GetControlMetadata() std::pair, 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_file); + auto nacp = nacp_file ? nullptr : std::make_unique(nacp_file); VirtualFile icon_file; for (const auto& language : FileSys::LANGUAGE_NAMES) { diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp index 29b1004141..98fd0b7750 100644 --- a/src/core/file_sys/registered_cache.cpp +++ b/src/core/file_sys/registered_cache.cpp @@ -223,7 +223,7 @@ void RegisteredCache::ProcessFiles(const std::vector& ids) { for (const auto& id : ids) { const auto file = GetFileAtID(id); - if (file == nullptr) + if (file) continue; const auto nca = std::make_shared(parser(file, id)); if (nca->GetStatus() != Loader::ResultStatus::Success || @@ -246,7 +246,7 @@ void RegisteredCache::ProcessFiles(const std::vector& 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 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(raw); } @@ -386,7 +386,7 @@ std::vector RegisteredCache::ListEntriesFilter( static std::shared_ptr GetNCAFromNSPForID(std::shared_ptr 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(file); } @@ -423,7 +423,7 @@ InstallResult RegisteredCache::InstallEntry(std::shared_ptr 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, 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 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(raw); } diff --git a/src/core/file_sys/romfs.cpp b/src/core/file_sys/romfs.cpp index 81e1f66acd..71c152c133 100644 --- a/src/core/file_sys/romfs.cpp +++ b/src/core/file_sys/romfs.cpp @@ -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}; diff --git a/src/core/file_sys/romfs_factory.cpp b/src/core/file_sys/romfs_factory.cpp index 0b645b106b..edd821389b 100644 --- a/src/core/file_sys/romfs_factory.cpp +++ b/src/core/file_sys/romfs_factory.cpp @@ -63,12 +63,12 @@ ResultVal RomFSFactory::Open(u64 title_id, StorageId storage, Conte UNIMPLEMENTED_MSG("Unimplemented storage_id={:02X}", static_cast(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); } diff --git a/src/core/file_sys/savedata_factory.cpp b/src/core/file_sys/savedata_factory.cpp index ef1aaebbb0..cb4762f027 100644 --- a/src/core/file_sys/savedata_factory.cpp +++ b/src/core/file_sys/savedata_factory.cpp @@ -66,7 +66,7 @@ ResultVal 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 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); } diff --git a/src/core/file_sys/submission_package.cpp b/src/core/file_sys/submission_package.cpp index ab5dc900c7..6103e6d20e 100644 --- a/src/core/file_sys/submission_package.cpp +++ b/src/core/file_sys/submission_package.cpp @@ -23,7 +23,7 @@ void SetTicketKeys(const std::vector& 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 NSP::GetTitlekey() const { LOG_WARNING(Service_FS, "called on an NSP that is of type extracted."); std::vector 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& 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.", diff --git a/src/core/file_sys/vfs.cpp b/src/core/file_sys/vfs.cpp index 3824c74e0d..86db74e156 100644 --- a/src/core/file_sys/vfs.cpp +++ b/src/core/file_sys/vfs.cpp @@ -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& 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 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::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::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 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::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::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; } diff --git a/src/core/file_sys/vfs.h b/src/core/file_sys/vfs.h index 7f0d520ca0..884e825e64 100644 --- a/src/core/file_sys/vfs.h +++ b/src/core/file_sys/vfs.h @@ -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& 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)); } diff --git a/src/core/file_sys/vfs_offset.cpp b/src/core/file_sys/vfs_offset.cpp index a4c6719a0d..3c7c0f1a4f 100644 --- a/src/core/file_sys/vfs_offset.cpp +++ b/src/core/file_sys/vfs_offset.cpp @@ -12,7 +12,7 @@ namespace FileSys { OffsetVfsFile::OffsetVfsFile(std::shared_ptr 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; diff --git a/src/core/hle/kernel/client_session.cpp b/src/core/hle/kernel/client_session.cpp index c114eaf994..7da9d72c84 100644 --- a/src/core/hle/kernel/client_session.cpp +++ b/src/core/hle/kernel/client_session.cpp @@ -39,7 +39,7 @@ ClientSession::~ClientSession() { ResultCode ClientSession::SendSyncRequest(SharedPtr thread) { // Keep ServerSession alive until we're done working with it. SharedPtr server = parent->server; - if (server == nullptr) + if (server) return ERR_SESSION_CLOSED_BY_REMOTE; // Signal the server session that new data is available diff --git a/src/core/hle/kernel/handle_table.cpp b/src/core/hle/kernel/handle_table.cpp index 5ee5c05e31..9f2ed28e14 100644 --- a/src/core/hle/kernel/handle_table.cpp +++ b/src/core/hle/kernel/handle_table.cpp @@ -44,7 +44,7 @@ ResultVal HandleTable::Create(SharedPtr obj) { ResultVal HandleTable::Duplicate(Handle handle) { SharedPtr object = GetGeneric(handle); - if (object == nullptr) { + if (object) { LOG_ERROR(Kernel, "Tried to duplicate invalid handle: {:08X}", handle); return ERR_INVALID_HANDLE; } diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 4b6b32dd54..3e425dbfe5 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -39,7 +39,7 @@ static void ThreadWakeupCallback(u64 thread_handle, [[maybe_unused]] int cycles_ SharedPtr 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 = system.Kernel().RetrieveTimerFromCallbackHandleTable(proper_handle); - if (timer == nullptr) { + if (timer) { LOG_CRITICAL(Kernel, "Callback fired for invalid timer {:016X}", timer_handle); return; } diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp index dd541ffcc6..dce753b889 100644 --- a/src/core/hle/kernel/mutex.cpp +++ b/src/core/hle/kernel/mutex.cpp @@ -35,7 +35,7 @@ static std::pair, 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; } diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index 073dd5a7d6..0fbd9d954f 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp @@ -240,7 +240,7 @@ ResultVal 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>(); heap_start = heap_end = target; diff --git a/src/core/hle/kernel/server_session.cpp b/src/core/hle/kernel/server_session.cpp index 5fc3204036..61b0c5af25 100644 --- a/src/core/hle/kernel/server_session.cpp +++ b/src/core/hle/kernel/server_session.cpp @@ -47,7 +47,7 @@ ResultVal> 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; diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index a5302d924f..42a996cc47 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -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(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 evt = handle_table.Get(handle); - if (evt == nullptr) { + if (evt) { return ERR_INVALID_HANDLE; } diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 59bc9e0af6..67648d475a 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -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) { } // 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; } diff --git a/src/core/hle/service/aoc/aoc_u.cpp b/src/core/hle/service/aoc/aoc_u.cpp index 54305cf05d..457c5cf2f4 100644 --- a/src/core/hle/service/aoc/aoc_u.cpp +++ b/src/core/hle/service/aoc/aoc_u.cpp @@ -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; } diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp index e32a7c48e2..85d54ff155 100644 --- a/src/core/hle/service/filesystem/filesystem.cpp +++ b/src/core/hle/service/filesystem/filesystem.cpp @@ -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 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 VfsDirectoryServiceWrapper::OpenFile(const std:: ResultVal 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 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 sdmc_factory; static std::unique_ptr bis_factory; ResultCode RegisterRomFS(std::unique_ptr&& 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&& 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&& 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&& 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&& 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 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 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(storage_id), static_cast(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 OpenSaveData(FileSys::SaveDataSpaceId space, LOG_TRACE(Service_FS, "Opening Save Data for space_id={:01X}, save_struct={}", static_cast(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 OpenSaveData(FileSys::SaveDataSpaceId space, ResultVal 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 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(nand_directory, load_directory); - if (save_data_factory == nullptr) + if (save_data_factory) save_data_factory = std::make_unique(std::move(nand_directory)); - if (sdmc_factory == nullptr) + if (sdmc_factory) sdmc_factory = std::make_unique(std::move(sd_directory)); } diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index a9aa9ec780..3f4914751e 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp @@ -301,7 +301,7 @@ private: std::shared_ptr applet_resource; void CreateAppletResource(Kernel::HLERequestContext& ctx) { - if (applet_resource == nullptr) { + if (applet_resource) { applet_resource = std::make_shared(); } diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index a4cf452670..cd93d752d0 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -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 server_port; @@ -119,7 +119,7 @@ void ServiceFrameworkBase::InstallAsNamedPort() { } Kernel::SharedPtr ServiceFrameworkBase::CreatePort() { - ASSERT(port == nullptr); + ASSERT(port); auto& kernel = Core::System::GetInstance().Kernel(); Kernel::SharedPtr 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); } diff --git a/src/core/hle/service/sm/sm.h b/src/core/hle/service/sm/sm.h index 4f8145dda7..b928b51c37 100644 --- a/src/core/hle/service/sm/sm.h +++ b/src/core/hle/service/sm/sm.h @@ -61,7 +61,7 @@ public: return nullptr; } auto port = service->second->GetServerPort(); - if (port == nullptr) { + if (port) { return nullptr; } return std::static_pointer_cast(port->hle_handler); diff --git a/src/core/loader/deconstructed_rom_directory.cpp b/src/core/loader/deconstructed_rom_directory.cpp index 8518dddcbb..208ac5974b 100644 --- a/src/core/loader/deconstructed_rom_directory.cpp +++ b/src/core/loader/deconstructed_rom_directory.cpp @@ -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; diff --git a/src/core/loader/nax.cpp b/src/core/loader/nax.cpp index 42f4a777be..cd7940880d 100644 --- a/src/core/loader/nax.cpp +++ b/src/core/loader/nax.cpp @@ -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; diff --git a/src/core/loader/nca.cpp b/src/core/loader/nca.cpp index 7e1b0d84fc..4e2be873ec 100644 --- a/src/core/loader/nca.cpp +++ b/src/core/loader/nca.cpp @@ -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(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; diff --git a/src/core/loader/nro.cpp b/src/core/loader/nro.cpp index 243b499f2c..f647084963 100644 --- a/src/core/loader/nro.cpp +++ b/src/core/loader/nro.cpp @@ -215,7 +215,7 @@ ResultStatus AppLoader_NRO::ReadIcon(std::vector& 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; } diff --git a/src/core/loader/nsp.cpp b/src/core/loader/nsp.cpp index 13e57848db..e44394abe6 100644 --- a/src/core/loader/nsp.cpp +++ b/src/core/loader/nsp.cpp @@ -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(read); @@ -136,14 +136,14 @@ ResultStatus AppLoader_NSP::ReadProgramId(u64& out_program_id) { } ResultStatus AppLoader_NSP::ReadIcon(std::vector& 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; diff --git a/src/core/loader/xci.cpp b/src/core/loader/xci.cpp index 461607c95a..baee0990f5 100644 --- a/src/core/loader/xci.cpp +++ b/src/core/loader/xci.cpp @@ -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(read); @@ -108,14 +108,14 @@ ResultStatus AppLoader_XCI::ReadProgramId(u64& out_program_id) { } ResultStatus AppLoader_XCI::ReadIcon(std::vector& 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; diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 014298ed68..35b6dc4fb3 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -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.