diff --git a/libmesosphere/source/kern_k_resource_limit.cpp b/libmesosphere/source/kern_k_resource_limit.cpp index 0727a146..22438ad7 100644 --- a/libmesosphere/source/kern_k_resource_limit.cpp +++ b/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/libmesosphere/source/kern_k_thread.cpp b/libmesosphere/source/kern_k_thread.cpp index a457879c..49519dd2 100644 --- a/libmesosphere/source/kern_k_thread.cpp +++ b/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/libmesosphere/source/kern_k_thread_local_page.cpp b/libmesosphere/source/kern_k_thread_local_page.cpp index 9fcfea2c..9d2105ce 100644 --- a/libmesosphere/source/kern_k_thread_local_page.cpp +++ b/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/libstratosphere/Makefile b/libstratosphere/Makefile index a01800fc..c6dfa2e9 100644 --- a/libstratosphere/Makefile +++ b/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/libstratosphere/include/stratosphere/cfg/cfg_types.hpp b/libstratosphere/include/stratosphere/cfg/cfg_types.hpp index 7df965af..8c8ee368 100644 --- a/libstratosphere/include/stratosphere/cfg/cfg_types.hpp +++ b/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/libstratosphere/include/stratosphere/fs/fs_remote_filesystem.hpp b/libstratosphere/include/stratosphere/fs/fs_remote_filesystem.hpp index 45666447..19e65853 100644 --- a/libstratosphere/include/stratosphere/fs/fs_remote_filesystem.hpp +++ b/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/libstratosphere/include/stratosphere/fssystem/fssystem_utility.hpp b/libstratosphere/include/stratosphere/fssystem/fssystem_utility.hpp index 1a0d3bf3..0255d627 100644 --- a/libstratosphere/include/stratosphere/fssystem/fssystem_utility.hpp +++ b/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/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_cache.hpp b/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_cache.hpp index adcb0113..1731524d 100644 --- a/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_cache.hpp +++ b/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/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_store.hpp b/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_store.hpp index 461193dd..5ac39627 100644 --- a/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_store.hpp +++ b/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/libstratosphere/include/stratosphere/kvdb/kvdb_memory_key_value_store.hpp b/libstratosphere/include/stratosphere/kvdb/kvdb_memory_key_value_store.hpp index 6393eca5..2bce9b83 100644 --- a/libstratosphere/include/stratosphere/kvdb/kvdb_memory_key_value_store.hpp +++ b/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/libstratosphere/include/stratosphere/ncm/ncm_rights_id_cache.hpp b/libstratosphere/include/stratosphere/ncm/ncm_rights_id_cache.hpp index b137818e..381789b1 100644 --- a/libstratosphere/include/stratosphere/ncm/ncm_rights_id_cache.hpp +++ b/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/libstratosphere/include/stratosphere/rapidjson.hpp b/libstratosphere/include/stratosphere/rapidjson.hpp index 6d000e29..ddd30b9a 100644 --- a/libstratosphere/include/stratosphere/rapidjson.hpp +++ b/libstratosphere/include/stratosphere/rapidjson.hpp @@ -26,4 +26,4 @@ #include #include -#include \ No newline at end of file +#include diff --git a/libstratosphere/include/stratosphere/ro/ro_types.hpp b/libstratosphere/include/stratosphere/ro/ro_types.hpp index 45b26a14..057258c9 100644 --- a/libstratosphere/include/stratosphere/ro/ro_types.hpp +++ b/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/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_service_object.hpp b/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_service_object.hpp index 54897495..120d8499 100644 --- a/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_service_object.hpp +++ b/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/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_dispatch.hpp b/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_dispatch.hpp index 7161174c..cf0408ab 100644 --- a/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_dispatch.hpp +++ b/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/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp b/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp index 5659fefb..eeeb21a9 100644 --- a/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp +++ b/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/libstratosphere/include/stratosphere/sm/sm_types.hpp b/libstratosphere/include/stratosphere/sm/sm_types.hpp index ddbc260a..f9154637 100644 --- a/libstratosphere/include/stratosphere/sm/sm_types.hpp +++ b/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/libstratosphere/source/ams/ams_emummc_api.cpp b/libstratosphere/source/ams/ams_emummc_api.cpp index 1ee2626d..0258c056 100644 --- a/libstratosphere/source/ams/ams_emummc_api.cpp +++ b/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/libstratosphere/source/ams/ams_environment.cpp b/libstratosphere/source/ams/ams_environment.cpp index 7cbb5be8..eba47ec3 100644 --- a/libstratosphere/source/ams/ams_environment.cpp +++ b/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/libstratosphere/source/ams/ams_exosphere_api.cpp b/libstratosphere/source/ams/ams_exosphere_api.cpp index 2998f990..9df6fdfe 100644 --- a/libstratosphere/source/ams/ams_exosphere_api.cpp +++ b/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/libstratosphere/source/boot2/boot2_api.cpp b/libstratosphere/source/boot2/boot2_api.cpp index eea1c055..17c90292 100644 --- a/libstratosphere/source/boot2/boot2_api.cpp +++ b/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/libstratosphere/source/capsrv/server/jpeg/decodersrv_software_jpeg_decoder.cpp b/libstratosphere/source/capsrv/server/jpeg/decodersrv_software_jpeg_decoder.cpp index 67ee272b..3631a364 100644 --- a/libstratosphere/source/capsrv/server/jpeg/decodersrv_software_jpeg_decoder.cpp +++ b/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/libstratosphere/source/cfg/cfg_override.cpp b/libstratosphere/source/cfg/cfg_override.cpp index 2451074c..54629ff5 100644 --- a/libstratosphere/source/cfg/cfg_override.cpp +++ b/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/libstratosphere/source/cfg/cfg_sd_card.cpp b/libstratosphere/source/cfg/cfg_sd_card.cpp index e00908e6..999f524f 100644 --- a/libstratosphere/source/cfg/cfg_sd_card.cpp +++ b/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/libstratosphere/source/fssrv/fssrv_filesystem_interface_adapter.cpp b/libstratosphere/source/fssrv/fssrv_filesystem_interface_adapter.cpp index 58224e80..51880aba 100644 --- a/libstratosphere/source/fssrv/fssrv_filesystem_interface_adapter.cpp +++ b/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/libstratosphere/source/fssrv/fssrv_storage_interface_adapter.cpp b/libstratosphere/source/fssrv/fssrv_storage_interface_adapter.cpp index c5648857..5e757162 100644 --- a/libstratosphere/source/fssrv/fssrv_storage_interface_adapter.cpp +++ b/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/libstratosphere/source/fssystem/fssystem_directory_savedata_filesystem.cpp b/libstratosphere/source/fssystem/fssystem_directory_savedata_filesystem.cpp index ff78c099..7a1d8a3b 100644 --- a/libstratosphere/source/fssystem/fssystem_directory_savedata_filesystem.cpp +++ b/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/libstratosphere/source/fssystem/fssystem_utility.cpp b/libstratosphere/source/fssystem/fssystem_utility.cpp index 78a896fa..0b91df0a 100644 --- a/libstratosphere/source/fssystem/fssystem_utility.cpp +++ b/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/libstratosphere/source/kvdb/kvdb_archive.cpp b/libstratosphere/source/kvdb/kvdb_archive.cpp index de61a4a3..d4e3df29 100644 --- a/libstratosphere/source/kvdb/kvdb_archive.cpp +++ b/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/libstratosphere/source/ldr/ldr_pm_api.cpp b/libstratosphere/source/ldr/ldr_pm_api.cpp index 1a4856e4..0ad1d405 100644 --- a/libstratosphere/source/ldr/ldr_pm_api.cpp +++ b/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/libstratosphere/source/lm/lm_remote_log_service.cpp b/libstratosphere/source/lm/lm_remote_log_service.cpp index 88a4149b..5ebe3a1e 100644 --- a/libstratosphere/source/lm/lm_remote_log_service.cpp +++ b/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/libstratosphere/source/lm/lm_remote_log_service.hpp b/libstratosphere/source/lm/lm_remote_log_service.hpp index 47303c3a..c948008b 100644 --- a/libstratosphere/source/lm/lm_remote_log_service.hpp +++ b/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/libstratosphere/source/lmem/impl/lmem_impl_exp_heap.cpp b/libstratosphere/source/lmem/impl/lmem_impl_exp_heap.cpp index d59866b9..0da7a066 100644 --- a/libstratosphere/source/lmem/impl/lmem_impl_exp_heap.cpp +++ b/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/libstratosphere/source/lmem/impl/lmem_impl_unit_heap.cpp b/libstratosphere/source/lmem/impl/lmem_impl_unit_heap.cpp index f08763b8..fc6a78ce 100644 --- a/libstratosphere/source/lmem/impl/lmem_impl_unit_heap.cpp +++ b/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/libstratosphere/source/lr/lr_add_on_content_location_resolver_impl.cpp b/libstratosphere/source/lr/lr_add_on_content_location_resolver_impl.cpp index 84b80252..f76a4446 100644 --- a/libstratosphere/source/lr/lr_add_on_content_location_resolver_impl.cpp +++ b/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/libstratosphere/source/lr/lr_content_location_resolver_impl.cpp b/libstratosphere/source/lr/lr_content_location_resolver_impl.cpp index c6f56679..ec73341c 100644 --- a/libstratosphere/source/lr/lr_content_location_resolver_impl.cpp +++ b/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/libstratosphere/source/lr/lr_location_redirector.cpp b/libstratosphere/source/lr/lr_location_redirector.cpp index 7833b245..fd4e34eb 100644 --- a/libstratosphere/source/lr/lr_location_redirector.cpp +++ b/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/libstratosphere/source/lr/lr_remote_location_resolver_impl.hpp b/libstratosphere/source/lr/lr_remote_location_resolver_impl.hpp index 9b8c6716..500e2757 100644 --- a/libstratosphere/source/lr/lr_remote_location_resolver_impl.hpp +++ b/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/libstratosphere/source/lr/lr_remote_registered_location_resolver_impl.hpp b/libstratosphere/source/lr/lr_remote_registered_location_resolver_impl.hpp index 1f0ff9af..e57a78fa 100644 --- a/libstratosphere/source/lr/lr_remote_registered_location_resolver_impl.hpp +++ b/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/libstratosphere/source/ncm/ncm_content_manager_impl.cpp b/libstratosphere/source/ncm/ncm_content_manager_impl.cpp index 8b5376aa..9c7f0270 100644 --- a/libstratosphere/source/ncm/ncm_content_manager_impl.cpp +++ b/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/libstratosphere/source/ncm/ncm_content_storage_impl.cpp b/libstratosphere/source/ncm/ncm_content_storage_impl.cpp index 284bd711..5338c2e6 100644 --- a/libstratosphere/source/ncm/ncm_content_storage_impl.cpp +++ b/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/libstratosphere/source/ncm/ncm_host_content_storage_impl.cpp b/libstratosphere/source/ncm/ncm_host_content_storage_impl.cpp index 3e92b5bd..540e69bf 100644 --- a/libstratosphere/source/ncm/ncm_host_content_storage_impl.cpp +++ b/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/libstratosphere/source/ncm/ncm_install_task_base.cpp b/libstratosphere/source/ncm/ncm_install_task_base.cpp index 07041b9a..218e0ddb 100644 --- a/libstratosphere/source/ncm/ncm_install_task_base.cpp +++ b/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/libstratosphere/source/ncm/ncm_placeholder_accessor.cpp b/libstratosphere/source/ncm/ncm_placeholder_accessor.cpp index 69d47d6d..13be1c60 100644 --- a/libstratosphere/source/ncm/ncm_placeholder_accessor.cpp +++ b/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/libstratosphere/source/ncm/ncm_read_only_content_storage_impl.cpp b/libstratosphere/source/ncm/ncm_read_only_content_storage_impl.cpp index cb9e2324..abb7704d 100644 --- a/libstratosphere/source/ncm/ncm_read_only_content_storage_impl.cpp +++ b/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/libstratosphere/source/os/impl/os_multiple_wait_impl.cpp b/libstratosphere/source/os/impl/os_multiple_wait_impl.cpp index 34eea3a2..ba48dcb7 100644 --- a/libstratosphere/source/os/impl/os_multiple_wait_impl.cpp +++ b/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/libstratosphere/source/os/impl/os_multiple_wait_object_list.hpp b/libstratosphere/source/os/impl/os_multiple_wait_object_list.hpp index 298b93f5..d70eab59 100644 --- a/libstratosphere/source/os/impl/os_multiple_wait_object_list.hpp +++ b/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/libstratosphere/source/os/impl/os_rw_lock_target_impl.os.horizon.cpp b/libstratosphere/source/os/impl/os_rw_lock_target_impl.os.horizon.cpp index d77cc1c4..a90ac69e 100644 --- a/libstratosphere/source/os/impl/os_rw_lock_target_impl.os.horizon.cpp +++ b/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/libstratosphere/source/os/os_multiple_wait.cpp b/libstratosphere/source/os/os_multiple_wait.cpp index 4e6e0ee9..47d2b330 100644 --- a/libstratosphere/source/os/os_multiple_wait.cpp +++ b/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/libstratosphere/source/os/os_random.cpp b/libstratosphere/source/os/os_random.cpp index ef18f046..0d5dafba 100644 --- a/libstratosphere/source/os/os_random.cpp +++ b/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/libstratosphere/source/patcher/patcher_api.cpp b/libstratosphere/source/patcher/patcher_api.cpp index 35770577..1898046b 100644 --- a/libstratosphere/source/patcher/patcher_api.cpp +++ b/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/libstratosphere/source/pm/pm_boot_mode_api.cpp b/libstratosphere/source/pm/pm_boot_mode_api.cpp index 347d4653..a4a5db95 100644 --- a/libstratosphere/source/pm/pm_boot_mode_api.cpp +++ b/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/libstratosphere/source/pm/pm_dmnt_api.cpp b/libstratosphere/source/pm/pm_dmnt_api.cpp index faed95bf..fd382ada 100644 --- a/libstratosphere/source/pm/pm_dmnt_api.cpp +++ b/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/libstratosphere/source/pm/pm_info_api.cpp b/libstratosphere/source/pm/pm_info_api.cpp index 5a13daff..d46fad90 100644 --- a/libstratosphere/source/pm/pm_info_api.cpp +++ b/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/libstratosphere/source/pm/pm_info_api_weak.cpp b/libstratosphere/source/pm/pm_info_api_weak.cpp index 3784e354..56f72787 100644 --- a/libstratosphere/source/pm/pm_info_api_weak.cpp +++ b/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/libstratosphere/source/pm/pm_shell_api.cpp b/libstratosphere/source/pm/pm_shell_api.cpp index 862e6b0b..1d362264 100644 --- a/libstratosphere/source/pm/pm_shell_api.cpp +++ b/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/libstratosphere/source/sf/cmif/sf_cmif_domain_manager.cpp b/libstratosphere/source/sf/cmif/sf_cmif_domain_manager.cpp index 83d14b25..b882ea08 100644 --- a/libstratosphere/source/sf/cmif/sf_cmif_domain_manager.cpp +++ b/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/libstratosphere/source/sf/cmif/sf_cmif_domain_service_object.cpp b/libstratosphere/source/sf/cmif/sf_cmif_domain_service_object.cpp index 1be7e296..ae4c81a4 100644 --- a/libstratosphere/source/sf/cmif/sf_cmif_domain_service_object.cpp +++ b/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/libstratosphere/source/sf/hipc/sf_hipc_server_domain_session_manager.cpp b/libstratosphere/source/sf/hipc/sf_hipc_server_domain_session_manager.cpp index 7b5b5fc6..038de40d 100644 --- a/libstratosphere/source/sf/hipc/sf_hipc_server_domain_session_manager.cpp +++ b/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/libstratosphere/source/sf/hipc/sf_hipc_server_manager.cpp b/libstratosphere/source/sf/hipc/sf_hipc_server_manager.cpp index f5823ba5..7b5ecb0b 100644 --- a/libstratosphere/source/sf/hipc/sf_hipc_server_manager.cpp +++ b/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/libstratosphere/source/sf/hipc/sf_hipc_server_session_manager.cpp b/libstratosphere/source/sf/hipc/sf_hipc_server_session_manager.cpp index b79a20f5..9802621d 100644 --- a/libstratosphere/source/sf/hipc/sf_hipc_server_session_manager.cpp +++ b/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/libstratosphere/source/sm/sm_manager_api.cpp b/libstratosphere/source/sm/sm_manager_api.cpp index 296c4085..80372381 100644 --- a/libstratosphere/source/sm/sm_manager_api.cpp +++ b/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/libstratosphere/source/sm/sm_utils.hpp b/libstratosphere/source/sm/sm_utils.hpp index 73fcd6eb..a7d6f6ca 100644 --- a/libstratosphere/source/sm/sm_utils.hpp +++ b/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/libstratosphere/source/spl/smc/spl_smc.cpp b/libstratosphere/source/spl/smc/spl_smc.cpp index d531eeb1..b6416eed 100644 --- a/libstratosphere/source/spl/smc/spl_smc.cpp +++ b/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/libstratosphere/source/updater/updater_api.cpp b/libstratosphere/source/updater/updater_api.cpp index 95f65cb0..98d60065 100644 --- a/libstratosphere/source/updater/updater_api.cpp +++ b/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/libstratosphere/source/updater/updater_bis_management.hpp b/libstratosphere/source/updater/updater_bis_management.hpp index 90d5ae75..674259cf 100644 --- a/libstratosphere/source/updater/updater_bis_management.hpp +++ b/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/libstratosphere/source/util/util_ini.cpp b/libstratosphere/source/util/util_ini.cpp index 8b1b73b7..3da84029 100644 --- a/libstratosphere/source/util/util_ini.cpp +++ b/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/libvapours/include/vapours/util/util_intrusive_list.hpp b/libvapours/include/vapours/util/util_intrusive_list.hpp index 655ec3f7..f87ce0de 100644 --- a/libvapours/include/vapours/util/util_intrusive_list.hpp +++ b/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/libvapours/include/vapours/util/util_tinymt.hpp b/libvapours/include/vapours/util/util_tinymt.hpp index a3d19420..94c1adf2 100644 --- a/libvapours/include/vapours/util/util_tinymt.hpp +++ b/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/libvapours/source/crypto/impl/crypto_bignum_operations.cpp b/libvapours/source/crypto/impl/crypto_bignum_operations.cpp index 5e58088e..31371663 100644 --- a/libvapours/source/crypto/impl/crypto_bignum_operations.cpp +++ b/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/libvapours/source/dd/dd_io_mapping.cpp b/libvapours/source/dd/dd_io_mapping.cpp index efc8127a..b549b99a 100644 --- a/libvapours/source/dd/dd_io_mapping.cpp +++ b/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; }