Skip to content

Commit

Permalink
code style only: wrap after open parenthesis if not in one line (#565)
Browse files Browse the repository at this point in the history
Signed-off-by: Dirk Thomas <[email protected]>
  • Loading branch information
dirk-thomas authored Feb 3, 2020
1 parent 7537f83 commit 4b9c0a3
Show file tree
Hide file tree
Showing 43 changed files with 944 additions and 538 deletions.
126 changes: 76 additions & 50 deletions rcl/src/rcl/arguments.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,8 @@ rcl_parse_arguments(
if (i + 1 < argc) {
// Attempt to parse next argument as parameter override rule
if (RCL_RET_OK == _rcl_parse_param_rule(argv[i + 1], args_impl->parameter_overrides)) {
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME,
"Got param override rule : %s\n", argv[i + 1]);
RCUTILS_LOG_DEBUG_NAMED(
ROS_PACKAGE_NAME, "Got param override rule : %s\n", argv[i + 1]);
++i; // Skip flag here, for loop will skip rule.
continue;
}
Expand All @@ -414,8 +414,8 @@ rcl_parse_arguments(
ret = RCL_RET_INVALID_ROS_ARGS;
goto fail;
}
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME,
"Arg %d (%s) is not a %s nor a %s flag.",
RCUTILS_LOG_DEBUG_NAMED(
ROS_PACKAGE_NAME, "Arg %d (%s) is not a %s nor a %s flag.",
i, argv[i], RCL_PARAM_FLAG, RCL_SHORT_PARAM_FLAG);

// Attempt to parse argument as remap rule flag
Expand All @@ -442,9 +442,9 @@ rcl_parse_arguments(
ret = RCL_RET_INVALID_ROS_ARGS;
goto fail;
}
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME,
"Arg %d (%s) is not a %s nor a %s flag.", i,
argv[i], RCL_REMAP_FLAG, RCL_SHORT_REMAP_FLAG);
RCUTILS_LOG_DEBUG_NAMED(
ROS_PACKAGE_NAME, "Arg %d (%s) is not a %s nor a %s flag.",
i, argv[i], RCL_REMAP_FLAG, RCL_SHORT_REMAP_FLAG);

// Attempt to parse argument as parameter file rule
if (strcmp(RCL_PARAM_FILE_FLAG, argv[i]) == 0) {
Expand All @@ -457,7 +457,8 @@ rcl_parse_arguments(
&args_impl->parameter_files[args_impl->num_param_files_args]))
{
++(args_impl->num_param_files_args);
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME,
RCUTILS_LOG_DEBUG_NAMED(
ROS_PACKAGE_NAME,
"Got params file : %s\ntotal num param files %d",
args_impl->parameter_files[args_impl->num_param_files_args - 1],
args_impl->num_param_files_args);
Expand All @@ -476,8 +477,9 @@ rcl_parse_arguments(
ret = RCL_RET_INVALID_ROS_ARGS;
goto fail;
}
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME,
"Arg %d (%s) is not a %s flag.", i, argv[i], RCL_PARAM_FILE_FLAG);
RCUTILS_LOG_DEBUG_NAMED(
ROS_PACKAGE_NAME, "Arg %d (%s) is not a %s flag.",
i, argv[i], RCL_PARAM_FILE_FLAG);

// Attempt to parse argument as log level configuration
if (strcmp(RCL_LOG_LEVEL_FLAG, argv[i]) == 0) {
Expand All @@ -501,25 +503,25 @@ rcl_parse_arguments(
ret = RCL_RET_INVALID_ROS_ARGS;
goto fail;
}
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME,
"Arg %d (%s) is not a %s flag.",
RCUTILS_LOG_DEBUG_NAMED(
ROS_PACKAGE_NAME, "Arg %d (%s) is not a %s flag.",
i, argv[i], RCL_LOG_LEVEL_FLAG);

// Attempt to parse argument as log configuration file
if (strcmp(RCL_EXTERNAL_LOG_CONFIG_FLAG, argv[i]) == 0) {
if (i + 1 < argc) {
if (NULL != args_impl->external_log_config_file) {
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME,
"Overriding log configuration file : %s\n",
RCUTILS_LOG_DEBUG_NAMED(
ROS_PACKAGE_NAME, "Overriding log configuration file : %s\n",
args_impl->external_log_config_file);
allocator.deallocate(args_impl->external_log_config_file, allocator.state);
args_impl->external_log_config_file = NULL;
}
if (RCL_RET_OK == _rcl_parse_external_log_config_file(
argv[i + 1], allocator, &args_impl->external_log_config_file))
{
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME,
"Got log configuration file : %s\n",
RCUTILS_LOG_DEBUG_NAMED(
ROS_PACKAGE_NAME, "Got log configuration file : %s\n",
args_impl->external_log_config_file);
++i; // Skip flag here, for loop will skip value.
continue;
Expand All @@ -536,19 +538,21 @@ rcl_parse_arguments(
ret = RCL_RET_INVALID_ROS_ARGS;
goto fail;
}
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME,
"Arg %d (%s) is not a %s flag.",
RCUTILS_LOG_DEBUG_NAMED(
ROS_PACKAGE_NAME, "Arg %d (%s) is not a %s flag.",
i, argv[i], RCL_EXTERNAL_LOG_CONFIG_FLAG);

// Attempt to parse --enable/disable-stdout-logs flag
ret = _rcl_parse_disabling_flag(
argv[i], RCL_LOG_STDOUT_FLAG_SUFFIX, &args_impl->log_stdout_disabled);
if (RCL_RET_OK == ret) {
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME,
"Disable log stdout ? %s\n", args_impl->log_stdout_disabled ? "true" : "false");
RCUTILS_LOG_DEBUG_NAMED(
ROS_PACKAGE_NAME, "Disable log stdout ? %s\n",
args_impl->log_stdout_disabled ? "true" : "false");
continue;
}
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME,
RCUTILS_LOG_DEBUG_NAMED(
ROS_PACKAGE_NAME,
"Couldn't parse arg %d (%s) as %s%s or %s%s flag. Error: %s",
i, argv[i], RCL_ENABLE_FLAG_PREFIX, RCL_LOG_STDOUT_FLAG_SUFFIX,
RCL_DISABLE_FLAG_PREFIX, RCL_LOG_STDOUT_FLAG_SUFFIX, rcl_get_error_string().str);
Expand All @@ -558,11 +562,13 @@ rcl_parse_arguments(
ret = _rcl_parse_disabling_flag(
argv[i], RCL_LOG_ROSOUT_FLAG_SUFFIX, &args_impl->log_rosout_disabled);
if (RCL_RET_OK == ret) {
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME,
"Disable log rosout ? %s\n", args_impl->log_rosout_disabled ? "true" : "false");
RCUTILS_LOG_DEBUG_NAMED(
ROS_PACKAGE_NAME, "Disable log rosout ? %s\n",
args_impl->log_rosout_disabled ? "true" : "false");
continue;
}
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME,
RCUTILS_LOG_DEBUG_NAMED(
ROS_PACKAGE_NAME,
"Couldn't parse arg %d (%s) as %s%s or %s%s flag. Error: %s",
i, argv[i], RCL_ENABLE_FLAG_PREFIX, RCL_LOG_ROSOUT_FLAG_SUFFIX,
RCL_DISABLE_FLAG_PREFIX, RCL_LOG_ROSOUT_FLAG_SUFFIX, rcl_get_error_string().str);
Expand All @@ -572,11 +578,13 @@ rcl_parse_arguments(
ret = _rcl_parse_disabling_flag(
argv[i], RCL_LOG_EXT_LIB_FLAG_SUFFIX, &args_impl->log_ext_lib_disabled);
if (RCL_RET_OK == ret) {
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME,
"Disable log external lib ? %s\n", args_impl->log_ext_lib_disabled ? "true" : "false");
RCUTILS_LOG_DEBUG_NAMED(
ROS_PACKAGE_NAME, "Disable log external lib ? %s\n",
args_impl->log_ext_lib_disabled ? "true" : "false");
continue;
}
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME,
RCUTILS_LOG_DEBUG_NAMED(
ROS_PACKAGE_NAME,
"Couldn't parse arg %d (%s) as %s%s or %s%s flag. Error: %s",
i, argv[i], RCL_ENABLE_FLAG_PREFIX, RCL_LOG_EXT_LIB_FLAG_SUFFIX,
RCL_DISABLE_FLAG_PREFIX, RCL_LOG_EXT_LIB_FLAG_SUFFIX, rcl_get_error_string().str);
Expand All @@ -596,14 +604,16 @@ rcl_parse_arguments(
rcl_remap_t * rule = &(args_impl->remap_rules[args_impl->num_remap_rules]);
*rule = rcl_get_zero_initialized_remap();
if (RCL_RET_OK == _rcl_parse_remap_rule(argv[i], allocator, rule)) {
RCUTILS_LOG_WARN_NAMED(ROS_PACKAGE_NAME,
RCUTILS_LOG_WARN_NAMED(
ROS_PACKAGE_NAME,
"Found remap rule '%s'. This syntax is deprecated. Use '%s %s %s' instead.",
argv[i], RCL_ROS_ARGS_FLAG, RCL_REMAP_FLAG, argv[i]);
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME, "Got remap rule : %s\n", argv[i + 1]);
++(args_impl->num_remap_rules);
continue;
}
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME,
RCUTILS_LOG_DEBUG_NAMED(
ROS_PACKAGE_NAME,
"Couldn't parse arg %d (%s) as a remap rule in its deprecated form. Error: %s",
i, argv[i], rcl_get_error_string().str);
rcl_reset_error();
Expand All @@ -616,31 +626,36 @@ rcl_parse_arguments(
&args_impl->parameter_files[args_impl->num_param_files_args]))
{
++(args_impl->num_param_files_args);
RCUTILS_LOG_WARN_NAMED(ROS_PACKAGE_NAME,
RCUTILS_LOG_WARN_NAMED(
ROS_PACKAGE_NAME,
"Found parameter file rule '%s'. This syntax is deprecated. Use '%s %s %s' instead.",
argv[i], RCL_ROS_ARGS_FLAG, RCL_PARAM_FILE_FLAG,
args_impl->parameter_files[args_impl->num_param_files_args - 1]);
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME,
RCUTILS_LOG_DEBUG_NAMED(
ROS_PACKAGE_NAME,
"params rule : %s\n total num param rules %d",
args_impl->parameter_files[args_impl->num_param_files_args - 1],
args_impl->num_param_files_args);
continue;
}
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME,
RCUTILS_LOG_DEBUG_NAMED(
ROS_PACKAGE_NAME,
"Couldn't parse arg %d (%s) as a deprecated parameter file rule. Error: %s",
i, argv[i], rcl_get_error_string().str);
rcl_reset_error();

// Attempt to parse argument as log level configuration
int log_level;
if (RCL_RET_OK == _rcl_parse_log_level_rule(argv[i], allocator, &log_level)) {
RCUTILS_LOG_WARN_NAMED(ROS_PACKAGE_NAME,
RCUTILS_LOG_WARN_NAMED(
ROS_PACKAGE_NAME,
"Found log level rule '%s'. This syntax is deprecated. Use '%s %s %s' instead.",
argv[i], RCL_ROS_ARGS_FLAG, RCL_LOG_LEVEL_FLAG, g_rcutils_log_severity_names[log_level]);
args_impl->log_level = log_level;
continue;
}
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME,
RCUTILS_LOG_DEBUG_NAMED(
ROS_PACKAGE_NAME,
"Couldn't parse arg %d (%s) as a deprecated log level rule. Error: %s",
i, argv[i], rcl_get_error_string().str);
rcl_reset_error();
Expand All @@ -649,16 +664,18 @@ rcl_parse_arguments(
rcl_ret_t ret = _rcl_parse_external_log_config_file_rule(
argv[i], allocator, &args_impl->external_log_config_file);
if (RCL_RET_OK == ret) {
RCUTILS_LOG_WARN_NAMED(ROS_PACKAGE_NAME,
RCUTILS_LOG_WARN_NAMED(
ROS_PACKAGE_NAME,
"Found log config rule '%s'. This syntax is deprecated. Use '%s %s %s' instead.",
argv[i], RCL_ROS_ARGS_FLAG, RCL_EXTERNAL_LOG_CONFIG_FLAG,
args_impl->external_log_config_file);
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME,
"Got log configuration file : %s\n",
RCUTILS_LOG_DEBUG_NAMED(
ROS_PACKAGE_NAME, "Got log configuration file : %s\n",
args_impl->external_log_config_file);
continue;
}
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME,
RCUTILS_LOG_DEBUG_NAMED(
ROS_PACKAGE_NAME,
"Couldn't parse arg %d (%s) as a deprecated log config rule. Error: %s",
i, argv[i], rcl_get_error_string().str);
rcl_reset_error();
Expand All @@ -669,14 +686,17 @@ rcl_parse_arguments(
if (RCL_RET_OK == ret) {
const char * flag_prefix =
args_impl->log_stdout_disabled ? RCL_DISABLE_FLAG_PREFIX : RCL_ENABLE_FLAG_PREFIX;
RCUTILS_LOG_WARN_NAMED(ROS_PACKAGE_NAME,
RCUTILS_LOG_WARN_NAMED(
ROS_PACKAGE_NAME,
"Found '%s'. This syntax is deprecated. Use '%s %s%s' instead.",
argv[i], RCL_ROS_ARGS_FLAG, flag_prefix, RCL_LOG_STDOUT_FLAG_SUFFIX);
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME,
"Disable log stdout ? %s\n", args_impl->log_stdout_disabled ? "true" : "false");
RCUTILS_LOG_DEBUG_NAMED(
ROS_PACKAGE_NAME, "Disable log stdout ? %s\n",
args_impl->log_stdout_disabled ? "true" : "false");
continue;
}
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME,
RCUTILS_LOG_DEBUG_NAMED(
ROS_PACKAGE_NAME,
"Couldn't parse arg %d (%s) as a deprecated log_stdout_disabled rule. Error: %s",
i, argv[i], rcl_get_error_string().str);
rcl_reset_error();
Expand All @@ -687,14 +707,17 @@ rcl_parse_arguments(
if (RCL_RET_OK == ret) {
const char * flag_prefix =
args_impl->log_rosout_disabled ? RCL_DISABLE_FLAG_PREFIX : RCL_ENABLE_FLAG_PREFIX;
RCUTILS_LOG_WARN_NAMED(ROS_PACKAGE_NAME,
RCUTILS_LOG_WARN_NAMED(
ROS_PACKAGE_NAME,
"Found '%s'. This syntax is deprecated. Use '%s %s%s' instead.",
argv[i], RCL_ROS_ARGS_FLAG, flag_prefix, RCL_LOG_ROSOUT_FLAG_SUFFIX);
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME,
"Disable log rosout ? %s\n", args_impl->log_rosout_disabled ? "true" : "false");
RCUTILS_LOG_DEBUG_NAMED(
ROS_PACKAGE_NAME, "Disable log rosout ? %s\n",
args_impl->log_rosout_disabled ? "true" : "false");
continue;
}
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME,
RCUTILS_LOG_DEBUG_NAMED(
ROS_PACKAGE_NAME,
"Couldn't parse arg %d (%s) as a deprecated log_rosout_disabled rule. Error: %s",
i, argv[i], rcl_get_error_string().str);
rcl_reset_error();
Expand All @@ -705,14 +728,17 @@ rcl_parse_arguments(
if (RCL_RET_OK == ret) {
const char * flag_prefix =
args_impl->log_ext_lib_disabled ? RCL_DISABLE_FLAG_PREFIX : RCL_ENABLE_FLAG_PREFIX;
RCUTILS_LOG_WARN_NAMED(ROS_PACKAGE_NAME,
RCUTILS_LOG_WARN_NAMED(
ROS_PACKAGE_NAME,
"Found '%s'. This syntax is deprecated. Use '%s %s%s' instead.",
argv[i], RCL_ROS_ARGS_FLAG, flag_prefix, RCL_LOG_EXT_LIB_FLAG_SUFFIX);
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME,
"Disable log external lib ? %s\n", args_impl->log_ext_lib_disabled ? "true" : "false");
RCUTILS_LOG_DEBUG_NAMED(
ROS_PACKAGE_NAME, "Disable log external lib ? %s\n",
args_impl->log_ext_lib_disabled ? "true" : "false");
continue;
}
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME,
RCUTILS_LOG_DEBUG_NAMED(
ROS_PACKAGE_NAME,
"Couldn't parse arg %d (%s) as a deprecated log_ext_lib_disabled rule. Error: %s",
i, argv[i], rcl_get_error_string().str);
rcl_reset_error();
Expand Down
3 changes: 2 additions & 1 deletion rcl/src/rcl/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ rcl_shutdown(rcl_context_t * context)
}

rcl_ret_t rcl_ret = rcl_logging_fini();
RCUTILS_LOG_ERROR_EXPRESSION_NAMED(RCL_RET_OK != rcl_ret, ROS_PACKAGE_NAME,
RCUTILS_LOG_ERROR_EXPRESSION_NAMED(
RCL_RET_OK != rcl_ret, ROS_PACKAGE_NAME,
"Failed to fini logging, rcl_ret_t: %i, rcl_error_str: %s", rcl_ret,
rcl_get_error_string().str);
rcl_reset_error();
Expand Down
15 changes: 9 additions & 6 deletions rcl/src/rcl/logging_rosout.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,11 @@ rcl_ret_t rcl_logging_rosout_init(
return RCL_RET_OK;
}
__logger_map = rcutils_get_zero_initialized_hash_map();
RCL_RET_FROM_RCUTIL_RET(status,
rcutils_hash_map_init(&__logger_map, 2, sizeof(const char *), sizeof(rosout_map_entry_t),
rcutils_hash_map_string_hash_func, rcutils_hash_map_string_cmp_func, allocator));
RCL_RET_FROM_RCUTIL_RET(
status,
rcutils_hash_map_init(
&__logger_map, 2, sizeof(const char *), sizeof(rosout_map_entry_t),
rcutils_hash_map_string_hash_func, rcutils_hash_map_string_cmp_func, allocator));
if (RCL_RET_OK == status) {
__rosout_allocator = *allocator;
__is_initialized = true;
Expand All @@ -111,8 +113,8 @@ rcl_ret_t rcl_logging_rosout_fini()
rosout_map_entry_t entry;

// fini all the outstanding publishers
rcutils_ret_t hashmap_ret = rcutils_hash_map_get_next_key_and_data(&__logger_map, NULL, &key,
&entry);
rcutils_ret_t hashmap_ret = rcutils_hash_map_get_next_key_and_data(
&__logger_map, NULL, &key, &entry);
while (RCL_RET_OK == status && RCUTILS_RET_OK == hashmap_ret) {
// Teardown publisher
status = rcl_publisher_fini(&entry.publisher, entry.node);
Expand Down Expand Up @@ -157,7 +159,8 @@ rcl_ret_t rcl_logging_rosout_init_publisher_for_node(
if (rcutils_hash_map_key_exists(&__logger_map, &logger_name)) {
// @TODO(nburek) Update behavior to either enforce unique names or work with non-unique
// names based on the outcome here: https://github.com/ros2/design/issues/187
RCUTILS_LOG_WARN_NAMED("rcl.logging_rosout",
RCUTILS_LOG_WARN_NAMED(
"rcl.logging_rosout",
"Publisher already registered for provided node name. If this is due to multiple nodes "
"with the same name then all logs for that logger name will go out over the existing "
"publisher. As soon as any node with that name is destructed it will unregister the "
Expand Down
3 changes: 2 additions & 1 deletion rcl/src/rcl/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,8 @@ rcl_node_init(
node->impl->logger_name)
{
ret = rcl_logging_rosout_fini_publisher_for_node(node);
RCUTILS_LOG_ERROR_EXPRESSION_NAMED((ret != RCL_RET_OK && ret != RCL_RET_NOT_INIT),
RCUTILS_LOG_ERROR_EXPRESSION_NAMED(
(ret != RCL_RET_OK && ret != RCL_RET_NOT_INIT),
ROS_PACKAGE_NAME, "Failed to fini publisher for node: %i", ret);
allocator->deallocate((char *)node->impl->logger_name, allocator->state);
}
Expand Down
12 changes: 6 additions & 6 deletions rcl/src/rcl/publisher.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ rcl_publisher_init(
remapped_topic_name,
&(options->qos),
&(options->rmw_publisher_options));
RCL_CHECK_FOR_NULL_WITH_MSG(publisher->impl->rmw_handle,
rmw_get_error_string().str, goto fail);
RCL_CHECK_FOR_NULL_WITH_MSG(
publisher->impl->rmw_handle, rmw_get_error_string().str, goto fail);
// get actual qos, and store it
rmw_ret = rmw_publisher_get_actual_qos(
publisher->impl->rmw_handle,
Expand Down Expand Up @@ -303,8 +303,8 @@ rcl_publish_serialized_message(
return RCL_RET_PUBLISHER_INVALID; // error already set
}
RCL_CHECK_ARGUMENT_FOR_NULL(serialized_message, RCL_RET_INVALID_ARGUMENT);
rmw_ret_t ret = rmw_publish_serialized_message(publisher->impl->rmw_handle, serialized_message,
allocation);
rmw_ret_t ret = rmw_publish_serialized_message(
publisher->impl->rmw_handle, serialized_message, allocation);
if (ret != RMW_RET_OK) {
RCL_SET_ERROR_MSG(rmw_get_error_string().str);
if (ret == RMW_RET_BAD_ALLOC) {
Expand Down Expand Up @@ -420,8 +420,8 @@ rcl_publisher_get_subscription_count(
}
RCL_CHECK_ARGUMENT_FOR_NULL(subscription_count, RCL_RET_INVALID_ARGUMENT);

rmw_ret_t ret = rmw_publisher_count_matched_subscriptions(publisher->impl->rmw_handle,
subscription_count);
rmw_ret_t ret = rmw_publisher_count_matched_subscriptions(
publisher->impl->rmw_handle, subscription_count);

if (ret != RMW_RET_OK) {
RCL_SET_ERROR_MSG(rmw_get_error_string().str);
Expand Down
Loading

0 comments on commit 4b9c0a3

Please sign in to comment.