diff --git a/include/stratosphere/results/utilities.h b/include/stratosphere/results/utilities.h index 5eaa52f0..7afe40d7 100644 --- a/include/stratosphere/results/utilities.h +++ b/include/stratosphere/results/utilities.h @@ -58,9 +58,7 @@ extern "C" { ({ \ const Result _tmp_r_try_cleanup_rc = res_expr; \ if (R_FAILED(_tmp_r_try_cleanup_rc)) { \ - do { \ - cleanup_expr \ - } while (0); \ + ({ cleanup_expr }); \ return _tmp_r_try_cleanup_rc; \ } \ }) diff --git a/include/stratosphere/scope_guard.hpp b/include/stratosphere/scope_guard.hpp index 5fdf7edd..9ff4be70 100644 --- a/include/stratosphere/scope_guard.hpp +++ b/include/stratosphere/scope_guard.hpp @@ -13,7 +13,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - + /* Scope guard logic lovingly taken from Andrei Alexandrescu's "Systemic Error Handling in C++" */ #pragma once @@ -28,7 +28,7 @@ public: ScopeGuard(F f) : f(std::move(f)), active(true) { } ~ScopeGuard() { if (active) { f(); } } void Cancel() { active = false; } - + ScopeGuard() = delete; ScopeGuard(const ScopeGuard &) = delete; ScopeGuard& operator=(const ScopeGuard&) = delete; @@ -58,4 +58,5 @@ ScopeGuard operator+(ScopeGuardOnExit, F&& f) { #define ANONYMOUS_VARIABLE(pref) CONCATENATE(pref, __LINE__) #endif -#define ON_SCOPE_EXIT auto ANONYMOUS_VARIABLE(SCOPE_EXIT_STATE_) = ScopeGuardOnExit() + [&]() \ No newline at end of file +#define SCOPE_GUARD ScopeGuardOnExit() + [&]() +#define ON_SCOPE_EXIT auto ANONYMOUS_VARIABLE(SCOPE_EXIT_STATE_) = SCOPE_GUARD