Skip to content

Commit

Permalink
fix return code for invalid nodes
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
  • Loading branch information
ivanpauno committed Jul 17, 2020
1 parent 2ded9f7 commit 2cdd2ba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions rcl/src/rcl/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,10 @@ rcl_node_get_options(const rcl_node_t * node)
rcl_ret_t
rcl_node_get_domain_id(const rcl_node_t * node, size_t * domain_id)
{
RCL_CHECK_ARGUMENT_FOR_NULL(node, RCL_RET_NODE_INVALID);
if (!rcl_node_is_valid(node)) {
return RCL_RET_NODE_INVALID;
}
RCL_CHECK_ARGUMENT_FOR_NULL(domain_id, RCL_RET_INVALID_ARGUMENT);
RCL_CHECK_FOR_NULL_WITH_MSG(node->context, "invalid node", return RCL_RET_NODE_INVALID);
rcl_ret_t ret = rcl_context_get_domain_id(node->context, domain_id);
if (RCL_RET_OK != ret) {
return ret;
Expand Down
2 changes: 1 addition & 1 deletion rcl/test/rcl/test_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ TEST_F(CLASSNAME(TestNodeFixture, RMW_IMPLEMENTATION), test_rcl_node_accessors)
ASSERT_TRUE(rcl_error_is_set());
rcl_reset_error();
ret = rcl_node_get_domain_id(&invalid_node, &actual_domain_id);
EXPECT_EQ(RCL_RET_OK, ret);
EXPECT_EQ(RCL_RET_NODE_INVALID, ret);
rcl_reset_error();
EXPECT_NO_MEMORY_OPERATIONS(
{
Expand Down

0 comments on commit 2cdd2ba

Please sign in to comment.