From 364b772ba993f81deb43a6205e373e36d16d6d82 Mon Sep 17 00:00:00 2001 From: Jorge Perez Date: Tue, 2 Jun 2020 17:18:22 -0300 Subject: [PATCH 1/7] Check for case RMW_LOCALHOST_ONLY_DISABLED in init_options Signed-off-by: Jorge Perez --- rcl/src/rcl/init.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rcl/src/rcl/init.c b/rcl/src/rcl/init.c index a18f675bb..3aa01fbc2 100644 --- a/rcl/src/rcl/init.c +++ b/rcl/src/rcl/init.c @@ -162,6 +162,10 @@ rcl_init( fail_ret = ret; goto fail; } + } else if (RMW_LOCALHOST_ONLY_DISABLED == *localhost_only) { + // If the user sets the rmw init option to RMW_LOCALHOST_ONLY_DISABLED + // manually, save the boolean variable as 0 + *localhost_only = 0; } if (context->global_arguments.impl->enclave) { From 30936422eeb6083705fa1237399421fa3aa84518 Mon Sep 17 00:00:00 2001 From: Jorge Perez Date: Tue, 2 Jun 2020 17:19:01 -0300 Subject: [PATCH 2/7] Take init value from node context Signed-off-by: Jorge Perez --- rcl/src/rcl/node.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/rcl/src/rcl/node.c b/rcl/src/rcl/node.c index 4ae93ecd8..3de4be482 100644 --- a/rcl/src/rcl/node.c +++ b/rcl/src/rcl/node.c @@ -263,11 +263,7 @@ 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), From 442615d356ee19bbebcae1ae8810e6ce32f6b207 Mon Sep 17 00:00:00 2001 From: Jorge Perez Date: Tue, 2 Jun 2020 18:00:32 -0300 Subject: [PATCH 3/7] Convert enum variable to boolean Signed-off-by: Jorge Perez --- rcl/src/rcl/node.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rcl/src/rcl/node.c b/rcl/src/rcl/node.c index 3de4be482..dc5174898 100644 --- a/rcl/src/rcl/node.c +++ b/rcl/src/rcl/node.c @@ -267,7 +267,8 @@ rcl_node_init( 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); From ffae768bbee366f79b9b86368b312dbfd986de63 Mon Sep 17 00:00:00 2001 From: Jorge Perez Date: Tue, 2 Jun 2020 18:33:18 -0300 Subject: [PATCH 4/7] Remove extra check Signed-off-by: Jorge Perez --- rcl/src/rcl/init.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/rcl/src/rcl/init.c b/rcl/src/rcl/init.c index 3aa01fbc2..a18f675bb 100644 --- a/rcl/src/rcl/init.c +++ b/rcl/src/rcl/init.c @@ -162,10 +162,6 @@ rcl_init( fail_ret = ret; goto fail; } - } else if (RMW_LOCALHOST_ONLY_DISABLED == *localhost_only) { - // If the user sets the rmw init option to RMW_LOCALHOST_ONLY_DISABLED - // manually, save the boolean variable as 0 - *localhost_only = 0; } if (context->global_arguments.impl->enclave) { From c992146de9db3a3624379d37266e3a860620e352 Mon Sep 17 00:00:00 2001 From: Jorge Perez Date: Tue, 2 Jun 2020 18:33:44 -0300 Subject: [PATCH 5/7] Remove not needed reference and dereference Signed-off-by: Jorge Perez --- rcl/src/rcl/node.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rcl/src/rcl/node.c b/rcl/src/rcl/node.c index dc5174898..46d248026 100644 --- a/rcl/src/rcl/node.c +++ b/rcl/src/rcl/node.c @@ -263,7 +263,7 @@ rcl_node_init( RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME, "Using domain ID of '%zu'", domain_id); node->impl->actual_domain_id = domain_id; - localhost_only = *(&context->impl->init_options.impl->rmw_init_options.localhost_only); + 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), From d45ff22d5c925b6ac8049416f6ed10b2733e7ab3 Mon Sep 17 00:00:00 2001 From: Jorge Perez Date: Wed, 3 Jun 2020 17:32:18 -0300 Subject: [PATCH 6/7] Change rcl_get_localhost_only to match signature Signed-off-by: Jorge Perez --- rcl/src/rcl/localhost.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rcl/src/rcl/localhost.c b/rcl/src/rcl/localhost.c index a798c4783..de539d4e7 100644 --- a/rcl/src/rcl/localhost.c +++ b/rcl/src/rcl/localhost.c @@ -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; } From 04dfa577faa8c74840ef04eb5a51fbc5ccf50d66 Mon Sep 17 00:00:00 2001 From: Jorge Perez Date: Wed, 3 Jun 2020 17:58:16 -0300 Subject: [PATCH 7/7] Add parenthesis to make clearer precedence Signed-off-by: Jorge Perez --- rcl/src/rcl/localhost.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rcl/src/rcl/localhost.c b/rcl/src/rcl/localhost.c index de539d4e7..556a07b4a 100644 --- a/rcl/src/rcl/localhost.c +++ b/rcl/src/rcl/localhost.c @@ -41,9 +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 && + *localhost_only = (ros_local_host_env_val != NULL && strcmp( - ros_local_host_env_val, - "1") == 0 ? RMW_LOCALHOST_ONLY_ENABLED : RMW_LOCALHOST_ONLY_DISABLED; + ros_local_host_env_val, + "1") == 0) ? RMW_LOCALHOST_ONLY_ENABLED : RMW_LOCALHOST_ONLY_DISABLED; return RCL_RET_OK; }