Skip to content

Commit

Permalink
Kernel: Mark Lock getters as [[nodiscard]]
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bgianfo authored and awesomekling committed Feb 15, 2021
1 parent a75d795 commit 0cbede9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Kernel/Lock.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ class Lock {
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)
{
Expand Down Expand Up @@ -149,10 +149,10 @@ class Lockable {
: 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;
Expand Down

0 comments on commit 0cbede9

Please sign in to comment.