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

CLI remapping followup #221

Merged
merged 6 commits into from
Mar 21, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions rcl/include/rcl/graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ typedef rmw_names_and_types_t rcl_names_and_types_t;
*
* \see rmw_get_topic_names_and_types for more details on no_demangle
*
* The returned names are not automatically remapped by this function.
* Attempting to create publishers or subscribers using names returned by this function may not
* result in the desired topic name being used depending on the remap rules in use.
*
* <hr>
* Attribute | Adherence
* ------------------ | -------------
Expand Down Expand Up @@ -96,6 +100,10 @@ rcl_get_topic_names_and_types(
* it is no longer needed.
* Failing to do so will result in leaked memory.
*
* The returned names are not automatically remapped by this function.
* Attempting to create clients or services using names returned by this function may not result in
* the desired service name being used depending on the remap rules in use.
*
* <hr>
* Attribute | Adherence
* ------------------ | -------------
Expand Down Expand Up @@ -219,6 +227,12 @@ rcl_get_node_names(
* In the event that error handling needs to allocate memory, this function
* will try to use the node's allocator.
*
* The topic name is not automatically remapped by this function.
* If there is a publisher created with topic name `foo` and remap rule `foo:=bar` then calling
* this with `topic_name` set to `bar` will return a count of 1, and with `topic_name` set to `foo`
* will return a count of 0.
* /sa rcl_remap_topic_name()
*
* <hr>
* Attribute | Adherence
* ------------------ | -------------
Expand Down Expand Up @@ -260,6 +274,12 @@ rcl_count_publishers(
* In the event that error handling needs to allocate memory, this function
* will try to use the node's allocator.
*
* The topic name is not automatically remapped by this function.
* If there is a subscriber created with topic name `foo` and remap rule `foo:=bar` then calling
* this with `topic_name` set to `bar` will return a count of 1, and with `topic_name` set to `foo`
* will return a count of 0.
* /sa rcl_remap_topic_name()
*
* <hr>
* Attribute | Adherence
* ------------------ | -------------
Expand Down
22 changes: 10 additions & 12 deletions rcl/src/rcl/arguments.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,12 @@ _rcl_parse_remap_rule(
if (len_node_name) {
int validation_result;
size_t invalid_index;
if (
RMW_RET_OK != rmw_validate_node_name_with_size(arg, len_node_name, &validation_result,
&invalid_index))
{
rmw_ret_t rmw_ret = rmw_validate_node_name_with_size(arg, len_node_name, &validation_result,
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: I would suggest to wrap after the opening parenthesis so that all arguments are on the indented next line.

&invalid_index);
if (RMW_RET_OK != rmw_ret) {
RCL_SET_ERROR_MSG("failed to run check on node name", allocator);
return RCL_RET_ERROR;
}
if (RMW_NODE_NAME_VALID != validation_result) {
} else if (RMW_NODE_NAME_VALID != validation_result) {
RCL_SET_ERROR_MSG_WITH_FORMAT_STRING(
allocator,
"node name prefix invalid: %s", rmw_node_name_validation_result_string(validation_result));
Expand Down Expand Up @@ -158,11 +156,11 @@ _rcl_parse_remap_rule(
} else if (RCL_NAMESPACE_REMAP == type) {
int validation_result;
size_t invalid_idx;
if (RMW_RET_OK != rmw_validate_namespace(replacement_begin, &validation_result, &invalid_idx)) {
rmw_ret_t rmw_ret = rmw_validate_namespace(replacement_begin, &validation_result, &invalid_idx);
if (RMW_RET_OK != rmw_ret) {
RCL_SET_ERROR_MSG("failed to run check on namespace", allocator);
return RCL_RET_ERROR;
}
if (RMW_NAMESPACE_VALID != validation_result) {
} else if (RMW_NAMESPACE_VALID != validation_result) {
RCL_SET_ERROR_MSG_WITH_FORMAT_STRING(
allocator,
"namespace is invalid: %s", rmw_namespace_validation_result_string(validation_result));
Expand All @@ -171,11 +169,11 @@ _rcl_parse_remap_rule(
} else if (RCL_NODENAME_REMAP == type) {
int validation_result;
size_t invalid_idx;
if (RMW_RET_OK != rmw_validate_node_name(replacement_begin, &validation_result, &invalid_idx)) {
rmw_ret_t rmw_ret = rmw_validate_node_name(replacement_begin, &validation_result, &invalid_idx);
if (RMW_RET_OK != rmw_ret) {
RCL_SET_ERROR_MSG("failed to run check on node name", allocator);
return RCL_RET_ERROR;
}
if (RMW_NODE_NAME_VALID != validation_result) {
} else if (RMW_NODE_NAME_VALID != validation_result) {
RCL_SET_ERROR_MSG_WITH_FORMAT_STRING(
allocator,
"node name is invalid: %s", rmw_node_name_validation_result_string(validation_result));
Expand Down