diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_manager_impl.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_manager_impl.hpp index 75d52855a..e3663c66f 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_manager_impl.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_manager_impl.hpp @@ -69,14 +69,14 @@ namespace ams::ncm { }; private: os::Mutex mutex; - bool initialized = false; + bool initialized; ContentStorageRoot content_storage_roots[MaxContentStorageRoots]; ContentMetaDatabaseRoot content_meta_database_roots[MaxContentMetaDatabaseRoots]; u32 num_content_storage_entries; u32 num_content_meta_entries; RightsIdCache rights_id_cache; public: - ContentManagerImpl() { /* ... */ }; + ContentManagerImpl() : initialized(false) { /* ... */ }; ~ContentManagerImpl(); public: Result Initialize(); diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_rights_id_cache.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_rights_id_cache.hpp index bc41b4a7b..f29d01a8a 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_rights_id_cache.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_rights_id_cache.hpp @@ -65,8 +65,7 @@ namespace ams::ncm { /* Update the cache. */ eviction_candidate->uuid = content_id.uuid; eviction_candidate->rights_id = rights_id; - eviction_candidate->last_accessed = this->counter; - this->counter++; + eviction_candidate->last_accessed = this->counter++; } bool Find(ncm::RightsId *out_rights_id, ContentId content_id) { diff --git a/libraries/libstratosphere/source/lr/lr_add_on_content_location_resolver_impl.cpp b/libraries/libstratosphere/source/lr/lr_add_on_content_location_resolver_impl.cpp index 74bd49e7e..bf3ceb184 100644 --- a/libraries/libstratosphere/source/lr/lr_add_on_content_location_resolver_impl.cpp +++ b/libraries/libstratosphere/source/lr/lr_add_on_content_location_resolver_impl.cpp @@ -23,7 +23,7 @@ namespace ams::lr { ncm::StorageId storage_id = ncm::StorageId::None; R_UNLESS(this->registered_storages.Find(&storage_id, id), lr::ResultAddOnContentNotFound()); - /* Obtain a Content Meta Database for the storage id. */ + /* Obtain a content meta database for the storage id. */ ncm::ContentMetaDatabase content_meta_database; R_TRY(ncm::OpenContentMetaDatabase(&content_meta_database, storage_id)); @@ -31,7 +31,7 @@ namespace ams::lr { ncm::ContentId data_content_id; R_TRY(content_meta_database.GetLatestData(&data_content_id, id)); - /* Obtain a Content Storage for the storage id. */ + /* Obtain a content storage for the storage id. */ ncm::ContentStorage content_storage; R_TRY(ncm::OpenContentStorage(&content_storage, storage_id)); diff --git a/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.cpp b/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.cpp index 57cdbe411..49df0c001 100644 --- a/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.cpp +++ b/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.cpp @@ -106,7 +106,7 @@ namespace ams::lr { } Result ContentLocationResolverImpl::Refresh() { - /* Obtain Content Meta Database and Content Storage objects for this resolver's storage. */ + /* Obtain content meta database and content storage objects for this resolver's storage. */ ncm::ContentMetaDatabase meta_db; ncm::ContentStorage storage; R_TRY(ncm::OpenContentMetaDatabase(&meta_db, this->storage_id)); diff --git a/libraries/libstratosphere/source/lr/lr_location_redirector.cpp b/libraries/libstratosphere/source/lr/lr_location_redirector.cpp index fff5b83d3..f2c6a45b2 100644 --- a/libraries/libstratosphere/source/lr/lr_location_redirector.cpp +++ b/libraries/libstratosphere/source/lr/lr_location_redirector.cpp @@ -97,7 +97,7 @@ namespace ams::lr { } void LocationRedirector::ClearRedirections(u32 flags) { - /* Remove anyredirections with matching flags. */ + /* Remove any redirections with matching flags. */ for (auto it = this->redirection_list.begin(); it != this->redirection_list.end();) { if ((it->GetFlags() & flags) == flags) { auto old = it; diff --git a/libraries/libstratosphere/source/lr/lr_location_resolver_manager_impl.cpp b/libraries/libstratosphere/source/lr/lr_location_resolver_manager_impl.cpp index 0167a5515..f726cdf7e 100644 --- a/libraries/libstratosphere/source/lr/lr_location_resolver_manager_impl.cpp +++ b/libraries/libstratosphere/source/lr/lr_location_resolver_manager_impl.cpp @@ -42,8 +42,7 @@ namespace ams::lr { } /* Copy the output interface. */ - std::shared_ptr new_intf = *resolver; - out.SetValue(std::move(new_intf)); + out.SetValue(std::shared_ptr(*resolver)); return ResultSuccess(); } @@ -56,8 +55,7 @@ namespace ams::lr { } /* Copy the output interface. */ - std::shared_ptr new_intf = this->registered_location_resolver; - out.SetValue(std::move(new_intf)); + out.SetValue(std::shared_ptr(this->registered_location_resolver)); return ResultSuccess(); } @@ -85,8 +83,7 @@ namespace ams::lr { } /* Copy the output interface. */ - std::shared_ptr new_intf = this->add_on_content_location_resolver; - out.SetValue(std::move(new_intf)); + out.SetValue(std::shared_ptr(this->add_on_content_location_resolver)); return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/ncm/ncm_content_id_utils.cpp b/libraries/libstratosphere/source/ncm/ncm_content_id_utils.cpp index 8de1ef24f..4450693c3 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_id_utils.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_id_utils.cpp @@ -51,9 +51,7 @@ namespace ams::ncm { ContentIdString GetContentIdString(ContentId id) { ContentIdString str; - GetStringFromContentId(str.data, sizeof(str), id); - return str; } diff --git a/libraries/libstratosphere/source/ncm/ncm_content_manager_impl.cpp b/libraries/libstratosphere/source/ncm/ncm_content_manager_impl.cpp index 9162fa406..d64301fac 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_manager_impl.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_manager_impl.cpp @@ -91,8 +91,8 @@ namespace ams::ncm { ALWAYS_INLINE Result GetContentStorageNotActiveResult(StorageId storage_id) { switch (storage_id) { case StorageId::GameCard: return ResultGameCardContentStorageNotActive(); - case StorageId::BuiltInSystem: return ResultNandSystemContentStorageNotActive(); - case StorageId::BuiltInUser: return ResultNandUserContentStorageNotActive(); + case StorageId::BuiltInSystem: return ResultBuiltInSystemContentStorageNotActive(); + case StorageId::BuiltInUser: return ResultBuiltInUserContentStorageNotActive(); case StorageId::SdCard: return ResultSdCardContentStorageNotActive(); default: return ResultUnknownContentStorageNotActive(); } @@ -101,8 +101,8 @@ namespace ams::ncm { ALWAYS_INLINE Result GetContentMetaDatabaseNotActiveResult(StorageId storage_id) { switch (storage_id) { case StorageId::GameCard: return ResultGameCardContentMetaDatabaseNotActive(); - case StorageId::BuiltInSystem: return ResultNandSystemContentMetaDatabaseNotActive(); - case StorageId::BuiltInUser: return ResultNandUserContentMetaDatabaseNotActive(); + case StorageId::BuiltInSystem: return ResultBuiltInSystemContentMetaDatabaseNotActive(); + case StorageId::BuiltInUser: return ResultBuiltInUserContentMetaDatabaseNotActive(); case StorageId::SdCard: return ResultSdCardContentMetaDatabaseNotActive(); default: return ResultUnknownContentMetaDatabaseNotActive(); } @@ -290,9 +290,7 @@ namespace ams::ncm { R_TRY(impl::EnsureDirectoryRecursively(root->path)); /* Initialize content and placeholder directories for the root. */ - R_TRY(ContentStorageImpl::InitializeBase(root->path)); - - return ResultSuccess(); + return ContentStorageImpl::InitializeBase(root->path); } Result ContentManagerImpl::CreateContentMetaDatabase(StorageId storage_id) { @@ -312,9 +310,7 @@ namespace ams::ncm { R_TRY(impl::EnsureDirectoryRecursively(root->path)); /* Commit our changes. */ - R_TRY(fs::CommitSaveData(root->mount_name)); - - return ResultSuccess(); + return fs::CommitSaveData(root->mount_name); } Result ContentManagerImpl::VerifyContentStorage(StorageId storage_id) { @@ -334,9 +330,7 @@ namespace ams::ncm { ON_SCOPE_EXIT { fs::Unmount(mount_name.str); }; /* Ensure the root, content and placeholder directories exist for the storage. */ - R_TRY(ContentStorageImpl::VerifyBase(path)); - - return ResultSuccess(); + return ContentStorageImpl::VerifyBase(path); } Result ContentManagerImpl::VerifyContentMetaDatabase(StorageId storage_id) { @@ -382,8 +376,7 @@ namespace ams::ncm { } } - auto content_storage = root->content_storage; - out.SetValue(std::move(content_storage)); + out.SetValue(std::shared_ptr(root->content_storage)); return ResultSuccess(); } @@ -404,8 +397,7 @@ namespace ams::ncm { } } - auto content_meta_db = root->content_meta_database; - out.SetValue(std::move(content_meta_db)); + out.SetValue(std::shared_ptr(root->content_meta_database)); return ResultSuccess(); } @@ -428,8 +420,7 @@ namespace ams::ncm { R_TRY(this->GetContentMetaDatabaseRoot(&root, storage_id)); /* Delete save data for the content meta database root. */ - R_TRY(fs::DeleteSaveData(root->info.space_id, root->info.id)); - return ResultSuccess(); + return fs::DeleteSaveData(root->info.space_id, root->info.id); } Result ContentManagerImpl::ActivateContentStorage(StorageId storage_id) { diff --git a/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.cpp b/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.cpp index d72718c73..8b643f2a9 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.cpp @@ -249,6 +249,8 @@ namespace ams::ncm { Result ContentMetaDatabaseImpl::GetRequiredSystemVersion(sf::Out out_version, const ContentMetaKey &key) { R_TRY(this->EnsureEnabled()); + + /* Only applications and patches have a required system version. */ R_UNLESS(key.type == ContentMetaType::Application || key.type == ContentMetaType::Patch, ncm::ResultInvalidContentMetaKey()); /* Obtain the content meta for the key. */ @@ -275,6 +277,8 @@ namespace ams::ncm { Result ContentMetaDatabaseImpl::GetPatchId(sf::Out out_patch_id, const ContentMetaKey &key) { R_TRY(this->EnsureEnabled()); + + /* Only applications can have patches. */ R_UNLESS(key.type == ContentMetaType::Application, ncm::ResultInvalidContentMetaKey()); /* Obtain the content meta for the key. */ @@ -378,6 +382,7 @@ namespace ams::ncm { out_meta_info[count] = *reader.GetContentMetaInfo(count + offset); } + /* Set the ouput value. */ out_entries_written.SetValue(count); return ResultSuccess(); } @@ -393,6 +398,7 @@ namespace ams::ncm { /* Create a reader. */ ContentMetaReader reader(meta, meta_size); + /* Set the ouput value. */ out_attributes.SetValue(reader.GetHeader()->attributes); return ResultSuccess(); } @@ -422,6 +428,7 @@ namespace ams::ncm { AMS_UNREACHABLE_DEFAULT_CASE(); } + /* Set the ouput value. */ out_version.SetValue(required_version); return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.cpp b/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.cpp index 466b9826a..c0aefcbf8 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.cpp @@ -176,9 +176,7 @@ namespace ams::ncm { /* Create the placeholder directory. */ PlaceHolderAccessor::MakeBaseDirectoryPath(std::addressof(path), root_path); - R_TRY(impl::EnsureDirectoryRecursively(path)); - - return ResultSuccess(); + return impl::EnsureDirectoryRecursively(path); } Result ContentStorageImpl::CleanupBase(const char *root_path) { @@ -190,9 +188,7 @@ namespace ams::ncm { /* Create the placeholder directory. */ PlaceHolderAccessor::MakeBaseDirectoryPath(std::addressof(path), root_path); - R_TRY(CleanDirectoryRecursively(path)); - - return ResultSuccess(); + return CleanDirectoryRecursively(path); } Result ContentStorageImpl::VerifyBase(const char *root_path) { @@ -259,7 +255,6 @@ namespace ams::ncm { this->make_content_path_func = content_path_func; this->placeholder_accessor.Initialize(std::addressof(this->root_path), placeholder_path_func, delay_flush); this->rights_id_cache = rights_id_cache; - return ResultSuccess(); } @@ -271,11 +266,8 @@ namespace ams::ncm { Result ContentStorageImpl::CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, s64 size) { R_TRY(this->EnsureEnabled()); - R_TRY(EnsureContentDirectory(content_id, this->make_content_path_func, this->root_path)); - R_TRY(this->placeholder_accessor.CreatePlaceHolderFile(placeholder_id, size)); - - return ResultSuccess(); + return this->placeholder_accessor.CreatePlaceHolderFile(placeholder_id, size); } Result ContentStorageImpl::DeletePlaceHolder(PlaceHolderId placeholder_id) { @@ -294,7 +286,6 @@ namespace ams::ncm { bool has = false; R_TRY(impl::HasFile(&has, placeholder_path)); out.SetValue(has); - return ResultSuccess(); } @@ -343,7 +334,6 @@ namespace ams::ncm { bool has = false; R_TRY(impl::HasFile(&has, content_path)); out.SetValue(has); - return ResultSuccess(); } @@ -649,23 +639,15 @@ namespace ams::ncm { ON_SCOPE_EXIT { fs::CloseFile(file); }; /* Write the provided data to the file. */ - R_TRY(fs::WriteFile(file, offset, data.GetPointer(), data.GetSize(), fs::WriteOption::Flush)); - - return ResultSuccess(); + return fs::WriteFile(file, offset, data.GetPointer(), data.GetSize(), fs::WriteOption::Flush); } Result ContentStorageImpl::GetFreeSpaceSize(sf::Out out_size) { - s64 size; - R_TRY(fs::GetFreeSpaceSize(std::addressof(size), this->root_path)); - out_size.SetValue(size); - return ResultSuccess(); + return fs::GetFreeSpaceSize(out_size.GetPointer(), this->root_path); } Result ContentStorageImpl::GetTotalSpaceSize(sf::Out out_size) { - s64 size; - R_TRY(fs::GetTotalSpaceSize(std::addressof(size), this->root_path)); - out_size.SetValue(size); - return ResultSuccess(); + return fs::GetTotalSpaceSize(out_size.GetPointer(), this->root_path); } Result ContentStorageImpl::FlushPlaceHolder() { diff --git a/libraries/libstratosphere/source/ncm/ncm_placeholder_accessor.cpp b/libraries/libstratosphere/source/ncm/ncm_placeholder_accessor.cpp index 265fb2d6d..e16771172 100644 --- a/libraries/libstratosphere/source/ncm/ncm_placeholder_accessor.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_placeholder_accessor.cpp @@ -97,7 +97,7 @@ namespace ams::ncm { bool PlaceHolderAccessor::LoadFromCache(fs::FileHandle *out_handle, PlaceHolderId placeholder_id) { std::scoped_lock lk(this->cache_mutex); - /* attempt to find an entry in the cache. */ + /* Attempt to find an entry in the cache. */ CacheEntry *entry = this->FindInCache(placeholder_id); if (!entry) { return false; diff --git a/libraries/libvapours/include/vapours/results/ncm_results.hpp b/libraries/libvapours/include/vapours/results/ncm_results.hpp index 58d2aef84..3bd912870 100644 --- a/libraries/libvapours/include/vapours/results/ncm_results.hpp +++ b/libraries/libvapours/include/vapours/results/ncm_results.hpp @@ -41,18 +41,18 @@ namespace ams::ncm { R_DEFINE_ERROR_RESULT(ContentStorageBaseNotFound, 310); R_DEFINE_ERROR_RANGE(ContentStorageNotActive, 250, 258); - R_DEFINE_ERROR_RESULT(GameCardContentStorageNotActive, 251); - R_DEFINE_ERROR_RESULT(NandSystemContentStorageNotActive, 252); - R_DEFINE_ERROR_RESULT(NandUserContentStorageNotActive, 253); - R_DEFINE_ERROR_RESULT(SdCardContentStorageNotActive, 254); - R_DEFINE_ERROR_RESULT(UnknownContentStorageNotActive, 258); + R_DEFINE_ERROR_RESULT(GameCardContentStorageNotActive, 251); + R_DEFINE_ERROR_RESULT(BuiltInSystemContentStorageNotActive, 252); + R_DEFINE_ERROR_RESULT(BuiltInUserContentStorageNotActive, 253); + R_DEFINE_ERROR_RESULT(SdCardContentStorageNotActive, 254); + R_DEFINE_ERROR_RESULT(UnknownContentStorageNotActive, 258); R_DEFINE_ERROR_RANGE(ContentMetaDatabaseNotActive, 260, 268); - R_DEFINE_ERROR_RESULT(GameCardContentMetaDatabaseNotActive, 261); - R_DEFINE_ERROR_RESULT(NandSystemContentMetaDatabaseNotActive, 262); - R_DEFINE_ERROR_RESULT(NandUserContentMetaDatabaseNotActive, 263); - R_DEFINE_ERROR_RESULT(SdCardContentMetaDatabaseNotActive, 264); - R_DEFINE_ERROR_RESULT(UnknownContentMetaDatabaseNotActive, 268); + R_DEFINE_ERROR_RESULT(GameCardContentMetaDatabaseNotActive, 261); + R_DEFINE_ERROR_RESULT(BuiltInSystemContentMetaDatabaseNotActive, 262); + R_DEFINE_ERROR_RESULT(BuiltInUserContentMetaDatabaseNotActive, 263); + R_DEFINE_ERROR_RESULT(SdCardContentMetaDatabaseNotActive, 264); + R_DEFINE_ERROR_RESULT(UnknownContentMetaDatabaseNotActive, 268); R_DEFINE_ERROR_RANGE(InvalidArgument, 8181, 8191); R_DEFINE_ERROR_RESULT(InvalidOffset, 8182);