Commit b933c14a9297ca616305098ee81ea5ffd392384d

Edward Thomson 2022-02-08T12:22:15

util: remove `p_mktemp` / `p_mkstemp` We have our own temporary file creation function now in `git_futils_mktmp`, remove the others since they may be terrible on some platforms.

diff --git a/src/posix.h b/src/posix.h
index 1757764..e6f6030 100644
--- a/src/posix.h
+++ b/src/posix.h
@@ -131,7 +131,6 @@ extern ssize_t p_pwrite(int fd, const void *data, size_t size, off64_t offset);
 
 #define p_close(fd) close(fd)
 #define p_umask(m) umask(m)
-#define p_mktemp(p) mktemp(p)
 
 extern int p_open(const char *path, int flags, ...);
 extern int p_creat(const char *path, mode_t mode);
diff --git a/src/unix/posix.h b/src/unix/posix.h
index 27a8fec..49065e5 100644
--- a/src/unix/posix.h
+++ b/src/unix/posix.h
@@ -58,7 +58,6 @@ GIT_INLINE(int) p_fsync(int fd)
 #define p_strncasecmp(s1, s2, c) strncasecmp(s1, s2, c)
 #define p_vsnprintf(b, c, f, a) vsnprintf(b, c, f, a)
 #define p_snprintf snprintf
-#define p_mkstemp(p) mkstemp(p)
 #define p_chdir(p) chdir(p)
 #define p_rmdir(p) rmdir(p)
 #define p_access(p,m) access(p,m)
diff --git a/src/win32/posix.h b/src/win32/posix.h
index 87c6b43..578347f 100644
--- a/src/win32/posix.h
+++ b/src/win32/posix.h
@@ -42,7 +42,6 @@ extern int p_inet_pton(int af, const char *src, void* dst);
 
 extern int p_vsnprintf(char *buffer, size_t count, const char *format, va_list argptr);
 extern int p_snprintf(char *buffer, size_t count, const char *format, ...) GIT_FORMAT_PRINTF(3, 4);
-extern int p_mkstemp(char *tmp_path);
 extern int p_chdir(const char *path);
 extern int p_chmod(const char *path, mode_t mode);
 extern int p_rmdir(const char *path);
diff --git a/src/win32/posix_w32.c b/src/win32/posix_w32.c
index b607241..5f7cd0c 100644
--- a/src/win32/posix_w32.c
+++ b/src/win32/posix_w32.c
@@ -860,20 +860,6 @@ int p_snprintf(char *buffer, size_t count, const char *format, ...)
 	return r;
 }
 
-/* TODO: wut? */
-int p_mkstemp(char *tmp_path)
-{
-#if defined(_MSC_VER) && _MSC_VER >= 1500
-	if (_mktemp_s(tmp_path, strlen(tmp_path) + 1) != 0)
-		return -1;
-#else
-	if (_mktemp(tmp_path) == NULL)
-		return -1;
-#endif
-
-	return p_open(tmp_path, O_RDWR | O_CREAT | O_EXCL, 0744); /* -V536 */
-}
-
 int p_access(const char *path, mode_t mode)
 {
 	git_win32_path buf;