Repository navigation
use string_array_t from c_utilities package - #320
Conversation
| if (ret != RMW_RET_OK) { | ||
| if (rmw_destroy_node_names(&node_names_c) != RMW_RET_OK) { | ||
| if (ret != RCL_RET_OK) { | ||
| if (utilities_string_array_fini(&node_names_c) != RCL_RET_OK) { |
There was a problem hiding this comment.
Shouldn't the return code be compared to one of these: https://github.com/ros2/c_utilities/blob/e6ff86450ddef392b18cb15a2bf5b165f77ca3d0/include/c_utilities/types/utilities_ret.h#L24-L26
There was a problem hiding this comment.
excellent catch! thanks
| if (ret != RMW_RET_OK) { | ||
| if (rmw_destroy_node_names(&node_names_c) != RMW_RET_OK) { | ||
| if (ret != RCL_RET_OK) { | ||
| if (utilities_string_array_fini(&node_names_c) != RCL_RET_OK) { |
| std::vector<std::string> node_names(&node_names_c.data[0], | ||
| &node_names_c.data[0 + node_names_c.size]); | ||
| ret = rmw_destroy_node_names(&node_names_c); | ||
| ret = utilities_string_array_fini(&node_names_c); |
There was a problem hiding this comment.
Same thing here, it's being compared to RMW_RET_OK, should be UTILITIES_RET_OK.
| // *INDENT-OFF* | ||
| throw std::runtime_error( | ||
| std::string("could not destroy node names: ") + rmw_get_error_string_safe()); | ||
| std::string("could not destroy node names: ") + rcl_get_error_string_safe()); |
There was a problem hiding this comment.
Is there actually an error string set here now that it is in utilities_string_array_fini()?
| if (rmw_destroy_node_names(&node_names_c) != RMW_RET_OK) { | ||
| if (ret != RCL_RET_OK) { | ||
| if (utilities_string_array_fini(&node_names_c) != UTILITIES_RET_OK) { | ||
| RMW_SET_ERROR_MSG("Fatal: Leaking node_name memory."); |
There was a problem hiding this comment.
Sorry, I know this isn't part of this pr, but this looks wrong. This should either print to stderr or throw an exception, probably the latter. No one is going to check the rmw error state after this function is called.
There was a problem hiding this comment.
Can you please address this either in this pr or in an immediate follow up pr?
wjwwood
left a comment
There was a problem hiding this comment.
other than the comments about the weird error message (not added by this pr), lgtm
|
@wjwwood Would you mind reviewing the last commit again? I also think to have fixed a memory leak for the topic_names_and_types as this was not destroying memory before throwing. I'll anyway run a new batch of CI before merging all this. |
| // *INDENT-ON* | ||
| auto error_msg = std::string("Failed to get topic names and types."); | ||
| if (rmw_destroy_topic_names_and_types(&topic_names_and_types) != RMW_RET_OK) { | ||
| error_msg += "Fatal: Leaking topic_names_and_types memory."; |
There was a problem hiding this comment.
This would end up with a string like Failed to get topic names and types.Fatal: Leaking topic_names_and_types memory. which would be strange.
I think it's acceptable to throw from here, overruling the throw on the next line. Or you could throw here and reword it as failed to cleanup after failing to get the topic names and types, leaking memory.
Also, try to follow the existing style for error messages were possible. The message you're removing notably is not capitalized and lacks punctuation. This is also the case in other places in this file already.
wjwwood
left a comment
There was a problem hiding this comment.
Looks great, thanks for iterating @Karsten1987!
* Add action goal handle implementation and unit tests * Add check to goal state machine transition function for index out of bounds
Signed-off-by: Anas Abou Allaban <[email protected]>
connects to ros2/rmw#100