From c99ce36d7ddf7731a9a086b76fd6acebaf2f8ce9 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sun, 21 Mar 2021 20:36:49 -0700 Subject: [PATCH] ams: convert to util::ConstructAt where appropriate --- libraries/libstratosphere/source/fs/fs_code.cpp | 6 ++---- .../source/htc/server/htc_htcmisc_hipc_server.cpp | 7 ++----- libraries/libstratosphere/source/htcfs/htcfs_client.cpp | 4 ++-- .../source/htclow/mux/htclow_mux_channel_impl_map.cpp | 2 +- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/libraries/libstratosphere/source/fs/fs_code.cpp b/libraries/libstratosphere/source/fs/fs_code.cpp index e58acb3e3..eb4fa2956 100644 --- a/libraries/libstratosphere/source/fs/fs_code.cpp +++ b/libraries/libstratosphere/source/fs/fs_code.cpp @@ -40,12 +40,10 @@ namespace ams::fs { /* Setup the storage. */ /* NOTE: This owns the file, and so on failure it will be closed appropriately. */ - std::construct_at(GetPointer(g_stratosphere_romfs_storage), stratosphere_romfs_file, true); - auto storage_guard = SCOPE_GUARD { std::destroy_at(GetPointer(g_stratosphere_romfs_storage)); }; + auto storage_guard = util::ConstructAtGuarded(g_stratosphere_romfs_storage, stratosphere_romfs_file, true); /* Create the filesystem. */ - std::construct_at(GetPointer(g_stratosphere_romfs_fs)); - auto fs_guard = SCOPE_GUARD { std::destroy_at(GetPointer(g_stratosphere_romfs_fs)); }; + auto fs_guard = util::ConstructAtGuarded(g_stratosphere_romfs_fs); /* Initialize the filesystem. */ R_TRY(GetReference(g_stratosphere_romfs_fs).Initialize(GetPointer(g_stratosphere_romfs_storage), nullptr, 0, false)); diff --git a/libraries/libstratosphere/source/htc/server/htc_htcmisc_hipc_server.cpp b/libraries/libstratosphere/source/htc/server/htc_htcmisc_hipc_server.cpp index 6ee4fda59..08694ab63 100644 --- a/libraries/libstratosphere/source/htc/server/htc_htcmisc_hipc_server.cpp +++ b/libraries/libstratosphere/source/htc/server/htc_htcmisc_hipc_server.cpp @@ -39,11 +39,8 @@ namespace ams::htc::server { /* Check that we haven't already initialized. */ AMS_ASSERT(g_server_manager == nullptr); - /* Create the server manager. */ - std::construct_at(GetPointer(g_server_manager_storage)); - - /* Set the server manager pointer. */ - g_server_manager = GetPointer(g_server_manager_storage); + /* Create/Set the server manager pointer. */ + g_server_manager = util::ConstructAt(g_server_manager_storage); /* Create and register the htc manager object. */ HtcServiceObject *service_object; diff --git a/libraries/libstratosphere/source/htcfs/htcfs_client.cpp b/libraries/libstratosphere/source/htcfs/htcfs_client.cpp index 37a4dc93f..d1920972e 100644 --- a/libraries/libstratosphere/source/htcfs/htcfs_client.cpp +++ b/libraries/libstratosphere/source/htcfs/htcfs_client.cpp @@ -28,13 +28,13 @@ namespace ams::htcfs { void InitializeClient(htclow::HtclowManager *manager) { AMS_ASSERT(!g_initialized); - std::construct_at(GetPointer(g_client_storage), manager); + util::ConstructAt(g_client_storage, manager); } void FinalizeClient() { AMS_ASSERT(g_initialized); - std::destroy_at(GetPointer(g_client_storage)); + util::DestroyAt(g_client_storage); } Client &GetClient() { diff --git a/libraries/libstratosphere/source/htclow/mux/htclow_mux_channel_impl_map.cpp b/libraries/libstratosphere/source/htclow/mux/htclow_mux_channel_impl_map.cpp index 8cc55f7c3..1ab38b1f6 100644 --- a/libraries/libstratosphere/source/htclow/mux/htclow_mux_channel_impl_map.cpp +++ b/libraries/libstratosphere/source/htclow/mux/htclow_mux_channel_impl_map.cpp @@ -56,7 +56,7 @@ namespace ams::htclow::mux { R_UNLESS(idx < MaxChannelCount, htclow::ResultOutOfChannel()); /* Create the channel impl. */ - std::construct_at(GetPointer(m_channel_storage[idx]), channel, m_packet_factory, m_state_machine, m_task_manager, m_event); + util::ConstructAt(m_channel_storage[idx], channel, m_packet_factory, m_state_machine, m_task_manager, m_event); /* Mark the storage valid. */ m_storage_valid[idx] = true;