diff options
author | Andreas Kling <kling@serenityos.org> | 2021-09-06 12:58:03 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-06 13:06:05 +0200 |
commit | 6e3381ac32e5d251c124cc6147c4598dd2bac505 (patch) | |
tree | 108e6a04d89d5f9c483df0361079caea2424362c /Kernel/Memory | |
parent | e3a716ceffc0fc1f5c4f2ee35dee02e987731621 (diff) | |
download | serenity-6e3381ac32e5d251c124cc6147c4598dd2bac505.zip |
Kernel: Use KResultOr and TRY() for {Shared,Private}InodeVMObject
Diffstat (limited to 'Kernel/Memory')
-rw-r--r-- | Kernel/Memory/PrivateInodeVMObject.cpp | 4 | ||||
-rw-r--r-- | Kernel/Memory/PrivateInodeVMObject.h | 2 | ||||
-rw-r--r-- | Kernel/Memory/SharedInodeVMObject.cpp | 6 | ||||
-rw-r--r-- | Kernel/Memory/SharedInodeVMObject.h | 2 |
4 files changed, 6 insertions, 8 deletions
diff --git a/Kernel/Memory/PrivateInodeVMObject.cpp b/Kernel/Memory/PrivateInodeVMObject.cpp index 0c3aa9f981..25b1b6cbad 100644 --- a/Kernel/Memory/PrivateInodeVMObject.cpp +++ b/Kernel/Memory/PrivateInodeVMObject.cpp @@ -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() diff --git a/Kernel/Memory/PrivateInodeVMObject.h b/Kernel/Memory/PrivateInodeVMObject.h index a664c219a8..96a2f67fb7 100644 --- a/Kernel/Memory/PrivateInodeVMObject.h +++ b/Kernel/Memory/PrivateInodeVMObject.h @@ -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: diff --git a/Kernel/Memory/SharedInodeVMObject.cpp b/Kernel/Memory/SharedInodeVMObject.cpp index cfeda69841..7dacfd6e66 100644 --- a/Kernel/Memory/SharedInodeVMObject.cpp +++ b/Kernel/Memory/SharedInodeVMObject.cpp @@ -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; } diff --git a/Kernel/Memory/SharedInodeVMObject.h b/Kernel/Memory/SharedInodeVMObject.h index 6690c3a2d7..5b91785c55 100644 --- a/Kernel/Memory/SharedInodeVMObject.h +++ b/Kernel/Memory/SharedInodeVMObject.h @@ -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: |