Module Name: src
Committed By: rillig
Date: Sat Aug 22 13:28:20 UTC 2020
Modified Files:
src/usr.bin/make: job.c lst.c lst.h make.c meta.c parse.c suff.c targ.c
Log Message:
make(1): convert remaining Lst_AtEnd to the stricter Lst_Append
The general-purpose list library that is included in make allows to call
Lst_AtEnd for invalid lists, silently ignoring this programming error.
This is a flexibility that make doesn't need.
Another unneeded "feature" is that list items can theoretically be null
pointers. This doesn't make sense as well and is therefore not needed
by make.
These programming errors are now caught early by assertions.
To generate a diff of this commit:
cvs rdiff -u -r1.210 -r1.211 src/usr.bin/make/job.c
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/make/lst.c
cvs rdiff -u -r1.29 -r1.30 src/usr.bin/make/lst.h
cvs rdiff -u -r1.112 -r1.113 src/usr.bin/make/make.c
cvs rdiff -u -r1.94 -r1.95 src/usr.bin/make/meta.c
cvs rdiff -u -r1.253 -r1.254 src/usr.bin/make/parse.c
cvs rdiff -u -r1.102 -r1.103 src/usr.bin/make/suff.c
cvs rdiff -u -r1.68 -r1.69 src/usr.bin/make/targ.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/job.c
diff -u src/usr.bin/make/job.c:1.210 src/usr.bin/make/job.c:1.211
--- src/usr.bin/make/job.c:1.210 Sat Aug 22 11:35:00 2020
+++ src/usr.bin/make/job.c Sat Aug 22 13:28:20 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: job.c,v 1.210 2020/08/22 11:35:00 rillig Exp $ */
+/* $NetBSD: job.c,v 1.211 2020/08/22 13:28:20 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.210 2020/08/22 11:35:00 rillig Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.211 2020/08/22 13:28:20 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.210 2020/08/22 11:35:00 rillig Exp $");
+__RCSID("$NetBSD: job.c,v 1.211 2020/08/22 13:28:20 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -1972,7 +1972,7 @@ JobRun(GNode *targ)
* the nice side effect that it avoids a lot of other problems.
*/
Lst lst = Lst_Init();
- Lst_AtEnd(lst, targ);
+ Lst_AppendS(lst, targ);
(void)Make_Run(lst);
Lst_Destroy(lst, NULL);
JobStart(targ, JOB_SPECIAL);
Index: src/usr.bin/make/lst.c
diff -u src/usr.bin/make/lst.c:1.22 src/usr.bin/make/lst.c:1.23
--- src/usr.bin/make/lst.c:1.22 Sat Aug 22 13:06:39 2020
+++ src/usr.bin/make/lst.c Sat Aug 22 13:28:20 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.22 2020/08/22 13:06:39 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.23 2020/08/22 13:28:20 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -37,11 +37,11 @@
#include "make.h"
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: lst.c,v 1.22 2020/08/22 13:06:39 rillig Exp $";
+static char rcsid[] = "$NetBSD: lst.c,v 1.23 2020/08/22 13:28:20 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: lst.c,v 1.22 2020/08/22 13:06:39 rillig Exp $");
+__RCSID("$NetBSD: lst.c,v 1.23 2020/08/22 13:28:20 rillig Exp $");
#endif /* not lint */
#endif
@@ -71,6 +71,8 @@ struct List {
LstNode prev; /* Previous node, if open. Used by Lst_Remove */
};
+static ReturnStatus Lst_AtEnd(Lst, void *);
+
static Boolean
LstIsValid(Lst list)
{
Index: src/usr.bin/make/lst.h
diff -u src/usr.bin/make/lst.h:1.29 src/usr.bin/make/lst.h:1.30
--- src/usr.bin/make/lst.h:1.29 Sat Aug 22 13:06:39 2020
+++ src/usr.bin/make/lst.h Sat Aug 22 13:28:20 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.h,v 1.29 2020/08/22 13:06:39 rillig Exp $ */
+/* $NetBSD: lst.h,v 1.30 2020/08/22 13:28:20 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -121,7 +121,6 @@ ReturnStatus Lst_InsertAfter(Lst, LstNod
ReturnStatus Lst_AtFront(Lst, void *);
void Lst_PrependS(Lst, void *);
/* Place an element at the end of a lst. */
-ReturnStatus Lst_AtEnd(Lst, void *);
void Lst_AppendS(Lst, void *);
/* Remove an element */
void Lst_RemoveS(Lst, LstNode);
Index: src/usr.bin/make/make.c
diff -u src/usr.bin/make/make.c:1.112 src/usr.bin/make/make.c:1.113
--- src/usr.bin/make/make.c:1.112 Sat Aug 22 13:06:39 2020
+++ src/usr.bin/make/make.c Sat Aug 22 13:28:20 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: make.c,v 1.112 2020/08/22 13:06:39 rillig Exp $ */
+/* $NetBSD: make.c,v 1.113 2020/08/22 13:28:20 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: make.c,v 1.112 2020/08/22 13:06:39 rillig Exp $";
+static char rcsid[] = "$NetBSD: make.c,v 1.113 2020/08/22 13:28:20 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)make.c 8.1 (Berkeley) 6/6/93";
#else
-__RCSID("$NetBSD: make.c,v 1.112 2020/08/22 13:06:39 rillig Exp $");
+__RCSID("$NetBSD: make.c,v 1.113 2020/08/22 13:28:20 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -1013,7 +1013,7 @@ MakeBuildChild(void *v_cn, void *toBeMad
cn->made = REQUESTED;
if (toBeMade_next == NULL)
- Lst_AtEnd(toBeMade, cn);
+ Lst_AppendS(toBeMade, cn);
else
Lst_InsertBefore(toBeMade, toBeMade_next, cn);
@@ -1347,8 +1347,8 @@ link_parent(void *cnp, void *pnp)
GNode *cn = cnp;
GNode *pn = pnp;
- Lst_AtEnd(pn->children, cn);
- Lst_AtEnd(cn->parents, pn);
+ Lst_AppendS(pn->children, cn);
+ Lst_AppendS(cn->parents, pn);
pn->unmade++;
return 0;
}
@@ -1370,9 +1370,9 @@ add_wait_dep(void *v_cn, void *v_wn)
fprintf(debug_file, ".WAIT: add dependency %s%s -> %s\n",
cn->name, cn->cohort_num, wn->name);
- Lst_AtEnd(wn->children, cn);
+ Lst_AppendS(wn->children, cn);
wn->unmade++;
- Lst_AtEnd(cn->parents, wn);
+ Lst_AppendS(cn->parents, wn);
return 0;
}
@@ -1403,7 +1403,7 @@ Make_ProcessWait(Lst targs)
MakeBuildChild(pgn, NULL);
examine = Lst_Init();
- Lst_AtEnd(examine, pgn);
+ Lst_AppendS(examine, pgn);
while (!Lst_IsEmpty (examine)) {
pgn = Lst_DeQueue(examine);
@@ -1432,7 +1432,7 @@ Make_ProcessWait(Lst targs)
Lst_ForEachFrom(pgn->children, owln, add_wait_dep, cgn);
owln = ln;
} else {
- Lst_AtEnd(examine, cgn);
+ Lst_AppendS(examine, cgn);
}
}
Lst_CloseS(pgn->children);
Index: src/usr.bin/make/meta.c
diff -u src/usr.bin/make/meta.c:1.94 src/usr.bin/make/meta.c:1.95
--- src/usr.bin/make/meta.c:1.94 Fri Aug 21 03:36:03 2020
+++ src/usr.bin/make/meta.c Sat Aug 22 13:28:20 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: meta.c,v 1.94 2020/08/21 03:36:03 rillig Exp $ */
+/* $NetBSD: meta.c,v 1.95 2020/08/22 13:28:20 rillig Exp $ */
/*
* Implement 'meta' mode.
@@ -1410,7 +1410,7 @@ meta_oodate(GNode *gn, Boolean oodate)
(link_src == NULL && cached_stat(p, &fs) < 0)) {
if (!meta_ignore(gn, p)) {
if (Lst_Find(missingFiles, p, string_match) == NULL)
- Lst_AtEnd(missingFiles, bmake_strdup(p));
+ Lst_AppendS(missingFiles, bmake_strdup(p));
}
}
break;
@@ -1496,7 +1496,7 @@ meta_oodate(GNode *gn, Boolean oodate)
* We cannot catch every eventuality here...
*/
if (Lst_Find(missingFiles, p, string_match) == NULL)
- Lst_AtEnd(missingFiles, bmake_strdup(p));
+ Lst_AppendS(missingFiles, bmake_strdup(p));
}
}
if (buf[0] == 'E') {
Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.253 src/usr.bin/make/parse.c:1.254
--- src/usr.bin/make/parse.c:1.253 Sat Aug 22 11:35:00 2020
+++ src/usr.bin/make/parse.c Sat Aug 22 13:28:20 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.253 2020/08/22 11:35:00 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.254 2020/08/22 13:28:20 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.253 2020/08/22 11:35:00 rillig Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.254 2020/08/22 13:28:20 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.253 2020/08/22 11:35:00 rillig Exp $");
+__RCSID("$NetBSD: parse.c,v 1.254 2020/08/22 13:28:20 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -3135,7 +3135,7 @@ Parse_File(const char *name, int fd)
cp = bmake_strdup(cp);
Lst_ForEach(targets, ParseAddCmd, cp);
#ifdef CLEANUP
- Lst_AtEnd(targCmds, cp);
+ Lst_AppendS(targCmds, cp);
#endif
}
}
Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.102 src/usr.bin/make/suff.c:1.103
--- src/usr.bin/make/suff.c:1.102 Sat Aug 22 11:35:00 2020
+++ src/usr.bin/make/suff.c Sat Aug 22 13:28:20 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: suff.c,v 1.102 2020/08/22 11:35:00 rillig Exp $ */
+/* $NetBSD: suff.c,v 1.103 2020/08/22 13:28:20 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: suff.c,v 1.102 2020/08/22 11:35:00 rillig Exp $";
+static char rcsid[] = "$NetBSD: suff.c,v 1.103 2020/08/22 13:28:20 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94";
#else
-__RCSID("$NetBSD: suff.c,v 1.102 2020/08/22 11:35:00 rillig Exp $");
+__RCSID("$NetBSD: suff.c,v 1.103 2020/08/22 13:28:20 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -1213,7 +1213,7 @@ SuffAddSrc(void *sp, void *lsp)
Lst_AppendS(ls->l, s2);
#ifdef DEBUG_SRC
s2->cp = Lst_Init();
- Lst_AtEnd(targ->cp, s2);
+ Lst_AppendS(targ->cp, s2);
fprintf(debug_file, "1 add %p %p to %p:", targ, s2, ls->l);
Lst_ForEach(ls->l, PrintAddr, NULL);
fprintf(debug_file, "\n");
@@ -1231,7 +1231,7 @@ SuffAddSrc(void *sp, void *lsp)
Lst_AppendS(ls->l, s2);
#ifdef DEBUG_SRC
s2->cp = Lst_Init();
- Lst_AtEnd(targ->cp, s2);
+ Lst_AppendS(targ->cp, s2);
fprintf(debug_file, "2 add %p %p to %p:", targ, s2, ls->l);
Lst_ForEach(ls->l, PrintAddr, NULL);
fprintf(debug_file, "\n");
@@ -1390,7 +1390,7 @@ SuffFindThem(Lst srcs, Lst slst)
}
SuffAddLevel(srcs, s);
- Lst_AtEnd(slst, s);
+ Lst_AppendS(slst, s);
}
if (DEBUG(SUFF) && rs) {
@@ -1496,9 +1496,9 @@ SuffFindCmds(Src *targ, Lst slst)
#ifdef DEBUG_SRC
ret->cp = Lst_Init();
fprintf(debug_file, "3 add %p %p\n", targ, ret);
- Lst_AtEnd(targ->cp, ret);
+ Lst_AppendS(targ->cp, ret);
#endif
- Lst_AtEnd(slst, ret);
+ Lst_AppendS(slst, ret);
if (DEBUG(SUFF)) {
fprintf(debug_file, "\tusing existing source %s\n", s->name);
}
@@ -2312,7 +2312,7 @@ sfnd_abort:
*/
while (bottom && bottom->parent != NULL) {
if (Lst_Member(slst, bottom) == NULL) {
- Lst_AtEnd(slst, bottom);
+ Lst_AppendS(slst, bottom);
}
bottom = bottom->parent;
}
@@ -2388,7 +2388,7 @@ sfnd_abort:
sfnd_return:
if (bottom)
if (Lst_Member(slst, bottom) == NULL)
- Lst_AtEnd(slst, bottom);
+ Lst_AppendS(slst, bottom);
while (SuffRemoveSrc(srcs) || SuffRemoveSrc(targs))
continue;
Index: src/usr.bin/make/targ.c
diff -u src/usr.bin/make/targ.c:1.68 src/usr.bin/make/targ.c:1.69
--- src/usr.bin/make/targ.c:1.68 Sat Aug 22 11:35:00 2020
+++ src/usr.bin/make/targ.c Sat Aug 22 13:28:20 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: targ.c,v 1.68 2020/08/22 11:35:00 rillig Exp $ */
+/* $NetBSD: targ.c,v 1.69 2020/08/22 13:28:20 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: targ.c,v 1.68 2020/08/22 11:35:00 rillig Exp $";
+static char rcsid[] = "$NetBSD: targ.c,v 1.69 2020/08/22 13:28:20 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)targ.c 8.2 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: targ.c,v 1.68 2020/08/22 11:35:00 rillig Exp $");
+__RCSID("$NetBSD: targ.c,v 1.69 2020/08/22 13:28:20 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -273,7 +273,7 @@ Targ_NewGN(const char *name)
#ifdef CLEANUP
if (allGNs == NULL)
allGNs = Lst_Init();
- Lst_AtEnd(allGNs, gn);
+ Lst_AppendS(allGNs, gn);
#endif
return gn;
@@ -401,7 +401,7 @@ Targ_FindList(Lst names, int flags)
gn = Targ_FindNode(name, flags);
if (gn != NULL) {
/*
- * Note: Lst_AtEnd must come before the Lst_Concat so the nodes
+ * Note: Lst_Append must come before the Lst_Concat so the nodes
* are added to the list in the order in which they were
* encountered in the makefile.
*/