Skip to content

Commit

Permalink
Address peer review comments.
Browse files Browse the repository at this point in the history
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
  • Loading branch information
hidmic committed Aug 20, 2019
1 parent 37e1569 commit ac845e9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
1 change: 0 additions & 1 deletion rcl/include/rcl/arguments.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ rcl_arguments_get_param_files(
* Lock-Free | Yes
*
* \param[in] arguments An arguments structure that has been parsed.
* \param[in] allocator A valid allocator.
* \param[out] parameter_overrides Zero or more parameter overrides.
* This structure must be finalized by the caller.
* \return `RCL_RET_OK` if everything goes correctly, or
Expand Down
13 changes: 8 additions & 5 deletions rcl/test/rcl/test_arguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
#include <gtest/gtest.h>
#include <sstream>

#include "osrf_testing_tools_cpp/scope_exit.hpp"

#include "rcl/rcl.h"
#include "rcl/arguments.h"

#include "rcl/error_handling.h"

#include "rcl_yaml_param_parser/parser.h"
Expand Down Expand Up @@ -606,10 +607,16 @@ TEST_F(CLASSNAME(TestArgumentsFixture, RMW_IMPLEMENTATION), test_two_param_overr

rcl_ret_t ret = rcl_parse_arguments(argc, argv, alloc, &parsed_args);
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({
EXPECT_EQ(RCL_RET_OK, rcl_arguments_fini(&parsed_args));
});

rcl_params_t * params = NULL;
ret = rcl_arguments_get_param_overrides(&parsed_args, &params);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({
rcl_yaml_node_struct_fini(params);
});
EXPECT_EQ(2U, params->num_nodes);

rcl_variant_t * param_value =
Expand All @@ -622,8 +629,4 @@ TEST_F(CLASSNAME(TestArgumentsFixture, RMW_IMPLEMENTATION), test_two_param_overr
ASSERT_TRUE(NULL != param_value);
ASSERT_TRUE(NULL != param_value->integer_value);
EXPECT_EQ(4, *(param_value->integer_value));

rcl_yaml_node_struct_fini(params);

EXPECT_EQ(RCL_RET_OK, rcl_arguments_fini(&parsed_args));
}
4 changes: 2 additions & 2 deletions rcl_yaml_param_parser/src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ rcl_params_t * rcl_yaml_node_struct_copy(
}

rcutils_ret_t ret;
for (size_t node_idx = 0U; node_idx < params_st->num_nodes; node_idx++) {
for (size_t node_idx = 0U; node_idx < params_st->num_nodes; ++node_idx) {
out_params_st->node_names[node_idx] =
rcutils_strdup(params_st->node_names[node_idx], allocator);
if (NULL == out_params_st->node_names[node_idx]) {
Expand All @@ -428,7 +428,7 @@ rcl_params_t * rcl_yaml_node_struct_copy(
}
goto fail;
}
for (size_t parameter_idx = 0U; parameter_idx < node_params_st->num_params; parameter_idx++) {
for (size_t parameter_idx = 0U; parameter_idx < node_params_st->num_params; ++parameter_idx) {
out_node_params_st->parameter_names[parameter_idx] =
rcutils_strdup(node_params_st->parameter_names[parameter_idx], allocator);
if (NULL == out_node_params_st->parameter_names[parameter_idx]) {
Expand Down

0 comments on commit ac845e9

Please sign in to comment.