mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:18:12 +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:
parent
61c0e3ca92
commit
4bfd6e41b9
26 changed files with 194 additions and 122 deletions
|
@ -47,13 +47,14 @@ KResultOr<Memory::Region*> MemoryDevice::mmap(Process& process, FileDescription&
|
|||
return EINVAL;
|
||||
}
|
||||
|
||||
auto vmobject = Memory::AnonymousVMObject::try_create_for_physical_range(viewed_address, range.size());
|
||||
if (!vmobject)
|
||||
return ENOMEM;
|
||||
auto maybe_vmobject = Memory::AnonymousVMObject::try_create_for_physical_range(viewed_address, range.size());
|
||||
if (maybe_vmobject.is_error())
|
||||
return maybe_vmobject.error();
|
||||
|
||||
dbgln("MemoryDevice: Mapped physical memory at {} for range of {} bytes", viewed_address, range.size());
|
||||
return process.address_space().allocate_region_with_vmobject(
|
||||
range,
|
||||
vmobject.release_nonnull(),
|
||||
maybe_vmobject.release_value(),
|
||||
0,
|
||||
"Mapped Physical Memory",
|
||||
prot,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue