mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-09-27 06:20:12 +00:00
check: Use mkstemp instead of tempnam if possible
Using tempnam() is deprecated, this gives warning and fails the build with -Werror. https://bugzilla.gnome.org/show_bug.cgi?id=745858
This commit is contained in:
parent
4b174b14f5
commit
a7797d30a8
2 changed files with 20 additions and 1 deletions
|
@ -216,10 +216,11 @@ teardown_messaging (void)
|
||||||
FILE *
|
FILE *
|
||||||
open_tmp_file (char **name)
|
open_tmp_file (char **name)
|
||||||
{
|
{
|
||||||
FILE *file;
|
FILE *file = NULL;
|
||||||
|
|
||||||
*name = NULL;
|
*name = NULL;
|
||||||
|
|
||||||
|
#if !HAVE_MKSTEMP
|
||||||
/* Windows does not like tmpfile(). This is likely because tmpfile()
|
/* Windows does not like tmpfile(). This is likely because tmpfile()
|
||||||
* call unlink() on the file before returning it, to make sure the
|
* call unlink() on the file before returning it, to make sure the
|
||||||
* file is deleted when it is closed. The unlink() call also fails
|
* file is deleted when it is closed. The unlink() call also fails
|
||||||
|
@ -250,6 +251,21 @@ open_tmp_file (char **name)
|
||||||
*name = uniq_tmp_file;
|
*name = uniq_tmp_file;
|
||||||
free (tmp_file);
|
free (tmp_file);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
int fd = -1;
|
||||||
|
const char *tmp_dir = getenv ("TEMP");
|
||||||
|
if (!tmp_dir) {
|
||||||
|
tmp_dir = ".";
|
||||||
|
}
|
||||||
|
*name = ck_strdup_printf ("%s/check_XXXXXX", tmp_dir);
|
||||||
|
if (-1 < (fd = mkstemp (*name))) {
|
||||||
|
file = fdopen (fd, "w+b");
|
||||||
|
if (0 == unlink (*name) || NULL == file) {
|
||||||
|
free (*name);
|
||||||
|
*name = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,9 @@ dnl Check for strdup() and _strdup()
|
||||||
AC_CHECK_DECLS([strdup])
|
AC_CHECK_DECLS([strdup])
|
||||||
AC_CHECK_FUNCS([_strdup])
|
AC_CHECK_FUNCS([_strdup])
|
||||||
|
|
||||||
|
dnl Check for mkstemp
|
||||||
|
AC_CHECK_FUNCS([mkstemp])
|
||||||
|
|
||||||
dnl Check for fork
|
dnl Check for fork
|
||||||
AC_CHECK_FUNCS([fork], HAVE_FORK=1, HAVE_FORK=0)
|
AC_CHECK_FUNCS([fork], HAVE_FORK=1, HAVE_FORK=0)
|
||||||
AC_SUBST(HAVE_FORK)
|
AC_SUBST(HAVE_FORK)
|
||||||
|
|
Loading…
Reference in a new issue