Skip to content

Commit a4f2a2d

Browse files
richiwaremergify[bot]
authored andcommitted
Fix warning on ubuntu noble (#133)
Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev> (cherry picked from commit cb2addc)
1 parent 8cf52cd commit a4f2a2d

1 file changed

Lines changed: 68 additions & 84 deletions

File tree

src/DiscoveryServerManager.cpp

Lines changed: 68 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ DiscoveryServerManager::DiscoveryServerManager(
113113
tinyxml2::XMLPrinter printer;
114114
profiles->Accept(&printer);
115115
std::string xmlString = R"(")" + std::string(printer.CStr()) + R"(")";
116-
if (RETCODE_OK ==
117-
DomainParticipantFactory::get_instance()->load_XML_profiles_string(xmlString.c_str(),
116+
if (RETCODE_OK == DomainParticipantFactory::get_instance()->load_XML_profiles_string(xmlString.c_str(),
118117
std::string(printer.CStr()).length()))
119118
{
120119
LOG_INFO("Profiles parsed successfully.");
@@ -134,7 +133,7 @@ DiscoveryServerManager::DiscoveryServerManager(
134133
auto topic_desc_it = topic_description_profiles_map.find(topic_profile_name);
135134
if (topic_desc_it == topic_description_profiles_map.end())
136135
{
137-
auto &topic_desc = topic_description_profiles_map[topic_profile_name];
136+
auto& topic_desc = topic_description_profiles_map[topic_profile_name];
138137
if (!fill_topic_description_profile(topic_profile, topic_desc))
139138
{
140139
LOG_ERROR("Error parsing topic profiles");
@@ -704,8 +703,8 @@ Topic* DiscoveryServerManager::getParticipantTopicByName(
704703
}
705704

706705
bool DiscoveryServerManager::fill_topic_description_profile(
707-
tinyxml2::XMLElement* elem,
708-
TopicDescriptionItem& topic_description)
706+
tinyxml2::XMLElement* elem,
707+
TopicDescriptionItem& topic_description)
709708
{
710709
/*
711710
<xs:complexType name="topicDescriptionType">
@@ -714,50 +713,50 @@ bool DiscoveryServerManager::fill_topic_description_profile(
714713
<xs:element name="dataType" type="stringType" minOccurs="0"/>
715714
</xs:all>
716715
</xs:complexType>
717-
*/
716+
*/
718717

719718
bool ret = true;
720719
tinyxml2::XMLElement* p_aux0 = elem->FirstChildElement();
721720
const char* name = nullptr;
722721
for (; p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
723722
{
724-
name = p_aux0->Name();
723+
name = p_aux0->Name();
725724

726-
if (strcmp(name, DSxmlparser::NAME) == 0)
725+
if (strcmp(name, DSxmlparser::NAME) == 0)
726+
{
727+
// name - stringType
728+
const char* text = p_aux0->GetText();
729+
if (nullptr != text)
727730
{
728-
// name - stringType
729-
const char* text = p_aux0->GetText();
730-
if (nullptr != text)
731-
{
732-
topic_description.name = text;
733-
}
734-
else
735-
{
736-
LOG_ERROR("<" << p_aux0->Value() << "> GetText XML_ERROR");
737-
ret = false;
738-
break;
739-
}
731+
topic_description.name = text;
740732
}
741-
else if (strcmp(name, DSxmlparser::DATA_TYPE) == 0)
733+
else
742734
{
743-
// dataType - stringType
744-
const char* text = p_aux0->GetText();
745-
if (nullptr != text)
746-
{
747-
topic_description.type_name = text;
748-
}
749-
else
750-
{
751-
LOG_ERROR("<" << p_aux0->Value() << "> GetText XML_ERROR");
752-
ret = false;
753-
break;
754-
}
735+
LOG_ERROR("<" << p_aux0->Value() << "> GetText XML_ERROR");
736+
ret = false;
737+
break;
738+
}
739+
}
740+
else if (strcmp(name, DSxmlparser::DATA_TYPE) == 0)
741+
{
742+
// dataType - stringType
743+
const char* text = p_aux0->GetText();
744+
if (nullptr != text)
745+
{
746+
topic_description.type_name = text;
755747
}
756748
else
757749
{
758-
LOG_ERROR("Invalid element found into 'topicDescriptionType'. Name: " << name);
750+
LOG_ERROR("<" << p_aux0->Value() << "> GetText XML_ERROR");
759751
ret = false;
752+
break;
760753
}
754+
}
755+
else
756+
{
757+
LOG_ERROR("Invalid element found into 'topicDescriptionType'. Name: " << name);
758+
ret = false;
759+
}
761760
}
762761

763762
return ret;
@@ -925,9 +924,7 @@ void DiscoveryServerManager::loadServer(
925924
GuidPrefix_t& prefix = dpQOS.wire_protocol().prefix;
926925
const char* cprefix = server->Attribute(DSxmlparser::PREFIX);
927926

928-
if (cprefix != nullptr &&
929-
!(std::istringstream(cprefix) >> prefix) &&
930-
(prefix == c_GuidPrefix_Unknown))
927+
if (cprefix != nullptr && !(std::istringstream(cprefix) >> prefix) && (prefix == c_GuidPrefix_Unknown))
931928
{
932929
LOG_ERROR("Servers cannot have a framework provided prefix"); // at least for now
933930
return;
@@ -936,8 +933,7 @@ void DiscoveryServerManager::loadServer(
936933
GUID_t guid(prefix, c_EntityId_RTPSParticipant);
937934

938935
// Check if the guidPrefix is already in use (there is a mistake on config file)
939-
if (enable_prefix_validation &&
940-
servers.find(guid) != servers.end())
936+
if (enable_prefix_validation && servers.find(guid) != servers.end())
941937
{
942938
LOG_ERROR("DiscoveryServerManager detected two servers sharing the same prefix " << prefix);
943939
return;
@@ -946,8 +942,7 @@ void DiscoveryServerManager::loadServer(
946942
// replace the DomainParticipantQOS builtin lists with the ones from server_locators (if present)
947943
// note that a previous call to DiscoveryServerManager::MapServerInfo
948944
serverLocator_map::mapped_type& lists = server_locators[guid];
949-
if (!lists.first.empty() ||
950-
!lists.second.empty())
945+
if (!lists.first.empty() || !lists.second.empty())
951946
{
952947
// server elements take precedence over profile ones
953948
// I copy them because other servers may need this values
@@ -967,7 +962,8 @@ void DiscoveryServerManager::loadServer(
967962
// We define the PDP as external (when moved to fast library it would be SERVER)
968963
DiscoverySettings& b = dpQOS.wire_protocol().builtin.discovery_config;
969964
(void)b;
970-
assert(b.discoveryProtocol == eprosima::fastdds::rtps::DiscoveryProtocol::SERVER || b.discoveryProtocol == eprosima::fastdds::rtps::DiscoveryProtocol::BACKUP);
965+
assert(b.discoveryProtocol == eprosima::fastdds::rtps::DiscoveryProtocol::SERVER ||
966+
b.discoveryProtocol == eprosima::fastdds::rtps::DiscoveryProtocol::BACKUP);
971967

972968
// Create the participant or the associated events
973969
DelayedParticipantCreation event(creation_time, std::move(dpQOS), &DiscoveryServerManager::addServer);
@@ -1053,8 +1049,7 @@ void DiscoveryServerManager::loadClient(
10531049
if (dpQOS.wire_protocol().builtin.discovery_config.discoveryProtocol != DiscoveryProtocol::CLIENT &&
10541050
dpQOS.wire_protocol().builtin.discovery_config.discoveryProtocol != DiscoveryProtocol::SUPER_CLIENT)
10551051
{
1056-
LOG_ERROR(
1057-
"DiscoveryServerManager::loadClient try to create a client with an incompatible profile: " <<
1052+
LOG_ERROR("DiscoveryServerManager::loadClient try to create a client with an incompatible profile: " <<
10581053
profile_name);
10591054
return;
10601055
}
@@ -1103,7 +1098,7 @@ void DiscoveryServerManager::loadClient(
11031098
if (!p4)
11041099
{
11051100
// try to find a descriptor matching the listener port setup
1106-
if (p4 = std::dynamic_pointer_cast<TCPv4TransportDescriptor>(sp))
1101+
if ((p4 = std::dynamic_pointer_cast<TCPv4TransportDescriptor>(sp)))
11071102
{
11081103
continue;
11091104
}
@@ -1267,8 +1262,8 @@ void DiscoveryServerManager::loadSimple(
12671262
if (dpQOS.wire_protocol().builtin.discovery_config.discoveryProtocol != DiscoveryProtocol::SIMPLE)
12681263
{
12691264
LOG_ERROR(
1270-
"DiscoveryServerManager::loadSimple try to create a simple participant with an incompatible profile: " <<
1271-
profile_name);
1265+
"DiscoveryServerManager::loadSimple try to create a simple participant with an incompatible profile: "
1266+
<< profile_name);
12721267
return;
12731268
}
12741269

@@ -1419,9 +1414,8 @@ void DiscoveryServerManager::loadSubscriber(
14191414
endpoint_profile = std::string(profile_name);
14201415
}
14211416

1422-
DelayedEndpointCreation<DataReader> event(creation_time, topic_description.name,
1423-
topic_description.type_name, topic_name, endpoint_profile, part_guid, pDE,
1424-
participant_creation_event);
1417+
DelayedEndpointCreation<DataReader> event(creation_time, topic_description.name, topic_description.type_name,
1418+
topic_name, endpoint_profile, part_guid, pDE, participant_creation_event);
14251419

14261420
if (creation_time == getTime())
14271421
{
@@ -1525,9 +1519,8 @@ void DiscoveryServerManager::loadPublisher(
15251519
endpoint_profile = std::string(profile_name);
15261520
}
15271521

1528-
DelayedEndpointCreation<DataWriter> event(creation_time, topic_description.name,
1529-
topic_description.type_name, topic_name, endpoint_profile, part_guid, pDE,
1530-
participant_creation_event);
1522+
DelayedEndpointCreation<DataWriter> event(creation_time, topic_description.name, topic_description.type_name,
1523+
topic_name, endpoint_profile, part_guid, pDE, participant_creation_event);
15311524

15321525
if (creation_time == getTime())
15331526
{
@@ -1637,8 +1630,7 @@ void DiscoveryServerManager::MapServerInfo(
16371630
// I must load the prefix from the profile
16381631
// retrieve profile QOS
16391632
pqos = std::make_shared<DomainParticipantQos>();
1640-
if (RETCODE_OK !=
1641-
DomainParticipantFactory::get_instance()->get_participant_qos_from_profile(profile_name, *pqos))
1633+
if (RETCODE_OK != DomainParticipantFactory::get_instance()->get_participant_qos_from_profile(profile_name, *pqos))
16421634
{
16431635
LOG_ERROR("DiscoveryServerManager::loadServer couldn't load profile " << profile_name);
16441636
return;
@@ -1690,8 +1682,8 @@ void DiscoveryServerManager::on_participant_discovery(
16901682
return;
16911683
}
16921684

1693-
LOG_INFO("Participant " << participant->get_qos().name().to_string() << " reports a participant "
1694-
<< info.participant_name << " is " << status << ". Prefix " << partid);
1685+
LOG_INFO("Participant " << participant->get_qos().name().to_string() << " reports a participant " <<
1686+
info.participant_name << " is " << status << ". Prefix " << partid);
16951687

16961688
std::chrono::steady_clock::time_point callback_time = std::chrono::steady_clock::now();
16971689
{
@@ -1714,8 +1706,7 @@ void DiscoveryServerManager::on_participant_discovery(
17141706
{
17151707
case ParticipantDiscoveryStatus::DISCOVERED_PARTICIPANT:
17161708
{
1717-
state.AddParticipant(srcGuid, srcName, partid, info.participant_name.to_string(), callback_time,
1718-
server);
1709+
state.AddParticipant(srcGuid, srcName, partid, info.participant_name.to_string(), callback_time, server);
17191710
break;
17201711
}
17211712
case ParticipantDiscoveryStatus::REMOVED_PARTICIPANT:
@@ -1765,8 +1756,7 @@ void DiscoveryServerManager::on_data_reader_discovery(
17651756
if (!no_callbacks)
17661757
{
17671758
// is one of ours?
1768-
if ((it = servers.find(partid)) != servers.end() ||
1769-
(it = clients.find(partid)) != clients.end() ||
1759+
if ((it = servers.find(partid)) != servers.end() || (it = clients.find(partid)) != clients.end() ||
17701760
(it = simples.find(partid)) != simples.end())
17711761
{
17721762
part_name = it->second->get_qos().name().to_string();
@@ -1806,9 +1796,9 @@ void DiscoveryServerManager::on_data_reader_discovery(
18061796
break;
18071797
}
18081798

1809-
LOG_INFO("Participant " << participant->get_qos().name().to_string() << " reports a subscriber of participant "
1810-
<< part_name << " is " << reason << " with typename: " << info.type_name
1811-
<< " topic: " << info.topic_name << " GUID: " << subsid);
1799+
LOG_INFO("Participant " << participant->get_qos().name().to_string() << " reports a subscriber of participant " <<
1800+
part_name << " is " << reason << " with typename: " << info.type_name << " topic: " << info.topic_name <<
1801+
" GUID: " << subsid);
18121802
}
18131803

18141804
void DiscoveryServerManager::on_data_writer_discovery(
@@ -1847,8 +1837,7 @@ void DiscoveryServerManager::on_data_writer_discovery(
18471837
// is one of ours?
18481838
participant_map::iterator it;
18491839

1850-
if ((it = servers.find(partid)) != servers.end() ||
1851-
(it = clients.find(partid)) != clients.end() ||
1840+
if ((it = servers.find(partid)) != servers.end() || (it = clients.find(partid)) != clients.end() ||
18521841
(it = simples.find(partid)) != simples.end())
18531842
{
18541843
part_name = it->second->get_qos().name().to_string();
@@ -1879,13 +1868,8 @@ void DiscoveryServerManager::on_data_writer_discovery(
18791868
{
18801869
case DS::DISCOVERED_WRITER:
18811870

1882-
state.AddDataWriter(srcGuid,
1883-
srcName,
1884-
partid,
1885-
pubsid,
1886-
info.type_name.to_string(),
1887-
info.topic_name.to_string(),
1888-
callback_time);
1871+
state.AddDataWriter(srcGuid, srcName, partid, pubsid, info.type_name.to_string(),
1872+
info.topic_name.to_string(), callback_time);
18891873
break;
18901874
case DS::REMOVED_WRITER:
18911875

@@ -1895,9 +1879,9 @@ void DiscoveryServerManager::on_data_writer_discovery(
18951879
break;
18961880
}
18971881

1898-
LOG_INFO("Participant " << participant->get_qos().name().to_string() << " reports a publisher of participant "
1899-
<< part_name << " is " << reason << " with typename: " << info.type_name
1900-
<< " topic: " << info.topic_name << " GUID: " << pubsid);
1882+
LOG_INFO("Participant " << participant->get_qos().name().to_string() << " reports a publisher of participant " <<
1883+
part_name << " is " << reason << " with typename: " << info.type_name << " topic: " << info.topic_name <<
1884+
" GUID: " << pubsid);
19011885
}
19021886

19031887
void DiscoveryServerManager::on_liveliness_changed(
@@ -2002,15 +1986,15 @@ Snapshot& DiscoveryServerManager::takeSnapshot(
20021986
temp.insert(clients.begin(), clients.end());
20031987
temp.insert(simples.begin(), simples.end());
20041988

2005-
std::function<bool(const participant_map::value_type&, const Snapshot::value_type&)> pred(
2006-
[](const participant_map::value_type& p1, const Snapshot::value_type& p2)
2007-
{
2008-
return p1.first == p2.endpoint_guid;
2009-
}
2010-
);
1989+
std::function<bool(const participant_map::value_type&,
1990+
const Snapshot::value_type&)> pred([](const participant_map::value_type& p1, const Snapshot::value_type& p2)
1991+
{
1992+
return p1.first == p2.endpoint_guid;
1993+
}
1994+
);
20111995

2012-
std::pair<participant_map::const_iterator, Snapshot::const_iterator> res =
2013-
std::mismatch(temp.cbegin(), temp.cend(), shot.cbegin(), shot.cend(), pred);
1996+
std::pair<participant_map::const_iterator, Snapshot::const_iterator> res = std::mismatch(temp.cbegin(), temp.cend(),
1997+
shot.cbegin(), shot.cend(), pred);
20141998

20151999
while (res.first != temp.end())
20162000
{

0 commit comments

Comments
 (0)