From a511600f0391e7ecc2fa55e5cda222b5535422e8 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 17 Sep 2022 09:30:20 -0700 Subject: Simplify HAVE_MKSTEMP block Signed-off-by: Alan Coopersmith --- imake.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/imake.c b/imake.c index 62e73eb..c07948d 100644 --- a/imake.c +++ b/imake.c @@ -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); -- cgit v1.2.3