Skip to content

Commit f18aa68

Browse files
rscharfegitster
authored andcommitted
wrapper: simplify xmkstemp()
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent f368df4 commit f18aa68

File tree

1 file changed

+1
-18
lines changed

1 file changed

+1
-18
lines changed

wrapper.c

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -421,24 +421,7 @@ FILE *fopen_or_warn(const char *path, const char *mode)
421421

422422
int xmkstemp(char *filename_template)
423423
{
424-
int fd;
425-
char origtemplate[PATH_MAX];
426-
strlcpy(origtemplate, filename_template, sizeof(origtemplate));
427-
428-
fd = mkstemp(filename_template);
429-
if (fd < 0) {
430-
int saved_errno = errno;
431-
const char *nonrelative_template;
432-
433-
if (strlen(filename_template) != strlen(origtemplate))
434-
filename_template = origtemplate;
435-
436-
nonrelative_template = absolute_path(filename_template);
437-
errno = saved_errno;
438-
die_errno("Unable to create temporary file '%s'",
439-
nonrelative_template);
440-
}
441-
return fd;
424+
return xmkstemp_mode(filename_template, 0600);
442425
}
443426

444427
/* Adapted from libiberty's mkstemp.c. */

0 commit comments

Comments
 (0)