mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-22 11:02:53 +00:00
Kernel: Make Memory::Region allocation functions return KResultOr
This makes for some nicer handling of errors compared to checking an OwnPtr for null state.
This commit is contained in:
parent
4bfd6e41b9
commit
0a18425cbb
Notes:
sideshowbarker
2024-07-18 05:39:28 +09:00
Author: https://github.com/sin-ack
Commit: 0a18425cbb
Pull-request: https://github.com/SerenityOS/serenity/pull/9434
Reviewed-by: https://github.com/awesomekling
5 changed files with 45 additions and 38 deletions
|
@ -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?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue