diff --git a/mach/proto/as/comm7.c b/mach/proto/as/comm7.c index 3c7871fbe..e95037305 100644 --- a/mach/proto/as/comm7.c +++ b/mach/proto/as/comm7.c @@ -363,7 +363,8 @@ char *path, *tail; if ((dir = getenv("TMPDIR")) == NULL) dir = tmp_dir; sprintf(path, "%s/%s", dir, tail); - return(ffcreat(mktemp(path))); + close(mkstemp(path)); + return(ffcreat(path)); } /* ---------- Error handling ---------- */ diff --git a/modules/src/em_code/insert.c b/modules/src/em_code/insert.c index fd88cd4ec..36950c3ea 100644 --- a/modules/src/em_code/insert.c +++ b/modules/src/em_code/insert.c @@ -145,7 +145,8 @@ swttmp() strcpy(p, C_tmpdir); strcat(p, "/CodeXXXXXX"); - C_tmpfile = mktemp(p); + close(mkstemp(p)); + C_tmpfile = p; if (! sys_open(p, OP_WRITE, &C_old_ofp)) { C_failed(); } @@ -250,7 +251,7 @@ mkpart(part) */ register Part *p = C_findpart(part); register int index = part % TABSIZ; - + if (p != 0) { /* multiple defined part ... */ C_internal_error(); diff --git a/modules/src/system/lock.c b/modules/src/system/lock.c index 0f6be5985..6f00a3a16 100644 --- a/modules/src/system/lock.c +++ b/modules/src/system/lock.c @@ -4,6 +4,8 @@ */ /* $Id$ */ +#include +#include #include "system.h" int @@ -12,7 +14,6 @@ sys_lock(path) { char buf[1024]; char *tmpf = ".lockXXXXXX"; - char *strrchr(), *strcpy(), *mktemp(); char *p; int ok, fd; @@ -23,8 +24,7 @@ sys_lock(path) } else strcpy(buf, tmpf); - mktemp(buf); - if ((fd = creat(buf, 0)) < 0) + if ((fd = mkstemp(buf)) < 0) return 0; close(fd); ok = (link(buf, path) == 0); diff --git a/util/LLgen/src/main.c b/util/LLgen/src/main.c index ca4b05f22..1bd31aa46 100644 --- a/util/LLgen/src/main.c +++ b/util/LLgen/src/main.c @@ -37,7 +37,6 @@ extern fatal(); extern comfatal(); extern copyfile(); extern void install(); -extern char *mktemp(); extern char *sbrk(); main(argc,argv) register string argv[]; { @@ -164,8 +163,8 @@ main(argc,argv) register string argv[]; { nc_rec_file = libpath ("nc_rec"); } #endif - mktemp(f_temp); - mktemp(f_pars); + close(mkstemp(f_temp)); + close(mkstemp(f_pars)); if ((fact = fopen(f_temp,"w")) == NULL) { fputs("Cannot create temporary\n",stderr); exit(1); diff --git a/util/amisc/astrip.c b/util/amisc/astrip.c index e96617abf..e82cb27f1 100644 --- a/util/amisc/astrip.c +++ b/util/amisc/astrip.c @@ -17,8 +17,6 @@ char temp_name[] = "/tmp/sXXXXXX"; char *tname; -char *mktemp(); -FILE *fopen(); FILE *tf; struct outhead buf; int readerror, writeerror; @@ -31,12 +29,12 @@ char **argv; signal(SIGHUP, SIG_IGN); signal(SIGINT, SIG_IGN); signal(SIGQUIT, SIG_IGN); - tname = mktemp(temp_name); + close(mkstemp(temp_name)); while(--argc) { if ((status = strip(argv[argc])) > 1) break; } - unlink(tname); + unlink(temp_name); exit(status); } diff --git a/util/arch/archiver.c b/util/arch/archiver.c index 65684232a..2be5fd3ad 100644 --- a/util/arch/archiver.c +++ b/util/arch/archiver.c @@ -106,7 +106,6 @@ char *progname; char temp_buf[32]; char *temp_arch = &temp_buf[0]; -extern char *mktemp(); extern char *ctime(); void do_object(int f, long size); @@ -277,7 +276,7 @@ char *argv[]; || app_fl #endif ) { - mktemp(temp_arch); + close(mkstemp(temp_arch)); } #ifdef AAL tab = (struct ranlib *) malloc(512 * sizeof(struct ranlib)); diff --git a/util/byacc/main.c b/util/byacc/main.c index 32982239c..b7f5e8f0c 100644 --- a/util/byacc/main.c +++ b/util/byacc/main.c @@ -1,3 +1,4 @@ +#include #include #include "defs.h" @@ -56,10 +57,6 @@ char *rassoc; short **derives; char *nullable; -extern char *mktemp(); -extern char *getenv(); - - done(k) int k; { @@ -253,9 +250,9 @@ create_file_names() text_file_name[len + 5] = 't'; union_file_name[len + 5] = 'u'; - mktemp(action_file_name); - mktemp(text_file_name); - mktemp(union_file_name); + close(mkstemp(action_file_name)); + close(mkstemp(text_file_name)); + close(mkstemp(union_file_name)); len = strlen(file_prefix); diff --git a/util/ego/em_ego/em_ego.c b/util/ego/em_ego/em_ego.c index d29be7385..543f0b50b 100644 --- a/util/ego/em_ego/em_ego.c +++ b/util/ego/em_ego/em_ego.c @@ -280,7 +280,7 @@ static void phargs[argc++] = "-M"; phargs[argc++] = descr_file; } - + for (i=0; i= 1; i--) { diff --git a/util/ego/il/il.c b/util/ego/il/il.c index 938dfa3cc..8313cb93e 100644 --- a/util/ego/il/il.c +++ b/util/ego/il/il.c @@ -334,10 +334,10 @@ char* argv[]; strcat(ccname, "/ego.i2.XXXXXX"); strcat(sname, "/ego.i3.XXXXXX"); strcat(cname2, "/ego.i4.XXXXXX"); - mktemp(cname); - mktemp(ccname); - mktemp(sname); - mktemp(cname2); + close(mkstemp(cname)); + close(mkstemp(ccname)); + close(mkstemp(sname)); + close(mkstemp(cname2)); pass1(files->lname_in, files->bname_in, cname); /* grep calls, analyse procedures */ space = total_size * space / 100; pass2(cname, space); /* select calls to be expanded */ diff --git a/util/flex/main.c b/util/flex/main.c index fad1a3fa8..d6f0ec936 100644 --- a/util/flex/main.c +++ b/util/flex/main.c @@ -6,7 +6,7 @@ * * This code is derived from software contributed to Berkeley by * Vern Paxson. - * + * * The United States Government has rights in this work pursuant * to contract no. DE-AC03-76SF00098 between the United States * Department of Energy and the University of California. @@ -38,6 +38,7 @@ static char rcsid[] = #endif +#include #include "flexdef.h" static char flex_version[] = "2.3"; @@ -394,7 +395,7 @@ char **argv; { int i, sawcmpflag; - char *arg, *flex_gettime(), *mktemp(); + char *arg, *flex_gettime(); printstats = syntaxerror = trace = spprdflt = interactive = caseins = false; backtrack_report = performance_report = ddebug = fulltbl = fullspd = false; @@ -611,7 +612,7 @@ get_next_arg: /* used by -C and -S flags in lieu of a "continue 2" control */ #else (void) strcpy( temp_action_file_name, "flexXXXXXX.tmp" ); #endif - (void) mktemp( temp_action_file_name ); + close(mkstemp(temp_action_file_name)); action_file_name = temp_action_file_name; } diff --git a/util/opt/main.c b/util/opt/main.c index 2990b22b2..a3df98a73 100644 --- a/util/opt/main.c +++ b/util/opt/main.c @@ -57,13 +57,12 @@ flags(s) register char *s; { } fileinit() { - char *mktemp(); short readshort(); if (readshort() != (short) sp_magic) error("wrong input file"); if (Lflag) { - outfile = fopen(mktemp(template),"w"); + outfile = fdopen(mkstemp(template),"w"); if (outfile == NULL) error("can't create %s",template); } else {