[vlc-devel] [PATCH v2 8/13] platform: use new vlc_MakeTmpFile() helper

Lyndon Brown jnqnfe at gmail.com
Tue Oct 6 07:59:58 CEST 2020


From: Lyndon Brown <jnqnfe at gmail.com>
Date: Tue, 6 Oct 2020 01:16:50 +0100
Subject: platform: use new vlc_MakeTmpFile() helper


diff --git a/src/linux/filesystem.c b/src/linux/filesystem.c
index efdff12580..c2ec9c3a5a 100644
--- a/src/linux/filesystem.c
+++ b/src/linux/filesystem.c
@@ -59,13 +59,8 @@ int vlc_memfd(void)
      * EISDIR, or EOPNOTSUPP, cf. man open(2). */
     const char *filetemplate = PACKAGE_NAME"XXXXXX";
     char *bufpath;
-    if (asprintf(&bufpath, "%s/%s", tempdir, filetemplate) == -1) {
-        free(tempdir);
-        return -1;
-    }
-    free(tempdir);
+    fd = vlc_MakeTmpFile(&bufpath, filetemplate);
 
-    fd = vlc_mkstemp(bufpath);
     if (fd != -1)
         unlink(bufpath);
     free(bufpath);
diff --git a/src/posix/filesystem.c b/src/posix/filesystem.c
index 1cf5df224d..01d4aa1ab0 100644
--- a/src/posix/filesystem.c
+++ b/src/posix/filesystem.c
@@ -44,7 +44,6 @@
 
 #include <vlc_common.h>
 #include <vlc_fs.h>
-#include <vlc_configuration.h>
 
 #if !defined(HAVE_ACCEPT4)
 static inline void vlc_cloexec(int fd)
@@ -91,19 +90,10 @@ int vlc_mkstemp (char *template)
 
 VLC_WEAK int vlc_memfd(void)
 {
-    char *tempdir = config_GetTempPath();
-    if (tempdir == NULL)
-        return -1;
-
     const char *filetemplate = PACKAGE_NAME"XXXXXX";
     char *bufpath;
-    if (asprintf(&bufpath, "%s/%s", tempdir, filetemplate) == -1) {
-        free(tempdir);
-        return -1;
-    }
-    free(tempdir);
+    int fd = vlc_MakeTmpFile(&bufpath, filetemplate);
 
-    int fd = vlc_mkstemp(bufpath);
     if (fd != -1)
         unlink (bufpath);
     free(bufpath);



More information about the vlc-devel mailing list