mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 23:37:43 +00:00
Kernel: Tidy up InodeWatcher construction
- Rename create() => try_create() - Use adopt_nonnull_ref_or_enomem()
This commit is contained in:
parent
393229e2aa
commit
68a6d4c30a
3 changed files with 4 additions and 7 deletions
|
@ -12,12 +12,9 @@
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
KResultOr<NonnullRefPtr<InodeWatcher>> InodeWatcher::create()
|
KResultOr<NonnullRefPtr<InodeWatcher>> InodeWatcher::try_create()
|
||||||
{
|
{
|
||||||
auto watcher = adopt_ref_if_nonnull(new (nothrow) InodeWatcher);
|
return adopt_nonnull_ref_or_enomem(new (nothrow) InodeWatcher);
|
||||||
if (watcher)
|
|
||||||
return watcher.release_nonnull();
|
|
||||||
return ENOMEM;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InodeWatcher::~InodeWatcher()
|
InodeWatcher::~InodeWatcher()
|
||||||
|
|
|
@ -43,7 +43,7 @@ private:
|
||||||
|
|
||||||
class InodeWatcher final : public File {
|
class InodeWatcher final : public File {
|
||||||
public:
|
public:
|
||||||
static KResultOr<NonnullRefPtr<InodeWatcher>> create();
|
static KResultOr<NonnullRefPtr<InodeWatcher>> try_create();
|
||||||
virtual ~InodeWatcher() override;
|
virtual ~InodeWatcher() override;
|
||||||
|
|
||||||
virtual bool can_read(const FileDescription&, size_t) const override;
|
virtual bool can_read(const FileDescription&, size_t) const override;
|
||||||
|
|
|
@ -23,7 +23,7 @@ KResultOr<FlatPtr> Process::sys$create_inode_watcher(u32 flags)
|
||||||
return fd_or_error.error();
|
return fd_or_error.error();
|
||||||
auto inode_watcher_fd = fd_or_error.release_value();
|
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())
|
if (watcher_or_error.is_error())
|
||||||
return watcher_or_error.error();
|
return watcher_or_error.error();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue