From 410aa61d81b0993398893129fdc157319f594e02 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 2 Jun 2022 11:09:30 -0300 Subject: [PATCH] Fix the history depth for KEEP_ALL. (#305) (#394) The comment in the code explains it in a lot more detail, but essentially this avoids a signed/unsigned mismatch in higher level code. Since the depth is meaningless in KEEP_ALL anyway, this shouldn't have any deleterious effects elsewhere. Signed-off-by: Chris Lalancette (cherry picked from commit d5980d5a8fb753d2d7074c635426b9a2805928ba) Co-authored-by: Chris Lalancette --- rmw_cyclonedds_cpp/src/rmw_node.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/rmw_cyclonedds_cpp/src/rmw_node.cpp b/rmw_cyclonedds_cpp/src/rmw_node.cpp index 2a8de48..cc98484 100644 --- a/rmw_cyclonedds_cpp/src/rmw_node.cpp +++ b/rmw_cyclonedds_cpp/src/rmw_node.cpp @@ -1739,7 +1739,13 @@ static bool dds_qos_to_rmw_qos(const dds_qos_t * dds_qos, rmw_qos_profile_t * qo break; case DDS_HISTORY_KEEP_ALL: qos_policies->history = RMW_QOS_POLICY_HISTORY_KEEP_ALL; - qos_policies->depth = (uint32_t) depth; + // When using a policy of KEEP_ALL, the depth is meaningless. + // CycloneDDS reports this as -1, but the rmw_qos_profile_t structure + // expects an unsigned number. Casting -1 to unsigned would yield + // a value of 2^32 - 1, but unfortunately our XML-RPC connection + // (used for the command-line tools) doesn't understand anything + // larger than 2^31 - 1. Just set the depth to 0 here instead. + qos_policies->depth = 0; break; default: rmw_cyclonedds_cpp::unreachable();