Skip to content

Commit b88b026

Browse files
authored
Fix destroying safety (#77)
* Pre-regresion * Regresion fixed * Fix * Renaming
1 parent e95eb70 commit b88b026

17 files changed

Lines changed: 54 additions & 42 deletions

rmw_microxrcedds_c/src/rmw_client.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ rmw_create_client(
4040
RMW_SET_ERROR_MSG("node handle is null");
4141
} else if (!type_support) {
4242
RMW_SET_ERROR_MSG("type support is null");
43-
} else if (strcmp(node->implementation_identifier, rmw_get_implementation_identifier()) != 0) {
43+
} else if (!is_uxrce_rmw_identifier_valid(node->implementation_identifier)) {
4444
RMW_SET_ERROR_MSG("node handle not from this implementation");
4545
} else if (!service_name || strlen(service_name) == 0) {
4646
RMW_SET_ERROR_MSG("service name is null or empty string");
@@ -183,7 +183,7 @@ rmw_destroy_client(
183183
if (!node) {
184184
RMW_SET_ERROR_MSG("node handle is null");
185185
result_ret = RMW_RET_ERROR;
186-
} else if (strcmp(node->implementation_identifier, rmw_get_implementation_identifier()) != 0) {
186+
} else if (!is_uxrce_rmw_identifier_valid(node->implementation_identifier)) {
187187
RMW_SET_ERROR_MSG("node handle not from this implementation");
188188
result_ret = RMW_RET_ERROR;
189189
} else if (!node->data) {
@@ -192,10 +192,7 @@ rmw_destroy_client(
192192
} else if (!client) {
193193
RMW_SET_ERROR_MSG("client handle is null");
194194
result_ret = RMW_RET_ERROR;
195-
} else if (strcmp(
196-
client->implementation_identifier, // NOLINT
197-
rmw_get_implementation_identifier()) != 0)
198-
{
195+
} else if (!is_uxrce_rmw_identifier_valid(client->implementation_identifier)) {
199196
RMW_SET_ERROR_MSG("client handle not from this implementation");
200197
result_ret = RMW_RET_ERROR;
201198
} else if (!client->data) {

rmw_microxrcedds_c/src/rmw_node.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ rmw_ret_t rmw_destroy_node(rmw_node_t * node)
148148
return RMW_RET_ERROR;
149149
}
150150

151-
if (strcmp(node->implementation_identifier, rmw_get_implementation_identifier()) != 0) {
151+
if (!is_uxrce_rmw_identifier_valid(node->implementation_identifier)) {
152152
RMW_SET_ERROR_MSG("node handle not from this implementation");
153153
return RMW_RET_ERROR;
154154
}

rmw_microxrcedds_c/src/rmw_publish.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ rmw_publish(
3333
} else if (!ros_message) {
3434
RMW_SET_ERROR_MSG("ros_message pointer is null");
3535
ret = RMW_RET_ERROR;
36-
} else if (strcmp(
37-
publisher->implementation_identifier,
38-
rmw_get_implementation_identifier()) != 0)
36+
} else if (!is_uxrce_rmw_identifier_valid(publisher->implementation_identifier))
3937
{
4038
RMW_SET_ERROR_MSG("publisher handle not from this implementation");
4139
ret = RMW_RET_ERROR;

rmw_microxrcedds_c/src/rmw_publisher.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ rmw_create_publisher(
6767
RMW_SET_ERROR_MSG("node handle is null");
6868
} else if (!type_support) {
6969
RMW_SET_ERROR_MSG("type support is null");
70-
} else if (strcmp(node->implementation_identifier, rmw_get_implementation_identifier()) != 0) {
70+
} else if (!is_uxrce_rmw_identifier_valid(node->implementation_identifier)) {
7171
RMW_SET_ERROR_MSG("node handle not from this implementation");
7272
} else if (!topic_name || strlen(topic_name) == 0) {
7373
RMW_SET_ERROR_MSG("publisher topic is null or empty string");
@@ -288,7 +288,7 @@ rmw_destroy_publisher(
288288
if (!node) {
289289
RMW_SET_ERROR_MSG("node handle is null");
290290
result_ret = RMW_RET_ERROR;
291-
} else if (strcmp(node->implementation_identifier, rmw_get_implementation_identifier()) != 0) {
291+
} else if (!is_uxrce_rmw_identifier_valid(node->implementation_identifier)) {
292292
RMW_SET_ERROR_MSG("node handle not from this implementation");
293293
result_ret = RMW_RET_ERROR;
294294
} else if (!node->data) {
@@ -297,9 +297,7 @@ rmw_destroy_publisher(
297297
} else if (!publisher) {
298298
RMW_SET_ERROR_MSG("publisher handle is null");
299299
result_ret = RMW_RET_ERROR;
300-
} else if (strcmp(
301-
publisher->implementation_identifier, // NOLINT
302-
rmw_get_implementation_identifier()) != 0)
300+
} else if (!is_uxrce_rmw_identifier_valid(publisher->implementation_identifier))
303301
{
304302
RMW_SET_ERROR_MSG("publisher handle not from this implementation");
305303
result_ret = RMW_RET_ERROR;

rmw_microxrcedds_c/src/rmw_request.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ rmw_send_request(
2525
{
2626
EPROS_PRINT_TRACE();
2727

28-
if (strcmp(client->implementation_identifier, rmw_get_implementation_identifier()) != 0) {
28+
if (!is_uxrce_rmw_identifier_valid(client->implementation_identifier)) {
2929
RMW_SET_ERROR_MSG("Wrong implementation");
3030
return RMW_RET_INCORRECT_RMW_IMPLEMENTATION;
3131
}
@@ -74,7 +74,7 @@ rmw_take_request(
7474
*taken = false;
7575
}
7676

77-
if (strcmp(service->implementation_identifier, rmw_get_implementation_identifier()) != 0) {
77+
if (!is_uxrce_rmw_identifier_valid(service->implementation_identifier)) {
7878
RMW_SET_ERROR_MSG("Wrong implementation");
7979
return RMW_RET_INCORRECT_RMW_IMPLEMENTATION;
8080
}

rmw_microxrcedds_c/src/rmw_response.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ rmw_send_response(
2525
{
2626
EPROS_PRINT_TRACE();
2727

28-
if (strcmp(service->implementation_identifier, rmw_get_implementation_identifier()) != 0) {
28+
if (!is_uxrce_rmw_identifier_valid(service->implementation_identifier)) {
2929
RMW_SET_ERROR_MSG("Wrong implementation");
3030
return RMW_RET_INCORRECT_RMW_IMPLEMENTATION;
3131
}
@@ -77,7 +77,7 @@ rmw_take_response(
7777
*taken = false;
7878
}
7979

80-
if (strcmp(client->implementation_identifier, rmw_get_implementation_identifier()) != 0) {
80+
if (!is_uxrce_rmw_identifier_valid(client->implementation_identifier)) {
8181
RMW_SET_ERROR_MSG("Wrong implementation");
8282
return RMW_RET_INCORRECT_RMW_IMPLEMENTATION;
8383
}

rmw_microxrcedds_c/src/rmw_service.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ rmw_create_service(
4040
RMW_SET_ERROR_MSG("node handle is null");
4141
} else if (!type_support) {
4242
RMW_SET_ERROR_MSG("type support is null");
43-
} else if (strcmp(node->implementation_identifier, rmw_get_implementation_identifier()) != 0) {
43+
} else if (!is_uxrce_rmw_identifier_valid(node->implementation_identifier)) {
4444
RMW_SET_ERROR_MSG("node handle not from this implementation");
4545
} else if (!service_name || strlen(service_name) == 0) {
4646
RMW_SET_ERROR_MSG("service name is null or empty string");
@@ -180,7 +180,7 @@ rmw_destroy_service(
180180
if (!node) {
181181
RMW_SET_ERROR_MSG("node handle is null");
182182
result_ret = RMW_RET_ERROR;
183-
} else if (strcmp(node->implementation_identifier, rmw_get_implementation_identifier()) != 0) {
183+
} else if (!is_uxrce_rmw_identifier_valid(node->implementation_identifier)) {
184184
RMW_SET_ERROR_MSG("node handle not from this implementation");
185185
result_ret = RMW_RET_ERROR;
186186
} else if (!node->data) {
@@ -189,10 +189,7 @@ rmw_destroy_service(
189189
} else if (!service) {
190190
RMW_SET_ERROR_MSG("service handle is null");
191191
result_ret = RMW_RET_ERROR;
192-
} else if (strcmp(
193-
service->implementation_identifier, // NOLINT
194-
rmw_get_implementation_identifier()) != 0)
195-
{
192+
} else if (!is_uxrce_rmw_identifier_valid(service->implementation_identifier)) {
196193
RMW_SET_ERROR_MSG("service handle not from this implementation");
197194
result_ret = RMW_RET_ERROR;
198195
} else if (!service->data) {

rmw_microxrcedds_c/src/rmw_subscription.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ rmw_create_subscription(
6464
RMW_SET_ERROR_MSG("node handle is null");
6565
} else if (!type_support) {
6666
RMW_SET_ERROR_MSG("type support is null");
67-
} else if (strcmp(node->implementation_identifier, rmw_get_implementation_identifier()) != 0) {
67+
} else if (!is_uxrce_rmw_identifier_valid(node->implementation_identifier)) {
6868
RMW_SET_ERROR_MSG("node handle not from this implementation");
6969
} else if (!topic_name || strlen(topic_name) == 0) {
7070
RMW_SET_ERROR_MSG("subscription topic is null or empty string");
@@ -267,7 +267,7 @@ rmw_destroy_subscription(rmw_node_t * node, rmw_subscription_t * subscription)
267267
if (!node) {
268268
RMW_SET_ERROR_MSG("node handle is null");
269269
result_ret = RMW_RET_ERROR;
270-
} else if (strcmp(node->implementation_identifier, rmw_get_implementation_identifier()) != 0) {
270+
} else if (!is_uxrce_rmw_identifier_valid(node->implementation_identifier)) {
271271
RMW_SET_ERROR_MSG("node handle not from this implementation");
272272
result_ret = RMW_RET_ERROR;
273273
} else if (!node->data) {
@@ -276,10 +276,7 @@ rmw_destroy_subscription(rmw_node_t * node, rmw_subscription_t * subscription)
276276
} else if (!subscription) {
277277
RMW_SET_ERROR_MSG("subscription handle is null");
278278
result_ret = RMW_RET_ERROR;
279-
} else if (strcmp(
280-
subscription->implementation_identifier, // NOLINT
281-
rmw_get_implementation_identifier()) != 0)
282-
{
279+
} else if (!is_uxrce_rmw_identifier_valid(subscription->implementation_identifier)) {
283280
RMW_SET_ERROR_MSG("subscription handle not from this implementation");
284281
result_ret = RMW_RET_ERROR;
285282
} else if (!subscription->data) {

rmw_microxrcedds_c/src/rmw_take.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ rmw_take_with_info(
4444
*taken = false;
4545
}
4646

47-
if (strcmp(subscription->implementation_identifier, rmw_get_implementation_identifier()) != 0) {
47+
if (!is_uxrce_rmw_identifier_valid(subscription->implementation_identifier)) {
4848
RMW_SET_ERROR_MSG("Wrong implementation");
4949
return RMW_RET_ERROR;
5050
}
@@ -97,7 +97,7 @@ rmw_take_sequence(
9797

9898
*taken = 0;
9999

100-
if (strcmp(subscription->implementation_identifier, rmw_get_implementation_identifier()) != 0) {
100+
if (!is_uxrce_rmw_identifier_valid(subscription->implementation_identifier)) {
101101
RMW_SET_ERROR_MSG("Wrong implementation");
102102
return RMW_RET_ERROR;
103103
}

rmw_microxrcedds_c/src/rmw_trigger_guard_condition.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ rmw_trigger_guard_condition(const rmw_guard_condition_t * guard_condition)
2626
if (!guard_condition) {
2727
RMW_SET_ERROR_MSG("guard condition pointer is null");
2828
ret = RMW_RET_ERROR;
29-
} else if (strcmp(
30-
guard_condition->implementation_identifier,
31-
rmw_get_implementation_identifier()) != 0)
32-
{
29+
} else if (!is_uxrce_rmw_identifier_valid(guard_condition->implementation_identifier)) {
3330
RMW_SET_ERROR_MSG("guard condition handle not from this implementation");
3431
ret = RMW_RET_ERROR;
3532
} else {

0 commit comments

Comments
 (0)