ros2 / rclc

ROS Client Library for the C language.
Apache License 2.0
118 stars 42 forks source link

Fix string-format type mismatches #400

Open cliu5764 opened 9 months ago

cliu5764 commented 9 months ago

  Compiler warnings fixes: c files change string formats to match type.

Zard-C commented 9 months ago

Thanks for the fix! Btw, your commit message didn't pass the dco check,

To add your Signed-off-by line to every commit in this branch:

Ensure you have a local copy of your branch by [checking out the pull request locally via command line](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/checking-out-pull-requests-locally).
In your local branch, run: git rebase HEAD~1 --signoff
Force push your changes to overwrite the branch: git push --force-with-lease origin beechwoods_fixes
Zard-C commented 9 months ago

@JanStaschulat,Hi Dr Jan, if you have time could you please take a look at this PR? Thanks in advance

codecov-commenter commented 9 months ago

Codecov Report

Attention: Patch coverage is 0% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 69.20%. Comparing base (65d293d) to head (c4813b5).

Files Patch % Lines
rclc/src/rclc/timer.c 0.00% 0 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## humble #400 +/- ## ======================================= Coverage 69.20% 69.20% ======================================= Files 16 16 Lines 2715 2715 Branches 765 765 ======================================= Hits 1879 1879 Misses 450 450 Partials 386 386 ```

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

JanStaschulat commented 8 months ago

there is still the compiler warning on OpenRobotics build farm CI job:

format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘size_t’ {aka ‘long unsigned int’} [-Wformat=] 1836 | "Subscription added to wait_set_subscription[%d]", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1837 | executor->handles[i].index); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | size_t {aka long unsigned int}

https://build.ros2.org/job/Hpr__rclc__ubuntu_jammy_amd64/36/gcc/fileName.-1655778739/

cliu5764 commented 8 months ago

Here is the warning I see:

/b/mros/installer_no_patches/microros_ws/firmware/mcu_ws/uros/rclc/rclc/src/rclc/executor.c:1836:13: warning: format '%ld' expects argument of type 'long int', but argument 5 has type 'size_t' {aka 'unsigned int'} [-Wformat=]
 1836 |             "Subscription added to wait_set_subscription[%ld] ",
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1837 |             executor->handles[i].index);
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                 |
      |                                 size_t {aka unsigned int}
/b/mros/installer_no_patches/microros_ws/firmware/mcu_ws/uros/rclc/rclc/src/rclc/executor.c:1836:60: note: format string is defined here
 1836 |             "Subscription added to wait_set_subscription[%ld] ",
      |                                                          ~~^
      |                                                            |
      |                                                            long int
      |                                                          %d

%d work fine on me. maybe I should use %u, what do you think?

cliu5764 commented 8 months ago

Can someone why the build failed? Thanks

Zard-C commented 8 months ago

Can someone why the build failed? Thanks

Check this out https://build.ros2.org/job/Hpr__rclc__ubuntu_jammy_amd64/37/clang-tidy/new/fileName.-1655778739/

Build Status

cliu5764 commented 8 months ago

Can someone why the build failed? Thanks

Check this out https://build.ros2.org/job/Hpr__rclc__ubuntu_jammy_amd64/37/clang-tidy/new/fileName.-1655778739/

Build Status

I checked out the console log, I have no idea why the build got the following errors. Anyone knows?

01:58:54 No credentials specified
01:58:54  > git rev-parse fe02b94aeff734c4e120d3a063c725191ad3c43e^{commit} # timeout=10
01:58:54 [GNU C Compiler (gcc)] [-ERROR-] Can't create fingerprints for some files:
01:58:54 [GNU C Compiler (gcc)] [-ERROR-] - '/tmp/ws/src/rclc/rclc/src/rclc/timer.c', IO exception has been thrown: java.nio.file.NoSuchFileException: /tmp/ws/src/rclc/rclc/src/rclc/timer.c
01:58:54 [GNU C Compiler (gcc)] [-ERROR-] - '/tmp/ws/src/rclc/rclc/src/rclc/executor.c', IO exception has been thrown: java.nio.file.NoSuchFileException: /tmp/ws/src/rclc/rclc/src/rclc/executor.c
01:58:54 [GNU C Compiler (gcc)] [-ERROR-] - '/tmp/ws/src/rclc/rclc/src/rclc/executor.c', IO exception has been thrown: java.nio.file.NoSuchFileException: /tmp/ws/src/rclc/rclc/src/rclc/executor.c
01:58:54 [GNU C Compiler (gcc)] [-ERROR-] - '/tmp/ws/src/rclc/rclc/src/rclc/executor.c', IO exception has been thrown: java.nio.file.NoSuchFileException: /tmp/ws/src/rclc/rclc/src/rclc/executor.c
01:58:54 [GNU C Compiler (gcc)] [-ERROR-] - '/tmp/ws/src/rclc/rclc/src/rclc/executor.c', IO exception has been thrown: java.nio.file.NoSuchFileException: /tmp/ws/src/rclc/rclc/src/rclc/executor.c
01:58:54 [GNU C Compiler (gcc)] [-ERROR-] - '/tmp/ws/src/rclc/rclc/src/rclc/executor.c', IO exception has been thrown: java.nio.file.NoSuchFileException: /tmp/ws/src/rclc/rclc/src/rclc/executor.c
01:58:54 [GNU C Compiler (gcc)] [-ERROR-] - '/tmp/ws/src/rclc/rclc/src/rclc/executor.c', IO exception has been thrown: java.nio.file.NoSuchFileException: /tmp/ws/src/rclc/rclc/src/rclc/executor.c
01:58:54 [GNU C Compiler (gcc)] [-ERROR-] - '/tmp/ws/src/rclc/rclc/src/rclc/executor.c', IO exception has been thrown: java.nio.file.NoSuchFileException: /tmp/ws/src/rclc/rclc/src/rclc/executor.c
01:58:54 [GNU C Compiler (gcc)] [-ERROR-] - '/tmp/ws/src/rclc/rclc/src/rclc/executor.c', IO exception has been thrown: java.nio.file.NoSuchFileException: /tmp/ws/src/rclc/rclc/src/rclc/executor.c
01:58:55 [GNU C Compiler (gcc)] Post processing issues on 'agent-1ec510a6' with source code encoding 'UTF-8'
JanStaschulat commented 3 weeks ago

Hi @cliu5764, what is the status of this pull request?