Skip to content

use string_array_t from c_utilities package - #320

Merged
Karsten1987 merged 4 commits into
masterfrom
utilities_string_array
Apr 14, 2017
Merged

Karsten1987 merged 4 commits into
masterfrom
utilities_string_array

Conversation

@Karsten1987

@Karsten1987 Karsten1987 commented Apr 11, 2017 •

Copy link
Copy Markdown
Contributor

connects to ros2/rmw#100

@Karsten1987 Karsten1987 self-assigned this Apr 11, 2017
@Karsten1987 Karsten1987 added the in progress Actively being worked on (Kanban column) label Apr 11, 2017
@mikaelarguedas mikaelarguedas changed the title use c_utilities package use string_array_t from c_utilities package Apr 12, 2017
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) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

excellent catch! thanks

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still applies.

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) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still applies.

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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please address this either in this pr or in an immediate follow up pr?

wjwwood
wjwwood previously approved these changes Apr 13, 2017

@wjwwood wjwwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other than the comments about the weird error message (not added by this pr), lgtm

@Karsten1987

Copy link
Copy Markdown
Contributor Author

@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.

@wjwwood
wjwwood dismissed their stale review April 14, 2017 00:54

new commits

// *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.";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 wjwwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks for iterating @Karsten1987!

@Karsten1987
Karsten1987 merged commit 81b8255 into master Apr 14, 2017
@Karsten1987
Karsten1987 deleted the utilities_string_array branch April 14, 2017 23:18
@Karsten1987 Karsten1987 removed the in progress Actively being worked on (Kanban column) label Apr 14, 2017
nnmm pushed a commit to ApexAI/rclcpp that referenced this pull request Jul 9, 2022
* Add action goal handle implementation and unit tests
* Add check to goal state machine transition function for index out of bounds
DensoADAS pushed a commit to DensoADAS/rclcpp that referenced this pull request Aug 5, 2022
Signed-off-by: Anas Abou Allaban <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants