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): make srclist a local variable
details: https://anonhg.NetBSD.org/src/rev/ca1d82c2ee16
branches: trunk
changeset: 946253:ca1d82c2ee16
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Nov 21 20:55:45 2020 +0000
description:
make(1): make srclist a local variable
In all current unit tests, the variable srclist was empty both when
entering Suff_FindDeps and when leaving it. Since that's the only
function that used this variable, it has been converted to a local
variable instead, to limit its scope.
To protect against accidental implementation mistakes, an assertion has
been added to ensure that at the end, everything could be cleaned up
properly. This assertion was missing before, and if there had really
been a case where the list were non-empty, make would have resolved
completely wrong candidates for the implied sources.
diffstat:
usr.bin/make/suff.c | 18 ++++++++----------
1 files changed, 8 insertions(+), 10 deletions(-)
diffs (63 lines):
diff -r d3c202fefcd5 -r ca1d82c2ee16 usr.bin/make/suff.c
--- a/usr.bin/make/suff.c Sat Nov 21 20:50:08 2020 +0000
+++ b/usr.bin/make/suff.c Sat Nov 21 20:55:45 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: suff.c,v 1.276 2020/11/21 20:20:31 rillig Exp $ */
+/* $NetBSD: suff.c,v 1.277 2020/11/21 20:55:45 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -114,7 +114,7 @@
#include "dir.h"
/* "@(#)suff.c 8.4 (Berkeley) 3/21/94" */
-MAKE_RCSID("$NetBSD: suff.c,v 1.276 2020/11/21 20:20:31 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.277 2020/11/21 20:55:45 rillig Exp $");
#define SUFF_DEBUG0(text) DEBUG0(SUFF, text)
#define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1)
@@ -131,10 +131,6 @@
static SuffixList *suffClean; /* List of suffixes to be cleaned */
#endif
-/* XXX: What exactly is this variable used for? */
-/* XXX: Does it really have to be a global variable? */
-static SrcList *srclist;
-
/* List of transformation rules, such as ".c.o" */
static GNodeList *transforms;
@@ -1894,11 +1890,15 @@
void
Suff_FindDeps(GNode *gn)
{
+ SrcList *srcs = Lst_New();
- SuffFindDeps(gn, srclist);
+ SuffFindDeps(gn, srcs);
- while (SuffRemoveSrc(srclist))
+ while (SuffRemoveSrc(srcs))
continue;
+
+ assert(Lst_IsEmpty(srcs));
+ Lst_Free(srcs);
}
static void
@@ -1981,7 +1981,6 @@
suffClean = Lst_New();
sufflist = Lst_New();
#endif
- srclist = Lst_New();
transforms = Lst_New();
/*
@@ -2002,7 +2001,6 @@
Lst_Destroy(suffClean, SuffFree);
if (nullSuff != NULL)
SuffFree(nullSuff);
- Lst_Free(srclist);
Lst_Free(transforms);
#endif
}
Home |
Main Index |
Thread Index |
Old Index