From 01a66efe9d607d0a47d81e49c862b6ac1adcf950 Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Sun, 14 Feb 2021 15:21:38 -0800 Subject: [PATCH] Kernel: Mark KResult 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/KResult.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Kernel/KResult.h b/Kernel/KResult.h index aaafe7d052..5039af8b3d 100644 --- a/Kernel/KResult.h +++ b/Kernel/KResult.h @@ -141,27 +141,27 @@ public: [[nodiscard]] bool is_error() const { return m_is_error; } - ALWAYS_INLINE KResult error() const + [[nodiscard]] ALWAYS_INLINE KResult error() const { ASSERT(m_is_error); return m_error; } - KResult result() const { return m_is_error ? m_error : KSuccess; } + [[nodiscard]] KResult result() const { return m_is_error ? m_error : KSuccess; } - ALWAYS_INLINE T& value() + [[nodiscard]] ALWAYS_INLINE T& value() { ASSERT(!m_is_error); return *reinterpret_cast(&m_storage); } - ALWAYS_INLINE const T& value() const + [[nodiscard]] ALWAYS_INLINE const T& value() const { ASSERT(!m_is_error); return *reinterpret_cast(&m_storage); } - ALWAYS_INLINE T release_value() + [[nodiscard]] ALWAYS_INLINE T release_value() { ASSERT(!m_is_error); ASSERT(m_have_storage);