summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2017-08-26 12:59:13 +0000
committerschwarze <schwarze@openbsd.org>2017-08-26 12:59:13 +0000
commit458b6f49bdf7c2a0c2554e8eb88018cc6e39f58f (patch)
tree533ccdeeb3416f8a73e4b23ee7e20fbf787ad0ec
parentregen (diff)
downloadwireguard-openbsd-458b6f49bdf7c2a0c2554e8eb88018cc6e39f58f.tar.xz
wireguard-openbsd-458b6f49bdf7c2a0c2554e8eb88018cc6e39f58f.zip
No need to fork and exec rm(1) -rf, we know that we have exactly
one file and exactly one directory to remove. While here, increase the size of the buffer such that the file name actually fits. Minus 17 lines of code, no functional change. Opportunity for simplification reported by George Brown <321 dot george at gmail dot com> on misc@.
-rw-r--r--usr.bin/mandoc/mandocdb.c25
1 files changed, 4 insertions, 21 deletions
diff --git a/usr.bin/mandoc/mandocdb.c b/usr.bin/mandoc/mandocdb.c
index b62bb9d5f52..35683d4d848 100644
--- a/usr.bin/mandoc/mandocdb.c
+++ b/usr.bin/mandoc/mandocdb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mandocdb.c,v 1.202 2017/07/28 14:46:46 schwarze Exp $ */
+/* $OpenBSD: mandocdb.c,v 1.203 2017/08/26 12:59:13 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -2079,7 +2079,7 @@ dbprune(struct dba *dba)
static void
dbwrite(struct dba *dba)
{
- char tfn[32];
+ char tfn[33];
int status;
pid_t child;
@@ -2153,26 +2153,9 @@ dbwrite(struct dba *dba)
}
out:
+ unlink(tfn);
*strrchr(tfn, '/') = '\0';
- switch (child = fork()) {
- case -1:
- exitcode = (int)MANDOCLEVEL_SYSERR;
- say("", "&fork rm");
- return;
- case 0:
- execlp("rm", "rm", "-rf", tfn, (char *)NULL);
- say("", "&exec rm");
- exit((int)MANDOCLEVEL_SYSERR);
- default:
- break;
- }
- if (waitpid(child, &status, 0) == -1) {
- exitcode = (int)MANDOCLEVEL_SYSERR;
- say("", "&wait rm");
- } else if (WIFSIGNALED(status) || WEXITSTATUS(status)) {
- exitcode = (int)MANDOCLEVEL_SYSERR;
- say("", "%s: Cannot remove temporary directory", tfn);
- }
+ rmdir(tfn);
}
static int