Skip to content

Conversation

@audrow
Copy link
Member

@audrow audrow commented Oct 13, 2020

This PR enables -Wformat=2, -Wconversion, and -Wsign-conversion in rcl_yaml_param_parser. No source code was modified to enable these warnings. This PR relies on using gtest v1.10.0, see ament/googletest#8.

@audrow audrow self-assigned this Oct 13, 2020
@audrow
Copy link
Member Author

audrow commented Oct 13, 2020

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

Copy link
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

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

The changes seem reasonable to me, but please make sure to get the upgraded googletest PR merged and released into Rolling before merging. That way we won't break PR jobs for all future PRs.

@audrow
Copy link
Member Author

audrow commented Oct 20, 2020

@ros-pull-request-builder retest this, please. (should have been done after release)

@audrow
Copy link
Member Author

audrow commented Oct 20, 2020

@ros-pull-request-builder retest this, please.

@clalancette
Copy link
Contributor

clalancette commented Oct 20, 2020

@ros-pull-request-builder retest this, please.

Just FYI, the buildfarm is still rebuilding things (it turns out that googletest causes almost all packages to rebuild, so it takes a while). So you may just have to wait until tomorrow morning for the builds to finish and be synced to testing.

@audrow
Copy link
Member Author

audrow commented Oct 21, 2020

@ros-pull-request-builder retest this, please.

@clalancette
Copy link
Contributor

It looks like the remaining errors on the PR job are actually warnings from -Wsign-conversion. So those look like actual bugs that need to be fixed.

@audrow audrow force-pushed the audrow/add-warnings-rcl_yaml_param_parser branch from 7e4111e to 4b07655 Compare October 29, 2020 18:54
Signed-off-by: Audrow Nash <[email protected]>
@audrow audrow force-pushed the audrow/add-warnings-rcl_yaml_param_parser branch from 4b07655 to 21a1d46 Compare December 3, 2020 19:24
@audrow audrow force-pushed the audrow/add-warnings-rcl_yaml_param_parser branch from 1a9eb2d to 0e3978c Compare December 3, 2020 20:01
@audrow audrow requested a review from clalancette December 3, 2020 20:27
@audrow
Copy link
Member Author

audrow commented Dec 3, 2020

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

} else {
do {
size_t len = separator_pos - absolute_namespace - i;
size_t len = ((size_t) (separator_pos - absolute_namespace)) - i;
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this code isn't new, but this case is a little scary. In particular, are we sure that (separator_pos - absolute_namespace) is always >= i? If not, we can get into a situation where we pass a very large number into rcutils_strndup, leading to bad behavior. Would you mind looking into this a bit and seeing what you can find out?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, I'll look into it.

Copy link
Member Author

@audrow audrow Dec 4, 2020

Choose a reason for hiding this comment

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

I believe that separator_pos - absolute_namespace is always >= i. I tried to make a proof-like explanation that showed it, but it's hard to do in markdown and probably more confusing than anything.

Basically, i is the sum of the previous lengths of namespaces already processed. The separator_pos - absolute_namespace is used to effectively get the index (through pointer arithmetic) of the next separator character (/). i is then used to skip the already considered part of absolute_namespace, so I should always be less than or equal to the index obtained from separator_pos - absolute_namespace.

Here is a simplified version of what's going on: https://repl.it/@audrow/Test-validating-namespace.

Copy link
Contributor

Choose a reason for hiding this comment

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

That works for me. Thanks for looking into it.

} else {
do {
size_t len = separator_pos - absolute_namespace - i;
size_t len = ((size_t) (separator_pos - absolute_namespace)) - i;
Copy link
Contributor

Choose a reason for hiding this comment

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

That works for me. Thanks for looking into it.

@audrow audrow merged commit 1f5a713 into master Dec 4, 2020
@delete-merged-branch delete-merged-branch bot deleted the audrow/add-warnings-rcl_yaml_param_parser branch December 4, 2020 16:43
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.

4 participants