ams: replace most remaining operator & with std::addressof

This commit is contained in:
Michael Scire
2021-10-09 14:49:53 -07:00
parent ce8aacef21
commit 1ab0bd1765
109 changed files with 587 additions and 586 deletions

View File

@@ -251,7 +251,7 @@ namespace ams::ncm {
/* Obtain the content meta database root. */
ContentMetaDatabaseRoot *root;
R_TRY(this->GetContentMetaDatabaseRoot(&root, storage_id));
R_TRY(this->GetContentMetaDatabaseRoot(std::addressof(root), storage_id));
/* Print the savedata path. */
PathString savedata_db_path;
@@ -331,14 +331,14 @@ namespace ams::ncm {
}
/* First, setup the BuiltInSystem storage entry. */
R_TRY(this->InitializeContentStorageRoot(&this->content_storage_roots[this->num_content_storage_entries++], StorageId::BuiltInSystem, fs::ContentStorageId::System));
R_TRY(this->InitializeContentStorageRoot(std::addressof(this->content_storage_roots[this->num_content_storage_entries++]), StorageId::BuiltInSystem, fs::ContentStorageId::System));
if (R_FAILED(this->VerifyContentStorage(StorageId::BuiltInSystem))) {
R_TRY(this->CreateContentStorage(StorageId::BuiltInSystem));
}
R_TRY(this->ActivateContentStorage(StorageId::BuiltInSystem));
/* Next, the BuiltInSystem content meta entry. */
R_TRY(this->InitializeContentMetaDatabaseRoot(&this->content_meta_database_roots[this->num_content_meta_entries++], StorageId::BuiltInSystem, BuiltInSystemSystemSaveDataInfo, SystemMaxContentMetaCount, std::addressof(g_system_content_meta_memory_resource)));
R_TRY(this->InitializeContentMetaDatabaseRoot(std::addressof(this->content_meta_database_roots[this->num_content_meta_entries++]), StorageId::BuiltInSystem, BuiltInSystemSystemSaveDataInfo, SystemMaxContentMetaCount, std::addressof(g_system_content_meta_memory_resource)));
if (R_FAILED(this->VerifyContentMetaDatabase(StorageId::BuiltInSystem))) {
R_TRY(this->CreateContentMetaDatabase(StorageId::BuiltInSystem));
@@ -365,19 +365,19 @@ namespace ams::ncm {
R_TRY(this->ActivateContentMetaDatabase(StorageId::BuiltInSystem));
/* Now for BuiltInUser's content storage and content meta entries. */
R_TRY(this->InitializeContentStorageRoot(&this->content_storage_roots[this->num_content_storage_entries++], StorageId::BuiltInUser, fs::ContentStorageId::User));
R_TRY(this->InitializeContentMetaDatabaseRoot(&this->content_meta_database_roots[this->num_content_meta_entries++], StorageId::BuiltInUser, BuiltInUserSystemSaveDataInfo, UserMaxContentMetaCount, std::addressof(g_sd_and_user_content_meta_memory_resource)));
R_TRY(this->InitializeContentStorageRoot(std::addressof(this->content_storage_roots[this->num_content_storage_entries++]), StorageId::BuiltInUser, fs::ContentStorageId::User));
R_TRY(this->InitializeContentMetaDatabaseRoot(std::addressof(this->content_meta_database_roots[this->num_content_meta_entries++]), StorageId::BuiltInUser, BuiltInUserSystemSaveDataInfo, UserMaxContentMetaCount, std::addressof(g_sd_and_user_content_meta_memory_resource)));
/* Beyond this point, N uses hardcoded indices. */
/* Next SdCard's content storage and content meta entries. */
R_TRY(this->InitializeContentStorageRoot(&this->content_storage_roots[2], StorageId::SdCard, fs::ContentStorageId::SdCard));
R_TRY(this->InitializeContentMetaDatabaseRoot(&this->content_meta_database_roots[2], StorageId::SdCard, SdCardSystemSaveDataInfo, SdCardMaxContentMetaCount, std::addressof(g_sd_and_user_content_meta_memory_resource)));
R_TRY(this->InitializeContentStorageRoot(std::addressof(this->content_storage_roots[2]), StorageId::SdCard, fs::ContentStorageId::SdCard));
R_TRY(this->InitializeContentMetaDatabaseRoot(std::addressof(this->content_meta_database_roots[2]), StorageId::SdCard, SdCardSystemSaveDataInfo, SdCardMaxContentMetaCount, std::addressof(g_sd_and_user_content_meta_memory_resource)));
/* GameCard's content storage and content meta entries. */
/* N doesn't set a content storage id for game cards, so we'll just use 0 (System). */
R_TRY(this->InitializeGameCardContentStorageRoot(&this->content_storage_roots[3]));
R_TRY(this->InitializeGameCardContentMetaDatabaseRoot(&this->content_meta_database_roots[3], GameCardMaxContentMetaCount, std::addressof(g_gamecard_content_meta_memory_resource)));
R_TRY(this->InitializeGameCardContentStorageRoot(std::addressof(this->content_storage_roots[3])));
R_TRY(this->InitializeGameCardContentMetaDatabaseRoot(std::addressof(this->content_meta_database_roots[3]), GameCardMaxContentMetaCount, std::addressof(g_gamecard_content_meta_memory_resource)));
this->initialized = true;
return ResultSuccess();
@@ -408,7 +408,7 @@ namespace ams::ncm {
/* Obtain the content meta database root. */
ContentMetaDatabaseRoot *root;
R_TRY(this->GetContentMetaDatabaseRoot(&root, storage_id));
R_TRY(this->GetContentMetaDatabaseRoot(std::addressof(root), storage_id));
/* Mount (and optionally create) save data for the root. */
R_TRY(this->EnsureAndMountSystemSaveData(root->mount_name, root->info));
@@ -449,7 +449,7 @@ namespace ams::ncm {
/* Obtain the content meta database root. */
ContentMetaDatabaseRoot *root;
R_TRY(this->GetContentMetaDatabaseRoot(&root, storage_id));
R_TRY(this->GetContentMetaDatabaseRoot(std::addressof(root), storage_id));
/* Mount save data for non-existing content meta databases. */
const bool mount = !root->content_meta_database;
@@ -460,7 +460,7 @@ namespace ams::ncm {
/* Ensure the root path exists. */
bool has_dir = false;
R_TRY(fs::HasDirectory(&has_dir, root->path));
R_TRY(fs::HasDirectory(std::addressof(has_dir), root->path));
R_UNLESS(has_dir, ncm::ResultInvalidContentMetaDatabase());
return ResultSuccess();
@@ -492,7 +492,7 @@ namespace ams::ncm {
/* Obtain the content meta database root. */
ContentMetaDatabaseRoot *root;
R_TRY(this->GetContentMetaDatabaseRoot(&root, storage_id));
R_TRY(this->GetContentMetaDatabaseRoot(std::addressof(root), storage_id));
if (hos::GetVersion() >= hos::Version_2_0_0) {
/* Obtain the content meta database if already active. */
@@ -524,7 +524,7 @@ namespace ams::ncm {
/* Obtain the content meta database root. */
ContentMetaDatabaseRoot *root;
R_TRY(this->GetContentMetaDatabaseRoot(&root, storage_id));
R_TRY(this->GetContentMetaDatabaseRoot(std::addressof(root), storage_id));
/* Delete save data for the content meta database root. */
return fs::DeleteSaveData(root->info.space_id, root->info.id);
@@ -614,7 +614,7 @@ namespace ams::ncm {
/* Obtain the content meta database root. */
ContentMetaDatabaseRoot *root;
R_TRY(this->GetContentMetaDatabaseRoot(&root, storage_id));
R_TRY(this->GetContentMetaDatabaseRoot(std::addressof(root), storage_id));
/* Already activated. */
R_SUCCEED_IF(root->content_meta_database != nullptr);
@@ -652,7 +652,7 @@ namespace ams::ncm {
/* Obtain the content meta database root. */
ContentMetaDatabaseRoot *root;
R_TRY(this->GetContentMetaDatabaseRoot(&root, storage_id));
R_TRY(this->GetContentMetaDatabaseRoot(std::addressof(root), storage_id));
/* Disable the content meta database, if present. */
if (root->content_meta_database != nullptr) {

View File

@@ -88,7 +88,7 @@ namespace ams::ncm {
/* Call the process function. */
bool should_continue = true;
bool should_retry_dir_read = false;
R_TRY(f(&should_continue, &should_retry_dir_read, current_path, entry));
R_TRY(f(std::addressof(should_continue), std::addressof(should_retry_dir_read), current_path, entry));
/* If the provided function wishes to terminate immediately, we should respect it. */
if (!should_continue) {
@@ -368,7 +368,7 @@ namespace ams::ncm {
MakeContentPath(std::addressof(path), content_id, this->make_content_path_func, this->root_path);
/* Open the content file and store to the cache. */
R_TRY_CATCH(fs::OpenFile(&this->cached_file_handle, path, fs::OpenMode_Read)) {
R_TRY_CATCH(fs::OpenFile(std::addressof(this->cached_file_handle), path, fs::OpenMode_Read)) {
R_CONVERT(ams::fs::ResultPathNotFound, ncm::ResultContentNotFound())
} R_END_TRY_CATCH;
@@ -416,7 +416,7 @@ namespace ams::ncm {
/* Check if placeholder file exists. */
bool has = false;
R_TRY(fs::HasFile(&has, placeholder_path));
R_TRY(fs::HasFile(std::addressof(has), placeholder_path));
out.SetValue(has);
return ResultSuccess();
}
@@ -464,7 +464,7 @@ namespace ams::ncm {
/* Check if the content file exists. */
bool has = false;
R_TRY(fs::HasFile(&has, content_path));
R_TRY(fs::HasFile(std::addressof(has), content_path));
out.SetValue(has);
return ResultSuccess();
}
@@ -714,7 +714,7 @@ namespace ams::ncm {
Result ContentStorageImpl::GetRightsIdFromPlaceHolderIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, PlaceHolderId placeholder_id) {
/* Obtain the regular rights id for the placeholder id. */
ncm::RightsId rights_id;
R_TRY(this->GetRightsIdFromPlaceHolderId(&rights_id, placeholder_id));
R_TRY(this->GetRightsIdFromPlaceHolderId(std::addressof(rights_id), placeholder_id));
/* Output the fs rights id. */
out_rights_id.SetValue(rights_id.id);
@@ -735,7 +735,7 @@ namespace ams::ncm {
Result ContentStorageImpl::GetRightsIdFromContentIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, ContentId content_id) {
/* Obtain the regular rights id for the content id. */
ncm::RightsId rights_id;
R_TRY(this->GetRightsIdFromContentId(&rights_id, content_id));
R_TRY(this->GetRightsIdFromContentId(std::addressof(rights_id), content_id));
/* Output the fs rights id. */
out_rights_id.SetValue(rights_id.id);
@@ -893,7 +893,7 @@ namespace ams::ncm {
/* Get the rights id. */
ncm::RightsId rights_id;
R_TRY(GetRightsId(&rights_id, common_path));
R_TRY(GetRightsId(std::addressof(rights_id), common_path));
this->rights_id_cache->Store(cache_content_id, rights_id);
/* Set output. */

View File

@@ -137,7 +137,7 @@ namespace ams::ncm {
Result HostContentStorageImpl::GetRightsIdFromContentIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, ContentId content_id) {
/* Obtain the regular rights id for the content id. */
ncm::RightsId rights_id;
R_TRY(this->GetRightsIdFromContentId(&rights_id, content_id));
R_TRY(this->GetRightsIdFromContentId(std::addressof(rights_id), content_id));
/* Output the fs rights id. */
out_rights_id.SetValue(rights_id.id);

View File

@@ -206,7 +206,7 @@ namespace ams::ncm {
/* Open the relevant content storage. */
ContentStorage content_storage;
R_TRY(ncm::OpenContentStorage(&content_storage, storage_id));
R_TRY(ncm::OpenContentStorage(std::addressof(content_storage), storage_id));
/* Iterate over content infos. */
for (size_t i = 0; i < reader.GetContentCount(); i++) {
@@ -464,7 +464,7 @@ namespace ams::ncm {
/* Open the content storage for this meta. */
ContentStorage content_storage;
R_TRY(OpenContentStorage(&content_storage, storage_id));
R_TRY(OpenContentStorage(std::addressof(content_storage), storage_id));
/* Open the content meta database for this meta. */
ContentMetaDatabase meta_db;
@@ -546,7 +546,7 @@ namespace ams::ncm {
/* Open the content storage for the content info. */
ContentStorage content_storage;
R_TRY(OpenContentStorage(&content_storage, content_info->storage_id));
R_TRY(OpenContentStorage(std::addressof(content_storage), content_info->storage_id));
/* Write data to the placeholder. */
R_TRY(content_storage.WritePlaceHolder(content_info->placeholder_id, content_info->written, data, data_size));
@@ -658,7 +658,7 @@ namespace ams::ncm {
/* Open the relevant content storage. */
ContentStorage content_storage;
R_TRY(ncm::OpenContentStorage(&content_storage, storage_id));
R_TRY(ncm::OpenContentStorage(std::addressof(content_storage), storage_id));
/* Update the storage id in the header. */
auto writer = content_meta.GetWriter();
@@ -670,7 +670,7 @@ namespace ams::ncm {
/* Check if we have the content already exists. */
bool has_content;
R_TRY(content_storage.Has(&has_content, content_info->GetId()));
R_TRY(content_storage.Has(std::addressof(has_content), content_info->GetId()));
if (has_content) {
/* Add the size of installed content infos to the total size. */
@@ -739,7 +739,7 @@ namespace ams::ncm {
Result InstallTaskBase::PrepareContentMeta(const InstallContentMetaInfo &meta_info, util::optional<ContentMetaKey> expected_key, util::optional<u32> source_version) {
/* Open the BuiltInSystem content storage. */
ContentStorage content_storage;
R_TRY(OpenContentStorage(&content_storage, StorageId::BuiltInSystem));
R_TRY(OpenContentStorage(std::addressof(content_storage), StorageId::BuiltInSystem));
/* Write content meta to a placeholder. */
InstallContentInfo content_info;
@@ -1104,7 +1104,7 @@ namespace ams::ncm {
/* Open the content storage. */
ContentStorage content_storage;
R_TRY(ncm::OpenContentStorage(&content_storage, storage_id));
R_TRY(ncm::OpenContentStorage(std::addressof(content_storage), storage_id));
/* Iterate over content meta. */
for (s32 i = 0; i < count; i++) {
@@ -1162,7 +1162,7 @@ namespace ams::ncm {
/* Open the BuiltInSystem content storage. */
ContentStorage content_storage;
R_TRY(ncm::OpenContentStorage(&content_storage, StorageId::BuiltInSystem));
R_TRY(ncm::OpenContentStorage(std::addressof(content_storage), StorageId::BuiltInSystem));
/* Write content meta to a placeholder. */
InstallContentInfo content_info;
@@ -1375,7 +1375,7 @@ namespace ams::ncm {
/* Open the relevant content storage. */
ContentStorage content_storage;
R_TRY(ncm::OpenContentStorage(&content_storage, content_info->storage_id));
R_TRY(ncm::OpenContentStorage(std::addressof(content_storage), content_info->storage_id));
/* Get the rights id. */
RightsId rights_id;

View File

@@ -137,7 +137,7 @@ namespace ams::ncm {
/* Attempt to find a cache entry with the same placeholder id. */
for (size_t i = 0; i < MaxCacheEntries; i++) {
if (placeholder_id == this->caches[i].id) {
return &this->caches[i];
return std::addressof(this->caches[i]);
}
}
return nullptr;

View File

@@ -224,7 +224,7 @@ namespace ams::ncm {
Result ReadOnlyContentStorageImpl::GetRightsIdFromContentIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, ContentId content_id) {
/* Obtain the regular rights id for the content id. */
ncm::RightsId rights_id;
R_TRY(this->GetRightsIdFromContentId(&rights_id, content_id));
R_TRY(this->GetRightsIdFromContentId(std::addressof(rights_id), content_id));
/* Output the fs rights id. */
out_rights_id.SetValue(rights_id.id);
@@ -240,7 +240,7 @@ namespace ams::ncm {
/* Get the rights id. */
ncm::RightsId rights_id;
R_TRY(GetRightsId(&rights_id, path));
R_TRY(GetRightsId(std::addressof(rights_id), path));
out_rights_id.SetValue(rights_id);
return ResultSuccess();