summaryrefslogtreecommitdiff
path: root/Kernel/Syscalls/fork.cpp
diff options
context:
space:
mode:
authorsin-ack <sin-ack@users.noreply.github.com>2021-08-15 10:11:05 +0000
committerAndreas Kling <kling@serenityos.org>2021-08-15 15:41:02 +0200
commit0a18425cbb8ac027fa378ff72d60e5a21573b814 (patch)
treed71cbe15837e6957689ced733704468404330b36 /Kernel/Syscalls/fork.cpp
parent4bfd6e41b952c2583c6941e58dea3e5cc032b9f3 (diff)
downloadserenity-0a18425cbb8ac027fa378ff72d60e5a21573b814.zip
Kernel: Make Memory::Region allocation functions return KResultOr
This makes for some nicer handling of errors compared to checking an OwnPtr for null state.
Diffstat (limited to 'Kernel/Syscalls/fork.cpp')
-rw-r--r--Kernel/Syscalls/fork.cpp8
1 files changed, 4 insertions, 4 deletions
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<FlatPtr> 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?