瀏覽代碼

Kernel/DevPtsFS: Add tightly typed DevPtsFSInode::fs()

Andreas Kling 3 年之前
父節點
當前提交
fc0cd8317a
共有 2 個文件被更改,包括 4 次插入3 次删除
  1. 1 3
      Kernel/FileSystem/DevPtsFS.cpp
  2. 3 0
      Kernel/FileSystem/DevPtsFS.h

+ 1 - 3
Kernel/FileSystem/DevPtsFS.cpp

@@ -145,11 +145,9 @@ KResultOr<NonnullRefPtr<Inode>> DevPtsFSInode::lookup(StringView name)
     if (name == "." || name == "..")
     if (name == "." || name == "..")
         return *this;
         return *this;
 
 
-    auto& fs = static_cast<DevPtsFS&>(this->fs());
-
     auto pty_index = name.to_uint();
     auto pty_index = name.to_uint();
     if (pty_index.has_value() && s_ptys->contains(pty_index.value())) {
     if (pty_index.has_value() && s_ptys->contains(pty_index.value())) {
-        auto inode = fs.get_inode({ fsid(), pty_index_to_inode_index(pty_index.value()) });
+        auto inode = fs().get_inode({ fsid(), pty_index_to_inode_index(pty_index.value()) });
         if (!inode)
         if (!inode)
             return ENOENT;
             return ENOENT;
         return inode.release_nonnull();
         return inode.release_nonnull();

+ 3 - 0
Kernel/FileSystem/DevPtsFS.h

@@ -43,6 +43,9 @@ class DevPtsFSInode final : public Inode {
 public:
 public:
     virtual ~DevPtsFSInode() override;
     virtual ~DevPtsFSInode() override;
 
 
+    DevPtsFS& fs() { return static_cast<DevPtsFS&>(Inode::fs()); }
+    DevPtsFS const& fs() const { return static_cast<DevPtsFS const&>(Inode::fs()); }
+
 private:
 private:
     DevPtsFSInode(DevPtsFS&, InodeIndex, SlavePTY*);
     DevPtsFSInode(DevPtsFS&, InodeIndex, SlavePTY*);