From 68a6d4c30ac0154e844e06db6de203775d786112 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 4 Sep 2021 23:52:39 +0200 Subject: [PATCH] Kernel: Tidy up InodeWatcher construction - Rename create() => try_create() - Use adopt_nonnull_ref_or_enomem() --- Kernel/FileSystem/InodeWatcher.cpp | 7 ++----- Kernel/FileSystem/InodeWatcher.h | 2 +- Kernel/Syscalls/inode_watcher.cpp | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Kernel/FileSystem/InodeWatcher.cpp b/Kernel/FileSystem/InodeWatcher.cpp index f8b30e993e9..8edd88092f6 100644 --- a/Kernel/FileSystem/InodeWatcher.cpp +++ b/Kernel/FileSystem/InodeWatcher.cpp @@ -12,12 +12,9 @@ namespace Kernel { -KResultOr> InodeWatcher::create() +KResultOr> 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 e7dca214999..96fcece63fd 100644 --- a/Kernel/FileSystem/InodeWatcher.h +++ b/Kernel/FileSystem/InodeWatcher.h @@ -43,7 +43,7 @@ private: class InodeWatcher final : public File { public: - static KResultOr> create(); + static KResultOr> 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 f4b42d5b142..242e0fcbf5c 100644 --- a/Kernel/Syscalls/inode_watcher.cpp +++ b/Kernel/Syscalls/inode_watcher.cpp @@ -23,7 +23,7 @@ KResultOr 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();