summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem/ProcFS.cpp
diff options
context:
space:
mode:
authorDaniel Bertalan <dani@danielbertalan.dev>2021-09-03 19:11:51 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-03 23:20:23 +0200
commitd7b6cc6421c48185f4dfafb24d2b093b86305860 (patch)
tree7e5ace9318b73d4efe095c43605cd514db1cccaa /Kernel/FileSystem/ProcFS.cpp
parentbad23e3f8cc9c66d818ddb2f7bbe7bddce5c09e2 (diff)
downloadserenity-d7b6cc6421c48185f4dfafb24d2b093b86305860.zip
Everywhere: Prevent risky implicit casts of (Nonnull)RefPtr
Our existing implementation did not check the element type of the other pointer in the constructors and move assignment operators. This meant that some operations that would require explicit casting on raw pointers were done implicitly, such as: - downcasting a base class to a derived class (e.g. `Kernel::Inode` => `Kernel::ProcFSDirectoryInode` in Kernel/ProcFS.cpp), - casting to an unrelated type (e.g. `Promise<bool>` => `Promise<Empty>` in LibIMAP/Client.cpp) This, of course, allows gross violations of the type system, and makes the need to type-check less obvious before downcasting. Luckily, while adding the `static_ptr_cast`s, only two truly incorrect usages were found; in the other instances, our casts just needed to be made explicit.
Diffstat (limited to 'Kernel/FileSystem/ProcFS.cpp')
-rw-r--r--Kernel/FileSystem/ProcFS.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp
index fb5e51d068..176bfb04f9 100644
--- a/Kernel/FileSystem/ProcFS.cpp
+++ b/Kernel/FileSystem/ProcFS.cpp
@@ -55,7 +55,7 @@ KResult ProcFS::initialize()
auto root_inode = ProcFSComponentRegistry::the().root_directory().to_inode(*this);
if (root_inode.is_error())
return root_inode.error();
- m_root_inode = static_cast<NonnullRefPtr<ProcFSDirectoryInode>>(root_inode.release_value());
+ m_root_inode = static_ptr_cast<ProcFSDirectoryInode>(root_inode.release_value());
return KSuccess;
}