From 37c76574795d13d85d99f8406fcc6dc1b397ecab Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Thu, 28 May 2020 15:33:31 +0800 Subject: [PATCH 1/2] compare the return value to constants Signed-off-by: Chen Lihui --- rcl/src/rcl/logging.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/rcl/src/rcl/logging.c b/rcl/src/rcl/logging.c index 71c778388..bd76efb7a 100644 --- a/rcl/src/rcl/logging.c +++ b/rcl/src/rcl/logging.c @@ -88,15 +88,11 @@ rcl_logging_configure_with_output_handler( if (g_rcl_logging_ext_lib_enabled) { status = rcl_logging_external_initialize(config_file, g_logging_allocator); if (RCL_RET_OK == status) { - // TODO(dirk-thomas) the return value should be typed and compared to - // constants instead of zero - int logging_status = rcl_logging_external_set_logger_level( - NULL, default_level); - if (logging_status != 0) { - status = RCL_RET_ERROR; + status = rcl_logging_external_set_logger_level(NULL, default_level); + if (RCL_RET_OK == status) { + g_rcl_logging_out_handlers[g_rcl_logging_num_out_handlers++] = + rcl_logging_ext_lib_output_handler; } - g_rcl_logging_out_handlers[g_rcl_logging_num_out_handlers++] = - rcl_logging_ext_lib_output_handler; } } rcutils_logging_set_output_handler(output_handler); From 600edd245419549936bcaed5bf8d2de3a8a35006 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Thu, 28 May 2020 17:30:11 +0800 Subject: [PATCH 2/2] keep the original logic Signed-off-by: Chen Lihui --- rcl/src/rcl/logging.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/rcl/src/rcl/logging.c b/rcl/src/rcl/logging.c index bd76efb7a..59bbd8e97 100644 --- a/rcl/src/rcl/logging.c +++ b/rcl/src/rcl/logging.c @@ -88,11 +88,13 @@ rcl_logging_configure_with_output_handler( if (g_rcl_logging_ext_lib_enabled) { status = rcl_logging_external_initialize(config_file, g_logging_allocator); if (RCL_RET_OK == status) { - status = rcl_logging_external_set_logger_level(NULL, default_level); - if (RCL_RET_OK == status) { - g_rcl_logging_out_handlers[g_rcl_logging_num_out_handlers++] = - rcl_logging_ext_lib_output_handler; + rcl_ret_t logging_status = rcl_logging_external_set_logger_level( + NULL, default_level); + if (logging_status != RCL_RET_OK) { + status = RCL_RET_ERROR; } + g_rcl_logging_out_handlers[g_rcl_logging_num_out_handlers++] = + rcl_logging_ext_lib_output_handler; } } rcutils_logging_set_output_handler(output_handler);