git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] wrapper: simplify xmkstemp()

From
René Scharfe <l.s.r@web.de>
Date
Nov 17, 2025, 19:42 UTC
Message-ID
<058c5722-30f5-4bc5-90f5-24e4c6f3ff8f@web.de>

Call xmkstemp_mode() instead of duplicating its error handling code. This switches the implementation from the system's mkstemp(3) to our own git_mkstemp_mode(), which works just as well.

Signed-off-by: René Scharfe <l.s.r@web.de>
---
 wrapper.c | 19 +------------------
 1 file changed, 1 insertion(+), 18 deletions(-)
diff --git a/wrapper.c b/wrapper.c
index 3d507d4204..d5976b3e7e 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -421,24 +421,7 @@ FILE *fopen_or_warn(const char *path, const char *mode)
 
 int xmkstemp(char *filename_template)
 {
-	int fd;
-	char origtemplate[PATH_MAX];
-	strlcpy(origtemplate, filename_template, sizeof(origtemplate));
-
-	fd = mkstemp(filename_template);
-	if (fd < 0) {
-		int saved_errno = errno;
-		const char *nonrelative_template;
-
-		if (strlen(filename_template) != strlen(origtemplate))
-			filename_template = origtemplate;
-
-		nonrelative_template = absolute_path(filename_template);
-		errno = saved_errno;
-		die_errno("Unable to create temporary file '%s'",
-			nonrelative_template);
-	}
-	return fd;
+	return xmkstemp_mode(filename_template, 0600);
 }
 
 /* Adapted from libiberty's mkstemp.c. */
-- 
2.51.2
Next: Junio C Hamano
Message 1 of 9 in “wrapper: simplify xmkstemp()”
  1. wrapper: simplify xmkstemp()René Scharfe, Nov 17, 2025
  2. Junio C HamanoNov 17, 2025
  3. Jeff KingNov 18, 2025
  4. René ScharfeNov 18, 2025
  5. Junio C HamanoNov 18, 2025
  6. Jeff KingNov 20, 2025
  7. Junio C HamanoNov 20, 2025
  8. René ScharfeNov 22, 2025
  9. René ScharfeNov 22, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.