Bug 1162 - opt build examples module unused variables
authorJohn Abraham<john.abraham@gatech.edu>
Wed, 18 May 2011 12:59:20 -0400
changeset 7231 619d57dab032
parent 7230 dae74efe7d78
child 7232 7af3504459ce
Bug 1162 - opt build examples module unused variables
examples/energy/energy-model-example.cc
examples/stats/wifi-example-apps.cc
examples/wireless/multirate.cc
examples/wireless/wifi-simple-interference.cc
src/applications/model/packet-sink.cc
src/internet/test/ipv4-raw-test.cc
src/internet/test/udp-test.cc
src/test/ns3wifi/wifi-interference-test-suite.cc
--- a/examples/energy/energy-model-example.cc	Wed May 18 12:28:03 2011 -0400
+++ b/examples/energy/energy-model-example.cc	Wed May 18 12:59:20 2011 -0400
@@ -53,6 +53,9 @@
           NS_LOG_UNCOND ("--\nReceived one packet! Socket: "<< iaddr.GetIpv4 ()
                                                             << " port: " << iaddr.GetPort () << " at time = " <<
                          Simulator::Now ().GetSeconds () << "\n--");
+          //cast iaddr to void, to suppress 'iaddr' set but not used compiler warning
+          //in optimized builds
+          (void) iaddr;
         }
     }
 }
--- a/examples/stats/wifi-example-apps.cc	Wed May 18 12:28:03 2011 -0400
+++ b/examples/stats/wifi-example-apps.cc	Wed May 18 12:59:20 2011 -0400
@@ -242,9 +242,8 @@
   Address from;
   while (packet = socket->RecvFrom(from)) {
       if (InetSocketAddress::IsMatchingType (from)) {
-          InetSocketAddress address = InetSocketAddress::ConvertFrom (from);
           NS_LOG_INFO ("Received " << packet->GetSize() << " bytes from " <<
-                       address.GetIpv4());
+                       InetSocketAddress::ConvertFrom (from).GetIpv4());
         }
 
       TimestampTag timestamp;
--- a/examples/wireless/multirate.cc	Wed May 18 12:28:03 2011 -0400
+++ b/examples/wireless/multirate.cc	Wed May 18 12:59:20 2011 -0400
@@ -334,6 +334,11 @@
                                        << " position (" << clientPos.x << "," << clientPos.y << "," << clientPos.z << ")"
                                        << "\n");
 
+  //cast serverPos,clientPos,iaddrClient to void, to suppress variable set but not
+  //used compiler warning in optimized builds
+  (void) serverPos;
+  (void) clientPos;
+  (void) ipv4AddrClient;
 
   // Equipping the source  node with OnOff Application used for sending 
   OnOffHelper onoff ("ns3::UdpSocketFactory", Address(InetSocketAddress(Ipv4Address("10.0.0.1"), port)));
--- a/examples/wireless/wifi-simple-interference.cc	Wed May 18 12:28:03 2011 -0400
+++ b/examples/wireless/wifi-simple-interference.cc	Wed May 18 12:59:20 2011 -0400
@@ -102,6 +102,9 @@
   socket->GetSockName (addr);
   InetSocketAddress iaddr = InetSocketAddress::ConvertFrom (addr);
   NS_LOG_UNCOND ("Received one packet!  Socket: " << iaddr.GetIpv4 () << " port: " << iaddr.GetPort ());
+  //cast iaddr to void, to suppress iaddr set but not used compiler warning
+  //in optimized builds
+  (void) iaddr;
 }
 
 static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize, 
--- a/src/applications/model/packet-sink.cc	Wed May 18 12:28:03 2011 -0400
+++ b/src/applications/model/packet-sink.cc	Wed May 18 12:59:20 2011 -0400
@@ -165,9 +165,13 @@
       if (InetSocketAddress::IsMatchingType (from))
         {
           m_totalRx += packet->GetSize();
+          InetSocketAddress address = InetSocketAddress::ConvertFrom (from);
           NS_LOG_INFO ("Received " << packet->GetSize() << " bytes from " << 
-                       address.GetIpv4() << " [" << InetSocketAddress::ConvertFrom (from) << "]" 
+                       address.GetIpv4() << " [" << address << "]" 
                                    << " total Rx " << m_totalRx);
+          //cast address to void , to suppress 'address' set but not used 
+          //compiler warning in optimized builds
+          (void) address;
         }
       m_rxTrace (packet, from);
     }
--- a/src/internet/test/ipv4-raw-test.cc	Wed May 18 12:28:03 2011 -0400
+++ b/src/internet/test/ipv4-raw-test.cc	Wed May 18 12:59:20 2011 -0400
@@ -112,6 +112,9 @@
   NS_ASSERT (m_receivedPacket->GetSize () == 2);
   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 Ipv4RawSocketImplTest::ReceivePkt2 (Ptr<Socket> socket)
@@ -122,6 +125,9 @@
   NS_ASSERT (m_receivedPacket2->GetSize () == 2);
   m_receivedPacket2 = socket->Recv (std::numeric_limits<uint32_t>::max(), 0);
   NS_ASSERT (availableData == m_receivedPacket2->GetSize ());
+  //cast availableData to void, to suppress 'availableData' set but not used
+  //compiler warning
+  (void) availableData;
 }
 
 void
--- a/src/internet/test/udp-test.cc	Wed May 18 12:28:03 2011 -0400
+++ b/src/internet/test/udp-test.cc	Wed May 18 12:59:20 2011 -0400
@@ -94,6 +94,9 @@
   availableData = 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
@@ -152,6 +155,9 @@
   availableData = 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 UdpSocketImplTest::ReceivePkt2 (Ptr<Socket> socket)
@@ -160,6 +166,9 @@
   availableData = socket->GetRxAvailable ();
   m_receivedPacket2 = socket->Recv (std::numeric_limits<uint32_t>::max(), 0);
   NS_ASSERT (availableData == m_receivedPacket2->GetSize ());
+  //cast availableData to void, to suppress 'availableData' set but not used
+  //compiler warning
+  (void) availableData;
 }
 
 void
--- a/src/test/ns3wifi/wifi-interference-test-suite.cc	Wed May 18 12:28:03 2011 -0400
+++ b/src/test/ns3wifi/wifi-interference-test-suite.cc	Wed May 18 12:59:20 2011 -0400
@@ -82,8 +82,7 @@
 {
   Address addr;
   socket->GetSockName (addr);
-  InetSocketAddress iaddr = InetSocketAddress::ConvertFrom (addr);
-  NS_LOG_UNCOND ("Received one packet!  Socket: " << iaddr.GetIpv4 () << " port: " << iaddr.GetPort ());
+  NS_LOG_UNCOND ("Received one packet!  Socket: " << InetSocketAddress::ConvertFrom (addr).GetIpv4 () << " port: " << iaddr.GetPort ());
 }
 
 void