Skip to content

Commit

Permalink
add-Wnull-dereference and fix warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>
  • Loading branch information
Ryanf55 committed Jun 10, 2023
1 parent 4bbba4b commit 63030ae
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion nav2_common/cmake/nav2_package.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ macro(nav2_package)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic -Werror -Wdeprecated -fPIC )
add_compile_options(-Wall -Wextra -Wpedantic -Werror -Wdeprecated -fPIC -Wnull-dereference)
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:-Wnon-virtual-dtor>")
endif()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,10 @@ class GroupsRemover
// The group of pixels labeled 0 corresponds to empty map cells.
// Zero bin of the histogram is equal to the number of pixels in this group.
// Because the values of empty map cells should not be changed, we will reset this bin
groups_sizes.front() = 0; // don't change image background value
if (!groups_sizes.empty()) {
groups_sizes.front() = 0; // don't change image background value
}


// noise_labels_table[i] = true if group with label i is noise
std::vector<bool> noise_labels_table(groups_sizes.size());
Expand Down
14 changes: 12 additions & 2 deletions nav2_mppi_controller/test/critic_manager_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,22 @@ class CriticManagerWrapper : public CriticManager

bool getDummyCriticInitialized()
{
return dynamic_cast<DummyCritic *>(critics_[0].get())->initialized_;
const auto critic = critics_[0].get();
if (critic == nullptr) {
return false;
}
const auto dummy_critic = dynamic_cast<DummyCritic *>(critic);
return dummy_critic == nullptr ? false : dummy_critic->initialized_;
}

bool getDummyCriticScored()
{
return dynamic_cast<DummyCritic *>(critics_[0].get())->scored_;
const auto critic = critics_[0].get();
if (critic == nullptr) {
return false;
}
const auto dummy_critic = dynamic_cast<DummyCritic *>(critic);
return dummy_critic == nullptr ? false : dummy_critic->scored_;
}
};

Expand Down

0 comments on commit 63030ae

Please sign in to comment.