Skip to content

Commit

Permalink
Add -Wconversion flag to protect future developments (#1053)
Browse files Browse the repository at this point in the history
(cherry picked from commit 1b83a5b)

# Conflicts:
#	controller_interface/CMakeLists.txt
#	controller_manager/CMakeLists.txt
#	hardware_interface/CMakeLists.txt
#	joint_limits/CMakeLists.txt
#	transmission_interface/CMakeLists.txt
#	transmission_interface/test/random_generator_utils.hpp
  • Loading branch information
gwalck authored and mergify[bot] committed Oct 26, 2024
1 parent 8bf8a6c commit 93e9987
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 2 deletions.
5 changes: 5 additions & 0 deletions controller_interface/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
cmake_minimum_required(VERSION 3.5)
project(controller_interface)

<<<<<<< HEAD
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra)
=======
if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra -Wconversion)
>>>>>>> 1b83a5b (Add -Wconversion flag to protect future developments (#1053))
endif()

find_package(ament_cmake REQUIRED)
Expand Down
5 changes: 5 additions & 0 deletions controller_manager/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
cmake_minimum_required(VERSION 3.5)
project(controller_manager)

<<<<<<< HEAD
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra)
=======
if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra -Wconversion)
>>>>>>> 1b83a5b (Add -Wconversion flag to protect future developments (#1053))
endif()

set(THIS_PACKAGE_INCLUDE_DEPENDS
Expand Down
5 changes: 5 additions & 0 deletions hardware_interface/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
cmake_minimum_required(VERSION 3.5)
project(hardware_interface)

<<<<<<< HEAD
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra)
=======
if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra -Wconversion)
>>>>>>> 1b83a5b (Add -Wconversion flag to protect future developments (#1053))
endif()

set(THIS_PACKAGE_INCLUDE_DEPENDS
Expand Down
6 changes: 4 additions & 2 deletions hardware_interface/src/component_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,8 @@ ComponentInfo parse_complex_component_from_xml(const tinyxml2::XMLElement * comp
component.command_interfaces.push_back(parse_interfaces_from_xml(command_interfaces_it));
component.command_interfaces.back().data_type =
parse_data_type_attribute(command_interfaces_it);
component.command_interfaces.back().size = parse_size_attribute(command_interfaces_it);
component.command_interfaces.back().size =
static_cast<int>(parse_size_attribute(command_interfaces_it));
command_interfaces_it = command_interfaces_it->NextSiblingElement(kCommandInterfaceTag);
}

Expand All @@ -358,7 +359,8 @@ ComponentInfo parse_complex_component_from_xml(const tinyxml2::XMLElement * comp
{
component.state_interfaces.push_back(parse_interfaces_from_xml(state_interfaces_it));
component.state_interfaces.back().data_type = parse_data_type_attribute(state_interfaces_it);
component.state_interfaces.back().size = parse_size_attribute(state_interfaces_it);
component.state_interfaces.back().size =
static_cast<int>(parse_size_attribute(state_interfaces_it));
state_interfaces_it = state_interfaces_it->NextSiblingElement(kStateInterfaceTag);
}

Expand Down
5 changes: 5 additions & 0 deletions joint_limits/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
cmake_minimum_required(VERSION 3.5)
project(joint_limits)

<<<<<<< HEAD
# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra)
=======
if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra -Wconversion)
>>>>>>> 1b83a5b (Add -Wconversion flag to protect future developments (#1053))
endif()

find_package(ament_cmake REQUIRED)
Expand Down
5 changes: 5 additions & 0 deletions transmission_interface/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
cmake_minimum_required(VERSION 3.5)
project(transmission_interface)

<<<<<<< HEAD
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
=======
if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra -Wpedantic -Wconversion)
>>>>>>> 1b83a5b (Add -Wconversion flag to protect future developments (#1053))
endif()

set(THIS_PACKAGE_INCLUDE_DEPENDS
Expand Down
4 changes: 4 additions & 0 deletions transmission_interface/test/random_generator_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ struct RandomDoubleGenerator
RandomDoubleGenerator(double min_val, double max_val, unsigned int seed = 1234)
: min_val_(min_val), max_val_(max_val)
{
<<<<<<< HEAD
srand(seed);
=======
srand(static_cast<unsigned int>(time(nullptr)));
>>>>>>> 1b83a5b (Add -Wconversion flag to protect future developments (#1053))
}
double operator()()
{
Expand Down

0 comments on commit 93e9987

Please sign in to comment.