summaryrefslogtreecommitdiff
path: root/Kernel/Thread.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-09-04 21:49:08 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-04 23:11:04 +0200
commit5d5a3708c459afb2a5de1cafc5afa3c6e5b6fee7 (patch)
tree6bb43caed331094d9f0627b61af765e02f250dc7 /Kernel/Thread.cpp
parentcfc1a628d59ac36186a643468065a6a826386131 (diff)
downloadserenity-5d5a3708c459afb2a5de1cafc5afa3c6e5b6fee7.zip
Kernel: Rename Thread::clone() => try_clone() and propagate errors
Diffstat (limited to 'Kernel/Thread.cpp')
-rw-r--r--Kernel/Thread.cpp10
1 files changed, 3 insertions, 7 deletions
diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp
index bf45dea28a..2140bbec9f 100644
--- a/Kernel/Thread.cpp
+++ b/Kernel/Thread.cpp
@@ -50,11 +50,7 @@ KResultOr<NonnullRefPtr<Thread>> Thread::try_create(NonnullRefPtr<Process> proce
auto name = KString::try_create(process->name());
- auto thread = adopt_ref_if_nonnull(new (nothrow) Thread(move(process), kernel_stack_region.release_nonnull(), block_timer.release_nonnull(), move(name)));
- if (!thread)
- return ENOMEM;
-
- return thread.release_nonnull();
+ return adopt_nonnull_ref_or_enomem(new (nothrow) Thread(move(process), kernel_stack_region.release_nonnull(), block_timer.release_nonnull(), move(name)));
}
Thread::Thread(NonnullRefPtr<Process> process, NonnullOwnPtr<Memory::Region> kernel_stack_region, NonnullRefPtr<Timer> block_timer, OwnPtr<KString> name)
@@ -1030,11 +1026,11 @@ RegisterState& Thread::get_register_dump_from_stack()
return *trap->regs;
}
-RefPtr<Thread> Thread::clone(Process& process)
+KResultOr<NonnullRefPtr<Thread>> Thread::try_clone(Process& process)
{
auto thread_or_error = Thread::try_create(process);
if (thread_or_error.is_error())
- return {};
+ return thread_or_error.error();
auto& clone = thread_or_error.value();
auto signal_action_data_span = m_signal_action_data.span();
signal_action_data_span.copy_to(clone->m_signal_action_data.span());