Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make(1): replace execError with execDie



details:   https://anonhg.NetBSD.org/src/rev/5b5952855f0d
branches:  trunk
changeset: 955959:5b5952855f0d
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Oct 18 07:46:04 2020 +0000

description:
make(1): replace execError with execDie

All calls to this function were followed by _exit(1).

diffstat:

 usr.bin/make/compat.c  |   7 ++---
 usr.bin/make/job.c     |  56 +++++++++++++++++--------------------------------
 usr.bin/make/main.c    |  11 +++++----
 usr.bin/make/meta.c    |   9 ++-----
 usr.bin/make/nonints.h |   4 +-
 5 files changed, 34 insertions(+), 53 deletions(-)

diffs (211 lines):

diff -r 5ce864787910 -r 5b5952855f0d usr.bin/make/compat.c
--- a/usr.bin/make/compat.c     Sat Oct 17 23:23:06 2020 +0000
+++ b/usr.bin/make/compat.c     Sun Oct 18 07:46:04 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat.c,v 1.165 2020/10/05 19:27:47 rillig Exp $      */
+/*     $NetBSD: compat.c,v 1.166 2020/10/18 07:46:04 rillig Exp $      */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -96,7 +96,7 @@
 #include "pathnames.h"
 
 /*     "@(#)compat.c   8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: compat.c,v 1.165 2020/10/05 19:27:47 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.166 2020/10/18 07:46:04 rillig Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
@@ -348,8 +348,7 @@
        }
 #endif
        (void)execvp(av[0], (char *const *)UNCONST(av));
-       execError("exec", av[0]);
-       _exit(1);
+       execDie("exec", av[0]);
     }
 
     free(mav);
diff -r 5ce864787910 -r 5b5952855f0d usr.bin/make/job.c
--- a/usr.bin/make/job.c        Sat Oct 17 23:23:06 2020 +0000
+++ b/usr.bin/make/job.c        Sun Oct 18 07:46:04 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.c,v 1.263 2020/10/17 21:32:30 rillig Exp $ */
+/*     $NetBSD: job.c,v 1.264 2020/10/18 07:46:04 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -143,7 +143,7 @@
 #include "trace.h"
 
 /*     "@(#)job.c      8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: job.c,v 1.263 2020/10/17 21:32:30 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.264 2020/10/18 07:46:04 rillig Exp $");
 
 # define STATIC static
 
@@ -1203,55 +1203,40 @@
         * reset it to the beginning (again). Since the stream was marked
         * close-on-exec, we must clear that bit in the new input.
         */
-       if (dup2(fileno(job->cmdFILE), 0) == -1) {
-           execError("dup2", "job->cmdFILE");
-           _exit(1);
-       }
-       if (fcntl(0, F_SETFD, 0) == -1) {
-           execError("fcntl clear close-on-exec", "stdin");
-           _exit(1);
-       }
-       if (lseek(0, (off_t)0, SEEK_SET) == -1) {
-           execError("lseek to 0", "stdin");
-           _exit(1);
-       }
+       if (dup2(fileno(job->cmdFILE), 0) == -1)
+           execDie("dup2", "job->cmdFILE");
+       if (fcntl(0, F_SETFD, 0) == -1)
+           execDie("fcntl clear close-on-exec", "stdin");
+       if (lseek(0, (off_t)0, SEEK_SET) == -1)
+           execDie("lseek to 0", "stdin");
 
        if (job->node->type & (OP_MAKE | OP_SUBMAKE)) {
                /*
                 * Pass job token pipe to submakes.
                 */
-               if (fcntl(tokenWaitJob.inPipe, F_SETFD, 0) == -1) {
-                   execError("clear close-on-exec", "tokenWaitJob.inPipe");
-                   _exit(1);
-               }
-               if (fcntl(tokenWaitJob.outPipe, F_SETFD, 0) == -1) {
-                   execError("clear close-on-exec", "tokenWaitJob.outPipe");
-                   _exit(1);
-               }
+               if (fcntl(tokenWaitJob.inPipe, F_SETFD, 0) == -1)
+                   execDie("clear close-on-exec", "tokenWaitJob.inPipe");
+               if (fcntl(tokenWaitJob.outPipe, F_SETFD, 0) == -1)
+                   execDie("clear close-on-exec", "tokenWaitJob.outPipe");
        }
 
        /*
         * Set up the child's output to be routed through the pipe
         * we've created for it.
         */
-       if (dup2(job->outPipe, 1) == -1) {
-           execError("dup2", "job->outPipe");
-           _exit(1);
-       }
+       if (dup2(job->outPipe, 1) == -1)
+           execDie("dup2", "job->outPipe");
+
        /*
         * The output channels are marked close on exec. This bit was
         * duplicated by the dup2(on some systems), so we have to clear
         * it before routing the shell's error output to the same place as
         * its standard output.
         */
-       if (fcntl(1, F_SETFD, 0) == -1) {
-           execError("clear close-on-exec", "stdout");
-           _exit(1);
-       }
-       if (dup2(1, 2) == -1) {
-           execError("dup2", "1, 2");
-           _exit(1);
-       }
+       if (fcntl(1, F_SETFD, 0) == -1)
+           execDie("clear close-on-exec", "stdout");
+       if (dup2(1, 2) == -1)
+           execDie("dup2", "1, 2");
 
        /*
         * We want to switch the child into a different process family so
@@ -1270,8 +1255,7 @@
        Var_ExportVars();
 
        (void)execv(shellPath, argv);
-       execError("exec", shellPath);
-       _exit(1);
+       execDie("exec", shellPath);
     }
 
     /* Parent, continuing after the child exec */
diff -r 5ce864787910 -r 5b5952855f0d usr.bin/make/main.c
--- a/usr.bin/make/main.c       Sat Oct 17 23:23:06 2020 +0000
+++ b/usr.bin/make/main.c       Sun Oct 18 07:46:04 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.371 2020/10/05 22:45:47 rillig Exp $        */
+/*     $NetBSD: main.c,v 1.372 2020/10/18 07:46:04 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -122,7 +122,7 @@
 #endif
 
 /*     "@(#)main.c     8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: main.c,v 1.371 2020/10/05 22:45:47 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.372 2020/10/18 07:46:04 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
            "The Regents of the University of California.  "
@@ -1877,11 +1877,11 @@
 }
 
 /*
- * execError --
+ * execDie --
  *     Print why exec failed, avoiding stdio.
  */
-void
-execError(const char *af, const char *av)
+void MAKE_ATTR_DEAD
+execDie(const char *af, const char *av)
 {
 #ifdef USE_IOVEC
        int i = 0;
@@ -1907,6 +1907,7 @@
        while (writev(2, iov, 8) == -1 && errno == EAGAIN)
            continue;
 #endif
+       _exit(1);
 }
 
 /*
diff -r 5ce864787910 -r 5b5952855f0d usr.bin/make/meta.c
--- a/usr.bin/make/meta.c       Sat Oct 17 23:23:06 2020 +0000
+++ b/usr.bin/make/meta.c       Sun Oct 18 07:46:04 2020 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: meta.c,v 1.122 2020/09/28 22:23:35 rillig Exp $ */
+/*      $NetBSD: meta.c,v 1.123 2020/10/18 07:46:04 rillig Exp $ */
 
 /*
  * Implement 'meta' mode.
@@ -1647,11 +1647,8 @@
 meta_compat_child(void)
 {
     meta_job_child(NULL);
-    if (dup2(childPipe[1], 1) < 0 ||
-       dup2(1, 2) < 0) {
-       execError("dup2", "pipe");
-       _exit(1);
-    }
+    if (dup2(childPipe[1], 1) < 0 || dup2(1, 2) < 0)
+       execDie("dup2", "pipe");
 }
 
 void
diff -r 5ce864787910 -r 5b5952855f0d usr.bin/make/nonints.h
--- a/usr.bin/make/nonints.h    Sat Oct 17 23:23:06 2020 +0000
+++ b/usr.bin/make/nonints.h    Sun Oct 18 07:46:04 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nonints.h,v 1.141 2020/10/17 21:32:30 rillig Exp $     */
+/*     $NetBSD: nonints.h,v 1.142 2020/10/18 07:46:04 rillig Exp $     */
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -114,7 +114,7 @@
 void DieHorribly(void) MAKE_ATTR_DEAD;
 void Finish(int) MAKE_ATTR_DEAD;
 int eunlink(const char *);
-void execError(const char *, const char *);
+void execDie(const char *, const char *);
 char *getTmpdir(void);
 Boolean s2Boolean(const char *, Boolean);
 Boolean getBoolean(const char *, Boolean);



Home | Main Index | Thread Index | Old Index