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: clean up Job_CatchOutput



details:   https://anonhg.NetBSD.org/src/rev/5b81c9712e28
branches:  trunk
changeset: 959125:5b81c9712e28
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Feb 01 18:46:38 2021 +0000

description:
make: clean up Job_CatchOutput

The switch statement was unnecessarily long since every branch needed to
be terminated with a break or with a comment explaining that it didn't
fall through to the next case label.

diffstat:

 usr.bin/make/job.c |  27 +++++++++------------------
 1 files changed, 9 insertions(+), 18 deletions(-)

diffs (68 lines):

diff -r aa7cb5ae6cd2 -r 5b81c9712e28 usr.bin/make/job.c
--- a/usr.bin/make/job.c        Mon Feb 01 18:36:32 2021 +0000
+++ b/usr.bin/make/job.c        Mon Feb 01 18:46:38 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.c,v 1.408 2021/02/01 18:25:57 rillig Exp $ */
+/*     $NetBSD: job.c,v 1.409 2021/02/01 18:46:38 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -142,7 +142,7 @@
 #include "trace.h"
 
 /*     "@(#)job.c      8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: job.c,v 1.408 2021/02/01 18:25:57 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.409 2021/02/01 18:46:38 rillig Exp $");
 
 /*
  * A shell defines how the commands are run.  All commands for a target are
@@ -991,7 +991,7 @@
  * Print all commands to the shell file that is later executed.
  *
  * The special command "..." stops printing and saves the remaining commands
- * to be executed later.
+ * to be executed later, when the target '.END' is made.
  *
  * Return whether at least one command was written to the shell file.
  */
@@ -1507,9 +1507,7 @@
                job->cmdFILE = NULL;
        }
 
-       /*
-        * Now the job is actually running, add it to the table.
-        */
+       /* Now that the job is actually running, add it to the table. */
        if (DEBUG(JOB)) {
                debug_printf("JobExec(%s): pid %d added to jobs table\n",
                    job->node->name, job->pid);
@@ -2065,24 +2063,17 @@
                char token = 0;
                ssize_t count;
                count = read(childExitJob.inPipe, &token, 1);
-               switch (count) {
-               case 0:
-                       Punt("unexpected eof on token pipe");
-                       /*NOTREACHED*/
-               case -1:
-                       Punt("token pipe read: %s", strerror(errno));
-                       /*NOTREACHED*/
-               case 1:
+               if (count == 1) {
                        if (token == DO_JOB_RESUME[0])
                                /*
                                 * Complete relay requested from our SIGCONT
                                 * handler
                                 */
                                JobRestartJobs();
-                       break;
-               default:
-                       abort();
-               }
+               } else if (count == 0)
+                       Punt("unexpected eof on token pipe");
+               else
+                       Punt("token pipe read: %s", strerror(errno));
                nready--;
        }
 



Home | Main Index | Thread Index | Old Index