core, internet, sixlowpan: Declare unused variables as [[maybe_unused]]

This commit is contained in:
Eduardo Almeida
2022-10-11 11:21:54 +01:00
parent d03f12151e
commit 453dd70612
12 changed files with 25 additions and 90 deletions

View File

@@ -126,18 +126,16 @@ EmptyAttributeAccessor::~EmptyAttributeAccessor()
}
bool
EmptyAttributeAccessor::Set(ObjectBase* object, const AttributeValue& value) const
EmptyAttributeAccessor::Set(ObjectBase* object [[maybe_unused]],
const AttributeValue& value [[maybe_unused]]) const
{
(void)object;
(void)value;
return true;
}
bool
EmptyAttributeAccessor::Get(const ObjectBase* object, AttributeValue& attribute) const
EmptyAttributeAccessor::Get(const ObjectBase* object [[maybe_unused]],
AttributeValue& attribute [[maybe_unused]]) const
{
(void)object;
(void)attribute;
return true;
}
@@ -163,9 +161,8 @@ EmptyAttributeChecker::~EmptyAttributeChecker()
}
bool
EmptyAttributeChecker::Check(const AttributeValue& value) const
EmptyAttributeChecker::Check(const AttributeValue& value [[maybe_unused]]) const
{
(void)value;
return true;
}
@@ -195,10 +192,9 @@ EmptyAttributeChecker::Create() const
}
bool
EmptyAttributeChecker::Copy(const AttributeValue& source, AttributeValue& destination) const
EmptyAttributeChecker::Copy(const AttributeValue& source [[maybe_unused]],
AttributeValue& destination [[maybe_unused]]) const
{
(void)source;
(void)destination;
return true;
}

View File

@@ -398,7 +398,7 @@ LookupTimeTestCase::DoRun()
for (uint16_t i = 0; i < nids; ++i)
{
const TypeId tid = TypeId::GetRegistered(i);
const TypeId sid = TypeId::LookupByName(tid.GetName());
const TypeId sid [[maybe_unused]] = TypeId::LookupByName(tid.GetName());
}
}
int stop = clock();
@@ -410,7 +410,7 @@ LookupTimeTestCase::DoRun()
for (uint16_t i = 0; i < nids; ++i)
{
const TypeId tid = TypeId::GetRegistered(i);
const TypeId sid = TypeId::LookupByHash(tid.GetHash());
const TypeId sid [[maybe_unused]] = TypeId::LookupByHash(tid.GetHash());
}
}
stop = clock();

View File

@@ -1207,15 +1207,11 @@ Ipv4GlobalRoutingSlash32TestCase::~Ipv4GlobalRoutingSlash32TestCase()
void
Ipv4GlobalRoutingSlash32TestCase::ReceivePkt(Ptr<Socket> socket)
{
uint32_t availableData;
availableData = socket->GetRxAvailable();
uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
m_receivedPacket = socket->Recv(std::numeric_limits<uint32_t>::max(), 0);
NS_TEST_ASSERT_MSG_EQ(availableData,
m_receivedPacket->GetSize(),
"Received packet size is not equal to Rx buffer size");
// cast availableData to void, to suppress 'availableData' set but not used
// compiler warning
(void)availableData;
}
void

View File

@@ -87,15 +87,11 @@ Ipv4RipTest::Ipv4RipTest()
void
Ipv4RipTest::ReceivePkt(Ptr<Socket> socket)
{
uint32_t availableData;
availableData = socket->GetRxAvailable();
uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
m_receivedPacket = socket->Recv(std::numeric_limits<uint32_t>::max(), 0);
NS_TEST_ASSERT_MSG_EQ(availableData,
m_receivedPacket->GetSize(),
"Received Packet size is not equal to the Rx buffer size");
// cast availableData to void, to suppress 'availableData' set but not used
// compiler warning
(void)availableData;
}
void
@@ -321,15 +317,11 @@ Ipv4RipCountToInfinityTest::Ipv4RipCountToInfinityTest()
void
Ipv4RipCountToInfinityTest::ReceivePkt(Ptr<Socket> socket)
{
uint32_t availableData;
availableData = socket->GetRxAvailable();
uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
m_receivedPacket = socket->Recv(std::numeric_limits<uint32_t>::max(), 0);
NS_TEST_ASSERT_MSG_EQ(availableData,
m_receivedPacket->GetSize(),
"Received Packet size is not equal to the Rx buffer size");
// cast availableData to void, to suppress 'availableData' set but not used
// compiler warning
(void)availableData;
}
void
@@ -553,8 +545,7 @@ Ipv4RipSplitHorizonStrategyTest::Ipv4RipSplitHorizonStrategyTest(Rip::SplitHoriz
void
Ipv4RipSplitHorizonStrategyTest::ReceivePktProbe(Ptr<Socket> socket)
{
uint32_t availableData;
availableData = socket->GetRxAvailable();
uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
Address srcAddr;
Ptr<Packet> receivedPacketProbe =
socket->RecvFrom(std::numeric_limits<uint32_t>::max(), 0, srcAddr);
@@ -592,10 +583,6 @@ Ipv4RipSplitHorizonStrategyTest::ReceivePktProbe(Ptr<Socket> socket)
}
}
}
// cast availableData to void, to suppress 'availableData' set but not used
// compiler warning
(void)availableData;
}
void

View File

@@ -88,15 +88,11 @@ Ipv4StaticRoutingSlash32TestCase::~Ipv4StaticRoutingSlash32TestCase()
void
Ipv4StaticRoutingSlash32TestCase::ReceivePkt(Ptr<Socket> socket)
{
uint32_t availableData;
availableData = socket->GetRxAvailable();
uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
m_receivedPacket = socket->Recv(std::numeric_limits<uint32_t>::max(), 0);
NS_TEST_ASSERT_MSG_EQ(availableData,
m_receivedPacket->GetSize(),
"Received packet size is not equal to Rx buffer size");
// cast availableData to void, to suppress 'availableData' set but not used
// compiler warning
(void)availableData;
}
void

View File

@@ -85,15 +85,11 @@ Ipv6ForwardingTest::Ipv6ForwardingTest()
void
Ipv6ForwardingTest::ReceivePkt(Ptr<Socket> socket)
{
uint32_t availableData;
availableData = socket->GetRxAvailable();
uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
m_receivedPacket = socket->Recv(std::numeric_limits<uint32_t>::max(), 0);
NS_TEST_ASSERT_MSG_EQ(availableData,
m_receivedPacket->GetSize(),
"Received packet size is not equal to Rx buffer size");
// cast availableData to void, to suppress 'availableData' set but not used
// compiler warning
(void)availableData;
}
void

View File

@@ -86,15 +86,11 @@ Ipv6RipngTest::Ipv6RipngTest()
void
Ipv6RipngTest::ReceivePkt(Ptr<Socket> socket)
{
uint32_t availableData;
availableData = socket->GetRxAvailable();
uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
m_receivedPacket = socket->Recv(std::numeric_limits<uint32_t>::max(), 0);
NS_TEST_ASSERT_MSG_EQ(availableData,
m_receivedPacket->GetSize(),
"Received packet size is not equal to Rx buffer size");
// cast availableData to void, to suppress 'availableData' set but not used
// compiler warning
(void)availableData;
}
void
@@ -321,15 +317,11 @@ Ipv6RipngCountToInfinityTest::Ipv6RipngCountToInfinityTest()
void
Ipv6RipngCountToInfinityTest::ReceivePkt(Ptr<Socket> socket)
{
uint32_t availableData;
availableData = socket->GetRxAvailable();
uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
m_receivedPacket = socket->Recv(std::numeric_limits<uint32_t>::max(), 0);
NS_TEST_ASSERT_MSG_EQ(availableData,
m_receivedPacket->GetSize(),
"Received packet size is not equal to Rx buffer size");
// cast availableData to void, to suppress 'availableData' set but not used
// compiler warning
(void)availableData;
}
void
@@ -552,8 +544,7 @@ Ipv6RipngSplitHorizonStrategyTest::Ipv6RipngSplitHorizonStrategyTest(
void
Ipv6RipngSplitHorizonStrategyTest::ReceivePktProbe(Ptr<Socket> socket)
{
uint32_t availableData;
availableData = socket->GetRxAvailable();
uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
Address srcAddr;
Ptr<Packet> receivedPacketProbe =
socket->RecvFrom(std::numeric_limits<uint32_t>::max(), 0, srcAddr);
@@ -590,10 +581,6 @@ Ipv6RipngSplitHorizonStrategyTest::ReceivePktProbe(Ptr<Socket> socket)
}
}
}
// cast availableData to void, to suppress 'availableData' set but not used
// compiler warning
(void)availableData;
}
void

View File

@@ -132,12 +132,10 @@ TcpFlagErrorModel::TcpFlagErrorModel()
bool
TcpFlagErrorModel::ShouldDrop(const Ipv4Header& ipHeader,
const TcpHeader& tcpHeader,
uint32_t packetSize)
uint32_t packetSize [[maybe_unused]])
{
NS_LOG_FUNCTION(this << ipHeader << tcpHeader);
(void)packetSize;
bool toDrop = false;
if ((tcpHeader.GetFlags() & m_flagsToKill) == m_flagsToKill)

View File

@@ -271,9 +271,8 @@ TcpGeneralTest::DoConnect()
}
void
TcpGeneralTest::HandleAccept(Ptr<Socket> socket, const Address& from)
TcpGeneralTest::HandleAccept(Ptr<Socket> socket, const Address& from [[maybe_unused]])
{
(void)from;
socket->SetRecvCallback(MakeCallback(&TcpGeneralTest::ReceivePacket, this));
socket->SetCloseCallbacks(MakeCallback(&TcpGeneralTest::NormalCloseCb, this),
MakeCallback(&TcpGeneralTest::ErrorCloseCb, this));

View File

@@ -142,15 +142,11 @@ Udp6SocketLoopbackTest::Udp6SocketLoopbackTest()
void
Udp6SocketLoopbackTest::ReceivePkt(Ptr<Socket> socket)
{
uint32_t availableData;
availableData = socket->GetRxAvailable();
uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
m_receivedPacket = socket->Recv(std::numeric_limits<uint32_t>::max(), 0);
NS_TEST_ASSERT_MSG_EQ(availableData,
m_receivedPacket->GetSize(),
"ReceivedPacket size is not equal to the Rx buffer size");
// cast availableData to void, to suppress 'availableData' set but not used
// compiler warning
(void)availableData;
}
void
@@ -601,29 +597,21 @@ Udp6SocketImplTest::ReceivePacket2(Ptr<Socket> socket, Ptr<Packet> packet, const
void
Udp6SocketImplTest::ReceivePkt(Ptr<Socket> socket)
{
uint32_t availableData;
availableData = socket->GetRxAvailable();
uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
m_receivedPacket = socket->Recv(std::numeric_limits<uint32_t>::max(), 0);
NS_TEST_ASSERT_MSG_EQ(availableData,
m_receivedPacket->GetSize(),
"ReceivedPacket size is not equal to the Rx buffer size");
// cast availableData to void, to suppress 'availableData' set but not used
// compiler warning
(void)availableData;
}
void
Udp6SocketImplTest::ReceivePkt2(Ptr<Socket> socket)
{
uint32_t availableData;
availableData = socket->GetRxAvailable();
uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
m_receivedPacket2 = socket->Recv(std::numeric_limits<uint32_t>::max(), 0);
NS_TEST_ASSERT_MSG_EQ(availableData,
m_receivedPacket2->GetSize(),
"ReceivedPacket size is not equal to the Rx buffer size");
// cast availableData to void, to suppress 'availableData' set but not used
// compiler warning
(void)availableData;
}
void

View File

@@ -96,13 +96,9 @@ SixlowpanHc1ImplTest::ReceivePacket(Ptr<Socket> socket, Ptr<Packet> packet, cons
void
SixlowpanHc1ImplTest::ReceivePkt(Ptr<Socket> socket)
{
uint32_t availableData;
availableData = socket->GetRxAvailable();
uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
m_receivedPacket = socket->Recv(std::numeric_limits<uint32_t>::max(), 0);
NS_ASSERT(availableData == m_receivedPacket->GetSize());
// cast availableData to void, to suppress 'availableData' set but not used
// compiler warning
(void)availableData;
}
void

View File

@@ -96,13 +96,9 @@ SixlowpanIphcImplTest::ReceivePacket(Ptr<Socket> socket, Ptr<Packet> packet, con
void
SixlowpanIphcImplTest::ReceivePkt(Ptr<Socket> socket)
{
uint32_t availableData;
availableData = socket->GetRxAvailable();
uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
m_receivedPacket = socket->Recv(std::numeric_limits<uint32_t>::max(), 0);
NS_ASSERT(availableData == m_receivedPacket->GetSize());
// cast availableData to void, to suppress 'availableData' set but not used
// compiler warning
(void)availableData;
}
void