Fix clang-tidy readability-string-compare warnings

This commit is contained in:
Eduardo Almeida
2022-10-06 22:14:30 +00:00
parent 1b78ecc117
commit f65238a0db
23 changed files with 61 additions and 61 deletions

View File

@@ -136,7 +136,7 @@ int main (int argc, char *argv[])
// Set recovery algorithm and TCP variant
Config::SetDefault ("ns3::TcpL4Protocol::RecoveryType", TypeIdValue (TypeId::LookupByName (recovery)));
if (tcpTypeId.compare ("ns3::TcpWestwoodPlus") == 0)
if (tcpTypeId == "ns3::TcpWestwoodPlus")
{
// TcpWestwoodPlus is not an actual TypeId name; we need TcpWestwood here
Config::SetDefault ("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpWestwood::GetTypeId ()));

View File

@@ -407,7 +407,7 @@ int main (int argc, char *argv[])
Config::SetDefault ("ns3::TcpL4Protocol::RecoveryType",
TypeIdValue (TypeId::LookupByName (recovery)));
// Select TCP variant
if (transport_prot.compare ("ns3::TcpWestwoodPlus") == 0)
if (transport_prot == "ns3::TcpWestwoodPlus")
{
// TcpWestwoodPlus is not an actual TypeId name; we need TcpWestwood here
Config::SetDefault ("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpWestwood::GetTypeId ()));
@@ -486,11 +486,11 @@ int main (int argc, char *argv[])
Ipv4InterfaceContainer interfaces = address.Assign (devices);
devices = UnReLink.Install (gateways.Get (0), sinks.Get (i));
if (queue_disc_type.compare ("ns3::PfifoFastQueueDisc") == 0)
if (queue_disc_type == "ns3::PfifoFastQueueDisc")
{
tchPfifo.Install (devices);
}
else if (queue_disc_type.compare ("ns3::CoDelQueueDisc") == 0)
else if (queue_disc_type == "ns3::CoDelQueueDisc")
{
tchCoDel.Install (devices);
}

View File

@@ -179,37 +179,37 @@ int main (int argc, char *argv[])
// Bottleneck link traffic control configuration
TrafficControlHelper tchBottleneck;
if (queueDiscType.compare ("PfifoFast") == 0)
if (queueDiscType == "PfifoFast")
{
tchBottleneck.SetRootQueueDisc ("ns3::PfifoFastQueueDisc", "MaxSize",
QueueSizeValue (QueueSize (QueueSizeUnit::PACKETS, queueDiscSize)));
}
else if (queueDiscType.compare ("ARED") == 0)
else if (queueDiscType == "ARED")
{
tchBottleneck.SetRootQueueDisc ("ns3::RedQueueDisc");
Config::SetDefault ("ns3::RedQueueDisc::ARED", BooleanValue (true));
Config::SetDefault ("ns3::RedQueueDisc::MaxSize",
QueueSizeValue (QueueSize (QueueSizeUnit::PACKETS, queueDiscSize)));
}
else if (queueDiscType.compare ("CoDel") == 0)
else if (queueDiscType == "CoDel")
{
tchBottleneck.SetRootQueueDisc ("ns3::CoDelQueueDisc");
Config::SetDefault ("ns3::CoDelQueueDisc::MaxSize",
QueueSizeValue (QueueSize (QueueSizeUnit::PACKETS, queueDiscSize)));
}
else if (queueDiscType.compare ("FqCoDel") == 0)
else if (queueDiscType == "FqCoDel")
{
tchBottleneck.SetRootQueueDisc ("ns3::FqCoDelQueueDisc");
Config::SetDefault ("ns3::FqCoDelQueueDisc::MaxSize",
QueueSizeValue (QueueSize (QueueSizeUnit::PACKETS, queueDiscSize)));
}
else if (queueDiscType.compare ("PIE") == 0)
else if (queueDiscType == "PIE")
{
tchBottleneck.SetRootQueueDisc ("ns3::PieQueueDisc");
Config::SetDefault ("ns3::PieQueueDisc::MaxSize",
QueueSizeValue (QueueSize (QueueSizeUnit::PACKETS, queueDiscSize)));
}
else if (queueDiscType.compare ("prio") == 0)
else if (queueDiscType == "prio")
{
uint16_t handle = tchBottleneck.SetRootQueueDisc ("ns3::PrioQueueDisc", "Priomap",
StringValue ("0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1"));

View File

@@ -112,7 +112,7 @@ main (int argc, char *argv[])
cmd.AddValue ("transportProt", "Transport protocol to use: Tcp, Udp", transportProt);
cmd.Parse (argc, argv);
if (transportProt.compare ("Tcp") == 0)
if (transportProt == "Tcp")
{
socketType = "ns3::TcpSocketFactory";
}

View File

@@ -538,9 +538,9 @@ int main (int argc, char *argv[])
gnuplot.AddDataset (statistics.GetDatafile ());
gnuplot.GenerateOutput (outfile);
if (manager.compare ("ns3::ParfWifiManager") == 0
|| manager.compare ("ns3::AparfWifiManager") == 0
|| manager.compare ("ns3::RrpaaWifiManager") == 0)
if (manager == "ns3::ParfWifiManager"
|| manager == "ns3::AparfWifiManager"
|| manager == "ns3::RrpaaWifiManager")
{
std::ofstream outfile2 (("power-" + outputFileName + ".plt").c_str ());
gnuplot = Gnuplot (("power-" + outputFileName + ".eps").c_str (), "Average Transmit Power");

View File

@@ -676,9 +676,9 @@ int main (int argc, char *argv[])
gnuplot.AddDataset (statisticsAp0.GetDatafile ());
gnuplot.GenerateOutput (outfileTh0);
if (manager.compare ("ns3::ParfWifiManager") == 0
|| manager.compare ("ns3::AparfWifiManager") == 0
|| manager.compare ("ns3::RrpaaWifiManager") == 0)
if (manager == "ns3::ParfWifiManager"
|| manager == "ns3::AparfWifiManager"
|| manager == "ns3::RrpaaWifiManager")
{
std::ofstream outfilePower0 (("power-" + outputFileName + "-0.plt").c_str ());
gnuplot = Gnuplot (("power-" + outputFileName + "-0.eps").c_str (), "Average Transmit Power");
@@ -730,9 +730,9 @@ int main (int argc, char *argv[])
gnuplot.AddDataset (statisticsAp1.GetDatafile ());
gnuplot.GenerateOutput (outfileTh1);
if (manager.compare ("ns3::ParfWifiManager") == 0
|| manager.compare ("ns3::AparfWifiManager") == 0
|| manager.compare ("ns3::RrpaaWifiManager") == 0)
if (manager == "ns3::ParfWifiManager"
|| manager == "ns3::AparfWifiManager"
|| manager == "ns3::RrpaaWifiManager")
{
std::ofstream outfilePower1 (("power-" + outputFileName + "-1.plt").c_str ());
gnuplot = Gnuplot (("power-" + outputFileName + "-1.eps").c_str (), "Average Transmit Power");

View File

@@ -93,7 +93,7 @@ main (int argc, char *argv[])
tcpVariant = std::string ("ns3::") + tcpVariant;
// Select TCP variant
if (tcpVariant.compare ("ns3::TcpWestwoodPlus") == 0)
if (tcpVariant == "ns3::TcpWestwoodPlus")
{
// TcpWestwoodPlus is not an actual TypeId name; we need TcpWestwood here
Config::SetDefault ("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpWestwood::GetTypeId ()));

View File

@@ -366,7 +366,7 @@ LogComponentEnable (char const *name, enum LogLevel level)
i != components->end ();
i++)
{
if (i->first.compare (name) == 0)
if (i->first == name)
{
i->second->Enable (level);
return;
@@ -401,7 +401,7 @@ LogComponentDisable (char const *name, enum LogLevel level)
i != components->end ();
i++)
{
if (i->first.compare (name) == 0)
if (i->first == name)
{
i->second->Disable (level);
break;
@@ -510,7 +510,7 @@ static bool ComponentExists (std::string componentName)
i != components->end ();
i++)
{
if (i->first.compare (name) == 0)
if (i->first == name)
{
return true;
}

View File

@@ -98,7 +98,7 @@ EnergySource::FindDeviceEnergyModels (std::string name)
DeviceEnergyModelContainer::Iterator i;
for (i = m_models.Begin (); i != m_models.End (); i++)
{
if ((*i)->GetInstanceTypeId ().GetName ().compare (name) == 0)
if ((*i)->GetInstanceTypeId ().GetName () == name)
{
container.Add (*i);
}

View File

@@ -156,7 +156,7 @@ main (int argc, char *argv[])
cmd.AddValue ("emuMode", "Emulation mode in {raw, netmap}", emuMode);
cmd.Parse (argc, argv);
if (transportProt.compare ("Tcp") == 0)
if (transportProt == "Tcp")
{
socketType = "ns3::TcpSocketFactory";
}

View File

@@ -238,11 +238,11 @@ main (int argc, char *argv[])
// Bottleneck link side
TrafficControlHelper tch1;
if (queueDiscType.compare ("PfifoFast") == 0)
if (queueDiscType == "PfifoFast")
{
tch1.SetRootQueueDisc ("ns3::PfifoFastQueueDisc", "MaxSize", StringValue ("1000p"));
}
else if (queueDiscType.compare ("ARED") == 0)
else if (queueDiscType == "ARED")
{
tch1.SetRootQueueDisc ("ns3::RedQueueDisc");
Config::SetDefault ("ns3::RedQueueDisc::ARED", BooleanValue (true));
@@ -253,15 +253,15 @@ main (int argc, char *argv[])
Config::SetDefault ("ns3::RedQueueDisc::MinTh", DoubleValue (83333));
Config::SetDefault ("ns3::RedQueueDisc::MinTh", DoubleValue (250000));
}
else if (queueDiscType.compare ("CoDel") == 0)
else if (queueDiscType == "CoDel")
{
tch1.SetRootQueueDisc ("ns3::CoDelQueueDisc");
}
else if (queueDiscType.compare ("FqCoDel") == 0)
else if (queueDiscType == "FqCoDel")
{
tch1.SetRootQueueDisc ("ns3::FqCoDelQueueDisc");
}
else if (queueDiscType.compare ("PIE") == 0)
else if (queueDiscType == "PIE")
{
tch1.SetRootQueueDisc ("ns3::PieQueueDisc");
Config::SetDefault ("ns3::PieQueueDisc::MaxSize",

View File

@@ -335,11 +335,11 @@ TcpGeneralTest::CreateReceiverSocket (Ptr<Node> node)
void
TcpGeneralTest::QueueDropCb ( std::string context, Ptr<const Packet> p)
{
if (context.compare ("SENDER") == 0)
if (context == "SENDER")
{
QueueDrop (SENDER);
}
else if (context.compare ("RECEIVER") == 0)
else if (context == "RECEIVER")
{
QueueDrop (RECEIVER);
}
@@ -352,11 +352,11 @@ TcpGeneralTest::QueueDropCb ( std::string context, Ptr<const Packet> p)
void
TcpGeneralTest::PhyDropCb (std::string context, [[maybe_unused]] Ptr<const Packet> p)
{
if (context.compare ("SENDER") == 0)
if (context == "SENDER")
{
PhyDrop (SENDER);
}
else if (context.compare ("RECEIVER") == 0)
else if (context == "RECEIVER")
{
PhyDrop (RECEIVER);
}

View File

@@ -1439,11 +1439,11 @@ CqaFfMacScheduler::DoSchedDlTriggerReq (const struct FfMacSchedSapProvider::Sche
hol = 1;
}
if ( m_CqaMetric.compare ("CqaFf") == 0)
if ( m_CqaMetric == "CqaFf")
{
metric = coita_metric*tbr_weight*hol;
}
else if (m_CqaMetric.compare ("CqaPf") == 0)
else if (m_CqaMetric == "CqaPf")
{
metric = tbr_weight*pf_weight*hol;
}

View File

@@ -1105,7 +1105,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq (const struct FfMacSchedSapProvider::Sche
} // end of m_flowStatsDl
if ( m_fdSchedulerType.compare("CoItA") == 0)
if ( m_fdSchedulerType == "CoItA")
{
// FD scheduler: Carrier over Interference to Average (CoItA)
std::map < uint16_t, uint8_t > sbCqiSum;
@@ -1270,7 +1270,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq (const struct FfMacSchedSapProvider::Sche
}// end of CoIta
if ( m_fdSchedulerType.compare("PFsch") == 0)
if ( m_fdSchedulerType == "PFsch")
{
// FD scheduler: Proportional Fair scheduled (PFsch)
for (int i = 0; i < rbgNum; i++)

View File

@@ -202,7 +202,7 @@ LenaMimoTestCase::DoRun ()
enbNetDev->GetCcMap()[0]->GetAttribute ("FfMacScheduler", ptrval);
Ptr<PfFfMacScheduler> pfsched;
Ptr<RrFfMacScheduler> rrsched;
if (m_schedulerType.compare ("ns3::RrFfMacScheduler") == 0)
if (m_schedulerType == "ns3::RrFfMacScheduler")
{
rrsched = ptrval.Get<RrFfMacScheduler> ();
if (!rrsched)
@@ -212,7 +212,7 @@ LenaMimoTestCase::DoRun ()
Simulator::Schedule (Seconds (0.2), &RrFfMacScheduler::TransmissionModeConfigurationUpdate, rrsched, rnti, 1);
Simulator::Schedule (Seconds (0.4), &RrFfMacScheduler::TransmissionModeConfigurationUpdate, rrsched, rnti, 2);
}
else if (m_schedulerType.compare ("ns3::PfFfMacScheduler") == 0)
else if (m_schedulerType == "ns3::PfFfMacScheduler")
{
pfsched = ptrval.Get<PfFfMacScheduler> ();
if (!pfsched)

View File

@@ -347,7 +347,7 @@ Ns3TcpLossTestCase::DoRun ()
std::ostringstream tcpModel;
tcpModel << "ns3::Tcp" << m_tcpModel;
if (m_tcpModel.compare ("WestwoodPlus") == 0)
if (m_tcpModel == "WestwoodPlus")
{
Config::SetDefault ("ns3::TcpL4Protocol::SocketType",
TypeIdValue (TcpWestwood::GetTypeId ()));

View File

@@ -91,7 +91,7 @@ static void
TraceCwnd (std::string cwndTrFileName)
{
AsciiTraceHelper ascii;
if (cwndTrFileName.compare ("") == 0)
if (cwndTrFileName == "")
{
NS_LOG_DEBUG ("No trace file for cwnd provided");
return;
@@ -124,7 +124,7 @@ static void
TraceSojourn (std::string sojournTrFileName)
{
AsciiTraceHelper ascii;
if (sojournTrFileName.compare ("") == 0)
if (sojournTrFileName == "")
{
NS_LOG_DEBUG ("No trace file for sojourn provided");
return;
@@ -158,7 +158,7 @@ static void
TraceQueueLength (std::string queueLengthTrFileName)
{
AsciiTraceHelper ascii;
if (queueLengthTrFileName.compare ("") == 0)
if (queueLengthTrFileName == "")
{
NS_LOG_DEBUG ("No trace file for queue length provided");
return;
@@ -191,7 +191,7 @@ static void
TraceEveryDrop (std::string everyDropTrFileName)
{
AsciiTraceHelper ascii;
if (everyDropTrFileName.compare ("") == 0)
if (everyDropTrFileName == "")
{
NS_LOG_DEBUG ("No trace file for every drop event provided");
return;
@@ -234,7 +234,7 @@ static void
TraceDroppingState (std::string dropStateTrFileName)
{
AsciiTraceHelper ascii;
if (dropStateTrFileName.compare ("") == 0)
if (dropStateTrFileName == "")
{
NS_LOG_DEBUG ("No trace file for dropping state provided");
return;
@@ -424,11 +424,11 @@ int main (int argc, char *argv[])
tchPfifo.Install (serverCmtsDev);
tchPfifo.Install (cmtsWanDev);
if (routerWanQueueDiscType.compare ("PfifoFast") == 0)
if (routerWanQueueDiscType == "PfifoFast")
{
tchPfifo.Install (routerWanDev);
}
else if (routerWanQueueDiscType.compare ("CoDel") == 0)
else if (routerWanQueueDiscType == "CoDel")
{
tchCoDel.Install (routerWanDev);
}
@@ -493,7 +493,7 @@ int main (int argc, char *argv[])
Simulator::Schedule (Seconds (0.00001), &TraceCwnd, cwndTrFileName);
TraceEveryDrop (everyDropTrFileName);
if (routerWanQueueDiscType.compare ("CoDel") == 0)
if (routerWanQueueDiscType == "CoDel")
{
TraceSojourn (sojournTrFileName);
TraceQueueLength (queueLengthTrFileName);

View File

@@ -78,7 +78,7 @@ static void
TraceCwnd (std::string cwndTrFileName)
{
AsciiTraceHelper ascii;
if (cwndTrFileName.compare ("") == 0)
if (cwndTrFileName == "")
{
NS_LOG_DEBUG ("No trace file for cwnd provided");
return;
@@ -196,11 +196,11 @@ int main (int argc, char *argv[])
devicesBottleneckLink = bottleneckLink.Install (gateway.Get (0), sink.Get (0));
address.NewNetwork ();
if (queueDiscType.compare ("PfifoFast") == 0)
if (queueDiscType == "PfifoFast")
{
tchPfifo.Install (devicesBottleneckLink);
}
else if (queueDiscType.compare ("CoDel") == 0)
else if (queueDiscType == "CoDel")
{
tchCoDel.Install (devicesBottleneckLink);
}

View File

@@ -204,7 +204,7 @@ QueueDisc::Stats::Print (std::ostream &os) const
while (itp != nDroppedPacketsBeforeEnqueue.end () &&
itb != nDroppedBytesBeforeEnqueue.end ())
{
NS_ASSERT (itp->first.compare (itb->first) == 0);
NS_ASSERT (itp->first == itb->first);
os << std::endl << " " << itp->first << ": "
<< itp->second << " / " << itb->second;
itp++;
@@ -221,7 +221,7 @@ QueueDisc::Stats::Print (std::ostream &os) const
while (itp != nDroppedPacketsAfterDequeue.end () &&
itb != nDroppedBytesAfterDequeue.end ())
{
NS_ASSERT (itp->first.compare (itb->first) == 0);
NS_ASSERT (itp->first == itb->first);
os << std::endl << " " << itp->first << ": "
<< itp->second << " / " << itb->second;
itp++;
@@ -241,7 +241,7 @@ QueueDisc::Stats::Print (std::ostream &os) const
while (itp != nMarkedPackets.end () &&
itb != nMarkedBytes.end ())
{
NS_ASSERT (itp->first.compare (itb->first) == 0);
NS_ASSERT (itp->first == itb->first);
os << std::endl << " " << itp->first << ": "
<< itp->second << " / " << itb->second;
itp++;

View File

@@ -62,7 +62,7 @@ AcousticModemEnergyModelHelper::DoInstall (Ptr<NetDevice> device,
NS_ASSERT (source);
// check if device is UanNetDevice
std::string deviceName = device->GetInstanceTypeId ().GetName ();
if (deviceName.compare ("ns3::UanNetDevice") != 0)
if (deviceName != "ns3::UanNetDevice")
{
NS_FATAL_ERROR ("NetDevice type is not UanNetDevice!");
}

View File

@@ -1028,7 +1028,7 @@ void
ConfigStoreHelper::SaveConfig (std::string configFilename)
{
// only save if a non-empty filename has been specified
if (configFilename.compare ("") != 0)
if (configFilename != "")
{
// Output config store to txt format
Config::SetDefault ("ns3::ConfigStore::Filename", StringValue (configFilename));

View File

@@ -113,7 +113,7 @@ public:
template <typename... Ts>
void NqosWaveMacHelper::SetType (std::string type, Ts&&... args)
{
if (type.compare ("ns3::OcbWifiMac") != 0)
if (type != "ns3::OcbWifiMac")
{
NS_FATAL_ERROR ("QosWaveMacHelper shall set OcbWifiMac");
}
@@ -123,7 +123,7 @@ template <typename... Ts>
template <typename... Ts>
void QosWaveMacHelper::SetType (std::string type, Ts&&... args)
{
if (type.compare ("ns3::OcbWifiMac") != 0)
if (type != "ns3::OcbWifiMac")
{
NS_FATAL_ERROR ("QosWaveMacHelper shall set OcbWifiMac");
}

View File

@@ -69,7 +69,7 @@ WifiRadioEnergyModelHelper::DoInstall (Ptr<NetDevice> device,
NS_ASSERT (source);
// check if device is WifiNetDevice
std::string deviceName = device->GetInstanceTypeId ().GetName ();
if (deviceName.compare ("ns3::WifiNetDevice") != 0)
if (deviceName != "ns3::WifiNetDevice")
{
NS_FATAL_ERROR ("NetDevice type is not WifiNetDevice!");
}