From 310c1f50beb77fc5c6f9075029973161d4e51a4a Mon Sep 17 00:00:00 2001 From: FearlessTobi Date: Mon, 19 Feb 2024 16:00:46 +0100 Subject: scope_exit: Make constexpr Allows the use of the macro in constexpr-contexts. Also avoids some potential problems when nesting braces inside it. --- src/android/app/src/main/jni/native.cpp | 8 ++- src/audio_core/sink/cubeb_sink.cpp | 4 +- src/audio_core/sink/sink_stream.cpp | 4 +- src/common/demangle.cpp | 4 +- src/common/host_memory.cpp | 4 +- src/common/page_table.cpp | 4 +- src/common/scope_exit.h | 66 +++++++++++++++------- src/core/cpu_manager.cpp | 4 +- src/core/device_memory_manager.inc | 4 +- src/core/file_sys/fs_directory.h | 4 ++ src/core/file_sys/fs_path_utility.h | 12 ++-- .../fssystem_hierarchical_sha256_storage.cpp | 4 +- src/core/file_sys/program_metadata.cpp | 4 +- src/core/hle/kernel/k_client_session.cpp | 8 ++- src/core/hle/kernel/k_page_table_base.cpp | 40 ++++++++----- src/core/hle/kernel/k_process.cpp | 16 ++++-- src/core/hle/kernel/k_server_session.cpp | 36 +++++++----- src/core/hle/kernel/k_thread_local_page.cpp | 4 +- src/core/hle/kernel/k_transfer_memory.cpp | 4 +- src/core/hle/kernel/kernel.cpp | 12 +++- src/core/hle/kernel/svc/svc_code_memory.cpp | 4 +- .../hle/kernel/svc/svc_device_address_space.cpp | 4 +- src/core/hle/kernel/svc/svc_event.cpp | 4 +- src/core/hle/kernel/svc/svc_ipc.cpp | 8 +-- src/core/hle/kernel/svc/svc_port.cpp | 8 +-- src/core/hle/kernel/svc/svc_resource_limit.cpp | 4 +- src/core/hle/kernel/svc/svc_session.cpp | 4 +- src/core/hle/kernel/svc/svc_synchronization.cpp | 4 +- src/core/hle/kernel/svc/svc_thread.cpp | 4 +- src/core/hle/kernel/svc/svc_transfer_memory.cpp | 4 +- src/core/hle/service/am/applet_data_broker.cpp | 4 +- src/core/hle/service/am/process.cpp | 4 +- src/core/hle/service/glue/time/static.cpp | 41 +++++++++----- src/core/hle/service/glue/time/time_zone.cpp | 36 +++++++----- src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp | 4 +- src/core/hle/service/nvdrv/nvdrv_interface.cpp | 4 +- src/core/hle/service/psc/time/static.cpp | 33 +++++++---- src/core/hle/service/psc/time/steady_clock.cpp | 25 +++++--- src/core/hle/service/psc/time/system_clock.cpp | 8 ++- .../hle/service/psc/time/time_zone_service.cpp | 32 ++++++----- src/core/hle/service/server_manager.cpp | 8 ++- src/core/loader/nca.cpp | 4 +- src/core/memory.cpp | 8 +-- src/core/memory/dmnt_cheat_vm.cpp | 4 +- src/hid_core/frontend/emulated_controller.cpp | 50 ++++++++++------ src/input_common/helpers/joycon_driver.cpp | 4 +- src/video_core/engines/maxwell_3d.cpp | 4 +- src/video_core/fence_manager.h | 4 +- src/video_core/gpu_thread.cpp | 4 +- src/video_core/host1x/ffmpeg/ffmpeg.cpp | 4 +- src/video_core/macro/macro_hle.cpp | 8 +-- src/video_core/renderer_opengl/gl_rasterizer.cpp | 8 ++- src/video_core/renderer_vulkan/present/layer.cpp | 4 +- src/video_core/renderer_vulkan/renderer_vulkan.cpp | 4 +- src/video_core/renderer_vulkan/vk_rasterizer.cpp | 8 ++- .../vulkan_common/nsight_aftermath_tracker.cpp | 4 +- src/yuzu/main.cpp | 28 +++++---- src/yuzu_cmd/yuzu.cpp | 4 +- 58 files changed, 421 insertions(+), 226 deletions(-) diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp index 50cef5d2a..4ea82e217 100644 --- a/src/android/app/src/main/jni/native.cpp +++ b/src/android/app/src/main/jni/native.cpp @@ -404,7 +404,9 @@ static Core::SystemResultStatus RunEmulation(const std::string& filepath, const size_t program_index, const bool frontend_initiated) { MicroProfileOnThreadCreate("EmuThread"); - SCOPE_EXIT({ MicroProfileShutdown(); }); + SCOPE_EXIT { + MicroProfileShutdown(); + }; LOG_INFO(Frontend, "starting"); @@ -413,7 +415,9 @@ static Core::SystemResultStatus RunEmulation(const std::string& filepath, return Core::SystemResultStatus::ErrorLoader; } - SCOPE_EXIT({ EmulationSession::GetInstance().ShutdownEmulation(); }); + SCOPE_EXIT { + EmulationSession::GetInstance().ShutdownEmulation(); + }; jconst result = EmulationSession::GetInstance().InitializeEmulation(filepath, program_index, frontend_initiated); diff --git a/src/audio_core/sink/cubeb_sink.cpp b/src/audio_core/sink/cubeb_sink.cpp index d97ca2a40..49efae8e3 100644 --- a/src/audio_core/sink/cubeb_sink.cpp +++ b/src/audio_core/sink/cubeb_sink.cpp @@ -357,7 +357,9 @@ bool IsCubebSuitable() { return false; } - SCOPE_EXIT({ cubeb_destroy(ctx); }); + SCOPE_EXIT { + cubeb_destroy(ctx); + }; #ifdef _WIN32 if (SUCCEEDED(com_init_result)) { diff --git a/src/audio_core/sink/sink_stream.cpp b/src/audio_core/sink/sink_stream.cpp index c047b0668..0a98eb31e 100644 --- a/src/audio_core/sink/sink_stream.cpp +++ b/src/audio_core/sink/sink_stream.cpp @@ -20,10 +20,10 @@ namespace AudioCore::Sink { void SinkStream::AppendBuffer(SinkBuffer& buffer, std::span samples) { - SCOPE_EXIT({ + SCOPE_EXIT { queue.enqueue(buffer); ++queued_buffers; - }); + }; if (type == StreamType::In) { return; diff --git a/src/common/demangle.cpp b/src/common/demangle.cpp index 6e117cb41..b2c9d126a 100644 --- a/src/common/demangle.cpp +++ b/src/common/demangle.cpp @@ -20,7 +20,9 @@ std::string DemangleSymbol(const std::string& mangled) { } char* demangled = nullptr; - SCOPE_EXIT({ std::free(demangled); }); + SCOPE_EXIT { + std::free(demangled); + }; if (is_itanium(mangled)) { demangled = llvm::itaniumDemangle(mangled.c_str()); diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp index 860c39e6a..e0b5a6a67 100644 --- a/src/common/host_memory.cpp +++ b/src/common/host_memory.cpp @@ -430,11 +430,11 @@ public: explicit Impl(size_t backing_size_, size_t virtual_size_) : backing_size{backing_size_}, virtual_size{virtual_size_} { bool good = false; - SCOPE_EXIT({ + SCOPE_EXIT { if (!good) { Release(); } - }); + }; long page_size = sysconf(_SC_PAGESIZE); if (page_size != 0x1000) { diff --git a/src/common/page_table.cpp b/src/common/page_table.cpp index 85dc18c11..3205eb7da 100644 --- a/src/common/page_table.cpp +++ b/src/common/page_table.cpp @@ -24,10 +24,10 @@ bool PageTable::ContinueTraversal(TraversalEntry* out_entry, TraversalContext* c out_entry->block_size = page_size; // Regardless of whether the page was mapped, advance on exit. - SCOPE_EXIT({ + SCOPE_EXIT { context->next_page += 1; context->next_offset += page_size; - }); + }; // Validate that we can read the actual entry. const auto page = context->next_page; diff --git a/src/common/scope_exit.h b/src/common/scope_exit.h index e9c789c88..f3e88cde9 100644 --- a/src/common/scope_exit.h +++ b/src/common/scope_exit.h @@ -7,29 +7,61 @@ #include "common/common_funcs.h" namespace detail { -template -struct ScopeExitHelper { - explicit ScopeExitHelper(Func&& func_) : func(std::move(func_)) {} - ~ScopeExitHelper() { +template +class ScopeGuard { + YUZU_NON_COPYABLE(ScopeGuard); + +private: + F f; + bool active; + +public: + constexpr ScopeGuard(F f_) : f(std::move(f_)), active(true) {} + constexpr ~ScopeGuard() { if (active) { - func(); + f(); } } - - void Cancel() { + constexpr void Cancel() { active = false; } - Func func; - bool active{true}; + constexpr ScopeGuard(ScopeGuard&& rhs) : f(std::move(rhs.f)), active(rhs.active) { + rhs.Cancel(); + } + + ScopeGuard& operator=(ScopeGuard&& rhs) = delete; }; -template -ScopeExitHelper ScopeExit(Func&& func) { - return ScopeExitHelper(std::forward(func)); +template +constexpr ScopeGuard MakeScopeGuard(F f) { + return ScopeGuard(std::move(f)); } + +enum class ScopeGuardOnExit {}; + +template +constexpr ScopeGuard operator+(ScopeGuardOnExit, F&& f) { + return ScopeGuard(std::forward(f)); +} + } // namespace detail +#define CONCATENATE_IMPL(s1, s2) s1##s2 +#define CONCATENATE(s1, s2) CONCATENATE_IMPL(s1, s2) + +#ifdef __COUNTER__ +#define ANONYMOUS_VARIABLE(pref) CONCATENATE(pref, __COUNTER__) +#else +#define ANONYMOUS_VARIABLE(pref) CONCATENATE(pref, __LINE__) +#endif + +/** + * This macro is similar to SCOPE_EXIT, except the object is caller managed. This is intended to be + * used when the caller might want to cancel the ScopeExit. + */ +#define SCOPE_GUARD detail::ScopeGuardOnExit() + [&]() + /** * This macro allows you to conveniently specify a block of code that will run on scope exit. Handy * for doing ad-hoc clean-up tasks in a function with multiple returns. @@ -38,7 +70,7 @@ ScopeExitHelper ScopeExit(Func&& func) { * \code * const int saved_val = g_foo; * g_foo = 55; - * SCOPE_EXIT({ g_foo = saved_val; }); + * SCOPE_EXIT{ g_foo = saved_val; }; * * if (Bar()) { * return 0; @@ -47,10 +79,4 @@ ScopeExitHelper ScopeExit(Func&& func) { * } * \endcode */ -#define SCOPE_EXIT(body) auto CONCAT2(scope_exit_helper_, __LINE__) = detail::ScopeExit([&]() body) - -/** - * This macro is similar to SCOPE_EXIT, except the object is caller managed. This is intended to be - * used when the caller might want to cancel the ScopeExit. - */ -#define SCOPE_GUARD(body) detail::ScopeExit([&]() body) +#define SCOPE_EXIT auto ANONYMOUS_VARIABLE(SCOPE_EXIT_STATE_) = SCOPE_GUARD diff --git a/src/core/cpu_manager.cpp b/src/core/cpu_manager.cpp index 7a5c22f78..9b1c77387 100644 --- a/src/core/cpu_manager.cpp +++ b/src/core/cpu_manager.cpp @@ -199,10 +199,10 @@ void CpuManager::RunThread(std::stop_token token, std::size_t core) { data.host_context = Common::Fiber::ThreadToFiber(); // Cleanup - SCOPE_EXIT({ + SCOPE_EXIT { data.host_context->Exit(); MicroProfileOnThreadExit(); - }); + }; // Running if (!gpu_barrier->Sync(token)) { diff --git a/src/core/device_memory_manager.inc b/src/core/device_memory_manager.inc index 6dfee806c..37c1e69c3 100644 --- a/src/core/device_memory_manager.inc +++ b/src/core/device_memory_manager.inc @@ -391,12 +391,12 @@ void DeviceMemoryManager::WalkBlock(DAddr addr, std::size_t size, auto o std::min((next_pages << Memory::YUZU_PAGEBITS) - page_offset, remaining_size); const auto current_vaddr = static_cast((page_index << Memory::YUZU_PAGEBITS) + page_offset); - SCOPE_EXIT({ + SCOPE_EXIT{ page_index += next_pages; page_offset = 0; increment(copy_amount); remaining_size -= copy_amount; - }); + }; auto phys_addr = compressed_physical_ptr[page_index]; if (phys_addr == 0) { diff --git a/src/core/file_sys/fs_directory.h b/src/core/file_sys/fs_directory.h index 25c9cb18a..3f90abb8f 100644 --- a/src/core/file_sys/fs_directory.h +++ b/src/core/file_sys/fs_directory.h @@ -3,6 +3,10 @@ #pragma once +#include +#include "common/common_funcs.h" +#include "common/common_types.h" + namespace FileSys { constexpr inline size_t EntryNameLengthMax = 0x300; diff --git a/src/core/file_sys/fs_path_utility.h b/src/core/file_sys/fs_path_utility.h index e9011d065..5643141f9 100644 --- a/src/core/file_sys/fs_path_utility.h +++ b/src/core/file_sys/fs_path_utility.h @@ -447,7 +447,7 @@ public: char* replacement_path = nullptr; size_t replacement_path_size = 0; - SCOPE_EXIT({ + SCOPE_EXIT { if (replacement_path != nullptr) { if (std::is_constant_evaluated()) { delete[] replacement_path; @@ -455,7 +455,7 @@ public: Deallocate(replacement_path, replacement_path_size); } } - }); + }; // Perform path replacement, if necessary if (IsParentDirectoryPathReplacementNeeded(cur_path)) { @@ -1102,8 +1102,8 @@ public: R_SUCCEED(); } - static Result Normalize(char* dst, size_t dst_size, const char* path, size_t path_len, - const PathFlags& flags) { + static constexpr Result Normalize(char* dst, size_t dst_size, const char* path, size_t path_len, + const PathFlags& flags) { // Use StringTraits names for remainder of scope using namespace StringTraits; @@ -1199,7 +1199,7 @@ public: const size_t replaced_src_len = path_len - (src - path); char* replaced_src = nullptr; - SCOPE_EXIT({ + SCOPE_EXIT { if (replaced_src != nullptr) { if (std::is_constant_evaluated()) { delete[] replaced_src; @@ -1207,7 +1207,7 @@ public: Deallocate(replaced_src, replaced_src_len); } } - }); + }; if (std::is_constant_evaluated()) { replaced_src = new char[replaced_src_len]; diff --git a/src/core/file_sys/fssystem/fssystem_hierarchical_sha256_storage.cpp b/src/core/file_sys/fssystem/fssystem_hierarchical_sha256_storage.cpp index caea0b8f8..a68fd973c 100644 --- a/src/core/file_sys/fssystem/fssystem_hierarchical_sha256_storage.cpp +++ b/src/core/file_sys/fssystem/fssystem_hierarchical_sha256_storage.cpp @@ -36,7 +36,9 @@ Result HierarchicalSha256Storage::Initialize(VirtualFile* base_storages, s32 lay // Get the base storage size. m_base_storage_size = base_storages[2]->GetSize(); { - auto size_guard = SCOPE_GUARD({ m_base_storage_size = 0; }); + auto size_guard = SCOPE_GUARD { + m_base_storage_size = 0; + }; R_UNLESS(m_base_storage_size <= static_cast(HashSize) << m_log_size_ratio << m_log_size_ratio, ResultHierarchicalSha256BaseStorageTooLarge); diff --git a/src/core/file_sys/program_metadata.cpp b/src/core/file_sys/program_metadata.cpp index ae4e441c9..289969cc4 100644 --- a/src/core/file_sys/program_metadata.cpp +++ b/src/core/file_sys/program_metadata.cpp @@ -98,7 +98,9 @@ Loader::ResultStatus ProgramMetadata::Load(VirtualFile file) { Loader::ResultStatus ProgramMetadata::Reload(VirtualFile file) { const u64 original_program_id = aci_header.title_id; - SCOPE_EXIT({ aci_header.title_id = original_program_id; }); + SCOPE_EXIT { + aci_header.title_id = original_program_id; + }; return this->Load(file); } diff --git a/src/core/hle/kernel/k_client_session.cpp b/src/core/hle/kernel/k_client_session.cpp index 472e8571c..3e01e3b67 100644 --- a/src/core/hle/kernel/k_client_session.cpp +++ b/src/core/hle/kernel/k_client_session.cpp @@ -24,7 +24,9 @@ Result KClientSession::SendSyncRequest(uintptr_t address, size_t size) { // Create a session request. KSessionRequest* request = KSessionRequest::Create(m_kernel); R_UNLESS(request != nullptr, ResultOutOfResource); - SCOPE_EXIT({ request->Close(); }); + SCOPE_EXIT { + request->Close(); + }; // Initialize the request. request->Initialize(nullptr, address, size); @@ -37,7 +39,9 @@ Result KClientSession::SendAsyncRequest(KEvent* event, uintptr_t address, size_t // Create a session request. KSessionRequest* request = KSessionRequest::Create(m_kernel); R_UNLESS(request != nullptr, ResultOutOfResource); - SCOPE_EXIT({ request->Close(); }); + SCOPE_EXIT { + request->Close(); + }; // Initialize the request. request->Initialize(event, address, size); diff --git a/src/core/hle/kernel/k_page_table_base.cpp b/src/core/hle/kernel/k_page_table_base.cpp index 1dd86fb3c..19cdf4f3a 100644 --- a/src/core/hle/kernel/k_page_table_base.cpp +++ b/src/core/hle/kernel/k_page_table_base.cpp @@ -1305,11 +1305,11 @@ Result KPageTableBase::UnmapCodeMemory(KProcessAddress dst_address, KProcessAddr // Ensure that we maintain the instruction cache. bool reprotected_pages = false; - SCOPE_EXIT({ + SCOPE_EXIT { if (reprotected_pages && any_code_pages) { InvalidateInstructionCache(m_kernel, this, dst_address, size); } - }); + }; // Unmap. { @@ -1397,7 +1397,9 @@ Result KPageTableBase::MapInsecureMemory(KProcessAddress address, size_t size) { // Close the opened pages when we're done with them. // If the mapping succeeds, each page will gain an extra reference, otherwise they will be freed // automatically. - SCOPE_EXIT({ pg.Close(); }); + SCOPE_EXIT { + pg.Close(); + }; // Clear all the newly allocated pages. for (const auto& it : pg) { @@ -1603,7 +1605,9 @@ Result KPageTableBase::AllocateAndMapPagesImpl(PageLinkedList* page_list, KProce m_kernel.MemoryManager().AllocateAndOpen(std::addressof(pg), num_pages, m_allocate_option)); // Ensure that the page group is closed when we're done working with it. - SCOPE_EXIT({ pg.Close(); }); + SCOPE_EXIT { + pg.Close(); + }; // Clear all pages. for (const auto& it : pg) { @@ -2191,7 +2195,9 @@ Result KPageTableBase::SetHeapSize(KProcessAddress* out, size_t size) { // Close the opened pages when we're done with them. // If the mapping succeeds, each page will gain an extra reference, otherwise they will be freed // automatically. - SCOPE_EXIT({ pg.Close(); }); + SCOPE_EXIT { + pg.Close(); + }; // Clear all the newly allocated pages. for (const auto& it : pg) { @@ -2592,7 +2598,9 @@ Result KPageTableBase::UnmapIoRegion(KProcessAddress dst_address, KPhysicalAddre // Temporarily unlock ourselves, so that other operations can occur while we flush the // region. m_general_lock.Unlock(); - SCOPE_EXIT({ m_general_lock.Lock(); }); + SCOPE_EXIT { + m_general_lock.Lock(); + }; // Flush the region. R_ASSERT(FlushDataCache(dst_address, size)); @@ -3311,10 +3319,10 @@ Result KPageTableBase::ReadIoMemoryImpl(KProcessAddress dst_addr, KPhysicalAddre // Ensure we unmap the io memory when we're done with it. const KPageProperties unmap_properties = KPageProperties{KMemoryPermission::None, false, false, DisableMergeAttribute::None}; - SCOPE_EXIT({ + SCOPE_EXIT { R_ASSERT(this->Operate(updater.GetPageList(), io_addr, map_size / PageSize, 0, false, unmap_properties, OperationType::Unmap, true)); - }); + }; // Read the memory. const KProcessAddress read_addr = io_addr + (GetInteger(phys_addr) & (PageSize - 1)); @@ -3347,10 +3355,10 @@ Result KPageTableBase::WriteIoMemoryImpl(KPhysicalAddress phys_addr, KProcessAdd // Ensure we unmap the io memory when we're done with it. const KPageProperties unmap_properties = KPageProperties{KMemoryPermission::None, false, false, DisableMergeAttribute::None}; - SCOPE_EXIT({ + SCOPE_EXIT { R_ASSERT(this->Operate(updater.GetPageList(), io_addr, map_size / PageSize, 0, false, unmap_properties, OperationType::Unmap, true)); - }); + }; // Write the memory. const KProcessAddress write_addr = io_addr + (GetInteger(phys_addr) & (PageSize - 1)); @@ -4491,14 +4499,14 @@ Result KPageTableBase::SetupForIpcServer(KProcessAddress* out_addr, size_t size, // If the partial pages are mapped, an extra reference will have been opened. Otherwise, they'll // free on scope exit. - SCOPE_EXIT({ + SCOPE_EXIT { if (start_partial_page != 0) { m_kernel.MemoryManager().Close(start_partial_page, 1); } if (end_partial_page != 0) { m_kernel.MemoryManager().Close(end_partial_page, 1); } - }); + }; ON_RESULT_FAILURE { if (cur_mapped_addr != dst_addr) { @@ -5166,10 +5174,10 @@ Result KPageTableBase::MapPhysicalMemory(KProcessAddress address, size_t size) { GetCurrentProcess(m_kernel).GetId(), m_heap_fill_value)); // If we fail in the next bit (or retry), we need to cleanup the pages. - auto pg_guard = SCOPE_GUARD({ + auto pg_guard = SCOPE_GUARD { pg.OpenFirst(); pg.Close(); - }); + }; // Map the memory. { @@ -5694,7 +5702,9 @@ Result KPageTableBase::Operate(PageLinkedList* page_list, KProcessAddress virt_a // Ensure that any pages we track are closed on exit. KPageGroup pages_to_close(m_kernel, this->GetBlockInfoManager()); - SCOPE_EXIT({ pages_to_close.CloseAndReset(); }); + SCOPE_EXIT { + pages_to_close.CloseAndReset(); + }; // Make a page group representing the region to unmap. this->MakePageGroup(pages_to_close, virt_addr, num_pages); diff --git a/src/core/hle/kernel/k_process.cpp b/src/core/hle/kernel/k_process.cpp index 1bcc42890..cb9a11a63 100644 --- a/src/core/hle/kernel/k_process.cpp +++ b/src/core/hle/kernel/k_process.cpp @@ -77,7 +77,9 @@ Result TerminateChildren(KernelCore& kernel, KProcess* process, } // Terminate and close the thread. - SCOPE_EXIT({ cur_child->Close(); }); + SCOPE_EXIT { + cur_child->Close(); + }; if (const Result terminate_result = cur_child->Terminate(); ResultTerminationRequested == terminate_result) { @@ -466,11 +468,11 @@ void KProcess::DoWorkerTaskImpl() { Result KProcess::StartTermination() { // Finalize the handle table when we're done, if the process isn't immortal. - SCOPE_EXIT({ + SCOPE_EXIT { if (!m_is_immortal) { this->FinalizeHandleTable(); } - }); + }; // Terminate child threads other than the current one. R_RETURN(TerminateChildren(m_kernel, this, GetCurrentThreadPointer(m_kernel))); @@ -964,7 +966,9 @@ Result KProcess::Run(s32 priority, size_t stack_size) { // Create a new thread for the process. KThread* main_thread = KThread::Create(m_kernel); R_UNLESS(main_thread != nullptr, ResultOutOfResource); - SCOPE_EXIT({ main_thread->Close(); }); + SCOPE_EXIT { + main_thread->Close(); + }; // Initialize the thread. R_TRY(KThread::InitializeUserThread(m_kernel.System(), main_thread, this->GetEntryPoint(), 0, @@ -1155,7 +1159,9 @@ Result KProcess::LoadFromMetadata(const FileSys::ProgramMetadata& metadata, std: Kernel::CreateResourceLimitForProcess(m_kernel.System(), physical_memory_size); // Ensure we maintain a clean state on exit. - SCOPE_EXIT({ res_limit->Close(); }); + SCOPE_EXIT { + res_limit->Close(); + }; // Declare flags and code address. Svc::CreateProcessFlag flag{}; diff --git a/src/core/hle/kernel/k_server_session.cpp b/src/core/hle/kernel/k_server_session.cpp index adaabdd6d..40c3323ef 100644 --- a/src/core/hle/kernel/k_server_session.cpp +++ b/src/core/hle/kernel/k_server_session.cpp @@ -651,11 +651,11 @@ Result ReceiveMessage(KernelCore& kernel, bool& recv_list_broken, uint64_t dst_m // Process any special data. if (src_header.GetHasSpecialHeader()) { // After we process, make sure we track whether the receive list is broken. - SCOPE_EXIT({ + SCOPE_EXIT { if (offset > dst_recv_list_idx) { recv_list_broken = true; } - }); + }; // Process special data. R_TRY(ProcessMessageSpecialData(offset, dst_process, src_process, src_thread, @@ -665,11 +665,11 @@ Result ReceiveMessage(KernelCore& kernel, bool& recv_list_broken, uint64_t dst_m // Process any pointer buffers. for (auto i = 0; i < src_header.GetPointerCount(); ++i) { // After we process, make sure we track whether the receive list is broken. - SCOPE_EXIT({ + SCOPE_EXIT { if (offset > dst_recv_list_idx) { recv_list_broken = true; } - }); + }; R_TRY(ProcessReceiveMessagePointerDescriptors( offset, pointer_key, dst_page_table, src_page_table, dst_msg, src_msg, dst_recv_list, @@ -680,11 +680,11 @@ Result ReceiveMessage(KernelCore& kernel, bool& recv_list_broken, uint64_t dst_m // Process any map alias buffers. for (auto i = 0; i < src_header.GetMapAliasCount(); ++i) { // After we process, make sure we track whether the receive list is broken. - SCOPE_EXIT({ + SCOPE_EXIT { if (offset > dst_recv_list_idx) { recv_list_broken = true; } - }); + }; // We process in order send, recv, exch. Buffers after send (recv/exch) are ReadWrite. const KMemoryPermission perm = (i >= src_header.GetSendCount()) @@ -702,11 +702,11 @@ Result ReceiveMessage(KernelCore& kernel, bool& recv_list_broken, uint64_t dst_m // Process any raw data. if (const auto raw_count = src_header.GetRawCount(); raw_count != 0) { // After we process, make sure we track whether the receive list is broken. - SCOPE_EXIT({ + SCOPE_EXIT { if (offset + raw_count > dst_recv_list_idx) { recv_list_broken = true; } - }); + }; // Get the offset and size. const size_t offset_words = offset * sizeof(u32); @@ -1124,7 +1124,9 @@ Result KServerSession::ReceiveRequest(uintptr_t server_message, uintptr_t server client_thread->Open(); } - SCOPE_EXIT({ client_thread->Close(); }); + SCOPE_EXIT { + client_thread->Close(); + }; // Set the request as our current. m_current_request = request; @@ -1174,7 +1176,9 @@ Result KServerSession::ReceiveRequest(uintptr_t server_message, uintptr_t server // Reply to the client. { // After we reply, close our reference to the request. - SCOPE_EXIT({ request->Close(); }); + SCOPE_EXIT { + request->Close(); + }; // Get the event to check whether the request is async. if (KEvent* event = request->GetEvent(); event != nullptr) { @@ -1236,7 +1240,9 @@ Result KServerSession::SendReply(uintptr_t server_message, uintptr_t server_buff } // Close reference to the request once we're done processing it. - SCOPE_EXIT({ request->Close(); }); + SCOPE_EXIT { + request->Close(); + }; // Extract relevant information from the request. const uint64_t client_message = request->GetAddress(); @@ -1394,7 +1400,9 @@ void KServerSession::CleanupRequests() { } // Close a reference to the request once it's cleaned up. - SCOPE_EXIT({ request->Close(); }); + SCOPE_EXIT { + request->Close(); + }; // Extract relevant information from the request. const uint64_t client_message = request->GetAddress(); @@ -1491,7 +1499,9 @@ void KServerSession::OnClientClosed() { ASSERT(thread != nullptr); // Ensure that we close the request when done. - SCOPE_EXIT({ request->Close(); }); + SCOPE_EXIT { + request->Close(); + }; // If we're terminating, close a reference to the thread and event. if (terminate) { diff --git a/src/core/hle/kernel/k_thread_local_page.cpp b/src/core/hle/kernel/k_thread_local_page.cpp index a632d1634..1952c0083 100644 --- a/src/core/hle/kernel/k_thread_local_page.cpp +++ b/src/core/hle/kernel/k_thread_local_page.cpp @@ -21,7 +21,9 @@ Result KThreadLocalPage::Initialize(KernelCore& kernel, KProcess* process) { // Allocate a new page. KPageBuffer* page_buf = KPageBuffer::Allocate(kernel); R_UNLESS(page_buf != nullptr, ResultOutOfMemory); - auto page_buf_guard = SCOPE_GUARD({ KPageBuffer::Free(kernel, page_buf); }); + auto page_buf_guard = SCOPE_GUARD { + KPageBuffer::Free(kernel, page_buf); + }; // Map the address in. const auto phys_addr = kernel.System().DeviceMemory().GetPhysicalAddr(page_buf); diff --git a/src/core/hle/kernel/k_transfer_memory.cpp b/src/core/hle/kernel/k_transfer_memory.cpp index cbb1b02bb..09295e8ad 100644 --- a/src/core/hle/kernel/k_transfer_memory.cpp +++ b/src/core/hle/kernel/k_transfer_memory.cpp @@ -24,7 +24,9 @@ Result KTransferMemory::Initialize(KProcessAddress addr, std::size_t size, // Construct the page group, guarding to make sure our state is valid on exit. m_page_group.emplace(m_kernel, page_table.GetBlockInfoManager()); - auto pg_guard = SCOPE_GUARD({ m_page_group.reset(); }); + auto pg_guard = SCOPE_GUARD { + m_page_group.reset(); + }; // Lock the memory. R_TRY(page_table.LockForTransferMemory(std::addressof(*m_page_group), addr, size, diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 4f4b02fac..9e5eaeec4 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -109,7 +109,9 @@ struct KernelCore::Impl { void Shutdown() { is_shutting_down.store(true, std::memory_order_relaxed); - SCOPE_EXIT({ is_shutting_down.store(false, std::memory_order_relaxed); }); + SCOPE_EXIT { + is_shutting_down.store(false, std::memory_order_relaxed); + }; CloseServices(); @@ -1080,7 +1082,9 @@ std::jthread KernelCore::RunOnHostCoreProcess(std::string&& process_name, process->Initialize(Svc::CreateProcessParameter{}, GetSystemResourceLimit(), false))); // Ensure that we don't hold onto any extra references. - SCOPE_EXIT({ process->Close(); }); + SCOPE_EXIT { + process->Close(); + }; // Register the new process. KProcess::Register(*this, process); @@ -1108,7 +1112,9 @@ void KernelCore::RunOnGuestCoreProcess(std::string&& process_name, std::function process->Initialize(Svc::CreateProcessParameter{}, GetSystemResourceLimit(), false))); // Ensure that we don't hold onto any extra references. - SCOPE_EXIT({ process->Close(); }); + SCOPE_EXIT { + process->Close(); + }; // Register the new process. KProcess::Register(*this, process); diff --git a/src/core/hle/kernel/svc/svc_code_memory.cpp b/src/core/hle/kernel/svc/svc_code_memory.cpp index bae4cb0cd..7be2802f0 100644 --- a/src/core/hle/kernel/svc/svc_code_memory.cpp +++ b/src/core/hle/kernel/svc/svc_code_memory.cpp @@ -45,7 +45,9 @@ Result CreateCodeMemory(Core::System& system, Handle* out, u64 address, uint64_t KCodeMemory* code_mem = KCodeMemory::Create(kernel); R_UNLESS(code_mem != nullptr, ResultOutOfResource); - SCOPE_EXIT({ code_mem->Close(); }); + SCOPE_EXIT { + code_mem->Close(); + }; // Verify that the region is in range. R_UNLESS(GetCurrentProcess(system.Kernel()).GetPageTable().Contains(address, size), diff --git a/src/core/hle/kernel/svc/svc_device_address_space.cpp b/src/core/hle/kernel/svc/svc_device_address_space.cpp index 42add9473..ac828320f 100644 --- a/src/core/hle/kernel/svc/svc_device_address_space.cpp +++ b/src/core/hle/kernel/svc/svc_device_address_space.cpp @@ -28,7 +28,9 @@ Result CreateDeviceAddressSpace(Core::System& system, Handle* out, uint64_t das_ // Create the device address space. KDeviceAddressSpace* das = KDeviceAddressSpace::Create(system.Kernel()); R_UNLESS(das != nullptr, ResultOutOfResource); - SCOPE_EXIT({ das->Close(); }); + SCOPE_EXIT { + das->Close(); + }; // Initialize the device address space. R_TRY(das->Initialize(das_address, das_size)); diff --git a/src/core/hle/kernel/svc/svc_event.cpp b/src/core/hle/kernel/svc/svc_event.cpp index 901202e6a..8e4beb396 100644 --- a/src/core/hle/kernel/svc/svc_event.cpp +++ b/src/core/hle/kernel/svc/svc_event.cpp @@ -72,10 +72,10 @@ Result CreateEvent(Core::System& system, Handle* out_write, Handle* out_read) { event_reservation.Commit(); // Ensure that we clean up the event (and its only references are handle table) on function end. - SCOPE_EXIT({ + SCOPE_EXIT { event->GetReadableEvent().Close(); event->Close(); - }); + }; // Register the event. KEvent::Register(kernel, event); diff --git a/src/core/hle/kernel/svc/svc_ipc.cpp b/src/core/hle/kernel/svc/svc_ipc.cpp index 85cc4f561..b619bd70a 100644 --- a/src/core/hle/kernel/svc/svc_ipc.cpp +++ b/src/core/hle/kernel/svc/svc_ipc.cpp @@ -129,11 +129,11 @@ Result ReplyAndReceiveImpl(KernelCore& kernel, int32_t* out_index, uintptr_t mes } // Ensure handles are closed when we're done. - SCOPE_EXIT({ + SCOPE_EXIT { for (auto i = 0; i < num_handles; ++i) { objs[i]->Close(); } - }); + }; R_RETURN(ReplyAndReceiveImpl(kernel, out_index, message, buffer_size, message_paddr, objs, num_handles, reply_target, timeout_ns)); @@ -208,10 +208,10 @@ Result SendAsyncRequestWithUserBuffer(Core::System& system, Handle* out_event_ha event_reservation.Commit(); // At end of scope, kill the standing references to the sub events. - SCOPE_EXIT({ + SCOPE_EXIT { event->GetReadableEvent().Close(); event->Close(); - }); + }; // Register the event. KEvent::Register(system.Kernel(), event); diff --git a/src/core/hle/kernel/svc/svc_port.cpp b/src/core/hle/kernel/svc/svc_port.cpp index 737749f7d..9a22dadaf 100644 --- a/src/core/hle/kernel/svc/svc_port.cpp +++ b/src/core/hle/kernel/svc/svc_port.cpp @@ -68,10 +68,10 @@ Result CreatePort(Core::System& system, Handle* out_server, Handle* out_client, port->Initialize(max_sessions, is_light, name); // Ensure that we clean up the port (and its only references are handle table) on function end. - SCOPE_EXIT({ + SCOPE_EXIT { port->GetServerPort().Close(); port->GetClientPort().Close(); - }); + }; // Register the port. KPort::Register(kernel, port); @@ -150,10 +150,10 @@ Result ManageNamedPort(Core::System& system, Handle* out_server_handle, uint64_t KPort::Register(system.Kernel(), port); // Ensure that our only reference to the port is in the handle table when we're done. - SCOPE_EXIT({ + SCOPE_EXIT { port->GetClientPort().Close(); port->GetServerPort().Close(); - }); + }; // Register the handle in the table. R_TRY(handle_table.Add(out_server_handle, std::addressof(port->GetServerPort()))); diff --git a/src/core/hle/kernel/svc/svc_resource_limit.cpp b/src/core/hle/kernel/svc/svc_resource_limit.cpp index c8e820b6a..6f3972482 100644 --- a/src/core/hle/kernel/svc/svc_resource_limit.cpp +++ b/src/core/hle/kernel/svc/svc_resource_limit.cpp @@ -18,7 +18,9 @@ Result CreateResourceLimit(Core::System& system, Handle* out_handle) { R_UNLESS(resource_limit != nullptr, ResultOutOfResource); // Ensure we don't leak a reference to the limit. - SCOPE_EXIT({ resource_limit->Close(); }); + SCOPE_EXIT { + resource_limit->Close(); + }; // Initialize the resource limit. resource_limit->Initialize(); diff --git a/src/core/hle/kernel/svc/svc_session.cpp b/src/core/hle/kernel/svc/svc_session.cpp index 2f5905f32..b034d21d1 100644 --- a/src/core/hle/kernel/svc/svc_session.cpp +++ b/src/core/hle/kernel/svc/svc_session.cpp @@ -69,10 +69,10 @@ Result CreateSession(Core::System& system, Handle* out_server, Handle* out_clien // Ensure that we clean up the session (and its only references are handle table) on function // end. - SCOPE_EXIT({ + SCOPE_EXIT { session->GetClientSession().Close(); session->GetServerSession().Close(); - }); + }; // Register the session. T::Register(system.Kernel(), session); diff --git a/src/core/hle/kernel/svc/svc_synchronization.cpp b/src/core/hle/kernel/svc/svc_synchronization.cpp index 6c79cfd8d..fb03908d7 100644 --- a/src/core/hle/kernel/svc/svc_synchronization.cpp +++ b/src/core/hle/kernel/svc/svc_synchronization.cpp @@ -78,11 +78,11 @@ Result WaitSynchronization(Core::System& system, int32_t* out_index, u64 user_ha } // Ensure handles are closed when we're done. - SCOPE_EXIT({ + SCOPE_EXIT { for (auto i = 0; i < num_handles; ++i) { objs[i]->Close(); } - }); + }; // Convert the timeout from nanoseconds to ticks. s64 timeout; diff --git a/src/core/hle/kernel/svc/svc_thread.cpp b/src/core/hle/kernel/svc/svc_thread.cpp index 7681afa33..7517bb9d3 100644 --- a/src/core/hle/kernel/svc/svc_thread.cpp +++ b/src/core/hle/kernel/svc/svc_thread.cpp @@ -51,7 +51,9 @@ Result CreateThread(Core::System& system, Handle* out_handle, u64 entry_point, u // Create the thread. KThread* thread = KThread::Create(kernel); R_UNLESS(thread != nullptr, ResultOutOfResource) - SCOPE_EXIT({ thread->Close(); }); + SCOPE_EXIT { + thread->Close(); + }; // Initialize the thread. { diff --git a/src/core/hle/kernel/svc/svc_transfer_memory.cpp b/src/core/hle/kernel/svc/svc_transfer_memory.cpp index 671bca23f..2ea0d4421 100644 --- a/src/core/hle/kernel/svc/svc_transfer_memory.cpp +++ b/src/core/hle/kernel/svc/svc_transfer_memory.cpp @@ -52,7 +52,9 @@ Result CreateTransferMemory(Core::System& system, Handle* out, u64 address, u64 R_UNLESS(trmem != nullptr, ResultOutOfResource); // Ensure the only reference is in the handle table when we're done. - SCOPE_EXIT({ trmem->Close(); }); + SCOPE_EXIT { + trmem->Close(); + }; // Ensure that the region is in range. R_UNLESS(process.GetPageTable().Contains(address, size), ResultInvalidCurrentMemory); diff --git a/src/core/hle/service/am/applet_data_broker.cpp b/src/core/hle/service/am/applet_data_broker.cpp index 4d58c4db5..9057244a9 100644 --- a/src/core/hle/service/am/applet_data_broker.cpp +++ b/src/core/hle/service/am/applet_data_broker.cpp @@ -24,11 +24,11 @@ void AppletStorageChannel::Push(std::shared_ptr storage) { Result AppletStorageChannel::Pop(std::shared_ptr* out_storage) { std::scoped_lock lk{m_lock}; - SCOPE_EXIT({ + SCOPE_EXIT { if (m_data.empty()) { m_event.Clear(); } - }); + }; R_UNLESS(!m_data.empty(), AM::ResultNoDataInChannel); diff --git a/src/core/hle/service/am/process.cpp b/src/core/hle/service/am/process.cpp index 992c50713..388d2045c 100644 --- a/src/core/hle/service/am/process.cpp +++ b/src/core/hle/service/am/process.cpp @@ -68,7 +68,9 @@ bool Process::Initialize(u64 program_id, u8 minimum_key_generation, u8 maximum_k Kernel::KProcess::Register(m_system.Kernel(), process); // On exit, ensure we free the additional reference to the process. - SCOPE_EXIT({ process->Close(); }); + SCOPE_EXIT { + process->Close(); + }; // Insert process modules into memory. const auto [load_result, load_parameters] = app_loader->Load(*process, m_system); diff --git a/src/core/hle/service/glue/time/static.cpp b/src/core/hle/service/glue/time/static.cpp index ec9b0efb1..b801faef2 100644 --- a/src/core/hle/service/glue/time/static.cpp +++ b/src/core/hle/service/glue/time/static.cpp @@ -142,16 +142,18 @@ Result StaticService::SetStandardSteadyClockInternalOffset(s64 offset_ns) { } Result StaticService::GetStandardSteadyClockRtcValue(Out out_rtc_value) { - SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_rtc_value={}", *out_rtc_value); }); + SCOPE_EXIT { + LOG_DEBUG(Service_Time, "called. out_rtc_value={}", *out_rtc_value); + }; R_RETURN(m_standard_steady_clock_resource.GetRtcTimeInSeconds(*out_rtc_value)); } Result StaticService::IsStandardUserSystemClockAutomaticCorrectionEnabled( Out out_automatic_correction) { - SCOPE_EXIT({ + SCOPE_EXIT { LOG_DEBUG(Service_Time, "called. out_automatic_correction={}", *out_automatic_correction); - }); + }; R_RETURN(m_wrapped_service->IsStandardUserSystemClockAutomaticCorrectionEnabled( out_automatic_correction)); @@ -166,21 +168,27 @@ Result StaticService::SetStandardUserSystemClockAutomaticCorrectionEnabled( } Result StaticService::GetStandardUserSystemClockInitialYear(Out out_year) { - SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_year={}", *out_year); }); + SCOPE_EXIT { + LOG_DEBUG(Service_Time, "called. out_year={}", *out_year); + }; R_RETURN(m_set_sys->GetSettingsItemValueImpl(*out_year, "time", "standard_user_clock_initial_year")); } Result StaticService::IsStandardNetworkSystemClockAccuracySufficient(Out out_is_sufficient) { - SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_is_sufficient={}", *out_is_sufficient); }); + SCOPE_EXIT { + LOG_DEBUG(Service_Time, "called. out_is_sufficient={}", *out_is_sufficient); + }; R_RETURN(m_wrapped_service->IsStandardNetworkSystemClockAccuracySufficient(out_is_sufficient)); } Result StaticService::GetStandardUserSystemClockAutomaticCorrectionUpdatedTime( Out out_time_point) { - SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_time_point={}", *out_time_point); }); + SCOPE_EXIT { + LOG_DEBUG(Service_Time, "called. out_time_point={}", *out_time_point); + }; R_RETURN(m_wrapped_service->GetStandardUserSystemClockAutomaticCorrectionUpdatedTime( out_time_point)); @@ -188,15 +196,18 @@ Result StaticService::GetStandardUserSystemClockAutomaticCorrectionUpdatedTime( Result StaticService::CalculateMonotonicSystemClockBaseTimePoint( Out out_time, const Service::PSC::Time::SystemClockContext& context) { - SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. context={} out_time={}", context, *out_time); }); + SCOPE_EXIT { + LOG_DEBUG(Service_Time, "called. context={} out_time={}", context, *out_time); + }; R_RETURN(m_wrapped_service->CalculateMonotonicSystemClockBaseTimePoint(out_time, context)); } Result StaticService::GetClockSnapshot(OutClockSnapshot out_snapshot, Service::PSC::Time::TimeType type) { - SCOPE_EXIT( - { LOG_DEBUG(Service_Time, "called. type={} out_snapshot={}", type, *out_snapshot); }); + SCOPE_EXIT { + LOG_DEBUG(Service_Time, "called. type={} out_snapshot={}", type, *out_snapshot); + }; R_RETURN(m_wrapped_service->GetClockSnapshot(out_snapshot, type)); } @@ -205,11 +216,11 @@ Result StaticService::GetClockSnapshotFromSystemClockContext( Service::PSC::Time::TimeType type, OutClockSnapshot out_snapshot, const Service::PSC::Time::SystemClockContext& user_context, const Service::PSC::Time::SystemClockContext& network_context) { - SCOPE_EXIT({ + SCOPE_EXIT { LOG_DEBUG(Service_Time, "called. type={} out_snapshot={} user_context={} network_context={}", type, *out_snapshot, user_context, network_context); - }); + }; R_RETURN(m_wrapped_service->GetClockSnapshotFromSystemClockContext( type, out_snapshot, user_context, network_context)); @@ -218,14 +229,18 @@ Result StaticService::GetClockSnapshotFromSystemClockContext( Result StaticService::CalculateStandardUserSystemClockDifferenceByUser(Out out_time, InClockSnapshot a, InClockSnapshot b) { - SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. a={} b={} out_time={}", *a, *b, *out_time); }); + SCOPE_EXIT { + LOG_DEBUG(Service_Time, "called. a={} b={} out_time={}", *a, *b, *out_time); + }; R_RETURN(m_wrapped_service->CalculateStandardUserSystemClockDifferenceByUser(out_time, a, b)); } Result StaticService::CalculateSpanBetween(Out out_time, InClockSnapshot a, InClockSnapshot b) { - SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. a={} b={} out_time={}", *a, *b, *out_time); }); + SCOPE_EXIT { + LOG_DEBUG(Service_Time, "called. a={} b={} out_time={}", *a, *b, *out_time); + }; R_RETURN(m_wrapped_service->CalculateSpanBetween(out_time, a, b)); } diff --git a/src/core/hle/service/glue/time/time_zone.cpp b/src/core/hle/service/glue/time/time_zone.cpp index 36f163419..f4d0c87d5 100644 --- a/src/core/hle/service/glue/time/time_zone.cpp +++ b/src/core/hle/service/glue/time/time_zone.cpp @@ -57,7 +57,9 @@ TimeZoneService::~TimeZoneService() = default; Result TimeZoneService::GetDeviceLocationName( Out out_location_name) { - SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_location_name={}", *out_location_name); }); + SCOPE_EXIT { + LOG_DEBUG(Service_Time, "called. out_location_name={}", *out_location_name); + }; R_RETURN(m_wrapped_service->GetDeviceLocationName(out_location_name)); } @@ -94,7 +96,9 @@ Result TimeZoneService::SetDeviceLocationName( } Result TimeZoneService::GetTotalLocationNameCount(Out out_count) { - SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_count={}", *out_count); }); + SCOPE_EXIT { + LOG_DEBUG(Service_Time, "called. out_count={}", *out_count); + }; R_RETURN(m_wrapped_service->GetTotalLocationNameCount(out_count)); } @@ -102,10 +106,10 @@ Result TimeZoneService::GetTotalLocationNameCount(Out out_count) { Result TimeZoneService::LoadLocationNameList( Out out_count, OutArray out_names, u32 index) { - SCOPE_EXIT({ + SCOPE_EXIT { LOG_DEBUG(Service_Time, "called. index={} out_count={} out_names[0]={} out_names[1]={}", index, *out_count, out_names[0], out_names[1]); - }); + }; std::scoped_lock l{m_mutex}; R_RETURN(GetTimeZoneLocationList(*out_count, out_names, out_names.size(), index)); @@ -124,7 +128,9 @@ Result TimeZoneService::LoadTimeZoneRule(OutRule out_rule, Result TimeZoneService::GetTimeZoneRuleVersion( Out out_rule_version) { - SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_rule_version={}", *out_rule_version); }); + SCOPE_EXIT { + LOG_DEBUG(Service_Time, "called. out_rule_version={}", *out_rule_version); + }; R_RETURN(m_wrapped_service->GetTimeZoneRuleVersion(out_rule_version)); } @@ -132,10 +138,10 @@ Result TimeZoneService::GetTimeZoneRuleVersion( Result TimeZoneService::GetDeviceLocationNameAndUpdatedTime( Out location_name, Out out_time_point) { - SCOPE_EXIT({ + SCOPE_EXIT { LOG_DEBUG(Service_Time, "called. location_name={} out_time_point={}", *location_name, *out_time_point); - }); + }; R_RETURN(m_wrapped_service->GetDeviceLocationNameAndUpdatedTime(location_name, out_time_point)); } @@ -178,10 +184,10 @@ Result TimeZoneService::GetDeviceLocationNameOperationEventReadableHandle( Result TimeZoneService::ToCalendarTime( Out out_calendar_time, Out out_additional_info, s64 time, InRule rule) { - SCOPE_EXIT({ + SCOPE_EXIT { LOG_DEBUG(Service_Time, "called. time={} out_calendar_time={} out_additional_info={}", time, *out_calendar_time, *out_additional_info); - }); + }; R_RETURN(m_wrapped_service->ToCalendarTime(out_calendar_time, out_additional_info, time, rule)); } @@ -189,10 +195,10 @@ Result TimeZoneService::ToCalendarTime( Result TimeZoneService::ToCalendarTimeWithMyRule( Out out_calendar_time, Out out_additional_info, s64 time) { - SCOPE_EXIT({ + SCOPE_EXIT { LOG_DEBUG(Service_Time, "called. time={} out_calendar_time={} out_additional_info={}", time, *out_calendar_time, *out_additional_info); - }); + }; R_RETURN( m_wrapped_service->ToCalendarTimeWithMyRule(out_calendar_time, out_additional_info, time)); @@ -202,11 +208,11 @@ Result TimeZoneService::ToPosixTime(Out out_count, OutArray out_times, const Service::PSC::Time::CalendarTime& calendar_time, InRule rule) { - SCOPE_EXIT({ + SCOPE_EXIT { LOG_DEBUG(Service_Time, "called. calendar_time={} out_count={} out_times[0]={} out_times[1]={}", calendar_time, *out_count, out_times[0], out_times[1]); - }); + }; R_RETURN(m_wrapped_service->ToPosixTime(out_count, out_times, calendar_time, rule)); } @@ -214,11 +220,11 @@ Result TimeZoneService::ToPosixTime(Out out_count, Result TimeZoneService::ToPosixTimeWithMyRule( Out out_count, OutArray out_times, const Service::PSC::Time::CalendarTime& calendar_time) { - SCOPE_EXIT({ + SCOPE_EXIT { LOG_DEBUG(Service_Time, "called. calendar_time={} out_count={} out_times[0]={} out_times[1]={}", calendar_time, *out_count, out_times[0], out_times[1]); - }); + }; R_RETURN(m_wrapped_service->ToPosixTimeWithMyRule(out_count, out_times, calendar_time)); } diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp index 250d01de3..0265d55f2 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp @@ -92,11 +92,11 @@ NvResult nvhost_ctrl::IocCtrlEventWait(IocCtrlEventWaitParams& params, bool is_a bool must_unmark_fail = !is_allocation; const u32 event_id = params.value.raw; - SCOPE_EXIT({ + SCOPE_EXIT { if (must_unmark_fail) { events[event_id].fails = 0; } - }); + }; const u32 fence_id = static_cast(params.fence.id); diff --git a/src/core/hle/service/nvdrv/nvdrv_interface.cpp b/src/core/hle/service/nvdrv/nvdrv_interface.cpp index 241006cc8..258970fd5 100644 --- a/src/core/hle/service/nvdrv/nvdrv_interface.cpp +++ b/src/core/hle/service/nvdrv/nvdrv_interface.cpp @@ -154,10 +154,10 @@ void NVDRV::Close(HLERequestContext& ctx) { void NVDRV::Initialize(HLERequestContext& ctx) { LOG_WARNING(Service_NVDRV, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 3}; - SCOPE_EXIT({ + SCOPE_EXIT { rb.Push(ResultSuccess); rb.PushEnum(NvResult::Success); - }); + }; if (is_initialized) { // No need to initialize again diff --git a/src/core/hle/service/psc/time/static.cpp b/src/core/hle/service/psc/time/static.cpp index 24b85cc61..9a0adb295 100644 --- a/src/core/hle/service/psc/time/static.cpp +++ b/src/core/hle/service/psc/time/static.cpp @@ -144,7 +144,9 @@ Result StaticService::GetStandardSteadyClockRtcValue(Out out_rtc_value) { Result StaticService::IsStandardUserSystemClockAutomaticCorrectionEnabled( Out out_is_enabled) { - SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_is_enabled={}", *out_is_enabled); }); + SCOPE_EXIT { + LOG_DEBUG(Service_Time, "called. out_is_enabled={}", *out_is_enabled); + }; R_UNLESS(m_user_system_clock.IsInitialized(), ResultClockUninitialized); @@ -180,7 +182,9 @@ Result StaticService::GetStandardUserSystemClockInitialYear(Out out_year) { } Result StaticService::IsStandardNetworkSystemClockAccuracySufficient(Out out_is_sufficient) { - SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_is_sufficient={}", *out_is_sufficient); }); + SCOPE_EXIT { + LOG_DEBUG(Service_Time, "called. out_is_sufficient={}", *out_is_sufficient); + }; *out_is_sufficient = m_network_system_clock.IsAccuracySufficient(); @@ -189,7 +193,9 @@ Result StaticService::IsStandardNetworkSystemClockAccuracySufficient(Out o Result StaticService::GetStandardUserSystemClockAutomaticCorrectionUpdatedTime( Out out_time_point) { - SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_time_point={}", *out_time_point); }); + SCOPE_EXIT { + LOG_DEBUG(Service_Time, "called. out_time_point={}", *out_time_point); + }; R_UNLESS(m_user_system_clock.IsInitialized(), ResultClockUninitialized); @@ -200,7 +206,9 @@ Result StaticService::GetStandardUserSystemClockAutomaticCorrectionUpdatedTime( Result StaticService::CalculateMonotonicSystemClockBaseTimePoint( Out out_time, const SystemClockContext& context) { - SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. context={} out_time={}", context, *out_time); }); + SCOPE_EXIT { + LOG_DEBUG(Service_Time, "called. context={} out_time={}", context, *out_time); + }; R_UNLESS(m_time->m_standard_steady_clock.IsInitialized(), ResultClockUninitialized); @@ -219,8 +227,9 @@ Result StaticService::CalculateMonotonicSystemClockBaseTimePoint( } Result StaticService::GetClockSnapshot(OutClockSnapshot out_snapshot, TimeType type) { - SCOPE_EXIT( - { LOG_DEBUG(Service_Time, "called. type={} out_snapshot={}", type, *out_snapshot); }); + SCOPE_EXIT { + LOG_DEBUG(Service_Time, "called. type={} out_snapshot={}", type, *out_snapshot); + }; SystemClockContext user_context{}; R_TRY(m_user_system_clock.GetContext(user_context)); @@ -234,11 +243,11 @@ Result StaticService::GetClockSnapshot(OutClockSnapshot out_snapshot, TimeType t Result StaticService::GetClockSnapshotFromSystemClockContext( TimeType type, OutClockSnapshot out_snapshot, const SystemClockContext& user_context, const SystemClockContext& network_context) { - SCOPE_EXIT({ + SCOPE_EXIT { LOG_DEBUG(Service_Time, "called. type={} user_context={} network_context={} out_snapshot={}", type, user_context, network_context, *out_snapshot); - }); + }; R_RETURN(GetClockSnapshotImpl(out_snapshot, user_context, network_context, type)); } @@ -246,9 +255,9 @@ Result StaticService::GetClockSnapshotFromSystemClockContext( Result StaticService::CalculateStandardUserSystemClockDifferenceByUser(Out out_difference, InClockSnapshot a, InClockSnapshot b) { - SCOPE_EXIT({ + SCOPE_EXIT { LOG_DEBUG(Service_Time, "called. a={} b={} out_difference={}", *a, *b, *out_difference); - }); + }; auto diff_s = std::chrono::seconds(b->user_context.offset) - std::chrono::seconds(a->user_context.offset); @@ -276,7 +285,9 @@ Result StaticService::CalculateStandardUserSystemClockDifferenceByUser(Out Result StaticService::CalculateSpanBetween(Out out_time, InClockSnapshot a, InClockSnapshot b) { - SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. a={} b={} out_time={}", *a, *b, *out_time); }); + SCOPE_EXIT { + LOG_DEBUG(Service_Time, "called. a={} b={} out_time={}", *a, *b, *out_time); + }; s64 time_s{}; auto res = diff --git a/src/core/hle/service/psc/time/steady_clock.cpp b/src/core/hle/service/psc/time/steady_clock.cpp index 948610a2b..78dcf532c 100644 --- a/src/core/hle/service/psc/time/steady_clock.cpp +++ b/src/core/hle/service/psc/time/steady_clock.cpp @@ -29,7 +29,9 @@ SteadyClock::SteadyClock(Core::System& system_, std::shared_ptr man } Result SteadyClock::GetCurrentTimePoint(Out out_time_point) { - SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_time_point={}", *out_time_point); }); + SCOPE_EXIT { + LOG_DEBUG(Service_Time, "called. out_time_point={}", *out_time_point); + }; R_UNLESS(m_can_write_uninitialized_clock || m_clock_core.IsInitialized(), ResultClockUninitialized); @@ -38,7 +40,9 @@ Result SteadyClock::GetCurrentTimePoint(Out out_time_point } Result SteadyClock::GetTestOffset(Out out_test_offset) { - SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_test_offset={}", *out_test_offset); }); + SCOPE_EXIT { + LOG_DEBUG(Service_Time, "called. out_test_offset={}", *out_test_offset); + }; R_UNLESS(m_can_write_uninitialized_clock || m_clock_core.IsInitialized(), ResultClockUninitialized); @@ -59,7 +63,9 @@ Result SteadyClock::SetTestOffset(s64 test_offset) { } Result SteadyClock::GetRtcValue(Out out_rtc_value) { - SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_rtc_value={}", *out_rtc_value); }); + SCOPE_EXIT { + LOG_DEBUG(Service_Time, "called. out_rtc_value={}", *out_rtc_value); + }; R_UNLESS(m_can_write_uninitialized_clock || m_clock_core.IsInitialized(), ResultClockUninitialized); @@ -68,7 +74,9 @@ Result SteadyClock::GetRtcValue(Out out_rtc_value) { } Result SteadyClock::IsRtcResetDetected(Out out_is_detected) { - SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_is_detected={}", *out_is_detected); }); + SCOPE_EXIT { + LOG_DEBUG(Service_Time, "called. out_is_detected={}", *out_is_detected); + }; R_UNLESS(m_can_write_uninitialized_clock || m_clock_core.IsInitialized(), ResultClockUninitialized); @@ -78,7 +86,9 @@ Result SteadyClock::IsRtcResetDetected(Out out_is_detected) { } Result SteadyClock::GetSetupResultValue(Out out_result) { - SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_result=0x{:X}", out_result->raw); }); + SCOPE_EXIT { + LOG_DEBUG(Service_Time, "called. out_result=0x{:X}", out_result->raw); + }; R_UNLESS(m_can_write_uninitialized_clock || m_clock_core.IsInitialized(), ResultClockUninitialized); @@ -88,8 +98,9 @@ Result SteadyClock::GetSetupResultValue(Out out_result) { } Result SteadyClock::GetInternalOffset(Out out_internal_offset) { - SCOPE_EXIT( - { LOG_DEBUG(Service_Time, "called. out_internal_offset={}", *out_internal_offset); }); + SCOPE_EXIT { + LOG_DEBUG(Service_Time, "called. out_internal_offset={}", *out_internal_offset); + }; R_UNLESS(m_can_write_uninitialized_clock || m_clock_core.IsInitialized(), ResultClockUninitialized); diff --git a/src/core/hle/service/psc/time/system_clock.cpp b/src/core/hle/service/psc/time/system_clock.cpp index b4e9264d8..9f841d8e0 100644 --- a/src/core/hle/service/psc/time/system_clock.cpp +++ b/src/core/hle/service/psc/time/system_clock.cpp @@ -26,7 +26,9 @@ SystemClock::SystemClock(Core::System& system_, SystemClockCore& clock_core, boo } Result SystemClock::GetCurrentTime(Out out_time) { - SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_time={}", *out_time); }); + SCOPE_EXIT { + LOG_DEBUG(Service_Time, "called. out_time={}", *out_time); + }; R_UNLESS(m_can_write_uninitialized_clock || m_clock_core.IsInitialized(), ResultClockUninitialized); @@ -45,7 +47,9 @@ Result SystemClock::SetCurrentTime(s64 time) { } Result SystemClock::GetSystemClockContext(Out out_context) { - SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_context={}", *out_context); }); + SCOPE_EXIT { + LOG_DEBUG(Service_Time, "called. out_context={}", *out_context); + }; R_UNLESS(m_can_write_uninitialized_clock || m_clock_core.IsInitialized(), ResultClockUninitialized); diff --git a/src/core/hle/service/psc/time/time_zone_service.cpp b/src/core/hle/service/psc/time/time_zone_service.cpp index 2f80030a4..9e0674f27 100644 --- a/src/core/hle/service/psc/time/time_zone_service.cpp +++ b/src/core/hle/service/psc/time/time_zone_service.cpp @@ -37,7 +37,9 @@ TimeZoneService::TimeZoneService(Core::System& system_, StandardSteadyClockCore& } Result TimeZoneService::GetDeviceLocationName(Out out_location_name) { - SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_location_name={}", *out_location_name); }); + SCOPE_EXIT { + LOG_DEBUG(Service_Time, "called. out_location_name={}", *out_location_name); + }; R_RETURN(m_time_zone.GetLocationName(*out_location_name)); } @@ -50,7 +52,9 @@ Result TimeZoneService::SetDeviceLocationName(const LocationName& location_name) } Result TimeZoneService::GetTotalLocationNameCount(Out out_count) { - SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_count={}", *out_count); }); + SCOPE_EXIT { + LOG_DEBUG(Service_Time, "called. out_count={}", *out_count); + }; R_RETURN(m_time_zone.GetTotalLocationCount(*out_count)); } @@ -69,17 +73,19 @@ Result TimeZoneService::LoadTimeZoneRule(OutRule out_rule, const LocationName& l } Result TimeZoneService::GetTimeZoneRuleVersion(Out out_rule_version) { - SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_rule_version={}", *out_rule_version); }); + SCOPE_EXIT { + LOG_DEBUG(Service_Time, "called. out_rule_version={}", *out_rule_version); + }; R_RETURN(m_time_zone.GetRuleVersion(*out_rule_version)); } Result TimeZoneService::GetDeviceLocationNameAndUpdatedTime( Out out_location_name, Out out_time_point) { - SCOPE_EXIT({ + SCOPE_EXIT { LOG_DEBUG(Service_Time, "called. out_location_name={} out_time_point={}", *out_location_name, *out_time_point); - }); + }; R_TRY(m_time_zone.GetLocationName(*out_location_name)); R_RETURN(m_time_zone.GetTimePoint(*out_time_point)); @@ -116,10 +122,10 @@ Result TimeZoneService::GetDeviceLocationNameOperationEventReadableHandle( Result TimeZoneService::ToCalendarTime(Out out_calendar_time, Out out_additional_info, s64 time, InRule rule) { - SCOPE_EXIT({ + SCOPE_EXIT { LOG_DEBUG(Service_Time, "called. time={} out_calendar_time={} out_additional_info={}", time, *out_calendar_time, *out_additional_info); - }); + }; R_RETURN( m_time_zone.ToCalendarTime(*out_calendar_time, *out_additional_info, time, *rule.Get())); @@ -128,10 +134,10 @@ Result TimeZoneService::ToCalendarTime(Out out_calendar_time, Result TimeZoneService::ToCalendarTimeWithMyRule(Out out_calendar_time, Out out_additional_info, s64 time) { - SCOPE_EXIT({ + SCOPE_EXIT { LOG_DEBUG(Service_Time, "called. time={} out_calendar_time={} out_additional_info={}", time, *out_calendar_time, *out_additional_info); - }); + }; R_RETURN(m_time_zone.ToCalendarTimeWithMyRule(*out_calendar_time, *out_additional_info, time)); } @@ -139,11 +145,11 @@ Result TimeZoneService::ToCalendarTimeWithMyRule(Out out_calendar_ Result TimeZoneService::ToPosixTime(Out out_count, OutArray out_times, const CalendarTime& calendar_time, InRule rule) { - SCOPE_EXIT({ + SCOPE_EXIT { LOG_DEBUG(Service_Time, "called. calendar_time={} out_count={} out_times[0]={} out_times[1]={} ", calendar_time, *out_count, out_times[0], out_times[1]); - }); + }; R_RETURN( m_time_zone.ToPosixTime(*out_count, out_times, out_times.size(), calendar_time, *rule)); @@ -152,11 +158,11 @@ Result TimeZoneService::ToPosixTime(Out out_count, Result TimeZoneService::ToPosixTimeWithMyRule(Out out_count, OutArray out_times, const CalendarTime& calendar_time) { - SCOPE_EXIT({ + SCOPE_EXIT { LOG_DEBUG(Service_Time, "called. calendar_time={} out_count={} out_times[0]={} out_times[1]={} ", calendar_time, *out_count, out_times[0], out_times[1]); - }); + }; R_RETURN( m_time_zone.ToPosixTimeWithMyRule(*out_count, out_times, out_times.size(), calendar_time)); diff --git a/src/core/hle/service/server_manager.cpp b/src/core/hle/service/server_manager.cpp index 8c7f94c8c..0b41bbcb9 100644 --- a/src/core/hle/service/server_manager.cpp +++ b/src/core/hle/service/server_manager.cpp @@ -177,10 +177,10 @@ Result ServerManager::ManageNamedPort(const std::string& service_name, Kernel::KPort::Register(m_system.Kernel(), port); // Ensure that our reference to the port is closed if we fail to register it. - SCOPE_EXIT({ + SCOPE_EXIT { port->GetClientPort().Close(); port->GetServerPort().Close(); - }); + }; // Register the object name with the kernel. R_TRY(Kernel::KObjectName::NewFromName(m_system.Kernel(), std::addressof(port->GetClientPort()), @@ -237,7 +237,9 @@ void ServerManager::StartAdditionalHostThreads(const char* name, size_t num_thre } Result ServerManager::LoopProcess() { - SCOPE_EXIT({ m_stopped.Set(); }); + SCOPE_EXIT { + m_stopped.Set(); + }; R_RETURN(this->LoopProcessImpl()); } diff --git a/src/core/loader/nca.cpp b/src/core/loader/nca.cpp index 2a32b1276..de27ec49e 100644 --- a/src/core/loader/nca.cpp +++ b/src/core/loader/nca.cpp @@ -118,7 +118,9 @@ ResultStatus AppLoader_NCA::VerifyIntegrity(std::function mbedtls_sha256_starts_ret(&ctx, 0); // Ensure we maintain a clean state on exit. - SCOPE_EXIT({ mbedtls_sha256_free(&ctx); }); + SCOPE_EXIT { + mbedtls_sha256_free(&ctx); + }; // Declare counters. const size_t total_size = file->GetSize(); diff --git a/src/core/memory.cpp b/src/core/memory.cpp index e10a4601e..8775369a4 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -831,11 +831,11 @@ struct Memory::Impl { if (core == sys_core) [[unlikely]] { sys_core_guard.lock(); } - SCOPE_EXIT({ + SCOPE_EXIT { if (core == sys_core) [[unlikely]] { sys_core_guard.unlock(); } - }); + }; gpu_device_memory->ApplyOpOnPointer(p, scratch_buffers[core], [&](DAddr address) { auto& current_area = rasterizer_write_areas[core]; PAddr subaddress = address >> YUZU_PAGEBITS; @@ -866,11 +866,11 @@ struct Memory::Impl { if (core == sys_core) [[unlikely]] { sys_core_guard.lock(); } - SCOPE_EXIT({ + SCOPE_EXIT { if (core == sys_core) [[unlikely]] { sys_core_guard.unlock(); } - }); + }; auto& gpu = system.GPU(); gpu_device_memory->ApplyOpOnPointer( p, scratch_buffers[core], [&](DAddr address) { gpu.InvalidateRegion(address, size); }); diff --git a/src/core/memory/dmnt_cheat_vm.cpp b/src/core/memory/dmnt_cheat_vm.cpp index f7097d01d..caceeec4f 100644 --- a/src/core/memory/dmnt_cheat_vm.cpp +++ b/src/core/memory/dmnt_cheat_vm.cpp @@ -224,12 +224,12 @@ bool DmntCheatVm::DecodeNextOpcode(CheatVmOpcode& out) { // If we've ever seen a decode failure, return false. bool valid = decode_success; CheatVmOpcode opcode = {}; - SCOPE_EXIT({ + SCOPE_EXIT { decode_success &= valid; if (valid) { out = opcode; } - }); + }; // Helper function for getting instruction dwords. const auto GetNextDword = [&] { diff --git a/src/hid_core/frontend/emulated_controller.cpp b/src/hid_core/frontend/emulated_controller.cpp index d9d278fa3..5cd26819c 100644 --- a/src/hid_core/frontend/emulated_controller.cpp +++ b/src/hid_core/frontend/emulated_controller.cpp @@ -933,8 +933,9 @@ void EmulatedController::SetStick(const Common::Input::CallbackStatus& callback, if (index >= controller.stick_values.size()) { return; } - auto trigger_guard = - SCOPE_GUARD({ TriggerOnChange(ControllerTriggerType::Stick, !is_configuring); }); + auto trigger_guard = SCOPE_GUARD { + TriggerOnChange(ControllerTriggerType::Stick, !is_configuring); + }; std::scoped_lock lock{mutex}; const auto stick_value = TransformToStick(callback); @@ -989,8 +990,9 @@ void EmulatedController::SetTrigger(const Common::Input::CallbackStatus& callbac if (index >= controller.trigger_values.size()) { return; } - auto trigger_guard = - SCOPE_GUARD({ TriggerOnChange(ControllerTriggerType::Trigger, !is_configuring); }); + auto trigger_guard = SCOPE_GUARD { + TriggerOnChange(ControllerTriggerType::Trigger, !is_configuring); + }; std::scoped_lock lock{mutex}; const auto trigger_value = TransformToTrigger(callback); @@ -1036,7 +1038,9 @@ void EmulatedController::SetMotion(const Common::Input::CallbackStatus& callback if (index >= controller.motion_values.size()) { return; } - SCOPE_EXIT({ TriggerOnChange(ControllerTriggerType::Motion, !is_configuring); }); + SCOPE_EXIT { + TriggerOnChange(ControllerTriggerType::Motion, !is_configuring); + }; std::scoped_lock lock{mutex}; auto& raw_status = controller.motion_values[index].raw_status; auto& emulated = controller.motion_values[index].emulated; @@ -1070,8 +1074,9 @@ void EmulatedController::SetColors(const Common::Input::CallbackStatus& callback if (index >= controller.color_values.size()) { return; } - auto trigger_guard = - SCOPE_GUARD({ TriggerOnChange(ControllerTriggerType::Color, !is_configuring); }); + auto trigger_guard = SCOPE_GUARD { + TriggerOnChange(ControllerTriggerType::Color, !is_configuring); + }; std::scoped_lock lock{mutex}; controller.color_values[index] = TransformToColor(callback); @@ -1120,7 +1125,9 @@ void EmulatedController::SetBattery(const Common::Input::CallbackStatus& callbac if (index >= controller.battery_values.size()) { return; } - SCOPE_EXIT({ TriggerOnChange(ControllerTriggerType::Battery, !is_configuring); }); + SCOPE_EXIT { + TriggerOnChange(ControllerTriggerType::Battery, !is_configuring); + }; std::scoped_lock lock{mutex}; controller.battery_values[index] = TransformToBattery(callback); @@ -1183,7 +1190,9 @@ void EmulatedController::SetBattery(const Common::Input::CallbackStatus& callbac } void EmulatedController::SetCamera(const Common::Input::CallbackStatus& callback) { - SCOPE_EXIT({ TriggerOnChange(ControllerTriggerType::IrSensor, !is_configuring); }); + SCOPE_EXIT { + TriggerOnChange(ControllerTriggerType::IrSensor, !is_configuring); + }; std::scoped_lock lock{mutex}; controller.camera_values = TransformToCamera(callback); @@ -1198,7 +1207,9 @@ void EmulatedController::SetCamera(const Common::Input::CallbackStatus& callback } void EmulatedController::SetRingAnalog(const Common::Input::CallbackStatus& callback) { - SCOPE_EXIT({ TriggerOnChange(ControllerTriggerType::RingController, !is_configuring); }); + SCOPE_EXIT { + TriggerOnChange(ControllerTriggerType::RingController, !is_configuring); + }; std::scoped_lock lock{mutex}; const auto force_value = TransformToStick(callback); @@ -1212,7 +1223,9 @@ void EmulatedController::SetRingAnalog(const Common::Input::CallbackStatus& call } void EmulatedController::SetNfc(const Common::Input::CallbackStatus& callback) { - SCOPE_EXIT({ TriggerOnChange(ControllerTriggerType::Nfc, !is_configuring); }); + SCOPE_EXIT { + TriggerOnChange(ControllerTriggerType::Nfc, !is_configuring); + }; std::scoped_lock lock{mutex}; controller.nfc_values = TransformToNfc(callback); @@ -1685,8 +1698,9 @@ void EmulatedController::Connect(bool use_temporary_value) { return; } - auto trigger_guard = - SCOPE_GUARD({ TriggerOnChange(ControllerTriggerType::Connected, !is_configuring); }); + auto trigger_guard = SCOPE_GUARD { + TriggerOnChange(ControllerTriggerType::Connected, !is_configuring); + }; std::scoped_lock lock{connect_mutex, mutex}; if (is_configuring) { tmp_is_connected = true; @@ -1701,8 +1715,9 @@ void EmulatedController::Connect(bool use_temporary_value) { } void EmulatedController::Disconnect() { - auto trigger_guard = - SCOPE_GUARD({ TriggerOnChange(ControllerTriggerType::Disconnected, !is_configuring); }); + auto trigger_guard = SCOPE_GUARD { + TriggerOnChange(ControllerTriggerType::Disconnected, !is_configuring); + }; std::scoped_lock lock{connect_mutex, mutex}; if (is_configuring) { tmp_is_connected = false; @@ -1738,8 +1753,9 @@ NpadStyleIndex EmulatedController::GetNpadStyleIndex(bool get_temporary_value) c } void EmulatedController::SetNpadStyleIndex(NpadStyleIndex npad_type_) { - auto trigger_guard = - SCOPE_GUARD({ TriggerOnChange(ControllerTriggerType::Type, !is_configuring); }); + auto trigger_guard = SCOPE_GUARD { + TriggerOnChange(ControllerTriggerType::Type, !is_configuring); + }; std::scoped_lock lock{mutex, npad_mutex}; if (is_configuring) { diff --git a/src/input_common/helpers/joycon_driver.cpp b/src/input_common/helpers/joycon_driver.cpp index c9f903213..0dd1c958a 100644 --- a/src/input_common/helpers/joycon_driver.cpp +++ b/src/input_common/helpers/joycon_driver.cpp @@ -268,7 +268,9 @@ void JoyconDriver::OnNewData(std::span buffer) { } Common::Input::DriverResult JoyconDriver::SetPollingMode() { - SCOPE_EXIT({ disable_input_thread = false; }); + SCOPE_EXIT { + disable_input_thread = false; + }; disable_input_thread = true; rumble_protocol->EnableRumble(vibration_enabled && supported_features.vibration); diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index a94e1f043..0d47b032c 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp @@ -291,7 +291,9 @@ u32 Maxwell3D::ProcessShadowRam(u32 method, u32 argument) { } void Maxwell3D::ConsumeSinkImpl() { - SCOPE_EXIT({ method_sink.clear(); }); + SCOPE_EXIT { + method_sink.clear(); + }; const auto control = shadow_state.shadow_ram_control; if (control == Regs::ShadowRamControl::Track || control == Regs::ShadowRamControl::TrackWithFilter) { diff --git a/src/video_core/fence_manager.h b/src/video_core/fence_manager.h index c3eda6893..2135f1f2d 100644 --- a/src/video_core/fence_manager.h +++ b/src/video_core/fence_manager.h @@ -197,7 +197,9 @@ private: MicroProfileOnThreadCreate(name.c_str()); // Cleanup - SCOPE_EXIT({ MicroProfileOnThreadExit(); }); + SCOPE_EXIT { + MicroProfileOnThreadExit(); + }; Common::SetCurrentThreadName(name.c_str()); Common::SetCurrentThreadPriority(Common::ThreadPriority::High); diff --git a/src/video_core/gpu_thread.cpp b/src/video_core/gpu_thread.cpp index 58d8110b8..477e11457 100644 --- a/src/video_core/gpu_thread.cpp +++ b/src/video_core/gpu_thread.cpp @@ -22,7 +22,9 @@ static void RunThread(std::stop_token stop_token, Core::System& system, Tegra::Control::Scheduler& scheduler, SynchState& state) { std::string name = "GPU"; MicroProfileOnThreadCreate(name.c_str()); - SCOPE_EXIT({ MicroProfileOnThreadExit(); }); + SCOPE_EXIT { + MicroProfileOnThreadExit(); + }; Common::SetCurrentThreadName(name.c_str()); Common::SetCurrentThreadPriority(Common::ThreadPriority::Critical); diff --git a/src/video_core/host1x/ffmpeg/ffmpeg.cpp b/src/video_core/host1x/ffmpeg/ffmpeg.cpp index 96686da59..1003cd38d 100644 --- a/src/video_core/host1x/ffmpeg/ffmpeg.cpp +++ b/src/video_core/host1x/ffmpeg/ffmpeg.cpp @@ -273,10 +273,10 @@ DeinterlaceFilter::DeinterlaceFilter(const Frame& frame) { const AVFilter* buffer_sink = avfilter_get_by_name("buffersink"); AVFilterInOut* inputs = avfilter_inout_alloc(); AVFilterInOut* outputs = avfilter_inout_alloc(); - SCOPE_EXIT({ + SCOPE_EXIT { avfilter_inout_free(&inputs); avfilter_inout_free(&outputs); - }); + }; // Don't know how to get the accurate time_base but it doesn't matter for yadif filter // so just use 1/1 to make buffer filter happy diff --git a/src/video_core/macro/macro_hle.cpp b/src/video_core/macro/macro_hle.cpp index 46e853e04..fb529f88b 100644 --- a/src/video_core/macro/macro_hle.cpp +++ b/src/video_core/macro/macro_hle.cpp @@ -92,12 +92,12 @@ public: private: void Fallback(const std::vector& parameters) { - SCOPE_EXIT({ + SCOPE_EXIT { if (extended) { maxwell3d.engine_state = Maxwell3D::EngineHint::None; maxwell3d.replace_table.clear(); } - }); + }; maxwell3d.RefreshParameters(); const u32 instance_count = (maxwell3d.GetRegisterValue(0xD1B) & parameters[2]); @@ -281,12 +281,12 @@ public: private: void Fallback(const std::vector& parameters) { - SCOPE_EXIT({ + SCOPE_EXIT { // Clean everything. maxwell3d.regs.vertex_id_base = 0x0; maxwell3d.engine_state = Maxwell3D::EngineHint::None; maxwell3d.replace_table.clear(); - }); + }; maxwell3d.RefreshParameters(); const u32 start_indirect = parameters[0]; const u32 end_indirect = parameters[1]; diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index b42fb110c..16af8e6bd 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -230,7 +230,9 @@ template void RasterizerOpenGL::PrepareDraw(bool is_indexed, Func&& draw_func) { MICROPROFILE_SCOPE(OpenGL_Drawing); - SCOPE_EXIT({ gpu.TickWork(); }); + SCOPE_EXIT { + gpu.TickWork(); + }; gpu_memory->FlushCaching(); GraphicsPipeline* const pipeline{shader_cache.CurrentGraphicsPipeline()}; @@ -355,7 +357,9 @@ void RasterizerOpenGL::DrawIndirect() { void RasterizerOpenGL::DrawTexture() { MICROPROFILE_SCOPE(OpenGL_Drawing); - SCOPE_EXIT({ gpu.TickWork(); }); + SCOPE_EXIT { + gpu.TickWork(); + }; texture_cache.SynchronizeGraphicsDescriptors(); texture_cache.UpdateRenderTargets(false); diff --git a/src/video_core/renderer_vulkan/present/layer.cpp b/src/video_core/renderer_vulkan/present/layer.cpp index 3847a9a13..4e41afe5b 100644 --- a/src/video_core/renderer_vulkan/present/layer.cpp +++ b/src/video_core/renderer_vulkan/present/layer.cpp @@ -82,7 +82,9 @@ void Layer::ConfigureDraw(PresentPushConstants* out_push_constants, // Finish any pending renderpass scheduler.RequestOutsideRenderPassOperationContext(); scheduler.Wait(resource_ticks[image_index]); - SCOPE_EXIT({ resource_ticks[image_index] = scheduler.CurrentTick(); }); + SCOPE_EXIT { + resource_ticks[image_index] = scheduler.CurrentTick(); + }; if (!use_accelerated) { UpdateRawImage(framebuffer, image_index); diff --git a/src/video_core/renderer_vulkan/renderer_vulkan.cpp b/src/video_core/renderer_vulkan/renderer_vulkan.cpp index d50417116..c553f5b3d 100644 --- a/src/video_core/renderer_vulkan/renderer_vulkan.cpp +++ b/src/video_core/renderer_vulkan/renderer_vulkan.cpp @@ -144,7 +144,9 @@ void RendererVulkan::Composite(std::span framebu return; } - SCOPE_EXIT({ render_window.OnFrameDisplayed(); }); + SCOPE_EXIT { + render_window.OnFrameDisplayed(); + }; RenderAppletCaptureLayer(framebuffers); diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index aa0a027bb..74f9f099e 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -196,7 +196,9 @@ template void RasterizerVulkan::PrepareDraw(bool is_indexed, Func&& draw_func) { MICROPROFILE_SCOPE(Vulkan_Drawing); - SCOPE_EXIT({ gpu.TickWork(); }); + SCOPE_EXIT { + gpu.TickWork(); + }; FlushWork(); gpu_memory->FlushCaching(); @@ -288,7 +290,9 @@ void RasterizerVulkan::DrawIndirect() { void RasterizerVulkan::DrawTexture() { MICROPROFILE_SCOPE(Vulkan_Drawing); - SCOPE_EXIT({ gpu.TickWork(); }); + SCOPE_EXIT { + gpu.TickWork(); + }; FlushWork(); query_cache.NotifySegment(true); diff --git a/src/video_core/vulkan_common/nsight_aftermath_tracker.cpp b/src/video_core/vulkan_common/nsight_aftermath_tracker.cpp index 5fa0d9620..f41c3e506 100644 --- a/src/video_core/vulkan_common/nsight_aftermath_tracker.cpp +++ b/src/video_core/vulkan_common/nsight_aftermath_tracker.cpp @@ -116,7 +116,9 @@ void NsightAftermathTracker::OnGpuCrashDumpCallback(const void* gpu_crash_dump, LOG_ERROR(Render_Vulkan, "Failed to create decoder"); return; } - SCOPE_EXIT({ GFSDK_Aftermath_GpuCrashDump_DestroyDecoder(decoder); }); + SCOPE_EXIT { + GFSDK_Aftermath_GpuCrashDump_DestroyDecoder(decoder); + }; u32 json_size = 0; if (!GFSDK_Aftermath_SUCCEED(GFSDK_Aftermath_GpuCrashDump_GenerateJSON( diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 0d16bfd65..236642fb9 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -646,10 +646,10 @@ void GMainWindow::AmiiboSettingsShowDialog(const Core::Frontend::CabinetParamete std::shared_ptr nfp_device) { cabinet_applet = new QtAmiiboSettingsDialog(this, parameters, input_subsystem.get(), nfp_device); - SCOPE_EXIT({ + SCOPE_EXIT { cabinet_applet->deleteLater(); cabinet_applet = nullptr; - }); + }; cabinet_applet->setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint); @@ -673,10 +673,10 @@ void GMainWindow::ControllerSelectorReconfigureControllers( const Core::Frontend::ControllerParameters& parameters) { controller_applet = new QtControllerSelectorDialog(this, parameters, input_subsystem.get(), *system); - SCOPE_EXIT({ + SCOPE_EXIT { controller_applet->deleteLater(); controller_applet = nullptr; - }); + }; controller_applet->setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint | Qt::WindowTitleHint | @@ -703,10 +703,10 @@ void GMainWindow::ControllerSelectorRequestExit() { void GMainWindow::ProfileSelectorSelectProfile( const Core::Frontend::ProfileSelectParameters& parameters) { profile_select_applet = new QtProfileSelectionDialog(*system, this, parameters); - SCOPE_EXIT({ + SCOPE_EXIT { profile_select_applet->deleteLater(); profile_select_applet = nullptr; - }); + }; profile_select_applet->setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint | Qt::WindowTitleHint | @@ -2885,17 +2885,19 @@ bool GMainWindow::CreateShortcutLink(const std::filesystem::path& shortcut_path, LOG_ERROR(Frontend, "CoInitialize failed"); return false; } - SCOPE_EXIT({ CoUninitialize(); }); + SCOPE_EXIT { + CoUninitialize(); + }; IShellLinkW* ps1 = nullptr; IPersistFile* persist_file = nullptr; - SCOPE_EXIT({ + SCOPE_EXIT { if (persist_file != nullptr) { persist_file->Release(); } if (ps1 != nullptr) { ps1->Release(); } - }); + }; HRESULT hres = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_IShellLinkW, reinterpret_cast(&ps1)); if (FAILED(hres)) { @@ -3520,10 +3522,10 @@ void GMainWindow::OnSaveConfig() { void GMainWindow::ErrorDisplayDisplayError(QString error_code, QString error_text) { error_applet = new OverlayDialog(render_window, *system, error_code, error_text, QString{}, tr("OK"), Qt::AlignLeft | Qt::AlignVCenter); - SCOPE_EXIT({ + SCOPE_EXIT { error_applet->deleteLater(); error_applet = nullptr; - }); + }; error_applet->exec(); emit ErrorDisplayFinished(); @@ -5192,7 +5194,9 @@ int main(int argc, char* argv[]) { Common::DetachedTasks detached_tasks; MicroProfileOnThreadCreate("Frontend"); - SCOPE_EXIT({ MicroProfileShutdown(); }); + SCOPE_EXIT { + MicroProfileShutdown(); + }; Common::ConfigureNvidiaEnvironmentFlags(); diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index 3b321dad1..8a8cdbc44 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -327,7 +327,9 @@ int main(int argc, char** argv) { #endif MicroProfileOnThreadCreate("EmuThread"); - SCOPE_EXIT({ MicroProfileShutdown(); }); + SCOPE_EXIT { + MicroProfileShutdown(); + }; Common::ConfigureNvidiaEnvironmentFlags(); -- cgit v1.2.3