From 0a18425cbb8ac027fa378ff72d60e5a21573b814 Mon Sep 17 00:00:00 2001 From: sin-ack Date: Sun, 15 Aug 2021 10:11:05 +0000 Subject: Kernel: Make Memory::Region allocation functions return KResultOr This makes for some nicer handling of errors compared to checking an OwnPtr for null state. --- Kernel/Syscalls/fork.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Kernel/Syscalls/fork.cpp') diff --git a/Kernel/Syscalls/fork.cpp b/Kernel/Syscalls/fork.cpp index 6f166e15aa..a0ff8cd74a 100644 --- a/Kernel/Syscalls/fork.cpp +++ b/Kernel/Syscalls/fork.cpp @@ -96,14 +96,14 @@ KResultOr Process::sys$fork(RegisterState& regs) ScopedSpinLock lock(address_space().get_lock()); for (auto& region : address_space().regions()) { dbgln_if(FORK_DEBUG, "fork: cloning Region({}) '{}' @ {}", region, region->name(), region->vaddr()); - auto region_clone = region->clone(); - if (!region_clone) { + auto maybe_region_clone = region->try_clone(); + if (maybe_region_clone.is_error()) { dbgln("fork: Cannot clone region, insufficient memory"); // TODO: tear down new process? - return ENOMEM; + return maybe_region_clone.error(); } - auto* child_region = child->address_space().add_region(region_clone.release_nonnull()); + auto* child_region = child->address_space().add_region(maybe_region_clone.release_value()); if (!child_region) { dbgln("fork: Cannot add region, insufficient memory"); // TODO: tear down new process? -- cgit v1.2.3