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): assert correct usage of the Lst_Open API
details: https://anonhg.NetBSD.org/src/rev/1261a6ef518e
branches: trunk
changeset: 937547:1261a6ef518e
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Aug 21 04:09:12 2020 +0000
description:
make(1): assert correct usage of the Lst_Open API
All calls to Lst_Next are properly protected by Lst_Open, so there is no
possible assertion failure here.
diffstat:
usr.bin/make/arch.c | 8 ++++----
usr.bin/make/dir.c | 20 ++++++++++----------
usr.bin/make/lst.c | 14 ++++++--------
usr.bin/make/lst.h | 4 ++--
usr.bin/make/make.c | 14 +++++++-------
usr.bin/make/suff.c | 14 +++++++-------
usr.bin/make/targ.c | 8 ++++----
7 files changed, 40 insertions(+), 42 deletions(-)
diffs (truncated from 343 to 300 lines):
diff -r 162b630df79e -r 1261a6ef518e usr.bin/make/arch.c
--- a/usr.bin/make/arch.c Fri Aug 21 03:44:58 2020 +0000
+++ b/usr.bin/make/arch.c Fri Aug 21 04:09:12 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: arch.c,v 1.84 2020/08/21 02:20:47 rillig Exp $ */
+/* $NetBSD: arch.c,v 1.85 2020/08/21 04:09:12 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: arch.c,v 1.84 2020/08/21 02:20:47 rillig Exp $";
+static char rcsid[] = "$NetBSD: arch.c,v 1.85 2020/08/21 04:09:12 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.84 2020/08/21 02:20:47 rillig Exp $");
+__RCSID("$NetBSD: arch.c,v 1.85 2020/08/21 04:09:12 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -1130,7 +1130,7 @@
gn->mtime = 0;
return 0;
}
- while ((ln = Lst_Next(gn->parents)) != NULL) {
+ while ((ln = Lst_NextS(gn->parents)) != NULL) {
pgn = (GNode *)Lst_Datum(ln);
if (pgn->type & OP_ARCHV) {
diff -r 162b630df79e -r 1261a6ef518e usr.bin/make/dir.c
--- a/usr.bin/make/dir.c Fri Aug 21 03:44:58 2020 +0000
+++ b/usr.bin/make/dir.c Fri Aug 21 04:09:12 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.94 2020/08/21 03:36:03 rillig Exp $ */
+/* $NetBSD: dir.c,v 1.95 2020/08/21 04:09:12 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: dir.c,v 1.94 2020/08/21 03:36:03 rillig Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.95 2020/08/21 04:09:12 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94";
#else
-__RCSID("$NetBSD: dir.c,v 1.94 2020/08/21 03:36:03 rillig Exp $");
+__RCSID("$NetBSD: dir.c,v 1.95 2020/08/21 04:09:12 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -509,7 +509,7 @@
Var_Append(".PATH", cur->name, VAR_GLOBAL);
}
- while ((ln = Lst_Next(dirSearchPath)) != NULL) {
+ while ((ln = Lst_NextS(dirSearchPath)) != NULL) {
p = (Path *)Lst_Datum(ln);
if (p == dotLast)
continue;
@@ -813,7 +813,7 @@
Path *p; /* Directory in the node */
if (Lst_Open(path) == SUCCESS) {
- while ((ln = Lst_Next(path)) != NULL) {
+ while ((ln = Lst_NextS(path)) != NULL) {
p = (Path *)Lst_Datum(ln);
DirMatchFiles(word, p, expansions);
}
@@ -1185,7 +1185,7 @@
return file;
}
- while ((ln = Lst_Next(path)) != NULL) {
+ while ((ln = Lst_NextS(path)) != NULL) {
p = (Path *)Lst_Datum(ln);
if (p == dotLast)
continue;
@@ -1243,7 +1243,7 @@
}
(void)Lst_Open(path);
- while ((ln = Lst_Next(path)) != NULL) {
+ while ((ln = Lst_NextS(path)) != NULL) {
p = (Path *)Lst_Datum(ln);
if (p == dotLast)
continue;
@@ -1301,7 +1301,7 @@
}
(void)Lst_Open(path);
- while ((ln = Lst_Next(path)) != NULL) {
+ while ((ln = Lst_NextS(path)) != NULL) {
p = (Path *)Lst_Datum(ln);
if (p == dotLast)
continue;
@@ -1679,7 +1679,7 @@
Buf_Init(&buf, 0);
if (Lst_Open(path) == SUCCESS) {
- while ((ln = Lst_Next(path)) != NULL) {
+ while ((ln = Lst_NextS(path)) != NULL) {
Path *p = (Path *)Lst_Datum(ln);
Buf_AddStr(&buf, " ");
Buf_AddStr(&buf, flag);
@@ -1803,7 +1803,7 @@
hits * 100 / (hits + bigmisses + nearmisses) : 0));
fprintf(debug_file, "# %-20s referenced\thits\n", "directory");
if (Lst_Open(openDirectories) == SUCCESS) {
- while ((ln = Lst_Next(openDirectories)) != NULL) {
+ while ((ln = Lst_NextS(openDirectories)) != NULL) {
p = (Path *)Lst_Datum(ln);
fprintf(debug_file, "# %-20s %10d\t%4d\n", p->name, p->refCount,
p->hits);
diff -r 162b630df79e -r 1261a6ef518e usr.bin/make/lst.c
--- a/usr.bin/make/lst.c Fri Aug 21 03:44:58 2020 +0000
+++ b/usr.bin/make/lst.c Fri Aug 21 04:09:12 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.8 2020/08/21 03:36:03 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.9 2020/08/21 04:09:12 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -38,11 +38,11 @@
#include "make_malloc.h"
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: lst.c,v 1.8 2020/08/21 03:36:03 rillig Exp $";
+static char rcsid[] = "$NetBSD: lst.c,v 1.9 2020/08/21 04:09:12 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: lst.c,v 1.8 2020/08/21 03:36:03 rillig Exp $");
+__RCSID("$NetBSD: lst.c,v 1.9 2020/08/21 04:09:12 rillig Exp $");
#endif /* not lint */
#endif
@@ -922,15 +922,13 @@
*-----------------------------------------------------------------------
*/
LstNode
-Lst_Next(Lst l)
+Lst_NextS(Lst l)
{
ListNode tln;
List list = l;
- if ((LstValid(l) == FALSE) ||
- (list->isOpen == FALSE)) {
- return NULL;
- }
+ assert(LstValid(l));
+ assert(list->isOpen);
list->prevPtr = list->curPtr;
diff -r 162b630df79e -r 1261a6ef518e usr.bin/make/lst.h
--- a/usr.bin/make/lst.h Fri Aug 21 03:44:58 2020 +0000
+++ b/usr.bin/make/lst.h Fri Aug 21 04:09:12 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.h,v 1.24 2020/08/21 03:36:03 rillig Exp $ */
+/* $NetBSD: lst.h,v 1.25 2020/08/21 04:09:12 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -168,7 +168,7 @@
/* Open the list */
ReturnStatus Lst_Open(Lst);
/* Next element please, or NULL */
-LstNode Lst_Next(Lst);
+LstNode Lst_NextS(Lst);
/* Finish table access */
void Lst_Close(Lst);
diff -r 162b630df79e -r 1261a6ef518e usr.bin/make/make.c
--- a/usr.bin/make/make.c Fri Aug 21 03:44:58 2020 +0000
+++ b/usr.bin/make/make.c Fri Aug 21 04:09:12 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: make.c,v 1.105 2020/08/21 03:36:03 rillig Exp $ */
+/* $NetBSD: make.c,v 1.106 2020/08/21 04:09:12 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: make.c,v 1.105 2020/08/21 03:36:03 rillig Exp $";
+static char rcsid[] = "$NetBSD: make.c,v 1.106 2020/08/21 04:09:12 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.105 2020/08/21 03:36:03 rillig Exp $");
+__RCSID("$NetBSD: make.c,v 1.106 2020/08/21 04:09:12 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -470,7 +470,7 @@
}
if (Lst_Open(cgn->children) == SUCCESS) {
- while ((ln = Lst_Next(cgn->children)) != NULL) {
+ while ((ln = Lst_NextS(cgn->children)) != NULL) {
GNode *tgn, *gn = (GNode *)Lst_Datum(ln);
/*
@@ -725,7 +725,7 @@
/* Now mark all the parents as having one less unmade child */
if (Lst_Open(parents) == SUCCESS) {
- while ((ln = Lst_Next(parents)) != NULL) {
+ while ((ln = Lst_NextS(parents)) != NULL) {
pgn = (GNode *)Lst_Datum(ln);
if (DEBUG(MAKE))
fprintf(debug_file, "inspect parent %s%s: flags %x, "
@@ -828,7 +828,7 @@
if (Lst_Open(cgn->iParents) == SUCCESS) {
const char *cpref = Var_Value(PREFIX, cgn, &p1);
- while ((ln = Lst_Next(cgn->iParents)) != NULL) {
+ while ((ln = Lst_NextS(cgn->iParents)) != NULL) {
pgn = (GNode *)Lst_Datum(ln);
if (pgn->flags & REMAKE) {
Var_Set(IMPSRC, cname, pgn);
@@ -1447,7 +1447,7 @@
owln = Lst_First(pgn->children);
Lst_Open(pgn->children);
- for (; (ln = Lst_Next(pgn->children)) != NULL; ) {
+ for (; (ln = Lst_NextS(pgn->children)) != NULL; ) {
cgn = Lst_Datum(ln);
if (cgn->type & OP_WAIT) {
/* Make the .WAIT node depend on the previous children */
diff -r 162b630df79e -r 1261a6ef518e usr.bin/make/suff.c
--- a/usr.bin/make/suff.c Fri Aug 21 03:44:58 2020 +0000
+++ b/usr.bin/make/suff.c Fri Aug 21 04:09:12 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: suff.c,v 1.98 2020/08/21 03:36:03 rillig Exp $ */
+/* $NetBSD: suff.c,v 1.99 2020/08/21 04:09:12 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: suff.c,v 1.98 2020/08/21 03:36:03 rillig Exp $";
+static char rcsid[] = "$NetBSD: suff.c,v 1.99 2020/08/21 04:09:12 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.98 2020/08/21 03:36:03 rillig Exp $");
+__RCSID("$NetBSD: suff.c,v 1.99 2020/08/21 04:09:12 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -502,7 +502,7 @@
if (Lst_Open(l) == FAILURE) {
return;
}
- while ((ln = Lst_Next(l)) != NULL) {
+ while ((ln = Lst_NextS(l)) != NULL) {
s2 = (Suff *)Lst_Datum(ln);
if (s2->sNum >= s->sNum) {
break;
@@ -1076,7 +1076,7 @@
inIncludes = Lst_Init();
inLibs = Lst_Init();
- while ((ln = Lst_Next(sufflist)) != NULL) {
+ while ((ln = Lst_NextS(sufflist)) != NULL) {
s = (Suff *)Lst_Datum(ln);
if (!Lst_IsEmpty (s->searchPath)) {
#ifdef INCLUDES
@@ -1301,7 +1301,7 @@
#endif
- while ((ln = Lst_Next(l)) != NULL) {
+ while ((ln = Lst_NextS(l)) != NULL) {
s = (Src *)Lst_Datum(ln);
if (s->children == 0) {
free(s->file);
@@ -1439,7 +1439,7 @@
Home |
Main Index |
Thread Index |
Old Index