diff options
author | Daniel Bertalan <dani@danielbertalan.dev> | 2021-09-03 19:11:51 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-03 23:20:23 +0200 |
commit | d7b6cc6421c48185f4dfafb24d2b093b86305860 (patch) | |
tree | 7e5ace9318b73d4efe095c43605cd514db1cccaa /Tests | |
parent | bad23e3f8cc9c66d818ddb2f7bbe7bddce5c09e2 (diff) | |
download | serenity-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 'Tests')
-rw-r--r-- | Tests/LibSQL/TestSqlDatabase.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Tests/LibSQL/TestSqlDatabase.cpp b/Tests/LibSQL/TestSqlDatabase.cpp index 9c67267c5e..e57b7bd8a5 100644 --- a/Tests/LibSQL/TestSqlDatabase.cpp +++ b/Tests/LibSQL/TestSqlDatabase.cpp @@ -16,7 +16,7 @@ #include <LibTest/TestCase.h> NonnullRefPtr<SQL::SchemaDef> setup_schema(SQL::Database&); -NonnullRefPtr<SQL::SchemaDef> setup_table(SQL::Database&); +NonnullRefPtr<SQL::TableDef> setup_table(SQL::Database&); void insert_into_table(SQL::Database&, int); void verify_table_contents(SQL::Database&, int); void insert_and_verify(int); @@ -28,7 +28,7 @@ NonnullRefPtr<SQL::SchemaDef> setup_schema(SQL::Database& db) return schema; } -NonnullRefPtr<SQL::SchemaDef> setup_table(SQL::Database& db) +NonnullRefPtr<SQL::TableDef> setup_table(SQL::Database& db) { auto schema = setup_schema(db); auto table = SQL::TableDef::construct(schema, "TestTable"); |