Skip to content

[rcl] Refactor error checking - #321

Merged
jacobperron merged 2 commits into
masterfrom
jacob/refactor_is_valid
Nov 6, 2018
Merged

jacobperron merged 2 commits into
masterfrom
jacob/refactor_is_valid

Conversation

@jacobperron

Copy link
Copy Markdown
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

@hidmic hidmic left a comment

Copy link
Copy Markdown
Contributor

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

hidmic commented Nov 6, 2018

Copy link
Copy Markdown
Contributor

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

@wjwwood

wjwwood commented Nov 6, 2018

Copy link
Copy Markdown
Member

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
Copy Markdown
Member Author

Is this ready for review?

Sure :)

@wjwwood wjwwood left a comment

Copy link
Copy Markdown
Member

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

Comment thread rcl/src/rcl/client.c
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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