summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-09-04 23:52:39 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-05 01:10:56 +0200
commit68a6d4c30ac0154e844e06db6de203775d786112 (patch)
tree39d8c0da9484ccb889979a95c6f818134342b94a /Kernel
parent393229e2aa0bbcee82eec6e41f2b86faa996e7d9 (diff)
downloadserenity-68a6d4c30ac0154e844e06db6de203775d786112.zip
Kernel: Tidy up InodeWatcher construction
- Rename create() => try_create() - Use adopt_nonnull_ref_or_enomem()
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/FileSystem/InodeWatcher.cpp7
-rw-r--r--Kernel/FileSystem/InodeWatcher.h2
-rw-r--r--Kernel/Syscalls/inode_watcher.cpp2
3 files changed, 4 insertions, 7 deletions
diff --git a/Kernel/FileSystem/InodeWatcher.cpp b/Kernel/FileSystem/InodeWatcher.cpp
index f8b30e993e..8edd88092f 100644
--- a/Kernel/FileSystem/InodeWatcher.cpp
+++ b/Kernel/FileSystem/InodeWatcher.cpp
@@ -12,12 +12,9 @@
namespace Kernel {
-KResultOr<NonnullRefPtr<InodeWatcher>> InodeWatcher::create()
+KResultOr<NonnullRefPtr<InodeWatcher>> InodeWatcher::try_create()
{
- auto watcher = adopt_ref_if_nonnull(new (nothrow) InodeWatcher);
- if (watcher)
- return watcher.release_nonnull();
- return ENOMEM;
+ return adopt_nonnull_ref_or_enomem(new (nothrow) InodeWatcher);
}
InodeWatcher::~InodeWatcher()
diff --git a/Kernel/FileSystem/InodeWatcher.h b/Kernel/FileSystem/InodeWatcher.h
index e7dca21499..96fcece63f 100644
--- a/Kernel/FileSystem/InodeWatcher.h
+++ b/Kernel/FileSystem/InodeWatcher.h
@@ -43,7 +43,7 @@ private:
class InodeWatcher final : public File {
public:
- static KResultOr<NonnullRefPtr<InodeWatcher>> create();
+ static KResultOr<NonnullRefPtr<InodeWatcher>> try_create();
virtual ~InodeWatcher() override;
virtual bool can_read(const FileDescription&, size_t) const override;
diff --git a/Kernel/Syscalls/inode_watcher.cpp b/Kernel/Syscalls/inode_watcher.cpp
index f4b42d5b14..242e0fcbf5 100644
--- a/Kernel/Syscalls/inode_watcher.cpp
+++ b/Kernel/Syscalls/inode_watcher.cpp
@@ -23,7 +23,7 @@ KResultOr<FlatPtr> Process::sys$create_inode_watcher(u32 flags)
return fd_or_error.error();
auto inode_watcher_fd = fd_or_error.release_value();
- auto watcher_or_error = InodeWatcher::create();
+ auto watcher_or_error = InodeWatcher::try_create();
if (watcher_or_error.is_error())
return watcher_or_error.error();