diff options
author | Andreas Kling <kling@serenityos.org> | 2021-09-06 19:24:54 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-06 19:25:36 +0200 |
commit | 56a2594de7fdcd1b0e8c2a20832ba4a14fa20501 (patch) | |
tree | c5da30fe55661c18aad37208fc073d5180793f8f /Kernel/Thread.cpp | |
parent | 69b9b2888cea47393461799746e80a04bdcae4d1 (diff) | |
download | serenity-56a2594de7fdcd1b0e8c2a20832ba4a14fa20501.zip |
Kernel: Make KString factories return KResultOr + use TRY() everywhere
There are a number of places that don't have an error propagation path
right now, so I've added FIXME's about that.
Diffstat (limited to 'Kernel/Thread.cpp')
-rw-r--r-- | Kernel/Thread.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp index 8c7125c58c..dfb2138c88 100644 --- a/Kernel/Thread.cpp +++ b/Kernel/Thread.cpp @@ -46,11 +46,8 @@ KResultOr<NonnullRefPtr<Thread>> Thread::try_create(NonnullRefPtr<Process> proce if (!block_timer) return ENOMEM; - auto name = KString::try_create(process->name()); - if (!name) - return ENOMEM; - - return adopt_nonnull_ref_or_enomem(new (nothrow) Thread(move(process), move(kernel_stack_region), block_timer.release_nonnull(), name.release_nonnull())); + auto name = TRY(KString::try_create(process->name())); + return adopt_nonnull_ref_or_enomem(new (nothrow) Thread(move(process), move(kernel_stack_region), block_timer.release_nonnull(), move(name))); } Thread::Thread(NonnullRefPtr<Process> process, NonnullOwnPtr<Memory::Region> kernel_stack_region, NonnullRefPtr<Timer> block_timer, NonnullOwnPtr<KString> name) @@ -70,7 +67,8 @@ Thread::Thread(NonnullRefPtr<Process> process, NonnullOwnPtr<Memory::Region> ker { // FIXME: Go directly to KString auto string = String::formatted("Kernel stack (thread {})", m_tid.value()); - m_kernel_stack_region->set_name(KString::try_create(string)); + // FIXME: Handle KString allocation failure. + m_kernel_stack_region->set_name(KString::try_create(string).release_value()); } Thread::all_instances().with([&](auto& list) { |