Skip to content

Commit 370470e

Browse files
committed
Merge branch 'rs/xmkstemp-simplify'
Code simplification. * rs/xmkstemp-simplify: wrapper: simplify xmkstemp()
2 parents 1b93acd + f18aa68 commit 370470e

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)