Skip to content

Commit e1a42f3

Browse files
authored
[#24584] Fix TypeObjectRegistry null pass to a callee (#6415)
* [#24584] Fixed MacOS tests compilation errors Signed-off-by: danipiza <dpizarrogallego@gmail.com> * [#24584] Fix TypeObjectRegistry null pass to a callee + regression tests Signed-off-by: danipiza <dpizarrogallego@gmail.com> * [#24585] Applied uncrusity + fix v142/3 builds Signed-off-by: danipiza <dpizarrogallego@gmail.com> * [#24585] Fixed windows build Signed-off-by: danipiza <dpizarrogallego@gmail.com> --------- Signed-off-by: danipiza <dpizarrogallego@gmail.com>
1 parent 9a31251 commit e1a42f3

27 files changed

Lines changed: 206 additions & 142 deletions

File tree

src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2617,7 +2617,7 @@ ReturnCode_t TypeObjectRegistry::set_annotation_parameter_value(
26172617
TypeValueConverter::sto(value) : 0));
26182618
break;
26192619
case TK_CHAR8:
2620-
param_value = TypeObjectUtils::build_annotation_parameter_value(!value.empty() ? value : 0);
2620+
param_value = TypeObjectUtils::build_annotation_parameter_value(!value.empty() ? value[0] : '\0');
26212621
break;
26222622
case TK_ENUM:
26232623
{

src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.hpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,12 @@ struct TypeRegistryEntry
8282

8383
// Class which holds the TypeObject registry, including every TypeIdentifier (plain and non-plain types), every
8484
// non-plain TypeObject and the non-plain TypeObject serialized sizes.
85-
class TypeObjectRegistry : public ITypeObjectRegistry
85+
// Exported so shared-library test targets can instantiate thin helper subclasses on Windows.
86+
#ifdef _MSC_VER
87+
#pragma warning(push)
88+
#pragma warning(disable:4251)
89+
#endif // _MSC_VER
90+
class FASTDDS_EXPORTED_API TypeObjectRegistry : public ITypeObjectRegistry
8691
{
8792

8893
public:
@@ -1118,6 +1123,9 @@ class TypeObjectRegistry : public ITypeObjectRegistry
11181123
std::mutex type_object_registry_mutex_;
11191124

11201125
};
1126+
#ifdef _MSC_VER
1127+
#pragma warning(pop)
1128+
#endif // _MSC_VER
11211129

11221130
} // namespace xtypes
11231131
} // namespace dds

src/cpp/utils/collections/FixedSizeQueue.hpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class FixedSizeQueue
4747
public:
4848

4949
using allocator_type = _Alloc;
50+
using allocator_traits = std::allocator_traits<allocator_type>;
5051
using value_type = _Ty;
5152
using pointer = _Ty*;
5253
using const_pointer = const _Ty*;
@@ -346,7 +347,7 @@ class FixedSizeQueue
346347
return false;
347348
}
348349
--head_;
349-
allocator_.construct(&(*head_), val);
350+
allocator_traits::construct(allocator_, &(*head_), val);
350351
++size_;
351352
return true;
352353
}
@@ -386,7 +387,7 @@ class FixedSizeQueue
386387
return false;
387388
}
388389
--head_;
389-
allocator_.construct(&(*head_), std::forward<Args &&>(args)...);
390+
allocator_traits::construct(allocator_, &(*head_), std::forward<Args &&>(args)...);
390391
++size_;
391392
return true;
392393
}
@@ -406,7 +407,7 @@ class FixedSizeQueue
406407
{
407408
return false;
408409
}
409-
allocator_.construct(&(*tail_), val);
410+
allocator_traits::construct(allocator_, &(*tail_), val);
410411
++tail_;
411412
++size_;
412413
return true;
@@ -446,7 +447,7 @@ class FixedSizeQueue
446447
{
447448
return false;
448449
}
449-
allocator_.construct(&(*tail_), std::forward<Args &&>(args)...);
450+
allocator_traits::construct(allocator_, &(*tail_), std::forward<Args &&>(args)...);
450451
++tail_;
451452
++size_;
452453
return true;
@@ -464,7 +465,7 @@ class FixedSizeQueue
464465
{
465466
return false;
466467
}
467-
allocator_.destroy(&(*head_));
468+
allocator_traits::destroy(allocator_, &(*head_));
468469
++head_;
469470
--size_;
470471
return true;
@@ -483,7 +484,7 @@ class FixedSizeQueue
483484
return false;
484485
}
485486
--tail_;
486-
allocator_.destroy(&(*tail_));
487+
allocator_traits::destroy(allocator_, &(*tail_));
487488
--size_;
488489
return true;
489490
}
@@ -652,7 +653,7 @@ class FixedSizeQueue
652653
++head_;
653654
memmove(&(*head_), &(*old_head), (pos - old_head) * sizeof(value_type));
654655

655-
allocator_.destroy(&(*old_head));
656+
allocator_traits::destroy(allocator_, &(*old_head));
656657
--size_;
657658
iterator next = pos;
658659
return ++next;
@@ -664,7 +665,7 @@ class FixedSizeQueue
664665
memmove(&(*pos), &(*next), (tail_ - pos) * sizeof(value_type));
665666

666667
--tail_;
667-
allocator_.destroy(&(*tail_));
668+
allocator_traits::destroy(allocator_, &(*tail_));
668669
--size_;
669670
return pos;
670671
}

test/blackbox/common/BlackboxTestsTransportTCP.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ TEST_P(TransportTCP, send_resource_cleanup)
500500
}
501501
return tcp_send_resources;
502502
};
503-
EXPECT_EQ(tcp_send_resources(send_resource_list), 1);
503+
EXPECT_EQ(tcp_send_resources(send_resource_list), 1u);
504504

505505
// Release TCP client resources.
506506
client.reset();
@@ -521,7 +521,7 @@ TEST_P(TransportTCP, send_resource_cleanup)
521521
// Check that the send_resource_list has size 0. This means that the send resource
522522
// for the client has been removed.
523523
send_resource_list = server_chaining_transport->get_send_resource_list();
524-
EXPECT_EQ(tcp_send_resources(send_resource_list), 0);
524+
EXPECT_EQ(tcp_send_resources(send_resource_list), 0u);
525525
send_resource_list.clear();
526526
}
527527

@@ -644,7 +644,7 @@ TEST_P(TransportTCP, send_resource_cleanup_initial_peer)
644644
}
645645
return tcp_send_resources;
646646
};
647-
EXPECT_EQ(tcp_send_resources(send_resource_list), 1);
647+
EXPECT_EQ(tcp_send_resources(send_resource_list), 1u);
648648

649649
// Release TCP client resources.
650650
server.reset();
@@ -665,7 +665,7 @@ TEST_P(TransportTCP, send_resource_cleanup_initial_peer)
665665
// Check that the send_resource_list has size 1. This means that the send resource
666666
// for the first client hasn't been removed because it was created from an initial_peer.
667667
send_resource_list = client_chaining_transport->get_send_resource_list();
668-
EXPECT_EQ(tcp_send_resources(send_resource_list), 1);
668+
EXPECT_EQ(tcp_send_resources(send_resource_list), 1u);
669669
send_resource_list.clear();
670670

671671
// If relaunching the server, the client should connect again.
@@ -1092,8 +1092,8 @@ TEST_P(TransportTCP, tcp_unique_network_flows_init)
10921092

10931093
EXPECT_TRUE(locators == locators2);
10941094
// LocatorList size depends on the number of interfaces. Different address but same port.
1095-
ASSERT_GT(locators.size(), 0);
1096-
ASSERT_GT(locators2.size(), 0);
1095+
ASSERT_GT(locators.size(), 0u);
1096+
ASSERT_GT(locators2.size(), 0u);
10971097
auto locator1 = locators.begin();
10981098
auto locator2 = locators2.begin();
10991099
EXPECT_EQ(IPLocator::getPhysicalPort(*locator1), IPLocator::getPhysicalPort(*locator2));
@@ -1122,8 +1122,8 @@ TEST_P(TransportTCP, tcp_unique_network_flows_init)
11221122

11231123
EXPECT_FALSE(locators == locators2);
11241124
// LocatorList size depends on the number of interfaces. Different address but same port.
1125-
ASSERT_GT(locators.size(), 0);
1126-
ASSERT_GT(locators2.size(), 0);
1125+
ASSERT_GT(locators.size(), 0u);
1126+
ASSERT_GT(locators2.size(), 0u);
11271127
auto locator1 = locators.begin();
11281128
auto locator2 = locators2.begin();
11291129
EXPECT_EQ(IPLocator::getPhysicalPort(*locator1), IPLocator::getPhysicalPort(*locator2));
@@ -1302,3 +1302,4 @@ GTEST_INSTANTIATE_TEST_MACRO(TransportTCP,
13021302
}
13031303

13041304
});
1305+

test/blackbox/common/DDSBlackboxTestsContentFilter.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ class DDSContentFilter : public testing::TestWithParam<communication_type>
339339
// Ensure writer is in clean state
340340
drop_data_on_all_readers();
341341
EXPECT_TRUE(writer.waitForAllAcked(std::chrono::seconds(5)));
342-
EXPECT_EQ(reader->get_unread_count(), 0);
342+
EXPECT_EQ(reader->get_unread_count(), 0ull);
343343

344344
// Send 10 samples with index 1 to 10
345345
auto data = default_helloworld_data_generator();
@@ -371,7 +371,7 @@ class DDSContentFilter : public testing::TestWithParam<communication_type>
371371
ReturnCode_t expected_ret;
372372
expected_ret = expected_samples == 0 ? RETCODE_NO_DATA : RETCODE_OK;
373373
EXPECT_EQ(expected_ret, reader->take(recv_data, recv_info));
374-
EXPECT_EQ(recv_data.length(), expected_samples);
374+
EXPECT_EQ(static_cast<uint64_t>(recv_data.length()), expected_samples);
375375
for (HelloWorldSeq::size_type i = 0;
376376
i < recv_data.length() && static_cast<uint32_t>(i) < expected_samples;
377377
++i)
@@ -1282,3 +1282,4 @@ GTEST_INSTANTIATE_TEST_MACRO(DDSContentFilter,
12821282
} // namespace dds
12831283
} // namespace fastdds
12841284
} // namespace eprosima
1285+

0 commit comments

Comments
 (0)