From e8e79b5ae45f9c5f24ed7075f57b3e984b4cf892 Mon Sep 17 00:00:00 2001 From: Michel Hidalgo Date: Thu, 20 Aug 2020 10:26:00 -0300 Subject: [PATCH 1/2] Ensure compliant publisher QoS queries. Follow-up after 8fc9ca3d98a64118590a205b2162559e17309a27. Signed-off-by: Michel Hidalgo --- rmw_fastrtps_cpp/src/rmw_publisher.cpp | 8 +++++++ .../src/rmw_publisher.cpp | 8 +++++++ rmw_fastrtps_shared_cpp/src/rmw_publisher.cpp | 21 ++++++------------- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/rmw_fastrtps_cpp/src/rmw_publisher.cpp b/rmw_fastrtps_cpp/src/rmw_publisher.cpp index 976964f3e..2c3b606ed 100644 --- a/rmw_fastrtps_cpp/src/rmw_publisher.cpp +++ b/rmw_fastrtps_cpp/src/rmw_publisher.cpp @@ -139,6 +139,14 @@ rmw_publisher_get_actual_qos( const rmw_publisher_t * publisher, rmw_qos_profile_t * qos) { + RMW_CHECK_ARGUMENT_FOR_NULL(publisher, RMW_RET_INVALID_ARGUMENT); + RMW_CHECK_TYPE_IDENTIFIERS_MATCH( + publisher, + publisher->implementation_identifier, + eprosima_fastrtps_identifier, + return RMW_RET_INCORRECT_RMW_IMPLEMENTATION); + RMW_CHECK_ARGUMENT_FOR_NULL(qos, RMW_RET_INVALID_ARGUMENT); + return rmw_fastrtps_shared_cpp::__rmw_publisher_get_actual_qos( publisher, qos); } diff --git a/rmw_fastrtps_dynamic_cpp/src/rmw_publisher.cpp b/rmw_fastrtps_dynamic_cpp/src/rmw_publisher.cpp index e9f5fe3f9..52ce14713 100644 --- a/rmw_fastrtps_dynamic_cpp/src/rmw_publisher.cpp +++ b/rmw_fastrtps_dynamic_cpp/src/rmw_publisher.cpp @@ -143,6 +143,14 @@ rmw_publisher_get_actual_qos( const rmw_publisher_t * publisher, rmw_qos_profile_t * qos) { + RMW_CHECK_ARGUMENT_FOR_NULL(publisher, RMW_RET_INVALID_ARGUMENT); + RMW_CHECK_TYPE_IDENTIFIERS_MATCH( + publisher, + publisher->implementation_identifier, + eprosima_fastrtps_identifier, + return RMW_RET_INCORRECT_RMW_IMPLEMENTATION); + RMW_CHECK_ARGUMENT_FOR_NULL(qos, RMW_RET_INVALID_ARGUMENT); + return rmw_fastrtps_shared_cpp::__rmw_publisher_get_actual_qos( publisher, qos); } diff --git a/rmw_fastrtps_shared_cpp/src/rmw_publisher.cpp b/rmw_fastrtps_shared_cpp/src/rmw_publisher.cpp index 143c7ced1..8ff5d21f6 100644 --- a/rmw_fastrtps_shared_cpp/src/rmw_publisher.cpp +++ b/rmw_fastrtps_shared_cpp/src/rmw_publisher.cpp @@ -125,22 +125,13 @@ __rmw_publisher_get_actual_qos( const rmw_publisher_t * publisher, rmw_qos_profile_t * qos) { - RMW_CHECK_ARGUMENT_FOR_NULL(publisher, RMW_RET_INVALID_ARGUMENT); - RMW_CHECK_ARGUMENT_FOR_NULL(qos, RMW_RET_INVALID_ARGUMENT); - - auto info = static_cast(publisher->data); - if (info == nullptr) { - return RMW_RET_ERROR; - } - eprosima::fastrtps::Publisher * fastrtps_pub = info->publisher_; - if (fastrtps_pub == nullptr) { - return RMW_RET_ERROR; - } - const eprosima::fastrtps::PublisherAttributes & attributes = - fastrtps_pub->getAttributes(); + auto info = static_cast(publisher->data); + eprosima::fastrtps::Publisher * fastrtps_pub = info->publisher_; + const eprosima::fastrtps::PublisherAttributes & attributes = + fastrtps_pub->getAttributes(); - dds_attributes_to_rmw_qos(attributes, qos); + dds_attributes_to_rmw_qos(attributes, qos); - return RMW_RET_OK; + return RMW_RET_OK; } } // namespace rmw_fastrtps_shared_cpp From afbb6b7f33b7da7d4269f210a4ad9847a6b3bee5 Mon Sep 17 00:00:00 2001 From: Michel Hidalgo Date: Thu, 20 Aug 2020 12:22:56 -0300 Subject: [PATCH 2/2] Please uncrustify. Signed-off-by: Michel Hidalgo --- rmw_fastrtps_shared_cpp/src/rmw_publisher.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rmw_fastrtps_shared_cpp/src/rmw_publisher.cpp b/rmw_fastrtps_shared_cpp/src/rmw_publisher.cpp index 8ff5d21f6..afa4b2e61 100644 --- a/rmw_fastrtps_shared_cpp/src/rmw_publisher.cpp +++ b/rmw_fastrtps_shared_cpp/src/rmw_publisher.cpp @@ -125,13 +125,13 @@ __rmw_publisher_get_actual_qos( const rmw_publisher_t * publisher, rmw_qos_profile_t * qos) { - auto info = static_cast(publisher->data); - eprosima::fastrtps::Publisher * fastrtps_pub = info->publisher_; - const eprosima::fastrtps::PublisherAttributes & attributes = - fastrtps_pub->getAttributes(); + auto info = static_cast(publisher->data); + eprosima::fastrtps::Publisher * fastrtps_pub = info->publisher_; + const eprosima::fastrtps::PublisherAttributes & attributes = + fastrtps_pub->getAttributes(); - dds_attributes_to_rmw_qos(attributes, qos); + dds_attributes_to_rmw_qos(attributes, qos); - return RMW_RET_OK; + return RMW_RET_OK; } } // namespace rmw_fastrtps_shared_cpp