Skip to content

Commit 01a66ef

Browse files
bgianfoawesomekling
authored andcommitted
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.
1 parent 3356f43 commit 01a66ef

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Kernel/KResult.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,27 +141,27 @@ class alignas(T) [[nodiscard]] KResultOr {
141141

142142
[[nodiscard]] bool is_error() const { return m_is_error; }
143143

144-
ALWAYS_INLINE KResult error() const
144+
[[nodiscard]] ALWAYS_INLINE KResult error() const
145145
{
146146
ASSERT(m_is_error);
147147
return m_error;
148148
}
149149

150-
KResult result() const { return m_is_error ? m_error : KSuccess; }
150+
[[nodiscard]] KResult result() const { return m_is_error ? m_error : KSuccess; }
151151

152-
ALWAYS_INLINE T& value()
152+
[[nodiscard]] ALWAYS_INLINE T& value()
153153
{
154154
ASSERT(!m_is_error);
155155
return *reinterpret_cast<T*>(&m_storage);
156156
}
157157

158-
ALWAYS_INLINE const T& value() const
158+
[[nodiscard]] ALWAYS_INLINE const T& value() const
159159
{
160160
ASSERT(!m_is_error);
161161
return *reinterpret_cast<T*>(&m_storage);
162162
}
163163

164-
ALWAYS_INLINE T release_value()
164+
[[nodiscard]] ALWAYS_INLINE T release_value()
165165
{
166166
ASSERT(!m_is_error);
167167
ASSERT(m_have_storage);

0 commit comments

Comments
 (0)