From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from localhost (fantadrom.bsd.lv [local]) by fantadrom.bsd.lv (OpenSMTPD) with ESMTPA id d7ba3862 for ; Sat, 26 Aug 2017 07:59:47 -0500 (EST) Date: Sat, 26 Aug 2017 07:59:47 -0500 (EST) Message-Id: <15553716636814665467.enqueue@fantadrom.bsd.lv> X-Mailinglist: mandoc-source Reply-To: source@mandoc.bsd.lv MIME-Version: 1.0 From: schwarze@mandoc.bsd.lv To: source@mandoc.bsd.lv Subject: mandoc: No need to fork and exec rm(1) -rf, we know that we have exactly X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- 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@. Modified Files: -------------- mandoc: mandocdb.c Revision Data ------------- Index: mandocdb.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/mandocdb.c,v retrieving revision 1.253 retrieving revision 1.254 diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.253 -r1.254 --- mandocdb.c +++ mandocdb.c @@ -2119,7 +2119,7 @@ dbprune(struct dba *dba) static void dbwrite(struct dba *dba) { - char tfn[32]; + char tfn[33]; int status; pid_t child; @@ -2193,26 +2193,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 -- To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv