autowarefoundation / autoware.universe

https://autowarefoundation.github.io/autoware.universe/
Apache License 2.0
1.02k stars 652 forks source link

fix(autoware_trajectory_follower_node): fix clang-diagnostic-format-security #9378

Closed veqcc closed 1 week ago

veqcc commented 1 week ago

Description

Use string format.

This solves the following clang-tidy error

clang-tidy-14 --use-color -p=build/ /home/veqcc/work/autoware/src/universe/autoware.universe/control/autoware_trajectory_follower_node/src/controller_node.cpp
/home/veqcc/work/autoware/src/universe/autoware.universe/control/autoware_trajectory_follower_node/src/controller_node.cpp:146:73: error: format string is not a string literal (potentially insecure) [clang-diagnostic-format-security]
    RCLCPP_INFO_THROTTLE(get_logger(), clock, logger_throttle_interval, msg.c_str());
                                                                        ^
/opt/ros/humble/include/rclcpp/rclcpp/logging.hpp:671:7: note: expanded from macro 'RCLCPP_INFO_THROTTLE'
      __VA_ARGS__); \
      ^~~~~~~~~~~
/opt/ros/humble/include/rcutils/rcutils/logging_macros.h:680:5: note: expanded from macro 'RCUTILS_LOG_INFO_THROTTLE_NAMED'
    __VA_ARGS__)
    ^~~~~~~~~~~
/opt/ros/humble/include/rcutils/rcutils/logging_macros.h:79:64: note: expanded from macro 'RCUTILS_LOG_COND_NAMED'
      rcutils_log(&__rcutils_logging_location, severity, name, __VA_ARGS__); \
                                                               ^~~~~~~~~~~
/home/veqcc/work/autoware/src/universe/autoware.universe/control/autoware_trajectory_follower_node/src/controller_node.cpp:146:73: note: treat the string as an argument to avoid this
    RCLCPP_INFO_THROTTLE(get_logger(), clock, logger_throttle_interval, msg.c_str());
                                                                        ^
                                                                        "%s", 
/opt/ros/humble/include/rclcpp/rclcpp/logging.hpp:671:7: note: expanded from macro 'RCLCPP_INFO_THROTTLE'
      __VA_ARGS__); \
      ^
/opt/ros/humble/include/rcutils/rcutils/logging_macros.h:680:5: note: expanded from macro 'RCUTILS_LOG_INFO_THROTTLE_NAMED'
    __VA_ARGS__)
    ^
/opt/ros/humble/include/rcutils/rcutils/logging_macros.h:79:64: note: expanded from macro 'RCUTILS_LOG_COND_NAMED'
      rcutils_log(&__rcutils_logging_location, severity, name, __VA_ARGS__); \
                                                               ^
1 error generated.
Error while processing /home/veqcc/work/autoware/src/universe/autoware.universe/control/autoware_trajectory_follower_node/src/controller_node.cpp.
Found compiler error(s).

Related links

Parent Issue:

How was this PR tested?

Notes for reviewers

None.

Interface changes

None.

Effects on system behavior

None.

github-actions[bot] commented 1 week ago

Thank you for contributing to the Autoware project!

🚧 If your pull request is in progress, switch it to draft mode.

Please ensure:

codecov[bot] commented 1 week ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 29.78%. Comparing base (a0c4ab4) to head (3112ff9). Report is 26 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #9378 +/- ## ========================================== - Coverage 29.79% 29.78% -0.01% ========================================== Files 1338 1338 Lines 103211 103227 +16 Branches 40212 40214 +2 ========================================== Hits 30748 30748 - Misses 69477 69492 +15 - Partials 2986 2987 +1 ``` | [Flag](https://app.codecov.io/gh/autowarefoundation/autoware.universe/pull/9378/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=autowarefoundation) | Coverage Δ | | *Carryforward flag | |---|---|---|---| | [differential](https://app.codecov.io/gh/autowarefoundation/autoware.universe/pull/9378/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=autowarefoundation) | `30.61% <100.00%> (?)` | | | | [total](https://app.codecov.io/gh/autowarefoundation/autoware.universe/pull/9378/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=autowarefoundation) | `29.79% <ø> (-0.01%)` | :arrow_down: | Carriedforward from [a0c4ab4](https://app.codecov.io/gh/autowarefoundation/autoware.universe/commit/a0c4ab45d78f64ef9c7c1022af2c8f61682ae32a?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=autowarefoundation) | *This pull request uses carry forward flags. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=autowarefoundation) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.


🚨 Try these New Features: