diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2017-08-26 12:59:14 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2017-08-26 12:59:14 +0000 |
commit | 2271b4e3814309bc1d47b92f824bb4e65ff628bf (patch) | |
tree | 7ef1621a123c472499587d7f5c0b267052ad2ee3 /usr.bin/mandoc | |
parent | 46f74e18f62f8ef940243067a82eef945dbee14d (diff) |
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@.
Diffstat (limited to 'usr.bin/mandoc')
-rw-r--r-- | usr.bin/mandoc/mandocdb.c | 25 |
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 |