From 80b15ea83f808ccbbfc6ad13d9ec7caec096baef Mon Sep 17 00:00:00 2001 From: "Peter D. Barnes, Jr." Date: Wed, 15 May 2013 16:26:46 -0400 Subject: [PATCH] [Coverity] Unchecked return value (CHECKED_RETURN) --- src/core/model/system-path.cc | 10 +++++-- src/dsr/model/dsr-routing.cc | 5 +++- .../test/ns2-mobility-helper-test-suite.cc | 7 ++++- src/network/test/pcap-file-test-suite.cc | 28 +++++++++++++++---- src/wifi/examples/wifi-phy-test.cc | 16 ++++++----- 5 files changed, 50 insertions(+), 16 deletions(-) diff --git a/src/core/model/system-path.cc b/src/core/model/system-path.cc index 642d88a5d..26571ed78 100644 --- a/src/core/model/system-path.cc +++ b/src/core/model/system-path.cc @@ -308,11 +308,17 @@ MakeDirectories (std::string path) { 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 } diff --git a/src/dsr/model/dsr-routing.cc b/src/dsr/model/dsr-routing.cc index 8cc73ba96..9571733c8 100644 --- a/src/dsr/model/dsr-routing.cc +++ b/src/dsr/model/dsr-routing.cc @@ -2206,7 +2206,10 @@ DsrRouting::ScheduleNetworkPacketRetry (MaintainBuffEntry & mb, 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 ()) { diff --git a/src/mobility/test/ns2-mobility-helper-test-suite.cc b/src/mobility/test/ns2-mobility-helper-test-suite.cc index 407e76ee6..a6937acb3 100644 --- a/src/mobility/test/ns2-mobility-helper-test-suite.cc +++ b/src/mobility/test/ns2-mobility-helper-test-suite.cc @@ -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 @@ private: 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 (); } diff --git a/src/network/test/pcap-file-test-suite.cc b/src/network/test/pcap-file-test-suite.cc index 91eea2fff..dffe7639a 100644 --- a/src/network/test/pcap-file-test-suite.cc +++ b/src/network/test/pcap-file-test-suite.cc @@ -22,11 +22,14 @@ #include #include +#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 @@ WriteModeCreateTestCase::DoSetup (void) 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 @@ ReadModeCreateTestCase::DoSetup (void) 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 @@ AppendModeCreateTestCase::DoSetup (void) 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 @@ FileHeaderTestCase::DoSetup (void) 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 @@ RecordHeaderTestCase::DoSetup (void) 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 diff --git a/src/wifi/examples/wifi-phy-test.cc b/src/wifi/examples/wifi-phy-test.cc index 28ac94b15..16e332116 100644 --- a/src/wifi/examples/wifi-phy-test.cc +++ b/src/wifi/examples/wifi-phy-test.cc @@ -187,14 +187,16 @@ void CollisionExperiment::Receive (Ptr 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++; + } } }