Skip to content

Fix build warnings on Windows#390

Merged
MatthijsBurgh merged 5 commits intoorocos:masterfrom
jacobperron:fix_msbuild_warnings
Apr 2, 2022
Merged

Fix build warnings on Windows#390
MatthijsBurgh merged 5 commits intoorocos:masterfrom
jacobperron:fix_msbuild_warnings

Conversation

@jacobperron
Copy link
Copy Markdown
Contributor

@jacobperron jacobperron commented Apr 1, 2022

We noticed these warnings when building orocos_kdl as part of ROS 2 CI, see https://ci.ros2.org/job/ci_windows/16708/msbuild

I've triggered a new Windows build with the changes in this PR: Build Status

These were caught as MSBuild warnings on Windows.
In most cases, acknowledge that the conversions may lose precision by doing a static cast.
In one case we change the type of an argument to be more accurate.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
Fixes a MSBuild warning on Windows.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

// add the segments from the common frame to the tip frame
for (int s=parents_chain_tip.size()-1; s>-1; s--){
for (int s=static_cast<int>(parents_chain_tip.size())-1; s>-1; s--){
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not go for an unsigned int here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition for the loop is to check if s>-1, so it must be able to become negative.

Copy link
Copy Markdown
Collaborator

@MatthijsBurgh MatthijsBurgh Apr 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And if we check for s>=0?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If s is an unsigned int it cannot be negative, so s-- will cause an integer overflow and this will become an infinite loop.

I've updated the code to use a reverse iterator, which I think makes it more readable (3324420).

*/

TreeIkSolverPos_Online(const double& nr_of_jnts,
TreeIkSolverPos_Online(const unsigned int& nr_of_jnts,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an API breaking change. This has been discussed in #384. So I think we should skip this one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to avoid breaking API: d70e705

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why, but it looks like this change (d70e705) broke a test 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since most of the members we were initializing with this value where being overridden immediately in the constructor, I've just removed them from the initializer list (fc0dfd8). CI looks happy now.

Use static cast instead to avoid compiler warnings.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
They are set inside the constructor anyways.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
Signed-off-by: Jacob Perron <jacob@openrobotics.org>
@jacobperron
Copy link
Copy Markdown
Contributor Author

I guess CI is flaky? Since the same change passed CI on my fork: https://github.com/jacobperron/orocos_kinematics_dynamics/runs/5796424695?check_suite_focus=true

@MatthijsBurgh
Copy link
Copy Markdown
Collaborator

I guess CI is flaky? Since the same change passed CI on my fork:

Yes, see #239

@MatthijsBurgh MatthijsBurgh merged commit de91a8e into orocos:master Apr 2, 2022
@jacobperron jacobperron deleted the fix_msbuild_warnings branch April 2, 2022 20:24
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