Skip to content

Commit

Permalink
Fix conversions between rmw_localhost_only_t and bool (#670)
Browse files Browse the repository at this point in the history
* Check for case RMW_LOCALHOST_ONLY_DISABLED in init_options
* Take init value from node context
* Convert enum variable to boolean
* Remove extra check
* Remove not needed reference and dereference
* Change rcl_get_localhost_only to match signature
* Add parenthesis to make clearer precedence

Signed-off-by: Jorge Perez <[email protected]>
  • Loading branch information
Blast545 authored Jun 3, 2020
1 parent f82eeca commit acd167e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
5 changes: 4 additions & 1 deletion rcl/src/rcl/localhost.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ rcl_get_localhost_only(rmw_localhost_only_t * localhost_only)
get_env_error_str);
return RCL_RET_ERROR;
}
*localhost_only = ros_local_host_env_val != NULL && strcmp(ros_local_host_env_val, "1") == 0;
*localhost_only = (ros_local_host_env_val != NULL &&
strcmp(
ros_local_host_env_val,
"1") == 0) ? RMW_LOCALHOST_ONLY_ENABLED : RMW_LOCALHOST_ONLY_DISABLED;
return RCL_RET_OK;
}
9 changes: 3 additions & 6 deletions rcl/src/rcl/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,12 @@ rcl_node_init(
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME, "Using domain ID of '%zu'", domain_id);
node->impl->actual_domain_id = domain_id;

if (RMW_LOCALHOST_ONLY_DEFAULT == localhost_only) {
if (RMW_RET_OK != rcl_get_localhost_only(&localhost_only)) {
goto fail;
}
}
localhost_only = context->impl->init_options.impl->rmw_init_options.localhost_only;

node->impl->rmw_node_handle = rmw_create_node(
&(node->context->impl->rmw_context),
name, local_namespace_, domain_id, localhost_only);
name, local_namespace_, domain_id,
localhost_only == RMW_LOCALHOST_ONLY_ENABLED);

RCL_CHECK_FOR_NULL_WITH_MSG(
node->impl->rmw_node_handle, rmw_get_error_string().str, goto fail);
Expand Down

0 comments on commit acd167e

Please sign in to comment.