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): remove ReturnStatus, SUCCESS and FAILURE
details: https://anonhg.NetBSD.org/src/rev/43c04c6a4c86
branches: trunk
changeset: 1013505:43c04c6a4c86
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Aug 29 12:20:17 2020 +0000
description:
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.
diffstat:
usr.bin/make/arch.c | 10 +++++-----
usr.bin/make/job.c | 24 ++++++++++++------------
usr.bin/make/job.h | 4 ++--
usr.bin/make/make.h | 20 +-------------------
usr.bin/make/parse.c | 24 ++++++++++++------------
5 files changed, 32 insertions(+), 50 deletions(-)
diffs (291 lines):
diff -r 83ec331f8525 -r 43c04c6a4c86 usr.bin/make/arch.c
--- a/usr.bin/make/arch.c Sat Aug 29 12:01:46 2020 +0000
+++ b/usr.bin/make/arch.c Sat Aug 29 12:20:17 2020 +0000
@@ -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 @@
* 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 @@
}
} 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);
diff -r 83ec331f8525 -r 43c04c6a4c86 usr.bin/make/job.c
--- a/usr.bin/make/job.c Sat Aug 29 12:01:46 2020 +0000
+++ b/usr.bin/make/job.c Sat Aug 29 12:20:17 2020 +0000
@@ -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 @@
*
* 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 @@
* 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 @@
*
*-----------------------------------------------------------------------
*/
-ReturnStatus
+Boolean
Job_ParseShell(char *line)
{
char **words;
@@ -2438,7 +2438,7 @@
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 @@
Parse_Error(PARSE_FATAL, "Unknown keyword \"%s\"",
*argv);
free(words);
- return FAILURE;
+ return FALSE;
}
fullSpec = TRUE;
}
@@ -2493,13 +2493,13 @@
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 @@
Parse_Error(PARSE_WARNING, "%s: No matching shell",
shellName);
free(words);
- return FAILURE;
+ return FALSE;
}
commandShell = sh;
} else {
@@ -2564,7 +2564,7 @@
* shell specification.
*/
free(words);
- return SUCCESS;
+ return TRUE;
}
/*-
diff -r 83ec331f8525 -r 43c04c6a4c86 usr.bin/make/job.h
--- a/usr.bin/make/job.h Sat Aug 29 12:01:46 2020 +0000
+++ b/usr.bin/make/job.h Sat Aug 29 12:20:17 2020 +0000
@@ -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_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);
diff -r 83ec331f8525 -r 43c04c6a4c86 usr.bin/make/make.h
--- a/usr.bin/make/make.h Sat Aug 29 12:01:46 2020 +0000
+++ b/usr.bin/make/make.h Sat Aug 29 12:20:17 2020 +0000
@@ -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 @@
#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"
diff -r 83ec331f8525 -r 43c04c6a4c86 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c Sat Aug 29 12:01:46 2020 +0000
+++ b/usr.bin/make/parse.c Sat Aug 29 12:20:17 2020 +0000
@@ -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 @@
/*
* 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 @@
* 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 @@
#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 @@
* 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 @@
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;
}
Home |
Main Index |
Thread Index |
Old Index