Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly recalculate serialized size on bounded sequences #540

Merged
merged 1 commit into from
Aug 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions rmw_fastrtps_cpp/src/type_support_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ void TypeSupport::set_members(const message_type_support_callbacks_t * members)
max_size_bound_ = 0 != (bounds_info & ROSIDL_TYPESUPPORT_FASTRTPS_BOUNDED_TYPE);
is_plain_ = bounds_info == ROSIDL_TYPESUPPORT_FASTRTPS_PLAIN_TYPE;
#else
max_size_bound_ = true;
auto data_size = static_cast<uint32_t>(members->max_serialized_size(max_size_bound_));
is_plain_ = true;
auto data_size = static_cast<uint32_t>(members->max_serialized_size(is_plain_));
max_size_bound_ = is_plain_;
#endif

// A fully bound message of size 0 is an empty message
if (max_size_bound_ && (data_size == 0) ) {
// A plain message of size 0 is an empty message
if (is_plain_ && (data_size == 0) ) {
has_data_ = false;
++data_size; // Dummy byte
} else {
Expand All @@ -58,7 +59,7 @@ void TypeSupport::set_members(const message_type_support_callbacks_t * members)

size_t TypeSupport::getEstimatedSerializedSize(const void * ros_message, const void * impl) const
{
if (max_size_bound_) {
if (is_plain_) {
return m_typeSize;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ template<typename MembersType>
size_t TypeSupport<MembersType>::getEstimatedSerializedSize(
const void * ros_message, const void * impl) const
{
if (max_size_bound_) {
if (is_plain_) {
return m_typeSize;
}

Expand Down