Merge Coverity fixes
authorPeter D. Barnes, Jr. <barnes26@llnl.gov>
Wed, 22 May 2013 17:58:58 -0700
changeset 9802 5dea58a3b261
parent 9773 8e9ea27f9cee (current diff)
parent 9801 d1dc77afbd27 (diff)
child 9804 29c398f10b53
Merge Coverity fixes
src/dsr/model/dsr-options.cc
src/dsr/model/dsr-routing.cc
src/internet/model/global-route-manager-impl.cc
src/internet/model/icmpv6-header.cc
src/internet/model/icmpv6-l4-protocol.cc
src/lte/model/lte-enb-phy.cc
src/lte/model/lte-ue-phy.cc
src/olsr/model/olsr-routing-protocol.cc
src/wifi/examples/wifi-phy-test.cc
src/wifi/model/ctrl-headers.cc
src/wifi/model/regular-wifi-mac.cc
--- a/.hgignore	Wed May 22 17:22:49 2013 -0700
+++ b/.hgignore	Wed May 22 17:58:58 2013 -0700
@@ -36,4 +36,6 @@
 \.diff$
 \.tr$
 \#[^\#/]+\#$
+^coverity
 syntax: glob
+TAGS
\ No newline at end of file
--- a/src/core/model/object-factory.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/core/model/object-factory.cc	Wed May 22 17:58:58 2013 -0700
@@ -92,6 +92,7 @@
   Callback<ObjectBase *> cb = m_tid.GetConstructor ();
   ObjectBase *base = cb ();
   Object *derived = dynamic_cast<Object *> (base);
+  NS_ASSERT (derived != 0);
   derived->SetTypeId (m_tid);
   derived->Construct (m_parameters);
   Ptr<Object> object = Ptr<Object> (derived, false);
--- a/src/core/model/system-path.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/core/model/system-path.cc	Wed May 22 17:58:58 2013 -0700
@@ -308,11 +308,17 @@
     {
       std::string tmp = Join (elements.begin (), i);
 #if defined(HAVE_MKDIR_H)
-      mkdir (tmp.c_str (), S_IRWXU);
+      if (mkdir (tmp.c_str (), S_IRWXU))
+        {
+          NS_LOG_ERROR ("failed creating directory " << tmp);
+        }
 #endif
     }
 #if defined(HAVE_MKDIR_H)
-  mkdir (path.c_str (), S_IRWXU);
+      if (mkdir (path.c_str (), S_IRWXU))
+        {
+          NS_LOG_ERROR ("failed creating directory " << path);
+        }
 #endif
 
 }
--- a/src/core/model/test.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/core/model/test.cc	Wed May 22 17:58:58 2013 -0700
@@ -278,7 +278,7 @@
 {
   NS_LOG_FUNCTION (this << filename);
   const TestCase *current = this;
-  while (current->m_dataDir == "" && current != 0)
+  while (current != 0 && current->m_dataDir == "")
     {
       current = current->m_parent;
     }
@@ -595,6 +595,8 @@
             }
         }
     }
+
+  os->unsetf(std::ios_base::floatfield);
 }
   
 void
@@ -652,6 +654,7 @@
   for (std::list<TestCase *>::const_iterator i = begin; i != end; ++i)
     {
       TestSuite * test= dynamic_cast<TestSuite *>(*i);
+      NS_ASSERT (test != 0);
       if (printTestType)
         {
           std::cout << label[test->GetTestType ()];
--- a/src/core/test/command-line-test-suite.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/core/test/command-line-test-suite.cc	Wed May 22 17:58:58 2013 -0700
@@ -60,6 +60,7 @@
       args[i+1] = arg;
       i++;
     }
+  va_end (ap);
   int argc = n + 1;
   cmd.Parse (argc, args);
   delete [] args;
--- a/src/dsr/model/dsr-options.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/dsr/model/dsr-options.cc	Wed May 22 17:58:58 2013 -0700
@@ -946,7 +946,7 @@
           return rreq.GetSerializedSize ();
         }
     }
-  return rreq.GetSerializedSize ();
+  //unreachable:  return rreq.GetSerializedSize ();
 }
 
 NS_OBJECT_ENSURE_REGISTERED (DsrOptionRrep);
--- a/src/dsr/model/dsr-routing.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/dsr/model/dsr-routing.cc	Wed May 22 17:58:58 2013 -0700
@@ -2513,7 +2513,10 @@
       networkKey.m_destination = newEntry.GetDst ();
 
       m_addressForwardCnt[networkKey] = 0;
-      m_maintainBuffer.Enqueue (newEntry);
+      if (! m_maintainBuffer.Enqueue (newEntry))
+        {
+          NS_LOG_ERROR ("Failed to enqueue packet retry");
+        }
 
       if (m_addressForwardTimer.find (networkKey) == m_addressForwardTimer.end ())
         {
--- a/src/internet/model/global-route-manager-impl.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/internet/model/global-route-manager-impl.cc	Wed May 22 17:58:58 2013 -0700
@@ -772,6 +772,7 @@
 // shortest path calculation.
 //
           l = v->GetLSA ()->GetLinkRecord (i);
+          NS_ASSERT (l != 0);
           if (l->GetLinkType () == GlobalRoutingLinkRecord::StubNetwork)
             {
               NS_LOG_LOGIC ("Found a Stub record to " << l->GetLinkId ());
@@ -841,6 +842,7 @@
 //
       if (v->GetLSA ()->GetLSType () == GlobalRoutingLSA::RouterLSA)
         {
+          NS_ASSERT (l != 0);
           distance = v->GetDistanceFromRoot () + l->GetMetric ();
         }
       else
--- a/src/internet/model/icmpv6-header.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/internet/model/icmpv6-header.cc	Wed May 22 17:58:58 2013 -0700
@@ -1895,6 +1895,7 @@
 
   SetType (i.ReadU8 ());
   SetLength (i.ReadU8 ());
+  NS_ASSERT (GetLength () * 8 - 2 <= 32);
   i.Read (mac, (GetLength () * 8) - 2);
 
   m_addr.CopyFrom (mac, (GetLength () * 8)-2);
--- a/src/internet/model/icmpv6-l4-protocol.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/internet/model/icmpv6-l4-protocol.cc	Wed May 22 17:58:58 2013 -0700
@@ -590,6 +590,10 @@
   if (!entry)
     {
       /* ouch!! we are victim of a DAD */
+      
+      /*  Logically dead code (DEADCODE)
+       *  b/c loop test compares default Ipv6InterfaceAddress to target
+       
       Ipv6InterfaceAddress ifaddr;
       bool found = false;
       uint32_t i = 0;
@@ -611,6 +615,7 @@
               interface->SetState (ifaddr.GetAddress (), Ipv6InterfaceAddress::INVALID);
             }
         }
+      */
       /* we have not initiated any communication with the target so... discard the NA */
       return;
     }
--- a/src/internet/model/ipv6-extension.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/internet/model/ipv6-extension.cc	Wed May 22 17:58:58 2013 -0700
@@ -530,15 +530,24 @@
         {
           if (it->second == Ipv6Header::IPV6_EXT_HOP_BY_HOP)
             {
-              fragment->AddHeader (*dynamic_cast<Ipv6ExtensionHopByHopHeader *> (it->first));
+              Ipv6ExtensionHopByHopHeader * p =
+                dynamic_cast<Ipv6ExtensionHopByHopHeader *> (it->first);
+              NS_ASSERT (p != 0);
+              fragment->AddHeader (*p);
             }
           else if (it->second == Ipv6Header::IPV6_EXT_ROUTING)
             {
-              fragment->AddHeader (*dynamic_cast<Ipv6ExtensionLooseRoutingHeader *> (it->first));
+              Ipv6ExtensionLooseRoutingHeader * p =
+                dynamic_cast<Ipv6ExtensionLooseRoutingHeader *> (it->first);
+              NS_ASSERT (p != 0);
+              fragment->AddHeader (*p);
             }
           else if (it->second == Ipv6Header::IPV6_EXT_DESTINATION)
             {
-              fragment->AddHeader (*dynamic_cast<Ipv6ExtensionDestinationHeader *> (it->first));
+              Ipv6ExtensionDestinationHeader * p =
+                dynamic_cast<Ipv6ExtensionDestinationHeader *> (it->first);
+              NS_ASSERT (p != 0);
+              fragment->AddHeader (*p);
             }
         }
 
--- a/src/internet/model/ipv6-l3-protocol.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/internet/model/ipv6-l3-protocol.cc	Wed May 22 17:58:58 2013 -0700
@@ -814,6 +814,7 @@
 
       // To get specific method GetFragments from Ipv6ExtensionFragmentation
       Ipv6ExtensionFragment *ipv6Fragment = dynamic_cast<Ipv6ExtensionFragment *> (PeekPointer (ipv6ExtensionDemux->GetExtension (Ipv6Header::IPV6_EXT_FRAGMENTATION)));
+      NS_ASSERT (ipv6Fragment != 0);
       ipv6Fragment->GetFragments (packet, outInterface->GetDevice ()->GetMtu (), fragments);
     }
 
--- a/src/internet/model/pending-data.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/internet/model/pending-data.cc	Wed May 22 17:58:58 2013 -0700
@@ -103,14 +103,7 @@
 void PendingData::Add (uint32_t s, const uint8_t* d)
 {
   NS_LOG_FUNCTION (this << s);
-  if (d == 0)
-    {
-      data.push_back (Create<Packet> (d,s));
-    }
-  else
-    {
-      data.push_back (Create<Packet> (s));
-    }
+  data.push_back (Create<Packet> (d,s));
   size += s;
 }
 
--- a/src/lte/helper/lte-hex-grid-enb-topology-helper.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/lte/helper/lte-hex-grid-enb-topology-helper.cc	Wed May 22 17:58:58 2013 -0700
@@ -153,8 +153,7 @@
 	  y -= m_offset*xydfactor;
 	  break;
 	
-	default:
-	  break;
+          // no default, n%3 = 0, 1, 2
 	}
       Ptr<Node> node = c.Get (n);
       Ptr<MobilityModel> mm = node->GetObject<MobilityModel> ();
--- a/src/lte/model/fdbet-ff-mac-scheduler.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/lte/model/fdbet-ff-mac-scheduler.cc	Wed May 22 17:58:58 2013 -0700
@@ -29,6 +29,7 @@
 #include <ns3/lte-vendor-specific-parameters.h>
 #include <ns3/boolean.h>
 #include <set>
+#include <cfloat>
 
 NS_LOG_COMPONENT_DEFINE ("FdBetFfMacScheduler");
 
@@ -1102,6 +1103,11 @@
 
       uint16_t lcActives = LcActivePerFlow ((*itMap).first);
       NS_LOG_INFO (this << "Allocate user " << newEl.m_rnti << " rbg " << lcActives);
+      if (lcActives == 0)
+        {
+          // Set to max value, to avoid divide by 0 below
+          lcActives = UINT16_MAX;
+        }
       uint16_t RgbPerRnti = (*itMap).second.size ();
       std::map <uint16_t,uint8_t>::iterator itCqi;
       itCqi = m_p10CqiRxed.find ((*itMap).first);
@@ -1338,7 +1344,7 @@
               sinrNum++;
             }
         }
-      double estimatedSinr = sinrSum / (double)sinrNum;
+      double estimatedSinr = (sinrNum > 0) ? (sinrSum / sinrNum) : DBL_MAX;
       // store the value
       (*itCqi).second.at (rb) = estimatedSinr;
       return (estimatedSinr);
--- a/src/lte/model/fdmt-ff-mac-scheduler.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/lte/model/fdmt-ff-mac-scheduler.cc	Wed May 22 17:58:58 2013 -0700
@@ -29,6 +29,7 @@
 #include <ns3/lte-vendor-specific-parameters.h>
 #include <ns3/boolean.h>
 #include <set>
+#include <cfloat>
 
 NS_LOG_COMPONENT_DEFINE ("FdMtFfMacScheduler");
 
@@ -1073,6 +1074,11 @@
 
       uint16_t lcActives = LcActivePerFlow ((*itMap).first);
       NS_LOG_INFO (this << "Allocate user " << newEl.m_rnti << " rbg " << lcActives);
+      if (lcActives == 0)
+        {
+          // Set to max value, to avoid divide by 0 below
+          lcActives = UINT16_MAX;
+        }
       uint16_t RgbPerRnti = (*itMap).second.size ();
       std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
       itCqi = m_a30CqiRxed.find ((*itMap).first);
@@ -1318,7 +1324,7 @@
               sinrNum++;
             }
         }
-      double estimatedSinr = sinrSum / (double)sinrNum;
+      double estimatedSinr = (sinrNum > 0) ? (sinrSum / sinrNum) : DBL_MAX;
       // store the value
       (*itCqi).second.at (rb) = estimatedSinr;
       return (estimatedSinr);
--- a/src/lte/model/fdtbfq-ff-mac-scheduler.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/lte/model/fdtbfq-ff-mac-scheduler.cc	Wed May 22 17:58:58 2013 -0700
@@ -30,6 +30,7 @@
 #include <ns3/boolean.h>
 #include <ns3/integer.h>
 #include <set>
+#include <cfloat>
 
 NS_LOG_COMPONENT_DEFINE ("FdTbfqFfMacScheduler");
 
@@ -1323,6 +1324,11 @@
 
       uint16_t lcActives = LcActivePerFlow ((*itMap).first);
       NS_LOG_INFO (this << "Allocate user " << newEl.m_rnti << " rbg " << lcActives);
+      if (lcActives == 0)
+        {
+          // Set to max value, to avoid divide by 0 below
+          lcActives = UINT16_MAX;
+        }
       uint16_t RgbPerRnti = (*itMap).second.size ();
       std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
       itCqi = m_a30CqiRxed.find ((*itMap).first);
@@ -1568,7 +1574,7 @@
               sinrNum++;
             }
         }
-      double estimatedSinr = sinrSum / (double)sinrNum;
+      double estimatedSinr = (sinrNum > 0) ? (sinrSum / sinrNum) : DBL_MAX;
       // store the value
       (*itCqi).second.at (rb) = estimatedSinr;
       return (estimatedSinr);
--- a/src/lte/model/lte-enb-phy.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/lte/model/lte-enb-phy.cc	Wed May 22 17:58:58 2013 -0700
@@ -21,6 +21,7 @@
 
 #include <ns3/object-factory.h>
 #include <ns3/log.h>
+#include <cfloat>
 #include <cmath>
 #include <ns3/simulator.h>
 #include <ns3/attribute-accessor-helper.h>
@@ -832,7 +833,8 @@
   vsp.m_value = rnti;
   ulcqi.m_vendorSpecificList.push_back (vsp);
   // call SRS tracing method
-  CreateSrsReport (m_srsUeOffset.at (m_currentSrsOffset), srsSum / i);
+  CreateSrsReport (m_srsUeOffset.at (m_currentSrsOffset),
+                   (i > 0) ? (srsSum / i) : DBL_MAX);
   return (ulcqi);
   
 }
--- a/src/lte/model/lte-ue-phy.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/lte/model/lte-ue-phy.cc	Wed May 22 17:58:58 2013 -0700
@@ -22,6 +22,7 @@
 
 #include <ns3/object-factory.h>
 #include <ns3/log.h>
+#include <cfloat>
 #include <cmath>
 #include <ns3/simulator.h>
 #include <ns3/double.h>
@@ -472,7 +473,7 @@
           sum += powerTxW;
           rbNum++;
         }
-      double rsrp = sum / (double)rbNum;
+      double rsrp = (rbNum > 0) ? (sum / rbNum) : DBL_MAX;
       // averaged SINR among RBs
       sum = 0.0;
       rbNum = 0;
@@ -481,7 +482,7 @@
           sum += (*it);
           rbNum++;
         }
-      double avSinr = sum / (double)rbNum;
+      double avSinr = (rbNum > 0) ? (sum / rbNum) : DBL_MAX;
       NS_LOG_INFO (this << " cellId " << m_cellId << " rnti " << m_rnti << " RSRP " << rsrp << " SINR " << avSinr);
  
       m_reportCurrentCellRsrpSinrTrace (m_cellId, m_rnti, rsrp, avSinr);
--- a/src/lte/model/pf-ff-mac-scheduler.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/lte/model/pf-ff-mac-scheduler.cc	Wed May 22 17:58:58 2013 -0700
@@ -27,6 +27,7 @@
 #include <ns3/pf-ff-mac-scheduler.h>
 #include <ns3/lte-vendor-specific-parameters.h>
 #include <ns3/boolean.h>
+#include <cfloat>
 #include <set>
 
 NS_LOG_COMPONENT_DEFINE ("PfFfMacScheduler");
@@ -1089,6 +1090,11 @@
 
       uint16_t lcActives = LcActivePerFlow ((*itMap).first);
       NS_LOG_INFO (this << "Allocate user " << newEl.m_rnti << " rbg " << lcActives);
+      if (lcActives == 0)
+        {
+          // Set to max value, to avoid divide by 0 below
+          lcActives = UINT16_MAX;
+        }
       uint16_t RgbPerRnti = (*itMap).second.size ();
       std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
       itCqi = m_a30CqiRxed.find ((*itMap).first);
@@ -1361,7 +1367,7 @@
               sinrNum++;
             }
         }
-      double estimatedSinr = sinrSum / (double)sinrNum;
+      double estimatedSinr = (sinrNum > 0) ? (sinrSum / sinrNum) : DBL_MAX;
       // store the value
       (*itCqi).second.at (rb) = estimatedSinr;
       return (estimatedSinr);
--- a/src/lte/model/pss-ff-mac-scheduler.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/lte/model/pss-ff-mac-scheduler.cc	Wed May 22 17:58:58 2013 -0700
@@ -28,6 +28,7 @@
 #include <ns3/pss-ff-mac-scheduler.h>
 #include <ns3/lte-vendor-specific-parameters.h>
 #include <ns3/boolean.h>
+#include <cfloat>
 #include <set>
 #include <ns3/string.h>
 #include <algorithm>
@@ -1388,6 +1389,11 @@
 
       uint16_t lcActives = LcActivePerFlow ((*itMap).first);
       NS_LOG_INFO (this << "Allocate user " << newEl.m_rnti << " rbg " << lcActives);
+      if (lcActives == 0)
+        {
+          // Set to max value, to avoid divide by 0 below
+          lcActives = UINT16_MAX;
+        }
       uint16_t RgbPerRnti = (*itMap).second.size ();
       std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
       itCqi = m_a30CqiRxed.find ((*itMap).first);
@@ -1666,7 +1672,7 @@
               sinrNum++;
             }
         }
-      double estimatedSinr = sinrSum / (double)sinrNum;
+      double estimatedSinr = (sinrNum > 0) ? (sinrSum / sinrNum) : DBL_MAX;
       // store the value
       (*itCqi).second.at (rb) = estimatedSinr;
       return (estimatedSinr);
--- a/src/lte/model/rr-ff-mac-scheduler.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/lte/model/rr-ff-mac-scheduler.cc	Wed May 22 17:58:58 2013 -0700
@@ -21,6 +21,7 @@
 #include <ns3/log.h>
 #include <ns3/pointer.h>
 #include <ns3/math.h>
+#include <cfloat>
 #include <set>
 
 #include <ns3/lte-amc.h>
@@ -977,7 +978,7 @@
   // Divide the resource equally among the active users according to
   // Resource allocation type 0 (see sec 7.1.6.1 of 36.213)
 
-  int rbgPerTb = (rbgNum - rbgAllocatedNum) / nTbs;
+  int rbgPerTb = (nTbs > 0) ? ((rbgNum - rbgAllocatedNum) / nTbs) : DBL_MAX;
   NS_LOG_INFO (this << " Flows to be transmitted " << nflows << " rbgPerTb " << rbgPerTb);
   if (rbgPerTb == 0)
     {
--- a/src/lte/model/tdbet-ff-mac-scheduler.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/lte/model/tdbet-ff-mac-scheduler.cc	Wed May 22 17:58:58 2013 -0700
@@ -29,6 +29,7 @@
 #include <ns3/lte-vendor-specific-parameters.h>
 #include <ns3/boolean.h>
 #include <set>
+#include <cfloat>
 
 NS_LOG_COMPONENT_DEFINE ("TdBetFfMacScheduler");
 
@@ -1025,6 +1026,11 @@
 
       uint16_t lcActives = LcActivePerFlow ((*itMap).first);
       NS_LOG_INFO (this << "Allocate user " << newEl.m_rnti << " rbg " << lcActives);
+      if (lcActives == 0)
+        {
+          // Set to max value, to avoid divide by 0 below
+          lcActives = UINT16_MAX;
+        }
       uint16_t RgbPerRnti = (*itMap).second.size ();
       std::map <uint16_t,uint8_t>::iterator itCqi;
       itCqi = m_p10CqiRxed.find ((*itMap).first);
@@ -1261,7 +1267,7 @@
               sinrNum++;
             }
         }
-      double estimatedSinr = sinrSum / (double)sinrNum;
+      double estimatedSinr = (sinrNum > 0) ? (sinrSum / sinrNum) : DBL_MAX;
       // store the value
       (*itCqi).second.at (rb) = estimatedSinr;
       return (estimatedSinr);
--- a/src/lte/model/tdmt-ff-mac-scheduler.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/lte/model/tdmt-ff-mac-scheduler.cc	Wed May 22 17:58:58 2013 -0700
@@ -29,6 +29,7 @@
 #include <ns3/lte-vendor-specific-parameters.h>
 #include <ns3/boolean.h>
 #include <set>
+#include <cfloat>
 
 NS_LOG_COMPONENT_DEFINE ("TdMtFfMacScheduler");
 
@@ -1052,6 +1053,11 @@
 
       uint16_t lcActives = LcActivePerFlow ((*itMap).first);
       NS_LOG_INFO (this << "Allocate user " << newEl.m_rnti << " rbg " << lcActives);
+      if (lcActives == 0)
+        {
+          // Set to max value, to avoid divide by 0 below
+          lcActives = UINT16_MAX;
+        }
       uint16_t RgbPerRnti = (*itMap).second.size ();
       std::map <uint16_t,uint8_t>::iterator itCqi;
       itCqi = m_p10CqiRxed.find ((*itMap).first);
@@ -1258,7 +1264,7 @@
               sinrNum++;
             }
         }
-      double estimatedSinr = sinrSum / (double)sinrNum;
+      double estimatedSinr = (sinrNum > 0) ? (sinrSum / sinrNum) : DBL_MAX;
       // store the value
       (*itCqi).second.at (rb) = estimatedSinr;
       return (estimatedSinr);
--- a/src/lte/model/tdtbfq-ff-mac-scheduler.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/lte/model/tdtbfq-ff-mac-scheduler.cc	Wed May 22 17:58:58 2013 -0700
@@ -30,6 +30,7 @@
 #include <ns3/boolean.h>
 #include <ns3/integer.h>
 #include <set>
+#include <cfloat>
 
 NS_LOG_COMPONENT_DEFINE ("TdTbfqFfMacScheduler");
 
@@ -1098,6 +1099,11 @@
 
       uint16_t lcActives = LcActivePerFlow ((*itMap).first);
       NS_LOG_INFO (this << "Allocate user " << newEl.m_rnti << " rbg " << lcActives);
+      if (lcActives == 0)
+        {
+          // Set to max value, to avoid divide by 0 below
+          lcActives = UINT16_MAX;
+        }
       uint16_t RgbPerRnti = (*itMap).second.size ();
       std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
       itCqi = m_a30CqiRxed.find ((*itMap).first);
@@ -1354,7 +1360,7 @@
               sinrNum++;
             }
         }
-      double estimatedSinr = sinrSum / (double)sinrNum;
+      double estimatedSinr = (sinrNum > 0) ? (sinrSum / sinrNum) : DBL_MAX;
       // store the value
       (*itCqi).second.at (rb) = estimatedSinr;
       return (estimatedSinr);
--- a/src/lte/model/tta-ff-mac-scheduler.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/lte/model/tta-ff-mac-scheduler.cc	Wed May 22 17:58:58 2013 -0700
@@ -29,6 +29,7 @@
 #include <ns3/lte-vendor-specific-parameters.h>
 #include <ns3/boolean.h>
 #include <set>
+#include <cfloat>
 
 NS_LOG_COMPONENT_DEFINE ("TtaFfMacScheduler");
 
@@ -1091,6 +1092,11 @@
 
       uint16_t lcActives = LcActivePerFlow ((*itMap).first);
       NS_LOG_INFO (this << "Allocate user " << newEl.m_rnti << " rbg " << lcActives);
+      if (lcActives == 0)
+        {
+          // Set to max value, to avoid divide by 0 below
+          lcActives = UINT16_MAX;
+        }
       uint16_t RgbPerRnti = (*itMap).second.size ();
       std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
       itCqi = m_a30CqiRxed.find ((*itMap).first);
@@ -1337,7 +1343,7 @@
               sinrNum++;
             }
         }
-      double estimatedSinr = sinrSum / (double)sinrNum;
+      double estimatedSinr = (sinrNum > 0) ? (sinrSum / sinrNum) : DBL_MAX;
       // store the value
       (*itCqi).second.at (rb) = estimatedSinr;
       return (estimatedSinr);
--- a/src/lte/test/test-lte-x2-handover.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/lte/test/test-lte-x2-handover.cc	Wed May 22 17:58:58 2013 -0700
@@ -234,8 +234,8 @@
    
   if (m_epc)
     {
-      bool epcDl = true;
-      bool epcUl = true;
+      // always true: bool epcDl = true;
+      // always true: bool epcUl = true;
       // the rest of this block is copied from lena-dual-stripe
 
     
@@ -271,7 +271,7 @@
 
               if (m_useUdp)
                 {              
-                  if (epcDl)
+                  // always true: if (epcDl)
                     {
                       UdpClientHelper dlClientHelper (ueIpIfaces.GetAddress (u), dlPort);
                       clientApps.Add (dlClientHelper.Install (remoteHost));
@@ -282,7 +282,7 @@
                       serverApps.Add (sinkContainer);
                       
                     }
-                  if (epcUl)
+                  // always true: if (epcUl)
                     {      
                       UdpClientHelper ulClientHelper (remoteHostAddr, ulPort);
                       clientApps.Add (ulClientHelper.Install (ue));
@@ -295,7 +295,7 @@
                 }                    
               else // use TCP
                 {
-                  if (epcDl)
+                  // always true: if (epcDl)
                     {
                       BulkSendHelper dlClientHelper ("ns3::TcpSocketFactory",
                                                      InetSocketAddress (ueIpIfaces.GetAddress (u), dlPort));
@@ -307,7 +307,7 @@
                       bearerData.dlSink = sinkContainer.Get (0)->GetObject<PacketSink> ();
                       serverApps.Add (sinkContainer);
                     }
-                  if (epcUl)
+                  // always true: if (epcUl)
                     {     
                       BulkSendHelper ulClientHelper ("ns3::TcpSocketFactory",
                                                      InetSocketAddress (remoteHostAddr, ulPort));
@@ -322,14 +322,14 @@
                 } // end if (useUdp)
 
               Ptr<EpcTft> tft = Create<EpcTft> ();
-              if (epcDl)
+              // always true: if (epcDl)
                 {
                   EpcTft::PacketFilter dlpf;
                   dlpf.localPortStart = dlPort;
                   dlpf.localPortEnd = dlPort;
                   tft->Add (dlpf); 
                 }
-              if (epcUl)
+              // always true: if (epcUl)
                 {
                   EpcTft::PacketFilter ulpf;
                   ulpf.remotePortStart = ulPort;
@@ -337,7 +337,7 @@
                   tft->Add (ulpf);
                 }
 
-              if (epcDl || epcUl)
+              // always true: if (epcDl || epcUl)
                 {
                   EpsBearer bearer (EpsBearer::NGBR_VIDEO_TCP_DEFAULT);
                   m_lteHelper->ActivateDedicatedEpsBearer (ueDevices.Get (u), bearer, tft);
--- a/src/mesh/model/dot11s/ie-dot11s-beacon-timing.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/mesh/model/dot11s/ie-dot11s-beacon-timing.cc	Wed May 22 17:58:58 2013 -0700
@@ -189,7 +189,7 @@
           && (a.GetBeaconInterval () == b.GetBeaconInterval ()));
 }
 bool
-IeBeaconTiming::operator== (WifiInformationElement const & a)
+IeBeaconTiming::operator== (WifiInformationElement const & a) const
 {
   try {
       IeBeaconTiming const & aa = dynamic_cast<IeBeaconTiming const &>(a);
--- a/src/mesh/model/dot11s/ie-dot11s-beacon-timing.h	Wed May 22 17:22:49 2013 -0700
+++ b/src/mesh/model/dot11s/ie-dot11s-beacon-timing.h	Wed May 22 17:58:58 2013 -0700
@@ -93,7 +93,7 @@
   virtual uint8_t DeserializeInformationField (Buffer::Iterator i, uint8_t length);
   virtual void Print (std::ostream& os) const;
   ///\}
-  bool operator== (WifiInformationElement const & a);
+  bool operator== (WifiInformationElement const & a) const;
 private:
   /**
    * Converters:
--- a/src/mesh/model/dot11s/peer-link.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/mesh/model/dot11s/peer-link.cc	Wed May 22 17:58:58 2013 -0700
@@ -578,6 +578,7 @@
         {
         case CLS_ACPT:
           ClearHoldingTimer ();
+          // fall through:
         case TOH:
           m_state = IDLE;
           m_linkStatusCallback (m_interface, m_peerAddress, m_peerMeshPointAddress, HOLDING, IDLE);
--- a/src/mobility/test/ns2-mobility-helper-test-suite.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/mobility/test/ns2-mobility-helper-test-suite.cc	Wed May 22 17:58:58 2013 -0700
@@ -49,6 +49,8 @@
 #include "ns3/config.h"
 #include "ns3/ns2-mobility-helper.h"
 
+NS_LOG_COMPONENT_DEFINE ("ns2-mobility-helper-test-suite");
+
 namespace ns3 {
 
 // -----------------------------------------------------------------------------
@@ -227,7 +229,10 @@
   void DoTeardown ()
   {
     Names::Clear ();
-    std::remove (m_traceFile.c_str ());
+    if (std::remove (m_traceFile.c_str ()))
+      {
+        NS_LOG_ERROR ("Failed to delete file " << m_traceFile);
+      }
     Simulator::Destroy ();
   }
 
--- a/src/network/model/address.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/network/model/address.cc	Wed May 22 17:58:58 2013 -0700
@@ -253,7 +253,7 @@
   NS_LOG_FUNCTION_NOARGS ();
   std::istringstream iss;
   iss.str (v);
-  uint32_t retval;
+  uint8_t retval;
   iss >> std::hex >> retval >> std::dec;
   return retval;
 }
--- a/src/network/test/pcap-file-test-suite.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/network/test/pcap-file-test-suite.cc	Wed May 22 17:58:58 2013 -0700
@@ -22,11 +22,14 @@
 #include <sstream>
 #include <cstring>
 
+#include "ns3/log.h"
 #include "ns3/test.h"
 #include "ns3/pcap-file.h"
 
 using namespace ns3;
 
+NS_LOG_COMPONENT_DEFINE ("pcap-file-test-suite");
+
 // ===========================================================================
 // Some utility functions for the tests.
 // ===========================================================================
@@ -113,7 +116,10 @@
 void
 WriteModeCreateTestCase::DoTeardown (void)
 {
-  remove (m_testFilename.c_str ());
+  if (remove (m_testFilename.c_str ()))
+    {
+      NS_LOG_ERROR ("Failed to delete file " << m_testFilename);
+    }
 }
 
 void
@@ -225,7 +231,10 @@
 void
 ReadModeCreateTestCase::DoTeardown (void)
 {
-  remove (m_testFilename.c_str ());
+  if (remove (m_testFilename.c_str ()))
+    {
+      NS_LOG_ERROR ("Failed to delete file " << m_testFilename);
+    }
 }
 
 void
@@ -331,7 +340,10 @@
 void
 AppendModeCreateTestCase::DoTeardown (void)
 {
-  remove (m_testFilename.c_str ());
+  if (remove (m_testFilename.c_str ()))
+    {
+      NS_LOG_ERROR ("Failed to delete file " << m_testFilename);
+    }
 }
 
 void
@@ -437,7 +449,10 @@
 void
 FileHeaderTestCase::DoTeardown (void)
 {
-  remove (m_testFilename.c_str ());
+  if (remove (m_testFilename.c_str ()))
+    {
+      NS_LOG_ERROR ("Failed to delete file " << m_testFilename);
+    }
 }
 
 void
@@ -674,7 +689,10 @@
 void
 RecordHeaderTestCase::DoTeardown (void)
 {
-  remove (m_testFilename.c_str ());
+  if (remove (m_testFilename.c_str ()))
+    {
+      NS_LOG_ERROR ("Failed to delete file " << m_testFilename);
+    }
 }
 
 void
@@ -876,7 +894,8 @@
   // starting there in the file.  We've tested this all before so we just assume
   // it's all right and just seek past it.
   //
-  std::fseek (p, 24, SEEK_SET);
+  result = std::fseek (p, 24, SEEK_SET);
+  NS_TEST_ASSERT_MSG_EQ (result, 0, "Failed seeking past pcap header");
 
   result = std::fread (&val32, sizeof(val32), 1, p);
   NS_TEST_ASSERT_MSG_EQ (result, 1, "Unable to fread() seconds timestamp");
--- a/src/network/utils/mac48-address.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/network/utils/mac48-address.cc	Wed May 22 17:58:58 2013 -0700
@@ -265,7 +265,7 @@
   NS_LOG_FUNCTION (v);
   std::istringstream iss;
   iss.str (v);
-  uint32_t retval;
+  uint8_t retval;
   iss >> std::hex >> retval >> std::dec;
   return retval;
 }
--- a/src/olsr/model/olsr-routing-protocol.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/olsr/model/olsr-routing-protocol.cc	Wed May 22 17:58:58 2013 -0700
@@ -2033,7 +2033,9 @@
         case OLSR_ASYM_LINK: linkTypeName = "ASYM_LINK"; break;
         case OLSR_SYM_LINK: linkTypeName = "SYM_LINK"; break;
         case OLSR_LOST_LINK: linkTypeName = "LOST_LINK"; break;
+          /*  no default, since lt must be in 0..3, covered above
         default: linkTypeName = "(invalid value!)";
+          */
         }
 
       const char *neighborTypeName;
@@ -2104,7 +2106,7 @@
     }
 
   // Schedules link tuple deletion
-  if (created && link_tuple != NULL)
+  if (created)
     {
       LinkTupleAdded (*link_tuple, hello.willingness);
       m_events.Track (Simulator::Schedule (DELAY (std::min (link_tuple->time, link_tuple->symTime)),
--- a/src/spectrum/test/spectrum-ideal-phy-test.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/spectrum/test/spectrum-ideal-phy-test.cc	Wed May 22 17:58:58 2013 -0700
@@ -202,7 +202,8 @@
     {
       NS_TEST_ASSERT_MSG_EQ (throughputBps, 0.0, "PHY rate is not achievable but throughput is non-zero");    
     }
-      
+
+  std::clog.unsetf(std::ios_base::floatfield);
   Simulator::Destroy ();
 }
 
--- a/src/stats/test/basic-data-calculators-test-suite.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/stats/test/basic-data-calculators-test-suite.cc	Wed May 22 17:58:58 2013 -0700
@@ -83,14 +83,7 @@
   min = multiple;
   max = multiple * count;
   mean = sum / count;
-  if (count == 1)
-    {
-      variance = 0;
-    }
-  else
-    {
-      variance = (count * sqrSum - sum * sum) / (count * (count - 1));
-    }
+  variance = 0;
   stddev = std::sqrt (variance);
 
   // Test the calculator.
@@ -161,14 +154,7 @@
   min = multiple;
   max = multiple * count;
   mean = sum / count;
-  if (count == 1)
-    {
-      variance = 0;
-    }
-  else
-    {
-      variance = (count * sqrSum - sum * sum) / (count * (count - 1));
-    }
+  variance = (count * sqrSum - sum * sum) / (count * (count - 1));
   stddev = std::sqrt (variance);
 
   // Test the calculator.
@@ -239,14 +225,7 @@
   min = multiple;
   max = multiple * count;
   mean = sum / count;
-  if (count == 1)
-    {
-      variance = 0;
-    }
-  else
-    {
-      variance = (count * sqrSum - sum * sum) / (count * (count - 1));
-    }
+  variance = (count * sqrSum - sum * sum) / (count * (count - 1));
   stddev = std::sqrt (variance);
 
   // Test the calculator.
--- a/src/tools/test/average-test-suite.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/tools/test/average-test-suite.cc	Wed May 22 17:58:58 2013 -0700
@@ -83,14 +83,7 @@
   min = multiple;
   max = multiple * count;
   mean = sum / count;
-  if (count == 1)
-    {
-      variance = 0;
-    }
-  else
-    {
-      variance = (count * sqrSum - sum * sum) / (count * (count - 1));
-    }
+  variance = 0;
   stddev = std::sqrt (variance);
 
   // Test the calculator.
@@ -159,14 +152,7 @@
   min = multiple;
   max = multiple * count;
   mean = sum / count;
-  if (count == 1)
-    {
-      variance = 0;
-    }
-  else
-    {
-      variance = (count * sqrSum - sum * sum) / (count * (count - 1));
-    }
+  variance = (count * sqrSum - sum * sum) / (count * (count - 1));
   stddev = std::sqrt (variance);
 
   // Test the calculator.
@@ -235,14 +221,7 @@
   min = multiple;
   max = multiple * count;
   mean = sum / count;
-  if (count == 1)
-    {
-      variance = 0;
-    }
-  else
-    {
-      variance = (count * sqrSum - sum * sum) / (count * (count - 1));
-    }
+  variance = (count * sqrSum - sum * sum) / (count * (count - 1));
   stddev = std::sqrt (variance);
 
   // Test the calculator.
--- a/src/topology-read/model/inet-topology-reader.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/topology-read/model/inet-topology-reader.cc	Wed May 22 17:58:58 2013 -0700
@@ -86,7 +86,7 @@
   lineBuffer >> totlink;
   NS_LOG_INFO ("Inet topology should have " << totnode << " nodes and " << totlink << " links");
 
-  for (int i = 0; i < totnode; i++)
+  for (int i = 0; i < totnode && !topgen.eof (); i++)
     {
       getline (topgen,line);
     }
--- a/src/uan/model/uan-mac-cw.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/uan/model/uan-mac-cw.cc	Wed May 22 17:58:58 2013 -0700
@@ -123,7 +123,7 @@
     {
     case CCABUSY:
       NS_LOG_DEBUG ("Time " << Simulator::Now ().GetSeconds () << " MAC " << GetAddress () << " Starting enqueue CCABUSY");
-      if (m_txEndEvent.IsRunning () == TX)
+      if (m_txEndEvent.IsRunning ())
         {
           NS_LOG_DEBUG ("State is TX");
         }
--- a/src/uan/model/uan-mac-rc-gw.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/uan/model/uan-mac-rc-gw.cc	Wed May 22 17:58:58 2013 -0700
@@ -32,6 +32,7 @@
 #include "ns3/double.h"
 #include "ns3/uinteger.h"
 
+#include <cfloat>
 #include <utility>
 #include <set>
 #include <map>
@@ -654,7 +655,8 @@
   double sum = 0;
   for (uint32_t i = 1; i <= n - k + 1; i++)
     {
-      double p = (double) NchooseK (n - i, k - 1) / NchooseK (n, k);
+      double nChK = NchooseK (n, k);
+      double p = (nChK > 0) ? (NchooseK (n - i, k - 1) / nChK) : DBL_MAX;
       sum += p * i;
     }
   return (uint32_t)(sum + 0.5);
--- a/src/uan/model/uan-prop-model.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/uan/model/uan-prop-model.cc	Wed May 22 17:58:58 2013 -0700
@@ -64,7 +64,7 @@
 
   std::complex<double> amp;
   pdp.m_taps = std::vector<Tap> (ntaps);
-  for (uint32_t i = 0; i < ntaps; i++)
+  for (uint32_t i = 0; i < ntaps && !is.eof (); i++)
     {
       is >> amp >> c1;
       if (c1 != '|')
--- a/src/uan/model/uan-tx-mode.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/uan/model/uan-tx-mode.cc	Wed May 22 17:58:58 2013 -0700
@@ -288,7 +288,7 @@
   ml.m_modes.clear ();
   ml.m_modes.resize (numModes);
 
-  for (int i = 0; i < numModes; i++)
+  for (int i = 0; i < numModes && !is.eof (); i++)
     {
       is >> ml.m_modes[i] >> c;
       if (c != '|')
--- a/src/wifi/examples/wifi-phy-test.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/wifi/examples/wifi-phy-test.cc	Wed May 22 17:58:58 2013 -0700
@@ -188,14 +188,16 @@
 CollisionExperiment::Receive (Ptr<Packet> p, double snr, WifiMode mode, enum WifiPreamble preamble)
 {
   FlowIdTag tag;
-  p->FindFirstMatchingByteTag (tag);
-  if (tag.GetFlowId () == m_flowIdA)
+  if (p->FindFirstMatchingByteTag (tag))
     {
-      m_output.receivedA++;
-    }
-  else if (tag.GetFlowId () == m_flowIdB)
-    {
-      m_output.receivedB++;
+      if (tag.GetFlowId () == m_flowIdA)
+        {
+          m_output.receivedA++;
+        }
+      else if (tag.GetFlowId () == m_flowIdB)
+        {
+          m_output.receivedB++;
+        }
     }
 }
 
--- a/src/wifi/model/ctrl-headers.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/wifi/model/ctrl-headers.cc	Wed May 22 17:58:58 2013 -0700
@@ -67,7 +67,7 @@
 CtrlBAckRequestHeader::Print (std::ostream &os) const
 {
   NS_LOG_FUNCTION (this << &os);
-  os << "TID_INFO=" << m_tidInfo << ", StartingSeq=" << std::hex << m_startingSeq;
+  os << "TID_INFO=" << m_tidInfo << ", StartingSeq=" << std::hex << m_startingSeq << std::dec;
 }
 
 uint32_t
--- a/src/wifi/model/mgt-headers.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/wifi/model/mgt-headers.cc	Wed May 22 17:58:58 2013 -0700
@@ -484,42 +484,46 @@
         {
         case BLOCK_ACK_ADDBA_REQUEST:
           retval.blockAck = BLOCK_ACK_ADDBA_REQUEST;
-          return retval;
+          break ;
         case BLOCK_ACK_ADDBA_RESPONSE:
           retval.blockAck = BLOCK_ACK_ADDBA_RESPONSE;
-          return retval;
+          break ;
         case BLOCK_ACK_DELBA:
           retval.blockAck = BLOCK_ACK_DELBA;
-          return retval;
+          break ;
         }
+      break ;
+      
     case MESH_PEERING_MGT:
       switch (m_actionValue)
         {
         case PEER_LINK_OPEN:
           retval.peerLink = PEER_LINK_OPEN;
-          return retval;
+          break ;
         case PEER_LINK_CONFIRM:
           retval.peerLink = PEER_LINK_CONFIRM;
-          return retval;
+          break ;
         case PEER_LINK_CLOSE:
           retval.peerLink = PEER_LINK_CLOSE;
-          return retval;
+          break ;
         default:
           NS_FATAL_ERROR ("Unknown mesh peering management action code");
           retval.peerLink = PEER_LINK_OPEN; /* quiet compiler */
-          return retval;
         }
+      break ;
+      
     case MESH_PATH_SELECTION:
       switch (m_actionValue)
         {
         case PATH_SELECTION:
           retval.pathSelection = PATH_SELECTION;
-          return retval;
+          break ;
         default:
           NS_FATAL_ERROR ("Unknown mesh path selection action code");
           retval.peerLink = PEER_LINK_OPEN; /* quiet compiler */
-          return retval;
         }
+      break ;
+      
     case MESH_LINK_METRIC:
     // not yet supported
     case MESH_INTERWORKING:
@@ -529,8 +533,8 @@
     default:
       NS_FATAL_ERROR ("Unsupported mesh action");
       retval.peerLink = PEER_LINK_OPEN; /* quiet compiler */
-      return retval;
     }
+  return retval;
 }
 TypeId
 WifiActionHeader::GetTypeId ()
--- a/src/wifi/model/regular-wifi-mac.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/wifi/model/regular-wifi-mac.cc	Wed May 22 17:58:58 2013 -0700
@@ -512,10 +512,13 @@
 
             default:
               NS_FATAL_ERROR ("Unsupported Action field in Block Ack Action frame");
+              return;
             }
 
+
         default:
           NS_FATAL_ERROR ("Unsupported Action frame received");
+          return;
         }
     }
   NS_FATAL_ERROR ("Don't know how to handle frame (type=" << hdr->GetType ());
--- a/src/wifi/model/wifi-information-element-vector.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/wifi/model/wifi-information-element-vector.cc	Wed May 22 17:58:58 2013 -0700
@@ -82,7 +82,9 @@
 {
   Buffer::Iterator i = start;
   uint8_t id = i.ReadU8 ();
-  uint8_t length = i.ReadU8 ();
+  //unused: uint8_t length = i.ReadU8 ();
+  //but need side effects of read:
+  i.ReadU8 ();  
   Ptr<WifiInformationElement> newElement;
   switch (id)
     {
@@ -90,6 +92,7 @@
       NS_FATAL_ERROR ("Information element " << (uint16_t) id << " is not implemented");
       return 0;
     }
+  /*  unreachable:  b/c switch is guaranteed to return from this function
   if (GetSize () + length > m_maxSize)
     {
       NS_FATAL_ERROR ("Check max size for information element!");
@@ -98,6 +101,7 @@
   i.Next (length);
   m_elements.push_back (newElement);
   return i.GetDistanceFrom (start);
+  */
 }
 void
 WifiInformationElementVector::Print (std::ostream & os) const
--- a/src/wifi/model/wifi-mac-header.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/wifi/model/wifi-mac-header.cc	Wed May 22 17:58:58 2013 -0700
@@ -221,12 +221,15 @@
     case WIFI_MAC_MGT_DEAUTHENTICATION:
       m_ctrlType = TYPE_MGT;
       m_ctrlSubtype = 12;
+      break;
     case WIFI_MAC_MGT_ACTION:
       m_ctrlType = TYPE_MGT;
       m_ctrlSubtype = 13;
+      break;
     case WIFI_MAC_MGT_ACTION_NO_ACK:
       m_ctrlType = TYPE_MGT;
       m_ctrlSubtype = 14;
+      break;
     case WIFI_MAC_MGT_MULTIHOP_ACTION:
       m_ctrlType = TYPE_MGT;
       m_ctrlSubtype = 15;
@@ -881,9 +884,11 @@
 const char *
 WifiMacHeader::GetTypeString (void) const
 {
+  std::string typeString;
+  
 #define FOO(x) \
 case WIFI_MAC_ ## x: \
-  return # x; \
+  typeString = # x; \
   break;
 
   switch (GetType ())
@@ -927,8 +932,7 @@
       return "ERROR";
     }
 #undef FOO
-  // needed to make gcc 4.0.1 ppc darwin happy.
-  return "BIG_ERROR";
+  return typeString.c_str ();
 }
 
 TypeId
@@ -998,10 +1002,12 @@
       os << " Duration/ID=" << m_duration << "us"
          << "DA=" << m_addr1 << ", SA=" << m_addr2 << ", BSSID=" << m_addr3
          << ", FragNumber=" << std::hex << (int) m_seqFrag << std::dec << ", SeqNumber=" << m_seqSeq;
+      break;
     case WIFI_MAC_MGT_MULTIHOP_ACTION:
       os << " Duration/ID=" << m_duration << "us"
          << "RA=" << m_addr1 << ", TA=" << m_addr2 << ", DA=" << m_addr3
          << ", FragNumber=" << std::hex << (int) m_seqFrag << std::dec << ", SeqNumber=" << m_seqSeq;
+      break;
     case WIFI_MAC_DATA:
       PrintFrameControl (os);
       os << " Duration/ID=" << m_duration << "us";
--- a/src/wimax/model/bs-scheduler-simple.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/wimax/model/bs-scheduler-simple.cc	Wed May 22 17:58:58 2013 -0700
@@ -297,7 +297,7 @@
       serviceFlows = GetBs ()->GetServiceFlowManager ()->GetServiceFlows (ServiceFlow::SF_TYPE_NRTPS);
       for (iter2 = serviceFlows.begin (); iter2 != serviceFlows.end (); ++iter2)
         {
-          serviceFlowRecord = (*iter2)->GetRecord ();
+          //unused: serviceFlowRecord = (*iter2)->GetRecord ();
           if ((*iter2)->HasPackets ())
             {
               NS_LOG_INFO ("Return NRTPS SF: CID = " << (*iter2)->GetCid () << "SFID = " << (*iter2)->GetSfid ());
@@ -309,7 +309,7 @@
       serviceFlows = GetBs ()->GetServiceFlowManager ()->GetServiceFlows (ServiceFlow::SF_TYPE_BE);
       for (iter2 = serviceFlows.begin (); iter2 != serviceFlows.end (); ++iter2)
         {
-          serviceFlowRecord = (*iter2)->GetRecord ();
+          //unused: serviceFlowRecord = (*iter2)->GetRecord ();
           if ((*iter2)->HasPackets ())
             {
               NS_LOG_INFO ("Return BE SF: CID = " << (*iter2)->GetCid () << "SFID = " << (*iter2)->GetSfid ());
--- a/src/wimax/model/simple-ofdm-wimax-phy.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/wimax/model/simple-ofdm-wimax-phy.cc	Wed May 22 17:58:58 2013 -0700
@@ -241,6 +241,7 @@
 SimpleOfdmWimaxPhy::Send (SendParams *params)
 {
   OfdmSendParams *o_params = dynamic_cast<OfdmSendParams*> (params);
+  NS_ASSERT (o_params !=0);
   Send (o_params->GetBurst (),
         (WimaxPhy::ModulationType) o_params->GetModulationType (),
         o_params->GetDirection ());
@@ -284,6 +285,7 @@
     }
 
   SimpleOfdmWimaxChannel *channel = dynamic_cast<SimpleOfdmWimaxChannel*> (PeekPointer (GetChannel ()));
+  NS_ASSERT (channel != 0);
 
   if (m_nrRemainingBlocksToSend==1)
     {
@@ -585,7 +587,7 @@
 SimpleOfdmWimaxPhy::RecreateBuffer ()
 {
 
-  bvec buffer (m_blockSize * m_nrBlocks);
+  bvec buffer (m_blockSize * (unsigned long)m_nrBlocks);
   bvec block (m_blockSize);
   uint32_t i = 0;
   for (uint32_t j = 0; j < m_nrBlocks; j++)
@@ -820,51 +822,51 @@
 {
   uint16_t duration = 0;
   duration = (uint16_t)(GetFrameDuration ().GetSeconds () * 10000);
+  uint8_t retval = 0;
   switch (duration)
     {
     case 25:
       {
-        return FRAME_DURATION_2_POINT_5_MS;
+        retval = FRAME_DURATION_2_POINT_5_MS;
         break;
       }
     case 40:
       {
-        return FRAME_DURATION_4_MS;
+        retval = FRAME_DURATION_4_MS;
         break;
       }
     case 50:
       {
-        return FRAME_DURATION_5_MS;
+        retval = FRAME_DURATION_5_MS;
         break;
       }
     case 80:
       {
-        return FRAME_DURATION_8_MS;
+        retval = FRAME_DURATION_8_MS;
         break;
       }
     case 100:
       {
-        return FRAME_DURATION_10_MS;
+        retval = FRAME_DURATION_10_MS;
         break;
       }
     case 125:
       {
-        return FRAME_DURATION_12_POINT_5_MS;
+        retval = FRAME_DURATION_12_POINT_5_MS;
         break;
       }
     case 200:
       {
-        return FRAME_DURATION_20_MS;
+        retval = FRAME_DURATION_20_MS;
         break;
       }
     default:
       {
         NS_FATAL_ERROR ("Invalid frame duration = " << duration);
-        return 0;
+        retval = 0;
       }
     }
-  NS_FATAL_ERROR ("Invalid frame duration = " << duration);
-  return 0;
+  return retval;
 }
 
 Time
--- a/src/wimax/model/snr-to-block-error-rate-manager.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/wimax/model/snr-to-block-error-rate-manager.cc	Wed May 22 17:58:58 2013 -0700
@@ -24,6 +24,7 @@
 #include "ns3/snr-to-block-error-rate-record.h"
 #include "default-traces.h"
 #include "ns3/log.h"
+#include "ns3/assert.h"
 #include <fstream>
 
 NS_LOG_COMPONENT_DEFINE ("SNRToBlockErrorRateManager");
@@ -273,6 +274,8 @@
 void
 SNRToBlockErrorRateManager::SetTraceFilePath (char *traceFilePath)
 {
+  NS_ASSERT_MSG (std::strlen (traceFilePath) < TRACE_FILE_PATH_SIZE,
+                 "char * traceFilePath too long");
   std::strcpy (m_traceFilePath, traceFilePath);
 }
 
--- a/src/wimax/model/snr-to-block-error-rate-manager.h	Wed May 22 17:22:49 2013 -0700
+++ b/src/wimax/model/snr-to-block-error-rate-manager.h	Wed May 22 17:58:58 2013 -0700
@@ -94,7 +94,8 @@
   void ClearRecords (void);
   double m_speed; // in m/s
   uint8_t m_activateLoss;
-  char m_traceFilePath[1024];
+  static const unsigned int TRACE_FILE_PATH_SIZE = 1024;
+  char m_traceFilePath[TRACE_FILE_PATH_SIZE];
 
   std::vector<SNRToBlockErrorRateRecord *> * m_recordModulation[7];
 
--- a/src/wimax/model/wimax-tlv.cc	Wed May 22 17:22:49 2013 -0700
+++ b/src/wimax/model/wimax-tlv.cc	Wed May 22 17:58:58 2013 -0700
@@ -940,9 +940,9 @@
 }
 ProtocolTlvValue::~ProtocolTlvValue ()
 {
-  m_protocol->clear ();
   if (m_protocol != 0)
     {
+      m_protocol->clear ();
       delete m_protocol;
       m_protocol = 0;
     }
@@ -1013,9 +1013,9 @@
 
 Ipv4AddressTlvValue::~Ipv4AddressTlvValue ()
 {
-  m_ipv4Addr->clear ();
   if (m_ipv4Addr != 0)
     {
+      m_ipv4Addr->clear ();
       delete m_ipv4Addr;
       m_ipv4Addr = 0;
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/utils/coverity-report.sh	Wed May 22 17:58:58 2013 -0700
@@ -0,0 +1,84 @@
+#!/bin/bash
+
+
+# Copyright (c) 2013 Lawrence Livermore National Laboratory
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation;
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+# Author: Peter D. Barnes, Jr. <pdbarnes@llnl.gov>
+
+#
+#  Do a coverity build and submit report
+#
+
+me=`basename $0`
+
+# echo commands and output to a log file
+
+logf=coverity/coverity-build.log
+echo | tee $logf
+
+function say ()
+{
+    echo "$me:" $* | tee -a $logf
+}
+blank ()
+{
+    echo | tee -a $logf
+}
+function doo ()
+{
+    say "$"$*
+    $* 2>&1 | tee -a $logf
+}
+
+
+
+
+say $(date)
+blank
+
+doo ./waf clean
+blank
+
+doo ./waf configure $NS3CONFIG
+blank
+
+cov=coverity/cov-int
+doo cov-build --dir $cov ./waf build
+blank
+
+tarf=coverity/ns-3.tgz
+doo tar cvzf $tarf -C coverity cov-int
+blank
+
+useremail=$(hg showconfig ui.username | \
+    egrep -o "\b[a-zA-Z0-9.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9.-]+\b")
+
+repoversion="$(basename $(dirname $PWD))@$(hg id -i)"
+
+description="Coverity mods"
+    
+doo curl \
+     --form file=@$tarf \
+     --form project=ns-3 \
+     --form password=4jk2BVX9 \
+     --form email="$useremail" \
+     --form version="$repoversion" \
+     --form description="$description" \
+     http://scan5.coverity.com/cgi-bin/upload.py
+blank
+
+say $(date)
+blank