[Coverity] Unchecked return value (CHECKED_RETURN)
authorPeter D. Barnes, Jr. <barnes26@llnl.gov>
Wed, 15 May 2013 16:26:46 -0400
changeset 9785 97052ab05772
parent 9784 740a983ed25b
child 9786 9f260d8a2508
[Coverity] Unchecked return value (CHECKED_RETURN)
src/core/model/system-path.cc
src/dsr/model/dsr-routing.cc
src/mobility/test/ns2-mobility-helper-test-suite.cc
src/network/test/pcap-file-test-suite.cc
src/wifi/examples/wifi-phy-test.cc
--- a/src/core/model/system-path.cc	Wed May 15 15:47:58 2013 -0400
+++ b/src/core/model/system-path.cc	Wed May 15 16:26:46 2013 -0400
@@ -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/dsr/model/dsr-routing.cc	Wed May 15 15:47:58 2013 -0400
+++ b/src/dsr/model/dsr-routing.cc	Wed May 15 16:26:46 2013 -0400
@@ -2206,7 +2206,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/mobility/test/ns2-mobility-helper-test-suite.cc	Wed May 15 15:47:58 2013 -0400
+++ b/src/mobility/test/ns2-mobility-helper-test-suite.cc	Wed May 15 16:26:46 2013 -0400
@@ -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/test/pcap-file-test-suite.cc	Wed May 15 15:47:58 2013 -0400
+++ b/src/network/test/pcap-file-test-suite.cc	Wed May 15 16:26:46 2013 -0400
@@ -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
--- a/src/wifi/examples/wifi-phy-test.cc	Wed May 15 15:47:58 2013 -0400
+++ b/src/wifi/examples/wifi-phy-test.cc	Wed May 15 16:26:46 2013 -0400
@@ -187,14 +187,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++;
+        }
     }
 }