Clean up rcl_expand_topic_name() implementation. (#757)
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
This commit is contained in:
parent
0698835633
commit
04210ebdc2
1 changed files with 2 additions and 25 deletions
|
@ -71,14 +71,7 @@ rcl_expand_topic_name(
|
||||||
rmw_ret = rmw_validate_node_name(node_name, &validation_result, NULL);
|
rmw_ret = rmw_validate_node_name(node_name, &validation_result, NULL);
|
||||||
if (rmw_ret != RMW_RET_OK) {
|
if (rmw_ret != RMW_RET_OK) {
|
||||||
RCL_SET_ERROR_MSG(rmw_get_error_string().str);
|
RCL_SET_ERROR_MSG(rmw_get_error_string().str);
|
||||||
switch (rmw_ret) {
|
return rcl_convert_rmw_ret_to_rcl_ret(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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (validation_result != RMW_NODE_NAME_VALID) {
|
if (validation_result != RMW_NODE_NAME_VALID) {
|
||||||
RCL_SET_ERROR_MSG("node name is invalid");
|
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);
|
rmw_ret = rmw_validate_namespace(node_namespace, &validation_result, NULL);
|
||||||
if (rmw_ret != RMW_RET_OK) {
|
if (rmw_ret != RMW_RET_OK) {
|
||||||
RCL_SET_ERROR_MSG(rmw_get_error_string().str);
|
RCL_SET_ERROR_MSG(rmw_get_error_string().str);
|
||||||
switch (rmw_ret) {
|
return rcl_convert_rmw_ret_to_rcl_ret(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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (validation_result != RMW_NODE_NAME_VALID) {
|
if (validation_result != RMW_NODE_NAME_VALID) {
|
||||||
RCL_SET_ERROR_MSG("node namespace is invalid");
|
RCL_SET_ERROR_MSG("node namespace is invalid");
|
||||||
|
@ -220,15 +206,6 @@ rcl_expand_topic_name(
|
||||||
return RCL_RET_BAD_ALLOC;
|
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
|
// finally store the result in the out pointer and return
|
||||||
*output_topic_name = local_output;
|
*output_topic_name = local_output;
|
||||||
return RCL_RET_OK;
|
return RCL_RET_OK;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue