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): handle special case of a list containi...
details: https://anonhg.NetBSD.org/src/rev/b42d83b0eaac
branches: trunk
changeset: 937670:b42d83b0eaac
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Aug 23 10:53:27 2020 +0000
description:
make(1): handle special case of a list containing null pointers
GNode.commands is the only place in make where a list can contain null
pointers. That's unexpected, and memory management in CompatRunCommand
looks suspicous enough to warrant extensive documentation.
diffstat:
usr.bin/make/compat.c | 12 +++++++-----
usr.bin/make/lst.c | 20 ++++++++++++++++----
usr.bin/make/lst.h | 5 +++--
3 files changed, 26 insertions(+), 11 deletions(-)
diffs (113 lines):
diff -r d0b6281f2e15 -r b42d83b0eaac usr.bin/make/compat.c
--- a/usr.bin/make/compat.c Sun Aug 23 10:27:22 2020 +0000
+++ b/usr.bin/make/compat.c Sun Aug 23 10:53:27 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat.c,v 1.126 2020/08/22 21:42:38 rillig Exp $ */
+/* $NetBSD: compat.c,v 1.127 2020/08/23 10:53:27 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: compat.c,v 1.126 2020/08/22 21:42:38 rillig Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.127 2020/08/23 10:53:27 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: compat.c,v 1.126 2020/08/22 21:42:38 rillig Exp $");
+__RCSID("$NetBSD: compat.c,v 1.127 2020/08/23 10:53:27 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -247,7 +247,7 @@
return 0;
}
cmd = cmdStart;
- Lst_ReplaceS(cmdNode, cmdStart);
+ LstNode_SetS(cmdNode, cmdStart);
if ((gn->type & OP_SAVE_CMDS) && (gn != ENDNode)) {
assert(ENDNode != NULL);
@@ -394,7 +394,9 @@
free(mav);
free(bp);
- Lst_ReplaceS(cmdNode, NULL);
+ /* XXX: Memory management looks suspicious here. */
+ /* XXX: Setting a list item to NULL is unexpected. */
+ LstNode_SetNullS(cmdNode);
#ifdef USE_META
if (useMeta) {
diff -r d0b6281f2e15 -r b42d83b0eaac usr.bin/make/lst.c
--- a/usr.bin/make/lst.c Sun Aug 23 10:27:22 2020 +0000
+++ b/usr.bin/make/lst.c Sun Aug 23 10:53:27 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.36 2020/08/22 23:06:51 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.37 2020/08/23 10:53:27 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.36 2020/08/22 23:06:51 rillig Exp $";
+static char rcsid[] = "$NetBSD: lst.c,v 1.37 2020/08/23 10:53:27 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: lst.c,v 1.36 2020/08/22 23:06:51 rillig Exp $");
+__RCSID("$NetBSD: lst.c,v 1.37 2020/08/23 10:53:27 rillig Exp $");
#endif /* not lint */
#endif
@@ -302,11 +302,23 @@
/* Replace the datum in the given node with the new datum. */
void
-Lst_ReplaceS(LstNode node, void *datum)
+LstNode_SetS(LstNode node, void *datum)
{
+ assert(LstNodeIsValid(node));
+ assert(datum != NULL);
+
node->datum = datum;
}
+/* Replace the datum in the given node to NULL. */
+void
+LstNode_SetNullS(LstNode node)
+{
+ assert(LstNodeIsValid(node));
+
+ node->datum = NULL;
+}
+
/*
* Node-specific functions
diff -r d0b6281f2e15 -r b42d83b0eaac usr.bin/make/lst.h
--- a/usr.bin/make/lst.h Sun Aug 23 10:27:22 2020 +0000
+++ b/usr.bin/make/lst.h Sun Aug 23 10:53:27 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.h,v 1.38 2020/08/22 22:57:53 rillig Exp $ */
+/* $NetBSD: lst.h,v 1.39 2020/08/23 10:53:27 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -120,7 +120,8 @@
/* Remove an element */
void Lst_RemoveS(Lst, LstNode);
/* Replace a node with a new value */
-void Lst_ReplaceS(LstNode, void *);
+void LstNode_SetS(LstNode node, void *datum);
+void LstNode_SetNullS(LstNode node);
void Lst_PrependAllS(Lst, Lst);
void Lst_AppendAllS(Lst, Lst);
void Lst_MoveAllS(Lst, Lst);
Home |
Main Index |
Thread Index |
Old Index