mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:18:11 +00:00
Kernel: Use KResultOr and TRY() for {Shared,Private}InodeVMObject
This commit is contained in:
parent
e3a716ceff
commit
6e3381ac32
8 changed files with 14 additions and 31 deletions
|
@ -9,14 +9,12 @@
|
|||
|
||||
namespace Kernel::Memory {
|
||||
|
||||
RefPtr<SharedInodeVMObject> SharedInodeVMObject::try_create_with_inode(Inode& inode)
|
||||
KResultOr<NonnullRefPtr<SharedInodeVMObject>> SharedInodeVMObject::try_create_with_inode(Inode& inode)
|
||||
{
|
||||
size_t size = inode.size();
|
||||
if (auto shared_vmobject = inode.shared_vmobject())
|
||||
return shared_vmobject.release_nonnull();
|
||||
auto vmobject = adopt_ref_if_nonnull(new (nothrow) SharedInodeVMObject(inode, size));
|
||||
if (!vmobject)
|
||||
return nullptr;
|
||||
auto vmobject = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) SharedInodeVMObject(inode, size)));
|
||||
vmobject->inode().set_shared_vmobject(*vmobject);
|
||||
return vmobject;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue