]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2025] fix Wunused-result warnings
authorAndrei Pavel <andrei@isc.org>
Thu, 12 Aug 2021 10:21:44 +0000 (13:21 +0300)
committerAndrei Pavel <andrei@isc.org>
Tue, 17 Aug 2021 06:31:05 +0000 (09:31 +0300)
src/lib/yang/tests/sysrepo_setup.h

index 1d40a77db175aa8dcee701fbc78a587760ca8583..9be43688249b80c081d4a22f64bc0455d6580d40 100644 (file)
@@ -29,8 +29,22 @@ struct SysrepoSetup {
     /// is the equivalent of running "make shm_clean" in sysrepo:
     /// https://github.com/sysrepo/sysrepo/blob/v1.4.140/CMakeLists.txt#L329-L334
     static void cleanSharedMemory() {
-        system("rm -rf /dev/shm/sr_*");
-        system("rm -rf /dev/shm/srsub_*");
+        call_system("rm -rf /dev/shm/sr_*");
+        call_system("rm -rf /dev/shm/srsub_*");
+    }
+
+private:
+    /// @brief Wrapper over a system() call that also checks the return value.
+    ///
+    /// @brief command the command to be run
+    static void call_system(char const* command) {
+        int return_value(system(command));
+        if (return_value != 0) {
+            std::cerr << "\"" << command << "\" exited with " << return_value
+                      << ". Unit tests may be influenced by previous abnormaly "
+                         "terminated unit tests or sysrepo uses."
+                      << std::endl;
+        }
     }
 };