summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorderaadt <deraadt>2016-07-19 06:43:27 +0000
committerderaadt <deraadt>2016-07-19 06:43:27 +0000
commitc75fd84ee574f6c9cc4079a65740c8a17a41e2a5 (patch)
treebed1ea50b0f2aabfa4e163244d7b205167b8a266
parent63c366dc875d2090bee7f3bd1133def63bf26593 (diff)
downloadpatch-c75fd84ee574f6c9cc4079a65740c8a17a41e2a5.tar
patch-c75fd84ee574f6c9cc4079a65740c8a17a41e2a5.tar.gz
Cleanup close(open idioms.OPENBSD_6_0_BASE
ok krw
-rw-r--r--inp.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/inp.c b/inp.c
index 4d77728..755c3d0 100644
--- a/inp.c
+++ b/inp.c
@@ -148,6 +148,8 @@ plan_a(const char *filename)
statfailed = stat(filename, &filestat);
if (statfailed && ok_to_create_file) {
+ int fd;
+
if (verbose)
say("(Creating file %s...)\n", filename);
@@ -159,7 +161,9 @@ plan_a(const char *filename)
if (check_only)
return true;
makedirs(filename, true);
- close(open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0666));
+ if ((fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0666)) != -1)
+ close(fd);
+
statfailed = stat(filename, &filestat);
}
if (statfailed)