diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-09-17 09:30:20 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-09-17 09:42:11 -0700 |
commit | a511600f0391e7ecc2fa55e5cda222b5535422e8 (patch) | |
tree | 8bacacf04d79a47bbcb788cbb912b0742a2b2031 | |
parent | 4945a09e914c48a2a55dacdb24ffe2806378641b (diff) |
Simplify HAVE_MKSTEMP block
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | imake.c | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -399,17 +399,16 @@ main(int argc, char *argv[]) if ((tmpfd = fopen(tmpMakefile, "w+")) == NULL) LogFatal("Cannot create temporary file %s.", tmpMakefile); } else { -#ifdef HAVE_MKSTEMP - int fd; -#endif char *tmpMakefileName = Strdup(tmpMakefileTemplate); + #ifndef HAVE_MKSTEMP if (mktemp(tmpMakefileName) == NULL || (tmpfd = fopen(tmpMakefileName, "w+")) == NULL) { LogFatal("Cannot create temporary file %s.", tmpMakefileName); } #else - fd = mkstemp(tmpMakefileName); + int fd = mkstemp(tmpMakefileName); + if (fd == -1 || (tmpfd = fdopen(fd, "w+")) == NULL) { if (fd != -1) { unlink(tmpMakefileName); close(fd); |