From 34f6e4b5296704c598037cb07299b12339afa8ab Mon Sep 17 00:00:00 2001 From: Chris Lalancette Date: Thu, 14 Oct 2021 08:25:48 -0400 Subject: [PATCH] Make sure to check typesupport handles against nullptr properly. (#119) 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 --- .../test/test_message_type_support_dispatch.cpp | 2 +- .../test/test_service_type_support_dispatch.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rosidl_typesupport_cpp/test/test_message_type_support_dispatch.cpp b/rosidl_typesupport_cpp/test/test_message_type_support_dispatch.cpp index e41b1862..4cf12ea9 100644 --- a/rosidl_typesupport_cpp/test/test_message_type_support_dispatch.cpp +++ b/rosidl_typesupport_cpp/test/test_message_type_support_dispatch.cpp @@ -102,7 +102,7 @@ TEST(TestMessageTypeSupportDispatch, get_handle_function) { ASSERT_NE(support_map.data[0], nullptr); auto * clib = static_cast(support_map.data[0]); auto * lib = const_cast(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"); diff --git a/rosidl_typesupport_cpp/test/test_service_type_support_dispatch.cpp b/rosidl_typesupport_cpp/test/test_service_type_support_dispatch.cpp index e5ddeeee..aae3fc4c 100644 --- a/rosidl_typesupport_cpp/test/test_service_type_support_dispatch.cpp +++ b/rosidl_typesupport_cpp/test/test_service_type_support_dispatch.cpp @@ -102,7 +102,7 @@ TEST(TestServiceTypeSupportDispatch, get_handle_function) { ASSERT_NE(support_map.data[0], nullptr); auto * clib = static_cast(support_map.data[0]); auto * lib = const_cast(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");