mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:57:45 +00:00
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.
This commit is contained in:
parent
3356f438ca
commit
01a66efe9d
1 changed files with 5 additions and 5 deletions
|
@ -141,27 +141,27 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] bool is_error() const { return m_is_error; }
|
[[nodiscard]] bool is_error() const { return m_is_error; }
|
||||||
|
|
||||||
ALWAYS_INLINE KResult error() const
|
[[nodiscard]] ALWAYS_INLINE KResult error() const
|
||||||
{
|
{
|
||||||
ASSERT(m_is_error);
|
ASSERT(m_is_error);
|
||||||
return m_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);
|
ASSERT(!m_is_error);
|
||||||
return *reinterpret_cast<T*>(&m_storage);
|
return *reinterpret_cast<T*>(&m_storage);
|
||||||
}
|
}
|
||||||
|
|
||||||
ALWAYS_INLINE const T& value() const
|
[[nodiscard]] ALWAYS_INLINE const T& value() const
|
||||||
{
|
{
|
||||||
ASSERT(!m_is_error);
|
ASSERT(!m_is_error);
|
||||||
return *reinterpret_cast<T*>(&m_storage);
|
return *reinterpret_cast<T*>(&m_storage);
|
||||||
}
|
}
|
||||||
|
|
||||||
ALWAYS_INLINE T release_value()
|
[[nodiscard]] ALWAYS_INLINE T release_value()
|
||||||
{
|
{
|
||||||
ASSERT(!m_is_error);
|
ASSERT(!m_is_error);
|
||||||
ASSERT(m_have_storage);
|
ASSERT(m_have_storage);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue