Fix conversions between rmw_localhost_only_t and bool (#670)

* 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 <jjperez@ekumenlabs.com>
This commit is contained in:
Jorge Perez 2020-06-03 19:11:22 -03:00 committed by GitHub
parent f82eecafdd
commit acd167e173
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View file

@ -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;
}

View file

@ -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);