Skip to content

rclcpp_components: Fix compilation with clang - #3229

Open
wentasah wants to merge 1 commit into
ros2:rollingfrom
wentasah:clang-fix
Open

rclcpp_components: Fix compilation with clang#3229
wentasah wants to merge 1 commit into
ros2:rollingfrom
wentasah:clang-fix

Conversation

@wentasah

Copy link
Copy Markdown

Description

This fixes the following error reported by clang:

/ros/rclcpp/rclcpp_components/src/component_container.cpp:204:50: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
  204 |   RCUTILS_LOG_DEBUG_NAMED("component_container", debug_msg.c_str());
      |                                                  ^~~~~~~~~~~~~~~~~
/nix/store/2xvm1s7bkzj40vswqm9ihlfmq7bxb291-ros-env/include/rcutils/rcutils/logging_macros.h:352:55: note: expanded from macro 'RCUTILS_LOG_DEBUG_NAMED'
  352 |   RCUTILS_LOG_NAMED(RCUTILS_LOG_SEVERITY_DEBUG, name, __VA_ARGS__)
      |                                                       ^~~~~~~~~~~
/nix/store/2xvm1s7bkzj40vswqm9ihlfmq7bxb291-ros-env/include/rcutils/rcutils/logging_macros.h:56:73: note: expanded from macro 'RCUTILS_LOG_NAMED'
   56 |       rcutils_log_internal(&__rcutils_logging_location, severity, name, __VA_ARGS__); \
      |                                                                         ^~~~~~~~~~~
/home/wsh/src/ros/rclcpp/rclcpp_components/src/component_container.cpp:204:50: note: treat the string as an argument to avoid this
  204 |   RCUTILS_LOG_DEBUG_NAMED("component_container", debug_msg.c_str());
      |                                                  ^
      |                                                  "%s",
/nix/store/2xvm1s7bkzj40vswqm9ihlfmq7bxb291-ros-env/include/rcutils/rcutils/logging_macros.h:352:55: note: expanded from macro 'RCUTILS_LOG_DEBUG_NAMED'
  352 |   RCUTILS_LOG_NAMED(RCUTILS_LOG_SEVERITY_DEBUG, name, __VA_ARGS__)
      |                                                       ^
/nix/store/2xvm1s7bkzj40vswqm9ihlfmq7bxb291-ros-env/include/rcutils/rcutils/logging_macros.h:56:73: note: expanded from macro 'RCUTILS_LOG_NAMED'
   56 |       rcutils_log_internal(&__rcutils_logging_location, severity, name, __VA_ARGS__); \
      |                                                                         ^

Is this user-facing behavior change?

No

Did you use Generative AI?

No

This fixes the following error reported by clang:

    /ros/rclcpp/rclcpp_components/src/component_container.cpp:204:50: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
      204 |   RCUTILS_LOG_DEBUG_NAMED("component_container", debug_msg.c_str());
          |                                                  ^~~~~~~~~~~~~~~~~
    /nix/store/2xvm1s7bkzj40vswqm9ihlfmq7bxb291-ros-env/include/rcutils/rcutils/logging_macros.h:352:55: note: expanded from macro 'RCUTILS_LOG_DEBUG_NAMED'
      352 |   RCUTILS_LOG_NAMED(RCUTILS_LOG_SEVERITY_DEBUG, name, __VA_ARGS__)
          |                                                       ^~~~~~~~~~~
    /nix/store/2xvm1s7bkzj40vswqm9ihlfmq7bxb291-ros-env/include/rcutils/rcutils/logging_macros.h:56:73: note: expanded from macro 'RCUTILS_LOG_NAMED'
       56 |       rcutils_log_internal(&__rcutils_logging_location, severity, name, __VA_ARGS__); \
          |                                                                         ^~~~~~~~~~~
    /home/wsh/src/ros/rclcpp/rclcpp_components/src/component_container.cpp:204:50: note: treat the string as an argument to avoid this
      204 |   RCUTILS_LOG_DEBUG_NAMED("component_container", debug_msg.c_str());
          |                                                  ^
          |                                                  "%s",
    /nix/store/2xvm1s7bkzj40vswqm9ihlfmq7bxb291-ros-env/include/rcutils/rcutils/logging_macros.h:352:55: note: expanded from macro 'RCUTILS_LOG_DEBUG_NAMED'
      352 |   RCUTILS_LOG_NAMED(RCUTILS_LOG_SEVERITY_DEBUG, name, __VA_ARGS__)
          |                                                       ^
    /nix/store/2xvm1s7bkzj40vswqm9ihlfmq7bxb291-ros-env/include/rcutils/rcutils/logging_macros.h:56:73: note: expanded from macro 'RCUTILS_LOG_NAMED'
       56 |       rcutils_log_internal(&__rcutils_logging_location, severity, name, __VA_ARGS__); \
          |                                                                         ^

Signed-off-by: Michal Sojka <michal.sojka@cvut.cz>
@mergify

mergify Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@skyegalaxy

Copy link
Copy Markdown
Member

Pulls: #3229
Gist: https://gist.githubusercontent.com/skyegalaxy/285b9f76733e715e934918936a618bbb/raw/a7fd6608e5126605b55c225d0483986898c4111d/ros2.repos
BUILD args: --packages-above-and-dependencies rclcpp
TEST args: --packages-above rclcpp
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/20089

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants