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

@@ -21,19 +21,19 @@ namespace ams::lr {
Result AddOnContentLocationResolverImpl::ResolveAddOnContentPath(sf::Out<Path> out, ncm::DataId id) {
/* Find a storage that contains the given program id. */
ncm::StorageId storage_id = ncm::StorageId::None;
R_UNLESS(this->registered_storages.Find(&storage_id, id), lr::ResultAddOnContentNotFound());
R_UNLESS(this->registered_storages.Find(std::addressof(storage_id), id), lr::ResultAddOnContentNotFound());
/* Obtain a content meta database for the storage id. */
ncm::ContentMetaDatabase content_meta_database;
R_TRY(ncm::OpenContentMetaDatabase(&content_meta_database, storage_id));
R_TRY(ncm::OpenContentMetaDatabase(std::addressof(content_meta_database), storage_id));
/* Find the latest data content id for the given program id. */
ncm::ContentId data_content_id;
R_TRY(content_meta_database.GetLatestData(&data_content_id, id));
R_TRY(content_meta_database.GetLatestData(std::addressof(data_content_id), id));
/* Obtain a content storage for the storage id. */
ncm::ContentStorage content_storage;
R_TRY(ncm::OpenContentStorage(&content_storage, storage_id));
R_TRY(ncm::OpenContentStorage(std::addressof(content_storage), storage_id));
/* Get the path of the data content. */
static_assert(sizeof(lr::Path) == sizeof(ncm::Path));

View File

@@ -34,7 +34,7 @@ namespace ams::lr {
/* Find the latest program content for the program id. */
ncm::ContentId program_content_id;
R_TRY_CATCH(this->content_meta_database.GetLatestProgram(&program_content_id, id)) {
R_TRY_CATCH(this->content_meta_database.GetLatestProgram(std::addressof(program_content_id), id)) {
R_CONVERT(ncm::ResultContentMetaNotFound, lr::ResultProgramNotFound())
} R_END_TRY_CATCH;
@@ -62,7 +62,7 @@ namespace ams::lr {
Result ContentLocationResolverImpl::ResolveDataPath(sf::Out<Path> out, ncm::DataId id) {
/* Find the latest data content for the program id. */
ncm::ContentId data_content_id;
R_TRY(this->content_meta_database.GetLatestData(&data_content_id, id));
R_TRY(this->content_meta_database.GetLatestData(std::addressof(data_content_id), id));
/* Obtain the content path. */
this->GetContentStoragePath(out.GetPointer(), data_content_id);
@@ -109,8 +109,8 @@ namespace ams::lr {
/* 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));
R_TRY(ncm::OpenContentStorage(&storage, this->storage_id));
R_TRY(ncm::OpenContentMetaDatabase(std::addressof(meta_db), this->storage_id));
R_TRY(ncm::OpenContentStorage(std::addressof(storage), this->storage_id));
/* Store the acquired objects. */
this->content_meta_database = std::move(meta_db);

View File

@@ -84,13 +84,13 @@ namespace ams::lr {
}
}
void LocationRedirector::EraseRedirection(ncm::ProgramId program_id)
{
void LocationRedirector::EraseRedirection(ncm::ProgramId program_id) {
/* Remove any redirections with a matching program id. */
for (auto &redirection : this->redirection_list) {
if (redirection.GetProgramId() == program_id) {
this->redirection_list.erase(this->redirection_list.iterator_to(redirection));
delete &redirection;
for (auto it = this->redirection_list.begin(); it != this->redirection_list.end();) {
if (it->GetProgramId() == program_id) {
auto *redirection = std::addressof(*it);
this->redirection_list.erase(it);
delete redirection;
break;
}
}
@@ -100,9 +100,9 @@ namespace ams::lr {
/* 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;
auto *redirection = std::addressof(*it);
it = this->redirection_list.erase(it);
delete std::addressof(*old);
delete redirection;
} else {
it++;
}
@@ -118,9 +118,9 @@ namespace ams::lr {
}
/* Remove the redirection. */
auto old = it;
auto *redirection = std::addressof(*it);
it = this->redirection_list.erase(it);
delete std::addressof(*old);
delete redirection;
}
}

View File

@@ -24,7 +24,7 @@ namespace ams::lr {
public:
RemoteLocationResolverImpl(::LrLocationResolver &l) : srv(l) { /* ... */ }
~RemoteLocationResolverImpl() { ::serviceClose(&srv.s); }
~RemoteLocationResolverImpl() { ::serviceClose(std::addressof(srv.s)); }
public:
/* Actual commands. */
Result ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id) {

View File

@@ -25,7 +25,7 @@ namespace ams::lr {
public:
RemoteRegisteredLocationResolverImpl(::LrRegisteredLocationResolver &l) : srv(l) { /* ... */ }
~RemoteRegisteredLocationResolverImpl() { ::serviceClose(&srv.s); }
~RemoteRegisteredLocationResolverImpl() { ::serviceClose(std::addressof(srv.s)); }
public:
/* Actual commands. */
Result ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id) {