Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rcl] Refactor error checking #321

Merged
merged 2 commits into from
Nov 6, 2018
Merged

Conversation

jacobperron
Copy link
Member

  • Remove redundant error checking
    • Checking for null pointers is delegated to the _is_valid() function (if such a function exists).
    • Removed null pointer check for "options" since it is not a pointer type.
  • Change returned error codes to be more explicit
    • Replace RCL_RET_INVALID_ARGUMENT with RCL_RET_*_INVALID where possible.
    • Return RCL_RET_BAD_ALLOC where appropriate.
  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@jacobperron jacobperron added the in progress Actively being worked on (Kanban column) label Nov 5, 2018
Copy link
Contributor

@hidmic hidmic left a comment

Choose a reason for hiding this comment

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

LGTM! Looks like I have some changes to apply to #319.

@hidmic
Copy link
Contributor

hidmic commented Nov 6, 2018

@jacobperron wait sets still keep the fuzzy distinction between invalid argument and invalid entity, see here.

@wjwwood
Copy link
Member

wjwwood commented Nov 6, 2018

Is this ready for review?

@jacobperron jacobperron added in review Waiting for review (Kanban column) and removed in progress Actively being worked on (Kanban column) labels Nov 6, 2018
@jacobperron
Copy link
Member Author

Is this ready for review?

Sure :)

Copy link
Member

@wjwwood wjwwood left a comment

Choose a reason for hiding this comment

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

lgtm, other than one question

RCL_CHECK_FOR_NULL_WITH_MSG(
client->impl, "client's rmw implementation is invalid", return false);
options = _client_get_options(client);
RCL_CHECK_FOR_NULL_WITH_MSG(
options, "client's options pointer is invalid", return false);
Copy link
Member

Choose a reason for hiding this comment

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

What's the rationale for removing the check of the options? Does it prevent this functions reuse somewhere else or something?

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought it was redundant since options is not a pointer in the underlying impl struct, which is already checked in the line above.
The private function _client_get_options() returns the address, and the user-facing rcl_client_get_options() calls rcl_client_is_valid() anyways.

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense, 👍

@jacobperron
Copy link
Member Author

wait sets still keep the fuzzy distinction between invalid argument and invalid entity, see here.

@hidmic I was considering tackling wait sets, timers, and guard conditions later since they do not have the same usage pattern of _is_valid().

@jacobperron jacobperron merged commit e6985c0 into master Nov 6, 2018
@jacobperron jacobperron deleted the jacob/refactor_is_valid branch November 6, 2018 22:15
@jacobperron jacobperron removed the in review Waiting for review (Kanban column) label Nov 6, 2018
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.

3 participants