Skip to content

Commit

Permalink
Clean up rcl_expand_topic_name() implementation. (#757)
Browse files Browse the repository at this point in the history
Signed-off-by: Michel Hidalgo <[email protected]>
  • Loading branch information
hidmic authored Aug 19, 2020
1 parent b2b57d9 commit 4cc5f2e
Showing 1 changed file with 2 additions and 25 deletions.
27 changes: 2 additions & 25 deletions rcl/src/rcl/expand_topic_name.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand Down Expand Up @@ -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;
}
}
// finally store the result in the out pointer and return
*output_topic_name = local_output;
return RCL_RET_OK;
Expand Down

0 comments on commit 4cc5f2e

Please sign in to comment.