Parcourir la source

[master] Merged trac3932 (check remove() return)

Francis Dupont il y a 9 ans
Parent
commit
caed0f6dca

+ 2 - 2
src/bin/dhcp4/tests/config_parser_unittest.cc

@@ -123,8 +123,8 @@ public:
         resetConfiguration();
 
         // ... and delete the hooks library marker files if present
-        remove(LOAD_MARKER_FILE);
-        remove(UNLOAD_MARKER_FILE);
+        static_cast<void>(remove(LOAD_MARKER_FILE));
+        static_cast<void>(remove(UNLOAD_MARKER_FILE));
     };
 
     /// @brief Returns an interface configuration used by the most of the

+ 2 - 2
src/bin/dhcp6/tests/config_parser_unittest.cc

@@ -115,8 +115,8 @@ public:
         resetConfiguration();
 
         // ... and delete the hooks library marker files if present
-        remove(LOAD_MARKER_FILE);
-        remove(UNLOAD_MARKER_FILE);
+        static_cast<void>(remove(LOAD_MARKER_FILE));
+        static_cast<void>(remove(UNLOAD_MARKER_FILE));
     };
 
     // Checks if config_result (result of DHCP server configuration) has

+ 2 - 2
src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc

@@ -247,7 +247,7 @@ public:
     };
 
     void createUnixChannelServer() {
-        ::remove(socket_path_.c_str());
+        static_cast<void>(::remove(socket_path_.c_str()));
 
         // Just a simple config. The important part here is the socket
         // location information.
@@ -292,7 +292,7 @@ public:
     /// @brief Reset
     void reset() {
         CtrlDhcpv6SrvTest::reset();
-        ::remove(socket_path_.c_str());
+        static_cast<void>(::remove(socket_path_.c_str()));
     }
 
     /// @brief Conducts a command/response exchange via UnixCommandSocket

+ 2 - 2
src/bin/dhcp6/tests/dhcp6_test_utils.cc

@@ -834,7 +834,7 @@ Dhcpv6SrvTest::configure(const std::string& config, NakedDhcpv6Srv& srv) {
 NakedDhcpv6SrvTest::NakedDhcpv6SrvTest()
 : rcode_(-1) {
     // it's ok if that fails. There should not be such a file anyway
-    remove(DUID_FILE);
+    static_cast<void>(remove(DUID_FILE));
 
     const isc::dhcp::IfaceMgr::IfaceCollection& ifaces =
         isc::dhcp::IfaceMgr::instance().getIfaces();
@@ -856,7 +856,7 @@ NakedDhcpv6SrvTest::~NakedDhcpv6SrvTest() {
     isc::stats::StatsMgr::instance().removeAll();
 
     // Let's clean up if there is such a file.
-    remove(DUID_FILE);
+    static_cast<void>(remove(DUID_FILE));
     isc::hooks::HooksManager::preCalloutsLibraryHandle()
         .deregisterAllCallouts("buffer6_receive");
     isc::hooks::HooksManager::preCalloutsLibraryHandle()

+ 1 - 1
src/lib/cc/tests/data_file_unittests.cc

@@ -35,7 +35,7 @@ public:
     /// @param content text to be written to disk
     void writeFile(const std::string& content) {
         // Write sample content to disk
-        remove(TEMP_FILE);
+        static_cast<void>(remove(TEMP_FILE));
         std::ofstream write_me(TEMP_FILE);
         EXPECT_TRUE(write_me.is_open());
         write_me << content;

+ 4 - 4
src/lib/config/command_socket_factory.cc

@@ -83,7 +83,7 @@ private:
         // Let's remove the old file. We don't care about any possible
         // errors here. The file should not be there if the file was
         // shut down properly.
-        remove(file_name.c_str());
+        static_cast<void>(remove(file_name.c_str()));
 
         // Set this socket to be non-blocking one.
         if (fcntl(fd, F_SETFL, O_NONBLOCK) !=0 ) {
@@ -100,7 +100,7 @@ private:
         if (bind(fd, (struct sockaddr*)&addr, sizeof(addr))) {
             const char* errmsg = strerror(errno);
             ::close(fd);
-            remove(file_name.c_str());
+            static_cast<void>(remove(file_name.c_str()));
             isc_throw(isc::config::SocketError, "Failed to bind socket " << fd
                       << " to " << file_name << ": " << errmsg);
         }
@@ -114,7 +114,7 @@ private:
         if (status < 0) {
             const char* errmsg = strerror(errno);
             ::close(fd);
-            remove(file_name.c_str());
+            static_cast<void>(remove(file_name.c_str()));
             isc_throw(isc::config::SocketError, "Failed to listen on socket fd="
                       << fd << ", filename=" << file_name << ": " << errmsg);
         }
@@ -181,7 +181,7 @@ private:
         // Close should always succeed. We don't care if we're able to delete
         // the socket or not.
         ::close(sockfd_);
-        remove(filename_.c_str());
+        static_cast<void>(remove(filename_.c_str()));
     }
 
     /// @brief UNIX filename representing this socket

+ 2 - 2
src/lib/config/tests/command_socket_factory_unittests.cc

@@ -33,14 +33,14 @@ public:
         :SOCKET_NAME(getSocketPath()) {
 
         // Remove any stale socket files
-        remove(SOCKET_NAME.c_str());
+        static_cast<void>(remove(SOCKET_NAME.c_str()));
     }
 
     /// Default destructor
     ~CommandSocketFactoryTest() {
 
         // Remove any stale socket files
-        remove(SOCKET_NAME.c_str());
+        static_cast<void>(remove(SOCKET_NAME.c_str()));
     }
 
     /// @brief Returns socket path (using either hardcoded path or env variable)

+ 1 - 1
src/lib/dhcp/tests/iface_mgr_unittest.cc

@@ -478,7 +478,7 @@ TEST_F(IfaceMgrTest, dhcp6Sniffer) {
     // Testing socket operation in a portable way is tricky
     // without interface detection implemented
 
-    remove("interfaces.txt");
+    static_cast<void>(remove("interfaces.txt"));
 
     ofstream interfaces("interfaces.txt", ios::ate);
     interfaces << "eth0 fe80::21e:8cff:fe9b:7349";

+ 1 - 1
src/lib/dhcpsrv/tests/lease_file_io.cc

@@ -55,7 +55,7 @@ LeaseFileIO::readFile() const {
 
 void
 LeaseFileIO::removeFile() const {
-    remove(testfile_.c_str());
+    static_cast<void>(remove(testfile_.c_str()));
 }
 
 void

+ 2 - 2
src/lib/log/tests/logger_manager_unittest.cc

@@ -195,7 +195,7 @@ TEST_F(LoggerManagerTest, FileLogger) {
     // For the first test, we want to check that the file is created
     // if it does not already exist.  So delete the temporary file before
     // logging the first message.
-    remove(file_spec.getFileName().c_str());
+    static_cast<void>(remove(file_spec.getFileName().c_str()));
 
     // Set up the file appenders.
     LoggerManager manager;
@@ -368,7 +368,7 @@ TEST_F(LoggerManagerTest, checkLayoutPattern) {
     // For the first test, we want to check that the file is created
     // if it does not already exist.  So delete the temporary file before
     // logging the first message.
-    remove(file_spec.getFileName().c_str());
+    static_cast<void>(remove(file_spec.getFileName().c_str()));
 
     // Set up the file appenders.
     LoggerManager manager;

+ 6 - 6
src/lib/util/tests/csv_file_unittest.cc

@@ -148,7 +148,7 @@ public:
     std::string readFile() const;
 
     /// @brief Removes existing file (if any).
-    void removeFile() const;
+    int removeFile() const;
 
     /// @brief Creates file with contents.
     ///
@@ -162,11 +162,11 @@ public:
 
 CSVFileTest::CSVFileTest()
     : testfile_(absolutePath("test.csv")) {
-    removeFile();
+    static_cast<void>(removeFile());
 }
 
 CSVFileTest::~CSVFileTest() {
-    removeFile();
+    static_cast<void>(removeFile());
 }
 
 std::string
@@ -196,9 +196,9 @@ CSVFileTest::readFile() const {
     return (contents);
 }
 
-void
+int
 CSVFileTest::removeFile() const {
-    remove(testfile_.c_str());
+    return (remove(testfile_.c_str()));
 }
 
 void
@@ -496,7 +496,7 @@ TEST_F(CSVFileTest, exists) {
 
     // Close the file and remove it.
     csv->close();
-    removeFile();
+    EXPECT_EQ(0, removeFile());
 
     // The file should not exist.
     EXPECT_FALSE(csv->exists());

+ 1 - 1
src/lib/util/tests/pid_file_unittest.cc

@@ -64,7 +64,7 @@ protected:
 private:
     /// @brief Removes any remaining test files
     void removeTestFile() const {
-        remove(absolutePath(TESTNAME).c_str());
+        static_cast<void>(remove(absolutePath(TESTNAME).c_str()));
     }
 
 };

+ 2 - 2
src/lib/util/tests/socketsession_unittest.cc

@@ -176,7 +176,7 @@ protected:
     {
         std::string unix_file = getSocketPath();
 
-        remove(unix_file.c_str());
+        static_cast<void>(remove(unix_file.c_str()));
         test_un_.sun_family = AF_UNIX;
         strncpy(test_un_.sun_path, unix_file.c_str(), sizeof(test_un_.sun_path));
 #ifdef HAVE_SA_LEN
@@ -188,7 +188,7 @@ protected:
         if (listen_fd_ != -1) {
             close(listen_fd_);
         }
-        remove(getSocketPath().c_str());
+        static_cast<void>(remove(getSocketPath().c_str()));
     }
 
     // Start an internal "socket session server".