From 0e685cbdbbd955ff52f3aab78b855cb8153dbb82 Mon Sep 17 00:00:00 2001 From: Peter Barnes Date: Tue, 21 Dec 2021 10:32:43 +0000 Subject: [PATCH] Use [[maybe_unused]] attribute directly, instead of NS_UNUSED --- examples/routing/manet-routing-compare.cc | 3 +- examples/tcp/tcp-linux-reno.cc | 3 +- examples/tcp/tcp-variants-comparison.cc | 9 +- .../model/three-gpp-http-client.cc | 4 +- .../model/three-gpp-http-server.cc | 12 +- .../buildings-channel-condition-model.cc | 3 +- src/core/model/attribute-accessor-helper.h | 9 +- src/core/model/example-as-test.cc | 1 - src/core/model/log.h | 2 +- src/core/model/nstime.h | 3 +- src/core/model/random-variable-stream.cc | 1 - src/core/model/simple-ref-count.h | 7 +- src/core/model/unused.h | 34 +++++- src/core/test/attribute-test-suite.cc | 28 +---- src/core/test/callback-test-suite.cc | 15 +-- src/core/test/config-test-suite.cc | 12 +- src/core/test/simulator-test-suite.cc | 6 +- src/core/test/traced-callback-test-suite.cc | 9 +- src/core/test/type-id-test-suite.cc | 2 - src/dsr/model/dsr-options.cc | 3 +- src/internet/model/rip.cc | 1 - src/internet/model/ripng.cc | 1 - src/internet/model/tcp-congestion-ops.cc | 6 +- src/internet/model/tcp-congestion-ops.h | 3 +- src/internet/model/tcp-prr-recovery.cc | 4 +- src/internet/model/tcp-recovery-ops.cc | 8 +- src/internet/model/tcp-socket-base.cc | 10 +- src/internet/model/tcp-tx-buffer.cc | 3 +- src/internet/model/tcp-westwood.cc | 3 +- src/internet/test/tcp-general-test.cc | 3 +- src/internet/test/tcp-general-test.h | 105 +++++++----------- src/internet/test/tcp-hybla-test.cc | 3 +- src/internet/test/tcp-rate-ops-test.cc | 3 +- src/lr-wpan/model/lr-wpan-csmaca.cc | 6 +- src/lte/model/lte-enb-mac.h | 3 +- .../model/no-op-component-carrier-manager.cc | 3 +- src/lte/test/lte-test-harq.cc | 1 - src/lte/test/lte-test-phy-error-model.cc | 7 +- src/mobility/helper/ns2-mobility-helper.cc | 4 +- src/netanim/model/animation-interface.cc | 3 +- src/network/test/packet-test-suite.cc | 6 +- src/network/utils/queue-size.cc | 4 +- src/network/utils/queue.h | 1 - src/nix-vector-routing/test/nix-test.cc | 6 +- .../model/channel-condition-model.cc | 14 +-- .../model/three-gpp-propagation-loss-model.cc | 34 +++--- src/sixlowpan/model/sixlowpan-net-device.cc | 12 +- src/stats/model/sqlite-output.cc | 10 +- .../ns3tc/fq-cobalt-queue-disc-test-suite.cc | 4 +- .../model/rocketfuel-topology-reader.cc | 5 +- src/traffic-control/model/queue-disc.cc | 4 +- .../test/cobalt-queue-disc-test-suite.cc | 4 +- .../test/codel-queue-disc-test-suite.cc | 8 +- src/uan/helper/uan-helper.cc | 8 +- src/uan/model/uan-mac-aloha.cc | 3 +- src/uan/model/uan-mac-cw.cc | 6 +- src/uan/model/uan-mac-rc-gw.cc | 16 ++- src/uan/model/uan-mac-rc.cc | 6 +- src/uan/model/uan-net-device.cc | 11 +- src/uan/model/uan-phy-dual.cc | 6 +- src/uan/model/uan-phy-dual.h | 3 +- src/uan/model/uan-phy-gen.cc | 6 +- src/uan/test/uan-energy-model-test.cc | 6 +- src/uan/test/uan-test.cc | 6 +- src/wave/helper/wave-helper.cc | 4 +- src/wave/helper/wifi-80211p-helper.cc | 7 +- src/wifi/model/he/rr-multi-user-scheduler.cc | 3 +- 67 files changed, 201 insertions(+), 348 deletions(-) diff --git a/examples/routing/manet-routing-compare.cc b/examples/routing/manet-routing-compare.cc index 309c99058..23fc7d4a1 100644 --- a/examples/routing/manet-routing-compare.cc +++ b/examples/routing/manet-routing-compare.cc @@ -268,7 +268,7 @@ RoutingExperiment::Run (int nSinks, double txp, std::string CSVfileName) NetDeviceContainer adhocDevices = wifi.Install (wifiPhy, wifiMac, adhocNodes); MobilityHelper mobilityAdhoc; - int64_t streamIndex = 0; // used to get consistent mobility across scenarios + [[maybe_unused]] int64_t streamIndex = 0; // used to get consistent mobility across scenarios ObjectFactory pos; pos.SetTypeId ("ns3::RandomRectanglePositionAllocator"); @@ -289,7 +289,6 @@ RoutingExperiment::Run (int nSinks, double txp, std::string CSVfileName) mobilityAdhoc.SetPositionAllocator (taPositionAlloc); mobilityAdhoc.Install (adhocNodes); streamIndex += mobilityAdhoc.AssignStreams (adhocNodes, streamIndex); - NS_UNUSED (streamIndex); // From this point, streamIndex is unused AodvHelper aodv; OlsrHelper olsr; diff --git a/examples/tcp/tcp-linux-reno.cc b/examples/tcp/tcp-linux-reno.cc index 0d2ba161d..2a0dca74c 100644 --- a/examples/tcp/tcp-linux-reno.cc +++ b/examples/tcp/tcp-linux-reno.cc @@ -211,7 +211,7 @@ int main (int argc, char *argv[]) // Create directories to store dat files struct stat buffer; - int retVal; + [[maybe_unused]] int retVal; if ((stat (dir.c_str (), &buffer)) == 0) { std::string dirToRemove = "rm -rf " + dir; @@ -227,7 +227,6 @@ int main (int argc, char *argv[]) NS_ASSERT_MSG (retVal == 0, "Error in return value"); retVal = system ((dirToSave + "/cwndTraces/").c_str ()); NS_ASSERT_MSG (retVal == 0, "Error in return value"); - NS_UNUSED (retVal); // Set default parameters for queue discipline Config::SetDefault (qdiscTypeId + "::MaxSize", QueueSizeValue (QueueSize ("100p"))); diff --git a/examples/tcp/tcp-variants-comparison.cc b/examples/tcp/tcp-variants-comparison.cc index 28311b9f0..cd3acd843 100644 --- a/examples/tcp/tcp-variants-comparison.cc +++ b/examples/tcp/tcp-variants-comparison.cc @@ -127,23 +127,20 @@ RtoTracer (Time oldval, Time newval) } static void -NextTxTracer (SequenceNumber32 old, SequenceNumber32 nextTx) +NextTxTracer ([[maybe_unused]] SequenceNumber32 old, SequenceNumber32 nextTx) { - NS_UNUSED (old); *nextTxStream->GetStream () << Simulator::Now ().GetSeconds () << " " << nextTx << std::endl; } static void -InFlightTracer (uint32_t old, uint32_t inFlight) +InFlightTracer ([[maybe_unused]] uint32_t old, uint32_t inFlight) { - NS_UNUSED (old); *inFlightStream->GetStream () << Simulator::Now ().GetSeconds () << " " << inFlight << std::endl; } static void -NextRxTracer (SequenceNumber32 old, SequenceNumber32 nextRx) +NextRxTracer ([[maybe_unused]] SequenceNumber32 old, SequenceNumber32 nextRx) { - NS_UNUSED (old); *nextRxStream->GetStream () << Simulator::Now ().GetSeconds () << " " << nextRx << std::endl; } diff --git a/src/applications/model/three-gpp-http-client.cc b/src/applications/model/three-gpp-http-client.cc index ab626d4f3..99303b956 100644 --- a/src/applications/model/three-gpp-http-client.cc +++ b/src/applications/model/three-gpp-http-client.cc @@ -33,7 +33,6 @@ #include #include #include -#include NS_LOG_COMPONENT_DEFINE ("ThreeGppHttpClient"); @@ -380,7 +379,7 @@ ThreeGppHttpClient::OpenConnection () m_socket = Socket::CreateSocket (GetNode (), TcpSocketFactory::GetTypeId ()); - int ret; + [[maybe_unused]] int ret; if (Ipv4Address::IsMatchingType (m_remoteServerAddress)) { @@ -415,7 +414,6 @@ ThreeGppHttpClient::OpenConnection () << " GetErrNo= " << m_socket->GetErrno () << "."); } - NS_UNUSED (ret); // Mute compiler warning. NS_ASSERT_MSG (m_socket != 0, "Failed creating socket."); SwitchToState (CONNECTING); diff --git a/src/applications/model/three-gpp-http-server.cc b/src/applications/model/three-gpp-http-server.cc index 2a99207ad..fa736fe4e 100644 --- a/src/applications/model/three-gpp-http-server.cc +++ b/src/applications/model/three-gpp-http-server.cc @@ -34,7 +34,6 @@ #include #include #include -#include NS_LOG_COMPONENT_DEFINE ("ThreeGppHttpServer"); @@ -223,7 +222,7 @@ ThreeGppHttpServer::StartApplication () TcpSocketFactory::GetTypeId ()); m_initialSocket->SetAttribute ("SegmentSize", UintegerValue (m_mtuSize)); - int ret; + [[maybe_unused]] int ret; if (Ipv4Address::IsMatchingType (m_localAddress)) { @@ -257,7 +256,6 @@ ThreeGppHttpServer::StartApplication () << " GetErrNo= " << m_initialSocket->GetErrno () << "."); - NS_UNUSED (ret); } // end of `if (m_initialSocket == 0)` @@ -491,8 +489,8 @@ ThreeGppHttpServer::SendCallback (Ptr socket, uint32_t availableBufferSi if (!m_txBuffer->IsBufferEmpty (socket)) { - const uint32_t txBufferSize = m_txBuffer->GetBufferSize (socket); - const uint32_t actualSent = ServeFromTxBuffer (socket); + [[maybe_unused]] const uint32_t txBufferSize = m_txBuffer->GetBufferSize (socket); + [[maybe_unused]] const uint32_t actualSent = ServeFromTxBuffer (socket); #ifdef NS3_LOG_ENABLE // Some log messages. @@ -530,10 +528,6 @@ ThreeGppHttpServer::SendCallback (Ptr socket, uint32_t availableBufferSi } #endif /* NS3_LOG_ENABLE */ - // Mute compiler warnings. - NS_UNUSED (txBufferSize); - NS_UNUSED (actualSent); - } // end of `if (m_txBuffer->IsBufferEmpty (socket))` } // end of `void SendCallback (Ptr socket, uint32_t availableBufferSize)` diff --git a/src/buildings/model/buildings-channel-condition-model.cc b/src/buildings/model/buildings-channel-condition-model.cc index a4d90fb02..434554562 100644 --- a/src/buildings/model/buildings-channel-condition-model.cc +++ b/src/buildings/model/buildings-channel-condition-model.cc @@ -133,9 +133,8 @@ BuildingsChannelConditionModel::IsLineOfSightBlocked (const ns3::Vector &l1, con } int64_t -BuildingsChannelConditionModel::AssignStreams (int64_t stream) +BuildingsChannelConditionModel::AssignStreams ([[maybe_unused]] int64_t stream) { - NS_UNUSED (stream); return 0; } diff --git a/src/core/model/attribute-accessor-helper.h b/src/core/model/attribute-accessor-helper.h index a1ecae7d3..c555737d6 100644 --- a/src/core/model/attribute-accessor-helper.h +++ b/src/core/model/attribute-accessor-helper.h @@ -21,7 +21,6 @@ #define ATTRIBUTE_ACCESSOR_HELPER_H #include "attribute.h" -#include "unused.h" /** * \file @@ -334,10 +333,8 @@ DoMakeAccessorHelperOne (U (T::*getter)(void) const) {} private: - virtual bool DoSet (T *object, const V *v) const + virtual bool DoSet ([[maybe_unused]] T *object, [[maybe_unused]] const V *v) const { - NS_UNUSED (object); - NS_UNUSED (v); return false; } virtual bool DoGet (const T *object, V *v) const @@ -402,10 +399,8 @@ DoMakeAccessorHelperOne (void (T::*setter)(U)) (object->*m_setter)(tmp); return true; } - virtual bool DoGet (const T *object, V *v) const + virtual bool DoGet ([[maybe_unused]] const T *object, [[maybe_unused]] V *v) const { - NS_UNUSED (object); - NS_UNUSED (v); return false; } virtual bool HasGetter (void) const diff --git a/src/core/model/example-as-test.cc b/src/core/model/example-as-test.cc index 8c32624c0..f3a2a91fd 100644 --- a/src/core/model/example-as-test.cc +++ b/src/core/model/example-as-test.cc @@ -21,7 +21,6 @@ #include "example-as-test.h" #include "ascii-test.h" #include "log.h" -#include "unused.h" #include "assert.h" #include diff --git a/src/core/model/log.h b/src/core/model/log.h index daf09ed1d..9e558db33 100644 --- a/src/core/model/log.h +++ b/src/core/model/log.h @@ -247,7 +247,7 @@ void LogComponentDisableAll (enum LogLevel level); * \param [in] name The log component name. */ #define NS_LOG_STATIC_TEMPLATE_DEFINE(name) \ - static LogComponent & NS_UNUSED_GLOBAL (g_log) = GetLogComponent (name) + [[maybe_unused]] static LogComponent & g_log = GetLogComponent (name) /** * Use \ref NS_LOG to output a message of level LOG_ERROR. diff --git a/src/core/model/nstime.h b/src/core/model/nstime.h index 68060b7ad..1a9f18dea 100644 --- a/src/core/model/nstime.h +++ b/src/core/model/nstime.h @@ -25,7 +25,6 @@ #include "attribute-helper.h" #include "event-id.h" #include "int64x64.h" -#include "unused.h" #include #include #include @@ -819,7 +818,7 @@ typedef void (* Time)(Time oldValue, Time newValue); * This is internal to the Time implementation. * \relates Time */ -static bool NS_UNUSED_GLOBAL (g_TimeStaticInit) = Time::StaticInit (); +[[maybe_unused]] static bool g_TimeStaticInit = Time::StaticInit (); /** * Equality operator for Time. diff --git a/src/core/model/random-variable-stream.cc b/src/core/model/random-variable-stream.cc index 252733510..69a02024d 100644 --- a/src/core/model/random-variable-stream.cc +++ b/src/core/model/random-variable-stream.cc @@ -33,7 +33,6 @@ #include "log.h" #include "rng-stream.h" #include "rng-seed-manager.h" -#include "unused.h" #include #include #include // upper_bound diff --git a/src/core/model/simple-ref-count.h b/src/core/model/simple-ref-count.h index 5744e3f7f..a9d15fb98 100644 --- a/src/core/model/simple-ref-count.h +++ b/src/core/model/simple-ref-count.h @@ -25,7 +25,6 @@ #include "empty.h" #include "default-deleter.h" #include "assert.h" -#include "unused.h" #include #include @@ -81,19 +80,17 @@ public: * Copy constructor * \param [in] o The object to copy into this one. */ - SimpleRefCount (const SimpleRefCount &o) + SimpleRefCount ([[maybe_unused]] const SimpleRefCount & o) : m_count (1) { - NS_UNUSED (o); } /** * Assignment operator * \param [in] o The object to copy * \returns The copy of \pname{o} */ - SimpleRefCount &operator = (const SimpleRefCount &o) + SimpleRefCount &operator = ([[maybe_unused]] const SimpleRefCount &o) { - NS_UNUSED (o); return *this; } /** diff --git a/src/core/model/unused.h b/src/core/model/unused.h index 3da7e9dc9..9c15ca177 100644 --- a/src/core/model/unused.h +++ b/src/core/model/unused.h @@ -21,33 +21,59 @@ #ifndef UNUSED_H #define UNUSED_H +#include "ns3/deprecated.h" + /** * \file * \ingroup core * NS_UNUSED and NS_UNUSED_GLOBAL macro definitions. */ + /** * \ingroup core * \def NS_UNUSED() * Mark a local variable as unused. + * + * \deprecated Please use `[[maybe_unused]]` directly. This macro is being + * kept temporarily to support older code. */ + +// We can't use NS_DEPRECATED_3_36 here because NS_UNUSED +// is used as a statement following a declaration: +// int x; +// NS_UNUSED (x); +// NS_DEPRECATED needs to be applied to the declaration +// NS_DEPRECATED_3_36 ("use double instead") int x; +// Instead we resort to a pragma + #ifndef NS_UNUSED -# define NS_UNUSED(x) ((void)(x)) +# define NS_UNUSED(x) \ + _Pragma ("GCC warning \"NS_UNUSED is deprecated, use [[maybe_unused]] directly\"") \ + ((void)(x)) #endif /** * \ingroup core * \def NS_UNUSED_GLOBAL() * Mark a variable at file scope as unused. + * + * \deprecated Please use `[[maybe_unused]]` directly. This macro is being + * kept temporarily to support older code. */ #ifndef NS_UNUSED_GLOBAL #if defined(__GNUC__) -# define NS_UNUSED_GLOBAL(x) x __attribute__((unused)) +# define NS_UNUSED_GLOBAL(x) \ + NS_DEPRECATED_3_36 ("NS_UNUSED_GLOBAL is deprecated, use [[maybe_unused]] directly") \ + [[maybe_unused]] x #elif defined(__LCLINT__) -# define NS_UNUSED_GLOBAL(x) /*@unused@*/ x +# define NS_UNUSED_GLOBAL(x) \ + NS_DEPRECATED_3_36 ("NS_UNUSED_GLOBAL is deprecated, use [[maybe_unused]] directly") \ + /*@unused@*/ x #else -# define NS_UNUSED_GLOBAL(x) x +# define NS_UNUSED_GLOBAL(x) \ + NS_DEPRECATED_3_36 ("NS_UNUSED_GLOBAL is deprecated, use [[maybe_unused]] directly") \ + x #endif #endif diff --git a/src/core/test/attribute-test-suite.cc b/src/core/test/attribute-test-suite.cc index b97373459..f5f46bcdb 100644 --- a/src/core/test/attribute-test-suite.cc +++ b/src/core/test/attribute-test-suite.cc @@ -58,20 +58,16 @@ public: }; -bool operator != (const ValueClassTest &a, const ValueClassTest &b) +bool operator != ([[maybe_unused]] const ValueClassTest &a, [[maybe_unused]] const ValueClassTest &b) { - NS_UNUSED (a); - NS_UNUSED (b); return true; } -std::ostream & operator << (std::ostream &os, ValueClassTest v) +std::ostream & operator << (std::ostream &os, [[maybe_unused]] ValueClassTest v) { - NS_UNUSED (v); return os; } -std::istream & operator >> (std::istream &is, ValueClassTest &v) +std::istream & operator >> (std::istream &is, [[maybe_unused]] ValueClassTest &v) { - NS_UNUSED (v); return is; } @@ -241,13 +237,6 @@ public: AttributeObjectTest (void) { - NS_UNUSED (m_boolTest); - NS_UNUSED (m_int16); - NS_UNUSED (m_int16WithBounds); - NS_UNUSED (m_uint8); - NS_UNUSED (m_float); - NS_UNUSED (m_enum); - NS_UNUSED (m_enumSetGet); } virtual ~AttributeObjectTest (void) @@ -1145,9 +1134,8 @@ public: private: virtual void DoRun (void); - void NotifySource1 (int8_t old, int8_t n) + void NotifySource1 ([[maybe_unused]] int8_t old, int8_t n) { - NS_UNUSED (old); m_got1 = n; } int64_t m_got1; @@ -1221,10 +1209,8 @@ public: private: virtual void DoRun (void); - void NotifySource2 (double a, int b, float c) + void NotifySource2 (double a, [[maybe_unused]] int b, [[maybe_unused]] float c) { - NS_UNUSED (b); - NS_UNUSED (c); m_got2 = a; } @@ -1300,10 +1286,8 @@ public: private: virtual void DoRun (void); - void NotifySource2 (double a, int b, float c) + void NotifySource2 (double a, [[maybe_unused]] int b, [[maybe_unused]] float c) { - NS_UNUSED (b); - NS_UNUSED (c); m_got2 = a; } diff --git a/src/core/test/callback-test-suite.cc b/src/core/test/callback-test-suite.cc index de9789b5c..cf6d67085 100644 --- a/src/core/test/callback-test-suite.cc +++ b/src/core/test/callback-test-suite.cc @@ -18,7 +18,6 @@ #include "ns3/test.h" #include "ns3/callback.h" -#include "ns3/unused.h" #include using namespace ns3; @@ -42,15 +41,12 @@ public: m_test2 = true; return 2; } - void Target3 (double a) + void Target3 ([[maybe_unused]] double a) { - NS_UNUSED (a); m_test3 = true; } - int Target4 (double a, int b) + int Target4 ([[maybe_unused]] double a, [[maybe_unused]] int b) { - NS_UNUSED (a); - NS_UNUSED (b); m_test4 = true; return 4; } @@ -189,15 +185,12 @@ public: m_test2 = true; return 2; } - void Target3 (double a) + void Target3 ([[maybe_unused]] double a) { - NS_UNUSED (a); m_test3 = true; } - int Target4 (double a, int b) + int Target4 ([[maybe_unused]] double a, [[maybe_unused]] int b) { - NS_UNUSED (a); - NS_UNUSED (b); m_test4 = true; return 4; } diff --git a/src/core/test/config-test-suite.cc b/src/core/test/config-test-suite.cc index abd3f1297..78d01ca69 100644 --- a/src/core/test/config-test-suite.cc +++ b/src/core/test/config-test-suite.cc @@ -30,7 +30,6 @@ #include "ns3/names.h" #include "ns3/pointer.h" #include "ns3/log.h" -#include "ns3/unused.h" #include @@ -235,11 +234,6 @@ public: private: int8_t m_x; //!< X attribute target. - /** Silence unused variable warning. */ - void Increment (void) - { - m_x++; - } }; TypeId @@ -633,9 +627,8 @@ public: * \param oldValue The old value. * \param newValue The new value. */ - void Trace (int16_t oldValue, int16_t newValue) + void Trace ([[maybe_unused]] int16_t oldValue, int16_t newValue) { - NS_UNUSED (oldValue); m_newValue = newValue; } /** @@ -644,9 +637,8 @@ public: * \param old The old value. * \param newValue The new value. */ - void TraceWithPath (std::string path, int16_t old, int16_t newValue) + void TraceWithPath (std::string path, [[maybe_unused]] int16_t old, int16_t newValue) { - NS_UNUSED (old); m_newValue = newValue; m_path = path; } diff --git a/src/core/test/simulator-test-suite.cc b/src/core/test/simulator-test-suite.cc index 6b47df7d4..819480acf 100644 --- a/src/core/test/simulator-test-suite.cc +++ b/src/core/test/simulator-test-suite.cc @@ -62,9 +62,8 @@ SimulatorEventsTestCase::NowUs (void) } void -SimulatorEventsTestCase::EventA (int a) +SimulatorEventsTestCase::EventA ([[maybe_unused]] int a) { - NS_UNUSED (a); m_a = false; } @@ -84,9 +83,8 @@ SimulatorEventsTestCase::EventB (int b) } void -SimulatorEventsTestCase::EventC (int c) +SimulatorEventsTestCase::EventC ([[maybe_unused]] int c) { - NS_UNUSED (c); m_c = false; } diff --git a/src/core/test/traced-callback-test-suite.cc b/src/core/test/traced-callback-test-suite.cc index 506669811..2d962c6f8 100644 --- a/src/core/test/traced-callback-test-suite.cc +++ b/src/core/test/traced-callback-test-suite.cc @@ -18,7 +18,6 @@ #include "ns3/test.h" #include "ns3/traced-callback.h" -#include "ns3/unused.h" using namespace ns3; @@ -44,18 +43,14 @@ BasicTracedCallbackTestCase::BasicTracedCallbackTestCase () {} void -BasicTracedCallbackTestCase::CbOne (uint8_t a, double b) +BasicTracedCallbackTestCase::CbOne ([[maybe_unused]] uint8_t a, [[maybe_unused]] double b) { - NS_UNUSED (a); - NS_UNUSED (b); m_one = true; } void -BasicTracedCallbackTestCase::CbTwo (uint8_t a, double b) +BasicTracedCallbackTestCase::CbTwo ([[maybe_unused]] uint8_t a, [[maybe_unused]] double b) { - NS_UNUSED (a); - NS_UNUSED (b); m_two = true; } diff --git a/src/core/test/type-id-test-suite.cc b/src/core/test/type-id-test-suite.cc index 4ef654888..1a2d129f1 100644 --- a/src/core/test/type-id-test-suite.cc +++ b/src/core/test/type-id-test-suite.cc @@ -29,7 +29,6 @@ #include "ns3/type-id.h" #include "ns3/test.h" #include "ns3/log.h" -#include "ns3/unused.h" using namespace std; @@ -216,7 +215,6 @@ public: DeprecatedAttribute () : m_attr (0) { - NS_UNUSED (m_attr); } virtual ~DeprecatedAttribute () {} diff --git a/src/dsr/model/dsr-options.cc b/src/dsr/model/dsr-options.cc index a96f2a0e9..19dfaaaee 100644 --- a/src/dsr/model/dsr-options.cc +++ b/src/dsr/model/dsr-options.cc @@ -1450,7 +1450,7 @@ uint8_t DsrOptionRerr::Process (Ptr packet, Ptr dsrP, Ipv4Addres /* * The error serialized size */ - uint32_t rerrSize; + [[maybe_unused]] uint32_t rerrSize; NS_LOG_DEBUG ("The error type value here " << (uint32_t)errorType); if (errorType == 1) // unreachable ip address { @@ -1494,7 +1494,6 @@ uint8_t DsrOptionRerr::Process (Ptr packet, Ptr dsrP, Ipv4Addres p->RemoveHeader (rerrUnsupport); rerrSize = rerrUnsupport.GetSerializedSize (); - NS_UNUSED (rerrSize); /// \todo This is for the other two error options, not supporting for now // uint32_t serialized = DoSendError (p, rerrUnsupport, rerrSize, ipv4Address, protocol); uint32_t serialized = 0; diff --git a/src/internet/model/rip.cc b/src/internet/model/rip.cc index 3eaa28cf3..c7a111ccf 100644 --- a/src/internet/model/rip.cc +++ b/src/internet/model/rip.cc @@ -23,7 +23,6 @@ #include "ns3/log.h" #include "ns3/abort.h" #include "ns3/assert.h" -#include "ns3/unused.h" #include "ns3/random-variable-stream.h" #include "ns3/ipv4-route.h" #include "ns3/node.h" diff --git a/src/internet/model/ripng.cc b/src/internet/model/ripng.cc index 7f49d88ec..9f3227f23 100644 --- a/src/internet/model/ripng.cc +++ b/src/internet/model/ripng.cc @@ -23,7 +23,6 @@ #include "ns3/log.h" #include "ns3/abort.h" #include "ns3/assert.h" -#include "ns3/unused.h" #include "ns3/random-variable-stream.h" #include "ns3/ipv6-route.h" #include "ns3/node.h" diff --git a/src/internet/model/tcp-congestion-ops.cc b/src/internet/model/tcp-congestion-ops.cc index ab94caabd..412923d8a 100644 --- a/src/internet/model/tcp-congestion-ops.cc +++ b/src/internet/model/tcp-congestion-ops.cc @@ -82,12 +82,10 @@ TcpCongestionOps::HasCongControl () const void TcpCongestionOps::CongControl (Ptr tcb, - const TcpRateOps::TcpRateConnection &rc, - const TcpRateOps::TcpRateSample &rs) + [[maybe_unused]] const TcpRateOps::TcpRateConnection &rc, + [[maybe_unused]] const TcpRateOps::TcpRateSample &rs) { NS_LOG_FUNCTION (this << tcb); - NS_UNUSED (rc); - NS_UNUSED (rs); } // RENO diff --git a/src/internet/model/tcp-congestion-ops.h b/src/internet/model/tcp-congestion-ops.h index 7ba35a71c..1164ab1f0 100644 --- a/src/internet/model/tcp-congestion-ops.h +++ b/src/internet/model/tcp-congestion-ops.h @@ -79,9 +79,8 @@ public: * * \param tcb internal congestion state */ - virtual void Init (Ptr tcb) + virtual void Init ([[maybe_unused]] Ptr tcb) { - NS_UNUSED (tcb); } /** diff --git a/src/internet/model/tcp-prr-recovery.cc b/src/internet/model/tcp-prr-recovery.cc index 5b2960b56..5a2912bcd 100644 --- a/src/internet/model/tcp-prr-recovery.cc +++ b/src/internet/model/tcp-prr-recovery.cc @@ -69,11 +69,11 @@ TcpPrrRecovery::~TcpPrrRecovery (void) } void -TcpPrrRecovery::EnterRecovery (Ptr tcb, uint32_t dupAckCount, +TcpPrrRecovery::EnterRecovery (Ptr tcb, + [[maybe_unused]] uint32_t dupAckCount, uint32_t unAckDataCount, uint32_t deliveredBytes) { NS_LOG_FUNCTION (this << tcb << dupAckCount << unAckDataCount); - NS_UNUSED (dupAckCount); m_prrOut = 0; m_prrDelivered = 0; diff --git a/src/internet/model/tcp-recovery-ops.cc b/src/internet/model/tcp-recovery-ops.cc index 06abaf938..5ee67be46 100644 --- a/src/internet/model/tcp-recovery-ops.cc +++ b/src/internet/model/tcp-recovery-ops.cc @@ -95,20 +95,18 @@ TcpClassicRecovery::~TcpClassicRecovery (void) void TcpClassicRecovery::EnterRecovery (Ptr tcb, uint32_t dupAckCount, - uint32_t unAckDataCount, uint32_t deliveredBytes) + [[maybe_unused]] uint32_t unAckDataCount, + [[maybe_unused]] uint32_t deliveredBytes) { NS_LOG_FUNCTION (this << tcb << dupAckCount << unAckDataCount); - NS_UNUSED (unAckDataCount); - NS_UNUSED (deliveredBytes); tcb->m_cWnd = tcb->m_ssThresh; tcb->m_cWndInfl = tcb->m_ssThresh + (dupAckCount * tcb->m_segmentSize); } void -TcpClassicRecovery::DoRecovery (Ptr tcb, uint32_t deliveredBytes) +TcpClassicRecovery::DoRecovery (Ptr tcb, [[maybe_unused]] uint32_t deliveredBytes) { NS_LOG_FUNCTION (this << tcb << deliveredBytes); - NS_UNUSED (deliveredBytes); tcb->m_cWndInfl += tcb->m_segmentSize; } diff --git a/src/internet/model/tcp-socket-base.cc b/src/internet/model/tcp-socket-base.cc index fc9eacabc..9edcb1686 100644 --- a/src/internet/model/tcp-socket-base.cc +++ b/src/internet/model/tcp-socket-base.cc @@ -860,9 +860,8 @@ TcpSocketBase::Send (Ptr p, uint32_t flags) /* Inherit from Socket class: In TcpSocketBase, it is same as Send() call */ int -TcpSocketBase::SendTo (Ptr p, uint32_t flags, const Address &address) +TcpSocketBase::SendTo (Ptr p, uint32_t flags, [[maybe_unused]] const Address &address) { - NS_UNUSED (address); return Send (p, flags); // SendTo() and Send() are the same } @@ -2304,9 +2303,9 @@ TcpSocketBase::ProcessSynSent (Ptr packet, const TcpHeader& tcpHeader) /* Received a packet upon SYN_RCVD */ void TcpSocketBase::ProcessSynRcvd (Ptr packet, const TcpHeader& tcpHeader, - const Address& fromAddress, const Address& toAddress) + const Address& fromAddress, + [[maybe_unused]] const Address& toAddress) { - NS_UNUSED (toAddress); NS_LOG_FUNCTION (this << tcpHeader); // Extract the flags. PSH, URG, CWR and ECE are disregarded. @@ -2886,11 +2885,10 @@ TcpSocketBase::SetupEndpoint6 () TcpSocketBase cloned, allocate a new end point to handle the incoming connection and send a SYN+ACK to complete the handshake. */ void -TcpSocketBase::CompleteFork (Ptr p, const TcpHeader& h, +TcpSocketBase::CompleteFork ([[maybe_unused]] Ptr p, const TcpHeader& h, const Address& fromAddress, const Address& toAddress) { NS_LOG_FUNCTION (this << p << h << fromAddress << toAddress); - NS_UNUSED (p); // Get port and address from peer (connecting host) if (InetSocketAddress::IsMatchingType (toAddress)) { diff --git a/src/internet/model/tcp-tx-buffer.cc b/src/internet/model/tcp-tx-buffer.cc index 6d24dea2f..6ecbc19fe 100644 --- a/src/internet/model/tcp-tx-buffer.cc +++ b/src/internet/model/tcp-tx-buffer.cc @@ -686,9 +686,8 @@ TcpTxBuffer::DiscardUpTo (const SequenceNumber32& seq, if (i == m_sentList.end ()) { // Move data from app list to sent list, so we can delete the item - Ptr p = CopyFromSequence (offset, m_firstByteSeq)->GetPacketCopy (); + [[maybe_unused]] Ptr p = CopyFromSequence (offset, m_firstByteSeq)->GetPacketCopy (); NS_ASSERT (p != nullptr); - NS_UNUSED (p); i = m_sentList.begin (); NS_ASSERT (i != m_sentList.end ()); } diff --git a/src/internet/model/tcp-westwood.cc b/src/internet/model/tcp-westwood.cc index 1e2734e06..d1808a0e4 100644 --- a/src/internet/model/tcp-westwood.cc +++ b/src/internet/model/tcp-westwood.cc @@ -167,9 +167,8 @@ TcpWestwood::EstimateBW (const Time &rtt, Ptr tcb) uint32_t TcpWestwood::GetSsThresh (Ptr tcb, - uint32_t bytesInFlight) + [[maybe_unused]] uint32_t bytesInFlight) { - NS_UNUSED (bytesInFlight); NS_LOG_LOGIC ("CurrentBW: " << m_currentBW << " minRtt: " << tcb->m_minRtt << " ssthresh: " << m_currentBW * static_cast (tcb->m_minRtt.GetSeconds ())); diff --git a/src/internet/test/tcp-general-test.cc b/src/internet/test/tcp-general-test.cc index 015a696e6..f0380e7a3 100644 --- a/src/internet/test/tcp-general-test.cc +++ b/src/internet/test/tcp-general-test.cc @@ -350,9 +350,8 @@ TcpGeneralTest::QueueDropCb ( std::string context, Ptr p) } void -TcpGeneralTest::PhyDropCb (std::string context, Ptr p) +TcpGeneralTest::PhyDropCb (std::string context, [[maybe_unused]] Ptr p) { - NS_UNUSED (p); if (context.compare ("SENDER") == 0) { PhyDrop (SENDER); diff --git a/src/internet/test/tcp-general-test.h b/src/internet/test/tcp-general-test.h index abf485670..1da22c5e8 100644 --- a/src/internet/test/tcp-general-test.h +++ b/src/internet/test/tcp-general-test.h @@ -696,11 +696,9 @@ protected: * \param oldValue old value * \param newValue new value */ - virtual void CongStateTrace (const TcpSocketState::TcpCongState_t oldValue, - const TcpSocketState::TcpCongState_t newValue) + virtual void CongStateTrace ([[maybe_unused]] const TcpSocketState::TcpCongState_t oldValue, + [[maybe_unused]] const TcpSocketState::TcpCongState_t newValue) { - NS_UNUSED (oldValue); - NS_UNUSED (newValue); } /** @@ -709,10 +707,9 @@ protected: * \param oldValue old value * \param newValue new value */ - virtual void CWndTrace (uint32_t oldValue, uint32_t newValue) + virtual void CWndTrace ([[maybe_unused]] uint32_t oldValue, + [[maybe_unused]] uint32_t newValue) { - NS_UNUSED (oldValue); - NS_UNUSED (newValue); } /** @@ -721,10 +718,9 @@ protected: * \param oldValue old value * \param newValue new value */ - virtual void CWndInflTrace (uint32_t oldValue, uint32_t newValue) + virtual void CWndInflTrace ([[maybe_unused]] uint32_t oldValue, + [[maybe_unused]] uint32_t newValue) { - NS_UNUSED (oldValue); - NS_UNUSED (newValue); } /** @@ -735,10 +731,9 @@ protected: * \param oldTime old value * \param newTime new value */ - virtual void RttTrace (Time oldTime, Time newTime) + virtual void RttTrace ([[maybe_unused]] Time oldTime, + [[maybe_unused]] Time newTime) { - NS_UNUSED (oldTime); - NS_UNUSED (newTime); } /** @@ -749,10 +744,9 @@ protected: * \param oldValue old value * \param newValue new value */ - virtual void SsThreshTrace (uint32_t oldValue, uint32_t newValue) + virtual void SsThreshTrace ([[maybe_unused]] uint32_t oldValue, + [[maybe_unused]] uint32_t newValue) { - NS_UNUSED (oldValue); - NS_UNUSED (newValue); } /** @@ -763,10 +757,9 @@ protected: * \param oldValue old value * \param newValue new value */ - virtual void BytesInFlightTrace (uint32_t oldValue, uint32_t newValue) + virtual void BytesInFlightTrace ([[maybe_unused]] uint32_t oldValue, + [[maybe_unused]] uint32_t newValue) { - NS_UNUSED (oldValue); - NS_UNUSED (newValue); } /** @@ -777,10 +770,9 @@ protected: * \param oldValue old value * \param newValue new value */ - virtual void RtoTrace (Time oldValue, Time newValue) + virtual void RtoTrace ([[maybe_unused]] Time oldValue, + [[maybe_unused]] Time newValue) { - NS_UNUSED (oldValue); - NS_UNUSED (newValue); } /** @@ -791,10 +783,9 @@ protected: * \param oldValue old value * \param newValue new value */ - virtual void NextTxSeqTrace (SequenceNumber32 oldValue, SequenceNumber32 newValue) + virtual void NextTxSeqTrace ([[maybe_unused]] SequenceNumber32 oldValue, + [[maybe_unused]] SequenceNumber32 newValue) { - NS_UNUSED (oldValue); - NS_UNUSED (newValue); } /** @@ -805,37 +796,33 @@ protected: * \param oldValue old value * \param newValue new value */ - virtual void HighestTxSeqTrace (SequenceNumber32 oldValue, SequenceNumber32 newValue) + virtual void HighestTxSeqTrace ([[maybe_unused]] SequenceNumber32 oldValue, + [[maybe_unused]] SequenceNumber32 newValue) { - NS_UNUSED (oldValue); - NS_UNUSED (newValue); } /** * \brief Track the rate value of TcpRateLinux. * \param rate updated value of TcpRate. */ - virtual void RateUpdatedTrace (const TcpRateLinux::TcpRateConnection &rate) + virtual void RateUpdatedTrace ([[maybe_unused]] const TcpRateLinux::TcpRateConnection &rate) { - NS_UNUSED (rate); } /** * \brief Track the rate sample value of TcpRateLinux. * \param sample updated value of TcpRateSample. */ - virtual void RateSampleUpdatedTrace (const TcpRateLinux::TcpRateSample &sample) + virtual void RateSampleUpdatedTrace ([[maybe_unused]] const TcpRateLinux::TcpRateSample &sample) { - NS_UNUSED (sample); } /** * \brief Socket closed normally * \param who the socket closed (SENDER or RECEIVER) */ - virtual void NormalClose (SocketWho who) + virtual void NormalClose ([[maybe_unused]] SocketWho who) { - NS_UNUSED (who); } /** @@ -843,28 +830,25 @@ protected: * * \param who the socket closed (SENDER or RECEIVER) */ - virtual void ErrorClose (SocketWho who) + virtual void ErrorClose ([[maybe_unused]] SocketWho who) { /** \todo indicate the error */ - NS_UNUSED (who); } /** * \brief Drop on the queue * \param who where the drop occurred (SENDER or RECEIVER) */ - virtual void QueueDrop (SocketWho who) + virtual void QueueDrop ([[maybe_unused]] SocketWho who) { - NS_UNUSED (who); } /** * \brief Link drop * \param who where the drop occurred (SENDER or RECEIVER) */ - virtual void PhyDrop (SocketWho who) + virtual void PhyDrop ([[maybe_unused]] SocketWho who) { - NS_UNUSED (who); } /** @@ -876,12 +860,10 @@ protected: * \param h the header of segment * \param who the socket which has received the ACK (SENDER or RECEIVER) */ - virtual void RcvAck (const Ptr tcb, - const TcpHeader& h, SocketWho who) + virtual void RcvAck ([[maybe_unused]] const Ptr tcb, + [[maybe_unused]] const TcpHeader& h, + [[maybe_unused]] SocketWho who) { - NS_UNUSED (tcb); - NS_UNUSED (h); - NS_UNUSED (who); } /** @@ -893,12 +875,10 @@ protected: * \param h the header of segment * \param who the socket which has processed the ACK (SENDER or RECEIVER) */ - virtual void ProcessedAck (const Ptr tcb, - const TcpHeader& h, SocketWho who) + virtual void ProcessedAck ([[maybe_unused]] const Ptr tcb, + [[maybe_unused]] const TcpHeader& h, + [[maybe_unused]] SocketWho who) { - NS_UNUSED (tcb); - NS_UNUSED (h); - NS_UNUSED (who); } /** @@ -925,10 +905,9 @@ protected: * \param tcb Transmission control block * \param who where the RTO has expired (SENDER or RECEIVER) */ - virtual void AfterRTOExpired (const Ptr tcb, SocketWho who) + virtual void AfterRTOExpired ([[maybe_unused]] const Ptr tcb, + [[maybe_unused]] SocketWho who) { - NS_UNUSED (tcb); - NS_UNUSED (who); } /** @@ -937,10 +916,9 @@ protected: * \param tcb Transmission control block * \param who where the RTO has expired (SENDER or RECEIVER) */ - virtual void BeforeRTOExpired (const Ptr tcb, SocketWho who) + virtual void BeforeRTOExpired ([[maybe_unused]] const Ptr tcb, + [[maybe_unused]] SocketWho who) { - NS_UNUSED (tcb); - NS_UNUSED (who); } /** @@ -950,13 +928,11 @@ protected: * \param isRetransmission self-explanatory * \param who where the rtt history was updated */ - virtual void UpdatedRttHistory (const SequenceNumber32 & seq, uint32_t sz, - bool isRetransmission, SocketWho who) + virtual void UpdatedRttHistory ([[maybe_unused]] const SequenceNumber32 & seq, + [[maybe_unused]] uint32_t sz, + [[maybe_unused]] bool isRetransmission, + [[maybe_unused]] SocketWho who) { - NS_UNUSED (seq); - NS_UNUSED (sz); - NS_UNUSED (isRetransmission); - NS_UNUSED (who); } /** @@ -965,10 +941,9 @@ protected: * \param size the amount of bytes transmitted * \param who where the RTO has expired (SENDER or RECEIVER) */ - virtual void DataSent (uint32_t size, SocketWho who) + virtual void DataSent ([[maybe_unused]] uint32_t size, + [[maybe_unused]] SocketWho who) { - NS_UNUSED (size); - NS_UNUSED (who); } /** diff --git a/src/internet/test/tcp-hybla-test.cc b/src/internet/test/tcp-hybla-test.cc index 76740c5dc..73d9b6801 100644 --- a/src/internet/test/tcp-hybla-test.cc +++ b/src/internet/test/tcp-hybla-test.cc @@ -79,9 +79,8 @@ TcpHyblaIncrementTest::TcpHyblaIncrementTest (uint32_t cWnd, uint32_t ssThresh, } void -TcpHyblaIncrementTest::RhoUpdated (double oldVal, double newVal) +TcpHyblaIncrementTest::RhoUpdated ([[maybe_unused]] double oldVal, double newVal) { - NS_UNUSED (oldVal); m_rho = newVal; } diff --git a/src/internet/test/tcp-rate-ops-test.cc b/src/internet/test/tcp-rate-ops-test.cc index 8891c84e7..4a60ae43d 100644 --- a/src/internet/test/tcp-rate-ops-test.cc +++ b/src/internet/test/tcp-rate-ops-test.cc @@ -359,9 +359,8 @@ TcpRateLinuxWithSocketsTest::Rx (const Ptr p, const TcpHeader &h, } void -TcpRateLinuxWithSocketsTest::BytesInFlightTrace (uint32_t oldValue, uint32_t newValue) +TcpRateLinuxWithSocketsTest::BytesInFlightTrace ([[maybe_unused]] uint32_t oldValue, uint32_t newValue) { - NS_UNUSED (oldValue); m_bytesInFlight = newValue; } diff --git a/src/lr-wpan/model/lr-wpan-csmaca.cc b/src/lr-wpan/model/lr-wpan-csmaca.cc index f84a8ee0a..51aaab924 100644 --- a/src/lr-wpan/model/lr-wpan-csmaca.cc +++ b/src/lr-wpan/model/lr-wpan-csmaca.cc @@ -195,8 +195,8 @@ LrWpanCsmaCa::GetTimeToNextSlot (void) const uint64_t elapsedSuperframeSymbols; uint64_t symbolRate; Time timeAtBoundary; - Time elapsedCap; - Time beaconTime; + [[maybe_unused]] Time elapsedCap; + [[maybe_unused]] Time beaconTime; currentTime = Simulator::Now (); @@ -210,8 +210,6 @@ LrWpanCsmaCa::GetTimeToNextSlot (void) const beaconTime = Seconds ((double) m_mac->m_rxBeaconSymbols / symbolRate); elapsedCap = elapsedSuperframe - beaconTime; NS_LOG_DEBUG ("Elapsed incoming CAP symbols: " << (elapsedCap.GetSeconds () * symbolRate) << " (" << elapsedCap.As (Time::S) << ")"); - NS_UNUSED (beaconTime); - NS_UNUSED (elapsedCap); } else { diff --git a/src/lte/model/lte-enb-mac.h b/src/lte/model/lte-enb-mac.h index fe0a917ce..fe2c37b86 100644 --- a/src/lte/model/lte-enb-mac.h +++ b/src/lte/model/lte-enb-mac.h @@ -350,9 +350,8 @@ private: * * Since SR is not implemented in LTE, this method does nothing. */ - void DoReportSrToScheduler (uint16_t rnti) + void DoReportSrToScheduler ([[maybe_unused]] uint16_t rnti) { - NS_UNUSED (rnti); } public: diff --git a/src/lte/model/no-op-component-carrier-manager.cc b/src/lte/model/no-op-component-carrier-manager.cc index 7caa6d678..0808b7250 100644 --- a/src/lte/model/no-op-component-carrier-manager.cc +++ b/src/lte/model/no-op-component-carrier-manager.cc @@ -540,10 +540,9 @@ RrComponentCarrierManager::DoUlReceiveMacCe (MacCeListElement_s bsr, uint8_t com } void -RrComponentCarrierManager::DoUlReceiveSr(uint16_t rnti, uint8_t componentCarrierId) +RrComponentCarrierManager::DoUlReceiveSr(uint16_t rnti, [[maybe_unused]] uint8_t componentCarrierId) { NS_LOG_FUNCTION (this); - NS_UNUSED (componentCarrierId); // split traffic in uplink equally among carriers uint32_t numberOfCarriersForUe = m_enabledComponentCarrier.find (rnti)->second; diff --git a/src/lte/test/lte-test-harq.cc b/src/lte/test/lte-test-harq.cc index 3b60b489a..41250a9be 100644 --- a/src/lte/test/lte-test-harq.cc +++ b/src/lte/test/lte-test-harq.cc @@ -46,7 +46,6 @@ #include #include #include -#include #include #include diff --git a/src/lte/test/lte-test-phy-error-model.cc b/src/lte/test/lte-test-phy-error-model.cc index 7182aab2c..e4a884b53 100644 --- a/src/lte/test/lte-test-phy-error-model.cc +++ b/src/lte/test/lte-test-phy-error-model.cc @@ -47,7 +47,6 @@ #include #include #include -#include #include #include @@ -258,7 +257,7 @@ LenaDataPhyErrorModelTestCase::DoRun (void) double dlRxPackets = rlcStats->GetDlRxPackets (imsi, lcId); double dlTxPackets = rlcStats->GetDlTxPackets (imsi, lcId); - double dlBler = 1.0 - (dlRxPackets/dlTxPackets); + [[maybe_unused]] double dlBler = 1.0 - (dlRxPackets/dlTxPackets); double expectedDlRxPackets = dlTxPackets -dlTxPackets*m_blerRef; NS_LOG_INFO ("\tUser " << i << " imsi " << imsi << " DOWNLINK" << " pkts rx " << dlRxPackets << " tx " << dlTxPackets @@ -266,7 +265,6 @@ LenaDataPhyErrorModelTestCase::DoRun (void) << " expected rx " << expectedDlRxPackets << " difference " << std::abs (expectedDlRxPackets - dlRxPackets) << " tolerance " << m_toleranceRxPackets); - NS_UNUSED (dlBler); // sanity check for whether the tx packets reported by the stats are correct // we expect one packet per TTI @@ -417,7 +415,7 @@ LenaDlCtrlPhyErrorModelTestCase::DoRun (void) uint8_t lcId = 3; double dlRxPackets = rlcStats->GetDlRxPackets (imsi, lcId); double dlTxPackets = rlcStats->GetDlTxPackets (imsi, lcId); - double dlBler = 1.0 - (dlRxPackets/dlTxPackets); + [[maybe_unused]] double dlBler = 1.0 - (dlRxPackets/dlTxPackets); double expectedDlRxPackets = dlTxPackets -dlTxPackets*m_blerRef; NS_LOG_INFO ("\tUser " << i << " imsi " << imsi << " DOWNLINK" << " pkts rx " << dlRxPackets << " tx " << dlTxPackets @@ -425,7 +423,6 @@ LenaDlCtrlPhyErrorModelTestCase::DoRun (void) << " expected rx " << expectedDlRxPackets << " difference " << std::abs (expectedDlRxPackets - dlRxPackets) << " tolerance " << m_toleranceRxPackets); - NS_UNUSED (dlBler); // sanity check for whether the tx packets reported by the stats are correct // we expect one packet per TTI diff --git a/src/mobility/helper/ns2-mobility-helper.cc b/src/mobility/helper/ns2-mobility-helper.cc index 1b786b11c..c2d8640c5 100644 --- a/src/mobility/helper/ns2-mobility-helper.cc +++ b/src/mobility/helper/ns2-mobility-helper.cc @@ -42,7 +42,6 @@ #include #include #include "ns3/log.h" -#include "ns3/unused.h" #include "ns3/simulator.h" #include "ns3/node-list.h" #include "ns3/node.h" @@ -595,8 +594,7 @@ bool IsNumber (const std::string& s) { char *endp; - double v = strtod (s.c_str (), &endp); // declared with warn_unused_result - NS_UNUSED (v); // suppress "set but not used" compiler warning + [[maybe_unused]] double v = strtod (s.c_str (), &endp); return endp == s.c_str () + s.size (); } diff --git a/src/netanim/model/animation-interface.cc b/src/netanim/model/animation-interface.cc index bd687b0cc..4886d141b 100644 --- a/src/netanim/model/animation-interface.cc +++ b/src/netanim/model/animation-interface.cc @@ -868,10 +868,9 @@ AnimationInterface::UanPhyGenRxTrace (std::string context, Ptr p) } void -AnimationInterface::WifiPhyTxBeginTrace (std::string context, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW) +AnimationInterface::WifiPhyTxBeginTrace (std::string context, WifiConstPsduMap psduMap, [[maybe_unused]] WifiTxVector txVector, double txPowerW) { NS_LOG_FUNCTION (this); - NS_UNUSED (txVector); CHECK_STARTED_INTIMEWINDOW_TRACKPACKETS; Ptr ndev = GetNetDeviceFromContext (context); NS_ASSERT (ndev); diff --git a/src/network/test/packet-test-suite.cc b/src/network/test/packet-test-suite.cc index d68b8174b..385aa74ee 100644 --- a/src/network/test/packet-test-suite.cc +++ b/src/network/test/packet-test-suite.cc @@ -20,7 +20,6 @@ #include "ns3/packet.h" #include "ns3/packet-tag-list.h" #include "ns3/test.h" -#include "ns3/unused.h" #include // std:numeric_limits #include #include @@ -947,10 +946,7 @@ PacketTagListTest::CheckRef (const PacketTagList & ref, ATestTag<5> t5 (1); \ ATestTag<6> t6 (1); \ ATestTag<7> t7 (1); \ - const int tagLast = 7; /* length of ref PacketTagList */ \ - NS_UNUSED (tagLast) /* silence warnings */ - - + [[maybe_unused]] const int tagLast = 7; /* length of ref PacketTagList */ void PacketTagListTest::CheckRefList (const PacketTagList & ptl, diff --git a/src/network/utils/queue-size.cc b/src/network/utils/queue-size.cc index b878c185a..27864ebfb 100644 --- a/src/network/utils/queue-size.cc +++ b/src/network/utils/queue-size.cc @@ -20,7 +20,6 @@ #include "queue-size.h" #include "ns3/log.h" -#include "ns3/unused.h" namespace ns3 { @@ -181,9 +180,8 @@ uint32_t QueueSize::GetValue () const QueueSize::QueueSize (std::string size) { NS_LOG_FUNCTION (this << size); - bool ok = DoParse (size, &m_unit, &m_value); + [[maybe_unused]] bool ok = DoParse (size, &m_unit, &m_value); NS_ABORT_MSG_IF (!ok, "Could not parse queue size: " << size); - NS_UNUSED (ok); // suppress compiler warning } /* For printing of queue size */ diff --git a/src/network/utils/queue.h b/src/network/utils/queue.h index 134713c81..915f8aee2 100644 --- a/src/network/utils/queue.h +++ b/src/network/utils/queue.h @@ -27,7 +27,6 @@ #include "ns3/object.h" #include "ns3/traced-callback.h" #include "ns3/traced-value.h" -#include "ns3/unused.h" #include "ns3/log.h" #include "ns3/queue-size.h" #include "ns3/queue-item.h" diff --git a/src/nix-vector-routing/test/nix-test.cc b/src/nix-vector-routing/test/nix-test.cc index 85be38a69..bb3b3304a 100644 --- a/src/nix-vector-routing/test/nix-test.cc +++ b/src/nix-vector-routing/test/nix-test.cc @@ -117,12 +117,10 @@ NixVectorRoutingTest::NixVectorRoutingTest () void NixVectorRoutingTest::ReceivePkt (Ptr socket) { - uint32_t availableData; - availableData = socket->GetRxAvailable (); + [[maybe_unused]] uint32_t availableData = socket->GetRxAvailable (); m_receivedPacket = socket->Recv (std::numeric_limits::max (), 0); NS_TEST_ASSERT_MSG_EQ (availableData, m_receivedPacket->GetSize (), "availableData should be equal to the size of packet received."); - NS_UNUSED (availableData); m_receivedPacketSizes.push_back (m_receivedPacket->GetSize ()); } @@ -380,4 +378,4 @@ public: }; /// Static variable for test initialization -static NixVectorRoutingTestSuite g_nixVectorRoutingTestSuite; \ No newline at end of file +static NixVectorRoutingTestSuite g_nixVectorRoutingTestSuite; diff --git a/src/propagation/model/channel-condition-model.cc b/src/propagation/model/channel-condition-model.cc index efc311815..3536de186 100644 --- a/src/propagation/model/channel-condition-model.cc +++ b/src/propagation/model/channel-condition-model.cc @@ -182,12 +182,9 @@ AlwaysLosChannelConditionModel::~AlwaysLosChannelConditionModel () {} Ptr -AlwaysLosChannelConditionModel::GetChannelCondition (Ptr a, - Ptr b) const +AlwaysLosChannelConditionModel::GetChannelCondition ([[maybe_unused]] Ptr a, + [[maybe_unused]] Ptr b) const { - NS_UNUSED (a); - NS_UNUSED (b); - Ptr c = CreateObject (ChannelCondition::LOS); return c; @@ -221,12 +218,9 @@ NeverLosChannelConditionModel::~NeverLosChannelConditionModel () {} Ptr -NeverLosChannelConditionModel::GetChannelCondition (Ptr a, - Ptr b) const +NeverLosChannelConditionModel::GetChannelCondition ([[maybe_unused]] Ptr a, + [[maybe_unused]] Ptr b) const { - NS_UNUSED (a); - NS_UNUSED (b); - Ptr c = CreateObject (ChannelCondition::NLOS); return c; diff --git a/src/propagation/model/three-gpp-propagation-loss-model.cc b/src/propagation/model/three-gpp-propagation-loss-model.cc index 11d1cc44e..377a4ec82 100644 --- a/src/propagation/model/three-gpp-propagation-loss-model.cc +++ b/src/propagation/model/three-gpp-propagation-loss-model.cc @@ -480,9 +480,8 @@ ThreeGppRmaPropagationLossModel::GetShadowingCorrelationDistance (ChannelConditi } double -ThreeGppRmaPropagationLossModel::Pl1 (double frequency, double distance3D, double h, double w) +ThreeGppRmaPropagationLossModel::Pl1 (double frequency, double distance3D, double h, [[maybe_unused]] double w) { - NS_UNUSED (w); double loss = 20.0 * log10 (40.0 * M_PI * distance3D * frequency / 1e9 / 3.0) + std::min (0.03 * pow (h, 1.72), 10.0) * log10 (distance3D) - std::min (0.044 * pow (h, 1.72), 14.77) + 0.002 * log10 (h) * distance3D; return loss; } @@ -651,11 +650,11 @@ ThreeGppUmaPropagationLossModel::GetLossNlos (double distance2D, double distance } double -ThreeGppUmaPropagationLossModel::GetShadowingStd (Ptr a, Ptr b, ChannelCondition::LosConditionValue cond) const +ThreeGppUmaPropagationLossModel::GetShadowingStd ([[maybe_unused]] Ptr a, + [[maybe_unused]] Ptr b, + ChannelCondition::LosConditionValue cond) const { NS_LOG_FUNCTION (this); - NS_UNUSED (a); - NS_UNUSED (b); double shadowingStd; if (cond == ChannelCondition::LosConditionValue::LOS) @@ -736,10 +735,10 @@ ThreeGppUmiStreetCanyonPropagationLossModel::~ThreeGppUmiStreetCanyonPropagation } double -ThreeGppUmiStreetCanyonPropagationLossModel::GetBpDistance (double hUt, double hBs, double distance2D) const +ThreeGppUmiStreetCanyonPropagationLossModel::GetBpDistance (double hUt, double hBs, + [[maybe_unused]] double distance2D) const { NS_LOG_FUNCTION (this); - NS_UNUSED (distance2D); // compute hE (see 3GPP TR 38.901, Table 7.4.1-1, Note 1) double hE = 1.0; @@ -868,11 +867,11 @@ ThreeGppUmiStreetCanyonPropagationLossModel::GetUtAndBsHeights (double za, doubl } double -ThreeGppUmiStreetCanyonPropagationLossModel::GetShadowingStd (Ptr a, Ptr b, ChannelCondition::LosConditionValue cond) const +ThreeGppUmiStreetCanyonPropagationLossModel::GetShadowingStd ([[maybe_unused]] Ptr a, + [[maybe_unused]] Ptr b, + ChannelCondition::LosConditionValue cond) const { NS_LOG_FUNCTION (this); - NS_UNUSED (a); - NS_UNUSED (b); double shadowingStd; if (cond == ChannelCondition::LosConditionValue::LOS) @@ -943,13 +942,12 @@ ThreeGppIndoorOfficePropagationLossModel::~ThreeGppIndoorOfficePropagationLossMo } double -ThreeGppIndoorOfficePropagationLossModel::GetLossLos (double distance2D, double distance3D, double hUt, double hBs) const +ThreeGppIndoorOfficePropagationLossModel::GetLossLos ([[maybe_unused]] double distance2D, + [[maybe_unused]] double distance3D, + [[maybe_unused]] double hUt, + [[maybe_unused]] double hBs) const { NS_LOG_FUNCTION (this); - NS_UNUSED (distance2D); - NS_UNUSED (distance3D); - NS_UNUSED (hUt); - NS_UNUSED (hBs); // check if the distance is outside the validity range if (distance3D < 1.0 || distance3D > 150.0) @@ -986,11 +984,11 @@ ThreeGppIndoorOfficePropagationLossModel::GetLossNlos (double distance2D, double } double -ThreeGppIndoorOfficePropagationLossModel::GetShadowingStd (Ptr a, Ptr b, ChannelCondition::LosConditionValue cond) const +ThreeGppIndoorOfficePropagationLossModel::GetShadowingStd ([[maybe_unused]] Ptr a, + [[maybe_unused]] Ptr b, + ChannelCondition::LosConditionValue cond) const { NS_LOG_FUNCTION (this); - NS_UNUSED (a); - NS_UNUSED (b); double shadowingStd; if (cond == ChannelCondition::LosConditionValue::LOS) diff --git a/src/sixlowpan/model/sixlowpan-net-device.cc b/src/sixlowpan/model/sixlowpan-net-device.cc index f9f645f9b..af097ff40 100644 --- a/src/sixlowpan/model/sixlowpan-net-device.cc +++ b/src/sixlowpan/model/sixlowpan-net-device.cc @@ -827,9 +827,8 @@ SixLowPanNetDevice::DecompressLowPanHc1 (Ptr packet, Address const &src, Ipv6Header ipHeader; SixLowPanHc1 encoding; - uint32_t ret = packet->RemoveHeader (encoding); + [[maybe_unused]] uint32_t ret = packet->RemoveHeader (encoding); NS_LOG_DEBUG ("removed " << ret << " bytes - pkt is " << *packet); - NS_UNUSED (ret); ipHeader.SetHopLimit (encoding.GetHopLimit ()); @@ -1335,9 +1334,8 @@ SixLowPanNetDevice::DecompressLowPanIphc (Ptr packet, Address const &src Ipv6Header ipHeader; SixLowPanIphc encoding; - uint32_t ret = packet->RemoveHeader (encoding); + [[maybe_unused]] uint32_t ret = packet->RemoveHeader (encoding); NS_LOG_DEBUG ("removed " << ret << " bytes - pkt is " << *packet); - NS_UNUSED (ret); // Hop Limit ipHeader.SetHopLimit (encoding.GetHopLimit ()); @@ -1916,9 +1914,8 @@ SixLowPanNetDevice::DecompressLowPanNhc (Ptr packet, Address const &src, SixLowPanNhcExtension encoding; - uint32_t ret = packet->RemoveHeader (encoding); + [[maybe_unused]] uint32_t ret = packet->RemoveHeader (encoding); NS_LOG_DEBUG ("removed " << ret << " bytes - pkt is " << *packet); - NS_UNUSED (ret); Ipv6ExtensionHopByHopHeader hopHeader; Ipv6ExtensionRoutingHeader routingHeader; @@ -2189,9 +2186,8 @@ SixLowPanNetDevice::DecompressLowPanUdpNhc (Ptr packet, Ipv6Address sadd UdpHeader udpHeader; SixLowPanUdpNhcExtension encoding; - uint32_t ret = packet->RemoveHeader (encoding); + [[maybe_unused]] uint32_t ret = packet->RemoveHeader (encoding); NS_LOG_DEBUG ("removed " << ret << " bytes - pkt is " << *packet); - NS_UNUSED (ret); // Set the value of the ports switch ( encoding.GetPorts () ) diff --git a/src/stats/model/sqlite-output.cc b/src/stats/model/sqlite-output.cc index 4427798ba..27ccf478e 100644 --- a/src/stats/model/sqlite-output.cc +++ b/src/stats/model/sqlite-output.cc @@ -20,7 +20,6 @@ #include #include #include "ns3/abort.h" -#include "ns3/unused.h" #include "ns3/log.h" #include "ns3/nstime.h" @@ -90,10 +89,8 @@ SQLiteOutput::SpinPrepare (sqlite3_stmt **stmt, const std::string &cmd) const template T -SQLiteOutput::RetrieveColumn (sqlite3_stmt *stmt, int pos) const +SQLiteOutput::RetrieveColumn ([[maybe_unused]] sqlite3_stmt *stmt, [[maybe_unused]] int pos) const { - NS_UNUSED (stmt); - NS_UNUSED (pos); NS_FATAL_ERROR ("Can't call generic fn"); } @@ -120,11 +117,8 @@ SQLiteOutput::RetrieveColumn (sqlite3_stmt *stmt, int pos) const template bool -SQLiteOutput::Bind (sqlite3_stmt *stmt, int pos, const T &value) const +SQLiteOutput::Bind ([[maybe_unused]] sqlite3_stmt *stmt, [[maybe_unused]] int pos, [[maybe_unused]] const T &value) const { - NS_UNUSED (stmt); - NS_UNUSED (pos); - NS_UNUSED (value); NS_FATAL_ERROR ("Can't call generic fn"); return false; } diff --git a/src/test/ns3tc/fq-cobalt-queue-disc-test-suite.cc b/src/test/ns3tc/fq-cobalt-queue-disc-test-suite.cc index c091984c8..71444af11 100644 --- a/src/test/ns3tc/fq-cobalt-queue-disc-test-suite.cc +++ b/src/test/ns3tc/fq-cobalt-queue-disc-test-suite.cc @@ -655,10 +655,8 @@ FqCobaltQueueDiscEcnMarking::DequeueWithDelay (Ptr queue, dou } void -FqCobaltQueueDiscEcnMarking::DropNextTracer (int64_t oldVal, int64_t newVal) +FqCobaltQueueDiscEcnMarking::DropNextTracer ([[maybe_unused]] int64_t oldVal, [[maybe_unused]] int64_t newVal) { - NS_UNUSED (oldVal); - NS_UNUSED (newVal); m_dropNextCount++; } diff --git a/src/topology-read/model/rocketfuel-topology-reader.cc b/src/topology-read/model/rocketfuel-topology-reader.cc index 01436deec..e5635f604 100644 --- a/src/topology-read/model/rocketfuel-topology-reader.cc +++ b/src/topology-read/model/rocketfuel-topology-reader.cc @@ -24,7 +24,6 @@ #include #include #include "ns3/log.h" -#include "ns3/unused.h" #include "ns3/node-container.h" #include "rocketfuel-topology-reader.h" @@ -239,8 +238,8 @@ RocketfuelTopologyReader::GenerateFromWeightsFile (int argc, char *argv[]) sname = argv[0]; tname = argv[1]; - double v = strtod (argv[2], &endptr); // weight - NS_UNUSED (v); // suppress "set but not used" compiler warning in optimized builds + [[maybe_unused]] double v = strtod (argv[2], &endptr); // weight + if (*endptr != '\0') { NS_LOG_WARN ("invalid weight: " << argv[2]); diff --git a/src/traffic-control/model/queue-disc.cc b/src/traffic-control/model/queue-disc.cc index d15cc35a4..c3c9f308b 100644 --- a/src/traffic-control/model/queue-disc.cc +++ b/src/traffic-control/model/queue-disc.cc @@ -24,7 +24,6 @@ #include "ns3/object-vector.h" #include "ns3/packet.h" #include "ns3/socket.h" -#include "ns3/unused.h" #include "ns3/simulator.h" #include "queue-disc.h" #include "ns3/net-device-queue-interface.h" @@ -402,9 +401,8 @@ QueueDisc::DoInitialize (void) NS_LOG_FUNCTION (this); // Check the configuration and initialize the parameters of this queue disc - bool ok = CheckConfig (); + [[maybe_unused]] bool ok = CheckConfig (); NS_ASSERT_MSG (ok, "The queue disc configuration is not correct"); - NS_UNUSED (ok); // suppress compiler warning InitializeParams (); // Check the configuration and initialize the parameters of the child queue discs diff --git a/src/traffic-control/test/cobalt-queue-disc-test-suite.cc b/src/traffic-control/test/cobalt-queue-disc-test-suite.cc index 07c40dab7..f3316d2ed 100644 --- a/src/traffic-control/test/cobalt-queue-disc-test-suite.cc +++ b/src/traffic-control/test/cobalt-queue-disc-test-suite.cc @@ -381,10 +381,8 @@ CobaltQueueDiscMarkTest::CobaltQueueDiscMarkTest (QueueSizeUnit mode) } void -CobaltQueueDiscMarkTest::DropNextTracer (int64_t oldVal, int64_t newVal) +CobaltQueueDiscMarkTest::DropNextTracer ([[maybe_unused]] int64_t oldVal, [[maybe_unused]] int64_t newVal) { - NS_UNUSED (oldVal); - NS_UNUSED (newVal); m_dropNextCount++; } diff --git a/src/traffic-control/test/codel-queue-disc-test-suite.cc b/src/traffic-control/test/codel-queue-disc-test-suite.cc index 8335dd214..c17a727c5 100644 --- a/src/traffic-control/test/codel-queue-disc-test-suite.cc +++ b/src/traffic-control/test/codel-queue-disc-test-suite.cc @@ -456,10 +456,8 @@ CoDelQueueDiscBasicDrop::CoDelQueueDiscBasicDrop (QueueSizeUnit mode) } void -CoDelQueueDiscBasicDrop::DropNextTracer (uint32_t oldVal, uint32_t newVal) +CoDelQueueDiscBasicDrop::DropNextTracer ([[maybe_unused]] uint32_t oldVal, [[maybe_unused]] uint32_t newVal) { - NS_UNUSED(oldVal); - NS_UNUSED(newVal); m_dropNextCount++; } @@ -631,10 +629,8 @@ CoDelQueueDiscBasicMark::CoDelQueueDiscBasicMark (QueueSizeUnit mode) } void -CoDelQueueDiscBasicMark::DropNextTracer (uint32_t oldVal, uint32_t newVal) +CoDelQueueDiscBasicMark::DropNextTracer ([[maybe_unused]] uint32_t oldVal, [[maybe_unused]] uint32_t newVal) { - NS_UNUSED(oldVal); - NS_UNUSED(newVal); m_dropNextCount++; } diff --git a/src/uan/helper/uan-helper.cc b/src/uan/helper/uan-helper.cc index 9623f5be2..63b7b398a 100644 --- a/src/uan/helper/uan-helper.cc +++ b/src/uan/helper/uan-helper.cc @@ -55,9 +55,9 @@ NS_LOG_COMPONENT_DEFINE ("UanHelper"); * \param mode The transmission mode. */ static void AsciiPhyTxEvent (std::ostream *os, std::string context, - Ptr packet, double txPowerDb, UanTxMode mode) + Ptr packet, + [[maybe_unused]] double txPowerDb, UanTxMode mode) { - NS_UNUSED (txPowerDb); *os << "+ " << Simulator::Now ().GetSeconds () << " " << context << " " << *packet << std::endl; } @@ -71,9 +71,9 @@ static void AsciiPhyTxEvent (std::ostream *os, std::string context, * \param mode The channel transmission mode. */ static void AsciiPhyRxOkEvent (std::ostream *os, std::string context, - Ptr packet, double snr, UanTxMode mode) + Ptr packet, + [[maybe_unused]] double snr, UanTxMode mode) { - NS_UNUSED (snr); *os << "r " << Simulator::Now ().GetSeconds () << " " << context << " " << *packet << std::endl; } diff --git a/src/uan/model/uan-mac-aloha.cc b/src/uan/model/uan-mac-aloha.cc index 9c6a665b7..d80adf2e0 100644 --- a/src/uan/model/uan-mac-aloha.cc +++ b/src/uan/model/uan-mac-aloha.cc @@ -114,9 +114,8 @@ UanMacAloha::AttachPhy (Ptr phy) } void -UanMacAloha::RxPacketGood (Ptr pkt, double sinr, UanTxMode txMode) +UanMacAloha::RxPacketGood (Ptr pkt, [[maybe_unused]] double sinr, UanTxMode txMode) { - NS_UNUSED (sinr); UanHeaderCommon header; pkt->RemoveHeader (header); NS_LOG_DEBUG ("Receiving packet from " << header.GetSrc () << " For " << header.GetDest ()); diff --git a/src/uan/model/uan-mac-cw.cc b/src/uan/model/uan-mac-cw.cc index 28db572a3..4360b25bd 100644 --- a/src/uan/model/uan-mac-cw.cc +++ b/src/uan/model/uan-mac-cw.cc @@ -326,9 +326,8 @@ UanMacCw::GetSlotTime (void) return m_slotTime; } void -UanMacCw::PhyRxPacketGood (Ptr packet, double sinr, UanTxMode mode) +UanMacCw::PhyRxPacketGood (Ptr packet, [[maybe_unused]] double sinr, UanTxMode mode) { - NS_UNUSED (sinr); UanHeaderCommon header; packet->RemoveHeader (header); @@ -338,9 +337,8 @@ UanMacCw::PhyRxPacketGood (Ptr packet, double sinr, UanTxMode mode) } } void -UanMacCw::PhyRxPacketError (Ptr packet, double sinr) +UanMacCw::PhyRxPacketError (Ptr packet, [[maybe_unused]] double sinr) { - NS_UNUSED (sinr); } void UanMacCw::SaveTimer (void) diff --git a/src/uan/model/uan-mac-rc-gw.cc b/src/uan/model/uan-mac-rc-gw.cc index 47b177dbb..f7cb1f712 100644 --- a/src/uan/model/uan-mac-rc-gw.cc +++ b/src/uan/model/uan-mac-rc-gw.cc @@ -171,10 +171,10 @@ UanMacRcGw::GetTypeId (void) } bool -UanMacRcGw::Enqueue (Ptr packet, uint16_t protocolNumber, const Address &dest) +UanMacRcGw::Enqueue (Ptr packet, + [[maybe_unused]] uint16_t protocolNumber, + [[maybe_unused]] const Address &dest) { - NS_UNUSED (dest); - NS_UNUSED (protocolNumber); NS_LOG_WARN ("RCMAC Gateway transmission to acoustic nodes is not yet implemented"); return false; } @@ -194,15 +194,13 @@ UanMacRcGw::AttachPhy (Ptr phy) } void -UanMacRcGw::ReceiveError (Ptr pkt, double sinr) +UanMacRcGw::ReceiveError (Ptr pkt, [[maybe_unused]] double sinr) { - NS_UNUSED (sinr); } void -UanMacRcGw::ReceivePacket (Ptr pkt, double sinr, UanTxMode mode) +UanMacRcGw::ReceivePacket (Ptr pkt, [[maybe_unused]] double sinr, UanTxMode mode) { - NS_UNUSED (sinr); UanHeaderCommon ch; pkt->PeekHeader (ch); @@ -536,9 +534,9 @@ UanMacRcGw::SendPacket (Ptr pkt, uint32_t rate) double -UanMacRcGw::ComputeAlpha (uint32_t totalFrames, uint32_t totalBytes, uint32_t n, uint32_t a, double deltaK) +UanMacRcGw::ComputeAlpha (uint32_t totalFrames, uint32_t totalBytes, + [[maybe_unused]] uint32_t n, uint32_t a, double deltaK) { - NS_UNUSED (n); double alpha; double lrae = m_rtsSize * 8.0 * a * std::exp (1.0); if (totalFrames == 0) diff --git a/src/uan/model/uan-mac-rc.cc b/src/uan/model/uan-mac-rc.cc index f658b5bde..a3a004cba 100644 --- a/src/uan/model/uan-mac-rc.cc +++ b/src/uan/model/uan-mac-rc.cc @@ -144,9 +144,8 @@ Reservation::IncrementRetry () } void -Reservation::SetTransmitted (bool t) +Reservation::SetTransmitted ([[maybe_unused]] bool t) { - NS_UNUSED (t); m_transmitted = true; } @@ -326,9 +325,8 @@ UanMacRc::AttachPhy (Ptr phy) } void -UanMacRc::ReceiveOkFromPhy (Ptr pkt, double sinr, UanTxMode mode) +UanMacRc::ReceiveOkFromPhy (Ptr pkt, [[maybe_unused]] double sinr, UanTxMode mode) { - NS_UNUSED (sinr); UanHeaderCommon ch; pkt->RemoveHeader (ch); if (ch.GetDest () == Mac8Address::ConvertFrom (GetAddress ()) || ch.GetDest () == Mac8Address::GetBroadcast ()) diff --git a/src/uan/model/uan-net-device.cc b/src/uan/model/uan-net-device.cc index 0e59ec5ca..f105a0ca0 100644 --- a/src/uan/model/uan-net-device.cc +++ b/src/uan/model/uan-net-device.cc @@ -275,9 +275,8 @@ UanNetDevice::IsMulticast () const } Address -UanNetDevice::GetMulticast (Ipv4Address multicastGroup) const +UanNetDevice::GetMulticast ([[maybe_unused]] Ipv4Address multicastGroup) const { - NS_UNUSED (multicastGroup); return m_mac->GetBroadcast (); } @@ -309,11 +308,11 @@ UanNetDevice::Send (Ptr packet, const Address &dest, uint16_t protocolNu } bool -UanNetDevice::SendFrom (Ptr packet, const Address& source, const Address& dest, uint16_t protocolNumber) +UanNetDevice::SendFrom (Ptr packet, + [[maybe_unused]] const Address& source, + [[maybe_unused]] const Address& dest, + [[maybe_unused]] uint16_t protocolNumber) { - NS_UNUSED (source); - NS_UNUSED (dest); - NS_UNUSED (protocolNumber); // Not yet implemented NS_ASSERT_MSG (0, "Not yet implemented"); return false; diff --git a/src/uan/model/uan-phy-dual.cc b/src/uan/model/uan-phy-dual.cc index b8ea1abdc..f57fa2fe6 100644 --- a/src/uan/model/uan-phy-dual.cc +++ b/src/uan/model/uan-phy-dual.cc @@ -273,9 +273,8 @@ UanPhyDual::RegisterListener (UanPhyListener *listener) } void -UanPhyDual::StartRxPacket (Ptr pkt, double rxPowerDb, UanTxMode txMode, UanPdp pdp) +UanPhyDual::StartRxPacket (Ptr pkt, [[maybe_unused]] double rxPowerDb, UanTxMode txMode, UanPdp pdp) { - NS_UNUSED (rxPowerDb); // Not called. StartRxPacket in m_phy1 and m_phy2 are called directly from Transducer. } @@ -484,9 +483,8 @@ UanPhyDual::SetMac (Ptr mac) m_phy2->SetMac (mac); } void -UanPhyDual::NotifyTransStartTx (Ptr packet, double txPowerDb, UanTxMode txMode) +UanPhyDual::NotifyTransStartTx (Ptr packet, [[maybe_unused]] double txPowerDb, UanTxMode txMode) { - NS_UNUSED (txPowerDb); } void UanPhyDual::NotifyIntChange (void) diff --git a/src/uan/model/uan-phy-dual.h b/src/uan/model/uan-phy-dual.h index 1a2c8cf46..5fa5098f0 100644 --- a/src/uan/model/uan-phy-dual.h +++ b/src/uan/model/uan-phy-dual.h @@ -135,9 +135,8 @@ public: virtual uint32_t GetNModes (void); virtual UanTxMode GetMode (uint32_t n); virtual void Clear (void); - virtual void SetSleepMode (bool sleep) + virtual void SetSleepMode ([[maybe_unused]] bool sleep) { - NS_UNUSED (sleep); /// \todo This method has to be implemented } int64_t AssignStreams (int64_t stream); diff --git a/src/uan/model/uan-phy-gen.cc b/src/uan/model/uan-phy-gen.cc index dc0e29081..99ea00489 100644 --- a/src/uan/model/uan-phy-gen.cc +++ b/src/uan/model/uan-phy-gen.cc @@ -831,9 +831,8 @@ UanPhyGen::StartRxPacket (Ptr pkt, double rxPowerDb, UanTxMode txMode, U } void -UanPhyGen::RxEndEvent (Ptr pkt, double rxPowerDb, UanTxMode txMode) +UanPhyGen::RxEndEvent (Ptr pkt, [[maybe_unused]] double rxPowerDb, UanTxMode txMode) { - NS_UNUSED (rxPowerDb); if (pkt != m_pktRx) { return; @@ -1041,9 +1040,8 @@ UanPhyGen::AssignStreams (int64_t stream) } void -UanPhyGen::NotifyTransStartTx (Ptr packet, double txPowerDb, UanTxMode txMode) +UanPhyGen::NotifyTransStartTx (Ptr packet, [[maybe_unused]] double txPowerDb, UanTxMode txMode) { - NS_UNUSED (txPowerDb); if (m_pktRx) { m_minRxSinrDb = -1e30; diff --git a/src/uan/test/uan-energy-model-test.cc b/src/uan/test/uan-energy-model-test.cc index 3cacadccb..7d10c099c 100644 --- a/src/uan/test/uan-energy-model-test.cc +++ b/src/uan/test/uan-energy-model-test.cc @@ -116,10 +116,10 @@ AcousticModemEnergyTestCase::SendOnePacket (Ptr node) } bool -AcousticModemEnergyTestCase::RxPacket (Ptr dev, Ptr pkt, uint16_t mode, const Address &sender) +AcousticModemEnergyTestCase::RxPacket (Ptr dev, Ptr pkt, + [[maybe_unused]] uint16_t mode, + [[maybe_unused]] const Address &sender) { - NS_UNUSED (mode); - NS_UNUSED (sender); // increase the total bytes received m_bytesRx += pkt->GetSize (); diff --git a/src/uan/test/uan-test.cc b/src/uan/test/uan-test.cc index c2cede6d3..2dfdea8a0 100644 --- a/src/uan/test/uan-test.cc +++ b/src/uan/test/uan-test.cc @@ -98,10 +98,10 @@ UanTest::UanTest () : TestCase ("UAN") } bool -UanTest::RxPacket (Ptr dev, Ptr pkt, uint16_t mode, const Address &sender) +UanTest::RxPacket (Ptr dev, Ptr pkt, + [[maybe_unused]] uint16_t mode, + [[maybe_unused]] const Address &sender) { - NS_UNUSED (mode); - NS_UNUSED (sender); m_bytesRx += pkt->GetSize (); return true; } diff --git a/src/wave/helper/wave-helper.cc b/src/wave/helper/wave-helper.cc index bba3201f6..bbb9a5a5e 100644 --- a/src/wave/helper/wave-helper.cc +++ b/src/wave/helper/wave-helper.cc @@ -25,7 +25,6 @@ #include "ns3/wave-net-device.h" #include "ns3/minstrel-wifi-manager.h" #include "ns3/radiotap-header.h" -#include "ns3/unused.h" #include "wave-mac-helper.h" #include "wave-helper.h" @@ -362,8 +361,7 @@ WaveHelper::Install (const WifiPhyHelper &phyHelper, const WifiMacHelper &macHe { try { - const QosWaveMacHelper& qosMac = dynamic_cast (macHelper); - NS_UNUSED (qosMac); + [[maybe_unused]] const QosWaveMacHelper& qosMac = dynamic_cast (macHelper); } catch (const std::bad_cast &) { diff --git a/src/wave/helper/wifi-80211p-helper.cc b/src/wave/helper/wifi-80211p-helper.cc index 86314ce82..7a32b45c1 100644 --- a/src/wave/helper/wifi-80211p-helper.cc +++ b/src/wave/helper/wifi-80211p-helper.cc @@ -26,7 +26,6 @@ #include #include "wave-mac-helper.h" #include "wifi-80211p-helper.h" -#include "ns3/unused.h" namespace ns3 { @@ -75,19 +74,17 @@ Wifi80211pHelper::EnableLogComponents (void) NetDeviceContainer Wifi80211pHelper::Install (const WifiPhyHelper &phyHelper, const WifiMacHelper &macHelper, NodeContainer c) const { - QosWaveMacHelper const * qosMac = dynamic_cast (&macHelper); + [[maybe_unused]] QosWaveMacHelper const * qosMac = dynamic_cast (&macHelper); if (qosMac == 0) { - NqosWaveMacHelper const * nqosMac = dynamic_cast (&macHelper); + [[maybe_unused]] NqosWaveMacHelper const * nqosMac = dynamic_cast (&macHelper); if (nqosMac == 0) { NS_FATAL_ERROR ("the macHelper should be either QosWaveMacHelper or NqosWaveMacHelper" ", or should be the subclass of QosWaveMacHelper or NqosWaveMacHelper"); } - NS_UNUSED (nqosMac); } - NS_UNUSED (qosMac); return WifiHelper::Install (phyHelper, macHelper, c); } diff --git a/src/wifi/model/he/rr-multi-user-scheduler.cc b/src/wifi/model/he/rr-multi-user-scheduler.cc index d2df0b25c..6707b229e 100644 --- a/src/wifi/model/he/rr-multi-user-scheduler.cc +++ b/src/wifi/model/he/rr-multi-user-scheduler.cc @@ -708,8 +708,7 @@ RrMultiUserScheduler::ComputeDlMuInfo (void) mpdu = candidate.second; NS_ASSERT (mpdu != nullptr); - bool ret = m_heFem->TryAddMpdu (mpdu, dlMuInfo.txParams, actualAvailableTime); - NS_UNUSED (ret); + [[maybe_unused]] bool ret = m_heFem->TryAddMpdu (mpdu, dlMuInfo.txParams, actualAvailableTime); NS_ASSERT_MSG (ret, "Weird that an MPDU does not meet constraints when " "transmitted over a larger RU"); }