mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-29 04:37:55 +00:00
AK: Stop allowing implicit downcast with RefPtr and NonnullRefPtr
We were allowing this dangerous kind of thing:
RefPtr<Base> base;
RefPtr<Derived> derived = base;
This patch changes the {Nonnull,}RefPtr constructors so this is no
longer possible.
To downcast one of these pointers, there is now static_ptr_cast<T>:
RefPtr<Derived> derived = static_ptr_cast<Derived>(base);
Fixing this exposed a ton of cowboy-downcasts in various places,
which we're now forced to fix. :^)
This commit is contained in:
@@ -307,8 +307,8 @@ KResult TmpFSInode::add_child(InodeIdentifier child_id, const StringView& name,
|
||||
|
||||
String owned_name = name;
|
||||
FS::DirectoryEntry entry = { owned_name.characters(), owned_name.length(), child_id, 0 };
|
||||
RefPtr<Inode> child_tmp = fs().get_inode(child_id);
|
||||
NonnullRefPtr<TmpFSInode> child = static_cast<NonnullRefPtr<TmpFSInode>>(child_tmp.release_nonnull());
|
||||
auto child_tmp = fs().get_inode(child_id);
|
||||
auto child = static_ptr_cast<TmpFSInode>(child_tmp.release_nonnull());
|
||||
|
||||
m_children.set(owned_name, { entry, move(child) });
|
||||
set_metadata_dirty(true);
|
||||
|
||||
Reference in New Issue
Block a user