From 6330863bd04195315efac648d02832b7f12aeb3b Mon Sep 17 00:00:00 2001 From: Arnau Ochoa Date: Thu, 30 May 2024 09:40:43 +0200 Subject: [PATCH] Fix missing constructor, cast type and add warnings (#56) * Added missing constructor in NavSatStatusData * fixed static_cast type * build with more warnings --------- Co-authored-by: Arnau --- fixposition_driver_lib/CMakeLists.txt | 3 ++- .../include/fixposition_driver_lib/msg_data.hpp | 1 + fixposition_driver_lib/src/helper.cpp | 6 +++--- fixposition_driver_ros1/CMakeLists.txt | 3 ++- fixposition_driver_ros2/CMakeLists.txt | 3 ++- fixposition_odometry_converter_ros1/CMakeLists.txt | 3 ++- fixposition_odometry_converter_ros2/CMakeLists.txt | 7 ++++--- 7 files changed, 16 insertions(+), 10 deletions(-) diff --git a/fixposition_driver_lib/CMakeLists.txt b/fixposition_driver_lib/CMakeLists.txt index b1b35af..38d134f 100644 --- a/fixposition_driver_lib/CMakeLists.txt +++ b/fixposition_driver_lib/CMakeLists.txt @@ -3,7 +3,8 @@ cmake_minimum_required(VERSION 3.5) project(fixposition_driver_lib VERSION 5.0.0 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 14) set(CMAKE_BUILD_TYPE "Release") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always -Wall -Wextra -Wpedantic -Wno-unused-parameter") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic\ + -Wshadow -Wunused-parameter -Wformat -Wpointer-arith") set(CMAKE_CXX_FLAGS_RELEASE "-O3") set(CMAKE_EXPORT_COMPILE_COMMANDS ON) diff --git a/fixposition_driver_lib/include/fixposition_driver_lib/msg_data.hpp b/fixposition_driver_lib/include/fixposition_driver_lib/msg_data.hpp index a4ed53c..20789af 100644 --- a/fixposition_driver_lib/include/fixposition_driver_lib/msg_data.hpp +++ b/fixposition_driver_lib/include/fixposition_driver_lib/msg_data.hpp @@ -117,6 +117,7 @@ struct NavSatStatusData { }; int8_t status; uint16_t service; + NavSatStatusData() : status(static_cast(Status::STATUS_NO_FIX)), service(0) {} }; struct NavSatFixData { diff --git a/fixposition_driver_lib/src/helper.cpp b/fixposition_driver_lib/src/helper.cpp index 2543f9b..fecb209 100644 --- a/fixposition_driver_lib/src/helper.cpp +++ b/fixposition_driver_lib/src/helper.cpp @@ -43,14 +43,14 @@ void BestGnssPosToNavSatFix(const Oem7MessageHeaderMem* const header, const BEST switch (static_cast(bestgnsspos->pos_type)) { case PositionOrVelocityType::NARROW_INT: - navsatfix.status.status = static_cast(NavSatStatusData::Status::STATUS_GBAS_FIX); + navsatfix.status.status = static_cast(NavSatStatusData::Status::STATUS_GBAS_FIX); break; case PositionOrVelocityType::NARROW_FLOAT: case PositionOrVelocityType::SINGLE: - navsatfix.status.status = static_cast(NavSatStatusData::Status::STATUS_FIX); + navsatfix.status.status = static_cast(NavSatStatusData::Status::STATUS_FIX); break; default: - navsatfix.status.status = static_cast(NavSatStatusData::Status::STATUS_NO_FIX); + navsatfix.status.status = static_cast(NavSatStatusData::Status::STATUS_NO_FIX); } // TODO hardcoded for now for all 4 systems diff --git a/fixposition_driver_ros1/CMakeLists.txt b/fixposition_driver_ros1/CMakeLists.txt index 408b0d8..b1608b7 100644 --- a/fixposition_driver_ros1/CMakeLists.txt +++ b/fixposition_driver_ros1/CMakeLists.txt @@ -3,7 +3,8 @@ cmake_minimum_required(VERSION 3.5) project(fixposition_driver_ros1 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 14) set(CMAKE_BUILD_TYPE "Release") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always -Wall -Wextra -Wpedantic -Wno-unused-parameter") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic\ + -Wshadow -Wunused-parameter -Wformat -Wpointer-arith") set(CMAKE_CXX_FLAGS_RELEASE "-O3") set(CMAKE_EXPORT_COMPILE_COMMANDS ON) diff --git a/fixposition_driver_ros2/CMakeLists.txt b/fixposition_driver_ros2/CMakeLists.txt index f3c0f09..7bf698c 100644 --- a/fixposition_driver_ros2/CMakeLists.txt +++ b/fixposition_driver_ros2/CMakeLists.txt @@ -3,7 +3,8 @@ cmake_minimum_required(VERSION 3.5) project(fixposition_driver_ros2) set(CMAKE_CXX_STANDARD 14) set(CMAKE_BUILD_TYPE "Release") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always -Wall -Wextra -Wpedantic -Wno-unused-parameter") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic\ + -Wshadow -Wunused-parameter -Wformat -Wpointer-arith") set(CMAKE_CXX_FLAGS_RELEASE "-O3") set(CMAKE_EXPORT_COMPILE_COMMANDS ON) diff --git a/fixposition_odometry_converter_ros1/CMakeLists.txt b/fixposition_odometry_converter_ros1/CMakeLists.txt index 9de66b7..2498d69 100644 --- a/fixposition_odometry_converter_ros1/CMakeLists.txt +++ b/fixposition_odometry_converter_ros1/CMakeLists.txt @@ -3,7 +3,8 @@ cmake_minimum_required(VERSION 3.5) project(fixposition_odometry_converter_ros1 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 14) set(CMAKE_BUILD_TYPE "Release") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always -Wall -Wextra -Wpedantic -Wno-unused-parameter") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic\ + -Wshadow -Wunused-parameter -Wformat -Wpointer-arith") set(CMAKE_CXX_FLAGS_RELEASE "-O3") set(CMAKE_EXPORT_COMPILE_COMMANDS ON) diff --git a/fixposition_odometry_converter_ros2/CMakeLists.txt b/fixposition_odometry_converter_ros2/CMakeLists.txt index cee1bf0..beaaf2a 100644 --- a/fixposition_odometry_converter_ros2/CMakeLists.txt +++ b/fixposition_odometry_converter_ros2/CMakeLists.txt @@ -3,7 +3,8 @@ cmake_minimum_required(VERSION 3.10.2) project(fixposition_odometry_converter_ros2) set(CMAKE_CXX_STANDARD 14) set(CMAKE_BUILD_TYPE "Release") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always -Wall -Wextra -Wpedantic -Wno-unused-parameter") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic\ + -Wshadow -Wunused-parameter -Wformat -Wpointer-arith") set(CMAKE_CXX_FLAGS_RELEASE "-O3") set(CMAKE_EXPORT_COMPILE_COMMANDS ON) @@ -27,7 +28,7 @@ include_directories( ) # BUILD EXECUTABLE ===================================================================================================== -add_library(odom_converter SHARED +add_library(odom_converter SHARED src/params.cpp src/odom_converter_node.cpp) ament_target_dependencies(odom_converter ${PACKAGE_INCLUDE_DEPENDS}) @@ -49,4 +50,4 @@ install(DIRECTORY include DESTINATION . ) -ament_package() \ No newline at end of file +ament_package()