mirror of
https://github.com/RGBCube/serenity
synced 2025-05-30 22:18:11 +00:00
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.
This commit is contained in:
parent
bad23e3f8c
commit
d7b6cc6421
21 changed files with 43 additions and 43 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue