asserts cut and paste into places where fatal error was appropriate
authorCraig Dowell <craigdo@ee.washington.edu>
Thu, 06 Nov 2008 11:52:59 -0800
changeset 3847 784c45b27326
parent 3846 265004d6dc15
child 3849 a10653fa0891
asserts cut and paste into places where fatal error was appropriate
src/devices/emu/emu-net-device.cc
--- a/src/devices/emu/emu-net-device.cc	Wed Nov 05 19:53:52 2008 -0800
+++ b/src/devices/emu/emu-net-device.cc	Thu Nov 06 11:52:59 2008 -0800
@@ -153,7 +153,10 @@
   //
   // Spin up the emu net device and start receiving packets.
   //
-  NS_ASSERT_MSG (m_sock == -1, "EmuNetDevice::StartDevice(): Device is already started");
+  if (m_sock != -1)
+    {
+      NS_FATAL_ERROR ("EmuNetDevice::StartDevice(): Device is already started");
+    }
 
   NS_LOG_LOGIC ("Creating socket");
   //
@@ -172,7 +175,10 @@
 
   NS_LOG_LOGIC ("Getting interface index");
   int32_t rc = ioctl (m_sock, SIOCGIFINDEX, &ifr);
-  NS_ASSERT_MSG (rc != -1, "EmuNetDevice::StartDevice(): Can't get interface index");
+  if (rc == -1)
+    {
+      NS_FATAL_ERROR ("EmuNetDevice::StartDevice(): Can't get interface index");
+    }
 
   //
   // Save the real interface index for later calls to sendto
@@ -192,10 +198,16 @@
   NS_LOG_LOGIC ("Binding socket to interface");
 
   rc = bind (m_sock, (struct sockaddr *)&ll, sizeof (ll));
-  NS_ASSERT_MSG (rc != -1, "EmuNetDevice::StartDevice(): Can't bind to specified interface");
+  if (rc == -1)
+    {
+      NS_FATAL_ERROR ("EmuNetDevice::StartDevice(): Can't bind to specified interface");
+    }
 
   rc = ioctl(m_sock, SIOCGIFFLAGS, &ifr);
-  NS_ASSERT_MSG (rc != -1, "EmuNetDevice::StartDevice(): Can't get interface flags");
+  if (rc == -1)
+    {
+      NS_FATAL_ERROR ("EmuNetDevice::StartDevice(): Can't get interface flags");
+    }
   
   //
   // This device only works if the underlying interface is up in promiscuous 
@@ -216,7 +228,10 @@
   //
   // Now spin up a read thread to read packets.
   //
-  NS_ASSERT_MSG (m_readThread == 0, "EmuNetDevice::StartDevice(): Receive thread is already running");
+  if (m_readThread != 0)
+    {
+      NS_FATAL_ERROR ("EmuNetDevice::StartDevice(): Receive thread is already running");
+    }
 
   NS_LOG_LOGIC ("Spinning up read thread");
 
@@ -565,7 +580,11 @@
     {
       uint32_t bufferSize = 65536;
       uint8_t *buf = (uint8_t *)malloc (bufferSize);
-      NS_ASSERT_MSG (buf, "EmuNetDevice::ReadThread(): malloc packet buffer failed");
+      if (buf == 0)
+        {
+          NS_FATAL_ERROR ("EmuNetDevice::ReadThread(): malloc packet buffer failed");
+        }
+
       NS_LOG_LOGIC ("Calling recvfrom");
       len = recvfrom (m_sock, buf, bufferSize, 0, (struct sockaddr *)&addr, &addrSize);
 
@@ -636,7 +655,10 @@
 
     NS_LOG_LOGIC ("Getting MAC address");
     int32_t rc = ioctl (m_sock, SIOCGIFHWADDR, &ifr);
-    NS_ASSERT_MSG (rc != -1, "EmuNetDevice::SendFrom(): Can't get MAC address");
+    if (rc == -1)
+      {
+        NS_FATAL_ERROR ("EmuNetDevice::SendFrom(): Can't get MAC address");
+      }
 
     std::ostringstream oss;
     oss << std::hex <<
@@ -694,7 +716,7 @@
 EmuNetDevice::SetDataRate(DataRate bps)
 {
   NS_LOG_FUNCTION (this << bps);
-  NS_ASSERT_MSG (false, "EmuNetDevice::SetDataRate():  Unable."); 
+  NS_FATAL_ERROR ("EmuNetDevice::SetDataRate():  Unable."); 
 }
 
 void
@@ -748,7 +770,7 @@
 Ptr<Channel> 
 EmuNetDevice::GetChannel (void) const
 {
-  NS_ASSERT_MSG (false, "EmuNetDevice::GetChannel():  Unable."); 
+  NS_FATAL_ERROR ("EmuNetDevice::GetChannel():  Unable."); 
   return 0;
 }
 
@@ -769,7 +791,7 @@
 bool 
 EmuNetDevice::SetMtu (const uint16_t mtu)
 {
-  NS_ASSERT_MSG (false, "EmuNetDevice::SetMtu():  Unable."); 
+  NS_FATAL_ERROR ("EmuNetDevice::SetMtu():  Unable."); 
   return false;
 }
 
@@ -782,8 +804,12 @@
 
   int32_t fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
 
+
   int32_t rc = ioctl(fd, SIOCGIFMTU, &ifr);
-  NS_ASSERT_MSG (rc != -1, "EmuNetDevice::GetMtu(): Can't ioctl SIOCGIFMTU");
+  if (rc == -1)
+    {
+      NS_FATAL_ERROR ("EmuNetDevice::GetMtu(): Can't ioctl SIOCGIFMTU");
+    }
 
   close (fd);
 
@@ -846,7 +872,7 @@
 void
 EmuNetDevice::SetPromiscReceiveCallback (PromiscReceiveCallback cb)
 {
-  NS_ASSERT_MSG (false, "EmuNetDevice::SetPromiscReceiveCallback(): Not implemented");
+  NS_FATAL_ERROR ("EmuNetDevice::SetPromiscReceiveCallback(): Not implemented");
 }
 
   bool