summaryrefslogtreecommitdiff
path: root/usr.bin/make/make.c
diff options
context:
space:
mode:
authorrillig <rillig@NetBSD.org>2020-09-24 06:45:59 +0000
committerrillig <rillig@NetBSD.org>2020-09-24 06:45:59 +0000
commitd26428226aaa14d02c0608ed588cfa080f536497 (patch)
treef5bade3d829335e61de35ccda6e45857e6bacb7d /usr.bin/make/make.c
parent1a84c72b43e32a844033098f55e19551b47343e9 (diff)
make(1): refactor add_wait_dep to not use Lst_ForEachFrom anymore
It was the last remaining use of that function outside of lst.c. While here, clean up the code of add_wait_dep by removing unreachable code (the GNode lists never contain NULL, only the GNode.commands lists do that).
Diffstat (limited to 'usr.bin/make/make.c')
-rw-r--r--usr.bin/make/make.c37
1 files changed, 16 insertions, 21 deletions
diff --git a/usr.bin/make/make.c b/usr.bin/make/make.c
index f1e69107ec9..af079c7bca6 100644
--- a/usr.bin/make/make.c
+++ b/usr.bin/make/make.c
@@ -1,4 +1,4 @@
-/* $NetBSD: make.c,v 1.138 2020/09/22 20:19:46 rillig Exp $ */
+/* $NetBSD: make.c,v 1.139 2020/09/24 06:45:59 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -107,7 +107,7 @@
#include "job.h"
/* "@(#)make.c 8.1 (Berkeley) 6/6/93" */
-MAKE_RCSID("$NetBSD: make.c,v 1.138 2020/09/22 20:19:46 rillig Exp $");
+MAKE_RCSID("$NetBSD: make.c,v 1.139 2020/09/24 06:45:59 rillig Exp $");
static unsigned int checked = 1;/* Sequence # to detect recursion */
static GNodeList *toBeMade; /* The current fringe of the graph. These
@@ -1372,27 +1372,23 @@ link_parent(void *cnp, void *pnp)
return 0;
}
-static int
-add_wait_dep(void *v_cn, void *v_wn)
+/* Make the .WAIT node depend on the previous children */
+static void
+add_wait_dependency(GNodeListNode *owln, GNode *wn)
{
- GNode *cn = v_cn;
- GNode *wn = v_wn;
+ GNodeListNode *cln;
+ GNode *cn;
- if (cn == wn)
- return 1;
+ for (cln = owln; (cn = LstNode_Datum(cln)) != wn; cln = LstNode_Next(cln)) {
+ if (DEBUG(MAKE))
+ fprintf(debug_file, ".WAIT: add dependency %s%s -> %s\n",
+ cn->name, cn->cohort_num, wn->name);
- if (cn == NULL || wn == NULL) {
- printf("bad wait dep %p %p\n", cn, wn);
- exit(4);
+ /* XXX: This pattern should be factored out, it repeats often */
+ Lst_Append(wn->children, cn);
+ wn->unmade++;
+ Lst_Append(cn->parents, wn);
}
- if (DEBUG(MAKE))
- fprintf(debug_file, ".WAIT: add dependency %s%s -> %s\n",
- cn->name, cn->cohort_num, wn->name);
-
- Lst_Append(wn->children, cn);
- wn->unmade++;
- Lst_Append(cn->parents, wn);
- return 0;
}
static void
@@ -1442,8 +1438,7 @@ Make_ProcessWait(GNodeList *targs)
for (; (ln = Lst_Next(pgn->children)) != NULL; ) {
cgn = LstNode_Datum(ln);
if (cgn->type & OP_WAIT) {
- /* Make the .WAIT node depend on the previous children */
- Lst_ForEachFrom(pgn->children, owln, add_wait_dep, cgn);
+ add_wait_dependency(owln, cgn);
owln = ln;
} else {
Lst_Append(examine, cgn);