Skip to content

Commit

Permalink
Make sure to check typesupport handles against nullptr properly. (#119)
Browse files Browse the repository at this point in the history
clang has a false-positive warning where it can't figure out
that ASSERT_TRUE(foo != nullptr) means that the rest of the
test is safe to dereference foo.  Switching to ASSERT_NE(foo, nullptr)
fixes the issue, so do that here.  This should get rid of a
number of warnings when building under clang static analysis.

Signed-off-by: Chris Lalancette <[email protected]>
  • Loading branch information
clalancette authored Oct 14, 2021
1 parent 120f4d9 commit 34f6e4b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ TEST(TestMessageTypeSupportDispatch, get_handle_function) {
ASSERT_NE(support_map.data[0], nullptr);
auto * clib = static_cast<const rcpputils::SharedLibrary *>(support_map.data[0]);
auto * lib = const_cast<rcpputils::SharedLibrary *>(clib);
ASSERT_TRUE(nullptr != lib);
ASSERT_NE(lib, nullptr);

EXPECT_TRUE(lib->has_symbol("test_message_type_support"));
auto * sym = lib->get_symbol("test_message_type_support");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ TEST(TestServiceTypeSupportDispatch, get_handle_function) {
ASSERT_NE(support_map.data[0], nullptr);
auto * clib = static_cast<const rcpputils::SharedLibrary *>(support_map.data[0]);
auto * lib = const_cast<rcpputils::SharedLibrary *>(clib);
ASSERT_TRUE(nullptr != lib);
ASSERT_NE(lib, nullptr);

EXPECT_TRUE(lib->has_symbol("test_service_type_support"));
auto * sym = lib->get_symbol("test_service_type_support");
Expand Down

0 comments on commit 34f6e4b

Please sign in to comment.