summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-11-08 00:51:39 +0100
committerAndreas Kling <kling@serenityos.org>2021-11-08 01:10:53 +0100
commit79fa9765ca89869d19364143989436d117974c21 (patch)
tree3af62f70127d9217d841047f6b7461351800d1ae /AK
parent7ee10c69264cb278845a1e1b06d5acf2e5e7ddf0 (diff)
downloadserenity-79fa9765ca89869d19364143989436d117974c21.zip
Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T>
We now use AK::Error and AK::ErrorOr<T> in both kernel and userspace! This was a slightly tedious refactoring that took a long time, so it's not unlikely that some bugs crept in. Nevertheless, it does pass basic functionality testing, and it's just real nice to finally see the same pattern in all contexts. :^)
Diffstat (limited to 'AK')
-rw-r--r--AK/OwnPtr.h17
-rw-r--r--AK/Try.h2
2 files changed, 2 insertions, 17 deletions
diff --git a/AK/OwnPtr.h b/AK/OwnPtr.h
index 582693d9e4..b950076efc 100644
--- a/AK/OwnPtr.h
+++ b/AK/OwnPtr.h
@@ -6,13 +6,9 @@
#pragma once
+#include <AK/Error.h>
#include <AK/NonnullOwnPtr.h>
#include <AK/RefCounted.h>
-#ifdef KERNEL
-# include <Kernel/API/KResult.h>
-#else
-# include <AK/Error.h>
-#endif
#define OWNPTR_SCRUB_BYTE 0xf0
@@ -209,16 +205,6 @@ inline OwnPtr<T> adopt_own_if_nonnull(T* object)
return {};
}
-#ifdef KERNEL
-template<typename T>
-inline Kernel::KResultOr<NonnullOwnPtr<T>> adopt_nonnull_own_or_enomem(T* object)
-{
- auto result = adopt_own_if_nonnull(object);
- if (!result)
- return ENOMEM;
- return result.release_nonnull();
-}
-#else
template<typename T>
inline ErrorOr<NonnullOwnPtr<T>> adopt_nonnull_own_or_enomem(T* object)
{
@@ -227,7 +213,6 @@ inline ErrorOr<NonnullOwnPtr<T>> adopt_nonnull_own_or_enomem(T* object)
return ENOMEM;
return result.release_nonnull();
}
-#endif
template<typename T, class... Args>
requires(IsConstructible<T, Args...>) inline OwnPtr<T> try_make(Args&&... args)
diff --git a/AK/Try.h b/AK/Try.h
index 4efb21a5a0..15d470e86b 100644
--- a/AK/Try.h
+++ b/AK/Try.h
@@ -7,7 +7,7 @@
#pragma once
// NOTE: This macro works with any result type that has the expected APIs.
-// It's designed with AK::Result and Kernel::KResult in mind.
+// It's designed with AK::Result and AK::Error in mind.
#define TRY(expression) \
({ \