Skip to content

Commit

Permalink
Add -Werror=missing-braces to compile options (#1423)
Browse files Browse the repository at this point in the history
  • Loading branch information
saikishor authored Mar 2, 2024
1 parent 81b67a1 commit a7af60b
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 29 deletions.
3 changes: 2 additions & 1 deletion controller_interface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ cmake_minimum_required(VERSION 3.16)
project(controller_interface LANGUAGES CXX)

if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra -Werror=conversion -Werror=unused-but-set-variable -Werror=return-type -Werror=shadow)
add_compile_options(-Wall -Wextra -Werror=conversion -Werror=unused-but-set-variable -Werror=return-type -Werror=shadow
-Werror=missing-braces)
endif()

set(THIS_PACKAGE_INCLUDE_DEPENDS
Expand Down
8 changes: 4 additions & 4 deletions controller_interface/test/test_force_torque_sensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ class ForceTorqueSensorTest : public ::testing::Test
protected:
const size_t size_ = 6;
const std::string sensor_name_ = "test_FTS";
std::array<double, 3> force_values_ = {1.1, 2.2, 3.3};
std::array<double, 3> torque_values_ = {4.4, 5.5, 6.6};
std::array<double, 3> force_values_ = {{1.1, 2.2, 3.3}};
std::array<double, 3> torque_values_ = {{4.4, 5.5, 6.6}};
std::unique_ptr<TestableForceTorqueSensor> force_torque_sensor_;

std::vector<std::string> full_interface_names_;
const std::vector<std::string> fts_interface_names_ = {"force.x", "force.y", "force.z",
"torque.x", "torque.y", "torque.z"};
const std::vector<std::string> fts_interface_names_ = {
{"force.x", "force.y", "force.z", "torque.x", "torque.y", "torque.z"}};
};

#endif // TEST_FORCE_TORQUE_SENSOR_HPP_
6 changes: 3 additions & 3 deletions controller_interface/test/test_imu_sensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ class IMUSensorTest : public ::testing::Test
protected:
const size_t size_ = 10;
const std::string sensor_name_ = "test_IMU";
std::array<double, 4> orientation_values_ = {1.1, 2.2, 3.3, 4.4};
std::array<double, 3> angular_velocity_values_ = {4.4, 5.5, 6.6};
std::array<double, 3> linear_acceleration_values_ = {4.4, 5.5, 6.6};
std::array<double, 4> orientation_values_ = {{1.1, 2.2, 3.3, 4.4}};
std::array<double, 3> angular_velocity_values_ = {{4.4, 5.5, 6.6}};
std::array<double, 3> linear_acceleration_values_ = {{4.4, 5.5, 6.6}};
std::unique_ptr<TestableIMUSensor> imu_sensor_;

std::vector<std::string> full_interface_names_;
Expand Down
3 changes: 2 additions & 1 deletion controller_manager/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ cmake_minimum_required(VERSION 3.16)
project(controller_manager LANGUAGES CXX)

if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra -Werror=conversion -Werror=unused-but-set-variable -Werror=return-type -Werror=shadow)
add_compile_options(-Wall -Wextra -Werror=conversion -Werror=unused-but-set-variable -Werror=return-type -Werror=shadow
-Werror=missing-braces)
endif()

set(THIS_PACKAGE_INCLUDE_DEPENDS
Expand Down
3 changes: 2 additions & 1 deletion hardware_interface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ cmake_minimum_required(VERSION 3.16)
project(hardware_interface LANGUAGES CXX)

if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra -Werror=conversion -Werror=unused-but-set-variable -Werror=return-type -Werror=shadow)
add_compile_options(-Wall -Wextra -Werror=conversion -Werror=unused-but-set-variable -Werror=return-type -Werror=shadow
-Werror=missing-braces)
endif()

set(THIS_PACKAGE_INCLUDE_DEPENDS
Expand Down
10 changes: 5 additions & 5 deletions hardware_interface/test/test_component_interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,12 @@ class DummySystem : public hardware_interface::SystemInterface

private:
std::array<double, 3> position_state_ = {
std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(),
std::numeric_limits<double>::quiet_NaN()};
{std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(),
std::numeric_limits<double>::quiet_NaN()}};
std::array<double, 3> velocity_state_ = {
std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(),
std::numeric_limits<double>::quiet_NaN()};
std::array<double, 3> velocity_command_ = {0.0, 0.0, 0.0};
{std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(),
std::numeric_limits<double>::quiet_NaN()}};
std::array<double, 3> velocity_command_ = {{0.0, 0.0, 0.0}};

// Helper variables to initiate error on read
unsigned int read_calls_ = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,11 @@ class TestSystemCommandModes : public hardware_interface::SystemInterface
std::vector<std::string> start_modes_ = {"position", "position"};
std::vector<bool> stop_modes_ = {false, false};

std::array<double, 2> position_command_ = {0.0, 0.0};
std::array<double, 2> velocity_command_ = {0.0, 0.0};
std::array<double, 2> position_state_ = {0.0, 0.0};
std::array<double, 2> velocity_state_ = {0.0, 0.0};
std::array<double, 2> acceleration_state_ = {0.0, 0.0};
std::array<double, 2> position_command_ = {{0.0, 0.0}};
std::array<double, 2> velocity_command_ = {{0.0, 0.0}};
std::array<double, 2> position_state_ = {{0.0, 0.0}};
std::array<double, 2> velocity_state_ = {{0.0, 0.0}};
std::array<double, 2> acceleration_state_ = {{0.0, 0.0}};
};

} // namespace test_hardware_components
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ class TestTwoJointSystem : public SystemInterface
}

private:
std::array<double, 2> position_command_ = {0.0, 0.0};
std::array<double, 2> position_state_ = {0.0, 0.0};
std::array<double, 2> position_command_ = {{0.0, 0.0}};
std::array<double, 2> position_state_ = {{0.0, 0.0}};
};

} // namespace test_hardware_components
Expand Down
3 changes: 2 additions & 1 deletion hardware_interface_testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ cmake_minimum_required(VERSION 3.16)
project(hardware_interface_testing LANGUAGES CXX)

if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra -Werror=conversion -Werror=unused-but-set-variable -Werror=return-type -Werror=shadow)
add_compile_options(-Wall -Wextra -Werror=conversion -Werror=unused-but-set-variable -Werror=return-type -Werror=shadow
-Werror=missing-braces)
endif()

set(THIS_PACKAGE_INCLUDE_DEPENDS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ class TestSystem : public SystemInterface
}

private:
std::array<double, 2> velocity_command_ = {0.0, 0.0};
std::array<double, 2> position_state_ = {0.0, 0.0};
std::array<double, 2> velocity_state_ = {0.0, 0.0};
std::array<double, 2> acceleration_state_ = {0.0, 0.0};
std::array<double, 2> velocity_command_ = {{0.0, 0.0}};
std::array<double, 2> position_state_ = {{0.0, 0.0}};
std::array<double, 2> velocity_state_ = {{0.0, 0.0}};
std::array<double, 2> acceleration_state_ = {{0.0, 0.0}};
double max_acceleration_command_ = 0.0;
double configuration_state_ = 0.0;
double configuration_command_ = 0.0;
Expand Down
3 changes: 2 additions & 1 deletion joint_limits/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ cmake_minimum_required(VERSION 3.16)
project(joint_limits LANGUAGES CXX)

if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra -Werror=conversion -Werror=unused-but-set-variable -Werror=return-type -Werror=shadow)
add_compile_options(-Wall -Wextra -Werror=conversion -Werror=unused-but-set-variable -Werror=return-type -Werror=shadow
-Werror=missing-braces)
endif()

set(THIS_PACKAGE_INCLUDE_DEPENDS
Expand Down
3 changes: 2 additions & 1 deletion transmission_interface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ cmake_minimum_required(VERSION 3.16)
project(transmission_interface LANGUAGES CXX)

if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra -Werror=conversion -Werror=unused-but-set-variable -Werror=return-type -Werror=shadow)
add_compile_options(-Wall -Wextra -Werror=conversion -Werror=unused-but-set-variable -Werror=return-type -Werror=shadow
-Werror=missing-braces)
endif()

set(THIS_PACKAGE_INCLUDE_DEPENDS
Expand Down

0 comments on commit a7af60b

Please sign in to comment.