From: Waldemar Kozaczuk <jwkozac...@gmail.com>
Committer: Nadav Har'El <n...@scylladb.com>
Branch: master

tests: replace tmpnam() with mkdtemp() in implementation of TempDir

This should be the last patch addressing compiler warnings
in unit tests as reported by the issue #976.

Refs #976

Signed-off-by: Waldemar Kozaczuk <jwkozac...@gmail.com>
Message-Id: <20191209042729.21316-1-jwkozac...@gmail.com>

---
diff --git a/tests/tst-fs.hh b/tests/tst-fs.hh
--- a/tests/tst-fs.hh
+++ b/tests/tst-fs.hh
@@ -11,6 +11,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
+#include <stdlib.h>
 #include <boost/filesystem.hpp>
 #include <boost/test/unit_test.hpp>
 #include <boost/filesystem/fstream.hpp>
@@ -22,8 +23,13 @@ typedef boost::format fmt;
 class TempDir : public fs::path
 {
 public:
-       TempDir() : fs::path(tmpnam(NULL)) {
-               fs::create_directories(*this);
+       TempDir() : fs::path() {
+           char path[64] = "/tmp/dirXXXXXX";
+           auto dir_path = mkdtemp(path);
+           if (!dir_path) {
+ throw std::system_error(std::error_code(errno, std::system_category()), "error creating temp directory");
+           }
+           *this += dir_path;
        }

        virtual ~TempDir() {

--
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/000000000000a14a620599426ebe%40google.com.

Reply via email to