1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-10 09:37:34 +00:00

Kernel: Make Kernel::VMObject allocation functions return KResultOr

This makes for nicer handling of errors compared to checking whether a
RefPtr is null. Additionally, this will give way to return different
types of errors in the future.
This commit is contained in:
sin-ack 2021-08-15 09:07:59 +00:00 committed by Andreas Kling
parent 61c0e3ca92
commit 4bfd6e41b9
26 changed files with 194 additions and 122 deletions

View file

@ -29,11 +29,11 @@ KResultOr<FlatPtr> Process::sys$anon_create(size_t size, int options)
if (new_fd_or_error.is_error())
return new_fd_or_error.error();
auto new_fd = new_fd_or_error.release_value();
auto vmobject = Memory::AnonymousVMObject::try_create_purgeable_with_size(size, AllocationStrategy::Reserve);
if (!vmobject)
return ENOMEM;
auto maybe_vmobject = Memory::AnonymousVMObject::try_create_purgeable_with_size(size, AllocationStrategy::Reserve);
if (maybe_vmobject.is_error())
return maybe_vmobject.error();
auto anon_file = AnonymousFile::create(vmobject.release_nonnull());
auto anon_file = AnonymousFile::create(maybe_vmobject.release_value());
if (!anon_file)
return ENOMEM;
auto description_or_error = FileDescription::create(*anon_file);