diff --git a/rmw_fastrtps_shared_cpp/src/rmw_node_names.cpp b/rmw_fastrtps_shared_cpp/src/rmw_node_names.cpp index 52b74ab6a..bd7817613 100644 --- a/rmw_fastrtps_shared_cpp/src/rmw_node_names.cpp +++ b/rmw_fastrtps_shared_cpp/src/rmw_node_names.cpp @@ -66,14 +66,14 @@ __rmw_get_node_names( rcutils_ret_t rcutils_ret = rcutils_string_array_init(node_names, participant_names.size() + 1, &allocator); if (rcutils_ret != RCUTILS_RET_OK) { - RMW_SET_ERROR_MSG(rcutils_get_error_string_safe()) + RMW_SET_ERROR_MSG(rcutils_get_error_string().str); goto fail; } rcutils_ret = rcutils_string_array_init(node_namespaces, participant_names.size() + 1, &allocator); if (rcutils_ret != RCUTILS_RET_OK) { - RMW_SET_ERROR_MSG(rcutils_get_error_string_safe()) + RMW_SET_ERROR_MSG(rcutils_get_error_string().str); goto fail; } @@ -86,7 +86,7 @@ __rmw_get_node_names( node_namespaces->data[i] = rcutils_strdup(participant_ns[i - 1].c_str(), allocator); } if (!node_names->data[i] || !node_namespaces->data[i]) { - RMW_SET_ERROR_MSG("failed to allocate memory for node name") + RMW_SET_ERROR_MSG("failed to allocate memory for node name"); goto fail; } } @@ -97,7 +97,7 @@ __rmw_get_node_names( 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()); + "failed to cleanup during error handling: %s", rcutils_get_error_string().str); rcutils_reset_error(); } } @@ -106,7 +106,7 @@ __rmw_get_node_names( 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()); + "failed to cleanup during error handling: %s", rcutils_get_error_string().str); rcutils_reset_error(); } } diff --git a/rmw_fastrtps_shared_cpp/src/rmw_publish.cpp b/rmw_fastrtps_shared_cpp/src/rmw_publish.cpp index 5a67d58d3..88c416075 100644 --- a/rmw_fastrtps_shared_cpp/src/rmw_publish.cpp +++ b/rmw_fastrtps_shared_cpp/src/rmw_publish.cpp @@ -31,11 +31,9 @@ __rmw_publish( const rmw_publisher_t * publisher, const void * ros_message) { - auto error_allocator = rcutils_get_default_allocator(); + RCUTILS_CHECK_FOR_NULL_WITH_MSG(publisher, "publisher pointer is null", return RMW_RET_ERROR); RCUTILS_CHECK_FOR_NULL_WITH_MSG( - publisher, "publisher pointer is null", return RMW_RET_ERROR, error_allocator); - RCUTILS_CHECK_FOR_NULL_WITH_MSG( - ros_message, "ros_message pointer is null", return RMW_RET_ERROR, error_allocator); + ros_message, "ros_message pointer is null", return RMW_RET_ERROR); if (publisher->implementation_identifier != identifier) { RMW_SET_ERROR_MSG("publisher handle not from this implementation"); @@ -43,8 +41,7 @@ __rmw_publish( } auto info = static_cast(publisher->data); - RCUTILS_CHECK_FOR_NULL_WITH_MSG( - info, "publisher info pointer is null", return RMW_RET_ERROR, error_allocator); + RCUTILS_CHECK_FOR_NULL_WITH_MSG(info, "publisher info pointer is null", return RMW_RET_ERROR); rmw_fastrtps_shared_cpp::SerializedData data; data.is_cdr_buffer = false; @@ -63,12 +60,9 @@ __rmw_publish_serialized_message( const rmw_publisher_t * publisher, const rmw_serialized_message_t * serialized_message) { - auto error_allocator = rcutils_get_default_allocator(); + RCUTILS_CHECK_FOR_NULL_WITH_MSG(publisher, "publisher pointer is null", return RMW_RET_ERROR); RCUTILS_CHECK_FOR_NULL_WITH_MSG( - publisher, "publisher pointer is null", return RMW_RET_ERROR, error_allocator); - RCUTILS_CHECK_FOR_NULL_WITH_MSG( - serialized_message, "serialized_message pointer is null", - return RMW_RET_ERROR, error_allocator); + serialized_message, "serialized_message pointer is null", return RMW_RET_ERROR); if (publisher->implementation_identifier != identifier) { RMW_SET_ERROR_MSG("publisher handle not from this implementation"); @@ -76,8 +70,7 @@ __rmw_publish_serialized_message( } auto info = static_cast(publisher->data); - RCUTILS_CHECK_FOR_NULL_WITH_MSG( - info, "publisher info pointer is null", return RMW_RET_ERROR, error_allocator); + RCUTILS_CHECK_FOR_NULL_WITH_MSG(info, "publisher info pointer is null", return RMW_RET_ERROR); eprosima::fastcdr::FastBuffer buffer( serialized_message->buffer, serialized_message->buffer_length); diff --git a/rmw_fastrtps_shared_cpp/src/rmw_service_names_and_types.cpp b/rmw_fastrtps_shared_cpp/src/rmw_service_names_and_types.cpp index 7c14431ae..0ac7c7b5c 100644 --- a/rmw_fastrtps_shared_cpp/src/rmw_service_names_and_types.cpp +++ b/rmw_fastrtps_shared_cpp/src/rmw_service_names_and_types.cpp @@ -41,11 +41,11 @@ __rmw_get_service_names_and_types( rmw_names_and_types_t * service_names_and_types) { if (!allocator) { - RMW_SET_ERROR_MSG("allocator is null") + RMW_SET_ERROR_MSG("allocator is null"); return RMW_RET_INVALID_ARGUMENT; } if (!node) { - RMW_SET_ERROR_MSG_ALLOC("null node handle", *allocator) + RMW_SET_ERROR_MSG("null node handle"); return RMW_RET_INVALID_ARGUMENT; } rmw_ret_t ret = rmw_names_and_types_check_zero(service_names_and_types); @@ -55,7 +55,7 @@ __rmw_get_service_names_and_types( // Get participant pointer from node if (node->implementation_identifier != identifier) { - RMW_SET_ERROR_MSG_ALLOC("node handle not from this implementation", *allocator); + RMW_SET_ERROR_MSG("node handle not from this implementation"); return RMW_RET_ERROR; } @@ -116,7 +116,7 @@ __rmw_get_service_names_and_types( if (rmw_ret != RMW_RET_OK) { RCUTILS_LOG_ERROR_NAMED( "rmw_fastrtps_shared_cpp", - "error during report of error: %s", rmw_get_error_string_safe()); + "error during report of error: %s", rmw_get_error_string().str); } }; // For each service, store the name, initialize the string array for types, and store all types @@ -125,7 +125,7 @@ __rmw_get_service_names_and_types( // Duplicate and store the service_name char * service_name = rcutils_strdup(service_n_types.first.c_str(), *allocator); if (!service_name) { - RMW_SET_ERROR_MSG_ALLOC("failed to allocate memory for service name", *allocator); + RMW_SET_ERROR_MSG("failed to allocate memory for service name"); fail_cleanup(); return RMW_RET_BAD_ALLOC; } @@ -137,7 +137,7 @@ __rmw_get_service_names_and_types( service_n_types.second.size(), allocator); if (rcutils_ret != RCUTILS_RET_OK) { - RMW_SET_ERROR_MSG(rcutils_get_error_string_safe()) + RMW_SET_ERROR_MSG(rcutils_get_error_string().str); fail_cleanup(); return rmw_convert_rcutils_ret_to_rmw_ret(rcutils_ret); } @@ -147,7 +147,7 @@ __rmw_get_service_names_and_types( for (const auto & type : service_n_types.second) { char * type_name = rcutils_strdup(type.c_str(), *allocator); if (!type_name) { - RMW_SET_ERROR_MSG_ALLOC("failed to allocate memory for type name", *allocator) + RMW_SET_ERROR_MSG("failed to allocate memory for type name"); fail_cleanup(); return RMW_RET_BAD_ALLOC; } diff --git a/rmw_fastrtps_shared_cpp/src/rmw_take.cpp b/rmw_fastrtps_shared_cpp/src/rmw_take.cpp index 8a2dc6446..8621e239b 100644 --- a/rmw_fastrtps_shared_cpp/src/rmw_take.cpp +++ b/rmw_fastrtps_shared_cpp/src/rmw_take.cpp @@ -59,9 +59,7 @@ _take( } CustomSubscriberInfo * info = static_cast(subscription->data); - auto error_msg_allocator = rcutils_get_default_allocator(); - RCUTILS_CHECK_FOR_NULL_WITH_MSG( - info, "custom subscriber info is null", return RMW_RET_ERROR, error_msg_allocator); + RCUTILS_CHECK_FOR_NULL_WITH_MSG(info, "custom subscriber info is null", return RMW_RET_ERROR); eprosima::fastrtps::SampleInfo_t sinfo; @@ -89,13 +87,11 @@ __rmw_take( void * ros_message, bool * taken) { - auto error_msg_allocator = rcutils_get_default_allocator(); - RCUTILS_CHECK_FOR_NULL_WITH_MSG( - subscription, "subscription pointer is null", return RMW_RET_ERROR, error_msg_allocator); RCUTILS_CHECK_FOR_NULL_WITH_MSG( - ros_message, "ros_message pointer is null", return RMW_RET_ERROR, error_msg_allocator); + subscription, "subscription pointer is null", return RMW_RET_ERROR); RCUTILS_CHECK_FOR_NULL_WITH_MSG( - taken, "boolean flag for taken is null", return RMW_RET_ERROR, error_msg_allocator); + ros_message, "ros_message pointer is null", return RMW_RET_ERROR); + RCUTILS_CHECK_FOR_NULL_WITH_MSG(taken, "boolean flag for taken is null", return RMW_RET_ERROR); return _take(identifier, subscription, ros_message, taken, nullptr); } @@ -108,15 +104,13 @@ __rmw_take_with_info( bool * taken, rmw_message_info_t * message_info) { - auto error_msg_allocator = rcutils_get_default_allocator(); - RCUTILS_CHECK_FOR_NULL_WITH_MSG( - subscription, "subscription pointer is null", return RMW_RET_ERROR, error_msg_allocator); RCUTILS_CHECK_FOR_NULL_WITH_MSG( - ros_message, "ros_message pointer is null", return RMW_RET_ERROR, error_msg_allocator); + subscription, "subscription pointer is null", return RMW_RET_ERROR); RCUTILS_CHECK_FOR_NULL_WITH_MSG( - taken, "boolean flag for taken is null", return RMW_RET_ERROR, error_msg_allocator); + ros_message, "ros_message pointer is null", return RMW_RET_ERROR); + RCUTILS_CHECK_FOR_NULL_WITH_MSG(taken, "boolean flag for taken is null", return RMW_RET_ERROR); RCUTILS_CHECK_FOR_NULL_WITH_MSG( - message_info, "message info pointer is null", return RMW_RET_ERROR, error_msg_allocator); + message_info, "message info pointer is null", return RMW_RET_ERROR); return _take(identifier, subscription, ros_message, taken, message_info); } @@ -137,9 +131,7 @@ _take_serialized_message( } CustomSubscriberInfo * info = static_cast(subscription->data); - auto error_msg_allocator = rcutils_get_default_allocator(); - RCUTILS_CHECK_FOR_NULL_WITH_MSG( - info, "custom subscriber info is null", return RMW_RET_ERROR, error_msg_allocator); + RCUTILS_CHECK_FOR_NULL_WITH_MSG(info, "custom subscriber info is null", return RMW_RET_ERROR); eprosima::fastcdr::FastBuffer buffer; eprosima::fastrtps::SampleInfo_t sinfo; @@ -178,13 +170,11 @@ __rmw_take_serialized_message( rmw_serialized_message_t * serialized_message, bool * taken) { - auto error_msg_allocator = rcutils_get_default_allocator(); - RCUTILS_CHECK_FOR_NULL_WITH_MSG( - subscription, "subscription pointer is null", return RMW_RET_ERROR, error_msg_allocator); RCUTILS_CHECK_FOR_NULL_WITH_MSG( - serialized_message, "ros_message pointer is null", return RMW_RET_ERROR, error_msg_allocator); + subscription, "subscription pointer is null", return RMW_RET_ERROR); RCUTILS_CHECK_FOR_NULL_WITH_MSG( - taken, "boolean flag for taken is null", return RMW_RET_ERROR, error_msg_allocator); + serialized_message, "ros_message pointer is null", return RMW_RET_ERROR); + RCUTILS_CHECK_FOR_NULL_WITH_MSG(taken, "boolean flag for taken is null", return RMW_RET_ERROR); return _take_serialized_message(identifier, subscription, serialized_message, taken, nullptr); } @@ -197,15 +187,13 @@ __rmw_take_serialized_message_with_info( bool * taken, rmw_message_info_t * message_info) { - auto error_msg_allocator = rcutils_get_default_allocator(); - RCUTILS_CHECK_FOR_NULL_WITH_MSG( - subscription, "subscription pointer is null", return RMW_RET_ERROR, error_msg_allocator); RCUTILS_CHECK_FOR_NULL_WITH_MSG( - serialized_message, "ros_message pointer is null", return RMW_RET_ERROR, error_msg_allocator); + subscription, "subscription pointer is null", return RMW_RET_ERROR); RCUTILS_CHECK_FOR_NULL_WITH_MSG( - taken, "boolean flag for taken is null", return RMW_RET_ERROR, error_msg_allocator); + serialized_message, "ros_message pointer is null", return RMW_RET_ERROR); + RCUTILS_CHECK_FOR_NULL_WITH_MSG(taken, "boolean flag for taken is null", return RMW_RET_ERROR); RCUTILS_CHECK_FOR_NULL_WITH_MSG( - message_info, "message info pointer is null", return RMW_RET_ERROR, error_msg_allocator); + message_info, "message info pointer is null", return RMW_RET_ERROR); return _take_serialized_message( identifier, subscription, serialized_message, taken, message_info); diff --git a/rmw_fastrtps_shared_cpp/src/rmw_topic_names_and_types.cpp b/rmw_fastrtps_shared_cpp/src/rmw_topic_names_and_types.cpp index 9e2bacde6..4023938b8 100644 --- a/rmw_fastrtps_shared_cpp/src/rmw_topic_names_and_types.cpp +++ b/rmw_fastrtps_shared_cpp/src/rmw_topic_names_and_types.cpp @@ -49,11 +49,11 @@ __rmw_get_topic_names_and_types( rmw_names_and_types_t * topic_names_and_types) { if (!allocator) { - RMW_SET_ERROR_MSG("allocator is null") + RMW_SET_ERROR_MSG("allocator is null"); return RMW_RET_INVALID_ARGUMENT; } if (!node) { - RMW_SET_ERROR_MSG_ALLOC("null node handle", *allocator) + RMW_SET_ERROR_MSG("null node handle"); return RMW_RET_INVALID_ARGUMENT; } @@ -64,7 +64,7 @@ __rmw_get_topic_names_and_types( // Get participant pointer from node if (node->implementation_identifier != identifier) { - RMW_SET_ERROR_MSG_ALLOC("node handle not from this implementation", *allocator); + RMW_SET_ERROR_MSG("node handle not from this implementation"); return RMW_RET_ERROR; } @@ -116,7 +116,7 @@ __rmw_get_topic_names_and_types( if (rmw_ret != RMW_RET_OK) { RCUTILS_LOG_ERROR_NAMED( "rmw_fastrtps_shared_cpp", - "error during report of error: %s", rmw_get_error_string_safe()); + "error during report of error: %s", rmw_get_error_string().str); } }; // Setup demangling functions based on no_demangle option @@ -135,7 +135,7 @@ __rmw_get_topic_names_and_types( // Duplicate and store the topic_name char * topic_name = rcutils_strdup(demangle_topic(topic_n_types.first).c_str(), *allocator); if (!topic_name) { - RMW_SET_ERROR_MSG_ALLOC("failed to allocate memory for topic name", *allocator); + RMW_SET_ERROR_MSG("failed to allocate memory for topic name"); fail_cleanup(); return RMW_RET_BAD_ALLOC; } @@ -147,7 +147,7 @@ __rmw_get_topic_names_and_types( topic_n_types.second.size(), allocator); if (rcutils_ret != RCUTILS_RET_OK) { - RMW_SET_ERROR_MSG(rcutils_get_error_string_safe()) + RMW_SET_ERROR_MSG(rcutils_get_error_string().str); fail_cleanup(); return rmw_convert_rcutils_ret_to_rmw_ret(rcutils_ret); } @@ -157,7 +157,7 @@ __rmw_get_topic_names_and_types( for (const auto & type : topic_n_types.second) { char * type_name = rcutils_strdup(demangle_type(type).c_str(), *allocator); if (!type_name) { - RMW_SET_ERROR_MSG_ALLOC("failed to allocate memory for type name", *allocator) + RMW_SET_ERROR_MSG("failed to allocate memory for type name"); fail_cleanup(); return RMW_RET_BAD_ALLOC; }