Module Name:    src
Committed By:   rillig
Date:           Sat Aug 29 12:20:17 UTC 2020

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

Log Message:
make(1): remove ReturnStatus, SUCCESS and FAILURE

These are used in so few places now that it is easier to use a simple
Boolean for them.


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 src/usr.bin/make/arch.c
cvs rdiff -u -r1.223 -r1.224 src/usr.bin/make/job.c
cvs rdiff -u -r1.46 -r1.47 src/usr.bin/make/job.h
cvs rdiff -u -r1.131 -r1.132 src/usr.bin/make/make.h
cvs rdiff -u -r1.271 -r1.272 src/usr.bin/make/parse.c

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/arch.c
diff -u src/usr.bin/make/arch.c:1.104 src/usr.bin/make/arch.c:1.105
--- src/usr.bin/make/arch.c:1.104	Sat Aug 29 10:12:06 2020
+++ src/usr.bin/make/arch.c	Sat Aug 29 12:20:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: arch.c,v 1.104 2020/08/29 10:12:06 rillig Exp $	*/
+/*	$NetBSD: arch.c,v 1.105 2020/08/29 12:20:17 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: arch.c,v 1.104 2020/08/29 10:12:06 rillig Exp $";
+static char rcsid[] = "$NetBSD: arch.c,v 1.105 2020/08/29 12:20:17 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)arch.c	8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: arch.c,v 1.104 2020/08/29 10:12:06 rillig Exp $");
+__RCSID("$NetBSD: arch.c,v 1.105 2020/08/29 12:20:17 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -94,7 +94,7 @@ __RCSID("$NetBSD: arch.c,v 1.104 2020/08
  * The interface to this module is:
  *	Arch_ParseArchive   	Given an archive specification, return a list
  *	    	  	    	of GNode's, one for each member in the spec.
- *	    	  	    	FAILURE is returned if the specification is
+ *	    	  	    	FALSE is returned if the specification is
  *	    	  	    	invalid for some reason.
  *
  *	Arch_Touch	    	Alter the modification time of the archive
@@ -358,7 +358,7 @@ Arch_ParseArchive(char **linePtr, Lst no
 		}
 	    } else if (!Arch_ParseArchive(&sacrifice, nodeLst, ctxt)) {
 		/*
-		 * Error in nested call -- free buffer and return FAILURE
+		 * Error in nested call -- free buffer and return FALSE
 		 * ourselves.
 		 */
 		free(buf);

Index: src/usr.bin/make/job.c
diff -u src/usr.bin/make/job.c:1.223 src/usr.bin/make/job.c:1.224
--- src/usr.bin/make/job.c:1.223	Sat Aug 29 10:41:12 2020
+++ src/usr.bin/make/job.c	Sat Aug 29 12:20:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.223 2020/08/29 10:41:12 rillig Exp $	*/
+/*	$NetBSD: job.c,v 1.224 2020/08/29 12:20:17 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: job.c,v 1.223 2020/08/29 10:41:12 rillig Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.224 2020/08/29 12:20:17 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)job.c	8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: job.c,v 1.223 2020/08/29 10:41:12 rillig Exp $");
+__RCSID("$NetBSD: job.c,v 1.224 2020/08/29 12:20:17 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -112,7 +112,7 @@ __RCSID("$NetBSD: job.c,v 1.223 2020/08/
  *
  *	Job_ParseShell	    	Given the line following a .SHELL target, parse
  *	    	  	    	the line as a shell specification. Returns
- *	    	  	    	FAILURE if the spec was incorrect.
+ *	    	  	    	FALSE if the spec was incorrect.
  *
  *	Job_Finish	    	Perform any final processing which needs doing.
  *	    	  	    	This includes the execution of any commands
@@ -2376,7 +2376,7 @@ JobMatchShell(const char *name)
  *	line		The shell spec
  *
  * Results:
- *	FAILURE if the specification was incorrect.
+ *	FALSE if the specification was incorrect.
  *
  * Side Effects:
  *	commandShell points to a Shell structure (either predefined or
@@ -2413,7 +2413,7 @@ JobMatchShell(const char *name)
  *
  *-----------------------------------------------------------------------
  */
-ReturnStatus
+Boolean
 Job_ParseShell(char *line)
 {
     char	**words;
@@ -2438,7 +2438,7 @@ Job_ParseShell(char *line)
     words = brk_string(line, TRUE, &argc, &path);
     if (words == NULL) {
 	Error("Unterminated quoted string [%s]", line);
-	return FAILURE;
+	return FALSE;
     }
     shellArgv = path;
 
@@ -2477,7 +2477,7 @@ Job_ParseShell(char *line)
 		    Parse_Error(PARSE_FATAL, "Unknown keyword \"%s\"",
 				*argv);
 		    free(words);
-		    return FAILURE;
+		    return FALSE;
 		}
 		fullSpec = TRUE;
 	    }
@@ -2493,13 +2493,13 @@ Job_ParseShell(char *line)
 	if (newShell.name == NULL) {
 	    Parse_Error(PARSE_FATAL, "Neither path nor name specified");
 	    free(words);
-	    return FAILURE;
+	    return FALSE;
 	} else {
 	    if ((sh = JobMatchShell(newShell.name)) == NULL) {
 		    Parse_Error(PARSE_WARNING, "%s: No matching shell",
 				newShell.name);
 		    free(words);
-		    return FAILURE;
+		    return FALSE;
 	    }
 	    commandShell = sh;
 	    shellName = newShell.name;
@@ -2535,7 +2535,7 @@ Job_ParseShell(char *line)
 		    Parse_Error(PARSE_WARNING, "%s: No matching shell",
 				shellName);
 		    free(words);
-		    return FAILURE;
+		    return FALSE;
 	    }
 	    commandShell = sh;
 	} else {
@@ -2564,7 +2564,7 @@ Job_ParseShell(char *line)
      * shell specification.
      */
     free(words);
-    return SUCCESS;
+    return TRUE;
 }
 
 /*-

Index: src/usr.bin/make/job.h
diff -u src/usr.bin/make/job.h:1.46 src/usr.bin/make/job.h:1.47
--- src/usr.bin/make/job.h:1.46	Thu Aug 27 06:18:22 2020
+++ src/usr.bin/make/job.h	Sat Aug 29 12:20:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.h,v 1.46 2020/08/27 06:18:22 rillig Exp $	*/
+/*	$NetBSD: job.h,v 1.47 2020/08/29 12:20:17 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -255,7 +255,7 @@ void Job_CatchOutput(void);
 void Job_Make(GNode *);
 void Job_Init(void);
 Boolean Job_Empty(void);
-ReturnStatus Job_ParseShell(char *);
+Boolean Job_ParseShell(char *);
 int Job_Finish(void);
 void Job_End(void);
 void Job_Wait(void);

Index: src/usr.bin/make/make.h
diff -u src/usr.bin/make/make.h:1.131 src/usr.bin/make/make.h:1.132
--- src/usr.bin/make/make.h:1.131	Sat Aug 29 08:09:07 2020
+++ src/usr.bin/make/make.h	Sat Aug 29 12:20:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.h,v 1.131 2020/08/29 08:09:07 rillig Exp $	*/
+/*	$NetBSD: make.h,v 1.132 2020/08/29 12:20:17 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -152,24 +152,6 @@ typedef int Boolean;
 #define FALSE	0
 #endif /* FALSE */
 
-/*
- * Functions that must return a status can return a ReturnStatus to
- * indicate success or type of failure.
- */
-
-typedef int  ReturnStatus;
-
-/*
- * The following statuses overlap with the first 2 generic statuses
- * defined in status.h:
- *
- * SUCCESS			There was no error.
- * FAILURE			There was a general error.
- */
-
-#define	SUCCESS			0x00000000
-#define	FAILURE			0x00000001
-
 #include "lst.h"
 #include "enum.h"
 #include "hash.h"

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.271 src/usr.bin/make/parse.c:1.272
--- src/usr.bin/make/parse.c:1.271	Sat Aug 29 11:24:54 2020
+++ src/usr.bin/make/parse.c	Sat Aug 29 12:20:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.271 2020/08/29 11:24:54 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.272 2020/08/29 12:20:17 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.271 2020/08/29 11:24:54 rillig Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.272 2020/08/29 12:20:17 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)parse.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: parse.c,v 1.271 2020/08/29 11:24:54 rillig Exp $");
+__RCSID("$NetBSD: parse.c,v 1.272 2020/08/29 12:20:17 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -425,17 +425,17 @@ loadedfile_nextbuf(void *x, size_t *len)
 /*
  * Try to get the size of a file.
  */
-static ReturnStatus
+static Boolean
 load_getsize(int fd, size_t *ret)
 {
 	struct stat st;
 
 	if (fstat(fd, &st) < 0) {
-		return FAILURE;
+		return FALSE;
 	}
 
 	if (!S_ISREG(st.st_mode)) {
-		return FAILURE;
+		return FALSE;
 	}
 
 	/*
@@ -448,11 +448,11 @@ load_getsize(int fd, size_t *ret)
 	 * While we're at it reject negative sizes too, just in case.
 	 */
 	if (st.st_size < 0 || st.st_size > 0x7fffffff) {
-		return FAILURE;
+		return FALSE;
 	}
 
 	*ret = (size_t) st.st_size;
-	return SUCCESS;
+	return TRUE;
 }
 
 /*
@@ -489,7 +489,7 @@ loadfile(const char *path, int fd)
 #endif
 	}
 
-	if (load_getsize(fd, &lf->len) == SUCCESS) {
+	if (load_getsize(fd, &lf->len)) {
 		/* found a size, try mmap */
 		if (pagesize == 0)
 			pagesize = sysconf(_SC_PAGESIZE);
@@ -1253,8 +1253,8 @@ ParseDoDependency(char *line)
 	     * things like "archive(file1.o file2.o file3.o)" are permissible.
 	     * Arch_ParseArchive will set 'line' to be the first non-blank
 	     * after the archive-spec. It creates/finds nodes for the members
-	     * and places them on the given list, returning SUCCESS if all
-	     * went well and FAILURE if there was an error in the
+	     * and places them on the given list, returning TRUE if all
+	     * went well and FALSE if there was an error in the
 	     * specification. On error, line should remain untouched.
 	     */
 	    if (!Arch_ParseArchive(&line, targets, VAR_CMD)) {
@@ -1609,7 +1609,7 @@ ParseDoDependency(char *line)
 	Main_ParseArgLine(line);
 	*line = '\0';
     } else if (specType == ExShell) {
-	if (Job_ParseShell(line) != SUCCESS) {
+	if (!Job_ParseShell(line)) {
 	    Parse_Error(PARSE_FATAL, "improper shell specification");
 	    goto out;
 	}

Reply via email to