From 74ce098d580c9751897fc6d76de411c8a7a1e231 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 4 Sep 2021 12:55:37 +0200 Subject: [PATCH] Kernel: Delete the rvalue-ref qualified version of KResultOr::value() This makes calling value() on a temporary KResultOr be a compile-time error. This exposed a number of missing error checks (fixed in the preceding commits.) --- Kernel/KResult.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Kernel/KResult.h b/Kernel/KResult.h index 5b70fd7681..ed670ac0a9 100644 --- a/Kernel/KResult.h +++ b/Kernel/KResult.h @@ -138,18 +138,20 @@ public: [[nodiscard]] KResult result() const { return m_is_error ? m_error : KSuccess; } - [[nodiscard]] ALWAYS_INLINE T& value() + [[nodiscard]] ALWAYS_INLINE T& value() & { VERIFY(!m_is_error); return *reinterpret_cast(&m_storage); } - [[nodiscard]] ALWAYS_INLINE const T& value() const + [[nodiscard]] ALWAYS_INLINE T const& value() const& { VERIFY(!m_is_error); return *reinterpret_cast(&m_storage); } + T value() && = delete; + [[nodiscard]] ALWAYS_INLINE T release_value() { VERIFY(!m_is_error);