From 9d57305d09cd371677edf065a38c2af527908bcd Mon Sep 17 00:00:00 2001 From: Mahmoud Mazouz Date: Mon, 25 Nov 2024 17:47:15 +0100 Subject: [PATCH 1/2] Fix `z_view_string_t` to `std::string` conversion --- rmw_zenoh_cpp/src/detail/rmw_service_data.cpp | 5 +++-- rmw_zenoh_cpp/src/detail/rmw_subscription_data.cpp | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/rmw_zenoh_cpp/src/detail/rmw_service_data.cpp b/rmw_zenoh_cpp/src/detail/rmw_service_data.cpp index b51b3973..7eab62d9 100644 --- a/rmw_zenoh_cpp/src/detail/rmw_service_data.cpp +++ b/rmw_zenoh_cpp/src/detail/rmw_service_data.cpp @@ -46,8 +46,9 @@ void service_data_handler(z_loaned_query_t * query, void * data) RMW_ZENOH_LOG_ERROR_NAMED( "rmw_zenoh_cpp", "Unable to obtain ServiceData from data for " - "service for %s", - z_loan(keystr) + "service for %.*s", + static_cast(z_string_len(z_loan(keystr))), + z_string_data(z_loan(keystr)) ); return; } diff --git a/rmw_zenoh_cpp/src/detail/rmw_subscription_data.cpp b/rmw_zenoh_cpp/src/detail/rmw_subscription_data.cpp index 614288f6..ed0a97fc 100644 --- a/rmw_zenoh_cpp/src/detail/rmw_subscription_data.cpp +++ b/rmw_zenoh_cpp/src/detail/rmw_subscription_data.cpp @@ -65,12 +65,14 @@ void sub_data_handler(z_loaned_sample_t * sample, void * data) z_owned_slice_t slice; z_bytes_to_slice(payload, &slice); + std::string topic_name(z_string_data(z_loan(keystr)), z_string_len(z_loan(keystr))); + sub_data->add_new_message( std::make_unique( slice, z_timestamp_ntp64_time(z_sample_timestamp(sample)), std::move(attachment)), - z_string_data(z_loan(keystr))); + &topic_name); } } // namespace From c660a20c807afec6fae8ec47a8e01102ae322d94 Mon Sep 17 00:00:00 2001 From: Mahmoud Mazouz Date: Tue, 26 Nov 2024 13:42:04 +0000 Subject: [PATCH 2/2] Fix formatting --- rmw_zenoh_cpp/src/detail/zenoh_utils.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rmw_zenoh_cpp/src/detail/zenoh_utils.cpp b/rmw_zenoh_cpp/src/detail/zenoh_utils.cpp index 74cf1668..d6f7770c 100644 --- a/rmw_zenoh_cpp/src/detail/zenoh_utils.cpp +++ b/rmw_zenoh_cpp/src/detail/zenoh_utils.cpp @@ -34,7 +34,10 @@ void create_map_and_set_sequence_num( } ///============================================================================= -ZenohQuery::ZenohQuery(const z_loaned_query_t * query, std::chrono::nanoseconds::rep received_timestamp) { +ZenohQuery::ZenohQuery( + const z_loaned_query_t * query, + std::chrono::nanoseconds::rep received_timestamp) +{ z_query_clone(&query_, query); received_timestamp_ = received_timestamp; }