From 0cbede91b83de7741f4df49ef1ec229373dc92f0 Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Sun, 14 Feb 2021 15:24:44 -0800 Subject: [PATCH] Kernel: Mark Lock getters as [[nodiscard]] There is no reason to call a getter without observing the result, doing so indicates an error in the code. Mark these methods as [[nodiscard]] to find these cases. --- Kernel/Lock.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Kernel/Lock.h b/Kernel/Lock.h index b3fe5a10df..22d98a44f5 100644 --- a/Kernel/Lock.h +++ b/Kernel/Lock.h @@ -58,10 +58,10 @@ public: void unlock(); [[nodiscard]] Mode force_unlock_if_locked(u32&); void restore_lock(Mode, u32); - bool is_locked() const { return m_mode != Mode::Unlocked; } + [[nodiscard]] bool is_locked() const { return m_mode != Mode::Unlocked; } void clear_waiters(); - const char* name() const { return m_name; } + [[nodiscard]] const char* name() const { return m_name; } static const char* mode_to_string(Mode mode) { @@ -149,10 +149,10 @@ public: : m_resource(move(resource)) { } - Lock& lock() { return m_lock; } - T& resource() { return m_resource; } + [[nodiscard]] Lock& lock() { return m_lock; } + [[nodiscard]] T& resource() { return m_resource; } - T lock_and_copy() + [[nodiscard]] T lock_and_copy() { LOCKER(m_lock); return m_resource;