From f808258ed9a44f74cd100b5be3b0001aabf73f9a Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 2 Aug 2020 20:15:20 -0400 Subject: [PATCH 1/2] kernel/scheduler: Mark SchedulerLock constructor as nodiscard Allows the compiler to warn about cases where the constructor is used but then immediately discarded, which is a potential cause of locking/unlocking bugs. --- src/core/hle/kernel/scheduler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/hle/kernel/scheduler.h b/src/core/hle/kernel/scheduler.h index b3b4b51699..36e3c26fb5 100644 --- a/src/core/hle/kernel/scheduler.h +++ b/src/core/hle/kernel/scheduler.h @@ -289,7 +289,7 @@ private: class SchedulerLock { public: - explicit SchedulerLock(KernelCore& kernel); + [[nodiscard]] explicit SchedulerLock(KernelCore& kernel); ~SchedulerLock(); protected: From a93f6e51d355ee95009a07c8a574fc9eaed212bf Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 2 Aug 2020 20:17:42 -0400 Subject: [PATCH 2/2] emu_window: Mark Scoped constructor and Acquire() as nodiscard Ensures that callers make use of the constructor, preventing bugs from silently occurring. --- src/core/frontend/emu_window.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/frontend/emu_window.h b/src/core/frontend/emu_window.h index 13aa149346..3e87802430 100644 --- a/src/core/frontend/emu_window.h +++ b/src/core/frontend/emu_window.h @@ -39,7 +39,7 @@ public: class Scoped { public: - explicit Scoped(GraphicsContext& context_) : context(context_) { + [[nodiscard]] explicit Scoped(GraphicsContext& context_) : context(context_) { context.MakeCurrent(); } ~Scoped() { @@ -52,7 +52,7 @@ public: /// Calls MakeCurrent on the context and calls DoneCurrent when the scope for the returned value /// ends - Scoped Acquire() { + [[nodiscard]] Scoped Acquire() { return Scoped{*this}; } };