*: introduce and use xmkstemp. -65 bytes.

Signed-off-by: Alexander Shishkin <virtuoso@slind.org>
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
This commit is contained in:
Alexander Shishkin
2010-10-22 13:27:16 +02:00
committed by Denys Vlasenko
parent cbfeaac7af
commit 6722737ece
7 changed files with 17 additions and 16 deletions
+2 -3
View File
@@ -685,9 +685,8 @@ static int diffreg(char *file[2])
*/
if (lseek(fd, 0, SEEK_SET) == -1 && errno == ESPIPE) {
char name[] = "/tmp/difXXXXXX";
int fd_tmp = mkstemp(name);
if (fd_tmp < 0)
bb_perror_msg_and_die("mkstemp");
int fd_tmp = xmkstemp(name);
unlink(name);
if (bb_copyfd_eof(fd, fd_tmp) < 0)
xfunc_die();
+1 -2
View File
@@ -200,8 +200,7 @@ int copy_tempfile(int fdin, char *name, char **tempname)
int fd;
*tempname = xasprintf("%sXXXXXX", name);
fd = mkstemp(*tempname);
if(-1 == fd) bb_perror_msg_and_die("no temp file");
fd = xmkstemp(*tempname);
// Set permissions of output file
fstat(fdin, &statbuf);
+1 -3
View File
@@ -1370,9 +1370,7 @@ int sed_main(int argc UNUSED_PARAM, char **argv)
}
G.outname = xasprintf("%sXXXXXX", argv[i]);
nonstdoutfd = mkstemp(G.outname);
if (-1 == nonstdoutfd)
bb_perror_msg_and_die("can't create temp file %s", G.outname);
nonstdoutfd = xmkstemp(G.outname);
G.nonstdout = xfdopen_for_write(nonstdoutfd);
/* Set permissions/owner of output file */