Module Name:    src
Committed By:   rillig
Date:           Fri Oct 23 07:14:32 UTC 2020

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

Log Message:
make(1): convert JobState and JobFlags to enum types

Both GCC and Clang complained when JobFindPid had its parameter "status"
as an int.  Strangely both compilers complained about a comparison
between unsigned and signed int, even though enums are defined to be
int, not unsigned.


To generate a diff of this commit:
cvs rdiff -u -r1.270 -r1.271 src/usr.bin/make/job.c
cvs rdiff -u -r1.56 -r1.57 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.270 src/usr.bin/make/job.c:1.271
--- src/usr.bin/make/job.c:1.270	Fri Oct 23 05:27:33 2020
+++ src/usr.bin/make/job.c	Fri Oct 23 07:14:32 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.270 2020/10/23 05:27:33 rillig Exp $	*/
+/*	$NetBSD: job.c,v 1.271 2020/10/23 07:14:32 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.270 2020/10/23 05:27:33 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.271 2020/10/23 07:14:32 rillig Exp $");
 
 # define STATIC static
 
@@ -592,7 +592,7 @@ JobPassSig_suspend(int signo)
 }
 
 static Job *
-JobFindPid(int pid, int status, Boolean isJobs)
+JobFindPid(int pid, JobState status, Boolean isJobs)
 {
     Job *job;
 

Index: src/usr.bin/make/job.h
diff -u src/usr.bin/make/job.h:1.56 src/usr.bin/make/job.h:1.57
--- src/usr.bin/make/job.h:1.56	Mon Oct 19 23:07:22 2020
+++ src/usr.bin/make/job.h	Fri Oct 23 07:14:32 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.h,v 1.56 2020/10/19 23:07:22 rillig Exp $	*/
+/*	$NetBSD: job.h,v 1.57 2020/10/23 07:14:32 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -117,6 +117,27 @@ struct pollfd;
 # include "meta.h"
 #endif
 
+typedef enum JobState {
+    JOB_ST_FREE =	0,	/* Job is available */
+    JOB_ST_SETUP =	1,	/* Job is allocated but otherwise invalid */
+    JOB_ST_RUNNING =	3,	/* Job is running, pid valid */
+    JOB_ST_FINISHED =	4	/* Job is done (ie after SIGCHILD) */
+} JobState;
+
+typedef enum JobFlags {
+    /* Ignore non-zero exits */
+    JOB_IGNERR =	0x001,
+    /* no output */
+    JOB_SILENT =	0x002,
+    /* Target is a special one. i.e. run it locally
+     * if we can't export it and maxLocal is 0 */
+    JOB_SPECIAL =	0x004,
+    /* Ignore "..." lines when processing commands */
+    JOB_IGNDOTS	=	0x008,
+    /* we've sent 'set -x' */
+    JOB_TRACED =	0x400
+} JobFlags;
+
 /* A Job manages the shell commands that are run to create a single target.
  * Each job is run in a separate subprocess by a shell.  Several jobs can run
  * in parallel.
@@ -146,22 +167,11 @@ typedef struct Job {
 
     int exit_status;		/* from wait4() in signal handler */
 
-    char job_state;		/* status of the job entry */
-#define JOB_ST_FREE	0	/* Job is available */
-#define JOB_ST_SETUP	1	/* Job is allocated but otherwise invalid */
-#define JOB_ST_RUNNING	3	/* Job is running, pid valid */
-#define JOB_ST_FINISHED	4	/* Job is done (ie after SIGCHILD) */
+    JobState job_state;		/* status of the job entry */
 
     char job_suspended;
 
-    int flags;			/* Flags to control treatment of job */
-#define	JOB_IGNERR	0x001	/* Ignore non-zero exits */
-#define	JOB_SILENT	0x002	/* no output */
-#define JOB_SPECIAL	0x004	/* Target is a special one. i.e. run it locally
-				 * if we can't export it and maxLocal is 0 */
-#define JOB_IGNDOTS	0x008	/* Ignore "..." lines when processing
-				 * commands */
-#define JOB_TRACED	0x400	/* we've sent 'set -x' */
+    JobFlags flags;		/* Flags to control treatment of job */
 
     int inPipe;			/* Pipe for reading output from job */
     int outPipe;		/* Pipe for writing control commands */

Reply via email to