-
Notifications
You must be signed in to change notification settings - Fork 163
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
Clean up rcl_expand_topic_name() implementation. #757
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,14 +71,7 @@ rcl_expand_topic_name( | |
rmw_ret = rmw_validate_node_name(node_name, &validation_result, NULL); | ||
if (rmw_ret != RMW_RET_OK) { | ||
RCL_SET_ERROR_MSG(rmw_get_error_string().str); | ||
switch (rmw_ret) { | ||
case RMW_RET_INVALID_ARGUMENT: | ||
return RCL_RET_INVALID_ARGUMENT; | ||
case RMW_RET_ERROR: | ||
// fall through on purpose | ||
default: | ||
return RCL_RET_ERROR; | ||
} | ||
return rcl_convert_rmw_ret_to_rcl_ret(rmw_ret); | ||
} | ||
if (validation_result != RMW_NODE_NAME_VALID) { | ||
RCL_SET_ERROR_MSG("node name is invalid"); | ||
|
@@ -88,14 +81,7 @@ rcl_expand_topic_name( | |
rmw_ret = rmw_validate_namespace(node_namespace, &validation_result, NULL); | ||
if (rmw_ret != RMW_RET_OK) { | ||
RCL_SET_ERROR_MSG(rmw_get_error_string().str); | ||
switch (rmw_ret) { | ||
case RMW_RET_INVALID_ARGUMENT: | ||
return RCL_RET_INVALID_ARGUMENT; | ||
case RMW_RET_ERROR: | ||
// fall through on purpose | ||
default: | ||
return RCL_RET_ERROR; | ||
} | ||
return rcl_convert_rmw_ret_to_rcl_ret(rmw_ret); | ||
} | ||
if (validation_result != RMW_NODE_NAME_VALID) { | ||
RCL_SET_ERROR_MSG("node namespace is invalid"); | ||
|
@@ -220,15 +206,6 @@ rcl_expand_topic_name( | |
return RCL_RET_BAD_ALLOC; | ||
} | ||
} | ||
// if the original input_topic_name has not yet be copied into new memory, strdup it now | ||
if (!local_output) { | ||
local_output = rcutils_strdup(input_topic_name, allocator); | ||
if (!local_output) { | ||
*output_topic_name = NULL; | ||
RCL_SET_ERROR_MSG("failed to allocate memory for output topic"); | ||
return RCL_RET_BAD_ALLOC; | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no logical path in this function that can result in the execution of this branch. |
||
// finally store the result in the out pointer and return | ||
*output_topic_name = local_output; | ||
return RCL_RET_OK; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this adds a couple of potential return codes that didn't exist previously (looking at
rcl_convert_rmw_ret_to_rcl_ret
. I think the header needs to be updated.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, looking at
rmw_validate_node_name
andrmw_validate_namespace
documentation, these can only returnRMW_RET_OK
,RMW_RET_ERROR
, andRMW_RET_INVALID_ARGUMENT
. Aren't we covered already?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. It looks fine then.