From f7a17e856bc04caba09afef0dd3e9e3b5dbebaa8 Mon Sep 17 00:00:00 2001 From: Eduardo Almeida Date: Fri, 9 Jun 2023 11:10:33 +0000 Subject: [PATCH] brite, click: Fix clang-tidy warnings --- src/brite/helper/brite-topology-helper.cc | 4 ++-- src/click/model/ipv4-click-routing.cc | 11 ++--------- src/click/model/ipv4-l3-click-protocol.cc | 20 +++++++++----------- 3 files changed, 13 insertions(+), 22 deletions(-) diff --git a/src/brite/helper/brite-topology-helper.cc b/src/brite/helper/brite-topology-helper.cc index 9392cbe00..f98728165 100644 --- a/src/brite/helper/brite-topology-helper.cc +++ b/src/brite/helper/brite-topology-helper.cc @@ -412,8 +412,8 @@ BriteTopologyHelper::BuildBriteTopology(InternetStackHelper& stack, const uint32 NS_LOG_LOGIC("Assigning << " << m_numAs << " AS to " << systemCount << " MPI instances"); for (uint32_t i = 0; i < m_numAs; ++i) { - int val = i % systemCount; - m_systemForAs.push_back(val); + uint32_t val = i % systemCount; + m_systemForAs.push_back(static_cast(val)); NS_LOG_INFO("AS: " << i << " System: " << val); } diff --git a/src/click/model/ipv4-click-routing.cc b/src/click/model/ipv4-click-routing.cc index 05e15dd9e..7c5d7507b 100644 --- a/src/click/model/ipv4-click-routing.cc +++ b/src/click/model/ipv4-click-routing.cc @@ -227,14 +227,7 @@ Ipv4ClickRouting::GetInterfaceId(const char* ifname) bool Ipv4ClickRouting::IsInterfaceReady(int ifid) { - if (ifid >= 0 && ifid < (int)m_ipv4->GetNInterfaces()) - { - return true; - } - else - { - return false; - } + return ifid >= 0 && ifid < static_cast(m_ipv4->GetNInterfaces()); } std::string @@ -288,7 +281,7 @@ Ipv4ClickRouting::GetTimevalFromNow() const curtime.tv_sec = Simulator::Now().GetSeconds(); curtime.tv_usec = Simulator::Now().GetMicroSeconds() % 1000000; - switch (Simulator::Now().GetResolution()) + switch (Simulator::Now()::GetResolution()) { case Time::NS: remainder = Simulator::Now().GetNanoSeconds() % 1000; diff --git a/src/click/model/ipv4-l3-click-protocol.cc b/src/click/model/ipv4-l3-click-protocol.cc index 417135759..337b5e47a 100644 --- a/src/click/model/ipv4-l3-click-protocol.cc +++ b/src/click/model/ipv4-l3-click-protocol.cc @@ -229,11 +229,10 @@ Ipv4L3ClickProtocol::IsDestinationAddress(Ipv4Address address, uint32_t iif) con #ifdef NOTYET if (MulticastCheckGroup(iif, address)) #endif - if (true) - { - NS_LOG_LOGIC("For me (Ipv4Addr multicast address"); - return true; - } + { + NS_LOG_LOGIC("For me (Ipv4Addr multicast address"); + return true; + } } if (address.IsBroadcast()) @@ -470,7 +469,7 @@ Ipv4L3ClickProtocol::SourceAddressSelection(uint32_t interfaceIdx, Ipv4Address d Ipv4InterfaceAddress test = GetAddress(interfaceIdx, i); if (test.GetLocal().CombineMask(test.GetMask()) == dest.CombineMask(test.GetMask())) { - if (test.IsSecondary() == false) + if (!test.IsSecondary()) { return test.GetLocal(); } @@ -677,7 +676,7 @@ Ipv4L3ClickProtocol::BuildHeader(Ipv4Address source, ipHeader.SetProtocol(protocol); ipHeader.SetPayloadSize(payloadSize); ipHeader.SetTtl(ttl); - if (mayFragment == true) + if (mayFragment) { ipHeader.SetMayFragment(); ipHeader.SetIdentification(m_identification); @@ -786,7 +785,7 @@ Ipv4L3ClickProtocol::Receive(Ptr device, NS_LOG_LOGIC("Packet from " << from << " received on node " << m_node->GetId()); // Forward packet to raw sockets, if any - if (protocol == Ipv4L3ClickProtocol::PROT_NUMBER && m_sockets.size() > 0) + if (protocol == Ipv4L3ClickProtocol::PROT_NUMBER && !m_sockets.empty()) { Ptr packetForRawSocket = p->Copy(); int32_t interface = GetInterfaceForDevice(device); @@ -854,8 +853,7 @@ Ipv4L3ClickProtocol::LocalDeliver(Ptr packet, const Ipv4Header& ip case IpL4Protocol::RX_CSUM_FAILED: break; case IpL4Protocol::RX_ENDPOINT_UNREACH: - if (ip.GetDestination().IsBroadcast() == true || - ip.GetDestination().IsMulticast() == true) + if (ip.GetDestination().IsBroadcast() || ip.GetDestination().IsMulticast()) { break; // Do not reply to broadcast or multicast } @@ -871,7 +869,7 @@ Ipv4L3ClickProtocol::LocalDeliver(Ptr packet, const Ipv4Header& ip subnetDirected = true; } } - if (subnetDirected == false) + if (!subnetDirected) { GetIcmp()->SendDestUnreachPort(ip, copy); }