1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:27:45 +00:00

Kernel: Tag more methods and types as [[nodiscard]]

Tag methods at where not obvserving the return value is an obvious error
with [[nodiscard]] to catch potential future bugs.
This commit is contained in:
Brian Gianforcaro 2020-12-26 01:47:08 -08:00 committed by Andreas Kling
parent 21a5524d01
commit 815d39886f
3 changed files with 26 additions and 24 deletions

View file

@ -58,7 +58,7 @@ public:
Processor::current().leave_critical(prev_flags);
}
ALWAYS_INLINE bool is_locked() const
[[nodiscard]] ALWAYS_INLINE bool is_locked() const
{
return m_lock.load(AK::memory_order_relaxed) != 0;
}
@ -105,12 +105,12 @@ public:
Processor::current().leave_critical(prev_flags);
}
ALWAYS_INLINE bool is_locked() const
[[nodiscard]] ALWAYS_INLINE bool is_locked() const
{
return m_lock.load(AK::memory_order_relaxed) != 0;
}
ALWAYS_INLINE bool own_lock() const
[[nodiscard]] ALWAYS_INLINE bool own_lock() const
{
return m_lock.load(AK::memory_order_relaxed) == FlatPtr(&Processor::current());
}
@ -126,7 +126,8 @@ private:
};
template<typename LockType>
class ScopedSpinLock {
class NO_DISCARD ScopedSpinLock {
AK_MAKE_NONCOPYABLE(ScopedSpinLock);
public:
@ -175,7 +176,7 @@ public:
m_have_lock = false;
}
ALWAYS_INLINE bool have_lock() const
[[nodiscard]] ALWAYS_INLINE bool have_lock() const
{
return m_have_lock;
}