Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Remove rmw_connext dead code #258

Closed
wants to merge 1 commit into from
Closed

Conversation

gaoethan
Copy link

Dead code in API rmw_create_subscription()
the condition "subscription" cannot be true in the "fail"
clauses and the execution never reaches this statement:

if (subscription) {
    rmw_subscription_free(subscription);
    }

the "subscribtion" will be finally free by
rmw_destroy_subscription() when it's not a nullptr

Dead code in API rmw_create_publisher()
the condition "publisher" cannot be true in the "fail"
clauses, so the execution cannot reach this statement:

if (publisher) {
    rmw_publisher_free(publisher);
    }

the "publisher" will be finally free by
rmw_destroy_publisher() when it's not a nullptr

Signed-off-by: Ethan Gao ethan.gao@linux.intel.com

Dead code in API rmw_create_subscription()
the condition "subscription" cannot be true in the "fail"
clauses and the execution never reaches this statement:

if (subscription) {
    rmw_subscription_free(subscription);
    }

the "subscribtion" will be finally free by
rmw_destroy_subscription() when it's not a nullptr

Dead code in API rmw_create_publisher()
the condition "publisher" cannot be true in the "fail"
clauses, so the execution cannot reach this statement:

if (publisher) {
    rmw_publisher_free(publisher);
    }

the "publisher" will be finally free by
rmw_destroy_publisher() when it's not a nullptr

Signed-off-by: Ethan Gao <ethan.gao@linux.intel.com>
@Karsten1987
Copy link
Contributor

I may miss something here, but I think this PR is not correct. Opposite to your PR in rmw_fastrtps_cpp ros2/rmw_fastrtps#163, in rmw_connext_cpp the memory allocation for the publisher happens first [0] and thus still can end up in a fail state.

[0] https://github.com/ros2/rmw_connext/blob/master/rmw_connext_cpp/src/rmw_publisher.cpp#L102

@@ -252,9 +252,7 @@ rmw_create_publisher(
DDS_String_free(topic_str);
topic_str = nullptr;
}
if (publisher) {
Copy link
Member

Choose a reason for hiding this comment

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

@gaoethan
Copy link
Author

@Karsten1987 @dirk-thomas yes, you're correct and I missed that, thanks 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants