-
Notifications
You must be signed in to change notification settings - Fork 33
Include node namespaces in get_node_names #299
Conversation
rmw_connext_shared_cpp/src/node.cpp
Outdated
|
||
snprintf(reinterpret_cast<char *>(participant_qos.user_data.value.get_contiguous_buffer()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be a good idea to check the return code of snprintf
.
if (rcutils_ret != RCUTILS_RET_OK) { | ||
RCUTILS_LOG_ERROR_NAMED( | ||
"rmw_connext_cpp", | ||
"failed to cleanup during error handling: %s", rcutils_get_error_string_safe()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to reset the error message here with rcutils_reset_error()
.
if (!node_namespaces->data[i]) { | ||
RMW_SET_ERROR_MSG("could not allocate memory for node namespace") | ||
rcutils_ret = rcutils_string_array_fini(node_names); | ||
rcutils_ret = rcutils_string_array_fini(node_namespaces); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If both fail then you'll need to reset the error state between them, but then again, perhaps that's ok or even intentional.
Separately I'll say that rather than duplicating this cleanup code, I'd recommend using a label and a goto to have it happen in one place.
* Use goto to handle failure conditions. * Check snprintf return.
c741336
to
e0d1e0d
Compare
* Include node namespaces in get_node_names. * Address reviewer feedback. * Use goto to handle failure conditions * Fix typo. Signed-off-by: Devin Bonnie <[email protected]>
Connects to ros2/rmw#142