From 1ab0bd176568b9acdbad3a52b917feeb043f5636 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sat, 9 Oct 2021 14:49:53 -0700 Subject: [PATCH] ams: replace most remaining operator & with std::addressof --- .../mariko_fatal/source/fatal_display.cpp | 2 +- .../source/kern_k_resource_limit.cpp | 2 +- .../libmesosphere/source/kern_k_thread.cpp | 2 +- .../source/kern_k_thread_local_page.cpp | 2 +- libraries/libstratosphere/Makefile | 4 ++ .../include/stratosphere/cfg/cfg_types.hpp | 2 +- .../stratosphere/fs/fs_remote_filesystem.hpp | 4 +- .../fssystem/fssystem_utility.hpp | 6 +- .../kvdb/kvdb_file_key_value_cache.hpp | 4 +- .../kvdb/kvdb_file_key_value_store.hpp | 12 ++-- .../kvdb/kvdb_memory_key_value_store.hpp | 12 ++-- .../stratosphere/ncm/ncm_rights_id_cache.hpp | 6 +- .../include/stratosphere/rapidjson.hpp | 2 +- .../include/stratosphere/ro/ro_types.hpp | 2 +- .../sf/cmif/sf_cmif_domain_service_object.hpp | 4 +- .../sf/cmif/sf_cmif_service_dispatch.hpp | 4 +- .../sf/impl/sf_impl_command_serialization.hpp | 8 +-- .../include/stratosphere/sm/sm_types.hpp | 2 +- .../source/ams/ams_emummc_api.cpp | 4 +- .../source/ams/ams_environment.cpp | 4 +- .../source/ams/ams_exosphere_api.cpp | 2 +- .../source/boot2/boot2_api.cpp | 18 +++--- .../jpeg/decodersrv_software_jpeg_decoder.cpp | 4 +- .../source/cfg/cfg_override.cpp | 6 +- .../source/cfg/cfg_sd_card.cpp | 6 +- .../fssrv_filesystem_interface_adapter.cpp | 8 +-- .../fssrv/fssrv_storage_interface_adapter.cpp | 2 +- ...fssystem_directory_savedata_filesystem.cpp | 12 ++-- .../source/fssystem/fssystem_utility.cpp | 8 +-- .../source/kvdb/kvdb_archive.cpp | 10 ++-- .../libstratosphere/source/ldr/ldr_pm_api.cpp | 8 +-- .../source/lm/lm_remote_log_service.cpp | 4 +- .../source/lm/lm_remote_log_service.hpp | 4 +- .../source/lmem/impl/lmem_impl_exp_heap.cpp | 40 ++++++------- .../source/lmem/impl/lmem_impl_unit_heap.cpp | 8 +-- ..._add_on_content_location_resolver_impl.cpp | 8 +-- .../lr/lr_content_location_resolver_impl.cpp | 8 +-- .../source/lr/lr_location_redirector.cpp | 20 +++---- .../lr/lr_remote_location_resolver_impl.hpp | 2 +- ...mote_registered_location_resolver_impl.hpp | 2 +- .../source/ncm/ncm_content_manager_impl.cpp | 32 +++++----- .../source/ncm/ncm_content_storage_impl.cpp | 14 ++--- .../ncm/ncm_host_content_storage_impl.cpp | 2 +- .../source/ncm/ncm_install_task_base.cpp | 18 +++--- .../source/ncm/ncm_placeholder_accessor.cpp | 2 +- .../ncm_read_only_content_storage_impl.cpp | 4 +- .../source/os/impl/os_multiple_wait_impl.cpp | 11 ++-- .../os/impl/os_multiple_wait_object_list.hpp | 2 +- .../os_rw_lock_target_impl.os.horizon.cpp | 2 +- .../source/os/os_multiple_wait.cpp | 2 +- .../libstratosphere/source/os/os_random.cpp | 4 +- .../source/patcher/patcher_api.cpp | 4 +- .../source/pm/pm_boot_mode_api.cpp | 2 +- .../libstratosphere/source/pm/pm_dmnt_api.cpp | 2 +- .../libstratosphere/source/pm/pm_info_api.cpp | 6 +- .../source/pm/pm_info_api_weak.cpp | 2 +- .../source/pm/pm_shell_api.cpp | 2 +- .../source/sf/cmif/sf_cmif_domain_manager.cpp | 4 +- .../sf/cmif/sf_cmif_domain_service_object.cpp | 8 +-- .../sf_hipc_server_domain_session_manager.cpp | 6 +- .../source/sf/hipc/sf_hipc_server_manager.cpp | 6 +- .../hipc/sf_hipc_server_session_manager.cpp | 18 +++--- .../source/sm/sm_manager_api.cpp | 2 +- .../libstratosphere/source/sm/sm_utils.hpp | 12 ++-- .../source/spl/smc/spl_smc.cpp | 8 +-- .../source/updater/updater_api.cpp | 18 +++--- .../source/updater/updater_bis_management.hpp | 2 +- .../libstratosphere/source/util/util_ini.cpp | 4 +- .../vapours/util/util_intrusive_list.hpp | 30 +++++----- .../include/vapours/util/util_tinymt.hpp | 10 ++-- .../crypto/impl/crypto_bignum_operations.cpp | 2 +- .../libvapours/source/dd/dd_io_mapping.cpp | 6 +- .../ams_mitm/source/amsmitm_fs_utils.cpp | 44 +++++++------- .../source/amsmitm_initialization.cpp | 8 +-- .../source/amsmitm_prodinfo_utils.cpp | 18 +++--- .../source/bpc_mitm/bpc_ams_power_utils.cpp | 6 +- .../source/bpc_mitm/bpc_ams_service.cpp | 2 +- .../source/dns_mitm/dnsmitm_resolver_impl.cpp | 2 +- .../source/fs_mitm/fs_mitm_service.cpp | 60 +++++++++---------- .../fs_mitm/fsmitm_layered_romfs_storage.cpp | 14 ++--- .../ams_mitm/source/fs_mitm/fsmitm_romfs.cpp | 46 +++++++------- .../source/ns_mitm/ns_web_mitm_service.cpp | 6 +- .../source/set_mitm/settings_sd_kvs.cpp | 22 +++---- .../creport/source/creport_modules.cpp | 18 +++--- .../creport/source/creport_threads.cpp | 48 +++++++-------- .../dmnt/source/cheat/impl/dmnt_cheat_api.cpp | 38 ++++++------ .../dmnt/source/cheat/impl/dmnt_cheat_vm.cpp | 22 +++---- stratosphere/fatal/source/fatal_config.cpp | 14 ++--- stratosphere/fatal/source/fatal_debug.cpp | 18 +++--- stratosphere/fatal/source/fatal_font.cpp | 20 +++---- stratosphere/fatal/source/fatal_repair.cpp | 12 ++-- stratosphere/fatal/source/fatal_service.cpp | 6 +- .../fatal/source/fatal_task_clock.cpp | 10 ++-- .../fatal/source/fatal_task_error_report.cpp | 6 +- .../fatal/source/fatal_task_power.cpp | 14 ++--- .../fatal/source/fatal_task_screen.cpp | 46 +++++++------- .../fatal/source/fatal_task_sound.cpp | 12 ++-- .../loader/source/ldr_loader_service.cpp | 4 +- stratosphere/loader/source/ldr_meta.cpp | 14 ++--- stratosphere/loader/source/ldr_patcher.cpp | 6 +- .../loader/source/ldr_process_creation.cpp | 20 +++---- .../pm/source/impl/pm_process_info.cpp | 2 +- .../pm/source/impl/pm_process_info.hpp | 8 +-- .../pm/source/impl/pm_process_manager.cpp | 20 +++---- stratosphere/pm/source/pm_main.cpp | 4 +- .../ro/source/impl/ro_service_impl.cpp | 20 +++---- .../sm/source/impl/sm_service_manager.cpp | 4 +- stratosphere/spl/source/spl_api_impl.cpp | 30 +++++----- stratosphere/spl/source/spl_ctr_drbg.cpp | 14 ++--- 109 files changed, 587 insertions(+), 586 deletions(-) diff --git a/exosphere/mariko_fatal/source/fatal_display.cpp b/exosphere/mariko_fatal/source/fatal_display.cpp index 83cf05740..f315abe2a 100644 --- a/exosphere/mariko_fatal/source/fatal_display.cpp +++ b/exosphere/mariko_fatal/source/fatal_display.cpp @@ -221,7 +221,7 @@ namespace ams::secmon::fatal { const int prefix_len = std::strlen(automatic_backups_prefix); for (size_t i = 0; i + prefix_len < f_ctx->stack_dump_size; ++i) { - if (std::memcmp(&f_ctx->stack_dump[i], automatic_backups_prefix, prefix_len) == 0) { + if (std::memcmp(f_ctx->stack_dump + i, automatic_backups_prefix, prefix_len) == 0) { suggestion = "The atmosphere directory may improperly have archive bits set.\n" "Please try running an archive bit fixer tool (for example, the one in Hekate).\n"; break; diff --git a/libraries/libmesosphere/source/kern_k_resource_limit.cpp b/libraries/libmesosphere/source/kern_k_resource_limit.cpp index 0727a1461..22438ad74 100644 --- a/libraries/libmesosphere/source/kern_k_resource_limit.cpp +++ b/libraries/libmesosphere/source/kern_k_resource_limit.cpp @@ -182,7 +182,7 @@ namespace ams::kern { if (m_current_hints[which] + value <= m_limit_values[which] && (timeout < 0 || KHardwareTimer::GetTick() < timeout)) { m_waiter_count++; - m_cond_var.Wait(&m_lock, timeout, false); + m_cond_var.Wait(std::addressof(m_lock), timeout, false); m_waiter_count--; if (GetCurrentThread().IsTerminationRequested()) { diff --git a/libraries/libmesosphere/source/kern_k_thread.cpp b/libraries/libmesosphere/source/kern_k_thread.cpp index a457879c6..49519dd2b 100644 --- a/libraries/libmesosphere/source/kern_k_thread.cpp +++ b/libraries/libmesosphere/source/kern_k_thread.cpp @@ -39,7 +39,7 @@ namespace ams::kern { const uintptr_t stack_bottom = stack_top - PageSize; KPhysicalAddress stack_paddr = Null; - MESOSPHERE_ABORT_UNLESS(Kernel::GetKernelPageTable().GetPhysicalAddress(&stack_paddr, stack_bottom)); + MESOSPHERE_ABORT_UNLESS(Kernel::GetKernelPageTable().GetPhysicalAddress(std::addressof(stack_paddr), stack_bottom)); MESOSPHERE_R_ABORT_UNLESS(Kernel::GetKernelPageTable().UnmapPages(stack_bottom, 1, KMemoryState_Kernel)); diff --git a/libraries/libmesosphere/source/kern_k_thread_local_page.cpp b/libraries/libmesosphere/source/kern_k_thread_local_page.cpp index 9fcfea2c6..9d2105ce5 100644 --- a/libraries/libmesosphere/source/kern_k_thread_local_page.cpp +++ b/libraries/libmesosphere/source/kern_k_thread_local_page.cpp @@ -41,7 +41,7 @@ namespace ams::kern { /* Get the physical address of the page. */ KPhysicalAddress phys_addr = Null; - MESOSPHERE_ABORT_UNLESS(m_owner->GetPageTable().GetPhysicalAddress(&phys_addr, this->GetAddress())); + MESOSPHERE_ABORT_UNLESS(m_owner->GetPageTable().GetPhysicalAddress(std::addressof(phys_addr), this->GetAddress())); /* Unmap the page. */ R_TRY(m_owner->GetPageTable().UnmapPages(this->GetAddress(), 1, KMemoryState_ThreadLocal)); diff --git a/libraries/libstratosphere/Makefile b/libraries/libstratosphere/Makefile index a01800fc5..c6dfa2e93 100644 --- a/libraries/libstratosphere/Makefile +++ b/libraries/libstratosphere/Makefile @@ -129,6 +129,10 @@ hos_stratosphere_api.o: CXXFLAGS += -fno-lto init_operator_new.o: CXXFLAGS += -fno-lto init_libnx_shim.os.horizon.o: CXXFLAGS += -fno-lto +usb_remote_ds_endpoint.o: CXXFLAGS += -Wno-error=deprecated-declarations +usb_remote_ds_interface.o: CXXFLAGS += -Wno-error=deprecated-declarations +usb_remote_ds_service.o: CXXFLAGS += -Wno-error=deprecated-declarations + #--------------------------------------------------------------------------------- %_bin.h %.bin.o : %.bin #--------------------------------------------------------------------------------- diff --git a/libraries/libstratosphere/include/stratosphere/cfg/cfg_types.hpp b/libraries/libstratosphere/include/stratosphere/cfg/cfg_types.hpp index 7df965aff..8c8ee368e 100644 --- a/libraries/libstratosphere/include/stratosphere/cfg/cfg_types.hpp +++ b/libraries/libstratosphere/include/stratosphere/cfg/cfg_types.hpp @@ -63,7 +63,7 @@ namespace ams::cfg { static_assert(util::is_pod::value, "util::is_pod::value"); constexpr inline bool operator==(const OverrideStatus &lhs, const OverrideStatus &rhs) { - return std::memcmp(&lhs, &rhs, sizeof(lhs)) == 0; + return std::memcmp(std::addressof(lhs), std::addressof(rhs), sizeof(lhs)) == 0; } constexpr inline bool operator!=(const OverrideStatus &lhs, const OverrideStatus &rhs) { diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_remote_filesystem.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_remote_filesystem.hpp index 456664470..19e658539 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_remote_filesystem.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_remote_filesystem.hpp @@ -169,7 +169,7 @@ namespace ams::fs { R_TRY(GetPathForServiceObject(std::addressof(sf_path), path)); FsFile f; - R_TRY(fsFsOpenFile(std::addressof(this->base_fs), sf_path.str, mode, &f)); + R_TRY(fsFsOpenFile(std::addressof(this->base_fs), sf_path.str, mode, std::addressof(f))); auto file = std::make_unique(f); R_UNLESS(file != nullptr, fs::ResultAllocationFailureInNew()); @@ -183,7 +183,7 @@ namespace ams::fs { R_TRY(GetPathForServiceObject(std::addressof(sf_path), path)); FsDir d; - R_TRY(fsFsOpenDirectory(std::addressof(this->base_fs), sf_path.str, mode, &d)); + R_TRY(fsFsOpenDirectory(std::addressof(this->base_fs), sf_path.str, mode, std::addressof(d))); auto dir = std::make_unique(d); R_UNLESS(dir != nullptr, fs::ResultAllocationFailureInNew()); diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_utility.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_utility.hpp index 1a0d3bf3a..0255d6277 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_utility.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_utility.hpp @@ -29,7 +29,7 @@ namespace ams::fssystem { Result IterateDirectoryRecursivelyImpl(fs::fsa::IFileSystem *fs, char *work_path, size_t work_path_size, fs::DirectoryEntry *dir_ent, OnEnterDir on_enter_dir, OnExitDir on_exit_dir, OnFile on_file) { /* Open the directory. */ std::unique_ptr dir; - R_TRY(fs->OpenDirectory(&dir, work_path, fs::OpenDirectoryMode_All)); + R_TRY(fs->OpenDirectory(std::addressof(dir), work_path, fs::OpenDirectoryMode_All)); const size_t parent_len = strnlen(work_path, work_path_size - 1); @@ -37,7 +37,7 @@ namespace ams::fssystem { while (true) { /* Read a single entry. */ s64 read_count = 0; - R_TRY(dir->Read(&read_count, dir_ent, 1)); + R_TRY(dir->Read(std::addressof(read_count), dir_ent, 1)); /* If we're out of entries, we're done. */ if (read_count == 0) { @@ -106,7 +106,7 @@ namespace ams::fssystem { Result IterateDirectoryRecursively(fs::fsa::IFileSystem *fs, const char *root_path, OnEnterDir on_enter_dir, OnExitDir on_exit_dir, OnFile on_file) { fs::DirectoryEntry dir_entry = {}; char work_path[fs::EntryNameLengthMax + 1] = {}; - return IterateDirectoryRecursively(fs, root_path, work_path, sizeof(work_path), &dir_entry, on_enter_dir, on_exit_dir, on_file); + return IterateDirectoryRecursively(fs, root_path, work_path, sizeof(work_path), std::addressof(dir_entry), on_enter_dir, on_exit_dir, on_file); } template diff --git a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_cache.hpp b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_cache.hpp index adcb0113c..1731524d5 100644 --- a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_cache.hpp +++ b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_cache.hpp @@ -245,8 +245,8 @@ namespace ams::kvdb { static Result ValidateExistingCache(const char *dir) { /* Check for existence. */ bool has_lru = false, has_kvs = false; - R_TRY(FileExists(&has_lru, GetLeastRecentlyUsedListPath(dir))); - R_TRY(DirectoryExists(&has_kvs, GetFileKeyValueStorePath(dir))); + R_TRY(FileExists(std::addressof(has_lru), GetLeastRecentlyUsedListPath(dir))); + R_TRY(DirectoryExists(std::addressof(has_kvs), GetFileKeyValueStorePath(dir))); /* If neither exists, CreateNewCache was never called. */ R_UNLESS(has_lru || has_kvs, kvdb::ResultNotCreated()); diff --git a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_store.hpp b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_store.hpp index 461193dd6..5ac396272 100644 --- a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_store.hpp +++ b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_store.hpp @@ -84,38 +84,38 @@ namespace ams::kvdb { template Result Get(size_t *out_size, void *out_value, size_t max_out_size, const Key &key) { static_assert(util::is_pod::value && sizeof(Key) <= MaxKeySize, "Invalid FileKeyValueStore Key!"); - return this->Get(out_size, out_value, max_out_size, &key, sizeof(Key)); + return this->Get(out_size, out_value, max_out_size, std::addressof(key), sizeof(Key)); } template Result Get(Value *out_value, const Key &key) { static_assert(util::is_pod::value && !std::is_pointer::value, "Invalid FileKeyValueStore Value!"); size_t size = 0; - R_TRY(this->Get(&size, out_value, sizeof(Value), key)); + R_TRY(this->Get(std::addressof(size), out_value, sizeof(Value), key)); AMS_ABORT_UNLESS(size >= sizeof(Value)); return ResultSuccess(); } template Result GetSize(size_t *out_size, const Key &key) { - return this->GetSize(out_size, &key, sizeof(Key)); + return this->GetSize(out_size, std::addressof(key), sizeof(Key)); } template Result Set(const Key &key, const void *value, size_t value_size) { static_assert(util::is_pod::value && sizeof(Key) <= MaxKeySize, "Invalid FileKeyValueStore Key!"); - return this->Set(&key, sizeof(Key), value, value_size); + return this->Set(std::addressof(key), sizeof(Key), value, value_size); } template Result Set(const Key &key, const Value &value) { static_assert(util::is_pod::value && !std::is_pointer::value, "Invalid FileKeyValueStore Value!"); - return this->Set(key, &value, sizeof(Value)); + return this->Set(key, std::addressof(value), sizeof(Value)); } template Result Remove(const Key &key) { - return this->Remove(&key, sizeof(Key)); + return this->Remove(std::addressof(key), sizeof(Key)); } }; diff --git a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_memory_key_value_store.hpp b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_memory_key_value_store.hpp index 6393eca50..2bce9b83c 100644 --- a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_memory_key_value_store.hpp +++ b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_memory_key_value_store.hpp @@ -306,7 +306,7 @@ namespace ams::kvdb { /* Try to read the archive -- note, path not found is a success condition. */ /* This is because no archive file = no entries, so we're in the right state. */ AutoBuffer buffer; - R_TRY_CATCH(this->ReadArchiveFile(&buffer)) { + R_TRY_CATCH(this->ReadArchiveFile(std::addressof(buffer))) { R_CONVERT(fs::ResultPathNotFound, ResultSuccess()); } R_END_TRY_CATCH; @@ -315,12 +315,12 @@ namespace ams::kvdb { ArchiveReader reader(buffer); size_t entry_count = 0; - R_TRY(reader.ReadEntryCount(&entry_count)); + R_TRY(reader.ReadEntryCount(std::addressof(entry_count))); for (size_t i = 0; i < entry_count; i++) { /* Get size of key/value. */ size_t key_size = 0, value_size = 0; - R_TRY(reader.GetEntrySize(&key_size, &value_size)); + R_TRY(reader.GetEntrySize(std::addressof(key_size), std::addressof(value_size))); /* Allocate memory for value. */ void *new_value = this->memory_resource->Allocate(value_size); @@ -329,7 +329,7 @@ namespace ams::kvdb { /* Read key and value. */ Key key; - R_TRY(reader.ReadEntry(&key, sizeof(key), new_value, value_size)); + R_TRY(reader.ReadEntry(std::addressof(key), sizeof(key), new_value, value_size)); R_TRY(this->index.AddUnsafe(key, new_value, value_size)); /* We succeeded, so cancel the value guard to prevent deallocation. */ @@ -351,7 +351,7 @@ namespace ams::kvdb { writer.WriteHeader(this->GetCount()); for (const auto &it : this->index) { const auto &key = it.GetKey(); - writer.WriteEntry(&key, sizeof(Key), it.GetValuePointer(), it.GetValueSize()); + writer.WriteEntry(std::addressof(key), sizeof(Key), it.GetValuePointer(), it.GetValueSize()); } } @@ -367,7 +367,7 @@ namespace ams::kvdb { Result Set(const Key &key, const Value &value) { /* Only allow setting pod. */ static_assert(util::is_pod::value, "KeyValueStore Values must be pod"); - return this->Set(key, &value, sizeof(Value)); + return this->Set(key, std::addressof(value), sizeof(Value)); } template 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 b137818e0..381789b1b 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_rights_id_cache.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_rights_id_cache.hpp @@ -50,11 +50,11 @@ namespace ams::ncm { void Store(ContentId content_id, ncm::RightsId rights_id) { std::scoped_lock lk(this->mutex); - Entry *eviction_candidate = &this->entries[0]; + Entry *eviction_candidate = std::addressof(this->entries[0]); /* Find a suitable existing entry to store our new one at. */ for (size_t i = 1; i < MaxEntries; i++) { - Entry *entry = &this->entries[i]; + Entry *entry = std::addressof(this->entries[i]); /* Change eviction candidates if the uuid already matches ours, or if the uuid doesn't already match and the last_accessed count is lower */ if (content_id == entry->uuid || (content_id != eviction_candidate->uuid && entry->last_accessed < eviction_candidate->last_accessed)) { @@ -73,7 +73,7 @@ namespace ams::ncm { /* Attempt to locate the content id in the cache. */ for (size_t i = 0; i < MaxEntries; i++) { - Entry *entry = &this->entries[i]; + Entry *entry = std::addressof(this->entries[i]); if (entry->last_accessed != 1 && content_id == entry->uuid) { entry->last_accessed = this->counter; diff --git a/libraries/libstratosphere/include/stratosphere/rapidjson.hpp b/libraries/libstratosphere/include/stratosphere/rapidjson.hpp index 6d000e29a..ddd30b9a0 100644 --- a/libraries/libstratosphere/include/stratosphere/rapidjson.hpp +++ b/libraries/libstratosphere/include/stratosphere/rapidjson.hpp @@ -26,4 +26,4 @@ #include #include -#include \ No newline at end of file +#include diff --git a/libraries/libstratosphere/include/stratosphere/ro/ro_types.hpp b/libraries/libstratosphere/include/stratosphere/ro/ro_types.hpp index 45b26a14f..057258c97 100644 --- a/libraries/libstratosphere/include/stratosphere/ro/ro_types.hpp +++ b/libraries/libstratosphere/include/stratosphere/ro/ro_types.hpp @@ -190,7 +190,7 @@ namespace ams::ro { } const ModuleId *GetModuleId() const { - return &this->module_id; + return std::addressof(this->module_id); } }; static_assert(sizeof(NroHeader) == 0x80, "NroHeader definition!"); diff --git a/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_service_object.hpp b/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_service_object.hpp index 548974954..120d84997 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_service_object.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_service_object.hpp @@ -116,7 +116,7 @@ namespace ams::sf::cmif { using DispatchTableType = DomainServiceObjectDispatchTable; static constexpr ProcessHandlerType ProcessHandlerImpl = &impl::ServiceDispatchTableBase::ProcessMessage; - static constexpr inline ServiceDispatchMeta Meta{&DomainServiceObject::s_CmifServiceDispatchTable, ProcessHandlerImpl}; + static constexpr inline ServiceDispatchMeta Meta{std::addressof(DomainServiceObject::s_CmifServiceDispatchTable), ProcessHandlerImpl}; }; template<> @@ -127,7 +127,7 @@ namespace ams::sf::cmif { using DispatchTableType = DomainServiceObjectDispatchTable; static constexpr ProcessHandlerType ProcessHandlerImpl = &impl::ServiceDispatchTableBase::ProcessMessageForMitm; - static constexpr inline ServiceDispatchMeta Meta{&DomainServiceObject::s_CmifServiceDispatchTable, ProcessHandlerImpl}; + static constexpr inline ServiceDispatchMeta Meta{std::addressof(DomainServiceObject::s_CmifServiceDispatchTable), ProcessHandlerImpl}; }; diff --git a/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_dispatch.hpp b/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_dispatch.hpp index 7161174c5..cf0408ab8 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_dispatch.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_dispatch.hpp @@ -136,7 +136,7 @@ namespace ams::sf::cmif { static constexpr ProcessHandlerType ProcessHandlerImpl = sf::IsMitmServiceObject ? (&impl::ServiceDispatchTableBase::ProcessMessageForMitm) : (&impl::ServiceDispatchTableBase::ProcessMessage); - static constexpr inline ServiceDispatchMeta Meta{&DispatchTable, ProcessHandlerImpl}; + static constexpr inline ServiceDispatchMeta Meta{std::addressof(DispatchTable), ProcessHandlerImpl}; }; template<> @@ -151,7 +151,7 @@ namespace ams::sf::cmif { template constexpr ALWAYS_INLINE const ServiceDispatchMeta *GetServiceDispatchMeta() { - return &ServiceDispatchTraits::Meta; + return std::addressof(ServiceDispatchTraits::Meta); } } diff --git a/libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp b/libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp index 5659fefba..eeeb21a90 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp @@ -760,7 +760,7 @@ namespace ams::sf::impl { template Out> GetOutObject() { auto sp = std::construct_at(GetOutObjectSharedPointer()); - return Out>(sp, this->out_object_ids + Index); + return Out>(sp, std::addressof(this->out_object_ids[Index])); } template @@ -869,7 +869,7 @@ namespace ams::sf::impl { return; } os::NativeHandle server_handle, client_handle; - R_ABORT_UNLESS(sf::hipc::CreateSession(&server_handle, &client_handle)); + R_ABORT_UNLESS(sf::hipc::CreateSession(std::addressof(server_handle), std::addressof(client_handle))); R_ABORT_UNLESS(manager->RegisterSession(server_handle, std::move(object))); response.move_handles[Index] = client_handle; } @@ -1137,10 +1137,10 @@ namespace ams::sf::impl { ImplProcessorType impl_processor; if (ctx.processor == nullptr) { /* In the non-domain case, this is our only processor. */ - ctx.processor = &impl_processor; + ctx.processor = std::addressof(impl_processor); } else { /* In the domain case, we already have a processor, so we should give it a pointer to our template implementation. */ - ctx.processor->SetImplementationProcessor(&impl_processor); + ctx.processor->SetImplementationProcessor(std::addressof(impl_processor)); } /* Validate the metadata has the expected counts. */ diff --git a/libraries/libstratosphere/include/stratosphere/sm/sm_types.hpp b/libraries/libstratosphere/include/stratosphere/sm/sm_types.hpp index ddbc260af..f91546371 100644 --- a/libraries/libstratosphere/include/stratosphere/sm/sm_types.hpp +++ b/libraries/libstratosphere/include/stratosphere/sm/sm_types.hpp @@ -50,7 +50,7 @@ namespace ams::sm { static_assert(alignof(ServiceName) == 1, "ServiceName definition!"); inline bool operator==(const ServiceName &lhs, const ServiceName &rhs) { - return std::memcmp(&lhs, &rhs, sizeof(ServiceName)) == 0; + return std::memcmp(std::addressof(lhs), std::addressof(rhs), sizeof(ServiceName)) == 0; } inline bool operator!=(const ServiceName &lhs, const ServiceName &rhs) { diff --git a/libraries/libstratosphere/source/ams/ams_emummc_api.cpp b/libraries/libstratosphere/source/ams/ams_emummc_api.cpp index 1ee2626d9..0258c0567 100644 --- a/libraries/libstratosphere/source/ams/ams_emummc_api.cpp +++ b/libraries/libstratosphere/source/ams/ams_emummc_api.cpp @@ -78,10 +78,10 @@ namespace ams::emummc { struct { char file_path[MaxDirLen + 1]; char nintendo_path[MaxDirLen + 1]; - } *paths = reinterpret_cast(&path_storage); + } *paths = reinterpret_cast(std::addressof(path_storage)); /* Retrieve paths from secure monitor. */ - AMS_ABORT_UNLESS(spl::smc::AtmosphereGetEmummcConfig(&g_exo_config, paths, 0) == spl::smc::Result::Success); + AMS_ABORT_UNLESS(spl::smc::AtmosphereGetEmummcConfig(std::addressof(g_exo_config), paths, 0) == spl::smc::Result::Success); const Storage storage = static_cast(g_exo_config.base_cfg.type); g_is_emummc = g_exo_config.base_cfg.magic == StorageMagic && storage != Storage_Emmc; diff --git a/libraries/libstratosphere/source/ams/ams_environment.cpp b/libraries/libstratosphere/source/ams/ams_environment.cpp index 7cbb5be88..eba47ec33 100644 --- a/libraries/libstratosphere/source/ams/ams_environment.cpp +++ b/libraries/libstratosphere/source/ams/ams_environment.cpp @@ -113,7 +113,7 @@ namespace ams { svc::lp64::MemoryInfo mem_info; svc::PageInfo page_info; if (R_SUCCEEDED(svc::QueryMemory(std::addressof(mem_info), std::addressof(page_info), cur_fp)) && (mem_info.permission & svc::MemoryPermission_Read) == svc::MemoryPermission_Read) { - std::memcpy(&cur_frame, reinterpret_cast(cur_fp), sizeof(cur_frame)); + std::memcpy(std::addressof(cur_frame), reinterpret_cast(cur_fp), sizeof(cur_frame)); } else { break; } @@ -145,7 +145,7 @@ namespace ams { } /* Just call the user exception handler. */ - ::ams::ExceptionHandler(&ams_ctx); + ::ams::ExceptionHandler(std::addressof(ams_ctx)); } NORETURN void AbortImpl(); diff --git a/libraries/libstratosphere/source/ams/ams_exosphere_api.cpp b/libraries/libstratosphere/source/ams/ams_exosphere_api.cpp index 2998f9902..9df6fdfe2 100644 --- a/libraries/libstratosphere/source/ams/ams_exosphere_api.cpp +++ b/libraries/libstratosphere/source/ams/ams_exosphere_api.cpp @@ -21,7 +21,7 @@ namespace ams::exosphere { ApiInfo GetApiInfo() { u64 exosphere_cfg; - if (spl::smc::GetConfig(&exosphere_cfg, 1, spl::ConfigItem::ExosphereApiVersion) != spl::smc::Result::Success) { + if (spl::smc::GetConfig(std::addressof(exosphere_cfg), 1, spl::ConfigItem::ExosphereApiVersion) != spl::smc::Result::Success) { R_ABORT_UNLESS(ResultNotPresent()); } diff --git a/libraries/libstratosphere/source/boot2/boot2_api.cpp b/libraries/libstratosphere/source/boot2/boot2_api.cpp index eea1c0558..17c90292a 100644 --- a/libraries/libstratosphere/source/boot2/boot2_api.cpp +++ b/libraries/libstratosphere/source/boot2/boot2_api.cpp @@ -143,7 +143,7 @@ namespace ams::boot2 { if (IsAllowedLaunchProgram(loc)) { /* Launch, lightly validate result. */ { - const auto launch_result = pm::shell::LaunchProgram(&process_id, loc, launch_flags); + const auto launch_result = pm::shell::LaunchProgram(std::addressof(process_id), loc, launch_flags); AMS_ABORT_UNLESS(!(svc::ResultOutOfResource::Includes(launch_result))); AMS_ABORT_UNLESS(!(svc::ResultOutOfMemory::Includes(launch_result))); AMS_ABORT_UNLESS(!(svc::ResultLimitReached::Includes(launch_result))); @@ -178,13 +178,13 @@ namespace ams::boot2 { bool IsForceMaintenance() { u8 force_maintenance = 1; - settings::fwdbg::GetSettingsItemValue(&force_maintenance, sizeof(force_maintenance), "boot", "force_maintenance"); + settings::fwdbg::GetSettingsItemValue(std::addressof(force_maintenance), sizeof(force_maintenance), "boot", "force_maintenance"); return force_maintenance != 0; } bool IsHtcEnabled() { u8 enable_htc = 0; - settings::fwdbg::GetSettingsItemValue(&enable_htc, sizeof(enable_htc), "atmosphere", "enable_htc"); + settings::fwdbg::GetSettingsItemValue(std::addressof(enable_htc), sizeof(enable_htc), "atmosphere", "enable_htc"); return enable_htc != 0; } @@ -195,7 +195,7 @@ namespace ams::boot2 { } u8 enable_ams_lm = 0; - settings::fwdbg::GetSettingsItemValue(&enable_ams_lm, sizeof(enable_ams_lm), "atmosphere", "enable_log_manager"); + settings::fwdbg::GetSettingsItemValue(std::addressof(enable_ams_lm), sizeof(enable_ams_lm), "atmosphere", "enable_log_manager"); return enable_ams_lm != 0; } @@ -215,7 +215,7 @@ namespace ams::boot2 { void IterateOverFlaggedProgramsOnSdCard(F f) { /* Validate that the contents directory exists. */ fs::DirectoryHandle contents_dir; - if (R_FAILED(fs::OpenDirectory(&contents_dir, "sdmc:/atmosphere/contents", fs::OpenDirectoryMode_Directory))) { + if (R_FAILED(fs::OpenDirectory(std::addressof(contents_dir), "sdmc:/atmosphere/contents", fs::OpenDirectoryMode_Directory))) { return; } ON_SCOPE_EXIT { fs::CloseDirectory(contents_dir); }; @@ -223,7 +223,7 @@ namespace ams::boot2 { /* Iterate over entries in the contents directory */ fs::DirectoryEntry entry; s64 count; - while (R_SUCCEEDED(fs::ReadDirectory(&count, &entry, contents_dir, 1)) && count == 1) { + while (R_SUCCEEDED(fs::ReadDirectory(std::addressof(count), std::addressof(entry), contents_dir, 1)) && count == 1) { /* Check that the subdirectory can be converted to a program id. */ if (std::strlen(entry.name) == 2 * sizeof(ncm::ProgramId) && IsHexadecimal(entry.name)) { /* Check if we've already launched the program. */ @@ -252,12 +252,12 @@ namespace ams::boot2 { util::SNPrintf(path, sizeof(path), "sdmc:/atmosphere/contents/%016lx/mitm.lst", static_cast(program_id)); fs::FileHandle f; - if (R_FAILED(fs::OpenFile(&f, path, fs::OpenMode_Read))) { + if (R_FAILED(fs::OpenFile(std::addressof(f), path, fs::OpenMode_Read))) { return; } ON_SCOPE_EXIT { fs::CloseFile(f); }; - R_ABORT_UNLESS(fs::ReadFile(&mitm_list_size, f, 0, mitm_list, sizeof(mitm_list))); + R_ABORT_UNLESS(fs::ReadFile(std::addressof(mitm_list_size), f, 0, mitm_list, sizeof(mitm_list))); } /* Validate read size. */ @@ -352,7 +352,7 @@ namespace ams::boot2 { /* Retrieve setting from the database. */ u8 force_maintenance = 0; - settings::fwdbg::GetSettingsItemValue(&force_maintenance, sizeof(force_maintenance), "boot", "force_maintenance"); + settings::fwdbg::GetSettingsItemValue(std::addressof(force_maintenance), sizeof(force_maintenance), "boot", "force_maintenance"); } /* Launch pcv. */ diff --git a/libraries/libstratosphere/source/capsrv/server/jpeg/decodersrv_software_jpeg_decoder.cpp b/libraries/libstratosphere/source/capsrv/server/jpeg/decodersrv_software_jpeg_decoder.cpp index 67ee272ba..3631a3643 100644 --- a/libraries/libstratosphere/source/capsrv/server/jpeg/decodersrv_software_jpeg_decoder.cpp +++ b/libraries/libstratosphere/source/capsrv/server/jpeg/decodersrv_software_jpeg_decoder.cpp @@ -121,7 +121,7 @@ namespace ams::capsrv::server::jpeg { cinfo.do_block_smoothing = input.block_smoothing; /* Start decompression. */ - R_UNLESS(jpeg_start_decompress(&cinfo) == TRUE, capsrv::ResultAlbumInvalidFileData()); + R_UNLESS(jpeg_start_decompress(std::addressof(cinfo)) == TRUE, capsrv::ResultAlbumInvalidFileData()); /* Check the parameters. */ CAPSRV_ASSERT(cinfo.output_width == input.width); @@ -169,7 +169,7 @@ namespace ams::capsrv::server::jpeg { } /* Finish the decompression. */ - R_UNLESS(jpeg_finish_decompress(&cinfo) == TRUE, capsrv::ResultAlbumInvalidFileData()); + R_UNLESS(jpeg_finish_decompress(std::addressof(cinfo)) == TRUE, capsrv::ResultAlbumInvalidFileData()); } else { /* Some unknown error was caught by our handler. */ return capsrv::ResultAlbumInvalidFileData(); diff --git a/libraries/libstratosphere/source/cfg/cfg_override.cpp b/libraries/libstratosphere/source/cfg/cfg_override.cpp index 2451074cb..54629ff54 100644 --- a/libraries/libstratosphere/source/cfg/cfg_override.cpp +++ b/libraries/libstratosphere/source/cfg/cfg_override.cpp @@ -373,9 +373,9 @@ namespace ams::cfg { .override_key = g_default_override_key, .cheat_enable_key = g_default_cheat_enable_key, }; - std::memset(&config.locale, 0xCC, sizeof(config.locale)); + std::memset(std::addressof(config.locale), 0xCC, sizeof(config.locale)); - ParseIniFile(ContentSpecificIniHandler, path, &config); + ParseIniFile(ContentSpecificIniHandler, path, std::addressof(config)); return config; } @@ -399,7 +399,7 @@ namespace ams::cfg { RefreshOverrideConfiguration(); /* If we can't read the key state, don't override anything. */ - if (R_FAILED(hid::GetKeysHeld(&status.keys_held))) { + if (R_FAILED(hid::GetKeysHeld(std::addressof(status.keys_held)))) { return status; } diff --git a/libraries/libstratosphere/source/cfg/cfg_sd_card.cpp b/libraries/libstratosphere/source/cfg/cfg_sd_card.cpp index e00908e62..999f524f0 100644 --- a/libraries/libstratosphere/source/cfg/cfg_sd_card.cpp +++ b/libraries/libstratosphere/source/cfg/cfg_sd_card.cpp @@ -37,7 +37,7 @@ namespace ams::cfg { Result CheckSdCardServicesReady() { for (size_t i = 0; i < NumRequiredServicesForSdCardAccess; i++) { bool service_present = false; - R_TRY(sm::HasService(&service_present, RequiredServicesForSdCardAccess[i])); + R_TRY(sm::HasService(std::addressof(service_present), RequiredServicesForSdCardAccess[i])); if (!service_present) { return fs::ResultSdCardNotPresent(); } @@ -54,14 +54,14 @@ namespace ams::cfg { Result TryInitializeSdCard() { R_TRY(CheckSdCardServicesReady()); - R_ABORT_UNLESS(fsOpenSdCardFileSystem(&g_sd_card_filesystem)); + R_ABORT_UNLESS(fsOpenSdCardFileSystem(std::addressof(g_sd_card_filesystem))); g_sd_card_initialized = true; return ResultSuccess(); } void InitializeSdCard() { WaitSdCardServicesReadyImpl(); - R_ABORT_UNLESS(fsOpenSdCardFileSystem(&g_sd_card_filesystem)); + R_ABORT_UNLESS(fsOpenSdCardFileSystem(std::addressof(g_sd_card_filesystem))); g_sd_card_initialized = true; } diff --git a/libraries/libstratosphere/source/fssrv/fssrv_filesystem_interface_adapter.cpp b/libraries/libstratosphere/source/fssrv/fssrv_filesystem_interface_adapter.cpp index 58224e803..51880abab 100644 --- a/libraries/libstratosphere/source/fssrv/fssrv_filesystem_interface_adapter.cpp +++ b/libraries/libstratosphere/source/fssrv/fssrv_filesystem_interface_adapter.cpp @@ -42,7 +42,7 @@ namespace ams::fssrv::impl { R_UNLESS(size >= 0, fs::ResultInvalidSize()); size_t read_size = 0; - R_TRY(this->base_file->Read(&read_size, offset, buffer.GetPointer(), static_cast(size), option)); + R_TRY(this->base_file->Read(std::addressof(read_size), offset, buffer.GetPointer(), static_cast(size), option)); out.SetValue(read_size); return ResultSuccess(); @@ -82,7 +82,7 @@ namespace ams::fssrv::impl { auto read_lock = this->parent_filesystem->AcquireCacheInvalidationReadLock(); fs::FileQueryRangeInfo info; - R_TRY(this->base_file->OperateRange(&info, sizeof(info), fs::OperationId::QueryRange, offset, size, nullptr, 0)); + R_TRY(this->base_file->OperateRange(std::addressof(info), sizeof(info), fs::OperationId::QueryRange, offset, size, nullptr, 0)); out->Merge(info); } @@ -268,7 +268,7 @@ namespace ams::fssrv::impl { /* TODO: N retries on fs::ResultDataCorrupted, we may want to eventually. */ std::unique_ptr file; - R_TRY(this->base_fs->OpenFile(&file, normalizer.GetPath(), static_cast(mode))); + R_TRY(this->base_fs->OpenFile(std::addressof(file), normalizer.GetPath(), static_cast(mode))); /* TODO: This is a hack to get the mitm API to work. Better solution? */ const auto target_object_id = file->GetDomainObjectId(); @@ -296,7 +296,7 @@ namespace ams::fssrv::impl { /* TODO: N retries on fs::ResultDataCorrupted, we may want to eventually. */ std::unique_ptr dir; - R_TRY(this->base_fs->OpenDirectory(&dir, normalizer.GetPath(), static_cast(mode))); + R_TRY(this->base_fs->OpenDirectory(std::addressof(dir), normalizer.GetPath(), static_cast(mode))); /* TODO: This is a hack to get the mitm API to work. Better solution? */ const auto target_object_id = dir->GetDomainObjectId(); diff --git a/libraries/libstratosphere/source/fssrv/fssrv_storage_interface_adapter.cpp b/libraries/libstratosphere/source/fssrv/fssrv_storage_interface_adapter.cpp index c56488575..5e757162d 100644 --- a/libraries/libstratosphere/source/fssrv/fssrv_storage_interface_adapter.cpp +++ b/libraries/libstratosphere/source/fssrv/fssrv_storage_interface_adapter.cpp @@ -84,7 +84,7 @@ namespace ams::fssrv::impl { auto read_lock = this->AcquireCacheInvalidationReadLock(); fs::StorageQueryRangeInfo info; - R_TRY(this->base_storage->OperateRange(&info, sizeof(info), fs::OperationId::QueryRange, offset, size, nullptr, 0)); + R_TRY(this->base_storage->OperateRange(std::addressof(info), sizeof(info), fs::OperationId::QueryRange, offset, size, nullptr, 0)); out->Merge(info); } diff --git a/libraries/libstratosphere/source/fssystem/fssystem_directory_savedata_filesystem.cpp b/libraries/libstratosphere/source/fssystem/fssystem_directory_savedata_filesystem.cpp index ff78c0992..7a1d8a3b0 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_directory_savedata_filesystem.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_directory_savedata_filesystem.cpp @@ -96,7 +96,7 @@ namespace ams::fssystem { fs::DirectoryEntryType type; /* Check that the working directory exists. */ - R_TRY_CATCH(this->base_fs->GetEntryType(&type, WorkingDirectoryPath)) { + R_TRY_CATCH(this->base_fs->GetEntryType(std::addressof(type), WorkingDirectoryPath)) { /* If path isn't found, create working directory and committed directory. */ R_CATCH(fs::ResultPathNotFound) { R_TRY(this->base_fs->CreateDirectory(WorkingDirectoryPath)); @@ -105,7 +105,7 @@ namespace ams::fssystem { } R_END_TRY_CATCH; /* Now check for the committed directory. */ - R_TRY_CATCH(this->base_fs->GetEntryType(&type, CommittedDirectoryPath)) { + R_TRY_CATCH(this->base_fs->GetEntryType(std::addressof(type), CommittedDirectoryPath)) { /* Committed doesn't exist, so synchronize and rename. */ R_CATCH(fs::ResultPathNotFound) { R_TRY(this->SynchronizeDirectory(SynchronizingDirectoryPath, WorkingDirectoryPath)); @@ -148,7 +148,7 @@ namespace ams::fssystem { /* Get a work buffer to work with. */ std::unique_ptr work_buf; size_t work_buf_size; - R_TRY(this->AllocateWorkBuffer(&work_buf, &work_buf_size, IdealWorkBufferSize)); + R_TRY(this->AllocateWorkBuffer(std::addressof(work_buf), std::addressof(work_buf_size), IdealWorkBufferSize)); /* Copy the directory recursively. */ return fssystem::CopyDirectoryRecursively(this->base_fs, dst, src, work_buf.get(), work_buf_size); @@ -165,7 +165,7 @@ namespace ams::fssystem { /* Normalize it. */ constexpr size_t WorkingDirectoryPathLength = sizeof(WorkingDirectoryPath) - 1; size_t normalized_length; - return fs::PathNormalizer::Normalize(out + WorkingDirectoryPathLength - 1, &normalized_length, relative_path, out_size - (WorkingDirectoryPathLength - 1)); + return fs::PathNormalizer::Normalize(out + WorkingDirectoryPathLength - 1, std::addressof(normalized_length), relative_path, out_size - (WorkingDirectoryPathLength - 1)); } void DirectorySaveDataFileSystem::OnWritableFileClose() { @@ -183,7 +183,7 @@ namespace ams::fssystem { /* Get a work buffer to work with. */ std::unique_ptr work_buf; size_t work_buf_size; - R_TRY(this->AllocateWorkBuffer(&work_buf, &work_buf_size, IdealWorkBufferSize)); + R_TRY(this->AllocateWorkBuffer(std::addressof(work_buf), std::addressof(work_buf_size), IdealWorkBufferSize)); /* Copy the directory recursively. */ R_TRY(fssystem::CopyDirectoryRecursively(this->base_fs, save_fs, fs::PathNormalizer::RootPath, fs::PathNormalizer::RootPath, work_buf.get(), work_buf_size)); @@ -198,7 +198,7 @@ namespace ams::fssystem { std::scoped_lock lk(this->accessor_mutex); std::unique_ptr base_file; - R_TRY(this->base_fs->OpenFile(&base_file, full_path, mode)); + R_TRY(this->base_fs->OpenFile(std::addressof(base_file), full_path, mode)); std::unique_ptr file(new (std::nothrow) DirectorySaveDataFile(std::move(base_file), this, mode)); R_UNLESS(file != nullptr, fs::ResultAllocationFailureInDirectorySaveDataFileSystem()); diff --git a/libraries/libstratosphere/source/fssystem/fssystem_utility.cpp b/libraries/libstratosphere/source/fssystem/fssystem_utility.cpp index 78a896fa2..0b91df0a6 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_utility.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_utility.cpp @@ -72,7 +72,7 @@ namespace ams::fssystem { Result CopyFile(fs::fsa::IFileSystem *dst_fs, fs::fsa::IFileSystem *src_fs, const char *dst_parent_path, const char *src_path, const fs::DirectoryEntry *entry, void *work_buf, size_t work_buf_size) { /* Open source file. */ std::unique_ptr src_file; - R_TRY(src_fs->OpenFile(&src_file, src_path, fs::OpenMode_Read)); + R_TRY(src_fs->OpenFile(std::addressof(src_file), src_path, fs::OpenMode_Read)); /* Open dst file. */ std::unique_ptr dst_file; @@ -83,7 +83,7 @@ namespace ams::fssystem { AMS_ABORT_UNLESS(original_size < sizeof(dst_path)); R_TRY(dst_fs->CreateFile(dst_path, entry->file_size)); - R_TRY(dst_fs->OpenFile(&dst_file, dst_path, fs::OpenMode_Write)); + R_TRY(dst_fs->OpenFile(std::addressof(dst_file), dst_path, fs::OpenMode_Write)); } /* Read/Write file in work buffer sized chunks. */ @@ -91,7 +91,7 @@ namespace ams::fssystem { s64 offset = 0; while (remaining > 0) { size_t read_size; - R_TRY(src_file->Read(&read_size, offset, work_buf, work_buf_size, fs::ReadOption())); + R_TRY(src_file->Read(std::addressof(read_size), offset, work_buf, work_buf_size, fs::ReadOption())); R_TRY(dst_file->Write(offset, work_buf, read_size, fs::WriteOption())); remaining -= read_size; @@ -132,7 +132,7 @@ namespace ams::fssystem { return ResultSuccess(); }, [&](const char *path, const fs::DirectoryEntry &entry) -> Result { /* On File */ - return CopyFile(dst_fs, src_fs, dst_path_buf, path, &entry, work_buf, work_buf_size); + return CopyFile(dst_fs, src_fs, dst_path_buf, path, std::addressof(entry), work_buf, work_buf_size); } ); } diff --git a/libraries/libstratosphere/source/kvdb/kvdb_archive.cpp b/libraries/libstratosphere/source/kvdb/kvdb_archive.cpp index de61a4a3d..d4e3df298 100644 --- a/libraries/libstratosphere/source/kvdb/kvdb_archive.cpp +++ b/libraries/libstratosphere/source/kvdb/kvdb_archive.cpp @@ -87,7 +87,7 @@ namespace ams::kvdb { /* Read and validate header. */ ArchiveHeader header; - R_TRY(this->Read(&header, sizeof(header))); + R_TRY(this->Read(std::addressof(header), sizeof(header))); R_TRY(header.Validate()); *out = header.entry_count; @@ -100,7 +100,7 @@ namespace ams::kvdb { /* Peek the next entry header. */ ArchiveEntryHeader header; - R_TRY(this->Peek(&header, sizeof(header))); + R_TRY(this->Peek(std::addressof(header), sizeof(header))); R_TRY(header.Validate()); *out_key_size = header.key_size; @@ -114,7 +114,7 @@ namespace ams::kvdb { /* Read the next entry header. */ ArchiveEntryHeader header; - R_TRY(this->Read(&header, sizeof(header))); + R_TRY(this->Read(std::addressof(header), sizeof(header))); R_TRY(header.Validate()); /* Key size and Value size must be correct. */ @@ -142,7 +142,7 @@ namespace ams::kvdb { AMS_ABORT_UNLESS(this->offset == 0); ArchiveHeader header = ArchiveHeader::Make(entry_count); - R_ABORT_UNLESS(this->Write(&header, sizeof(header))); + R_ABORT_UNLESS(this->Write(std::addressof(header), sizeof(header))); } void ArchiveWriter::WriteEntry(const void *key, size_t key_size, const void *value, size_t value_size) { @@ -150,7 +150,7 @@ namespace ams::kvdb { AMS_ABORT_UNLESS(this->offset != 0); ArchiveEntryHeader header = ArchiveEntryHeader::Make(key_size, value_size); - R_ABORT_UNLESS(this->Write(&header, sizeof(header))); + R_ABORT_UNLESS(this->Write(std::addressof(header), sizeof(header))); R_ABORT_UNLESS(this->Write(key, key_size)); R_ABORT_UNLESS(this->Write(value, value_size)); } diff --git a/libraries/libstratosphere/source/ldr/ldr_pm_api.cpp b/libraries/libstratosphere/source/ldr/ldr_pm_api.cpp index 1a4856e4c..0ad1d405c 100644 --- a/libraries/libstratosphere/source/ldr/ldr_pm_api.cpp +++ b/libraries/libstratosphere/source/ldr/ldr_pm_api.cpp @@ -24,12 +24,12 @@ namespace ams::ldr::pm { } Result GetProgramInfo(ProgramInfo *out, const ncm::ProgramLocation &loc) { - return ldrPmGetProgramInfo(reinterpret_cast(&loc), reinterpret_cast(out)); + return ldrPmGetProgramInfo(reinterpret_cast(std::addressof(loc)), reinterpret_cast(out)); } Result PinProgram(PinId *out, const ncm::ProgramLocation &loc) { static_assert(sizeof(*out) == sizeof(u64), "PinId definition!"); - return ldrPmPinProgram(reinterpret_cast(&loc), reinterpret_cast(out)); + return ldrPmPinProgram(reinterpret_cast(std::addressof(loc)), reinterpret_cast(out)); } Result UnpinProgram(PinId pin_id) { @@ -42,7 +42,7 @@ namespace ams::ldr::pm { Result AtmosphereGetProgramInfo(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc) { static_assert(sizeof(*out_status) == sizeof(CfgOverrideStatus), "CfgOverrideStatus definition!"); - return ldrPmAtmosphereGetProgramInfo(reinterpret_cast(out), reinterpret_cast(out_status), reinterpret_cast(&loc)); + return ldrPmAtmosphereGetProgramInfo(reinterpret_cast(out), reinterpret_cast(out_status), reinterpret_cast(std::addressof(loc))); } Result SetEnabledProgramVerification(bool enabled) { @@ -52,7 +52,7 @@ namespace ams::ldr::pm { Result AtmospherePinProgram(PinId *out, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status) { static_assert(sizeof(*out) == sizeof(u64), "PinId definition!"); static_assert(sizeof(status) == sizeof(CfgOverrideStatus), "CfgOverrideStatus definition!"); - return ldrPmAtmospherePinProgram(reinterpret_cast(out), reinterpret_cast(&loc), reinterpret_cast(&status)); + return ldrPmAtmospherePinProgram(reinterpret_cast(out), reinterpret_cast(std::addressof(loc)), reinterpret_cast(std::addressof(status))); } } diff --git a/libraries/libstratosphere/source/lm/lm_remote_log_service.cpp b/libraries/libstratosphere/source/lm/lm_remote_log_service.cpp index 88a4149b8..5ebe3a1e4 100644 --- a/libraries/libstratosphere/source/lm/lm_remote_log_service.cpp +++ b/libraries/libstratosphere/source/lm/lm_remote_log_service.cpp @@ -43,10 +43,10 @@ namespace ams::lm { u64 pid_placeholder = 0; #define NX_SERVICE_ASSUME_NON_DOMAIN - R_TRY(serviceDispatchIn(&m_srv, 0, pid_placeholder, + R_TRY(serviceDispatchIn(std::addressof(m_srv), 0, pid_placeholder, .in_send_pid = true, .out_num_objects = 1, - .out_objects = &logger_srv, + .out_objects = std::addressof(logger_srv), )); #undef NX_SERVICE_ASSUME_NON_DOMAIN } diff --git a/libraries/libstratosphere/source/lm/lm_remote_log_service.hpp b/libraries/libstratosphere/source/lm/lm_remote_log_service.hpp index 47303c3a5..c948008b8 100644 --- a/libraries/libstratosphere/source/lm/lm_remote_log_service.hpp +++ b/libraries/libstratosphere/source/lm/lm_remote_log_service.hpp @@ -32,14 +32,14 @@ namespace ams::lm { public: /* Actual commands. */ Result Log(const sf::InAutoSelectBuffer &message) { - return serviceDispatch(&m_srv, 0, + return serviceDispatch(std::addressof(m_srv), 0, .buffer_attrs = { SfBufferAttr_In | SfBufferAttr_HipcAutoSelect }, .buffers = { { message.GetPointer(), message.GetSize() } }, ); } Result SetDestination(u32 destination) { - return serviceDispatchIn(&m_srv, 1, destination); + return serviceDispatchIn(std::addressof(m_srv), 1, destination); } }; static_assert(lm::IsILogger); diff --git a/libraries/libstratosphere/source/lmem/impl/lmem_impl_exp_heap.cpp b/libraries/libstratosphere/source/lmem/impl/lmem_impl_exp_heap.cpp index d59866b93..0da7a0663 100644 --- a/libraries/libstratosphere/source/lmem/impl/lmem_impl_exp_heap.cpp +++ b/libraries/libstratosphere/source/lmem/impl/lmem_impl_exp_heap.cpp @@ -43,11 +43,11 @@ namespace ams::lmem::impl { } constexpr inline ExpHeapHead *GetExpHeapHead(HeapHead *heap_head) { - return &heap_head->impl_head.exp_heap_head; + return std::addressof(heap_head->impl_head.exp_heap_head); } constexpr inline const ExpHeapHead *GetExpHeapHead(const HeapHead *heap_head) { - return &heap_head->impl_head.exp_heap_head; + return std::addressof(heap_head->impl_head.exp_heap_head); } constexpr inline HeapHead *GetHeapHead(ExpHeapHead *exp_heap_head) { @@ -197,7 +197,7 @@ namespace ams::lmem::impl { /* Locate the block. */ for (auto it = head->free_list.begin(); it != head->free_list.end(); it++) { - ExpHeapMemoryBlockHead *cur_free_block = &*it; + ExpHeapMemoryBlockHead *cur_free_block = std::addressof(*it); if (cur_free_block < region->start) { prev_free_block_it = it; @@ -220,9 +220,9 @@ namespace ams::lmem::impl { auto insertion_it = head->free_list.begin(); if (prev_free_block_it != head->free_list.end()) { /* There's a previous free block, so we want to insert as the next iterator. */ - if (GetMemoryBlockEnd(&*prev_free_block_it) == region->start) { + if (GetMemoryBlockEnd(std::addressof(*prev_free_block_it)) == region->start) { /* We can coalesce, so do so. */ - free_region.start = &*prev_free_block_it; + free_region.start = std::addressof(*prev_free_block_it); insertion_it = head->free_list.erase(prev_free_block_it); } else { /* We can't coalesce, so just select the next iterator. */ @@ -249,7 +249,7 @@ namespace ams::lmem::impl { void *ConvertFreeBlockToUsedBlock(ExpHeapHead *head, ExpHeapMemoryBlockHead *block_head, void *block, size_t size, AllocationDirection direction) { /* Calculate freed memory regions. */ MemoryRegion free_region_front; - GetMemoryBlockRegion(&free_region_front, block_head); + GetMemoryBlockRegion(std::addressof(free_region_front), block_head); MemoryRegion free_region_back{ .start = reinterpret_cast(reinterpret_cast(block) + size), .end = free_region_front.end, }; /* Adjust end of head region. */ @@ -308,12 +308,12 @@ namespace ams::lmem::impl { size_t best_size = std::numeric_limits::max(); for (auto it = exp_heap_head->free_list.begin(); it != exp_heap_head->free_list.end(); it++) { - const uintptr_t absolute_block_start = reinterpret_cast(GetMemoryBlockStart(&*it)); + const uintptr_t absolute_block_start = reinterpret_cast(GetMemoryBlockStart(std::addressof(*it))); const uintptr_t block_start = util::AlignUp(absolute_block_start, alignment); const size_t block_offset = block_start - absolute_block_start; if (it->block_size >= size + block_offset && best_size > it->block_size) { - found_block_head = &*it; + found_block_head = std::addressof(*it); found_block = reinterpret_cast(block_start); best_size = it->block_size; @@ -342,12 +342,12 @@ namespace ams::lmem::impl { size_t best_size = std::numeric_limits::max(); for (auto it = exp_heap_head->free_list.rbegin(); it != exp_heap_head->free_list.rend(); it++) { - const uintptr_t absolute_block_start = reinterpret_cast(GetMemoryBlockStart(&*it)); + const uintptr_t absolute_block_start = reinterpret_cast(GetMemoryBlockStart(std::addressof(*it))); const uintptr_t block_start = util::AlignUp(absolute_block_start, alignment); const size_t block_offset = block_start - absolute_block_start; if (it->block_size >= size + block_offset && best_size > it->block_size) { - found_block_head = &*it; + found_block_head = std::addressof(*it); found_block = reinterpret_cast(block_start); best_size = it->block_size; @@ -396,7 +396,7 @@ namespace ams::lmem::impl { } /* Get the memory block end, make sure it really is the last block. */ - ExpHeapMemoryBlockHead *block = &exp_heap_head->free_list.back(); + ExpHeapMemoryBlockHead *block = std::addressof(exp_heap_head->free_list.back()); void * const block_start = GetMemoryBlockStart(block); const size_t block_size = block->block_size; void * const block_end = reinterpret_cast(reinterpret_cast(block_start) + block_size); @@ -460,11 +460,11 @@ namespace ams::lmem::impl { MemoryRegion region; /* Erase the heap from the used list, and coalesce it with adjacent blocks. */ - GetMemoryBlockRegion(®ion, block); + GetMemoryBlockRegion(std::addressof(region), block); exp_heap_head->used_list.erase(exp_heap_head->used_list.iterator_to(*block)); /* Coalesce with adjacent blocks. */ - const bool coalesced = CoalesceFreedRegion(exp_heap_head, ®ion); + const bool coalesced = CoalesceFreedRegion(exp_heap_head, std::addressof(region)); AMS_ASSERT(coalesced); AMS_UNUSED(coalesced); } @@ -493,8 +493,8 @@ namespace ams::lmem::impl { ExpHeapMemoryBlockHead *next_block_head = nullptr; for (auto it = exp_heap_head->free_list.begin(); it != exp_heap_head->free_list.end(); it++) { - if (&*it == cur_block_end) { - next_block_head = &*it; + if (std::addressof(*it) == cur_block_end) { + next_block_head = std::addressof(*it); break; } } @@ -508,7 +508,7 @@ namespace ams::lmem::impl { { /* Get block region. */ MemoryRegion new_free_region; - GetMemoryBlockRegion(&new_free_region, next_block_head); + GetMemoryBlockRegion(std::addressof(new_free_region), next_block_head); /* Remove the next block from the free list. */ auto insertion_it = exp_heap_head->free_list.erase(exp_heap_head->free_list.iterator_to(*next_block_head)); @@ -539,7 +539,7 @@ namespace ams::lmem::impl { /* Try to free the new memory. */ block_head->block_size = size; - if (!CoalesceFreedRegion(exp_heap_head, &new_free_region)) { + if (!CoalesceFreedRegion(exp_heap_head, std::addressof(new_free_region))) { /* We didn't shrink the block successfully, so restore the size. */ block_head->block_size = original_block_size; } @@ -567,9 +567,9 @@ namespace ams::lmem::impl { size_t max_size = std::numeric_limits::min(); size_t min_offset = std::numeric_limits::max(); for (const auto &it : GetExpHeapHead(handle)->free_list) { - const uintptr_t absolute_block_start = reinterpret_cast(GetMemoryBlockStart(&it)); + const uintptr_t absolute_block_start = reinterpret_cast(GetMemoryBlockStart(std::addressof(it))); const uintptr_t block_start = util::AlignUp(absolute_block_start, alignment); - const uintptr_t block_end = reinterpret_cast(GetMemoryBlockEnd(&it)); + const uintptr_t block_end = reinterpret_cast(GetMemoryBlockEnd(std::addressof(it))); if (block_start < block_end) { const size_t block_size = GetPointerDifference(block_start, block_end); @@ -620,7 +620,7 @@ namespace ams::lmem::impl { AMS_ASSERT(IsValidHeapHandle(handle)); for (auto &it : GetExpHeapHead(handle)->used_list) { - (*visitor)(GetMemoryBlockStart(&it), handle, user_data); + (*visitor)(GetMemoryBlockStart(std::addressof(it)), handle, user_data); } } diff --git a/libraries/libstratosphere/source/lmem/impl/lmem_impl_unit_heap.cpp b/libraries/libstratosphere/source/lmem/impl/lmem_impl_unit_heap.cpp index f08763b85..fc6a78ce8 100644 --- a/libraries/libstratosphere/source/lmem/impl/lmem_impl_unit_heap.cpp +++ b/libraries/libstratosphere/source/lmem/impl/lmem_impl_unit_heap.cpp @@ -27,11 +27,11 @@ namespace ams::lmem::impl { } constexpr inline UnitHeapHead *GetUnitHeapHead(HeapHead *heap_head) { - return &heap_head->impl_head.unit_heap_head; + return std::addressof(heap_head->impl_head.unit_heap_head); } constexpr inline const UnitHeapHead *GetUnitHeapHead(const HeapHead *heap_head) { - return &heap_head->impl_head.unit_heap_head; + return std::addressof(heap_head->impl_head.unit_heap_head); } inline UnitHead *PopUnit(UnitHeapList *list) { @@ -190,7 +190,7 @@ namespace ams::lmem::impl { /* Allocate a unit. */ UnitHeapHead *unit_heap = GetUnitHeapHead(handle); - UnitHead *unit = PopUnit(&unit_heap->free_list); + UnitHead *unit = PopUnit(std::addressof(unit_heap->free_list)); if (unit != nullptr) { /* Fill memory with pattern for debug, if needed. */ FillAllocatedMemory(handle, unit, unit_heap->unit_size); @@ -215,7 +215,7 @@ namespace ams::lmem::impl { FillFreedMemory(handle, block, unit_heap->unit_size); /* Push the unit onto the free list. */ - PushUnit(&unit_heap->free_list, reinterpret_cast(block)); + PushUnit(std::addressof(unit_heap->free_list), static_cast(block)); /* Note that we freed a unit. */ unit_heap->num_units--; 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 84b802521..f76a44464 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 @@ -21,19 +21,19 @@ namespace ams::lr { Result AddOnContentLocationResolverImpl::ResolveAddOnContentPath(sf::Out 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)); 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 c6f566795..ec73341cc 100644 --- a/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.cpp +++ b/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.cpp @@ -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 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); diff --git a/libraries/libstratosphere/source/lr/lr_location_redirector.cpp b/libraries/libstratosphere/source/lr/lr_location_redirector.cpp index 7833b2452..fd4e34eb8 100644 --- a/libraries/libstratosphere/source/lr/lr_location_redirector.cpp +++ b/libraries/libstratosphere/source/lr/lr_location_redirector.cpp @@ -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; } } diff --git a/libraries/libstratosphere/source/lr/lr_remote_location_resolver_impl.hpp b/libraries/libstratosphere/source/lr/lr_remote_location_resolver_impl.hpp index 9b8c67161..500e2757a 100644 --- a/libraries/libstratosphere/source/lr/lr_remote_location_resolver_impl.hpp +++ b/libraries/libstratosphere/source/lr/lr_remote_location_resolver_impl.hpp @@ -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 out, ncm::ProgramId id) { diff --git a/libraries/libstratosphere/source/lr/lr_remote_registered_location_resolver_impl.hpp b/libraries/libstratosphere/source/lr/lr_remote_registered_location_resolver_impl.hpp index 1f0ff9afc..e57a78faf 100644 --- a/libraries/libstratosphere/source/lr/lr_remote_registered_location_resolver_impl.hpp +++ b/libraries/libstratosphere/source/lr/lr_remote_registered_location_resolver_impl.hpp @@ -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 out, ncm::ProgramId id) { diff --git a/libraries/libstratosphere/source/ncm/ncm_content_manager_impl.cpp b/libraries/libstratosphere/source/ncm/ncm_content_manager_impl.cpp index 8b5376aa6..9c7f02706 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_manager_impl.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_manager_impl.cpp @@ -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) { diff --git a/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.cpp b/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.cpp index 284bd7114..5338c2e6f 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.cpp @@ -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 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 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. */ diff --git a/libraries/libstratosphere/source/ncm/ncm_host_content_storage_impl.cpp b/libraries/libstratosphere/source/ncm/ncm_host_content_storage_impl.cpp index 3e92b5bde..540e69bfd 100644 --- a/libraries/libstratosphere/source/ncm/ncm_host_content_storage_impl.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_host_content_storage_impl.cpp @@ -137,7 +137,7 @@ namespace ams::ncm { Result HostContentStorageImpl::GetRightsIdFromContentIdDeprecated(sf::Out 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); diff --git a/libraries/libstratosphere/source/ncm/ncm_install_task_base.cpp b/libraries/libstratosphere/source/ncm/ncm_install_task_base.cpp index 07041b9a7..218e0ddbc 100644 --- a/libraries/libstratosphere/source/ncm/ncm_install_task_base.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_install_task_base.cpp @@ -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 expected_key, util::optional 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; diff --git a/libraries/libstratosphere/source/ncm/ncm_placeholder_accessor.cpp b/libraries/libstratosphere/source/ncm/ncm_placeholder_accessor.cpp index 69d47d6d5..13be1c60e 100644 --- a/libraries/libstratosphere/source/ncm/ncm_placeholder_accessor.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_placeholder_accessor.cpp @@ -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; diff --git a/libraries/libstratosphere/source/ncm/ncm_read_only_content_storage_impl.cpp b/libraries/libstratosphere/source/ncm/ncm_read_only_content_storage_impl.cpp index cb9e23249..abb7704d7 100644 --- a/libraries/libstratosphere/source/ncm/ncm_read_only_content_storage_impl.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_read_only_content_storage_impl.cpp @@ -224,7 +224,7 @@ namespace ams::ncm { Result ReadOnlyContentStorageImpl::GetRightsIdFromContentIdDeprecated(sf::Out 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(); diff --git a/libraries/libstratosphere/source/os/impl/os_multiple_wait_impl.cpp b/libraries/libstratosphere/source/os/impl/os_multiple_wait_impl.cpp index 34eea3a28..ba48dcb78 100644 --- a/libraries/libstratosphere/source/os/impl/os_multiple_wait_impl.cpp +++ b/libraries/libstratosphere/source/os/impl/os_multiple_wait_impl.cpp @@ -70,7 +70,7 @@ namespace ams::os::impl { this->current_time = GetCurrentTick().ToTimeSpan(); TimeSpan min_timeout = 0; - MultiWaitHolderBase *min_timeout_object = this->RecalculateNextTimeout(&min_timeout, end_time); + MultiWaitHolderBase *min_timeout_object = this->RecalculateNextTimeout(std::addressof(min_timeout), end_time); s32 index = WaitInvalid; Result wait_result = ResultSuccess(); @@ -141,11 +141,10 @@ namespace ams::os::impl { for (MultiWaitHolderBase &holder_base : this->multi_wait_list) { if (auto handle = holder_base.GetHandle(); handle != os::InvalidNativeHandle) { - AMS_ASSERT(count < num); - AMS_UNUSED(num); + AMS_ABORT_UNLESS(count < num); out_handles[count] = handle; - out_objects[count] = &holder_base; + out_objects[count] = std::addressof(holder_base); count++; } } @@ -160,7 +159,7 @@ namespace ams::os::impl { TriBool is_signaled = holder_base.LinkToObjectList(); if (signaled_holder == nullptr && is_signaled == TriBool::True) { - signaled_holder = &holder_base; + signaled_holder = std::addressof(holder_base); } } @@ -179,7 +178,7 @@ namespace ams::os::impl { for (MultiWaitHolderBase &holder_base : this->multi_wait_list) { if (const TimeSpan cur_time = holder_base.GetAbsoluteWakeupTime(); cur_time < min_time) { - min_timeout_holder = &holder_base; + min_timeout_holder = std::addressof(holder_base); min_time = cur_time; } } diff --git a/libraries/libstratosphere/source/os/impl/os_multiple_wait_object_list.hpp b/libraries/libstratosphere/source/os/impl/os_multiple_wait_object_list.hpp index 298b93f5f..d70eab597 100644 --- a/libraries/libstratosphere/source/os/impl/os_multiple_wait_object_list.hpp +++ b/libraries/libstratosphere/source/os/impl/os_multiple_wait_object_list.hpp @@ -27,7 +27,7 @@ namespace ams::os::impl { public: void SignalAllThreads() { for (MultiWaitHolderBase &holder_base : this->object_list) { - holder_base.GetMultiWait()->SignalAndWakeupThread(&holder_base); + holder_base.GetMultiWait()->SignalAndWakeupThread(std::addressof(holder_base)); } } diff --git a/libraries/libstratosphere/source/os/impl/os_rw_lock_target_impl.os.horizon.cpp b/libraries/libstratosphere/source/os/impl/os_rw_lock_target_impl.os.horizon.cpp index d77cc1c4a..a90ac69e4 100644 --- a/libraries/libstratosphere/source/os/impl/os_rw_lock_target_impl.os.horizon.cpp +++ b/libraries/libstratosphere/source/os/impl/os_rw_lock_target_impl.os.horizon.cpp @@ -20,7 +20,7 @@ namespace ams::os::impl { #define ATOMIC_COMPARE_EXCHANGE_LOCK_COUNT(dst_ref, expected_ref, desired_ref, success, fail) \ - (__atomic_compare_exchange(reinterpret_cast(&dst_ref), reinterpret_cast(&expected_ref), reinterpret_cast(&desired_ref), true, success, fail)) + (__atomic_compare_exchange(reinterpret_cast(std::addressof(dst_ref)), reinterpret_cast(std::addressof(expected_ref)), reinterpret_cast(std::addressof(desired_ref)), true, success, fail)) void ReaderWriterLockHorizonImpl::AcquireReadLockWriteLocked(os::ReaderWriterLockType *rw_lock) { diff --git a/libraries/libstratosphere/source/os/os_multiple_wait.cpp b/libraries/libstratosphere/source/os/os_multiple_wait.cpp index 4e6e0ee9a..47d2b3308 100644 --- a/libraries/libstratosphere/source/os/os_multiple_wait.cpp +++ b/libraries/libstratosphere/source/os/os_multiple_wait.cpp @@ -102,7 +102,7 @@ namespace ams::os { AMS_ASSERT(!holder_base->IsLinked()); impl.LinkMultiWaitHolder(*holder_base); - holder_base->SetMultiWait(&impl); + holder_base->SetMultiWait(std::addressof(impl)); } void UnlinkMultiWaitHolder(MultiWaitHolderType *holder) { diff --git a/libraries/libstratosphere/source/os/os_random.cpp b/libraries/libstratosphere/source/os/os_random.cpp index ef18f0467..0d5dafbae 100644 --- a/libraries/libstratosphere/source/os/os_random.cpp +++ b/libraries/libstratosphere/source/os/os_random.cpp @@ -30,7 +30,7 @@ namespace ams::os { const T EffectiveMax = (std::numeric_limits::max() / max) * max; T cur_rnd; while (true) { - os::GenerateRandomBytes(&cur_rnd, sizeof(T)); + os::GenerateRandomBytes(std::addressof(cur_rnd), sizeof(T)); if (cur_rnd < EffectiveMax) { return cur_rnd % max; } @@ -43,7 +43,7 @@ namespace ams::os { std::scoped_lock lk(g_random_mutex); if (AMS_UNLIKELY(!g_initialized_random)) { - impl::InitializeRandomImpl(&g_random); + impl::InitializeRandomImpl(std::addressof(g_random)); g_initialized_random = true; } diff --git a/libraries/libstratosphere/source/patcher/patcher_api.cpp b/libraries/libstratosphere/source/patcher/patcher_api.cpp index 357705770..1898046b0 100644 --- a/libraries/libstratosphere/source/patcher/patcher_api.cpp +++ b/libraries/libstratosphere/source/patcher/patcher_api.cpp @@ -66,11 +66,11 @@ namespace ams::patcher { bool MatchesModuleId(const char *name, size_t name_len, size_t extension_len, const ro::ModuleId *module_id) { /* Get module id. */ ro::ModuleId module_id_from_name; - if (!ParseModuleIdFromPath(&module_id_from_name, name, name_len, extension_len)) { + if (!ParseModuleIdFromPath(std::addressof(module_id_from_name), name, name_len, extension_len)) { return false; } - return std::memcmp(&module_id_from_name, module_id, sizeof(*module_id)) == 0; + return std::memcmp(std::addressof(module_id_from_name), module_id, sizeof(*module_id)) == 0; } bool IsIpsFileForModule(const char *name, const ro::ModuleId *module_id) { diff --git a/libraries/libstratosphere/source/pm/pm_boot_mode_api.cpp b/libraries/libstratosphere/source/pm/pm_boot_mode_api.cpp index 347d4653e..a4a5db954 100644 --- a/libraries/libstratosphere/source/pm/pm_boot_mode_api.cpp +++ b/libraries/libstratosphere/source/pm/pm_boot_mode_api.cpp @@ -21,7 +21,7 @@ namespace ams::pm::bm { /* Both functions should be weakly linked, so that they can be overridden by ams::boot2 as needed. */ BootMode WEAK_SYMBOL GetBootMode() { PmBootMode boot_mode = PmBootMode_Normal; - R_ABORT_UNLESS(pmbmGetBootMode(&boot_mode)); + R_ABORT_UNLESS(pmbmGetBootMode(std::addressof(boot_mode))); return static_cast(boot_mode); } diff --git a/libraries/libstratosphere/source/pm/pm_dmnt_api.cpp b/libraries/libstratosphere/source/pm/pm_dmnt_api.cpp index faed95bfa..fd382ada7 100644 --- a/libraries/libstratosphere/source/pm/pm_dmnt_api.cpp +++ b/libraries/libstratosphere/source/pm/pm_dmnt_api.cpp @@ -34,7 +34,7 @@ namespace ams::pm::dmnt { Result HookToCreateApplicationProcess(os::NativeHandle *out_handle) { Event evt; - R_TRY(pmdmntHookToCreateApplicationProcess(&evt)); + R_TRY(pmdmntHookToCreateApplicationProcess(std::addressof(evt))); *out_handle = evt.revent; return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/pm/pm_info_api.cpp b/libraries/libstratosphere/source/pm/pm_info_api.cpp index 5a13daff7..d46fad90f 100644 --- a/libraries/libstratosphere/source/pm/pm_info_api.cpp +++ b/libraries/libstratosphere/source/pm/pm_info_api.cpp @@ -36,7 +36,7 @@ namespace ams::pm::info { bool HasLaunchedBootProgram(ncm::ProgramId program_id) { bool has_launched = false; - R_ABORT_UNLESS(HasLaunchedBootProgram(&has_launched, program_id)); + R_ABORT_UNLESS(HasLaunchedBootProgram(std::addressof(has_launched), program_id)); return has_launched; } @@ -44,7 +44,7 @@ namespace ams::pm::info { Result IsHblProcessId(bool *out, os::ProcessId process_id) { ncm::ProgramLocation loc; cfg::OverrideStatus override_status; - R_TRY(GetProcessInfo(&loc, &override_status, process_id)); + R_TRY(GetProcessInfo(std::addressof(loc), std::addressof(override_status), process_id)); *out = override_status.IsHbl(); return ResultSuccess(); @@ -52,7 +52,7 @@ namespace ams::pm::info { Result IsHblProgramId(bool *out, ncm::ProgramId program_id) { os::ProcessId process_id; - R_TRY(GetProcessId(&process_id, program_id)); + R_TRY(GetProcessId(std::addressof(process_id), program_id)); return IsHblProcessId(out, process_id); } diff --git a/libraries/libstratosphere/source/pm/pm_info_api_weak.cpp b/libraries/libstratosphere/source/pm/pm_info_api_weak.cpp index 3784e3549..56f72787b 100644 --- a/libraries/libstratosphere/source/pm/pm_info_api_weak.cpp +++ b/libraries/libstratosphere/source/pm/pm_info_api_weak.cpp @@ -21,7 +21,7 @@ namespace ams::pm::info { /* Information API. */ Result WEAK_SYMBOL HasLaunchedBootProgram(bool *out, ncm::ProgramId program_id) { bool has_launched = false; - R_TRY(pminfoAtmosphereHasLaunchedBootProgram(&has_launched, static_cast(program_id))); + R_TRY(pminfoAtmosphereHasLaunchedBootProgram(std::addressof(has_launched), static_cast(program_id))); *out = has_launched; return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/pm/pm_shell_api.cpp b/libraries/libstratosphere/source/pm/pm_shell_api.cpp index 862e6b0b7..1d3622642 100644 --- a/libraries/libstratosphere/source/pm/pm_shell_api.cpp +++ b/libraries/libstratosphere/source/pm/pm_shell_api.cpp @@ -21,7 +21,7 @@ namespace ams::pm::shell { Result WEAK_SYMBOL LaunchProgram(os::ProcessId *out, const ncm::ProgramLocation &loc, u32 launch_flags) { static_assert(sizeof(ncm::ProgramLocation) == sizeof(NcmProgramLocation)); static_assert(alignof(ncm::ProgramLocation) == alignof(NcmProgramLocation)); - return pmshellLaunchProgram(launch_flags, reinterpret_cast(&loc), reinterpret_cast(out)); + return pmshellLaunchProgram(launch_flags, reinterpret_cast(std::addressof(loc)), reinterpret_cast(out)); } Result TerminateProcess(os::ProcessId process_id) { diff --git a/libraries/libstratosphere/source/sf/cmif/sf_cmif_domain_manager.cpp b/libraries/libstratosphere/source/sf/cmif/sf_cmif_domain_manager.cpp index 83d14b253..b882ea080 100644 --- a/libraries/libstratosphere/source/sf/cmif/sf_cmif_domain_manager.cpp +++ b/libraries/libstratosphere/source/sf/cmif/sf_cmif_domain_manager.cpp @@ -19,7 +19,7 @@ namespace ams::sf::cmif { ServerDomainManager::Domain::~Domain() { while (!this->entries.empty()) { - Entry *entry = &this->entries.front(); + Entry *entry = std::addressof(this->entries.front()); { std::scoped_lock lk(this->manager->entry_owner_lock); AMS_ABORT_UNLESS(entry->owner == this); @@ -127,7 +127,7 @@ namespace ams::sf::cmif { return nullptr; } - Entry *e = &this->free_list.front(); + Entry *e = std::addressof(this->free_list.front()); this->free_list.pop_front(); return e; } diff --git a/libraries/libstratosphere/source/sf/cmif/sf_cmif_domain_service_object.cpp b/libraries/libstratosphere/source/sf/cmif/sf_cmif_domain_service_object.cpp index 1be7e2962..ae4c81a47 100644 --- a/libraries/libstratosphere/source/sf/cmif/sf_cmif_domain_service_object.cpp +++ b/libraries/libstratosphere/source/sf/cmif/sf_cmif_domain_service_object.cpp @@ -43,9 +43,9 @@ namespace ams::sf::cmif { std::memcpy(in_object_ids, reinterpret_cast(in_message_raw_data.GetAddress() + in_message_raw_data.GetSize()), sizeof(DomainObjectId) * in_header->num_in_objects); DomainServiceObjectProcessor domain_processor(domain, in_object_ids, in_header->num_in_objects); if (ctx.processor == nullptr) { - ctx.processor = &domain_processor; + ctx.processor = std::addressof(domain_processor); } else { - ctx.processor->SetImplementationProcessor(&domain_processor); + ctx.processor->SetImplementationProcessor(std::addressof(domain_processor)); } ctx.srv_obj = target_object.GetServiceObjectUnsafe(); return target_object.ProcessMessage(ctx, in_message_raw_data); @@ -82,9 +82,9 @@ namespace ams::sf::cmif { std::memcpy(in_object_ids, reinterpret_cast(in_message_raw_data.GetAddress() + in_message_raw_data.GetSize()), sizeof(DomainObjectId) * in_header->num_in_objects); DomainServiceObjectProcessor domain_processor(domain, in_object_ids, in_header->num_in_objects); if (ctx.processor == nullptr) { - ctx.processor = &domain_processor; + ctx.processor = std::addressof(domain_processor); } else { - ctx.processor->SetImplementationProcessor(&domain_processor); + ctx.processor->SetImplementationProcessor(std::addressof(domain_processor)); } ctx.srv_obj = target_object.GetServiceObjectUnsafe(); return target_object.ProcessMessage(ctx, in_message_raw_data); diff --git a/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_domain_session_manager.cpp b/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_domain_session_manager.cpp index 7b5b5fc66..038de40dd 100644 --- a/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_domain_session_manager.cpp +++ b/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_domain_session_manager.cpp @@ -79,7 +79,7 @@ namespace ams::sf::hipc { /* The object ID reservation cannot fail here, as that would cause desynchronization from target domain. */ object_id = cmif::DomainObjectId{session->forward_service->object_id}; - domain->ReserveSpecificIds(&object_id, 1); + domain->ReserveSpecificIds(std::addressof(object_id), 1); /* Register the object. */ domain->RegisterObject(object_id, std::move(session->srv_obj_holder)); @@ -91,7 +91,7 @@ namespace ams::sf::hipc { SharedPointer cmif_domain(domain, false); /* Reserve a new object in the domain. */ - R_TRY(domain->ReserveIds(&object_id, 1)); + R_TRY(domain->ReserveIds(std::addressof(object_id), 1)); /* Register the object. */ domain->RegisterObject(object_id, std::move(session->srv_obj_holder)); @@ -136,7 +136,7 @@ namespace ams::sf::hipc { } else { /* Copy from the target domain. */ os::NativeHandle new_forward_target; - R_TRY(cmifCopyFromCurrentDomain(this->session->forward_service->session, object_id.value, &new_forward_target)); + R_TRY(cmifCopyFromCurrentDomain(this->session->forward_service->session, object_id.value, std::addressof(new_forward_target))); /* Create new session handles. */ os::NativeHandle server_handle, client_handle; diff --git a/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_manager.cpp b/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_manager.cpp index f5823ba5a..7b5ecb0b0 100644 --- a/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_manager.cpp +++ b/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_manager.cpp @@ -21,7 +21,7 @@ namespace ams::sf::hipc { Result ServerManagerBase::InstallMitmServerImpl(os::NativeHandle *out_port_handle, sm::ServiceName service_name, ServerManagerBase::MitmQueryFunction query_func) { /* Install the Mitm. */ os::NativeHandle query_handle; - R_TRY(sm::mitm::InstallMitm(out_port_handle, &query_handle, service_name)); + R_TRY(sm::mitm::InstallMitm(out_port_handle, std::addressof(query_handle), service_name)); /* Register the query handle. */ impl::RegisterMitmQueryHandle(query_handle, query_func); @@ -57,9 +57,9 @@ namespace ams::sf::hipc { while (true) { this->LinkDeferred(); auto selected = os::WaitAny(std::addressof(this->multi_wait)); - if (selected == &this->request_stop_event_holder) { + if (selected == std::addressof(this->request_stop_event_holder)) { return nullptr; - } else if (selected == &this->notify_event_holder) { + } else if (selected == std::addressof(this->notify_event_holder)) { this->notify_event.Clear(); } else { os::UnlinkMultiWaitHolder(selected); diff --git a/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_session_manager.cpp b/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_session_manager.cpp index b79a20f5a..9802621d1 100644 --- a/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_session_manager.cpp +++ b/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_session_manager.cpp @@ -102,7 +102,7 @@ namespace ams::sf::hipc { Result ServerSessionManager::AcceptSessionImpl(ServerSession *session_memory, os::NativeHandle port_handle, cmif::ServiceObjectHolder &&obj) { /* Create session handle. */ os::NativeHandle session_handle; - R_TRY(svc::AcceptSession(&session_handle, port_handle)); + R_TRY(svc::AcceptSession(std::addressof(session_handle), port_handle)); auto session_guard = SCOPE_GUARD { os::CloseNativeHandle(session_handle); }; @@ -133,7 +133,7 @@ namespace ams::sf::hipc { Result ServerSessionManager::AcceptMitmSessionImpl(ServerSession *session_memory, os::NativeHandle mitm_port_handle, cmif::ServiceObjectHolder &&obj, std::shared_ptr<::Service> &&fsrv) { /* Create session handle. */ os::NativeHandle mitm_session_handle; - R_TRY(svc::AcceptSession(&mitm_session_handle, mitm_port_handle)); + R_TRY(svc::AcceptSession(std::addressof(mitm_session_handle), mitm_port_handle)); auto session_guard = SCOPE_GUARD { os::CloseNativeHandle(mitm_session_handle); }; @@ -147,25 +147,25 @@ namespace ams::sf::hipc { Result ServerSessionManager::RegisterSession(os::NativeHandle session_handle, cmif::ServiceObjectHolder &&obj) { /* We don't actually care about what happens to the session. It'll get linked. */ ServerSession *session_ptr = nullptr; - return this->RegisterSession(&session_ptr, session_handle, std::forward(obj)); + return this->RegisterSession(std::addressof(session_ptr), session_handle, std::forward(obj)); } Result ServerSessionManager::AcceptSession(os::NativeHandle port_handle, cmif::ServiceObjectHolder &&obj) { /* We don't actually care about what happens to the session. It'll get linked. */ ServerSession *session_ptr = nullptr; - return this->AcceptSession(&session_ptr, port_handle, std::forward(obj)); + return this->AcceptSession(std::addressof(session_ptr), port_handle, std::forward(obj)); } Result ServerSessionManager::RegisterMitmSession(os::NativeHandle mitm_session_handle, cmif::ServiceObjectHolder &&obj, std::shared_ptr<::Service> &&fsrv) { /* We don't actually care about what happens to the session. It'll get linked. */ ServerSession *session_ptr = nullptr; - return this->RegisterMitmSession(&session_ptr, mitm_session_handle, std::forward(obj), std::forward>(fsrv)); + return this->RegisterMitmSession(std::addressof(session_ptr), mitm_session_handle, std::forward(obj), std::forward>(fsrv)); } Result ServerSessionManager::AcceptMitmSession(os::NativeHandle mitm_port_handle, cmif::ServiceObjectHolder &&obj, std::shared_ptr<::Service> &&fsrv) { /* We don't actually care about what happens to the session. It'll get linked. */ ServerSession *session_ptr = nullptr; - return this->AcceptMitmSession(&session_ptr, mitm_port_handle, std::forward(obj), std::forward>(fsrv)); + return this->AcceptMitmSession(std::addressof(session_ptr), mitm_port_handle, std::forward(obj), std::forward>(fsrv)); } Result ServerSessionManager::ReceiveRequestImpl(ServerSession *session, const cmif::PointerAndSize &message) { @@ -184,7 +184,7 @@ namespace ams::sf::hipc { ); } hipc::ReceiveResult recv_result; - R_TRY(hipc::Receive(&recv_result, session->session_handle, message)); + R_TRY(hipc::Receive(std::addressof(recv_result), session->session_handle, message)); switch (recv_result) { case hipc::ReceiveResult::Success: session->is_closed = false; @@ -203,7 +203,7 @@ namespace ams::sf::hipc { NX_CONSTEXPR u32 GetCmifCommandType(const cmif::PointerAndSize &message) { HipcHeader hdr = {}; - __builtin_memcpy(&hdr, message.GetPointer(), sizeof(hdr)); + __builtin_memcpy(std::addressof(hdr), message.GetPointer(), sizeof(hdr)); return hdr.type; } @@ -289,7 +289,7 @@ namespace ams::sf::hipc { .manager = this, .session = session, .processor = nullptr, /* Filled in by template implementations. */ - .handles_to_close = &handles_to_close, + .handles_to_close = std::addressof(handles_to_close), .pointer_buffer = session->pointer_buffer, .in_message_buffer = in_message, .out_message_buffer = out_message, diff --git a/libraries/libstratosphere/source/sm/sm_manager_api.cpp b/libraries/libstratosphere/source/sm/sm_manager_api.cpp index 296c40858..80372381c 100644 --- a/libraries/libstratosphere/source/sm/sm_manager_api.cpp +++ b/libraries/libstratosphere/source/sm/sm_manager_api.cpp @@ -22,7 +22,7 @@ namespace ams::sm::manager { /* Manager API. */ Result RegisterProcess(os::ProcessId process_id, ncm::ProgramId program_id, cfg::OverrideStatus status, const void *acid, size_t acid_size, const void *aci, size_t aci_size) { static_assert(sizeof(status) == sizeof(CfgOverrideStatus), "CfgOverrideStatus definition"); - return smManagerAtmosphereRegisterProcess(static_cast(process_id), static_cast(program_id), reinterpret_cast(&status), acid, acid_size, aci, aci_size); + return smManagerAtmosphereRegisterProcess(static_cast(process_id), static_cast(program_id), reinterpret_cast(std::addressof(status)), acid, acid_size, aci, aci_size); } Result UnregisterProcess(os::ProcessId process_id) { diff --git a/libraries/libstratosphere/source/sm/sm_utils.hpp b/libraries/libstratosphere/source/sm/sm_utils.hpp index 73fcd6eb4..a7d6f6cad 100644 --- a/libraries/libstratosphere/source/sm/sm_utils.hpp +++ b/libraries/libstratosphere/source/sm/sm_utils.hpp @@ -40,19 +40,17 @@ namespace ams::sm::impl { TipcService srv; { std::scoped_lock lk(GetPerThreadSessionMutex()); - R_ABORT_UNLESS(smAtmosphereOpenSession(&srv)); + R_ABORT_UNLESS(smAtmosphereOpenSession(std::addressof(srv))); } { - ON_SCOPE_EXIT { smAtmosphereCloseSession(&srv); }; - return f(&srv); + ON_SCOPE_EXIT { smAtmosphereCloseSession(std::addressof(srv)); }; + return f(std::addressof(srv)); } } - NX_CONSTEXPR SmServiceName ConvertName(sm::ServiceName name) { + constexpr ALWAYS_INLINE SmServiceName ConvertName(sm::ServiceName name) { static_assert(sizeof(SmServiceName) == sizeof(sm::ServiceName)); - SmServiceName ret = {}; - __builtin_memcpy(&ret, &name, sizeof(sm::ServiceName)); - return ret; + return std::bit_cast(name); } } diff --git a/libraries/libstratosphere/source/spl/smc/spl_smc.cpp b/libraries/libstratosphere/source/spl/smc/spl_smc.cpp index d531eeb1e..b6416eed0 100644 --- a/libraries/libstratosphere/source/spl/smc/spl_smc.cpp +++ b/libraries/libstratosphere/source/spl/smc/spl_smc.cpp @@ -173,13 +173,13 @@ namespace ams::spl::smc { svc::SecureMonitorArguments args; args.r[0] = static_cast(FunctionId::ReencryptDeviceUniqueData); - args.r[1] = reinterpret_cast(&access_key_dec); - args.r[2] = reinterpret_cast(&access_key_enc); + args.r[1] = reinterpret_cast(std::addressof(access_key_dec)); + args.r[2] = reinterpret_cast(std::addressof(access_key_enc)); args.r[3] = option; args.r[4] = reinterpret_cast(data); args.r[5] = size; - args.r[6] = reinterpret_cast(&source_dec); - args.r[7] = reinterpret_cast(&source_enc); + args.r[6] = reinterpret_cast(std::addressof(source_dec)); + args.r[7] = reinterpret_cast(std::addressof(source_enc)); svc::CallSecureMonitor(std::addressof(args)); return static_cast(args.r[0]); diff --git a/libraries/libstratosphere/source/updater/updater_api.cpp b/libraries/libstratosphere/source/updater/updater_api.cpp index 95f65cb06..98d600655 100644 --- a/libraries/libstratosphere/source/updater/updater_api.cpp +++ b/libraries/libstratosphere/source/updater/updater_api.cpp @@ -112,7 +112,7 @@ namespace ams::updater { Result VerifyBootImagesAndRepairIfNeeded(bool *out_repaired, BootModeType mode, void *work_buffer, size_t work_buffer_size, BootImageUpdateType boot_image_update_type) { /* Get system data id for boot images (819/81A/81B/81C). */ ncm::SystemDataId bip_data_id = {}; - R_TRY(GetBootImagePackageId(&bip_data_id, mode, work_buffer, work_buffer_size)); + R_TRY(GetBootImagePackageId(std::addressof(bip_data_id), mode, work_buffer, work_buffer_size)); /* Verify the boot images in NAND. */ R_TRY_CATCH(VerifyBootImages(bip_data_id, mode, work_buffer, work_buffer_size, boot_image_update_type)) { @@ -174,7 +174,7 @@ namespace ams::updater { R_TRY(ValidateBctFileHash(boot0_accessor, Boot0Partition::BctNormalSub, nand_hash, work_buffer, work_buffer_size, boot_image_update_type)); /* Compare Package1 Normal/Sub hashes. */ - R_TRY(GetFileHash(&size, file_hash, GetPackage1Path(boot_image_update_type), work_buffer, work_buffer_size)); + R_TRY(GetFileHash(std::addressof(size), file_hash, GetPackage1Path(boot_image_update_type), work_buffer, work_buffer_size)); R_TRY(boot0_accessor.GetHash(nand_hash, size, work_buffer, work_buffer_size, Boot0Partition::Package1NormalMain)); R_TRY(CompareHash(file_hash, nand_hash, sizeof(file_hash))); @@ -183,7 +183,7 @@ namespace ams::updater { R_TRY(CompareHash(file_hash, nand_hash, sizeof(file_hash))); /* Compare Package2 Normal/Sub hashes. */ - R_TRY(GetFileHash(&size, file_hash, GetPackage2Path(boot_image_update_type), work_buffer, work_buffer_size)); + R_TRY(GetFileHash(std::addressof(size), file_hash, GetPackage2Path(boot_image_update_type), work_buffer, work_buffer_size)); R_TRY(GetPackage2Hash(nand_hash, size, work_buffer, work_buffer_size, Package2Type::NormalMain)); R_TRY(CompareHash(file_hash, nand_hash, sizeof(file_hash))); @@ -236,7 +236,7 @@ namespace ams::updater { R_TRY(ValidateBctFileHash(boot0_accessor, Boot0Partition::BctSafeSub, nand_hash, work_buffer, work_buffer_size, boot_image_update_type)); /* Compare Package1 Normal/Sub hashes. */ - R_TRY(GetFileHash(&size, file_hash, GetPackage1Path(boot_image_update_type), work_buffer, work_buffer_size)); + R_TRY(GetFileHash(std::addressof(size), file_hash, GetPackage1Path(boot_image_update_type), work_buffer, work_buffer_size)); R_TRY(boot1_accessor.GetHash(nand_hash, size, work_buffer, work_buffer_size, Boot1Partition::Package1SafeMain)); R_TRY(CompareHash(file_hash, nand_hash, sizeof(file_hash))); @@ -245,7 +245,7 @@ namespace ams::updater { R_TRY(CompareHash(file_hash, nand_hash, sizeof(file_hash))); /* Compare Package2 Normal/Sub hashes. */ - R_TRY(GetFileHash(&size, file_hash, GetPackage2Path(boot_image_update_type), work_buffer, work_buffer_size)); + R_TRY(GetFileHash(std::addressof(size), file_hash, GetPackage2Path(boot_image_update_type), work_buffer, work_buffer_size)); R_TRY(GetPackage2Hash(nand_hash, size, work_buffer, work_buffer_size, Package2Type::SafeMain)); R_TRY(CompareHash(file_hash, nand_hash, sizeof(file_hash))); @@ -291,7 +291,7 @@ namespace ams::updater { void *work = reinterpret_cast(reinterpret_cast(work_buffer) + BctSize); size_t size; - R_TRY(ReadFile(&size, bct, BctSize, GetBctPath(boot_image_update_type))); + R_TRY(ReadFile(std::addressof(size), bct, BctSize, GetBctPath(boot_image_update_type))); if (HasEks(boot_image_update_type)) { R_TRY(boot0_accessor.UpdateEks(bct, work)); } @@ -361,7 +361,7 @@ namespace ams::updater { void *work = reinterpret_cast(reinterpret_cast(work_buffer) + BctSize); size_t size; - R_TRY(ReadFile(&size, bct, BctSize, GetBctPath(boot_image_update_type))); + R_TRY(ReadFile(std::addressof(size), bct, BctSize, GetBctPath(boot_image_update_type))); if (HasEks(boot_image_update_type)) { R_TRY(boot0_accessor.UpdateEks(bct, work)); } @@ -419,7 +419,7 @@ namespace ams::updater { void *work = reinterpret_cast(reinterpret_cast(work_buffer) + BctSize); size_t size; - R_TRY(ReadFile(&size, bct, BctSize, GetBctPath(boot_image_update_type))); + R_TRY(ReadFile(std::addressof(size), bct, BctSize, GetBctPath(boot_image_update_type))); if (HasEks(boot_image_update_type)) { R_TRY(accessor.UpdateEks(bct, work)); } @@ -541,7 +541,7 @@ namespace ams::updater { /* Get verification state from NAND. */ VerificationState verification_state; - R_TRY(GetVerificationState(&verification_state, work_buffer, work_buffer_size)); + R_TRY(GetVerificationState(std::addressof(verification_state), work_buffer, work_buffer_size)); /* If we don't need to verify anything, we're done. */ if (!verification_state.needs_verify_normal && !verification_state.needs_verify_safe) { diff --git a/libraries/libstratosphere/source/updater/updater_bis_management.hpp b/libraries/libstratosphere/source/updater/updater_bis_management.hpp index 90d5ae751..674259cfb 100644 --- a/libraries/libstratosphere/source/updater/updater_bis_management.hpp +++ b/libraries/libstratosphere/source/updater/updater_bis_management.hpp @@ -127,7 +127,7 @@ namespace ams::updater { const OffsetSizeType *entry = nullptr; for (size_t i = 0; i < Meta::NumEntries; i++) { if (Meta::Entries[i].which == which) { - entry = &Meta::Entries[i]; + entry = std::addressof(Meta::Entries[i]); break; } } diff --git a/libraries/libstratosphere/source/util/util_ini.cpp b/libraries/libstratosphere/source/util/util_ini.cpp index 8b1b73b74..3da840291 100644 --- a/libraries/libstratosphere/source/util/util_ini.cpp +++ b/libraries/libstratosphere/source/util/util_ini.cpp @@ -115,12 +115,12 @@ namespace ams::util::ini { int ParseFile(fs::FileHandle file, void *user_ctx, Handler h) { FileContext ctx(file); - return ini_parse_stream(ini_reader_file_handle, &ctx, h, user_ctx); + return ini_parse_stream(ini_reader_file_handle, std::addressof(ctx), h, user_ctx); } int ParseFile(fs::fsa::IFile *file, void *user_ctx, Handler h) { IFileContext ctx(file); - return ini_parse_stream(ini_reader_ifile, &ctx, h, user_ctx); + return ini_parse_stream(ini_reader_ifile, std::addressof(ctx), h, user_ctx); } } \ No newline at end of file diff --git a/libraries/libvapours/include/vapours/util/util_intrusive_list.hpp b/libraries/libvapours/include/vapours/util/util_intrusive_list.hpp index 655ec3f79..f87ce0de1 100644 --- a/libraries/libvapours/include/vapours/util/util_intrusive_list.hpp +++ b/libraries/libvapours/include/vapours/util/util_intrusive_list.hpp @@ -200,23 +200,23 @@ namespace ams::util { } ALWAYS_INLINE iterator end() { - return iterator(&this->root_node); + return iterator(std::addressof(this->root_node)); } ALWAYS_INLINE const_iterator end() const { - return const_iterator(&this->root_node); + return const_iterator(std::addressof(this->root_node)); } ALWAYS_INLINE iterator iterator_to(reference v) { /* Only allow iterator_to for values in lists. */ AMS_ASSERT(v.IsLinked()); - return iterator(&v); + return iterator(std::addressof(v)); } ALWAYS_INLINE const_iterator iterator_to(const_reference v) const { /* Only allow iterator_to for values in lists. */ AMS_ASSERT(v.IsLinked()); - return const_iterator(&v); + return const_iterator(std::addressof(v)); } /* Content management. */ @@ -245,11 +245,11 @@ namespace ams::util { } ALWAYS_INLINE void push_back(reference node) { - this->root_node.LinkPrev(&node); + this->root_node.LinkPrev(std::addressof(node)); } ALWAYS_INLINE void push_front(reference node) { - this->root_node.LinkNext(&node); + this->root_node.LinkNext(std::addressof(node)); } ALWAYS_INLINE void pop_back() { @@ -261,8 +261,8 @@ namespace ams::util { } ALWAYS_INLINE iterator insert(const_iterator pos, reference node) { - pos.GetNonConstIterator()->LinkPrev(&node); - return iterator(&node); + pos.GetNonConstIterator()->LinkPrev(std::addressof(node)); + return iterator(std::addressof(node)); } ALWAYS_INLINE void splice(const_iterator pos, IntrusiveListImpl &o) { @@ -303,8 +303,8 @@ namespace ams::util { iterator pos(_pos.GetNonConstIterator()); iterator first(_first.GetNonConstIterator()); iterator last(_last.GetNonConstIterator()); - first->Unlink(&*last); - pos->SplicePrev(&*first, &*first); + first->Unlink(std::addressof(*last)); + pos->SplicePrev(std::addressof(*first), std::addressof(*first)); } }; @@ -362,7 +362,7 @@ namespace ams::util { } ALWAYS_INLINE pointer operator->() const { - return &Traits::GetParent(*this->iterator); + return std::addressof(Traits::GetParent(*this->iterator)); } ALWAYS_INLINE reference operator*() const { @@ -562,11 +562,11 @@ namespace ams::util { } static constexpr ALWAYS_INLINE Derived &GetParent(IntrusiveListNode &node) { - return util::GetParentReference(&node); + return util::GetParentReference(std::addressof(node)); } static constexpr ALWAYS_INLINE Derived const &GetParent(IntrusiveListNode const &node) { - return util::GetParentReference(&node); + return util::GetParentReference(std::addressof(node)); } private: static constexpr TypedStorage DerivedStorage = {}; @@ -597,11 +597,11 @@ namespace ams::util { } static constexpr ALWAYS_INLINE Derived &GetParent(IntrusiveListNode &node) { - return util::GetParentReference(&node); + return util::GetParentReference(std::addressof(node)); } static constexpr ALWAYS_INLINE Derived const &GetParent(IntrusiveListNode const &node) { - return util::GetParentReference(&node); + return util::GetParentReference(std::addressof(node)); } }; diff --git a/libraries/libvapours/include/vapours/util/util_tinymt.hpp b/libraries/libvapours/include/vapours/util/util_tinymt.hpp index a3d194204..94c1adf28 100644 --- a/libraries/libvapours/include/vapours/util/util_tinymt.hpp +++ b/libraries/libvapours/include/vapours/util/util_tinymt.hpp @@ -130,14 +130,14 @@ namespace ams::util { { const int num_init_iterations = std::max(seed_count + 1, MinimumInitIterations) - 1; - GenerateInitialValuePlus(&this->state, 0, seed_count); + GenerateInitialValuePlus(std::addressof(this->state), 0, seed_count); for (int i = 0; i < num_init_iterations; i++) { - GenerateInitialValuePlus(&this->state, (i + 1) % NumStateWords, (i < seed_count) ? seed[i] : 0); + GenerateInitialValuePlus(std::addressof(this->state), (i + 1) % NumStateWords, (i < seed_count) ? seed[i] : 0); } for (int i = 0; i < static_cast(NumStateWords); i++) { - GenerateInitialValueXor(&this->state, (i + 1 + num_init_iterations) % NumStateWords); + GenerateInitialValueXor(std::addressof(this->state), (i + 1 + num_init_iterations) % NumStateWords); } } @@ -163,7 +163,7 @@ namespace ams::util { /* Make sure we're aligned. */ if (start < aligned_start) { const u32 rnd = this->GenerateRandomU32(); - std::memcpy(dst, &rnd, aligned_start - start); + std::memcpy(dst, std::addressof(rnd), aligned_start - start); } /* Write as many aligned u32s as we can. */ @@ -179,7 +179,7 @@ namespace ams::util { /* Handle any leftover unaligned data. */ if (aligned_end < end) { const u32 rnd = this->GenerateRandomU32(); - std::memcpy(reinterpret_cast(aligned_end), &rnd, end - aligned_end); + std::memcpy(reinterpret_cast(aligned_end), std::addressof(rnd), end - aligned_end); } } diff --git a/libraries/libvapours/source/crypto/impl/crypto_bignum_operations.cpp b/libraries/libvapours/source/crypto/impl/crypto_bignum_operations.cpp index 5e58088e1..31371663d 100644 --- a/libraries/libvapours/source/crypto/impl/crypto_bignum_operations.cpp +++ b/libraries/libvapours/source/crypto/impl/crypto_bignum_operations.cpp @@ -257,7 +257,7 @@ namespace ams::crypto::impl { if (!(power_1.IsValid() && power_2.IsValid() && power_3.IsValid())) { return false; } - decltype(power_1)* powers[3] = { &power_1, &power_2, &power_3 }; + decltype(power_1)* powers[3] = { std::addressof(power_1), std::addressof(power_2), std::addressof(power_3) }; /* Set the powers of src. */ Copy(power_1.GetBuffer(), src, mod_words); diff --git a/libraries/libvapours/source/dd/dd_io_mapping.cpp b/libraries/libvapours/source/dd/dd_io_mapping.cpp index efc8127ae..b549b99a4 100644 --- a/libraries/libvapours/source/dd/dd_io_mapping.cpp +++ b/libraries/libvapours/source/dd/dd_io_mapping.cpp @@ -68,13 +68,13 @@ namespace ams::dd { if (hos::GetVersion() >= hos::Version_10_0_0) { svc::Size region_size = 0; - R_TRY_CATCH(svc::QueryIoMapping(&virt_addr, ®ion_size, aligned_addr, aligned_size)) { + R_TRY_CATCH(svc::QueryIoMapping(std::addressof(virt_addr), std::addressof(region_size), aligned_addr, aligned_size)) { /* Official software handles this by returning 0. */ R_CATCH(svc::ResultNotFound) { return 0; } } R_END_TRY_CATCH_WITH_ABORT_UNLESS; AMS_ASSERT(region_size >= aligned_size); } else { - R_TRY_CATCH(svc::LegacyQueryIoMapping(&virt_addr, aligned_addr, aligned_size)) { + R_TRY_CATCH(svc::LegacyQueryIoMapping(std::addressof(virt_addr), aligned_addr, aligned_size)) { /* Official software handles this by returning 0. */ R_CATCH(svc::ResultNotFound) { return 0; } } R_END_TRY_CATCH_WITH_ABORT_UNLESS; @@ -102,7 +102,7 @@ namespace ams::dd { u32 ReadWritePmcRegisterImpl(dd::PhysicalAddress phys_addr, u32 value, u32 mask) { u32 out_value; - R_ABORT_UNLESS(spl::smc::ConvertResult(spl::smc::AtmosphereReadWriteRegister(phys_addr, mask, value, &out_value))); + R_ABORT_UNLESS(spl::smc::ConvertResult(spl::smc::AtmosphereReadWriteRegister(phys_addr, mask, value, std::addressof(out_value)))); return out_value; } diff --git a/stratosphere/ams_mitm/source/amsmitm_fs_utils.cpp b/stratosphere/ams_mitm/source/amsmitm_fs_utils.cpp index 70521bc32..5dda00fc0 100644 --- a/stratosphere/ams_mitm/source/amsmitm_fs_utils.cpp +++ b/stratosphere/ams_mitm/source/amsmitm_fs_utils.cpp @@ -28,7 +28,7 @@ namespace ams::mitm::fs { /* Helpers. */ Result EnsureSdInitialized() { - R_UNLESS(serviceIsActive(&g_sd_filesystem.s), ams::fs::ResultSdCardNotPresent()); + R_UNLESS(serviceIsActive(std::addressof(g_sd_filesystem.s)), ams::fs::ResultSdCardNotPresent()); return ResultSuccess(); } @@ -39,17 +39,17 @@ namespace ams::mitm::fs { } void OpenGlobalSdCardFileSystem() { - R_ABORT_UNLESS(fsOpenSdCardFileSystem(&g_sd_filesystem)); + R_ABORT_UNLESS(fsOpenSdCardFileSystem(std::addressof(g_sd_filesystem))); } Result CreateSdFile(const char *path, s64 size, s32 option) { R_TRY(EnsureSdInitialized()); - return fsFsCreateFile(&g_sd_filesystem, path, size, option); + return fsFsCreateFile(std::addressof(g_sd_filesystem), path, size, option); } Result DeleteSdFile(const char *path) { R_TRY(EnsureSdInitialized()); - return fsFsDeleteFile(&g_sd_filesystem, path); + return fsFsDeleteFile(std::addressof(g_sd_filesystem), path); } bool HasSdFile(const char *path) { @@ -58,7 +58,7 @@ namespace ams::mitm::fs { } FsDirEntryType type; - if (R_FAILED(fsFsGetEntryType(&g_sd_filesystem, path, &type))) { + if (R_FAILED(fsFsGetEntryType(std::addressof(g_sd_filesystem), path, std::addressof(type)))) { return false; } @@ -85,7 +85,7 @@ namespace ams::mitm::fs { Result OpenSdFile(FsFile *out, const char *path, u32 mode) { R_TRY(EnsureSdInitialized()); - return fsFsOpenFile(&g_sd_filesystem, path, mode, out); + return fsFsOpenFile(std::addressof(g_sd_filesystem), path, mode, out); } Result OpenAtmosphereSdFile(FsFile *out, const char *path, u32 mode) { @@ -114,7 +114,7 @@ namespace ams::mitm::fs { Result CreateSdDirectory(const char *path) { R_TRY(EnsureSdInitialized()); - return fsFsCreateDirectory(&g_sd_filesystem, path); + return fsFsCreateDirectory(std::addressof(g_sd_filesystem), path); } Result CreateAtmosphereSdDirectory(const char *path) { @@ -125,7 +125,7 @@ namespace ams::mitm::fs { Result OpenSdDirectory(FsDir *out, const char *path, u32 mode) { R_TRY(EnsureSdInitialized()); - return fsFsOpenDirectory(&g_sd_filesystem, path, mode, out); + return fsFsOpenDirectory(std::addressof(g_sd_filesystem), path, mode, out); } Result OpenAtmosphereSdDirectory(FsDir *out, const char *path, u32 mode) { @@ -188,22 +188,22 @@ namespace ams::mitm::fs { /* Check if romfs.bin is present. */ { FsFile romfs_file; - if (R_SUCCEEDED(OpenAtmosphereSdFile(&romfs_file, program_id, "romfs.bin", OpenMode_Read))) { - fsFileClose(&romfs_file); + if (R_SUCCEEDED(OpenAtmosphereSdFile(std::addressof(romfs_file), program_id, "romfs.bin", OpenMode_Read))) { + fsFileClose(std::addressof(romfs_file)); return true; } } /* Check for romfs folder with content. */ FsDir romfs_dir; - if (R_FAILED(OpenAtmosphereSdRomfsDirectory(&romfs_dir, program_id, "", OpenDirectoryMode_All))) { + if (R_FAILED(OpenAtmosphereSdRomfsDirectory(std::addressof(romfs_dir), program_id, "", OpenDirectoryMode_All))) { return false; } - ON_SCOPE_EXIT { fsDirClose(&romfs_dir); }; + ON_SCOPE_EXIT { fsDirClose(std::addressof(romfs_dir)); }; /* Verify the folder has at least one entry. */ s64 num_entries = 0; - return R_SUCCEEDED(fsDirGetEntryCount(&romfs_dir, &num_entries)) && num_entries > 0; + return R_SUCCEEDED(fsDirGetEntryCount(std::addressof(romfs_dir), std::addressof(num_entries))) && num_entries > 0; } Result SaveAtmosphereSdFile(FsFile *out, ncm::ProgramId program_id, const char *path, void *data, size_t size) { @@ -215,17 +215,17 @@ namespace ams::mitm::fs { /* Unconditionally create. */ /* Don't check error, as a failure here should be okay. */ FsFile f; - fsFsCreateFile(&g_sd_filesystem, fixed_path, size, 0); + fsFsCreateFile(std::addressof(g_sd_filesystem), fixed_path, size, 0); /* Try to open. */ - R_TRY(fsFsOpenFile(&g_sd_filesystem, fixed_path, OpenMode_ReadWrite, &f)); - auto file_guard = SCOPE_GUARD { fsFileClose(&f); }; + R_TRY(fsFsOpenFile(std::addressof(g_sd_filesystem), fixed_path, OpenMode_ReadWrite, std::addressof(f))); + auto file_guard = SCOPE_GUARD { fsFileClose(std::addressof(f)); }; /* Try to set the size. */ - R_TRY(fsFileSetSize(&f, static_cast(size))); + R_TRY(fsFileSetSize(std::addressof(f), static_cast(size))); /* Try to write data. */ - R_TRY(fsFileWrite(&f, 0, data, size, FsWriteOption_Flush)); + R_TRY(fsFileWrite(std::addressof(f), 0, data, size, FsWriteOption_Flush)); /* Set output. */ file_guard.Cancel(); @@ -242,14 +242,14 @@ namespace ams::mitm::fs { /* Unconditionally create. */ /* Don't check error, as a failure here should be okay. */ FsFile f; - fsFsCreateFile(&g_sd_filesystem, fixed_path, size, 0); + fsFsCreateFile(std::addressof(g_sd_filesystem), fixed_path, size, 0); /* Try to open. */ - R_TRY(fsFsOpenFile(&g_sd_filesystem, fixed_path, OpenMode_ReadWrite, &f)); - auto file_guard = SCOPE_GUARD { fsFileClose(&f); }; + R_TRY(fsFsOpenFile(std::addressof(g_sd_filesystem), fixed_path, OpenMode_ReadWrite, std::addressof(f))); + auto file_guard = SCOPE_GUARD { fsFileClose(std::addressof(f)); }; /* Try to set the size. */ - R_TRY(fsFileSetSize(&f, static_cast(size))); + R_TRY(fsFileSetSize(std::addressof(f), static_cast(size))); /* Set output. */ file_guard.Cancel(); diff --git a/stratosphere/ams_mitm/source/amsmitm_initialization.cpp b/stratosphere/ams_mitm/source/amsmitm_initialization.cpp index be4cc51da..f0d08fb72 100644 --- a/stratosphere/ams_mitm/source/amsmitm_initialization.cpp +++ b/stratosphere/ams_mitm/source/amsmitm_initialization.cpp @@ -128,9 +128,9 @@ namespace ams::mitm { GetBackupFileName(bis_keys_backup_name, sizeof(bis_keys_backup_name), device_reference, "BISKEYS.bin"); mitm::fs::CreateAtmosphereSdFile(bis_keys_backup_name, sizeof(bis_keys), ams::fs::CreateOption_None); - R_ABORT_UNLESS(mitm::fs::OpenAtmosphereSdFile(&g_bis_key_file, bis_keys_backup_name, ams::fs::OpenMode_ReadWrite)); - R_ABORT_UNLESS(fsFileSetSize(&g_bis_key_file, sizeof(bis_keys))); - R_ABORT_UNLESS(fsFileWrite(&g_bis_key_file, 0, bis_keys, sizeof(bis_keys), FsWriteOption_Flush)); + R_ABORT_UNLESS(mitm::fs::OpenAtmosphereSdFile(std::addressof(g_bis_key_file), bis_keys_backup_name, ams::fs::OpenMode_ReadWrite)); + R_ABORT_UNLESS(fsFileSetSize(std::addressof(g_bis_key_file), sizeof(bis_keys))); + R_ABORT_UNLESS(fsFileWrite(std::addressof(g_bis_key_file), 0, bis_keys, sizeof(bis_keys), FsWriteOption_Flush)); /* NOTE: g_bis_key_file is intentionally not closed here. This prevents any other process from opening it. */ } @@ -167,7 +167,7 @@ namespace ams::mitm { if (const char *emummc_file_path = emummc::GetFilePath(); emummc_file_path != nullptr) { char emummc_path[ams::fs::EntryNameLengthMax + 1]; util::SNPrintf(emummc_path, sizeof(emummc_path), "%s/eMMC", emummc_file_path); - mitm::fs::OpenSdFile(&g_emummc_file, emummc_path, ams::fs::OpenMode_Read); + mitm::fs::OpenSdFile(std::addressof(g_emummc_file), emummc_path, ams::fs::OpenMode_Read); } } diff --git a/stratosphere/ams_mitm/source/amsmitm_prodinfo_utils.cpp b/stratosphere/ams_mitm/source/amsmitm_prodinfo_utils.cpp index 275daaa97..69740191b 100644 --- a/stratosphere/ams_mitm/source/amsmitm_prodinfo_utils.cpp +++ b/stratosphere/ams_mitm/source/amsmitm_prodinfo_utils.cpp @@ -297,28 +297,28 @@ namespace ams::mitm { void ReadStorageCalibrationBinary(CalibrationInfo *out) { FsStorage calibration_binary_storage; - R_ABORT_UNLESS(fsOpenBisStorage(&calibration_binary_storage, FsBisPartitionId_CalibrationBinary)); - ON_SCOPE_EXIT { fsStorageClose(&calibration_binary_storage); }; + R_ABORT_UNLESS(fsOpenBisStorage(std::addressof(calibration_binary_storage), FsBisPartitionId_CalibrationBinary)); + ON_SCOPE_EXIT { fsStorageClose(std::addressof(calibration_binary_storage)); }; - R_ABORT_UNLESS(fsStorageRead(&calibration_binary_storage, 0, out, sizeof(*out))); + R_ABORT_UNLESS(fsStorageRead(std::addressof(calibration_binary_storage), 0, out, sizeof(*out))); } constexpr inline const u8 SecureCalibrationBinaryBackupIv[crypto::Aes128CtrDecryptor::IvSize] = {}; void ReadStorageEncryptedSecureCalibrationBinaryBackupUnsafe(SecureCalibrationInfoBackup *out) { FsStorage calibration_binary_storage; - R_ABORT_UNLESS(fsOpenBisStorage(&calibration_binary_storage, FsBisPartitionId_CalibrationBinary)); - ON_SCOPE_EXIT { fsStorageClose(&calibration_binary_storage); }; + R_ABORT_UNLESS(fsOpenBisStorage(std::addressof(calibration_binary_storage), FsBisPartitionId_CalibrationBinary)); + ON_SCOPE_EXIT { fsStorageClose(std::addressof(calibration_binary_storage)); }; - R_ABORT_UNLESS(fsStorageRead(&calibration_binary_storage, SecureCalibrationInfoBackupOffset, out, sizeof(*out))); + R_ABORT_UNLESS(fsStorageRead(std::addressof(calibration_binary_storage), SecureCalibrationInfoBackupOffset, out, sizeof(*out))); } void WriteStorageEncryptedSecureCalibrationBinaryBackupUnsafe(const SecureCalibrationInfoBackup *src) { FsStorage calibration_binary_storage; - R_ABORT_UNLESS(fsOpenBisStorage(&calibration_binary_storage, FsBisPartitionId_CalibrationBinary)); - ON_SCOPE_EXIT { fsStorageClose(&calibration_binary_storage); }; + R_ABORT_UNLESS(fsOpenBisStorage(std::addressof(calibration_binary_storage), FsBisPartitionId_CalibrationBinary)); + ON_SCOPE_EXIT { fsStorageClose(std::addressof(calibration_binary_storage)); }; - R_ABORT_UNLESS(fsStorageWrite(&calibration_binary_storage, SecureCalibrationInfoBackupOffset, src, sizeof(*src))); + R_ABORT_UNLESS(fsStorageWrite(std::addressof(calibration_binary_storage), SecureCalibrationInfoBackupOffset, src, sizeof(*src))); } void GenerateSecureCalibrationBinaryBackupKey(void *dst, size_t dst_size) { diff --git a/stratosphere/ams_mitm/source/bpc_mitm/bpc_ams_power_utils.cpp b/stratosphere/ams_mitm/source/bpc_mitm/bpc_ams_power_utils.cpp index 6f8d7fe3f..b2e63b84b 100644 --- a/stratosphere/ams_mitm/source/bpc_mitm/bpc_ams_power_utils.cpp +++ b/stratosphere/ams_mitm/source/bpc_mitm/bpc_ams_power_utils.cpp @@ -135,13 +135,13 @@ namespace ams::mitm::bpc { /* Open payload file. */ FsFile payload_file; - R_TRY(fs::OpenAtmosphereSdFile(&payload_file, "/reboot_payload.bin", ams::fs::OpenMode_Read)); - ON_SCOPE_EXIT { fsFileClose(&payload_file); }; + R_TRY(fs::OpenAtmosphereSdFile(std::addressof(payload_file), "/reboot_payload.bin", ams::fs::OpenMode_Read)); + ON_SCOPE_EXIT { fsFileClose(std::addressof(payload_file)); }; /* Read payload file. Discard result. */ { size_t actual_size; - fsFileRead(&payload_file, 0, g_reboot_payload, sizeof(g_reboot_payload), FsReadOption_None, &actual_size); + fsFileRead(std::addressof(payload_file), 0, g_reboot_payload, sizeof(g_reboot_payload), FsReadOption_None, std::addressof(actual_size)); } /* NOTE: Preferred reboot type will be parsed from settings later on. */ diff --git a/stratosphere/ams_mitm/source/bpc_mitm/bpc_ams_service.cpp b/stratosphere/ams_mitm/source/bpc_mitm/bpc_ams_service.cpp index b9356bdcb..3d7330d5e 100644 --- a/stratosphere/ams_mitm/source/bpc_mitm/bpc_ams_service.cpp +++ b/stratosphere/ams_mitm/source/bpc_mitm/bpc_ams_service.cpp @@ -27,7 +27,7 @@ namespace ams::mitm::bpc { } void AtmosphereService::RebootToFatalError(const ams::FatalErrorContext &ctx) { - bpc::RebootForFatalError(&ctx); + bpc::RebootForFatalError(std::addressof(ctx)); } void AtmosphereService::SetRebootPayload(const ams::sf::InBuffer &payload) { diff --git a/stratosphere/ams_mitm/source/dns_mitm/dnsmitm_resolver_impl.cpp b/stratosphere/ams_mitm/source/dns_mitm/dnsmitm_resolver_impl.cpp index eda793bbf..6e2af5fb2 100644 --- a/stratosphere/ams_mitm/source/dns_mitm/dnsmitm_resolver_impl.cpp +++ b/stratosphere/ams_mitm/source/dns_mitm/dnsmitm_resolver_impl.cpp @@ -24,7 +24,7 @@ namespace ams::mitm::socket::resolver { ssize_t SerializeRedirectedHostEnt(u8 * const dst, size_t dst_size, const char *hostname, ams::socket::InAddrT redirect_addr) { struct in_addr addr = { .s_addr = redirect_addr }; - struct in_addr *addr_list[2] = { &addr, nullptr }; + struct in_addr *addr_list[2] = { std::addressof(addr), nullptr }; struct hostent ent = { .h_name = const_cast(hostname), diff --git a/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.cpp b/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.cpp index 33d2e180e..39d2819b0 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.cpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.cpp @@ -116,7 +116,7 @@ namespace ams::mitm::fs { bool GetSettingsItemBooleanValue(const char *name, const char *key) { u8 tmp = 0; - AMS_ABORT_UNLESS(settings::fwdbg::GetSettingsItemValue(&tmp, sizeof(tmp), name, key) == sizeof(tmp)); + AMS_ABORT_UNLESS(settings::fwdbg::GetSettingsItemValue(std::addressof(tmp), sizeof(tmp), name, key) == sizeof(tmp)); return (tmp != 0); } @@ -133,20 +133,20 @@ namespace ams::mitm::fs { Result OpenHblWebContentFileSystem(sf::Out> &out, ncm::ProgramId program_id) { /* Verify eligibility. */ bool is_hbl; - R_UNLESS(R_SUCCEEDED(pm::info::IsHblProgramId(&is_hbl, program_id)), sm::mitm::ResultShouldForwardToSession()); + R_UNLESS(R_SUCCEEDED(pm::info::IsHblProgramId(std::addressof(is_hbl), program_id)), sm::mitm::ResultShouldForwardToSession()); R_UNLESS(is_hbl, sm::mitm::ResultShouldForwardToSession()); /* Hbl html directory must exist. */ { FsDir d; - R_UNLESS(R_SUCCEEDED(mitm::fs::OpenSdDirectory(&d, AtmosphereHblWebContentDir, fs::OpenDirectoryMode_Directory)), sm::mitm::ResultShouldForwardToSession()); - fsDirClose(&d); + R_UNLESS(R_SUCCEEDED(mitm::fs::OpenSdDirectory(std::addressof(d), AtmosphereHblWebContentDir, fs::OpenDirectoryMode_Directory)), sm::mitm::ResultShouldForwardToSession()); + fsDirClose(std::addressof(d)); } /* Open the SD card using fs.mitm's session. */ FsFileSystem sd_fs; - R_TRY(fsOpenSdCardFileSystem(&sd_fs)); - const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(&sd_fs.s)}; + R_TRY(fsOpenSdCardFileSystem(std::addressof(sd_fs))); + const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(std::addressof(sd_fs.s))}; std::unique_ptr sd_ifs = std::make_unique(sd_fs); out.SetValue(MakeSharedFileSystem(std::make_shared(std::make_unique(std::move(sd_ifs), AtmosphereHblWebContentDir)), false), target_object_id); @@ -157,14 +157,14 @@ namespace ams::mitm::fs { /* Directory must exist. */ { FsDir d; - R_UNLESS(R_SUCCEEDED(mitm::fs::OpenAtmosphereSdDirectory(&d, program_id, ProgramWebContentDir, fs::OpenDirectoryMode_Directory)), sm::mitm::ResultShouldForwardToSession()); - fsDirClose(&d); + R_UNLESS(R_SUCCEEDED(mitm::fs::OpenAtmosphereSdDirectory(std::addressof(d), program_id, ProgramWebContentDir, fs::OpenDirectoryMode_Directory)), sm::mitm::ResultShouldForwardToSession()); + fsDirClose(std::addressof(d)); } /* Open the SD card using fs.mitm's session. */ FsFileSystem sd_fs; - R_TRY(fsOpenSdCardFileSystem(&sd_fs)); - const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(&sd_fs.s)}; + R_TRY(fsOpenSdCardFileSystem(std::addressof(sd_fs))); + const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(std::addressof(sd_fs.s))}; std::unique_ptr sd_ifs = std::make_unique(sd_fs); /* Format the subdirectory path. */ @@ -231,8 +231,8 @@ namespace ams::mitm::fs { /* Create a new SD card filesystem. */ FsFileSystem sd_fs; - R_TRY(fsOpenSdCardFileSystemFwd(this->forward_service.get(), &sd_fs)); - const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(&sd_fs.s)}; + R_TRY(fsOpenSdCardFileSystemFwd(this->forward_service.get(), std::addressof(sd_fs))); + const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(std::addressof(sd_fs.s))}; /* Return output filesystem. */ std::shared_ptr redir_fs = std::make_shared(std::make_shared(sd_fs), "/Nintendo", emummc::GetNintendoDirPath()); @@ -260,13 +260,13 @@ namespace ams::mitm::fs { /* Verify we can open the save. */ static_assert(sizeof(fs::SaveDataAttribute) == sizeof(::FsSaveDataAttribute)); FsFileSystem save_fs; - R_UNLESS(R_SUCCEEDED(fsOpenSaveDataFileSystemFwd(this->forward_service.get(), &save_fs, space_id, reinterpret_cast(&attribute))), sm::mitm::ResultShouldForwardToSession()); + R_UNLESS(R_SUCCEEDED(fsOpenSaveDataFileSystemFwd(this->forward_service.get(), std::addressof(save_fs), space_id, reinterpret_cast(std::addressof(attribute)))), sm::mitm::ResultShouldForwardToSession()); std::unique_ptr save_ifs = std::make_unique(save_fs); /* Mount the SD card using fs.mitm's session. */ FsFileSystem sd_fs; - R_TRY(fsOpenSdCardFileSystem(&sd_fs)); - const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(&sd_fs.s)}; + R_TRY(fsOpenSdCardFileSystem(std::addressof(sd_fs))); + const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(std::addressof(sd_fs.s))}; std::shared_ptr sd_ifs = std::make_shared(sd_fs); /* Verify that we can open the save directory, and that it exists. */ @@ -278,7 +278,7 @@ namespace ams::mitm::fs { bool is_new_save = false; { fs::DirectoryEntryType ent; - R_TRY_CATCH(sd_ifs->GetEntryType(&ent, save_dir_path)) { + R_TRY_CATCH(sd_ifs->GetEntryType(std::addressof(ent), save_dir_path)) { R_CATCH(fs::ResultPathNotFound) { is_new_save = true; } R_CATCH_ALL() { /* ... */ } } R_END_TRY_CATCH; @@ -310,8 +310,8 @@ namespace ams::mitm::fs { /* Try to open a storage for the partition. */ FsStorage bis_storage; - R_TRY(fsOpenBisStorageFwd(this->forward_service.get(), &bis_storage, bis_partition_id)); - const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(&bis_storage.s)}; + R_TRY(fsOpenBisStorageFwd(this->forward_service.get(), std::addressof(bis_storage), bis_partition_id)); + const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(std::addressof(bis_storage.s))}; const bool is_sysmodule = ncm::IsSystemProgramId(this->client_info.program_id); const bool is_hbl = this->client_info.override_status.IsHbl(); @@ -355,8 +355,8 @@ namespace ams::mitm::fs { /* Try to open the process romfs. */ FsStorage data_storage; - R_TRY(fsOpenDataStorageByCurrentProcessFwd(this->forward_service.get(), &data_storage)); - const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(&data_storage.s)}; + R_TRY(fsOpenDataStorageByCurrentProcessFwd(this->forward_service.get(), std::addressof(data_storage))); + const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(std::addressof(data_storage.s))}; /* Get a scoped lock. */ std::scoped_lock lk(g_data_storage_lock); @@ -376,7 +376,7 @@ namespace ams::mitm::fs { /* Create the layered storage. */ FsFile data_file; - if (R_SUCCEEDED(OpenAtmosphereSdFile(&data_file, this->client_info.program_id, "romfs.bin", OpenMode_Read))) { + if (R_SUCCEEDED(OpenAtmosphereSdFile(std::addressof(data_file), this->client_info.program_id, "romfs.bin", OpenMode_Read))) { auto layered_storage = std::make_shared(std::make_unique(new RemoteStorage(data_storage)), std::make_unique(new FileStorage(new RemoteFile(data_file))), this->client_info.program_id); layered_storage->BeginInitialize(); new_storage = std::move(layered_storage); @@ -386,7 +386,7 @@ namespace ams::mitm::fs { new_storage = std::move(layered_storage); } - SetStorageCacheEntry(this->client_info.program_id, &new_storage); + SetStorageCacheEntry(this->client_info.program_id, std::addressof(new_storage)); out.SetValue(MakeSharedStorage(new_storage), target_object_id); } @@ -405,8 +405,8 @@ namespace ams::mitm::fs { /* Try to open the process romfs. */ FsStorage data_storage; - R_TRY(fsOpenDataStorageByDataIdFwd(this->forward_service.get(), &data_storage, static_cast(data_id), static_cast(storage_id))); - const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(&data_storage.s)}; + R_TRY(fsOpenDataStorageByDataIdFwd(this->forward_service.get(), std::addressof(data_storage), static_cast(data_id), static_cast(storage_id))); + const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(std::addressof(data_storage.s))}; /* Get a scoped lock. */ std::scoped_lock lk(g_data_storage_lock); @@ -426,7 +426,7 @@ namespace ams::mitm::fs { /* Create the layered storage. */ FsFile data_file; - if (R_SUCCEEDED(OpenAtmosphereSdFile(&data_file, data_id, "romfs.bin", OpenMode_Read))) { + if (R_SUCCEEDED(OpenAtmosphereSdFile(std::addressof(data_file), data_id, "romfs.bin", OpenMode_Read))) { auto layered_storage = std::make_shared(std::make_unique(new RemoteStorage(data_storage)), std::make_unique(new FileStorage(new RemoteFile(data_file))), data_id); layered_storage->BeginInitialize(); new_storage = std::move(layered_storage); @@ -436,7 +436,7 @@ namespace ams::mitm::fs { new_storage = std::move(layered_storage); } - SetStorageCacheEntry(data_id, &new_storage); + SetStorageCacheEntry(data_id, std::addressof(new_storage)); out.SetValue(MakeSharedStorage(new_storage), target_object_id); } @@ -456,8 +456,8 @@ namespace ams::mitm::fs { /* Try to open the process romfs. */ FsStorage data_storage; - R_TRY(fsOpenDataStorageWithProgramIndexFwd(this->forward_service.get(), &data_storage, program_index)); - const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(&data_storage.s)}; + R_TRY(fsOpenDataStorageWithProgramIndexFwd(this->forward_service.get(), std::addressof(data_storage), program_index)); + const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(std::addressof(data_storage.s))}; /* Get a scoped lock. */ std::scoped_lock lk(g_data_storage_lock); @@ -477,7 +477,7 @@ namespace ams::mitm::fs { /* Create the layered storage. */ FsFile data_file; - if (R_SUCCEEDED(OpenAtmosphereSdFile(&data_file, program_id, "romfs.bin", OpenMode_Read))) { + if (R_SUCCEEDED(OpenAtmosphereSdFile(std::addressof(data_file), program_id, "romfs.bin", OpenMode_Read))) { auto layered_storage = std::make_shared(std::make_unique(new RemoteStorage(data_storage)), std::make_unique(new FileStorage(new RemoteFile(data_file))), program_id); layered_storage->BeginInitialize(); new_storage = std::move(layered_storage); @@ -487,7 +487,7 @@ namespace ams::mitm::fs { new_storage = std::move(layered_storage); } - SetStorageCacheEntry(program_id, &new_storage); + SetStorageCacheEntry(program_id, std::addressof(new_storage)); out.SetValue(MakeSharedStorage(new_storage), target_object_id); } diff --git a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_layered_romfs_storage.cpp b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_layered_romfs_storage.cpp index 9abf2122f..290c9cbf1 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_layered_romfs_storage.cpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_layered_romfs_storage.cpp @@ -31,7 +31,7 @@ namespace ams::mitm::fs { void RomfsInitializerThreadFunction(void *) { while (true) { uintptr_t storage_uptr = 0; - g_req_mq.Receive(&storage_uptr); + g_req_mq.Receive(std::addressof(storage_uptr)); std::shared_ptr layered_storage = reinterpret_cast(storage_uptr)->GetShared(); g_ack_mq.Send(storage_uptr); layered_storage->InitializeImpl(); @@ -54,7 +54,7 @@ namespace ams::mitm::fs { g_req_mq.Send(storage_uptr); uintptr_t ack = 0; - g_ack_mq.Receive(&ack); + g_ack_mq.Receive(std::addressof(ack)); AMS_ABORT_UNLESS(ack == storage_uptr); } @@ -92,7 +92,7 @@ namespace ams::mitm::fs { builder.AddStorageFiles(this->storage_romfs.get(), romfs::DataSourceType::Storage); } - builder.Build(&this->source_infos); + builder.Build(std::addressof(this->source_infos)); this->is_initialized = true; this->initialize_event.Signal(); @@ -140,11 +140,11 @@ namespace ams::mitm::fs { case romfs::DataSourceType::LooseSdFile: { FsFile file; - R_ABORT_UNLESS(mitm::fs::OpenAtmosphereSdRomfsFile(&file, this->program_id, cur_source.loose_source_info.path, OpenMode_Read)); - ON_SCOPE_EXIT { fsFileClose(&file); }; + R_ABORT_UNLESS(mitm::fs::OpenAtmosphereSdRomfsFile(std::addressof(file), this->program_id, cur_source.loose_source_info.path, OpenMode_Read)); + ON_SCOPE_EXIT { fsFileClose(std::addressof(file)); }; u64 out_read = 0; - R_ABORT_UNLESS(fsFileRead(&file, offset_within_source, cur_dst, cur_read_size, FsReadOption_None, &out_read)); + R_ABORT_UNLESS(fsFileRead(std::addressof(file), offset_within_source, cur_dst, cur_read_size, FsReadOption_None, std::addressof(out_read))); AMS_ABORT_UNLESS(out_read == cur_read_size); } break; @@ -154,7 +154,7 @@ namespace ams::mitm::fs { case romfs::DataSourceType::Metadata: { size_t out_read = 0; - R_ABORT_UNLESS(cur_source.metadata_source_info.file->Read(&out_read, offset_within_source, cur_dst, cur_read_size)); + R_ABORT_UNLESS(cur_source.metadata_source_info.file->Read(std::addressof(out_read), offset_within_source, cur_dst, cur_read_size)); AMS_ABORT_UNLESS(out_read == cur_read_size); } break; diff --git a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_romfs.cpp b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_romfs.cpp index 2e3547bd8..60aa8a4a3 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_romfs.cpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_romfs.cpp @@ -145,7 +145,7 @@ namespace ams::mitm::fs { private: ALWAYS_INLINE void Read(size_t ofs, void *dst, size_t sz) { u64 read_size; - R_ABORT_UNLESS(fsFileRead(this->file, this->offset + ofs, dst, sz, 0, &read_size)); + R_ABORT_UNLESS(fsFileRead(this->file, this->offset + ofs, dst, sz, 0, std::addressof(read_size))); AMS_ABORT_UNLESS(read_size == sz); } @@ -317,9 +317,9 @@ namespace ams::mitm::fs { /* Get number of child directories. */ s64 num_child_dirs = 0; { - OpenFileSystemRomfsDirectory(&dir, this->program_id, parent, OpenDirectoryMode_Directory, fs); - ON_SCOPE_EXIT { fsDirClose(&dir); }; - R_ABORT_UNLESS(fsDirGetEntryCount(&dir, &num_child_dirs)); + OpenFileSystemRomfsDirectory(std::addressof(dir), this->program_id, parent, OpenDirectoryMode_Directory, fs); + ON_SCOPE_EXIT { fsDirClose(std::addressof(dir)); }; + R_ABORT_UNLESS(fsDirGetEntryCount(std::addressof(dir), std::addressof(num_child_dirs))); } AMS_ABORT_UNLESS(num_child_dirs >= 0); @@ -330,12 +330,12 @@ namespace ams::mitm::fs { s64 cur_child_dir_ind = 0; { - OpenFileSystemRomfsDirectory(&dir, this->program_id, parent, OpenDirectoryMode_All, fs); - ON_SCOPE_EXIT { fsDirClose(&dir); }; + OpenFileSystemRomfsDirectory(std::addressof(dir), this->program_id, parent, OpenDirectoryMode_All, fs); + ON_SCOPE_EXIT { fsDirClose(std::addressof(dir)); }; s64 read_entries = 0; while (true) { - R_ABORT_UNLESS(fsDirRead(&dir, &read_entries, 1, &this->dir_entry)); + R_ABORT_UNLESS(fsDirRead(std::addressof(dir), std::addressof(read_entries), 1, std::addressof(this->dir_entry))); if (read_entries != 1) { break; } @@ -345,7 +345,7 @@ namespace ams::mitm::fs { AMS_ABORT_UNLESS(child_dirs != nullptr); BuildDirectoryContext *real_child = nullptr; - this->AddDirectory(&real_child, parent, std::make_unique(this->dir_entry.name, strlen(this->dir_entry.name))); + this->AddDirectory(std::addressof(real_child), parent, std::make_unique(this->dir_entry.name, strlen(this->dir_entry.name))); AMS_ABORT_UNLESS(real_child != nullptr); child_dirs[cur_child_dir_ind++] = real_child; AMS_ABORT_UNLESS(cur_child_dir_ind <= num_child_dirs); @@ -392,7 +392,7 @@ namespace ams::mitm::fs { { const DirectoryEntry *cur_child = dir_table.GetEntry(cur_child_offset); - this->AddDirectory(&real_child, parent, std::make_unique(cur_child->name, cur_child->name_size)); + this->AddDirectory(std::addressof(real_child), parent, std::make_unique(cur_child->name, cur_child->name_size)); AMS_ABORT_UNLESS(real_child != nullptr); next_child_offset = cur_child->sibling; @@ -409,25 +409,25 @@ namespace ams::mitm::fs { void Builder::AddSdFiles() { /* Open Sd Card filesystem. */ FsFileSystem sd_filesystem; - R_ABORT_UNLESS(fsOpenSdCardFileSystem(&sd_filesystem)); - ON_SCOPE_EXIT { fsFsClose(&sd_filesystem); }; + R_ABORT_UNLESS(fsOpenSdCardFileSystem(std::addressof(sd_filesystem))); + ON_SCOPE_EXIT { fsFsClose(std::addressof(sd_filesystem)); }; /* If there is no romfs folder on the SD, don't bother continuing. */ { FsDir dir; - if (R_FAILED(mitm::fs::OpenAtmosphereRomfsDirectory(&dir, this->program_id, this->root->path.get(), OpenDirectoryMode_Directory, &sd_filesystem))) { + if (R_FAILED(mitm::fs::OpenAtmosphereRomfsDirectory(std::addressof(dir), this->program_id, this->root->path.get(), OpenDirectoryMode_Directory, std::addressof(sd_filesystem)))) { return; } - fsDirClose(&dir); + fsDirClose(std::addressof(dir)); } this->cur_source_type = DataSourceType::LooseSdFile; - this->VisitDirectory(&sd_filesystem, this->root); + this->VisitDirectory(std::addressof(sd_filesystem), this->root); } void Builder::AddStorageFiles(ams::fs::IStorage *storage, DataSourceType source_type) { Header header; - R_ABORT_UNLESS(storage->Read(0, &header, sizeof(Header))); + R_ABORT_UNLESS(storage->Read(0, std::addressof(header), sizeof(Header))); AMS_ABORT_UNLESS(header.header_size == sizeof(Header)); /* Read tables. */ @@ -444,8 +444,8 @@ namespace ams::mitm::fs { /* Open an SD card filesystem. */ FsFileSystem sd_filesystem; - R_ABORT_UNLESS(fsOpenSdCardFileSystem(&sd_filesystem)); - ON_SCOPE_EXIT { fsFsClose(&sd_filesystem); }; + R_ABORT_UNLESS(fsOpenSdCardFileSystem(std::addressof(sd_filesystem))); + ON_SCOPE_EXIT { fsFsClose(std::addressof(sd_filesystem)); }; /* Calculate hash table sizes. */ const size_t num_dir_hash_table_entries = GetHashTableSize(this->num_dirs); @@ -460,7 +460,7 @@ namespace ams::mitm::fs { /* Open metadata file. */ const size_t metadata_size = this->dir_hash_table_size + this->dir_table_size + this->file_hash_table_size + this->file_table_size; FsFile metadata_file; - R_ABORT_UNLESS(mitm::fs::CreateAndOpenAtmosphereSdFile(&metadata_file, this->program_id, "romfs_metadata.bin", metadata_size)); + R_ABORT_UNLESS(mitm::fs::CreateAndOpenAtmosphereSdFile(std::addressof(metadata_file), this->program_id, "romfs_metadata.bin", metadata_size)); /* Ensure later hash tables will have correct defaults. */ static_assert(EmptyEntry == 0xFFFFFFFF); @@ -534,13 +534,13 @@ namespace ams::mitm::fs { u32 *file_hash_table = reinterpret_cast(fht_buf); std::memset(file_hash_table, 0xFF, this->file_hash_table_size); ON_SCOPE_EXIT { - R_ABORT_UNLESS(fsFileWrite(&metadata_file, this->dir_hash_table_size + this->dir_table_size, file_hash_table, this->file_hash_table_size, FsWriteOption_None)); + R_ABORT_UNLESS(fsFileWrite(std::addressof(metadata_file), this->dir_hash_table_size + this->dir_table_size, file_hash_table, this->file_hash_table_size, FsWriteOption_None)); std::free(fht_buf); }; /* Write the file table. */ { - FileTableWriter file_table(&metadata_file, this->dir_hash_table_size + this->dir_table_size + this->file_hash_table_size, this->file_table_size); + FileTableWriter file_table(std::addressof(metadata_file), this->dir_hash_table_size + this->dir_table_size + this->file_hash_table_size, this->file_table_size); for (const auto &it : this->files) { BuildFileContext *cur_file = it.get(); @@ -602,13 +602,13 @@ namespace ams::mitm::fs { u32 *dir_hash_table = reinterpret_cast(dht_buf); std::memset(dir_hash_table, 0xFF, this->dir_hash_table_size); ON_SCOPE_EXIT { - R_ABORT_UNLESS(fsFileWrite(&metadata_file, 0, dir_hash_table, this->dir_hash_table_size, FsWriteOption_None)); + R_ABORT_UNLESS(fsFileWrite(std::addressof(metadata_file), 0, dir_hash_table, this->dir_hash_table_size, FsWriteOption_None)); std::free(dht_buf); }; /* Write the file table. */ { - DirectoryTableWriter dir_table(&metadata_file, this->dir_hash_table_size, this->dir_table_size); + DirectoryTableWriter dir_table(std::addressof(metadata_file), this->dir_hash_table_size, this->dir_table_size); for (const auto &it : this->directories) { BuildDirectoryContext *cur_dir = it.get(); @@ -657,7 +657,7 @@ namespace ams::mitm::fs { /* Save metadata to the SD card, to save on memory space. */ { - R_ABORT_UNLESS(fsFileFlush(&metadata_file)); + R_ABORT_UNLESS(fsFileFlush(std::addressof(metadata_file))); out_infos->emplace_back(header->dir_hash_table_ofs, metadata_size, DataSourceType::Metadata, new RemoteFile(metadata_file)); } } diff --git a/stratosphere/ams_mitm/source/ns_mitm/ns_web_mitm_service.cpp b/stratosphere/ams_mitm/source/ns_mitm/ns_web_mitm_service.cpp index 128f8a3bf..538af7932 100644 --- a/stratosphere/ams_mitm/source/ns_mitm/ns_web_mitm_service.cpp +++ b/stratosphere/ams_mitm/source/ns_mitm/ns_web_mitm_service.cpp @@ -26,7 +26,7 @@ namespace ams::mitm::ns { /* Always succeed for web applets asking about HBL. */ /* This enables hbl html. */ bool is_hbl; - if (R_SUCCEEDED(pm::info::IsHblProgramId(&is_hbl, application_id)) && is_hbl) { + if (R_SUCCEEDED(pm::info::IsHblProgramId(std::addressof(is_hbl), application_id)) && is_hbl) { nswebResolveApplicationContentPath(this->srv.get(), static_cast(application_id), static_cast(content_type)); return ResultSuccess(); } @@ -40,8 +40,8 @@ namespace ams::mitm::ns { Result NsWebMitmService::GetDocumentInterface(sf::Out> out) { /* Open a document interface. */ NsDocumentInterface doc; - R_TRY(nsGetDocumentInterfaceFwd(this->forward_service.get(), &doc)); - const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(&doc.s)}; + R_TRY(nsGetDocumentInterfaceFwd(this->forward_service.get(), std::addressof(doc))); + const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(std::addressof(doc.s))}; out.SetValue(sf::CreateSharedObjectEmplaced(this->client_info, std::make_unique(doc)), target_object_id); return ResultSuccess(); diff --git a/stratosphere/ams_mitm/source/set_mitm/settings_sd_kvs.cpp b/stratosphere/ams_mitm/source/set_mitm/settings_sd_kvs.cpp index 3f7fe59b7..d9f370f31 100644 --- a/stratosphere/ams_mitm/source/set_mitm/settings_sd_kvs.cpp +++ b/stratosphere/ams_mitm/source/set_mitm/settings_sd_kvs.cpp @@ -177,11 +177,11 @@ namespace ams::settings::fwdbg { template Result ParseSettingsItemIntegralValue(SdKeyValueStoreEntry &out, const char *value_str) { - R_TRY(AllocateValue(&out.value, sizeof(T))); + R_TRY(AllocateValue(std::addressof(out.value), sizeof(T))); out.value_size = sizeof(T); T value = static_cast(strtoul(value_str, nullptr, 0)); - std::memcpy(out.value, &value, sizeof(T)); + std::memcpy(out.value, std::addressof(value), sizeof(T)); return ResultSuccess(); } @@ -191,7 +191,7 @@ namespace ams::settings::fwdbg { R_TRY(ValidateSettingsItemKey(key)); u8 dummy_value = 0; - SdKeyValueStoreEntry test_entry { .name = name, .key = key, .value = &dummy_value, .value_size = sizeof(dummy_value) }; + SdKeyValueStoreEntry test_entry { .name = name, .key = key, .value = std::addressof(dummy_value), .value_size = sizeof(dummy_value) }; auto *begin = g_entries; auto *end = begin + g_num_entries; @@ -199,7 +199,7 @@ namespace ams::settings::fwdbg { R_UNLESS(it != end, settings::ResultSettingsItemNotFound()); R_UNLESS(*it == test_entry, settings::ResultSettingsItemNotFound()); - *out = &*it; + *out = std::addressof(*it); return ResultSuccess(); } @@ -223,12 +223,12 @@ namespace ams::settings::fwdbg { SdKeyValueStoreEntry new_value = {}; /* Find name and key. */ - R_TRY(FindSettingsName(&new_value.name, name)); - R_TRY(FindSettingsItemKey(&new_value.key, key)); + R_TRY(FindSettingsName(std::addressof(new_value.name), name)); + R_TRY(FindSettingsItemKey(std::addressof(new_value.key), key)); if (strncasecmp(type, "str", type_len) == 0 || strncasecmp(type, "string", type_len) == 0) { const size_t size = value_len + 1; - R_TRY(AllocateValue(&new_value.value, size)); + R_TRY(AllocateValue(std::addressof(new_value.value), size)); std::memcpy(new_value.value, value_str, size); new_value.value_size = size; } else if (strncasecmp(type, "hex", type_len) == 0 || strncasecmp(type, "bytes", type_len) == 0) { @@ -237,7 +237,7 @@ namespace ams::settings::fwdbg { R_UNLESS(IsHexadecimal(value_str), settings::ResultInvalidFormatSettingsItemValue()); const size_t size = value_len / 2; - R_TRY(AllocateValue(&new_value.value, size)); + R_TRY(AllocateValue(std::addressof(new_value.value), size)); new_value.value_size = size; u8 *data = reinterpret_cast(new_value.value); @@ -300,7 +300,7 @@ namespace ams::settings::fwdbg { AMS_ABORT_UNLESS(file != nullptr); Result parse_result = ResultSuccess(); - util::ini::ParseFile(file.get(), &parse_result, SystemSettingsIniHandler); + util::ini::ParseFile(file.get(), std::addressof(parse_result), SystemSettingsIniHandler); R_TRY(parse_result); return ResultSuccess(); @@ -422,7 +422,7 @@ namespace ams::settings::fwdbg { Result GetSdCardKeyValueStoreSettingsItemValueSize(size_t *out_size, const char *name, const char *key) { SdKeyValueStoreEntry *entry = nullptr; - R_TRY(GetEntry(&entry, name, key)); + R_TRY(GetEntry(std::addressof(entry), name, key)); *out_size = entry->value_size; return ResultSuccess(); @@ -432,7 +432,7 @@ namespace ams::settings::fwdbg { R_UNLESS(dst != nullptr, settings::ResultNullSettingsItemValueBuffer()); SdKeyValueStoreEntry *entry = nullptr; - R_TRY(GetEntry(&entry, name, key)); + R_TRY(GetEntry(std::addressof(entry), name, key)); const size_t size = std::min(entry->value_size, dst_size); if (size > 0) { diff --git a/stratosphere/creport/source/creport_modules.cpp b/stratosphere/creport/source/creport_modules.cpp index a8e4bfd53..a832cc3cf 100644 --- a/stratosphere/creport/source/creport_modules.cpp +++ b/stratosphere/creport/source/creport_modules.cpp @@ -54,7 +54,7 @@ namespace ams::creport { if (std::strcmp(this->modules[i].name, "") != 0) { file.WriteFormat(" Name: %s\n", module.name); } - file.DumpMemory(" Build Id: ", &module.build_id[0], sizeof(module.build_id)); + file.DumpMemory(" Build Id: ", module.build_id, sizeof(module.build_id)); } } @@ -77,7 +77,7 @@ namespace ams::creport { void ModuleList::TryAddModule(uintptr_t guess) { /* Try to locate module from guess. */ uintptr_t base_address = 0; - if (!this->TryFindModule(&base_address, guess)) { + if (!this->TryFindModule(std::addressof(base_address), guess)) { return; } @@ -94,7 +94,7 @@ namespace ams::creport { /* Get the region extents. */ svc::MemoryInfo mi; svc::PageInfo pi; - if (R_FAILED(svc::QueryDebugProcessMemory(&mi, &pi, this->debug_handle, cur_address))) { + if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), this->debug_handle, cur_address))) { break; } @@ -129,20 +129,20 @@ namespace ams::creport { /* Query the memory region our guess falls in. */ svc::MemoryInfo mi; svc::PageInfo pi; - if (R_FAILED(svc::QueryDebugProcessMemory(&mi, &pi, this->debug_handle, guess))) { + if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), this->debug_handle, guess))) { return false; } /* If we fall into a RW region, it may be rwdata. Query the region before it, which may be rodata or text. */ if (mi.permission == svc::MemoryPermission_ReadWrite) { - if (R_FAILED(svc::QueryDebugProcessMemory(&mi, &pi, debug_handle, mi.base_address - 4))) { + if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), debug_handle, mi.base_address - 4))) { return false; } } /* If we fall into an RO region, it may be rodata. Query the region before it, which should be text. */ if (mi.permission == svc::MemoryPermission_Read) { - if (R_FAILED(svc::QueryDebugProcessMemory(&mi, &pi, debug_handle, mi.base_address - 4))) { + if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), debug_handle, mi.base_address - 4))) { return false; } } @@ -155,7 +155,7 @@ namespace ams::creport { /* Modules are a series of contiguous (text/rodata/rwdata) regions. */ /* Iterate backwards until we find unmapped memory, to find the start of the set of modules loaded here. */ while (mi.base_address > 0) { - if (R_FAILED(svc::QueryDebugProcessMemory(&mi, &pi, debug_handle, mi.base_address - 4))) { + if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), debug_handle, mi.base_address - 4))) { return false; } @@ -181,7 +181,7 @@ namespace ams::creport { svc::PageInfo pi; /* Verify .rodata is read-only. */ - if (R_FAILED(svc::QueryDebugProcessMemory(&mi, &pi, this->debug_handle, ro_start_address)) || mi.permission != svc::MemoryPermission_Read) { + if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), this->debug_handle, ro_start_address)) || mi.permission != svc::MemoryPermission_Read) { return; } @@ -228,7 +228,7 @@ namespace ams::creport { /* Verify .rodata is read-only. */ svc::MemoryInfo mi; svc::PageInfo pi; - if (R_FAILED(svc::QueryDebugProcessMemory(&mi, &pi, this->debug_handle, ro_start_address)) || mi.permission != svc::MemoryPermission_Read) { + if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), this->debug_handle, ro_start_address)) || mi.permission != svc::MemoryPermission_Read) { return; } diff --git a/stratosphere/creport/source/creport_threads.cpp b/stratosphere/creport/source/creport_threads.cpp index 17bd19d8d..1757534f7 100644 --- a/stratosphere/creport/source/creport_threads.cpp +++ b/stratosphere/creport/source/creport_threads.cpp @@ -132,7 +132,7 @@ namespace ams::creport { } /* Get the thread context. */ - if (R_FAILED(svc::GetDebugThreadContext(&this->context, debug_handle, this->thread_id, svc::ThreadContextFlag_All))) { + if (R_FAILED(svc::GetDebugThreadContext(std::addressof(this->context), debug_handle, this->thread_id, svc::ThreadContextFlag_All))) { return false; } @@ -151,21 +151,21 @@ namespace ams::creport { if (R_SUCCEEDED(svc::ReadDebugProcessMemory(reinterpret_cast(thread_tls), debug_handle, this->tls_address, sizeof(thread_tls)))) { std::memcpy(this->tls, thread_tls, sizeof(this->tls)); /* Try to detect libnx threads, and skip name parsing then. */ - if (*(reinterpret_cast(&thread_tls[0x1E0])) != LibnxThreadVarMagic) { + if (*(reinterpret_cast(std::addressof(thread_tls[0x1E0]))) != LibnxThreadVarMagic) { u8 thread_type[0x1C0]; - const u64 thread_type_addr = *(reinterpret_cast(&thread_tls[0x1F8])); + const u64 thread_type_addr = *(reinterpret_cast(std::addressof(thread_tls[0x1F8]))); if (R_SUCCEEDED(svc::ReadDebugProcessMemory(reinterpret_cast(thread_type), debug_handle, thread_type_addr, sizeof(thread_type)))) { /* Get the thread version. */ - const u16 thread_version = *reinterpret_cast(&thread_type[0x46]); + const u16 thread_version = *reinterpret_cast(std::addressof(thread_type[0x46])); if (thread_version == 0 || thread_version == 0xFFFF) { /* Check thread name is actually at thread name. */ static_assert(0x1A8 - 0x188 == NameLengthMax, "NameLengthMax definition!"); - if (*(reinterpret_cast(&thread_type[0x1A8])) == thread_type_addr + 0x188) { + if (*(reinterpret_cast(std::addressof(thread_type[0x1A8]))) == thread_type_addr + 0x188) { std::memcpy(this->name, thread_type + 0x188, NameLengthMax); } } else if (thread_version == 1) { static_assert(0x1A0 - 0x180 == NameLengthMax, "NameLengthMax definition!"); - if (*(reinterpret_cast(&thread_type[0x1A0])) == thread_type_addr + 0x180) { + if (*(reinterpret_cast(std::addressof(thread_type[0x1A0]))) == thread_type_addr + 0x180) { std::memcpy(this->name, thread_type + 0x180, NameLengthMax); } } @@ -179,9 +179,9 @@ namespace ams::creport { /* Dump stack trace. */ if (is_64_bit) { - ReadStackTrace(&this->stack_trace_size, this->stack_trace, StackTraceSizeMax, debug_handle, this->context.fp); + ReadStackTrace(std::addressof(this->stack_trace_size), this->stack_trace, StackTraceSizeMax, debug_handle, this->context.fp); } else { - ReadStackTrace(&this->stack_trace_size, this->stack_trace, StackTraceSizeMax, debug_handle, this->context.fp); + ReadStackTrace(std::addressof(this->stack_trace_size), this->stack_trace, StackTraceSizeMax, debug_handle, this->context.fp); } return true; @@ -191,14 +191,14 @@ namespace ams::creport { /* Query stack region. */ svc::MemoryInfo mi; svc::PageInfo pi; - if (R_FAILED(svc::QueryDebugProcessMemory(&mi, &pi, debug_handle, this->context.sp))) { + if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), debug_handle, this->context.sp))) { return; } /* Check if sp points into the stack. */ if (mi.state != svc::MemoryState_Stack) { /* It's possible that sp is below the stack... */ - if (R_FAILED(svc::QueryDebugProcessMemory(&mi, &pi, debug_handle, mi.base_address + mi.size)) || mi.state != svc::MemoryState_Stack) { + if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), debug_handle, mi.base_address + mi.size)) || mi.state != svc::MemoryState_Stack) { return; } } @@ -219,24 +219,24 @@ namespace ams::creport { void ThreadInfo::DumpBinary(ScopedFile &file) { /* Dump id and context. */ - file.Write(&this->thread_id, sizeof(this->thread_id)); - file.Write(&this->context, sizeof(this->context)); + file.Write(std::addressof(this->thread_id), sizeof(this->thread_id)); + file.Write(std::addressof(this->context), sizeof(this->context)); /* Dump TLS info and name. */ - file.Write(&this->tls_address, sizeof(this->tls_address)); - file.Write(&this->tls, sizeof(this->tls)); - file.Write(&this->name, sizeof(this->name)); + file.Write(std::addressof(this->tls_address), sizeof(this->tls_address)); + file.Write(std::addressof(this->tls), sizeof(this->tls)); + file.Write(std::addressof(this->name), sizeof(this->name)); /* Dump stack extents and stack dump. */ - file.Write(&this->stack_bottom, sizeof(this->stack_bottom)); - file.Write(&this->stack_top, sizeof(this->stack_top)); - file.Write(&this->stack_dump_base, sizeof(this->stack_dump_base)); - file.Write(&this->stack_dump, sizeof(this->stack_dump)); + file.Write(std::addressof(this->stack_bottom), sizeof(this->stack_bottom)); + file.Write(std::addressof(this->stack_top), sizeof(this->stack_top)); + file.Write(std::addressof(this->stack_dump_base), sizeof(this->stack_dump_base)); + file.Write(std::addressof(this->stack_dump), sizeof(this->stack_dump)); /* Dump stack trace. */ { const u64 sts = this->stack_trace_size; - file.Write(&sts, sizeof(sts)); + file.Write(std::addressof(sts), sizeof(sts)); } file.Write(this->stack_trace, this->stack_trace_size); } @@ -244,9 +244,9 @@ namespace ams::creport { void ThreadList::DumpBinary(ScopedFile &file, u64 crashed_thread_id) { const u32 magic = DumpedThreadInfoMagic; const u32 count = this->thread_count; - file.Write(&magic, sizeof(magic)); - file.Write(&count, sizeof(count)); - file.Write(&crashed_thread_id, sizeof(crashed_thread_id)); + file.Write(std::addressof(magic), sizeof(magic)); + file.Write(std::addressof(count), sizeof(count)); + file.Write(std::addressof(crashed_thread_id), sizeof(crashed_thread_id)); for (size_t i = 0; i < this->thread_count; i++) { this->threads[i].DumpBinary(file); } @@ -259,7 +259,7 @@ namespace ams::creport { s32 num_threads; u64 thread_ids[ThreadCountMax]; { - if (R_FAILED(svc::GetThreadList(&num_threads, thread_ids, ThreadCountMax, debug_handle))) { + if (R_FAILED(svc::GetThreadList(std::addressof(num_threads), thread_ids, ThreadCountMax, debug_handle))) { return; } num_threads = std::min(size_t(num_threads), ThreadCountMax); diff --git a/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_api.cpp b/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_api.cpp index ffd5cf49e..fe43d97e5 100644 --- a/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_api.cpp +++ b/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_api.cpp @@ -195,7 +195,7 @@ namespace ams::dmnt::cheat::impl { /* Clear metadata. */ static_assert(util::is_podcheat_process_metadata)>::value, "CheatProcessMetadata definition!"); - std::memset(&this->cheat_process_metadata, 0, sizeof(this->cheat_process_metadata)); + std::memset(std::addressof(this->cheat_process_metadata), 0, sizeof(this->cheat_process_metadata)); /* Clear cheat list. */ this->ResetAllCheatEntries(); @@ -219,8 +219,8 @@ namespace ams::dmnt::cheat::impl { /* Note: This function *MUST* be called only with the cheat lock held. */ os::ProcessId pid; bool has_cheat_process = this->cheat_process_debug_handle != os::InvalidNativeHandle; - has_cheat_process &= R_SUCCEEDED(os::GetProcessId(&pid, this->cheat_process_debug_handle)); - has_cheat_process &= R_SUCCEEDED(pm::dmnt::GetApplicationProcessId(&pid)); + has_cheat_process &= R_SUCCEEDED(os::GetProcessId(std::addressof(pid), this->cheat_process_debug_handle)); + has_cheat_process &= R_SUCCEEDED(pm::dmnt::GetApplicationProcessId(std::addressof(pid))); has_cheat_process &= (pid == this->cheat_process_metadata.process_id); if (!has_cheat_process) { @@ -241,7 +241,7 @@ namespace ams::dmnt::cheat::impl { os::NativeHandle HookToCreateApplicationProcess() const { os::NativeHandle h; - R_ABORT_UNLESS(pm::dmnt::HookToCreateApplicationProcess(&h)); + R_ABORT_UNLESS(pm::dmnt::HookToCreateApplicationProcess(std::addressof(h))); return h; } @@ -254,12 +254,12 @@ namespace ams::dmnt::cheat::impl { /* Learn whether we should enable cheats by default. */ { u8 en = 0; - if (settings::fwdbg::GetSettingsItemValue(&en, sizeof(en), "atmosphere", "dmnt_cheats_enabled_by_default") == sizeof(en)) { + if (settings::fwdbg::GetSettingsItemValue(std::addressof(en), sizeof(en), "atmosphere", "dmnt_cheats_enabled_by_default") == sizeof(en)) { this->enable_cheats_by_default = (en != 0); } en = 0; - if (settings::fwdbg::GetSettingsItemValue( &en, sizeof(en), "atmosphere", "dmnt_always_save_cheat_toggles") == sizeof(en)) { + if (settings::fwdbg::GetSettingsItemValue( std::addressof(en), sizeof(en), "atmosphere", "dmnt_always_save_cheat_toggles") == sizeof(en)) { this->always_save_cheat_toggles = (en != 0); } } @@ -293,7 +293,7 @@ namespace ams::dmnt::cheat::impl { R_TRY(this->EnsureCheatProcess()); - std::memcpy(out, &this->cheat_process_metadata, sizeof(*out)); + std::memcpy(out, std::addressof(this->cheat_process_metadata), sizeof(*out)); return ResultSuccess(); } @@ -327,7 +327,7 @@ namespace ams::dmnt::cheat::impl { if (proc_addr <= address && address < proc_addr + size) { const size_t offset = (address - proc_addr); const size_t copy_size = std::min(sizeof(value.value), size - offset); - std::memcpy(&value.value, reinterpret_cast(reinterpret_cast(data) + offset), copy_size); + std::memcpy(std::addressof(value.value), reinterpret_cast(reinterpret_cast(data) + offset), copy_size); } } @@ -356,7 +356,7 @@ namespace ams::dmnt::cheat::impl { svc::PageInfo page_info; u64 address = 0, count = 0; do { - if (R_FAILED(svc::QueryDebugProcessMemory(&mem_info, &page_info, this->GetCheatProcessHandle(), address))) { + if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mem_info), std::addressof(page_info), this->GetCheatProcessHandle(), address))) { break; } @@ -380,7 +380,7 @@ namespace ams::dmnt::cheat::impl { svc::PageInfo page_info; u64 address = 0, total_count = 0, written_count = 0; do { - if (R_FAILED(svc::QueryDebugProcessMemory(&mem_info, &page_info, this->GetCheatProcessHandle(), address))) { + if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mem_info), std::addressof(page_info), this->GetCheatProcessHandle(), address))) { break; } @@ -420,7 +420,7 @@ namespace ams::dmnt::cheat::impl { R_TRY(this->EnsureCheatProcess()); svc::PageInfo page_info; - return svc::QueryDebugProcessMemory(mapping, &page_info, this->GetCheatProcessHandle(), address); + return svc::QueryDebugProcessMemory(mapping, std::addressof(page_info), this->GetCheatProcessHandle(), address); } Result PauseCheatProcess() { @@ -646,7 +646,7 @@ namespace ams::dmnt::cheat::impl { FrozenAddressValue value = {}; value.width = width; - R_TRY(this->ReadCheatProcessMemoryUnsafe(address, &value.value, width)); + R_TRY(this->ReadCheatProcessMemoryUnsafe(address, std::addressof(value.value), width)); FrozenAddressMapEntry *entry = AllocateFrozenAddress(address, value); R_UNLESS(entry != nullptr, dmnt::cheat::ResultFrozenAddressOutOfResource()); @@ -677,11 +677,11 @@ namespace ams::dmnt::cheat::impl { CheatProcessManager *this_ptr = reinterpret_cast(_this); Event hook; while (true) { - eventLoadRemote(&hook, this_ptr->HookToCreateApplicationProcess(), true); - if (R_SUCCEEDED(eventWait(&hook, std::numeric_limits::max()))) { + eventLoadRemote(std::addressof(hook), this_ptr->HookToCreateApplicationProcess(), true); + if (R_SUCCEEDED(eventWait(std::addressof(hook), std::numeric_limits::max()))) { this_ptr->AttachToApplicationProcess(true); } - eventClose(&hook); + eventClose(std::addressof(hook)); } } @@ -747,7 +747,7 @@ namespace ams::dmnt::cheat::impl { /* Execute program only if it has opcodes. */ if (this_ptr->cheat_vm.GetProgramSize()) { - this_ptr->cheat_vm.Execute(&this_ptr->cheat_process_metadata); + this_ptr->cheat_vm.Execute(std::addressof(this_ptr->cheat_process_metadata)); } } @@ -792,7 +792,7 @@ namespace ams::dmnt::cheat::impl { } /* Get the application process's ID. */ - R_ABORT_UNLESS_IF_NEW_PROCESS(pm::dmnt::GetApplicationProcessId(&this->cheat_process_metadata.process_id)); + R_ABORT_UNLESS_IF_NEW_PROCESS(pm::dmnt::GetApplicationProcessId(std::addressof(this->cheat_process_metadata.process_id))); auto proc_guard = SCOPE_GUARD { if (on_process_launch) { this->StartProcess(this->cheat_process_metadata.process_id); @@ -806,7 +806,7 @@ namespace ams::dmnt::cheat::impl { ncm::ProgramLocation loc = {}; cfg::OverrideStatus status = {}; - R_ABORT_UNLESS_IF_NEW_PROCESS(pm::dmnt::AtmosphereGetProcessInfo(&proc_h, &loc, &status, this->cheat_process_metadata.process_id)); + R_ABORT_UNLESS_IF_NEW_PROCESS(pm::dmnt::AtmosphereGetProcessInfo(std::addressof(proc_h), std::addressof(loc), std::addressof(status), this->cheat_process_metadata.process_id)); ON_SCOPE_EXIT { os::CloseNativeHandle(proc_h); }; this->cheat_process_metadata.program_id = loc.program_id; @@ -830,7 +830,7 @@ namespace ams::dmnt::cheat::impl { s32 num_modules; /* TODO: ldr::dmnt:: */ - R_ABORT_UNLESS_IF_NEW_PROCESS(ldrDmntGetProcessModuleInfo(static_cast(this->cheat_process_metadata.process_id), proc_modules, util::size(proc_modules), &num_modules)); + R_ABORT_UNLESS_IF_NEW_PROCESS(ldrDmntGetProcessModuleInfo(static_cast(this->cheat_process_metadata.process_id), proc_modules, util::size(proc_modules), std::addressof(num_modules))); /* All applications must have two modules. */ /* Only accept one (which means we're attaching to HBL) */ diff --git a/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_vm.cpp b/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_vm.cpp index 538578669..68bf7ea42 100644 --- a/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_vm.cpp +++ b/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_vm.cpp @@ -676,7 +676,7 @@ namespace ams::dmnt::cheat::impl { const size_t desired_depth = this->condition_depth - 1; CheatVmOpcode skip_opcode; - while (this->condition_depth > desired_depth && this->DecodeNextOpcode(&skip_opcode)) { + while (this->condition_depth > desired_depth && this->DecodeNextOpcode(std::addressof(skip_opcode))) { /* Decode instructions until we see end of the current conditional block. */ /* NOTE: This is broken in gateway's implementation. */ /* Gateway currently checks for "0x2" instead of "0x20000000" */ @@ -770,7 +770,7 @@ namespace ams::dmnt::cheat::impl { u64 kHeld = 0; /* Get Keys held. */ - hid::GetKeysHeld(&kHeld); + hid::GetKeysHeld(std::addressof(kHeld)); this->OpenDebugLogFile(); ON_SCOPE_EXIT { this->CloseDebugLogFile(); }; @@ -784,7 +784,7 @@ namespace ams::dmnt::cheat::impl { this->ResetState(); /* Loop until program finishes. */ - while (this->DecodeNextOpcode(&cur_opcode)) { + while (this->DecodeNextOpcode(std::addressof(cur_opcode))) { this->LogToDebugFile("Instruction Ptr: %04x\n", (u32)this->instruction_ptr); for (size_t i = 0; i < NumRegisters; i++) { @@ -794,7 +794,7 @@ namespace ams::dmnt::cheat::impl { for (size_t i = 0; i < NumRegisters; i++) { this->LogToDebugFile("SavedRegs[%02x]: %016lx\n", i, this->saved_values[i]); } - this->LogOpcode(&cur_opcode); + this->LogOpcode(std::addressof(cur_opcode)); /* Increment conditional depth, if relevant. */ if (cur_opcode.begin_conditional_block) { @@ -812,7 +812,7 @@ namespace ams::dmnt::cheat::impl { case 2: case 4: case 8: - dmnt::cheat::impl::WriteCheatProcessMemoryUnsafe(dst_address, &dst_value, cur_opcode.store_static.bit_width); + dmnt::cheat::impl::WriteCheatProcessMemoryUnsafe(dst_address, std::addressof(dst_value), cur_opcode.store_static.bit_width); break; } } @@ -827,7 +827,7 @@ namespace ams::dmnt::cheat::impl { case 2: case 4: case 8: - dmnt::cheat::impl::ReadCheatProcessMemoryUnsafe(src_address, &src_value, cur_opcode.begin_cond.bit_width); + dmnt::cheat::impl::ReadCheatProcessMemoryUnsafe(src_address, std::addressof(src_value), cur_opcode.begin_cond.bit_width); break; } /* Check against condition. */ @@ -903,7 +903,7 @@ namespace ams::dmnt::cheat::impl { case 2: case 4: case 8: - dmnt::cheat::impl::ReadCheatProcessMemoryUnsafe(src_address, &this->registers[cur_opcode.ldr_memory.reg_index], cur_opcode.ldr_memory.bit_width); + dmnt::cheat::impl::ReadCheatProcessMemoryUnsafe(src_address, std::addressof(this->registers[cur_opcode.ldr_memory.reg_index]), cur_opcode.ldr_memory.bit_width); break; } } @@ -922,7 +922,7 @@ namespace ams::dmnt::cheat::impl { case 2: case 4: case 8: - dmnt::cheat::impl::WriteCheatProcessMemoryUnsafe(dst_address, &dst_value, cur_opcode.str_static.bit_width); + dmnt::cheat::impl::WriteCheatProcessMemoryUnsafe(dst_address, std::addressof(dst_value), cur_opcode.str_static.bit_width); break; } /* Increment register if relevant. */ @@ -1073,7 +1073,7 @@ namespace ams::dmnt::cheat::impl { case 2: case 4: case 8: - dmnt::cheat::impl::WriteCheatProcessMemoryUnsafe(dst_address, &dst_value, cur_opcode.str_register.bit_width); + dmnt::cheat::impl::WriteCheatProcessMemoryUnsafe(dst_address, std::addressof(dst_value), cur_opcode.str_register.bit_width); break; } @@ -1144,7 +1144,7 @@ namespace ams::dmnt::cheat::impl { case 2: case 4: case 8: - dmnt::cheat::impl::ReadCheatProcessMemoryUnsafe(cond_address, &cond_value, cur_opcode.begin_reg_cond.bit_width); + dmnt::cheat::impl::ReadCheatProcessMemoryUnsafe(cond_address, std::addressof(cond_value), cur_opcode.begin_reg_cond.bit_width); break; } } @@ -1286,7 +1286,7 @@ namespace ams::dmnt::cheat::impl { case 2: case 4: case 8: - dmnt::cheat::impl::ReadCheatProcessMemoryUnsafe(val_address, &log_value, cur_opcode.debug_log.bit_width); + dmnt::cheat::impl::ReadCheatProcessMemoryUnsafe(val_address, std::addressof(log_value), cur_opcode.debug_log.bit_width); break; } } diff --git a/stratosphere/fatal/source/fatal_config.cpp b/stratosphere/fatal/source/fatal_config.cpp index c8e252b31..210350cbc 100644 --- a/stratosphere/fatal/source/fatal_config.cpp +++ b/stratosphere/fatal/source/fatal_config.cpp @@ -43,7 +43,7 @@ namespace ams::fatal::srv { /* Event creator. */ os::NativeHandle GetFatalDirtyEventReadableHandle() { Event evt; - R_ABORT_UNLESS(setsysAcquireFatalDirtyFlagEventHandle(&evt)); + R_ABORT_UNLESS(setsysAcquireFatalDirtyFlagEventHandle(std::addressof(evt))); return evt.revent; } @@ -68,7 +68,7 @@ namespace ams::fatal::srv { os::ClearSystemEvent(std::addressof(g_fatal_dirty_event)); u64 flags_0, flags_1; - if (R_SUCCEEDED(setsysGetFatalDirtyFlags(&flags_0, &flags_1)) && (flags_0 & 1)) { + if (R_SUCCEEDED(setsysGetFatalDirtyFlags(std::addressof(flags_0), std::addressof(flags_1))) && (flags_0 & 1)) { GetFatalConfigImpl().UpdateLanguageCode(); } } @@ -77,20 +77,20 @@ namespace ams::fatal::srv { /* Get information from set. */ settings::system::GetSerialNumber(std::addressof(this->serial_number)); settings::system::GetFirmwareVersion(std::addressof(this->firmware_version)); - setsysGetQuestFlag(&this->quest_flag); + setsysGetQuestFlag(std::addressof(this->quest_flag)); this->UpdateLanguageCode(); /* Read information from settings. */ - settings::fwdbg::GetSettingsItemValue(&this->transition_to_fatal, sizeof(this->transition_to_fatal), "fatal", "transition_to_fatal"); - settings::fwdbg::GetSettingsItemValue(&this->show_extra_info, sizeof(this->show_extra_info), "fatal", "show_extra_info"); + settings::fwdbg::GetSettingsItemValue(std::addressof(this->transition_to_fatal), sizeof(this->transition_to_fatal), "fatal", "transition_to_fatal"); + settings::fwdbg::GetSettingsItemValue(std::addressof(this->show_extra_info), sizeof(this->show_extra_info), "fatal", "show_extra_info"); u64 quest_interval_second; - settings::fwdbg::GetSettingsItemValue(&quest_interval_second, sizeof(quest_interval_second), "fatal", "quest_reboot_interval_second"); + settings::fwdbg::GetSettingsItemValue(std::addressof(quest_interval_second), sizeof(quest_interval_second), "fatal", "quest_reboot_interval_second"); this->quest_reboot_interval = TimeSpan::FromSeconds(quest_interval_second); /* Atmosphere extension for automatic reboot. */ u64 auto_reboot_ms; - if (settings::fwdbg::GetSettingsItemValue(&auto_reboot_ms, sizeof(auto_reboot_ms), "atmosphere", "fatal_auto_reboot_interval") == sizeof(auto_reboot_ms)) { + if (settings::fwdbg::GetSettingsItemValue(std::addressof(auto_reboot_ms), sizeof(auto_reboot_ms), "atmosphere", "fatal_auto_reboot_interval") == sizeof(auto_reboot_ms)) { this->fatal_auto_reboot_interval = TimeSpan::FromMilliSeconds(auto_reboot_ms); this->fatal_auto_reboot_enabled = auto_reboot_ms != 0; } diff --git a/stratosphere/fatal/source/fatal_debug.cpp b/stratosphere/fatal/source/fatal_debug.cpp index d4c1ac105..defe32894 100644 --- a/stratosphere/fatal/source/fatal_debug.cpp +++ b/stratosphere/fatal/source/fatal_debug.cpp @@ -160,13 +160,13 @@ namespace ams::fatal::srv { bool TryGuessBaseAddress(u64 *out_base_address, os::NativeHandle debug_handle, u64 guess) { svc::MemoryInfo mi; svc::PageInfo pi; - if (R_FAILED(svc::QueryDebugProcessMemory(&mi, &pi, debug_handle, guess)) || mi.permission != svc::MemoryPermission_ReadExecute) { + if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), debug_handle, guess)) || mi.permission != svc::MemoryPermission_ReadExecute) { return false; } /* Iterate backwards until we find the memory before the code region. */ while (mi.base_address > 0) { - if (R_FAILED(svc::QueryDebugProcessMemory(&mi, &pi, debug_handle, guess))) { + if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), debug_handle, guess))) { return false; } @@ -185,16 +185,16 @@ namespace ams::fatal::srv { u64 GetBaseAddress(const ThrowContext *throw_ctx, const svc::ThreadContext *thread_ctx, os::NativeHandle debug_handle) { u64 base_address = 0; - if (TryGuessBaseAddress(&base_address, debug_handle, thread_ctx->pc)) { + if (TryGuessBaseAddress(std::addressof(base_address), debug_handle, thread_ctx->pc)) { return base_address; } - if (TryGuessBaseAddress(&base_address, debug_handle, thread_ctx->lr)) { + if (TryGuessBaseAddress(std::addressof(base_address), debug_handle, thread_ctx->lr)) { return base_address; } for (size_t i = 0; i < throw_ctx->cpu_ctx.aarch64_ctx.stack_trace_size; i++) { - if (TryGuessBaseAddress(&base_address, debug_handle, throw_ctx->cpu_ctx.aarch64_ctx.stack_trace[i])) { + if (TryGuessBaseAddress(std::addressof(base_address), debug_handle, throw_ctx->cpu_ctx.aarch64_ctx.stack_trace[i])) { return base_address; } } @@ -253,7 +253,7 @@ namespace ams::fatal::srv { /* We start by trying to get a list of threads. */ s32 thread_count; u64 thread_ids[0x60]; - if (R_FAILED(svc::GetThreadList(&thread_count, thread_ids, 0x60, debug_handle))) { + if (R_FAILED(svc::GetThreadList(std::addressof(thread_count), thread_ids, 0x60, debug_handle))) { return; } @@ -265,7 +265,7 @@ namespace ams::fatal::srv { continue; } - if (IsThreadFatalCaller(ctx->result, debug_handle, cur_thread_id, cur_thread_tls, &thread_ctx)) { + if (IsThreadFatalCaller(ctx->result, debug_handle, cur_thread_id, cur_thread_tls, std::addressof(thread_ctx))) { thread_id = cur_thread_id; thread_tls = cur_thread_tls; found_fatal_caller = true; @@ -276,7 +276,7 @@ namespace ams::fatal::srv { return; } } - if (R_FAILED(svc::GetDebugThreadContext(&thread_ctx, debug_handle, thread_id, svc::ThreadContextFlag_All))) { + if (R_FAILED(svc::GetDebugThreadContext(std::addressof(thread_ctx), debug_handle, thread_id, svc::ThreadContextFlag_All))) { return; } @@ -325,7 +325,7 @@ namespace ams::fatal::srv { } /* Parse the base address. */ - ctx->cpu_ctx.aarch64_ctx.SetBaseAddress(GetBaseAddress(ctx, &thread_ctx, debug_handle)); + ctx->cpu_ctx.aarch64_ctx.SetBaseAddress(GetBaseAddress(ctx, std::addressof(thread_ctx), debug_handle)); } } diff --git a/stratosphere/fatal/source/fatal_font.cpp b/stratosphere/fatal/source/fatal_font.cpp index 482c7579d..d3e7e8b8d 100644 --- a/stratosphere/fatal/source/fatal_font.cpp +++ b/stratosphere/fatal/source/fatal_font.cpp @@ -94,7 +94,7 @@ namespace ams::fatal::srv::font { void DrawCodePoint(u32 codepoint, u32 x, u32 y) { int width = 0, height = 0; - u8* imageptr = stbtt_GetCodepointBitmap(&g_stb_font, g_font_size, g_font_size, codepoint, &width, &height, 0, 0); + u8* imageptr = stbtt_GetCodepointBitmap(std::addressof(g_stb_font), g_font_size, g_font_size, codepoint, std::addressof(width), std::addressof(height), 0, 0); ON_SCOPE_EXIT { DeallocateForFont(imageptr); }; for (int tmpy = 0; tmpy < height; tmpy++) { @@ -114,11 +114,11 @@ namespace ams::fatal::srv::font { u32 prev_char = 0; for (u32 i = 0; i < len; ) { u32 cur_char; - ssize_t unit_count = decode_utf8(&cur_char, reinterpret_cast(str + i)); + ssize_t unit_count = decode_utf8(std::addressof(cur_char), reinterpret_cast(str + i)); if (unit_count <= 0) break; if (!g_mono_adv && i > 0) { - cur_x += g_font_size * stbtt_GetCodepointKernAdvance(&g_stb_font, prev_char, cur_char); + cur_x += g_font_size * stbtt_GetCodepointKernAdvance(std::addressof(g_stb_font), prev_char, cur_char); } i += unit_count; @@ -130,11 +130,11 @@ namespace ams::fatal::srv::font { } int adv_width, left_side_bearing; - stbtt_GetCodepointHMetrics(&g_stb_font, cur_char, &adv_width, &left_side_bearing); + stbtt_GetCodepointHMetrics(std::addressof(g_stb_font), cur_char, std::addressof(adv_width), std::addressof(left_side_bearing)); const u32 cur_width = static_cast(adv_width) * g_font_size; int x0, y0, x1, y1; - stbtt_GetCodepointBitmapBoxSubpixel(&g_stb_font, cur_char, g_font_size, g_font_size, 0, 0, &x0, &y0, &x1, &y1); + stbtt_GetCodepointBitmapBoxSubpixel(std::addressof(g_stb_font), cur_char, g_font_size, g_font_size, 0, 0, std::addressof(x0), std::addressof(y0), std::addressof(x1), std::addressof(y1)); DrawCodePoint(cur_char, cur_x + x0 + ((mono && g_mono_adv > cur_width) ? ((g_mono_adv - cur_width) / 2) : 0), cur_y + y0); @@ -225,14 +225,14 @@ namespace ams::fatal::srv::font { } void SetFontSize(float fsz) { - g_font_size = stbtt_ScaleForPixelHeight(&g_stb_font, fsz * 1.375); + g_font_size = stbtt_ScaleForPixelHeight(std::addressof(g_stb_font), fsz * 1.375); int ascent; - stbtt_GetFontVMetrics(&g_stb_font, &ascent,0,0); + stbtt_GetFontVMetrics(std::addressof(g_stb_font), std::addressof(ascent),0,0); g_font_line_pixels = ascent * g_font_size * 1.125; int adv_width, left_side_bearing; - stbtt_GetCodepointHMetrics(&g_stb_font, 'A', &adv_width, &left_side_bearing); + stbtt_GetCodepointHMetrics(std::addressof(g_stb_font), 'A', std::addressof(adv_width), std::addressof(left_side_bearing)); g_mono_adv = adv_width * g_font_size; } @@ -248,10 +248,10 @@ namespace ams::fatal::srv::font { } Result InitializeSharedFont() { - R_TRY(plGetSharedFontByType(&g_font, PlSharedFontType_Standard)); + R_TRY(plGetSharedFontByType(std::addressof(g_font), PlSharedFontType_Standard)); u8 *font_buffer = reinterpret_cast(g_font.address); - stbtt_InitFont(&g_stb_font, font_buffer, stbtt_GetFontOffsetForIndex(font_buffer, 0)); + stbtt_InitFont(std::addressof(g_stb_font), font_buffer, stbtt_GetFontOffsetForIndex(font_buffer, 0)); SetFontSize(16.0f); return ResultSuccess(); diff --git a/stratosphere/fatal/source/fatal_repair.cpp b/stratosphere/fatal/source/fatal_repair.cpp index a3926e6bc..201ec4ba4 100644 --- a/stratosphere/fatal/source/fatal_repair.cpp +++ b/stratosphere/fatal/source/fatal_repair.cpp @@ -28,7 +28,7 @@ namespace ams::fatal::srv { } bool in_repair; - return R_SUCCEEDED(setsysGetInRepairProcessEnableFlag(&in_repair)) && in_repair; + return R_SUCCEEDED(setsysGetInRepairProcessEnableFlag(std::addressof(in_repair))) && in_repair; } bool IsInRepairWithoutVolHeld() { @@ -66,7 +66,7 @@ namespace ams::fatal::srv { } bool requires_time_reviser; - return R_SUCCEEDED(setsysGetRequiresRunRepairTimeReviser(&requires_time_reviser)) && requires_time_reviser; + return R_SUCCEEDED(setsysGetRequiresRunRepairTimeReviser(std::addressof(requires_time_reviser))) && requires_time_reviser; } bool IsTimeReviserCartridgeInserted() { @@ -74,21 +74,21 @@ namespace ams::fatal::srv { u8 gc_attr; { FsDeviceOperator devop; - if (R_FAILED(fsOpenDeviceOperator(&devop))) { + if (R_FAILED(fsOpenDeviceOperator(std::addressof(devop)))) { return false; } /* Ensure we close even on early return. */ - ON_SCOPE_EXIT { fsDeviceOperatorClose(&devop); }; + ON_SCOPE_EXIT { fsDeviceOperatorClose(std::addressof(devop)); }; /* Check that a gamecard is inserted. */ bool inserted; - if (R_FAILED(fsDeviceOperatorIsGameCardInserted(&devop, &inserted)) || !inserted) { + if (R_FAILED(fsDeviceOperatorIsGameCardInserted(std::addressof(devop), std::addressof(inserted))) || !inserted) { return false; } /* Check that we can retrieve the gamecard's attributes. */ - if (R_FAILED(fsDeviceOperatorGetGameCardHandle(&devop, &gc_hnd)) || R_FAILED(fsDeviceOperatorGetGameCardAttribute(&devop, &gc_hnd, &gc_attr))) { + if (R_FAILED(fsDeviceOperatorGetGameCardHandle(std::addressof(devop), std::addressof(gc_hnd))) || R_FAILED(fsDeviceOperatorGetGameCardAttribute(std::addressof(devop), std::addressof(gc_hnd), std::addressof(gc_attr)))) { return false; } } diff --git a/stratosphere/fatal/source/fatal_service.cpp b/stratosphere/fatal/source/fatal_service.cpp index f479713e0..b052d9b7e 100644 --- a/stratosphere/fatal/source/fatal_service.cpp +++ b/stratosphere/fatal/source/fatal_service.cpp @@ -85,13 +85,13 @@ namespace ams::fatal::srv { } /* Get program id. */ - pm::info::GetProgramId(&this->context.program_id, process_id); + pm::info::GetProgramId(std::addressof(this->context.program_id), process_id); this->context.is_creport = (this->context.program_id == ncm::SystemProgramId::Creport); if (!this->context.is_creport) { /* On firmware version 2.0.0, use debugging SVCs to collect information. */ if (hos::GetVersion() >= hos::Version_2_0_0) { - fatal::srv::TryCollectDebugInformation(&this->context, process_id); + fatal::srv::TryCollectDebugInformation(std::addressof(this->context), process_id); } } else { /* We received info from creport. Parse program id from afsr0. */ @@ -117,7 +117,7 @@ namespace ams::fatal::srv { this->event_manager.SignalEvents(); if (GetFatalConfig().ShouldTransitionToFatal()) { - RunTasks(&this->context); + RunTasks(std::addressof(this->context)); } break; /* N aborts here. Should we just return an error code? */ diff --git a/stratosphere/fatal/source/fatal_task_clock.cpp b/stratosphere/fatal/source/fatal_task_clock.cpp index 20f420fe7..7c689197f 100644 --- a/stratosphere/fatal/source/fatal_task_clock.cpp +++ b/stratosphere/fatal/source/fatal_task_clock.cpp @@ -41,13 +41,13 @@ namespace ams::fatal::srv { if (hos::GetVersion() >= hos::Version_8_0_0) { /* On 8.0.0+, convert to module id + use clkrst API. */ PcvModuleId module_id; - R_TRY(pcvGetModuleId(&module_id, module)); + R_TRY(pcvGetModuleId(std::addressof(module_id), module)); ClkrstSession session; - R_TRY(clkrstOpenSession(&session, module_id, 3)); - ON_SCOPE_EXIT { clkrstCloseSession(&session); }; + R_TRY(clkrstOpenSession(std::addressof(session), module_id, 3)); + ON_SCOPE_EXIT { clkrstCloseSession(std::addressof(session)); }; - R_TRY(clkrstSetClockRate(&session, hz)); + R_TRY(clkrstSetClockRate(std::addressof(session), hz)); } else { /* On 1.0.0-7.0.1, use pcv API. */ R_TRY(pcvSetClockRate(module, hz)); @@ -77,7 +77,7 @@ namespace ams::fatal::srv { ITask *GetAdjustClockTask(const ThrowContext *ctx) { g_adjust_clock_task.Initialize(ctx); - return &g_adjust_clock_task; + return std::addressof(g_adjust_clock_task); } } diff --git a/stratosphere/fatal/source/fatal_task_error_report.cpp b/stratosphere/fatal/source/fatal_task_error_report.cpp index c482484a9..8f2f837e4 100644 --- a/stratosphere/fatal/source/fatal_task_error_report.cpp +++ b/stratosphere/fatal/source/fatal_task_error_report.cpp @@ -34,7 +34,7 @@ namespace ams::fatal::srv { /* Check if we have time service. */ { bool has_time_service = false; - if (R_FAILED(sm::HasService(&has_time_service, sm::ServiceName::Encode("time:s"))) || !has_time_service) { + if (R_FAILED(sm::HasService(std::addressof(has_time_service), sm::ServiceName::Encode("time:s"))) || !has_time_service) { return false; } } @@ -73,7 +73,7 @@ namespace ams::fatal::srv { /* Get a timestamp. */ u64 timestamp; - if (!TryGetCurrentTimestamp(×tamp)) { + if (!TryGetCurrentTimestamp(std::addressof(timestamp))) { timestamp = os::GetSystemTick().GetInt64Value(); } @@ -172,7 +172,7 @@ namespace ams::fatal::srv { ITask *GetErrorReportTask(const ThrowContext *ctx) { g_error_report_task.Initialize(ctx); - return &g_error_report_task; + return std::addressof(g_error_report_task); } } diff --git a/stratosphere/fatal/source/fatal_task_power.cpp b/stratosphere/fatal/source/fatal_task_power.cpp index f622d86dd..61569bf02 100644 --- a/stratosphere/fatal/source/fatal_task_power.cpp +++ b/stratosphere/fatal/source/fatal_task_power.cpp @@ -88,7 +88,7 @@ namespace ams::fatal::srv { break; } - if (R_FAILED(psmGetBatteryVoltageState(&bv_state)) || bv_state == PsmBatteryVoltageState_NeedsShutdown) { + if (R_FAILED(psmGetBatteryVoltageState(std::addressof(bv_state))) || bv_state == PsmBatteryVoltageState_NeedsShutdown) { break; } @@ -112,7 +112,7 @@ namespace ams::fatal::srv { PsmBatteryVoltageState bv_state = PsmBatteryVoltageState_Normal; /* Check the battery state, and shutdown on low voltage. */ - if (R_FAILED(psmGetBatteryVoltageState(&bv_state)) || bv_state == PsmBatteryVoltageState_NeedsShutdown) { + if (R_FAILED(psmGetBatteryVoltageState(std::addressof(bv_state))) || bv_state == PsmBatteryVoltageState_NeedsShutdown) { /* Wait a second for the error report task to finish. */ this->context->erpt_event->TimedWait(TimeSpan::FromSeconds(1)); this->TryShutdown(); @@ -124,7 +124,7 @@ namespace ams::fatal::srv { /* Loop querying voltage state every 5 seconds. */ while (true) { - if (R_FAILED(psmGetBatteryVoltageState(&bv_state))) { + if (R_FAILED(psmGetBatteryVoltageState(std::addressof(bv_state)))) { bv_state = PsmBatteryVoltageState_NeedsShutdown; } @@ -181,7 +181,7 @@ namespace ams::fatal::srv { if (fatal_reboot_helper.IsRebootTiming() || (quest_reboot_helper.IsRebootTiming()) || (check_vol_up && gpio::GetValue(std::addressof(vol_up_btn)) == gpio::GpioValue_Low) || (check_vol_down && gpio::GetValue(std::addressof(vol_down_btn)) == gpio::GpioValue_Low) || - (R_SUCCEEDED(bpcGetSleepButtonState(&state)) && state == BpcSleepButtonState_Held)) + (R_SUCCEEDED(bpcGetSleepButtonState(std::addressof(state))) && state == BpcSleepButtonState_Held)) { /* If any of the above conditions succeeded, we should reboot. */ bpcRebootSystem(); @@ -214,17 +214,17 @@ namespace ams::fatal::srv { ITask *GetPowerControlTask(const ThrowContext *ctx) { g_power_control_task.Initialize(ctx); - return &g_power_control_task; + return std::addressof(g_power_control_task); } ITask *GetPowerButtonObserveTask(const ThrowContext *ctx) { g_power_button_observe_task.Initialize(ctx); - return &g_power_button_observe_task; + return std::addressof(g_power_button_observe_task); } ITask *GetStateTransitionStopTask(const ThrowContext *ctx) { g_state_transition_stop_task.Initialize(ctx); - return &g_state_transition_stop_task; + return std::addressof(g_state_transition_stop_task); } } diff --git a/stratosphere/fatal/source/fatal_task_screen.cpp b/stratosphere/fatal/source/fatal_task_screen.cpp index 504bdace5..6330da4e1 100644 --- a/stratosphere/fatal/source/fatal_task_screen.cpp +++ b/stratosphere/fatal/source/fatal_task_screen.cpp @@ -107,23 +107,23 @@ namespace ams::fatal::srv { Result ShowFatalTask::SetupDisplayInternal() { ViDisplay temp_display; /* Try to open the display. */ - R_TRY_CATCH(viOpenDisplay("Internal", &temp_display)) { + R_TRY_CATCH(viOpenDisplay("Internal", std::addressof(temp_display))) { R_CONVERT(vi::ResultNotFound, ResultSuccess()); } R_END_TRY_CATCH; /* Guarantee we close the display. */ - ON_SCOPE_EXIT { viCloseDisplay(&temp_display); }; + ON_SCOPE_EXIT { viCloseDisplay(std::addressof(temp_display)); }; /* Turn on the screen. */ if (hos::GetVersion() >= hos::Version_3_0_0) { - R_TRY(viSetDisplayPowerState(&temp_display, ViPowerState_On)); + R_TRY(viSetDisplayPowerState(std::addressof(temp_display), ViPowerState_On)); } else { /* Prior to 3.0.0, the ViPowerState enum was different (0 = Off, 1 = On). */ - R_TRY(viSetDisplayPowerState(&temp_display, ViPowerState_On_Deprecated)); + R_TRY(viSetDisplayPowerState(std::addressof(temp_display), ViPowerState_On_Deprecated)); } /* Set alpha to 1.0f. */ - R_TRY(viSetDisplayAlpha(&temp_display, 1.0f)); + R_TRY(viSetDisplayAlpha(std::addressof(temp_display), 1.0f)); return ResultSuccess(); } @@ -131,15 +131,15 @@ namespace ams::fatal::srv { Result ShowFatalTask::SetupDisplayExternal() { ViDisplay temp_display; /* Try to open the display. */ - R_TRY_CATCH(viOpenDisplay("External", &temp_display)) { + R_TRY_CATCH(viOpenDisplay("External", std::addressof(temp_display))) { R_CONVERT(vi::ResultNotFound, ResultSuccess()); } R_END_TRY_CATCH; /* Guarantee we close the display. */ - ON_SCOPE_EXIT { viCloseDisplay(&temp_display); }; + ON_SCOPE_EXIT { viCloseDisplay(std::addressof(temp_display)); }; /* Set alpha to 1.0f. */ - R_TRY(viSetDisplayAlpha(&temp_display, 1.0f)); + R_TRY(viSetDisplayAlpha(std::addressof(temp_display), 1.0f)); return ResultSuccess(); } @@ -156,19 +156,19 @@ namespace ams::fatal::srv { R_TRY(SetupDisplayExternal()); /* Open the default display. */ - R_TRY(viOpenDefaultDisplay(&this->display)); + R_TRY(viOpenDefaultDisplay(std::addressof(this->display))); /* Reset the display magnification to its default value. */ s32 display_width, display_height; - R_TRY(viGetDisplayLogicalResolution(&this->display, &display_width, &display_height)); + R_TRY(viGetDisplayLogicalResolution(std::addressof(this->display), std::addressof(display_width), std::addressof(display_height))); /* viSetDisplayMagnification was added in 3.0.0. */ if (hos::GetVersion() >= hos::Version_3_0_0) { - R_TRY(viSetDisplayMagnification(&this->display, 0, 0, display_width, display_height)); + R_TRY(viSetDisplayMagnification(std::addressof(this->display), 0, 0, display_width, display_height)); } /* Create layer to draw to. */ - R_TRY(viCreateLayer(&this->display, &this->layer)); + R_TRY(viCreateLayer(std::addressof(this->display), std::addressof(this->layer))); /* Setup the layer. */ { @@ -183,16 +183,16 @@ namespace ams::fatal::srv { const float layer_x = static_cast((display_width - LayerWidth) / 2); const float layer_y = static_cast((display_height - LayerHeight) / 2); - R_TRY(viSetLayerSize(&this->layer, LayerWidth, LayerHeight)); + R_TRY(viSetLayerSize(std::addressof(this->layer), LayerWidth, LayerHeight)); /* Set the layer's Z at display maximum, to be above everything else .*/ - R_TRY(viSetLayerZ(&this->layer, FatalLayerZ)); + R_TRY(viSetLayerZ(std::addressof(this->layer), FatalLayerZ)); /* Center the layer in the screen. */ - R_TRY(viSetLayerPosition(&this->layer, layer_x, layer_y)); + R_TRY(viSetLayerPosition(std::addressof(this->layer), layer_x, layer_y)); /* Create framebuffer. */ - R_TRY(nwindowCreateFromLayer(&this->win, &this->layer)); + R_TRY(nwindowCreateFromLayer(std::addressof(this->win), std::addressof(this->layer))); R_TRY(this->InitializeNativeWindow()); } @@ -439,7 +439,7 @@ namespace ams::fatal::srv { R_TRY(nvFenceInit()); /* Create nvmap. */ - R_TRY(nvMapCreate(&this->map, g_framebuffer_memory, sizeof(g_framebuffer_memory), 0x20000, NvKind_Pitch, true)); + R_TRY(nvMapCreate(std::addressof(this->map), g_framebuffer_memory, sizeof(g_framebuffer_memory), 0x20000, NvKind_Pitch, true)); /* Setup graphics buffer. */ { @@ -458,14 +458,14 @@ namespace ams::fatal::srv { grbuf.planes[0].layout = NvLayout_BlockLinear; grbuf.planes[0].kind = NvKind_Generic_16BX2; grbuf.planes[0].block_height_log2 = 4; - grbuf.nvmap_id = nvMapGetId(&this->map); + grbuf.nvmap_id = nvMapGetId(std::addressof(this->map)); grbuf.stride = FatalScreenWidthAligned; grbuf.total_size = sizeof(g_framebuffer_memory); grbuf.planes[0].pitch = FatalScreenWidthAlignedBytes; grbuf.planes[0].size = sizeof(g_framebuffer_memory); grbuf.planes[0].offset = 0; - R_TRY(nwindowConfigureBuffer(&this->win, 0, &grbuf)); + R_TRY(nwindowConfigureBuffer(std::addressof(this->win), 0, std::addressof(grbuf))); } return ResultSuccess(); @@ -473,9 +473,9 @@ namespace ams::fatal::srv { void ShowFatalTask::DisplayPreRenderedFrame() { s32 slot; - R_ABORT_UNLESS(nwindowDequeueBuffer(&this->win, &slot, nullptr)); + R_ABORT_UNLESS(nwindowDequeueBuffer(std::addressof(this->win), std::addressof(slot), nullptr)); dd::FlushDataCache(g_framebuffer_memory, sizeof(g_framebuffer_memory)); - R_ABORT_UNLESS(nwindowQueueBuffer(&this->win, this->win.cur_slot, NULL)); + R_ABORT_UNLESS(nwindowQueueBuffer(std::addressof(this->win), this->win.cur_slot, NULL)); } Result ShowFatalTask::ShowFatal() { @@ -511,12 +511,12 @@ namespace ams::fatal::srv { ITask *GetShowFatalTask(const ThrowContext *ctx) { g_show_fatal_task.Initialize(ctx); - return &g_show_fatal_task; + return std::addressof(g_show_fatal_task); } ITask *GetBacklightControlTask(const ThrowContext *ctx) { g_backlight_control_task.Initialize(ctx); - return &g_backlight_control_task; + return std::addressof(g_backlight_control_task); } } diff --git a/stratosphere/fatal/source/fatal_task_sound.cpp b/stratosphere/fatal/source/fatal_task_sound.cpp index 580fc9291..06849c60c 100644 --- a/stratosphere/fatal/source/fatal_task_sound.cpp +++ b/stratosphere/fatal/source/fatal_task_sound.cpp @@ -39,8 +39,8 @@ namespace ams::fatal::srv { /* Talk to the ALC5639 over I2C, and disable audio output. */ { I2cSession audio; - if (R_SUCCEEDED(i2cOpenSession(&audio, I2cDevice_Alc5639))) { - ON_SCOPE_EXIT { i2csessionClose(&audio); }; + if (R_SUCCEEDED(i2cOpenSession(std::addressof(audio), I2cDevice_Alc5639))) { + ON_SCOPE_EXIT { i2csessionClose(std::addressof(audio)); }; struct { u8 reg; @@ -50,16 +50,16 @@ namespace ams::fatal::srv { cmd.reg = 0x01; cmd.val = 0xC8C8; - i2csessionSendAuto(&audio, &cmd, sizeof(cmd), I2cTransactionOption_All); + i2csessionSendAuto(std::addressof(audio), std::addressof(cmd), sizeof(cmd), I2cTransactionOption_All); cmd.reg = 0x02; cmd.val = 0xC8C8; - i2csessionSendAuto(&audio, &cmd, sizeof(cmd), I2cTransactionOption_All); + i2csessionSendAuto(std::addressof(audio), std::addressof(cmd), sizeof(cmd), I2cTransactionOption_All); for (u8 reg = 97; reg <= 102; reg++) { cmd.reg = reg; cmd.val = 0; - i2csessionSendAuto(&audio, &cmd, sizeof(cmd), I2cTransactionOption_All); + i2csessionSendAuto(std::addressof(audio), std::addressof(cmd), sizeof(cmd), I2cTransactionOption_All); } } } @@ -89,7 +89,7 @@ namespace ams::fatal::srv { ITask *GetStopSoundTask(const ThrowContext *ctx) { g_stop_sound_task.Initialize(ctx); - return &g_stop_sound_task; + return std::addressof(g_stop_sound_task); } } diff --git a/stratosphere/loader/source/ldr_loader_service.cpp b/stratosphere/loader/source/ldr_loader_service.cpp index 96747115c..5d678b4f0 100644 --- a/stratosphere/loader/source/ldr_loader_service.cpp +++ b/stratosphere/loader/source/ldr_loader_service.cpp @@ -31,7 +31,7 @@ namespace ams::ldr { std::memset(out, 0, sizeof(*out)); cfg::OverrideStatus status = {}; - R_TRY(ldr::GetProgramInfo(out, &status, loc)); + R_TRY(ldr::GetProgramInfo(out, std::addressof(status), loc)); if (loc.storage_id != static_cast(ncm::StorageId::None) && loc.program_id != out->program_id) { char path[fs::EntryNameLengthMax]; @@ -64,7 +64,7 @@ namespace ams::ldr { char path[fs::EntryNameLengthMax]; /* Get location and override status. */ - R_TRY(ldr::ro::GetProgramLocationAndStatus(&loc, &override_status, id)); + R_TRY(ldr::ro::GetProgramLocationAndStatus(std::addressof(loc), std::addressof(override_status), id)); if (loc.storage_id != static_cast(ncm::StorageId::None)) { R_TRY(ResolveContentPath(path, loc)); diff --git a/stratosphere/loader/source/ldr_meta.cpp b/stratosphere/loader/source/ldr_meta.cpp index 696b84398..d4936570b 100644 --- a/stratosphere/loader/source/ldr_meta.cpp +++ b/stratosphere/loader/source/ldr_meta.cpp @@ -156,7 +156,7 @@ namespace ams::ldr { /* Validate the meta. */ { - Meta *meta = &cache->meta; + Meta *meta = std::addressof(cache->meta); Npdm *npdm = reinterpret_cast(cache->buffer); R_TRY(ValidateNpdm(npdm, npdm_size)); @@ -194,11 +194,11 @@ namespace ams::ldr { R_TRY(fs::OpenFile(std::addressof(file), AtmosphereMetaPath, fs::OpenMode_Read)); { ON_SCOPE_EXIT { fs::CloseFile(file); }; - R_TRY(LoadMetaFromFile(file, &g_meta_cache)); + R_TRY(LoadMetaFromFile(file, std::addressof(g_meta_cache))); } /* Patch meta. Start by setting all program ids to the current program id. */ - Meta *meta = &g_meta_cache.meta; + Meta *meta = std::addressof(g_meta_cache.meta); meta->acid->program_id_min = loc.program_id; meta->acid->program_id_max = loc.program_id; meta->aci->program_id = loc.program_id; @@ -209,8 +209,8 @@ namespace ams::ldr { ON_SCOPE_EXIT { fs::CloseFile(file); }; - if (R_SUCCEEDED(LoadMetaFromFile(file, &g_original_meta_cache))) { - Meta *o_meta = &g_original_meta_cache.meta; + if (R_SUCCEEDED(LoadMetaFromFile(file, std::addressof(g_original_meta_cache)))) { + Meta *o_meta = std::addressof(g_original_meta_cache.meta); /* Fix pool partition. */ if (hos::GetVersion() >= hos::Version_5_0_0) { @@ -253,8 +253,8 @@ namespace ams::ldr { if (static_cast(loc.storage_id) != ncm::StorageId::None || ncm::IsApplicationId(loc.program_id)) { R_TRY(fs::OpenFile(std::addressof(file), BaseMetaPath, fs::OpenMode_Read)); ON_SCOPE_EXIT { fs::CloseFile(file); }; - R_TRY(LoadMetaFromFile(file, &g_original_meta_cache)); - R_TRY(ValidateAcidSignature(&g_original_meta_cache.meta)); + R_TRY(LoadMetaFromFile(file, std::addressof(g_original_meta_cache))); + R_TRY(ValidateAcidSignature(std::addressof(g_original_meta_cache.meta))); meta->modulus = g_original_meta_cache.meta.modulus; meta->check_verification_data = g_original_meta_cache.meta.check_verification_data; } diff --git a/stratosphere/loader/source/ldr_patcher.cpp b/stratosphere/loader/source/ldr_patcher.cpp index 1dd9a515f..6764ec093 100644 --- a/stratosphere/loader/source/ldr_patcher.cpp +++ b/stratosphere/loader/source/ldr_patcher.cpp @@ -118,15 +118,15 @@ namespace ams::ldr { } ro::ModuleId module_id; - std::memcpy(&module_id.build_id, build_id, sizeof(module_id.build_id)); - ams::patcher::LocateAndApplyIpsPatchesToModule(LoaderSdMountName, NsoPatchesDirectory, NsoPatchesProtectedSize, NsoPatchesProtectedOffset, &module_id, reinterpret_cast(mapped_nso), mapped_size); + std::memcpy(std::addressof(module_id.build_id), build_id, sizeof(module_id.build_id)); + ams::patcher::LocateAndApplyIpsPatchesToModule(LoaderSdMountName, NsoPatchesDirectory, NsoPatchesProtectedSize, NsoPatchesProtectedOffset, std::addressof(module_id), reinterpret_cast(mapped_nso), mapped_size); } /* Apply embedded patches. */ void ApplyEmbeddedPatchesToModule(const u8 *build_id, uintptr_t mapped_nso, size_t mapped_size) { /* Make module id. */ ro::ModuleId module_id; - std::memcpy(&module_id.build_id, build_id, sizeof(module_id.build_id)); + std::memcpy(std::addressof(module_id.build_id), build_id, sizeof(module_id.build_id)); if (IsUsb30ForceEnabled()) { for (const auto &patch : Usb30ForceEnablePatches) { diff --git a/stratosphere/loader/source/ldr_process_creation.cpp b/stratosphere/loader/source/ldr_process_creation.cpp index fc8371775..a2a40c72d 100644 --- a/stratosphere/loader/source/ldr_process_creation.cpp +++ b/stratosphere/loader/source/ldr_process_creation.cpp @@ -346,7 +346,7 @@ namespace ams::ldr { out->reslimit = reslimit_h; /* Set flags. */ - R_TRY(GetCreateProcessFlags(&out->flags, meta, flags)); + R_TRY(GetCreateProcessFlags(std::addressof(out->flags), meta, flags)); /* 3.0.0+ System Resource Size. */ if (hos::GetVersion() >= hos::Version_3_0_0) { @@ -574,11 +574,11 @@ namespace ams::ldr { R_TRY(map.GetResult()); /* Load NSO segments. */ - R_TRY(LoadNsoSegment(file, &nso_header->segments[NsoHeader::Segment_Text], nso_header->text_compressed_size, nso_header->text_hash, (nso_header->flags & NsoHeader::Flag_CompressedText) != 0, + R_TRY(LoadNsoSegment(file, std::addressof(nso_header->segments[NsoHeader::Segment_Text]), nso_header->text_compressed_size, nso_header->text_hash, (nso_header->flags & NsoHeader::Flag_CompressedText) != 0, (nso_header->flags & NsoHeader::Flag_CheckHashText) != 0, map_address + nso_header->text_dst_offset, map_address + nso_size)); - R_TRY(LoadNsoSegment(file, &nso_header->segments[NsoHeader::Segment_Ro], nso_header->ro_compressed_size, nso_header->ro_hash, (nso_header->flags & NsoHeader::Flag_CompressedRo) != 0, + R_TRY(LoadNsoSegment(file, std::addressof(nso_header->segments[NsoHeader::Segment_Ro]), nso_header->ro_compressed_size, nso_header->ro_hash, (nso_header->flags & NsoHeader::Flag_CompressedRo) != 0, (nso_header->flags & NsoHeader::Flag_CheckHashRo) != 0, map_address + nso_header->ro_dst_offset, map_address + nso_size)); - R_TRY(LoadNsoSegment(file, &nso_header->segments[NsoHeader::Segment_Rw], nso_header->rw_compressed_size, nso_header->rw_hash, (nso_header->flags & NsoHeader::Flag_CompressedRw) != 0, + R_TRY(LoadNsoSegment(file, std::addressof(nso_header->segments[NsoHeader::Segment_Rw]), nso_header->rw_compressed_size, nso_header->rw_hash, (nso_header->flags & NsoHeader::Flag_CompressedRw) != 0, (nso_header->flags & NsoHeader::Flag_CheckHashRw) != 0, map_address + nso_header->rw_dst_offset, map_address + nso_size)); /* Clear unused space to zero. */ @@ -670,10 +670,10 @@ namespace ams::ldr { /* Load meta, possibly from cache. */ Meta meta; - R_TRY(LoadMetaFromCache(&meta, loc, override_status)); + R_TRY(LoadMetaFromCache(std::addressof(meta), loc, override_status)); /* Validate meta. */ - R_TRY(ValidateMeta(&meta, loc, mount.GetCodeVerificationData())); + R_TRY(ValidateMeta(std::addressof(meta), loc, mount.GetCodeVerificationData())); /* Load, validate NSOs. */ R_TRY(LoadNsoHeaders(nso_headers, has_nso)); @@ -681,13 +681,13 @@ namespace ams::ldr { /* Actually create process. */ ProcessInfo info; - R_TRY(CreateProcessImpl(&info, &meta, nso_headers, has_nso, arg_info, flags, reslimit_h)); + R_TRY(CreateProcessImpl(std::addressof(info), std::addressof(meta), nso_headers, has_nso, arg_info, flags, reslimit_h)); /* Ensure we close the process handle, if we fail. */ ON_SCOPE_EXIT { os::CloseNativeHandle(info.process_handle); }; /* Load NSOs into process memory. */ - R_TRY(LoadNsosIntoProcessMemory(&info, nso_headers, has_nso, arg_info)); + R_TRY(LoadNsosIntoProcessMemory(std::addressof(info), nso_headers, has_nso, arg_info)); /* Register NSOs with ro manager. */ { @@ -732,13 +732,13 @@ namespace ams::ldr { { ScopedCodeMount mount(loc); R_TRY(mount.GetResult()); - R_TRY(LoadMeta(&meta, loc, mount.GetOverrideStatus())); + R_TRY(LoadMeta(std::addressof(meta), loc, mount.GetOverrideStatus())); if (out_status != nullptr) { *out_status = mount.GetOverrideStatus(); } } - return GetProgramInfoFromMeta(out, &meta); + return GetProgramInfoFromMeta(out, std::addressof(meta)); } } diff --git a/stratosphere/pm/source/impl/pm_process_info.cpp b/stratosphere/pm/source/impl/pm_process_info.cpp index da4c105c2..ec1e257e8 100644 --- a/stratosphere/pm/source/impl/pm_process_info.cpp +++ b/stratosphere/pm/source/impl/pm_process_info.cpp @@ -30,7 +30,7 @@ namespace ams::pm::impl { void ProcessInfo::Cleanup() { if (this->handle != os::InvalidNativeHandle) { /* Unregister the process. */ - fsprUnregisterProgram(static_cast(this->process_id)); + fsprUnregisterProgram(this->process_id.value); sm::manager::UnregisterProcess(this->process_id); ldr::pm::UnpinProgram(this->pin_id); diff --git a/stratosphere/pm/source/impl/pm_process_info.hpp b/stratosphere/pm/source/impl/pm_process_info.hpp index b57ed2873..527035408 100644 --- a/stratosphere/pm/source/impl/pm_process_info.hpp +++ b/stratosphere/pm/source/impl/pm_process_info.hpp @@ -186,7 +186,7 @@ namespace ams::pm::impl { ProcessInfo *Find(os::ProcessId process_id) { for (auto it = this->begin(); it != this->end(); it++) { if ((*it).GetProcessId() == process_id) { - return &*it; + return std::addressof(*it); } } return nullptr; @@ -195,7 +195,7 @@ namespace ams::pm::impl { ProcessInfo *Find(ncm::ProgramId program_id) { for (auto it = this->begin(); it != this->end(); it++) { if ((*it).GetProgramLocation().program_id == program_id) { - return &*it; + return std::addressof(*it); } } return nullptr; @@ -216,11 +216,11 @@ namespace ams::pm::impl { } ProcessList *operator->() { - return &this->list; + return std::addressof(this->list); } const ProcessList *operator->() const { - return &this->list; + return std::addressof(this->list); } ProcessList &operator*() { diff --git a/stratosphere/pm/source/impl/pm_process_manager.cpp b/stratosphere/pm/source/impl/pm_process_manager.cpp index 2d58009d9..eed499c78 100644 --- a/stratosphere/pm/source/impl/pm_process_manager.cpp +++ b/stratosphere/pm/source/impl/pm_process_manager.cpp @@ -166,7 +166,7 @@ namespace ams::pm::impl { while (true) { auto signaled_holder = os::WaitAny(std::addressof(process_multi_wait)); - if (signaled_holder == &start_event_holder) { + if (signaled_holder == std::addressof(start_event_holder)) { /* Launch start event signaled. */ /* TryWait will clear signaled, preventing duplicate notifications. */ if (g_process_launch_start_event.TryWait()) { @@ -224,7 +224,7 @@ namespace ams::pm::impl { /* Get Program Info. */ ldr::ProgramInfo program_info; cfg::OverrideStatus override_status; - R_TRY(ldr::pm::AtmosphereGetProgramInfo(&program_info, &override_status, args.location)); + R_TRY(ldr::pm::AtmosphereGetProgramInfo(std::addressof(program_info), std::addressof(override_status), args.location)); const bool is_application = (program_info.flags & ldr::ProgramInfoFlag_ApplicationTypeMask) == ldr::ProgramInfoFlag_Application; const bool allow_debug = (program_info.flags & ldr::ProgramInfoFlag_AllowDebug) || hos::GetVersion() < hos::Version_2_0_0; @@ -236,16 +236,16 @@ namespace ams::pm::impl { /* Pin the program with loader. */ ldr::PinId pin_id; - R_TRY(ldr::pm::AtmospherePinProgram(&pin_id, location, override_status)); + R_TRY(ldr::pm::AtmospherePinProgram(std::addressof(pin_id), location, override_status)); /* Ensure resources are available. */ - resource::WaitResourceAvailable(&program_info); + resource::WaitResourceAvailable(std::addressof(program_info)); /* Actually create the process. */ os::NativeHandle process_handle; { auto pin_guard = SCOPE_GUARD { ldr::pm::UnpinProgram(pin_id); }; - R_TRY(ldr::pm::CreateProcess(&process_handle, pin_id, GetLoaderCreateProcessFlags(args.flags), resource::GetResourceLimitHandle(&program_info))); + R_TRY(ldr::pm::CreateProcess(std::addressof(process_handle), pin_id, GetLoaderCreateProcessFlags(args.flags), resource::GetResourceLimitHandle(std::addressof(program_info)))); pin_guard.Cancel(); } @@ -301,7 +301,7 @@ namespace ams::pm::impl { os::SignalSystemEvent(std::addressof(g_hook_to_create_application_process_event)); g_application_hook = false; } else if (!ShouldStartSuspended(args.flags)) { - R_TRY(StartProcess(process_info, &program_info)); + R_TRY(StartProcess(process_info, std::addressof(program_info))); } /* We succeeded, so we can cancel our cleanup. */ @@ -319,7 +319,7 @@ namespace ams::pm::impl { const svc::ProcessState old_state = process_info->GetState(); { s64 tmp = 0; - R_ABORT_UNLESS(svc::GetProcessInfo(&tmp, process_info->GetHandle(), svc::ProcessInfoType_ProcessState)); + R_ABORT_UNLESS(svc::GetProcessInfo(std::addressof(tmp), process_info->GetHandle(), svc::ProcessInfoType_ProcessState)); process_info->SetState(static_cast(tmp)); } const svc::ProcessState new_state = process_info->GetState(); @@ -445,8 +445,8 @@ namespace ams::pm::impl { R_UNLESS(!process_info->HasStarted(), pm::ResultAlreadyStarted()); ldr::ProgramInfo program_info; - R_TRY(ldr::pm::GetProgramInfo(&program_info, process_info->GetProgramLocation())); - return StartProcess(process_info, &program_info); + R_TRY(ldr::pm::GetProgramInfo(std::addressof(program_info), process_info->GetProgramLocation())); + return StartProcess(process_info, std::addressof(program_info)); } Result TerminateProcess(os::ProcessId process_id) { @@ -518,7 +518,7 @@ namespace ams::pm::impl { out->event = GetProcessEventValue(ProcessEvent::Exited); out->process_id = process_info.GetProcessId(); - CleanupProcessInfo(dead_list, &process_info); + CleanupProcessInfo(dead_list, std::addressof(process_info)); return ResultSuccess(); } } diff --git a/stratosphere/pm/source/pm_main.cpp b/stratosphere/pm/source/pm_main.cpp index 085daaa92..eed73ce30 100644 --- a/stratosphere/pm/source/pm_main.cpp +++ b/stratosphere/pm/source/pm_main.cpp @@ -61,7 +61,7 @@ namespace ams { void RegisterPrivilegedProcesses() { /* Get privileged process range. */ os::ProcessId min_priv_process_id = os::InvalidProcessId, max_priv_process_id = os::InvalidProcessId; - cfg::GetInitialProcessRange(&min_priv_process_id, &max_priv_process_id); + cfg::GetInitialProcessRange(std::addressof(min_priv_process_id), std::addressof(max_priv_process_id)); /* Get current process id/program id. */ const auto cur_process_id = os::GetCurrentProcessId(); @@ -70,7 +70,7 @@ namespace ams { /* Get list of processes, register all privileged ones. */ s32 num_pids; os::ProcessId pids[ProcessCountMax]; - R_ABORT_UNLESS(svc::GetProcessList(&num_pids, reinterpret_cast(pids), ProcessCountMax)); + R_ABORT_UNLESS(svc::GetProcessList(std::addressof(num_pids), reinterpret_cast(pids), ProcessCountMax)); for (s32 i = 0; i < num_pids; i++) { if (min_priv_process_id <= pids[i] && pids[i] <= max_priv_process_id) { RegisterPrivilegedProcess(pids[i], pids[i] == cur_process_id ? cur_program_id : GetProcessProgramId(pids[i])); diff --git a/stratosphere/ro/source/impl/ro_service_impl.cpp b/stratosphere/ro/source/impl/ro_service_impl.cpp index 835c26107..1e9c343b5 100644 --- a/stratosphere/ro/source/impl/ro_service_impl.cpp +++ b/stratosphere/ro/source/impl/ro_service_impl.cpp @@ -364,7 +364,7 @@ namespace ams::ro::impl { bool ShouldEaseNroRestriction() { /* Retrieve whether we should ease restrictions from set:sys. */ u8 should_ease = 0; - if (settings::fwdbg::GetSettingsItemValue(&should_ease, sizeof(should_ease), "ro", "ease_nro_restriction") != sizeof(should_ease)) { + if (settings::fwdbg::GetSettingsItemValue(std::addressof(should_ease), sizeof(should_ease), "ro", "ease_nro_restriction") != sizeof(should_ease)) { return false; } @@ -379,7 +379,7 @@ namespace ams::ro::impl { { /* Validate handle is a valid process handle. */ os::ProcessId handle_pid; - R_UNLESS(R_SUCCEEDED(os::GetProcessId(&handle_pid, process_handle.GetOsHandle())), ro::ResultInvalidProcess()); + R_UNLESS(R_SUCCEEDED(os::GetProcessId(std::addressof(handle_pid), process_handle.GetOsHandle())), ro::ResultInvalidProcess()); /* Validate process id. */ R_UNLESS(handle_pid == process_id, ro::ResultInvalidProcess()); @@ -420,7 +420,7 @@ namespace ams::ro::impl { /* Check we have space for a new NRR. */ NrrInfo *nrr_info = nullptr; - R_TRY(context->GetFreeNrrInfo(&nrr_info)); + R_TRY(context->GetFreeNrrInfo(std::addressof(nrr_info))); /* Prepare to cache the NRR's signature hash. */ Sha256Hash signed_area_hash; @@ -429,7 +429,7 @@ namespace ams::ro::impl { /* Map. */ NrrHeader *header = nullptr; u64 mapped_code_address = 0; - R_TRY(MapAndValidateNrr(&header, &mapped_code_address, std::addressof(signed_area_hash), sizeof(signed_area_hash), context->process_handle, program_id, nrr_address, nrr_size, nrr_kind, enforce_nrr_kind)); + R_TRY(MapAndValidateNrr(std::addressof(header), std::addressof(mapped_code_address), std::addressof(signed_area_hash), sizeof(signed_area_hash), context->process_handle, program_id, nrr_address, nrr_size, nrr_kind, enforce_nrr_kind)); /* Set NRR info. */ context->SetNrrInfoInUse(nrr_info, true); @@ -458,7 +458,7 @@ namespace ams::ro::impl { /* Check the NRR is loaded. */ NrrInfo *nrr_info = nullptr; - R_TRY(context->GetNrrInfoByAddress(&nrr_info, nrr_address)); + R_TRY(context->GetNrrInfoByAddress(std::addressof(nrr_info), nrr_address)); /* Unmap. */ const NrrInfo nrr_backup = *nrr_info; @@ -485,20 +485,20 @@ namespace ams::ro::impl { /* Check we have space for a new NRO. */ NroInfo *nro_info = nullptr; - R_TRY(context->GetFreeNroInfo(&nro_info)); + R_TRY(context->GetFreeNroInfo(std::addressof(nro_info))); nro_info->nro_heap_address = nro_address; nro_info->nro_heap_size = nro_size; nro_info->bss_heap_address = bss_address; nro_info->bss_heap_size = bss_size; /* Map the NRO. */ - R_TRY(MapNro(&nro_info->base_address, context->process_handle, nro_address, nro_size, bss_address, bss_size)); + R_TRY(MapNro(std::addressof(nro_info->base_address), context->process_handle, nro_address, nro_size, bss_address, bss_size)); /* Validate the NRO (parsing region extents). */ u64 rx_size = 0, ro_size = 0, rw_size = 0; { auto unmap_guard = SCOPE_GUARD { UnmapNro(context->process_handle, nro_info->base_address, nro_address, bss_address, bss_size, nro_size, 0); }; - R_TRY(context->ValidateNro(&nro_info->module_id, &rx_size, &ro_size, &rw_size, nro_info->base_address, nro_size, bss_size)); + R_TRY(context->ValidateNro(std::addressof(nro_info->module_id), std::addressof(rx_size), std::addressof(ro_size), std::addressof(rw_size), nro_info->base_address, nro_size, bss_size)); unmap_guard.Cancel(); } @@ -526,7 +526,7 @@ namespace ams::ro::impl { /* Check the NRO is loaded. */ NroInfo *nro_info = nullptr; - R_TRY(context->GetNroInfoByAddress(&nro_info, nro_address)); + R_TRY(context->GetNroInfoByAddress(std::addressof(nro_info), nro_address)); /* Unmap. */ const NroInfo nro_backup = *nro_info; @@ -552,7 +552,7 @@ namespace ams::ro::impl { /* Just copy out the info. */ LoaderModuleInfo *out_info = std::addressof(out_infos[count++]); - memcpy(out_info->build_id, &nro_info->module_id, sizeof(nro_info->module_id)); + memcpy(out_info->build_id, std::addressof(nro_info->module_id), sizeof(nro_info->module_id)); out_info->base_address = nro_info->base_address; out_info->size = nro_info->nro_heap_size + nro_info->bss_heap_size; } diff --git a/stratosphere/sm/source/impl/sm_service_manager.cpp b/stratosphere/sm/source/impl/sm_service_manager.cpp index 50ad9b8ad..4e042ea8b 100644 --- a/stratosphere/sm/source/impl/sm_service_manager.cpp +++ b/stratosphere/sm/source/impl/sm_service_manager.cpp @@ -127,7 +127,7 @@ namespace ams::sm::impl { public: InitialProcessIdLimits() { /* Retrieve process limits. */ - cfg::GetInitialProcessRange(&this->min, &this->max); + cfg::GetInitialProcessRange(std::addressof(this->min), std::addressof(this->max)); /* Ensure range is sane. */ AMS_ABORT_UNLESS(this->min <= this->max); @@ -538,7 +538,7 @@ namespace ams::sm::impl { /* Check that we have the service. */ bool has_service = false; - R_TRY(impl::HasService(&has_service, service)); + R_TRY(impl::HasService(std::addressof(has_service), service)); /* If we do, we can succeed immediately. */ R_SUCCEED_IF(has_service); diff --git a/stratosphere/spl/source/spl_api_impl.cpp b/stratosphere/spl/source/spl_api_impl.cpp index e349dfcca..70b762121 100644 --- a/stratosphere/spl/source/spl_api_impl.cpp +++ b/stratosphere/spl/source/spl_api_impl.cpp @@ -203,7 +203,7 @@ namespace ams::spl::impl { } Result Allocate() { - R_TRY(AllocateAesKeySlot(&this->slot, this)); + R_TRY(AllocateAesKeySlot(std::addressof(this->slot), this)); this->has_slot = true; return ResultSuccess(); } @@ -269,7 +269,7 @@ namespace ams::spl::impl { void InitializeSeEvents() { u64 irq_num; - AMS_ABORT_UNLESS(smc::GetConfig(&irq_num, 1, ConfigItem::SecurityEngineInterruptNumber) == smc::Result::Success); + AMS_ABORT_UNLESS(smc::GetConfig(std::addressof(irq_num), 1, ConfigItem::SecurityEngineInterruptNumber) == smc::Result::Success); os::InitializeInterruptEvent(std::addressof(g_se_event), irq_num, os::EventClearMode_AutoClear); R_ABORT_UNLESS(os::CreateSystemEvent(std::addressof(g_se_keyslot_available_event), os::EventClearMode_AutoClear, true)); @@ -279,7 +279,7 @@ namespace ams::spl::impl { void InitializeDeviceAddressSpace() { /* Create Address Space. */ - R_ABORT_UNLESS(svc::CreateDeviceAddressSpace(&g_se_das_hnd, 0, (1ul << 32))); + R_ABORT_UNLESS(svc::CreateDeviceAddressSpace(std::addressof(g_se_das_hnd), 0, (1ul << 32))); /* Attach it to the SE. */ R_ABORT_UNLESS(svc::AttachDeviceAddressSpace(svc::DeviceName_Se, g_se_das_hnd)); @@ -320,7 +320,7 @@ namespace ams::spl::impl { WaitSeOperationComplete(); smc::Result op_res; - smc::Result res = smc::GetResult(&op_res, op_key); + smc::Result res = smc::GetResult(std::addressof(op_res), op_key); if (res != smc::Result::Success) { return res; } @@ -332,7 +332,7 @@ namespace ams::spl::impl { WaitSeOperationComplete(); smc::Result op_res; - smc::Result res = smc::GetResultData(&op_res, out_buf, out_buf_size, op_key); + smc::Result res = smc::GetResultData(std::addressof(op_res), out_buf, out_buf_size, op_key); if (res != smc::Result::Success) { return res; } @@ -381,7 +381,7 @@ namespace ams::spl::impl { const u32 dst_ll_addr = g_se_mapped_work_buffer_addr + offsetof(DecryptAesBlockLayout, crypt_ctx.out); const u32 src_ll_addr = g_se_mapped_work_buffer_addr + offsetof(DecryptAesBlockLayout, crypt_ctx.in); - smc::Result res = smc::ComputeAes(&op_key, mode, iv_ctr, dst_ll_addr, src_ll_addr, sizeof(layout->in_block)); + smc::Result res = smc::ComputeAes(std::addressof(op_key), mode, iv_ctr, dst_ll_addr, src_ll_addr, sizeof(layout->in_block)); if (res != smc::Result::Success) { return res; } @@ -443,7 +443,7 @@ namespace ams::spl::impl { std::scoped_lock lk(g_async_op_lock); smc::AsyncOperationKey op_key; - smc::Result res = smc::ModularExponentiateWithStorageKey(&op_key, layout->base, layout->mod, mode); + smc::Result res = smc::ModularExponentiateWithStorageKey(std::addressof(op_key), layout->base, layout->mod, mode); if (res != smc::Result::Success) { return smc::ConvertResult(res); } @@ -483,7 +483,7 @@ namespace ams::spl::impl { std::scoped_lock lk(g_async_op_lock); smc::AsyncOperationKey op_key; - smc::Result res = smc::PrepareEsDeviceUniqueKey(&op_key, layout->base, layout->mod, label_digest, label_digest_size, smc::GetPrepareEsDeviceUniqueKeyOption(type, generation)); + smc::Result res = smc::PrepareEsDeviceUniqueKey(std::addressof(op_key), layout->base, layout->mod, label_digest, label_digest_size, smc::GetPrepareEsDeviceUniqueKeyOption(type, generation)); if (res != smc::Result::Success) { return smc::ConvertResult(res); } @@ -571,7 +571,7 @@ namespace ams::spl::impl { std::scoped_lock lk(g_async_op_lock); smc::AsyncOperationKey op_key; - smc::Result res = smc::ModularExponentiate(&op_key, layout->base, layout->exp, exp_size, layout->mod); + smc::Result res = smc::ModularExponentiate(std::addressof(op_key), layout->base, layout->exp, exp_size, layout->mod); if (res != smc::Result::Success) { return smc::ConvertResult(res); } @@ -587,7 +587,7 @@ namespace ams::spl::impl { } Result SetConfig(ConfigItem which, u64 value) { - return smc::ConvertResult(smc::SetConfig(which, &value, 1)); + return smc::ConvertResult(smc::SetConfig(which, std::addressof(value), 1)); } Result GenerateRandomBytes(void *out, size_t size) { @@ -605,7 +605,7 @@ namespace ams::spl::impl { Result IsDevelopment(bool *out) { u64 hardware_state; - R_TRY(impl::GetConfig(&hardware_state, ConfigItem::HardwareState)); + R_TRY(impl::GetConfig(std::addressof(hardware_state), ConfigItem::HardwareState)); *out = (hardware_state == HardwareState_Development); return ResultSuccess(); @@ -646,7 +646,7 @@ namespace ams::spl::impl { R_TRY(LoadVirtualAesKey(keyslot_holder.GetKeySlot(), access_key, s_generate_aes_key_source)); - return smc::ConvertResult(DecryptAesBlock(keyslot_holder.GetKeySlot(), out_key, &key_source)); + return smc::ConvertResult(DecryptAesBlock(keyslot_holder.GetKeySlot(), out_key, std::addressof(key_source))); } Result DecryptAesKey(AesKey *out_key, const KeySource &key_source, u32 generation, u32 option) { @@ -655,7 +655,7 @@ namespace ams::spl::impl { }; AccessKey access_key; - R_TRY(GenerateAesKek(&access_key, s_decrypt_aes_key_source, generation, option)); + R_TRY(GenerateAesKek(std::addressof(access_key), s_decrypt_aes_key_source, generation, option)); return GenerateAesKey(out_key, access_key, key_source); } @@ -711,7 +711,7 @@ namespace ams::spl::impl { const u32 dst_ll_addr = g_se_mapped_work_buffer_addr + offsetof(SeCryptContext, out); const u32 src_ll_addr = g_se_mapped_work_buffer_addr + offsetof(SeCryptContext, in); - smc::Result res = smc::ComputeAes(&op_key, mode, iv_ctr, dst_ll_addr, src_ll_addr, src_size); + smc::Result res = smc::ComputeAes(std::addressof(op_key), mode, iv_ctr, dst_ll_addr, src_ll_addr, src_size); if (res != smc::Result::Success) { return smc::ConvertResult(res); } @@ -791,7 +791,7 @@ namespace ams::spl::impl { copy_size = std::min(dst_size, src_size - DeviceUniqueDataMetaSize); smc_res = smc::DecryptDeviceUniqueData(layout->data, src_size, access_key, key_source, static_cast(option)); } else { - smc_res = smc::DecryptDeviceUniqueData(©_size, layout->data, src_size, access_key, key_source, option); + smc_res = smc::DecryptDeviceUniqueData(std::addressof(copy_size), layout->data, src_size, access_key, key_source, option); copy_size = std::min(dst_size, copy_size); } diff --git a/stratosphere/spl/source/spl_ctr_drbg.cpp b/stratosphere/spl/source/spl_ctr_drbg.cpp index 0fb2ecaff..845c79c59 100644 --- a/stratosphere/spl/source/spl_ctr_drbg.cpp +++ b/stratosphere/spl/source/spl_ctr_drbg.cpp @@ -19,16 +19,16 @@ namespace ams::spl { void CtrDrbg::Update(const void *data) { - aes128ContextCreate(&this->aes_ctx, this->key, true); + aes128ContextCreate(std::addressof(this->aes_ctx), this->key, true); for (size_t offset = 0; offset < sizeof(this->work[1]); offset += BlockSize) { IncrementCounter(this->counter); - aes128EncryptBlock(&this->aes_ctx, &this->work[1][offset], this->counter); + aes128EncryptBlock(std::addressof(this->aes_ctx), std::addressof(this->work[1][offset]), this->counter); } Xor(this->work[1], data, sizeof(this->work[1])); - std::memcpy(this->key, &this->work[1][0], sizeof(this->key)); - std::memcpy(this->counter, &this->work[1][BlockSize], sizeof(this->key)); + std::memcpy(this->key, std::addressof(this->work[1][0]), sizeof(this->key)); + std::memcpy(this->counter, std::addressof(this->work[1][BlockSize]), sizeof(this->key)); } void CtrDrbg::Initialize(const void *seed) { @@ -54,19 +54,19 @@ namespace ams::spl { return false; } - aes128ContextCreate(&this->aes_ctx, this->key, true); + aes128ContextCreate(std::addressof(this->aes_ctx), this->key, true); u8 *cur_dst = reinterpret_cast(out); size_t aligned_size = (size & ~(BlockSize - 1)); for (size_t offset = 0; offset < aligned_size; offset += BlockSize) { IncrementCounter(this->counter); - aes128EncryptBlock(&this->aes_ctx, cur_dst, this->counter); + aes128EncryptBlock(std::addressof(this->aes_ctx), cur_dst, this->counter); cur_dst += BlockSize; } if (size > aligned_size) { IncrementCounter(this->counter); - aes128EncryptBlock(&this->aes_ctx, this->work[1], this->counter); + aes128EncryptBlock(std::addressof(this->aes_ctx), this->work[1], this->counter); std::memcpy(cur_dst, this->work[1], size - aligned_size); }