1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 16:07:45 +00:00

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. :^)
This commit is contained in:
Andreas Kling 2021-11-08 00:51:39 +01:00
parent 7ee10c6926
commit 79fa9765ca
262 changed files with 2415 additions and 2600 deletions

View file

@ -8,6 +8,7 @@
#include <AK/Concepts.h>
#include <AK/EnumBits.h>
#include <AK/Error.h>
#include <AK/HashMap.h>
#include <AK/IntrusiveList.h>
#include <AK/Optional.h>
@ -19,7 +20,6 @@
#include <AK/Vector.h>
#include <AK/WeakPtr.h>
#include <AK/Weakable.h>
#include <Kernel/API/KResult.h>
#include <Kernel/Arch/x86/SafeMem.h>
#include <Kernel/Debug.h>
#include <Kernel/FileSystem/InodeIdentifier.h>
@ -162,7 +162,7 @@ public:
return Processor::current_thread();
}
static KResultOr<NonnullRefPtr<Thread>> try_create(NonnullRefPtr<Process>);
static ErrorOr<NonnullRefPtr<Thread>> try_create(NonnullRefPtr<Process>);
~Thread();
static RefPtr<Thread> from_tid(ThreadID);
@ -516,7 +516,7 @@ public:
friend class JoinBlocker;
class JoinBlocker final : public Blocker {
public:
explicit JoinBlocker(Thread& joinee, KResult& try_join_result, void*& joinee_exit_value);
explicit JoinBlocker(Thread& joinee, ErrorOr<void>& try_join_result, void*& joinee_exit_value);
virtual Type blocker_type() const override { return Type::Join; }
virtual StringView state_string() const override { return "Joining"sv; }
virtual bool can_be_interrupted() const override { return false; }
@ -529,7 +529,7 @@ public:
private:
NonnullRefPtr<Thread> m_joinee;
void*& m_joinee_exit_value;
KResult& m_try_join_result;
ErrorOr<void>& m_try_join_result;
bool m_did_unblock { false };
};
@ -706,7 +706,7 @@ public:
Disowned
};
WaitBlocker(int wait_options, Variant<Empty, NonnullRefPtr<Process>, NonnullRefPtr<ProcessGroup>> waitee, KResultOr<siginfo_t>& result);
WaitBlocker(int wait_options, Variant<Empty, NonnullRefPtr<Process>, NonnullRefPtr<ProcessGroup>> waitee, ErrorOr<siginfo_t>& result);
virtual StringView state_string() const override { return "Waiting"sv; }
virtual Type blocker_type() const override { return Type::Wait; }
virtual void will_unblock_immediately_without_blocking(UnblockImmediatelyReason) override;
@ -721,7 +721,7 @@ public:
void do_set_result(const siginfo_t&);
const int m_wait_options;
KResultOr<siginfo_t>& m_result;
ErrorOr<siginfo_t>& m_result;
Variant<Empty, NonnullRefPtr<Process>, NonnullRefPtr<ProcessGroup>> m_waitee;
bool m_did_unblock { false };
bool m_got_sigchild { false };
@ -761,7 +761,7 @@ public:
};
template<typename AddBlockerHandler>
KResult try_join(AddBlockerHandler add_blocker)
ErrorOr<void> try_join(AddBlockerHandler add_blocker)
{
if (Thread::current() == this)
return EDEADLK;
@ -776,7 +776,7 @@ public:
// else. It also means that if the join is timed, it becomes
// detached when a timeout happens.
m_is_joinable = false;
return KSuccess;
return {};
}
void did_schedule() { ++m_times_scheduled; }
@ -1011,8 +1011,8 @@ public:
u32 signal_mask() const;
void clear_signals();
KResultOr<u32> peek_debug_register(u32 register_index);
KResult poke_debug_register(u32 register_index, u32 data);
ErrorOr<u32> peek_debug_register(u32 register_index);
ErrorOr<void> poke_debug_register(u32 register_index, u32 data);
void set_dump_backtrace_on_finalization() { m_dump_backtrace_on_finalization = true; }
@ -1028,7 +1028,7 @@ public:
FPUState& fpu_state() { return m_fpu_state; }
KResult make_thread_specific_region(Badge<Process>);
ErrorOr<void> make_thread_specific_region(Badge<Process>);
unsigned syscall_count() const { return m_syscall_count; }
void did_syscall() { ++m_syscall_count; }
@ -1104,7 +1104,7 @@ public:
return !m_is_joinable;
}
KResultOr<NonnullRefPtr<Thread>> try_clone(Process&);
ErrorOr<NonnullRefPtr<Thread>> try_clone(Process&);
template<IteratorFunction<Thread&> Callback>
static IterationDecision for_each_in_state(State, Callback);