mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:07:34 +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,9 +9,9 @@
|
|||
|
||||
namespace Kernel::Memory {
|
||||
|
||||
RefPtr<PrivateInodeVMObject> PrivateInodeVMObject::try_create_with_inode(Inode& inode)
|
||||
KResultOr<NonnullRefPtr<PrivateInodeVMObject>> PrivateInodeVMObject::try_create_with_inode(Inode& inode)
|
||||
{
|
||||
return adopt_ref_if_nonnull(new (nothrow) PrivateInodeVMObject(inode, inode.size()));
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) PrivateInodeVMObject(inode, inode.size()));
|
||||
}
|
||||
|
||||
KResultOr<NonnullRefPtr<VMObject>> PrivateInodeVMObject::try_clone()
|
||||
|
|
|
@ -18,7 +18,7 @@ class PrivateInodeVMObject final : public InodeVMObject {
|
|||
public:
|
||||
virtual ~PrivateInodeVMObject() override;
|
||||
|
||||
static RefPtr<PrivateInodeVMObject> try_create_with_inode(Inode&);
|
||||
static KResultOr<NonnullRefPtr<PrivateInodeVMObject>> try_create_with_inode(Inode&);
|
||||
virtual KResultOr<NonnullRefPtr<VMObject>> try_clone() override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ class SharedInodeVMObject final : public InodeVMObject {
|
|||
AK_MAKE_NONMOVABLE(SharedInodeVMObject);
|
||||
|
||||
public:
|
||||
static RefPtr<SharedInodeVMObject> try_create_with_inode(Inode&);
|
||||
static KResultOr<NonnullRefPtr<SharedInodeVMObject>> try_create_with_inode(Inode&);
|
||||
virtual KResultOr<NonnullRefPtr<VMObject>> try_clone() override;
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue