Module Name:    src
Committed By:   rillig
Date:           Sat Nov  7 20:03:56 UTC 2020

Modified Files:
        src/usr.bin/make: job.c job.h

Log Message:
make(1): clean up JobStart

Initialize the fields in declaration order.
Initialize Job.flags in a single assignment.


To generate a diff of this commit:
cvs rdiff -u -r1.308 -r1.309 src/usr.bin/make/job.c
cvs rdiff -u -r1.58 -r1.59 src/usr.bin/make/job.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/job.c
diff -u src/usr.bin/make/job.c:1.308 src/usr.bin/make/job.c:1.309
--- src/usr.bin/make/job.c:1.308	Sat Nov  7 13:53:12 2020
+++ src/usr.bin/make/job.c	Sat Nov  7 20:03:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.308 2020/11/07 13:53:12 rillig Exp $	*/
+/*	$NetBSD: job.c,v 1.309 2020/11/07 20:03:56 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.308 2020/11/07 13:53:12 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.309 2020/11/07 20:03:56 rillig Exp $");
 
 /* A shell defines how the commands are run.  All commands for a target are
  * written into a single file, which is then given to the shell to execute
@@ -1491,7 +1491,7 @@ JobMakeArgv(Job *job, char **argv)
  *-----------------------------------------------------------------------
  */
 static JobStartResult
-JobStart(GNode *gn, int flags)
+JobStart(GNode *gn, JobFlags flags)
 {
     Job *job;			/* new job descriptor */
     char *argv[10];		/* Argument vector to shell */
@@ -1507,26 +1507,17 @@ JobStart(GNode *gn, int flags)
 	Punt("JobStart no job slots vacant");
 
     memset(job, 0, sizeof *job);
-    job->job_state = JOB_ST_SETUP;
-    if (gn->type & OP_SPECIAL)
-	flags |= JOB_SPECIAL;
-
     job->node = gn;
     job->tailCmds = NULL;
+    job->job_state = JOB_ST_SETUP;
 
-    /*
-     * Set the initial value of the flags for this job based on the global
-     * ones and the node's attributes... Any flags supplied by the caller
-     * are also added to the field.
-     */
-    job->flags = 0;
-    if (Targ_Ignore(gn)) {
-	job->flags |= JOB_IGNERR;
-    }
-    if (Targ_Silent(gn)) {
-	job->flags |= JOB_SILENT;
-    }
-    job->flags |= flags;
+    if (gn->type & OP_SPECIAL)
+	flags |= JOB_SPECIAL;
+    if (Targ_Ignore(gn))
+	flags |= JOB_IGNERR;
+    if (Targ_Silent(gn))
+	flags |= JOB_SILENT;
+    job->flags = flags;
 
     /*
      * Check the commands now so any attributes from .DEFAULT have a chance
@@ -2053,7 +2044,7 @@ Job_CatchOutput(void)
 void
 Job_Make(GNode *gn)
 {
-    (void)JobStart(gn, 0);
+    (void)JobStart(gn, JOB_NONE);
 }
 
 void

Index: src/usr.bin/make/job.h
diff -u src/usr.bin/make/job.h:1.58 src/usr.bin/make/job.h:1.59
--- src/usr.bin/make/job.h:1.58	Mon Oct 26 21:34:10 2020
+++ src/usr.bin/make/job.h	Sat Nov  7 20:03:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.h,v 1.58 2020/10/26 21:34:10 rillig Exp $	*/
+/*	$NetBSD: job.h,v 1.59 2020/11/07 20:03:56 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -125,17 +125,18 @@ typedef enum JobState {
 } JobState;
 
 typedef enum JobFlags {
+    JOB_NONE	= 0,
     /* Ignore non-zero exits */
-    JOB_IGNERR =	0x001,
+    JOB_IGNERR	= 1 << 0,
     /* no output */
-    JOB_SILENT =	0x002,
+    JOB_SILENT	= 1 << 1,
     /* Target is a special one. i.e. run it locally
      * if we can't export it and maxLocal is 0 */
-    JOB_SPECIAL =	0x004,
+    JOB_SPECIAL	= 1 << 2,
     /* Ignore "..." lines when processing commands */
-    JOB_IGNDOTS	=	0x008,
+    JOB_IGNDOTS	= 1 << 3,
     /* we've sent 'set -x' */
-    JOB_TRACED =	0x400
+    JOB_TRACED	= 1 << 10
 } JobFlags;
 
 /* A Job manages the shell commands that are run to create a single target.

Reply via email to