CVS commit: src/distrib/sets/lists/tests

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Dec  7 07:51:25 UTC 2020

Modified Files:
src/distrib/sets/lists/tests: mi

Log Message:
make(1): add new unit test opt-keep-going-multiple.mk to file lists


To generate a diff of this commit:
cvs rdiff -u -r1.983 -r1.984 src/distrib/sets/lists/tests/mi

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.983 src/distrib/sets/lists/tests/mi:1.984
--- src/distrib/sets/lists/tests/mi:1.983	Sun Dec  6 21:22:04 2020
+++ src/distrib/sets/lists/tests/mi	Mon Dec  7 07:51:25 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.983 2020/12/06 21:22:04 rillig Exp $
+# $NetBSD: mi,v 1.984 2020/12/07 07:51:25 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -5219,6 +5219,8 @@
 ./usr/tests/usr.bin/make/unit-tests/opt-jobs-internal.mk			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/opt-jobs.exptests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/opt-jobs.mk	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/opt-keep-going-multiple.exp			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/opt-keep-going-multiple.mk			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/opt-keep-going.exptests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/opt-keep-going.mktests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/opt-m-include-dir.exp			tests-usr.bin-tests	compattestfile,atf



CVS commit: src/sys/kern

2020-12-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Dec  7 03:01:15 UTC 2020

Modified Files:
src/sys/kern: kern_time.c

Log Message:
fix the build; gcc does not always see that it can't happen.


To generate a diff of this commit:
cvs rdiff -u -r1.208 -r1.209 src/sys/kern/kern_time.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/kern_time.c
diff -u src/sys/kern/kern_time.c:1.208 src/sys/kern/kern_time.c:1.209
--- src/sys/kern/kern_time.c:1.208	Sun Dec  6 08:45:58 2020
+++ src/sys/kern/kern_time.c	Sun Dec  6 22:01:15 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_time.c,v 1.208 2020/12/06 13:45:58 thorpej Exp $	*/
+/*	$NetBSD: kern_time.c,v 1.209 2020/12/07 03:01:15 christos Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2004, 2005, 2007, 2008, 2009, 2020
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.208 2020/12/06 13:45:58 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.209 2020/12/07 03:01:15 christos Exp $");
 
 #include 
 #include 
@@ -1649,6 +1649,8 @@ dosetitimer(struct proc *p, int which, s
 			itl = >pts_prof;
 			pt->pt_ev.sigev_signo = SIGPROF;
 			break;
+		default:
+			panic("%s: can't happen %d", __func__, which);
 		}
 		itimer_init(it, _itimer_ops, which, itl);
 		pt->pt_proc = p;



CVS commit: src/usr.bin/make

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Dec  7 01:50:19 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): rename Var_Export1 to ExportVar

Since Var_Export1 is neither exported by the module nor does it belong
to the Var type, the previous function name was misleading.  The 1 in
the function name was not as expressive as possible.  The new name
aligns nicely with UnexportVar, which is a very young name as well.


To generate a diff of this commit:
cvs rdiff -u -r1.718 -r1.719 src/usr.bin/make/var.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/var.c
diff -u src/usr.bin/make/var.c:1.718 src/usr.bin/make/var.c:1.719
--- src/usr.bin/make/var.c:1.718	Sun Dec  6 18:13:17 2020
+++ src/usr.bin/make/var.c	Mon Dec  7 01:50:19 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.718 2020/12/06 18:13:17 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.719 2020/12/07 01:50:19 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -130,7 +130,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.718 2020/12/06 18:13:17 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.719 2020/12/07 01:50:19 rillig Exp $");
 
 /* A string that may need to be freed after use. */
 typedef struct FStr {
@@ -219,7 +219,7 @@ typedef enum VarExportFlags {
 	 */
 	VAR_EXPORT_PARENT = 0x01,
 	/*
-	 * We pass this to Var_Export1 to tell it to leave the value alone.
+	 * We pass this to ExportVar to tell it to leave the value alone.
 	 */
 	VAR_EXPORT_LITERAL = 0x02
 } VarExportFlags;
@@ -565,7 +565,7 @@ MayExport(const char *name)
  * We only manipulate flags of vars if 'parent' is set.
  */
 static Boolean
-Var_Export1(const char *name, VarExportFlags flags)
+ExportVar(const char *name, VarExportFlags flags)
 {
 	Boolean parent = (flags & VAR_EXPORT_PARENT) != 0;
 	Var *v;
@@ -651,7 +651,7 @@ Var_ExportVars(void)
 		HashIter_Init(, _GLOBAL->vars);
 		while (HashIter_Next() != NULL) {
 			Var *var = hi.entry->value;
-			Var_Export1(var->name.str, VAR_EXPORT_NORMAL);
+			ExportVar(var->name.str, VAR_EXPORT_NORMAL);
 		}
 		return;
 	}
@@ -664,7 +664,7 @@ Var_ExportVars(void)
 		size_t i;
 
 		for (i = 0; i < words.len; i++)
-			Var_Export1(words.words[i], VAR_EXPORT_NORMAL);
+			ExportVar(words.words[i], VAR_EXPORT_NORMAL);
 		Words_Free(words);
 	}
 	free(val);
@@ -707,7 +707,7 @@ Var_Export(const char *str, Boolean isEx
 		size_t i;
 		for (i = 0; i < words.len; i++) {
 			const char *name = words.words[i];
-			if (Var_Export1(name, flags)) {
+			if (ExportVar(name, flags)) {
 if (var_exportedVars == VAR_EXPORTED_NONE)
 	var_exportedVars = VAR_EXPORTED_SOME;
 if (isExport && (flags & VAR_EXPORT_PARENT)) {
@@ -910,7 +910,7 @@ Var_SetWithFlags(const char *name, const
 
 		DEBUG3(VAR, "%s:%s = %s\n", ctxt->name, name, val);
 		if (v->flags & VAR_EXPORTED)
-			Var_Export1(name, VAR_EXPORT_PARENT);
+			ExportVar(name, VAR_EXPORT_PARENT);
 	}
 	/*
 	 * Any variables given on the command line are automatically exported



CVS commit: src/usr.bin/make

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Dec  7 01:35:33 UTC 2020

Modified Files:
src/usr.bin/make: compat.c
src/usr.bin/make/unit-tests: opt-keep-going-multiple.exp opt.exp

Log Message:
make(1): fix wrong exit status for multiple failed main targets


To generate a diff of this commit:
cvs rdiff -u -r1.203 -r1.204 src/usr.bin/make/compat.c
cvs rdiff -u -r1.1 -r1.2 \
src/usr.bin/make/unit-tests/opt-keep-going-multiple.exp
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/opt.exp

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/compat.c
diff -u src/usr.bin/make/compat.c:1.203 src/usr.bin/make/compat.c:1.204
--- src/usr.bin/make/compat.c:1.203	Mon Dec  7 01:32:04 2020
+++ src/usr.bin/make/compat.c	Mon Dec  7 01:35:33 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.203 2020/12/07 01:32:04 rillig Exp $	*/
+/*	$NetBSD: compat.c,v 1.204 2020/12/07 01:35:33 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -96,7 +96,7 @@
 #include "pathnames.h"
 
 /*	"@(#)compat.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: compat.c,v 1.203 2020/12/07 01:32:04 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.204 2020/12/07 01:35:33 rillig Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
@@ -714,21 +714,12 @@ Compat_Run(GNodeList *targs)
 		} else if (gn->made == ABORTED) {
 			printf("`%s' not remade because of errors.\n",
 			   gn->name);
-			seenError = TRUE;
 		}
+		if (GNode_IsError(gn))
+			seenError = TRUE;
 	}
 
-	/*
-	 * XXX: what about multiple main targets if the first few fail but
-	 * the last one succeeds?  This should not count as overall success.
-	 * See opt-keep-going-multiple.mk.
-	 */
-	if (GNode_IsError(gn))
-		seenError = TRUE;
-
-	/*
-	 * If the user has defined a .END target, run its commands.
-	 */
+	/* If the user has defined a .END target, run its commands. */
 	if (!seenError) {
 		GNode *endNode = Targ_GetEndNode();
 		Compat_Make(endNode, endNode);

Index: src/usr.bin/make/unit-tests/opt-keep-going-multiple.exp
diff -u src/usr.bin/make/unit-tests/opt-keep-going-multiple.exp:1.1 src/usr.bin/make/unit-tests/opt-keep-going-multiple.exp:1.2
--- src/usr.bin/make/unit-tests/opt-keep-going-multiple.exp:1.1	Mon Dec  7 01:32:04 2020
+++ src/usr.bin/make/unit-tests/opt-keep-going-multiple.exp	Mon Dec  7 01:35:33 2020
@@ -3,5 +3,7 @@ false fail1
 false fail2
 *** Error code 1 (continuing)
 true succeed
-: The end.
-exit status 0
+
+Stop.
+make: stopped in unit-tests
+exit status 1

Index: src/usr.bin/make/unit-tests/opt.exp
diff -u src/usr.bin/make/unit-tests/opt.exp:1.7 src/usr.bin/make/unit-tests/opt.exp:1.8
--- src/usr.bin/make/unit-tests/opt.exp:1.7	Wed Nov 18 01:06:59 2020
+++ src/usr.bin/make/unit-tests/opt.exp	Mon Dec  7 01:35:33 2020
@@ -12,6 +12,10 @@ make -r -f /dev/null -- -VAR=value -f /d
 make: don't know how to make -f (continuing)
 `/dev/null' is up to date.
 
+Stop.
+make: stopped in unit-tests
+*** Error code 1 (ignored)
+
 make -?
 usage: make [-BeikNnqrSstWwX]
 [-C directory] [-D variable] [-d flags] [-f makefile]



CVS commit: src/usr.bin/make

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Dec  7 01:32:05 UTC 2020

Modified Files:
src/usr.bin/make: compat.c
src/usr.bin/make/unit-tests: Makefile
Added Files:
src/usr.bin/make/unit-tests: opt-keep-going-multiple.exp
opt-keep-going-multiple.mk

Log Message:
make(1): add test for wrong exit status 0 after failed targets with -k


To generate a diff of this commit:
cvs rdiff -u -r1.202 -r1.203 src/usr.bin/make/compat.c
cvs rdiff -u -r1.237 -r1.238 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 \
src/usr.bin/make/unit-tests/opt-keep-going-multiple.exp \
src/usr.bin/make/unit-tests/opt-keep-going-multiple.mk

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/compat.c
diff -u src/usr.bin/make/compat.c:1.202 src/usr.bin/make/compat.c:1.203
--- src/usr.bin/make/compat.c:1.202	Mon Dec  7 01:10:03 2020
+++ src/usr.bin/make/compat.c	Mon Dec  7 01:32:04 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.202 2020/12/07 01:10:03 rillig Exp $	*/
+/*	$NetBSD: compat.c,v 1.203 2020/12/07 01:32:04 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -96,7 +96,7 @@
 #include "pathnames.h"
 
 /*	"@(#)compat.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: compat.c,v 1.202 2020/12/07 01:10:03 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.203 2020/12/07 01:32:04 rillig Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
@@ -721,6 +721,7 @@ Compat_Run(GNodeList *targs)
 	/*
 	 * XXX: what about multiple main targets if the first few fail but
 	 * the last one succeeds?  This should not count as overall success.
+	 * See opt-keep-going-multiple.mk.
 	 */
 	if (GNode_IsError(gn))
 		seenError = TRUE;

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.237 src/usr.bin/make/unit-tests/Makefile:1.238
--- src/usr.bin/make/unit-tests/Makefile:1.237	Sun Dec  6 21:22:04 2020
+++ src/usr.bin/make/unit-tests/Makefile	Mon Dec  7 01:32:04 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.237 2020/12/06 21:22:04 rillig Exp $
+# $NetBSD: Makefile,v 1.238 2020/12/07 01:32:04 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -237,6 +237,7 @@ TESTS+=		opt-include-dir
 TESTS+=		opt-jobs
 TESTS+=		opt-jobs-internal
 TESTS+=		opt-keep-going
+TESTS+=		opt-keep-going-multiple
 TESTS+=		opt-m-include-dir
 TESTS+=		opt-no-action
 TESTS+=		opt-no-action-at-all

Added files:

Index: src/usr.bin/make/unit-tests/opt-keep-going-multiple.exp
diff -u /dev/null src/usr.bin/make/unit-tests/opt-keep-going-multiple.exp:1.1
--- /dev/null	Mon Dec  7 01:32:05 2020
+++ src/usr.bin/make/unit-tests/opt-keep-going-multiple.exp	Mon Dec  7 01:32:04 2020
@@ -0,0 +1,7 @@
+false fail1
+*** Error code 1 (continuing)
+false fail2
+*** Error code 1 (continuing)
+true succeed
+: The end.
+exit status 0
Index: src/usr.bin/make/unit-tests/opt-keep-going-multiple.mk
diff -u /dev/null src/usr.bin/make/unit-tests/opt-keep-going-multiple.mk:1.1
--- /dev/null	Mon Dec  7 01:32:05 2020
+++ src/usr.bin/make/unit-tests/opt-keep-going-multiple.mk	Mon Dec  7 01:32:04 2020
@@ -0,0 +1,21 @@
+# $NetBSD: opt-keep-going-multiple.mk,v 1.1 2020/12/07 01:32:04 rillig Exp $
+#
+# Tests for the -k command line option, which stops building a target as soon
+# as an error is detected, but continues building the other, independent
+# targets, as far as possible.
+#
+# Until 2020-12-07, the exit status of make depended only on the last of the
+# main targets.  Even if the first few targets could not be made, make
+# nevertheless exited with status 0.
+
+.MAKEFLAGS: -k
+.MAKEFLAGS: fail1 fail2 succeed
+
+fail1 fail2: .PHONY
+	false ${.TARGET}
+
+succeed: .PHONY
+	true ${.TARGET}
+
+.END:
+	: The end.



CVS commit: src/usr.bin/make

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Dec  7 01:27:08 UTC 2020

Modified Files:
src/usr.bin/make: suff.c

Log Message:
make(1): actually fix the use-after-free bug and the double-free

The use-after-free bug had been there since 2020-11-22, the double-free
bug since a few minutes.


To generate a diff of this commit:
cvs rdiff -u -r1.328 -r1.329 src/usr.bin/make/suff.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/suff.c
diff -u src/usr.bin/make/suff.c:1.328 src/usr.bin/make/suff.c:1.329
--- src/usr.bin/make/suff.c:1.328	Mon Dec  7 01:24:41 2020
+++ src/usr.bin/make/suff.c	Mon Dec  7 01:27:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.328 2020/12/07 01:24:41 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.329 2020/12/07 01:27:08 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.328 2020/12/07 01:24:41 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.329 2020/12/07 01:27:08 rillig Exp $");
 
 typedef List SuffixList;
 typedef ListNode SuffixListNode;
@@ -1068,7 +1068,6 @@ RemoveCandidate(CandidateList *srcs)
 		Candidate *src = ln->datum;
 
 		if (src->numChildren == 0) {
-			free(src->file);
 			if (src->parent == NULL)
 free(src->prefix);
 			else {



CVS commit: src/usr.bin/make

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Dec  7 01:24:41 UTC 2020

Modified Files:
src/usr.bin/make: suff.c

Log Message:
make(1): fix use-after-free in -DDEBUG_SRC mode (since 2020-11-22)


To generate a diff of this commit:
cvs rdiff -u -r1.327 -r1.328 src/usr.bin/make/suff.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/suff.c
diff -u src/usr.bin/make/suff.c:1.327 src/usr.bin/make/suff.c:1.328
--- src/usr.bin/make/suff.c:1.327	Sun Dec  6 10:49:02 2020
+++ src/usr.bin/make/suff.c	Mon Dec  7 01:24:41 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.327 2020/12/06 10:49:02 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.328 2020/12/07 01:24:41 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.327 2020/12/06 10:49:02 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.328 2020/12/07 01:24:41 rillig Exp $");
 
 typedef List SuffixList;
 typedef ListNode SuffixListNode;
@@ -1089,6 +1089,7 @@ RemoveCandidate(CandidateList *srcs)
 			Lst_Done(>childrenList);
 #endif
 			Lst_Remove(srcs, ln);
+			free(src->file);
 			free(src);
 			return TRUE;
 		}



CVS commit: src/usr.bin/make

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Dec  7 01:10:03 UTC 2020

Modified Files:
src/usr.bin/make: compat.c

Log Message:
make(1): merge local variables in Compat_Run


To generate a diff of this commit:
cvs rdiff -u -r1.201 -r1.202 src/usr.bin/make/compat.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/compat.c
diff -u src/usr.bin/make/compat.c:1.201 src/usr.bin/make/compat.c:1.202
--- src/usr.bin/make/compat.c:1.201	Mon Dec  7 01:07:13 2020
+++ src/usr.bin/make/compat.c	Mon Dec  7 01:10:03 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.201 2020/12/07 01:07:13 rillig Exp $	*/
+/*	$NetBSD: compat.c,v 1.202 2020/12/07 01:10:03 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -96,7 +96,7 @@
 #include "pathnames.h"
 
 /*	"@(#)compat.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: compat.c,v 1.201 2020/12/07 01:07:13 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.202 2020/12/07 01:10:03 rillig Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
@@ -664,8 +664,7 @@ void
 Compat_Run(GNodeList *targs)
 {
 	GNode *gn = NULL;	/* Current root target */
-	Boolean mainError;
-	Boolean endError;
+	Boolean seenError;
 
 	if (!shellName)
 		Shell_Init();
@@ -705,7 +704,7 @@ Compat_Run(GNodeList *targs)
 	 */
 	Make_ExpandUse(targs);
 
-	mainError = FALSE;
+	seenError = FALSE;
 	while (!Lst_IsEmpty(targs)) {
 		gn = Lst_Dequeue(targs);
 		Compat_Make(gn, gn);
@@ -715,7 +714,7 @@ Compat_Run(GNodeList *targs)
 		} else if (gn->made == ABORTED) {
 			printf("`%s' not remade because of errors.\n",
 			   gn->name);
-			mainError = TRUE;
+			seenError = TRUE;
 		}
 	}
 
@@ -724,19 +723,18 @@ Compat_Run(GNodeList *targs)
 	 * the last one succeeds?  This should not count as overall success.
 	 */
 	if (GNode_IsError(gn))
-		mainError = TRUE;
+		seenError = TRUE;
 
 	/*
 	 * If the user has defined a .END target, run its commands.
 	 */
-	if (!mainError) {
+	if (!seenError) {
 		GNode *endNode = Targ_GetEndNode();
 		Compat_Make(endNode, endNode);
-		endError = GNode_IsError(endNode);
-	} else
-		endError = FALSE;
+		seenError = GNode_IsError(endNode);
+	}
 
-	if (mainError || endError) {
+	if (seenError) {
 		PrintOnError(gn, "\nStop.");
 		exit(1);
 	}



CVS commit: src/usr.bin/make

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Dec  7 01:07:13 UTC 2020

Modified Files:
src/usr.bin/make: compat.c

Log Message:
make(1): clean up Compat_Run

Now that errors in the main targets and in their dependencies have the
same effect on the .END node and its dependencies, the two variables can
be merged.


To generate a diff of this commit:
cvs rdiff -u -r1.200 -r1.201 src/usr.bin/make/compat.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/compat.c
diff -u src/usr.bin/make/compat.c:1.200 src/usr.bin/make/compat.c:1.201
--- src/usr.bin/make/compat.c:1.200	Mon Dec  7 01:04:06 2020
+++ src/usr.bin/make/compat.c	Mon Dec  7 01:07:13 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.200 2020/12/07 01:04:06 rillig Exp $	*/
+/*	$NetBSD: compat.c,v 1.201 2020/12/07 01:07:13 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -96,7 +96,7 @@
 #include "pathnames.h"
 
 /*	"@(#)compat.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: compat.c,v 1.200 2020/12/07 01:04:06 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.201 2020/12/07 01:07:13 rillig Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
@@ -665,7 +665,6 @@ Compat_Run(GNodeList *targs)
 {
 	GNode *gn = NULL;	/* Current root target */
 	Boolean mainError;
-	Boolean mainDepError;
 	Boolean endError;
 
 	if (!shellName)
@@ -706,7 +705,7 @@ Compat_Run(GNodeList *targs)
 	 */
 	Make_ExpandUse(targs);
 
-	mainDepError = FALSE;
+	mainError = FALSE;
 	while (!Lst_IsEmpty(targs)) {
 		gn = Lst_Dequeue(targs);
 		Compat_Make(gn, gn);
@@ -716,7 +715,7 @@ Compat_Run(GNodeList *targs)
 		} else if (gn->made == ABORTED) {
 			printf("`%s' not remade because of errors.\n",
 			   gn->name);
-			mainDepError = TRUE;
+			mainError = TRUE;
 		}
 	}
 
@@ -724,19 +723,20 @@ Compat_Run(GNodeList *targs)
 	 * XXX: what about multiple main targets if the first few fail but
 	 * the last one succeeds?  This should not count as overall success.
 	 */
-	mainError = GNode_IsError(gn);
+	if (GNode_IsError(gn))
+		mainError = TRUE;
 
 	/*
 	 * If the user has defined a .END target, run its commands.
 	 */
-	if (!mainError && !mainDepError) {
+	if (!mainError) {
 		GNode *endNode = Targ_GetEndNode();
 		Compat_Make(endNode, endNode);
 		endError = GNode_IsError(endNode);
 	} else
 		endError = FALSE;
 
-	if (mainDepError || mainError || endError) {
+	if (mainError || endError) {
 		PrintOnError(gn, "\nStop.");
 		exit(1);
 	}



CVS commit: src/usr.bin/make

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Dec  7 01:04:07 UTC 2020

Modified Files:
src/usr.bin/make: compat.c
src/usr.bin/make/unit-tests: deptgt-end-fail-all.exp
deptgt-end-fail-all.mk deptgt-end-fail.exp deptgt-end-fail.mk

Log Message:
make(1): don't make .END if the main targets already failed

This only applies to -k mode.  By default, make exits earlier and skips
the .END node as well if an error occurs.


To generate a diff of this commit:
cvs rdiff -u -r1.199 -r1.200 src/usr.bin/make/compat.c
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/deptgt-end-fail-all.exp \
src/usr.bin/make/unit-tests/deptgt-end-fail-all.mk
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/deptgt-end-fail.exp \
src/usr.bin/make/unit-tests/deptgt-end-fail.mk

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/compat.c
diff -u src/usr.bin/make/compat.c:1.199 src/usr.bin/make/compat.c:1.200
--- src/usr.bin/make/compat.c:1.199	Mon Dec  7 00:53:30 2020
+++ src/usr.bin/make/compat.c	Mon Dec  7 01:04:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.199 2020/12/07 00:53:30 rillig Exp $	*/
+/*	$NetBSD: compat.c,v 1.200 2020/12/07 01:04:06 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -96,7 +96,7 @@
 #include "pathnames.h"
 
 /*	"@(#)compat.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: compat.c,v 1.199 2020/12/07 00:53:30 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.200 2020/12/07 01:04:06 rillig Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
@@ -729,7 +729,7 @@ Compat_Run(GNodeList *targs)
 	/*
 	 * If the user has defined a .END target, run its commands.
 	 */
-	if (!mainDepError) {
+	if (!mainError && !mainDepError) {
 		GNode *endNode = Targ_GetEndNode();
 		Compat_Make(endNode, endNode);
 		endError = GNode_IsError(endNode);

Index: src/usr.bin/make/unit-tests/deptgt-end-fail-all.exp
diff -u src/usr.bin/make/unit-tests/deptgt-end-fail-all.exp:1.1 src/usr.bin/make/unit-tests/deptgt-end-fail-all.exp:1.2
--- src/usr.bin/make/unit-tests/deptgt-end-fail-all.exp:1.1	Sun Dec  6 21:22:04 2020
+++ src/usr.bin/make/unit-tests/deptgt-end-fail-all.exp	Mon Dec  7 01:04:06 2020
@@ -1,9 +1,6 @@
 : Making all out of nothing.
 false
 *** Error code 1 (continuing)
-: Making .END out of nothing.
-false
-*** Error code 1 (continuing)
 
 Stop.
 make: stopped in unit-tests
Index: src/usr.bin/make/unit-tests/deptgt-end-fail-all.mk
diff -u src/usr.bin/make/unit-tests/deptgt-end-fail-all.mk:1.1 src/usr.bin/make/unit-tests/deptgt-end-fail-all.mk:1.2
--- src/usr.bin/make/unit-tests/deptgt-end-fail-all.mk:1.1	Sun Dec  6 21:22:04 2020
+++ src/usr.bin/make/unit-tests/deptgt-end-fail-all.mk	Mon Dec  7 01:04:07 2020
@@ -1,8 +1,14 @@
-# $NetBSD: deptgt-end-fail-all.mk,v 1.1 2020/12/06 21:22:04 rillig Exp $
+# $NetBSD: deptgt-end-fail-all.mk,v 1.2 2020/12/07 01:04:07 rillig Exp $
 #
 # Test whether the commands from the .END target are run even if there is
 # an error before.  The manual page says "after everything else is done",
 # which leaves room for interpretation.
+#
+# Until 2020-12-07, the .END node was made even if the main nodes had failed.
+# This was not intended since the .END node had already been skipped if a
+# dependency of the main nodes had failed, just not if one of the main nodes
+# themselves had failed.  This inconsistency was not worth keeping.  To run
+# some commands on error, use the .ERROR target instead, see deptgt-error.mk.
 
 all: .PHONY
 	: Making ${.TARGET} out of nothing.

Index: src/usr.bin/make/unit-tests/deptgt-end-fail.exp
diff -u src/usr.bin/make/unit-tests/deptgt-end-fail.exp:1.5 src/usr.bin/make/unit-tests/deptgt-end-fail.exp:1.6
--- src/usr.bin/make/unit-tests/deptgt-end-fail.exp:1.5	Mon Dec  7 00:53:30 2020
+++ src/usr.bin/make/unit-tests/deptgt-end-fail.exp	Mon Dec  7 01:04:07 2020
@@ -84,8 +84,6 @@ Test case all=ERR all-dep=ok end=ok end-
 : Making all-dep out of nothing.
 : Making all from all-dep.
 *** Error code 1 (continuing)
-: Making end-dep out of nothing.
-: Making .END from end-dep.
 
 Stop.
 make: stopped in unit-tests
@@ -96,8 +94,6 @@ Test case all=ERR all-dep=ok end=ok end-
 : Making all-dep out of nothing.
 : Making all from all-dep.
 *** Error code 1 (continuing)
-: Making end-dep out of nothing.
-*** Error code 1 (continuing)
 
 Stop.
 make: stopped in unit-tests
@@ -108,9 +104,6 @@ Test case all=ERR all-dep=ok end=ERR end
 : Making all-dep out of nothing.
 : Making all from all-dep.
 *** Error code 1 (continuing)
-: Making end-dep out of nothing.
-: Making .END from end-dep.
-*** Error code 1 (continuing)
 
 Stop.
 make: stopped in unit-tests
@@ -121,8 +114,6 @@ Test case all=ERR all-dep=ok end=ERR end
 : Making all-dep out of nothing.
 : Making all from all-dep.
 *** Error code 1 (continuing)
-: Making end-dep out of nothing.
-*** Error code 1 

CVS commit: src/usr.bin/make

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Dec  7 00:53:30 UTC 2020

Modified Files:
src/usr.bin/make: compat.c
src/usr.bin/make/unit-tests: dep-percent.exp deptgt-end-fail.exp
deptgt-end-fail.mk opt-debug-errors.exp opt-file.exp
opt-keep-going.exp opt-keep-going.mk posix.exp suff-add-later.exp
suff-clear-regular.exp suff-clear-regular.mk suff-clear-single.exp
suff-main-several.exp suff-self.exp suff-transform-endless.exp
suff-transform-expand.exp suff-transform-select.exp
use-inference.exp use-inference.mk

Log Message:
make(1): fix exit status in -k mode if a dependency fails

Whether in -k mode or not, the exit status tells whether all requested
targets were made or not.  If a dependency could not be made, the main
target was not made as well, therefore the exit status must be nonzero
in such a case.

This part of the code lacked proper unit tests until today.  The unit
test deptgt-end-fail.mk is compatible with make>=2003 at least, allowing
to compare the output over time.

In 2003, in the ok-ok-ok-ok case, "Making all from all-dep." was printed
twice in a row, for whatever reason  ... (40 minutes later) ... If I had
just made the two commands for 'all' and '.END' more distinguishable.
Back in 2003, the local variables for .END had not been initialized,
instead the .END node was run with the local variables of the last
preceding node.  In this case, that node was 'all', therefore ${.TARGET}
had obviously expanded to 'all'.

Somewhere in 2004, the shell commands were no longer run with the -e
flag, which resulted in the "exit status $?" line to be printed in cases
that had stopped early before.

Somewhere in 2005, the local variables for the .END node had been fixed.
The variable ${.TARGET} now had the value '.END', just as expected.  In
addition, the dependencies for the .END node were made, although without
getting their proper local variables.  This resulted in the output
"Making  out of nothing" instead of the expected "Making end-dep out of
nothing".

Still in 2005, in the test case "all=ok all-dep=ok end=ok end-dep=ERR",
the error code of the failed 'end-dep' was first reported as "*** Error
code 1 (continuing)".  To compensate for this improvement, a new bug had
been introduced.  The test case "all=ok all-dep=ok end=ERR end-dep=ERR"
had properly exited with status 1 on 2005-01-01, but on 2006-01-01 it
exited with status 0, thereby ignoring errors in the .END node.

Somewhere in 2008, some of the error messages (but not all) were
directed to stderr instead of stdout.  The actual output stayed the same
though.

Somewhere in 2011, the dependency of the .END node got its own local
variables, and ${.TARGET} now expanded to 'end-dep', as expected.

Somewhere in 2016, the two empty lines between the "*** Error code 1
(continuing)" and the "Stop." got compressed into a single empty line.

On 2020-12-07 (that is, today), the exit status 1 has been restored in
the error cases, after it had been wrong for at least 14 years.


To generate a diff of this commit:
cvs rdiff -u -r1.198 -r1.199 src/usr.bin/make/compat.c
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/dep-percent.exp \
src/usr.bin/make/unit-tests/posix.exp \
src/usr.bin/make/unit-tests/suff-clear-regular.exp \
src/usr.bin/make/unit-tests/suff-clear-regular.mk \
src/usr.bin/make/unit-tests/suff-clear-single.exp \
src/usr.bin/make/unit-tests/suff-self.exp \
src/usr.bin/make/unit-tests/suff-transform-expand.exp \
src/usr.bin/make/unit-tests/use-inference.exp
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/deptgt-end-fail.exp \
src/usr.bin/make/unit-tests/deptgt-end-fail.mk \
src/usr.bin/make/unit-tests/opt-file.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/opt-debug-errors.exp \
src/usr.bin/make/unit-tests/use-inference.mk
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/opt-keep-going.exp \
src/usr.bin/make/unit-tests/suff-add-later.exp \
src/usr.bin/make/unit-tests/suff-main-several.exp \
src/usr.bin/make/unit-tests/suff-transform-endless.exp \
src/usr.bin/make/unit-tests/suff-transform-select.exp
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/opt-keep-going.mk

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/compat.c
diff -u src/usr.bin/make/compat.c:1.198 src/usr.bin/make/compat.c:1.199
--- src/usr.bin/make/compat.c:1.198	Sun Dec  6 23:02:56 2020
+++ src/usr.bin/make/compat.c	Mon Dec  7 00:53:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.198 2020/12/06 23:02:56 rillig Exp $	*/
+/*	$NetBSD: compat.c,v 1.199 2020/12/07 00:53:30 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -96,7 +96,7 @@
 #include "pathnames.h"
 
 /*	"@(#)compat.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: compat.c,v 

CVS commit: src/usr.bin/make

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec  6 23:02:56 UTC 2020

Modified Files:
src/usr.bin/make: compat.c

Log Message:
make(1): refactor Compat_Run to show the error condition more clearly

This refactoring allows to gradually change the conditions for the
"Stop." error message, to demonstrate which cases are affected by each
tiny change.


To generate a diff of this commit:
cvs rdiff -u -r1.197 -r1.198 src/usr.bin/make/compat.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/compat.c
diff -u src/usr.bin/make/compat.c:1.197 src/usr.bin/make/compat.c:1.198
--- src/usr.bin/make/compat.c:1.197	Sun Dec  6 22:49:40 2020
+++ src/usr.bin/make/compat.c	Sun Dec  6 23:02:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.197 2020/12/06 22:49:40 rillig Exp $	*/
+/*	$NetBSD: compat.c,v 1.198 2020/12/06 23:02:56 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -96,7 +96,7 @@
 #include "pathnames.h"
 
 /*	"@(#)compat.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: compat.c,v 1.197 2020/12/06 22:49:40 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.198 2020/12/06 23:02:56 rillig Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
@@ -664,8 +664,9 @@ void
 Compat_Run(GNodeList *targs)
 {
 	GNode *gn = NULL;	/* Current root target */
-	int indirectErrors;	/* Number of targets not remade due to errors */
-	Boolean seenError;
+	Boolean mainError;
+	Boolean mainDepError;
+	Boolean endError;
 
 	if (!shellName)
 		Shell_Init();
@@ -705,7 +706,7 @@ Compat_Run(GNodeList *targs)
 	 */
 	Make_ExpandUse(targs);
 
-	indirectErrors = 0;
+	mainDepError = FALSE;
 	while (!Lst_IsEmpty(targs)) {
 		gn = Lst_Dequeue(targs);
 		Compat_Make(gn, gn);
@@ -715,21 +716,28 @@ Compat_Run(GNodeList *targs)
 		} else if (gn->made == ABORTED) {
 			printf("`%s' not remade because of errors.\n",
 			   gn->name);
-			indirectErrors++;
+			mainDepError = TRUE;
 		}
 	}
 
 	/*
+	 * XXX: what about multiple main targets if the first few fail but
+	 * the last one succeeds?  This should not count as overall success.
+	 */
+	mainError = GNode_IsError(gn);
+
+	/*
 	 * If the user has defined a .END target, run its commands.
 	 */
-	seenError = indirectErrors > 0;
-	if (!seenError) {
+	if (!mainDepError) {
 		GNode *endNode = Targ_GetEndNode();
 		Compat_Make(endNode, endNode);
-		seenError = GNode_IsError(gn) || GNode_IsError(endNode);
-		if (seenError) {
-			PrintOnError(gn, "\nStop.");
-			exit(1);
-		}
+		endError = GNode_IsError(endNode);
+	} else
+		endError = FALSE;
+
+	if (!mainDepError && (mainError || endError)) {
+		PrintOnError(gn, "\nStop.");
+		exit(1);
 	}
 }



CVS commit: src/usr.bin/make

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec  6 22:49:40 UTC 2020

Modified Files:
src/usr.bin/make: compat.c

Log Message:
make(1): refactor error handling in Compat_Run

This is in preparation for the upcoming bug fixes.


To generate a diff of this commit:
cvs rdiff -u -r1.196 -r1.197 src/usr.bin/make/compat.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/compat.c
diff -u src/usr.bin/make/compat.c:1.196 src/usr.bin/make/compat.c:1.197
--- src/usr.bin/make/compat.c:1.196	Sat Nov 28 19:22:32 2020
+++ src/usr.bin/make/compat.c	Sun Dec  6 22:49:40 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.196 2020/11/28 19:22:32 rillig Exp $	*/
+/*	$NetBSD: compat.c,v 1.197 2020/12/06 22:49:40 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -96,7 +96,7 @@
 #include "pathnames.h"
 
 /*	"@(#)compat.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: compat.c,v 1.196 2020/11/28 19:22:32 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.197 2020/12/06 22:49:40 rillig Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
@@ -665,6 +665,7 @@ Compat_Run(GNodeList *targs)
 {
 	GNode *gn = NULL;	/* Current root target */
 	int indirectErrors;	/* Number of targets not remade due to errors */
+	Boolean seenError;
 
 	if (!shellName)
 		Shell_Init();
@@ -721,10 +722,12 @@ Compat_Run(GNodeList *targs)
 	/*
 	 * If the user has defined a .END target, run its commands.
 	 */
-	if (indirectErrors == 0) {
+	seenError = indirectErrors > 0;
+	if (!seenError) {
 		GNode *endNode = Targ_GetEndNode();
 		Compat_Make(endNode, endNode);
-		if (GNode_IsError(gn) || GNode_IsError(endNode)) {
+		seenError = GNode_IsError(gn) || GNode_IsError(endNode);
+		if (seenError) {
 			PrintOnError(gn, "\nStop.");
 			exit(1);
 		}



CVS commit: src/usr.bin/make/unit-tests

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec  6 22:36:58 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: deptgt-end-fail.exp deptgt-end-fail.mk

Log Message:
make(1): test all combinations of failed main and .END targets

Adding an individual test for each of the 16 combinations would have
been too much manual work, and it's not easy to come up with a good
naming scheme for all the tests, keeping them short and expressive at
the same time.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/deptgt-end-fail.exp \
src/usr.bin/make/unit-tests/deptgt-end-fail.mk

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/unit-tests/deptgt-end-fail.exp
diff -u src/usr.bin/make/unit-tests/deptgt-end-fail.exp:1.3 src/usr.bin/make/unit-tests/deptgt-end-fail.exp:1.4
--- src/usr.bin/make/unit-tests/deptgt-end-fail.exp:1.3	Sun Dec  6 21:22:04 2020
+++ src/usr.bin/make/unit-tests/deptgt-end-fail.exp	Sun Dec  6 22:36:58 2020
@@ -1,8 +1,148 @@
-: all
-: Making .END out of nothing.
-false
+Test case all=ok all-dep=ok end=ok end-dep=ok.
+: Making all-dep out of nothing.
+: Making all from all-dep.
+: Making end-dep out of nothing.
+: Making .END from end-dep.
+exit status 0
+
+
+Test case all=ok all-dep=ok end=ok end-dep=ERR.
+: Making all-dep out of nothing.
+: Making all from all-dep.
+: Making end-dep out of nothing.
+*** Error code 1 (continuing)
+
+Stop.
+make: stopped in unit-tests
+exit status 1
+
+
+Test case all=ok all-dep=ok end=ERR end-dep=ok.
+: Making all-dep out of nothing.
+: Making all from all-dep.
+: Making end-dep out of nothing.
+: Making .END from end-dep.
 *** Error code 1 (continuing)
 
 Stop.
 make: stopped in unit-tests
 exit status 1
+
+
+Test case all=ok all-dep=ok end=ERR end-dep=ERR.
+: Making all-dep out of nothing.
+: Making all from all-dep.
+: Making end-dep out of nothing.
+*** Error code 1 (continuing)
+
+Stop.
+make: stopped in unit-tests
+exit status 1
+
+
+Test case all=ok all-dep=ERR end=ok end-dep=ok.
+: Making all-dep out of nothing.
+*** Error code 1 (continuing)
+`all' not remade because of errors.
+exit status 0
+
+
+Test case all=ok all-dep=ERR end=ok end-dep=ERR.
+: Making all-dep out of nothing.
+*** Error code 1 (continuing)
+`all' not remade because of errors.
+exit status 0
+
+
+Test case all=ok all-dep=ERR end=ERR end-dep=ok.
+: Making all-dep out of nothing.
+*** Error code 1 (continuing)
+`all' not remade because of errors.
+exit status 0
+
+
+Test case all=ok all-dep=ERR end=ERR end-dep=ERR.
+: Making all-dep out of nothing.
+*** Error code 1 (continuing)
+`all' not remade because of errors.
+exit status 0
+
+
+Test case all=ERR all-dep=ok end=ok end-dep=ok.
+: Making all-dep out of nothing.
+: Making all from all-dep.
+*** Error code 1 (continuing)
+: Making end-dep out of nothing.
+: Making .END from end-dep.
+
+Stop.
+make: stopped in unit-tests
+exit status 1
+
+
+Test case all=ERR all-dep=ok end=ok end-dep=ERR.
+: Making all-dep out of nothing.
+: Making all from all-dep.
+*** Error code 1 (continuing)
+: Making end-dep out of nothing.
+*** Error code 1 (continuing)
+
+Stop.
+make: stopped in unit-tests
+exit status 1
+
+
+Test case all=ERR all-dep=ok end=ERR end-dep=ok.
+: Making all-dep out of nothing.
+: Making all from all-dep.
+*** Error code 1 (continuing)
+: Making end-dep out of nothing.
+: Making .END from end-dep.
+*** Error code 1 (continuing)
+
+Stop.
+make: stopped in unit-tests
+exit status 1
+
+
+Test case all=ERR all-dep=ok end=ERR end-dep=ERR.
+: Making all-dep out of nothing.
+: Making all from all-dep.
+*** Error code 1 (continuing)
+: Making end-dep out of nothing.
+*** Error code 1 (continuing)
+
+Stop.
+make: stopped in unit-tests
+exit status 1
+
+
+Test case all=ERR all-dep=ERR end=ok end-dep=ok.
+: Making all-dep out of nothing.
+*** Error code 1 (continuing)
+`all' not remade because of errors.
+exit status 0
+
+
+Test case all=ERR all-dep=ERR end=ok end-dep=ERR.
+: Making all-dep out of nothing.
+*** Error code 1 (continuing)
+`all' not remade because of errors.
+exit status 0
+
+
+Test case all=ERR all-dep=ERR end=ERR end-dep=ok.
+: Making all-dep out of nothing.
+*** Error code 1 (continuing)
+`all' not remade because of errors.
+exit status 0
+
+
+Test case all=ERR all-dep=ERR end=ERR end-dep=ERR.
+: Making all-dep out of nothing.
+*** Error code 1 (continuing)
+`all' not remade because of errors.
+exit status 0
+
+
+exit status 0
Index: src/usr.bin/make/unit-tests/deptgt-end-fail.mk
diff -u src/usr.bin/make/unit-tests/deptgt-end-fail.mk:1.3 src/usr.bin/make/unit-tests/deptgt-end-fail.mk:1.4
--- src/usr.bin/make/unit-tests/deptgt-end-fail.mk:1.3	Sun Dec  6 21:22:04 2020
+++ src/usr.bin/make/unit-tests/deptgt-end-fail.mk	Sun Dec  6 22:36:58 2020
@@ -1,14 +1,66 @@
-# $NetBSD: deptgt-end-fail.mk,v 1.3 2020/12/06 21:22:04 rillig Exp $
+# $NetBSD: deptgt-end-fail.mk,v 

CVS commit: src

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec  6 21:22:04 UTC 2020

Modified Files:
src/distrib/sets/lists/tests: mi
src/usr.bin/make/unit-tests: Makefile deptgt-end-fail-indirect.mk
deptgt-end-fail.exp deptgt-end-fail.mk
Added Files:
src/usr.bin/make/unit-tests: deptgt-end-fail-all.exp
deptgt-end-fail-all.mk

Log Message:
make(1): add test for .END after failed main node


To generate a diff of this commit:
cvs rdiff -u -r1.982 -r1.983 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.236 -r1.237 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/deptgt-end-fail-all.exp \
src/usr.bin/make/unit-tests/deptgt-end-fail-all.mk
cvs rdiff -u -r1.1 -r1.2 \
src/usr.bin/make/unit-tests/deptgt-end-fail-indirect.mk
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/deptgt-end-fail.exp \
src/usr.bin/make/unit-tests/deptgt-end-fail.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.982 src/distrib/sets/lists/tests/mi:1.983
--- src/distrib/sets/lists/tests/mi:1.982	Tue Dec  1 22:16:36 2020
+++ src/distrib/sets/lists/tests/mi	Sun Dec  6 21:22:04 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.982 2020/12/01 22:16:36 rillig Exp $
+# $NetBSD: mi,v 1.983 2020/12/06 21:22:04 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4965,6 +4965,8 @@
 ./usr/tests/usr.bin/make/unit-tests/deptgt-default.mktests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/deptgt-delete_on_error.exp			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/deptgt-delete_on_error.mk			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/deptgt-end-fail-all.exp			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/deptgt-end-fail-all.mk			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/deptgt-end-fail-indirect.exp		tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/deptgt-end-fail-indirect.mk			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/deptgt-end-fail.exptests-usr.bin-tests	compattestfile,atf

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.236 src/usr.bin/make/unit-tests/Makefile:1.237
--- src/usr.bin/make/unit-tests/Makefile:1.236	Sat Dec  5 03:42:15 2020
+++ src/usr.bin/make/unit-tests/Makefile	Sun Dec  6 21:22:04 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.236 2020/12/05 03:42:15 sjg Exp $
+# $NetBSD: Makefile,v 1.237 2020/12/06 21:22:04 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -115,6 +115,7 @@ TESTS+=		deptgt-default
 TESTS+=		deptgt-delete_on_error
 TESTS+=		deptgt-end
 TESTS+=		deptgt-end-fail
+TESTS+=		deptgt-end-fail-all
 TESTS+=		deptgt-end-fail-indirect
 TESTS+=		deptgt-end-jobs
 TESTS+=		deptgt-error

Index: src/usr.bin/make/unit-tests/deptgt-end-fail-indirect.mk
diff -u src/usr.bin/make/unit-tests/deptgt-end-fail-indirect.mk:1.1 src/usr.bin/make/unit-tests/deptgt-end-fail-indirect.mk:1.2
--- src/usr.bin/make/unit-tests/deptgt-end-fail-indirect.mk:1.1	Tue Nov 24 17:59:42 2020
+++ src/usr.bin/make/unit-tests/deptgt-end-fail-indirect.mk	Sun Dec  6 21:22:04 2020
@@ -1,4 +1,4 @@
-# $NetBSD: deptgt-end-fail-indirect.mk,v 1.1 2020/11/24 17:59:42 rillig Exp $
+# $NetBSD: deptgt-end-fail-indirect.mk,v 1.2 2020/12/06 21:22:04 rillig Exp $
 #
 # Tests for an error in a dependency of the .END node.
 #
@@ -10,6 +10,7 @@ all:
 	: $@
 
 .END: failing
+	: Making ${.TARGET} from ${.ALLSRC}.
 
 failing: .PHONY
 	false

Index: src/usr.bin/make/unit-tests/deptgt-end-fail.exp
diff -u src/usr.bin/make/unit-tests/deptgt-end-fail.exp:1.2 src/usr.bin/make/unit-tests/deptgt-end-fail.exp:1.3
--- src/usr.bin/make/unit-tests/deptgt-end-fail.exp:1.2	Tue Nov 24 15:59:18 2020
+++ src/usr.bin/make/unit-tests/deptgt-end-fail.exp	Sun Dec  6 21:22:04 2020
@@ -1,4 +1,5 @@
 : all
+: Making .END out of nothing.
 false
 *** Error code 1 (continuing)
 
Index: src/usr.bin/make/unit-tests/deptgt-end-fail.mk
diff -u src/usr.bin/make/unit-tests/deptgt-end-fail.mk:1.2 src/usr.bin/make/unit-tests/deptgt-end-fail.mk:1.3
--- src/usr.bin/make/unit-tests/deptgt-end-fail.mk:1.2	Tue Nov 24 17:59:42 2020
+++ src/usr.bin/make/unit-tests/deptgt-end-fail.mk	Sun Dec  6 21:22:04 2020
@@ -1,4 +1,4 @@
-# $NetBSD: deptgt-end-fail.mk,v 1.2 2020/11/24 17:59:42 rillig Exp $
+# $NetBSD: deptgt-end-fail.mk,v 1.3 2020/12/06 21:22:04 rillig Exp $
 #
 # Tests for an error in the .END node.
 #
@@ -10,4 +10,5 @@ all:
 	: $@
 
 .END:
+	: Making ${.TARGET} out of nothing.
 	false

Added files:

Index: src/usr.bin/make/unit-tests/deptgt-end-fail-all.exp
diff -u /dev/null src/usr.bin/make/unit-tests/deptgt-end-fail-all.exp:1.1
--- /dev/null	Sun Dec  6 21:22:05 2020

CVS commit: src/usr.bin/make/unit-tests

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec  6 20:55:30 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: opt-file.mk

Log Message:
make(1): document undefined behavior from 2014

Earlier versions of make didn't know the -v option to print the expanded
value of a variable.  To make the test runnable by older makes as well,
switch to -V instead, which has been available much longer.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/opt-file.mk

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/unit-tests/opt-file.mk
diff -u src/usr.bin/make/unit-tests/opt-file.mk:1.6 src/usr.bin/make/unit-tests/opt-file.mk:1.7
--- src/usr.bin/make/unit-tests/opt-file.mk:1.6	Sun Dec  6 20:33:44 2020
+++ src/usr.bin/make/unit-tests/opt-file.mk	Sun Dec  6 20:55:30 2020
@@ -1,4 +1,4 @@
-# $NetBSD: opt-file.mk,v 1.6 2020/12/06 20:33:44 rillig Exp $
+# $NetBSD: opt-file.mk,v 1.7 2020/12/06 20:55:30 rillig Exp $
 #
 # Tests for the -f command line option.
 
@@ -12,9 +12,28 @@ all: file-containing-null-byte
 #
 # In the unlikely case where a file ends in a backslash instead of a newline,
 # that backslash is trimmed.  See ParseGetLine.
+#
+# make-2014.01.01.00.00.00 invoked undefined behavior, reading text from
+# outside of the file buffer.
+#
+#	printf '%s' 'VAR=value\' \
+#	| MALLOC_OPTIONS=JA make-2014.01.01.00.00.00 -r -f - -V VAR -dA 2>&1 \
+#	| less
+#
+# The debug output shows how make happily uses freshly allocated memory (the
+# ) and already freed memory ('Z').
+#
+#	ParseReadLine (1): 'VAR=value\'
+#	Global:VAR = value\value\
+#	ParseReadLine (2): 'alue\'
+#	ParseDoDependency(alue\)
+#	make-2014.01.01.00.00.00: "(stdin)" line 2: Need an operator
+#	ParseReadLine (3): ''
+#	ParseDoDependency()
+#
 file-ending-in-backslash: .PHONY
 	@printf '%s' 'VAR=value\' \
-	| ${MAKE} -r -f - -v VAR
+	| ${MAKE} -r -f - -V VAR
 
 # If a file contains null bytes, the rest of the line is skipped, and parsing
 # continues in the next line.  Throughout the history of make, the behavior
@@ -61,7 +80,7 @@ file-ending-in-backslash: .PHONY
 file-containing-null-byte: .PHONY
 	@printf '%s\n' 'VAR=value' 'VAR2=VALUE2' \
 	| tr 'l' '\0' \
-	| ${MAKE} -r -f - -v VAR -v VAR2
+	| ${MAKE} -r -f - -V VAR -V VAR2
 
 all:
 	: Making ${.TARGET}



CVS commit: src/usr.bin/make

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec  6 20:33:44 UTC 2020

Modified Files:
src/usr.bin/make: parse.c
src/usr.bin/make/unit-tests: opt-file.exp opt-file.mk

Log Message:
make(1): error out on null bytes in makefiles

Makefiles are text files, they must not contain null bytes.

The previous code in this area was rotten anyway.  It assumed that
buf_end could be NULL even if buf_ptr was a valid pointer, which is no
longer true, probably since a few years already.

Continuing parsing after a null byte does not make sense.  If there's a
null byte in a text file, that file is corrupted, and parsing it leads
to unintended effects easily.  Therefore the only sensible action is to
stop parsing immediately.

The check whether cf->readMore could be null was outdated as well, which
previously made the fatal error impossible to reach.  Because of the
missing unit tests, nobody noticed this though.

The "exit status 0" in opt-file.exp is worring but that's due to another
bug and will be fixed in a follow-up commit.


To generate a diff of this commit:
cvs rdiff -u -r1.471 -r1.472 src/usr.bin/make/parse.c
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/opt-file.exp
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/opt-file.mk

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/parse.c
diff -u src/usr.bin/make/parse.c:1.471 src/usr.bin/make/parse.c:1.472
--- src/usr.bin/make/parse.c:1.471	Sun Dec  6 20:09:01 2020
+++ src/usr.bin/make/parse.c	Sun Dec  6 20:33:44 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.471 2020/12/06 20:09:01 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.472 2020/12/06 20:33:44 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.471 2020/12/06 20:09:01 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.472 2020/12/06 20:33:44 rillig Exp $");
 
 /* types and constants */
 
@@ -2687,41 +2687,15 @@ ParseGetLine(GetLineMode mode)
 		escaped = NULL;
 		comment = NULL;
 		for (;;) {
-			/* XXX: can buf_end ever be null? */
-			if (cf->buf_end != NULL && ptr == cf->buf_end) {
+			if (ptr == cf->buf_end) {
 /* end of buffer */
 ch = '\0';
 break;
 			}
 			ch = *ptr;
-			if (ch == '\0' || (ch == '\\' && ptr[1] == '\0')) {
-
-/* XXX: can buf_end ever be null? */
-if (cf->buf_end == NULL)
-	/* End of string (aka for loop) data */
-	break;
-
-/* see if there is more we can parse */
-while (ptr++ < cf->buf_end) {
-	if ((ch = *ptr) == '\n') {
-		if (ptr > line &&
-		ptr[-1] == '\\')
-			continue;
-		Parse_Error(PARSE_WARNING,
-		"Zero byte read from file, "
-		"skipping rest of line.");
-		break;
-	}
-}
-/* XXX: Can cf->readMore ever be NULL? */
-if (cf->readMore != NULL) {
-	/*
-	 * End of this buffer; return EOF and
-	 * outer logic will get the next one.
-	 * (eww)
-	 */
-	break;
-}
+			if (ch == '\0' ||
+			(ch == '\\' && ptr + 1 < cf->buf_end &&
+			 ptr[1] == '\0')) {
 Parse_Error(PARSE_FATAL,
 "Zero byte read from file");
 return NULL;

Index: src/usr.bin/make/unit-tests/opt-file.exp
diff -u src/usr.bin/make/unit-tests/opt-file.exp:1.3 src/usr.bin/make/unit-tests/opt-file.exp:1.4
--- src/usr.bin/make/unit-tests/opt-file.exp:1.3	Sun Dec  6 19:18:26 2020
+++ src/usr.bin/make/unit-tests/opt-file.exp	Sun Dec  6 20:33:44 2020
@@ -1,5 +1,7 @@
 value
-make: "(stdin)" line 1: warning: Zero byte read from file, skipping rest of line.
-va
-VALUE2
+make: "(stdin)" line 1: Zero byte read from file
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+*** Error code 1 (continuing)
+`all' not remade because of errors.
 exit status 0

Index: src/usr.bin/make/unit-tests/opt-file.mk
diff -u src/usr.bin/make/unit-tests/opt-file.mk:1.5 src/usr.bin/make/unit-tests/opt-file.mk:1.6
--- src/usr.bin/make/unit-tests/opt-file.mk:1.5	Sun Dec  6 20:07:25 2020
+++ src/usr.bin/make/unit-tests/opt-file.mk	Sun Dec  6 20:33:44 2020
@@ -1,4 +1,4 @@
-# $NetBSD: opt-file.mk,v 1.5 2020/12/06 20:07:25 rillig Exp $
+# $NetBSD: opt-file.mk,v 1.6 2020/12/06 20:33:44 rillig Exp $
 #
 # Tests for the -f command line option.
 
@@ -49,15 +49,19 @@ file-ending-in-backslash: .PHONY
 #	make: stopped in .
 #	exit status 2
 #
-#	2014:
+#	2014 to 2020-12-06:
 #	make: "zero-byte.in" line 1: warning: Zero byte read from file, skipping rest of line.
 #	exit status 0
 #
-# XXX: It would be safer to just quit parsing in such a situation.
+#	Since 2020-12-07:
+#	make: "zero-byte.in" line 1: Zero byte read from file
+#	make: Fatal errors encountered -- cannot continue
+#	make: stopped in .
+#	exit status 1
 file-containing-null-byte: .PHONY
 	@printf '%s\n' 'VAR=value' 'VAR2=VALUE2' \
 	| tr 'l' '\0' \
 	| 

CVS commit: src/usr.bin/make

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec  6 20:09:01 UTC 2020

Modified Files:
src/usr.bin/make: nonints.h parse.c

Log Message:
make(1): rename IFile.nextbuf to readMore

The previous name sounded too much like a noun, which was too confusing.
See unit-tests/opt-file.mk for the history of this part of the code.


To generate a diff of this commit:
cvs rdiff -u -r1.164 -r1.165 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.470 -r1.471 src/usr.bin/make/parse.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/nonints.h
diff -u src/usr.bin/make/nonints.h:1.164 src/usr.bin/make/nonints.h:1.165
--- src/usr.bin/make/nonints.h:1.164	Sun Nov 29 00:04:22 2020
+++ src/usr.bin/make/nonints.h	Sun Dec  6 20:09:01 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nonints.h,v 1.164 2020/11/29 00:04:22 rillig Exp $	*/
+/*	$NetBSD: nonints.h,v 1.165 2020/12/06 20:09:01 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -145,14 +145,14 @@ typedef struct VarAssign {
 const char *value;		/* unexpanded */
 } VarAssign;
 
-typedef char *(*NextBufProc)(void *, size_t *);
+typedef char *(*ReadMoreProc)(void *, size_t *);
 
 void Parse_Error(ParseErrorLevel, const char *, ...) MAKE_ATTR_PRINTFLIKE(2, 3);
 Boolean Parse_IsVar(const char *, VarAssign *out_var);
 void Parse_DoVar(VarAssign *, GNode *);
 void Parse_AddIncludeDir(const char *);
 void Parse_File(const char *, int);
-void Parse_SetInput(const char *, int, int, NextBufProc, void *);
+void Parse_SetInput(const char *, int, int, ReadMoreProc, void *);
 void Parse_MainName(GNodeList *);
 int Parse_GetFatals(void);
 

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.470 src/usr.bin/make/parse.c:1.471
--- src/usr.bin/make/parse.c:1.470	Sun Dec  6 18:37:04 2020
+++ src/usr.bin/make/parse.c	Sun Dec  6 20:09:01 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.470 2020/12/06 18:37:04 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.471 2020/12/06 20:09:01 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.470 2020/12/06 18:37:04 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.471 2020/12/06 20:09:01 rillig Exp $");
 
 /* types and constants */
 
@@ -137,8 +137,10 @@ typedef struct IFile {
 	char *buf_ptr;		/* next char to be read */
 	char *buf_end;
 
-	char *(*nextbuf)(void *, size_t *); /* Function to get more data */
-	void *nextbuf_arg;	/* Opaque arg for nextbuf() */
+	/* Function to read more data, with a single opaque argument. */
+	ReadMoreProc readMore;
+	void *readMoreArg;
+
 	struct loadedfile *lf;	/* loadedfile object, if any */
 } IFile;
 
@@ -384,11 +386,11 @@ loadedfile_destroy(struct loadedfile *lf
 }
 
 /*
- * nextbuf() operation for loadedfile, as needed by the weird and twisted
- * logic below. Once that's cleaned up, we can get rid of lf->used...
+ * readMore() operation for loadedfile, as needed by the weird and twisted
+ * logic below. Once that's cleaned up, we can get rid of lf->used.
  */
 static char *
-loadedfile_nextbuf(void *x, size_t *len)
+loadedfile_readMore(void *x, size_t *len)
 {
 	struct loadedfile *lf = x;
 
@@ -2254,7 +2256,7 @@ Parse_include_file(char *file, Boolean i
 	lf = loadfile(fullname, fd);
 
 	/* Start reading from this file next */
-	Parse_SetInput(fullname, 0, -1, loadedfile_nextbuf, lf);
+	Parse_SetInput(fullname, 0, -1, loadedfile_readMore, lf);
 	CurFile()->lf = lf;
 	if (depinc)
 		doing_depend = depinc;	/* only turn it on */
@@ -2432,7 +2434,7 @@ ParseTrackInput(const char *name)
  */
 void
 Parse_SetInput(const char *name, int line, int fd,
-	   char *(*nextbuf)(void *, size_t *), void *arg)
+	   ReadMoreProc readMore, void *readMoreArg)
 {
 	IFile *curFile;
 	char *buf;
@@ -2445,14 +2447,14 @@ Parse_SetInput(const char *name, int lin
 		ParseTrackInput(name);
 
 	if (DEBUG(PARSE)) {
-		const char *caller = nextbuf == loadedfile_nextbuf
+		const char *caller = readMore == loadedfile_readMore
 		? "loadedfile" : "other";
 		debug_printf(
-		"%s: file %s, line %d, fd %d, nextbuf %s, arg %p\n",
-		__func__, name, line, fd, caller, arg);
+		"%s: file %s, line %d, fd %d, readMore %s, readMoreArg %p\n",
+		__func__, name, line, fd, caller, readMoreArg);
 	}
 
-	if (fd == -1 && nextbuf == NULL)
+	if (fd == -1 && readMore == NULL)
 		/* sanity */
 		return;
 
@@ -2461,15 +2463,15 @@ Parse_SetInput(const char *name, int lin
 	curFile->fromForLoop = fromForLoop;
 	curFile->lineno = line;
 	curFile->first_lineno = line;
-	curFile->nextbuf = nextbuf;
-	curFile->nextbuf_arg = arg;
+	curFile->readMore = readMore;
+	curFile->readMoreArg = readMoreArg;
 	curFile->lf = NULL;
 	curFile->depending = doing_depend;	/* restore this on EOF */
 
-	assert(nextbuf != NULL);
+	assert(readMore != NULL);
 
 	/* Get first block of input data */
-	

CVS commit: src/usr.bin/make/unit-tests

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec  6 20:07:26 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: opt-file.mk

Log Message:
make(1): document how make behaved for null bytes in the makefile


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/opt-file.mk

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/unit-tests/opt-file.mk
diff -u src/usr.bin/make/unit-tests/opt-file.mk:1.4 src/usr.bin/make/unit-tests/opt-file.mk:1.5
--- src/usr.bin/make/unit-tests/opt-file.mk:1.4	Sun Dec  6 19:18:26 2020
+++ src/usr.bin/make/unit-tests/opt-file.mk	Sun Dec  6 20:07:25 2020
@@ -1,4 +1,4 @@
-# $NetBSD: opt-file.mk,v 1.4 2020/12/06 19:18:26 rillig Exp $
+# $NetBSD: opt-file.mk,v 1.5 2020/12/06 20:07:25 rillig Exp $
 #
 # Tests for the -f command line option.
 
@@ -17,7 +17,41 @@ file-ending-in-backslash: .PHONY
 	| ${MAKE} -r -f - -v VAR
 
 # If a file contains null bytes, the rest of the line is skipped, and parsing
-# continues in the next line.
+# continues in the next line.  Throughout the history of make, the behavior
+# has changed several times, sometimes knowingly, sometimes by accident.
+#
+#	echo 'VAR=value' | tr 'l' '\0' > zero-byte.in
+#	printf '%s\n' 'all:' ': VAR=${VAR:Q}' >> zero-byte.in
+#
+#	for year in $(seq 2003 2020); do
+#	  echo $year:
+#	  make-$year.01.01.00.00.00 -r -f zero-byte.in
+#	  echo "exit status $?"
+#	  echo
+#	done 2>&1 \
+#	| sed "s,$PWD/,.,"
+#
+# This program generated the following output:
+#
+#	2003 to 2007:
+#	exit status 0
+#
+#	2008 to 2010:
+#	make: "zero-byte.in" line 1: Zero byte read from file
+#	make: Fatal errors encountered -- cannot continue
+#
+#	make: stopped in .
+#	exit status 1
+#
+#	2011 to 2013:
+#	make: no target to make.
+#
+#	make: stopped in .
+#	exit status 2
+#
+#	2014:
+#	make: "zero-byte.in" line 1: warning: Zero byte read from file, skipping rest of line.
+#	exit status 0
 #
 # XXX: It would be safer to just quit parsing in such a situation.
 file-containing-null-byte: .PHONY



CVS commit: src/usr.bin/make/unit-tests

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec  6 19:18:27 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: opt-file.exp opt-file.mk

Log Message:
make(1): add test for makefile containing null bytes


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/opt-file.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/opt-file.mk

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/unit-tests/opt-file.exp
diff -u src/usr.bin/make/unit-tests/opt-file.exp:1.2 src/usr.bin/make/unit-tests/opt-file.exp:1.3
--- src/usr.bin/make/unit-tests/opt-file.exp:1.2	Sun Dec  6 19:00:48 2020
+++ src/usr.bin/make/unit-tests/opt-file.exp	Sun Dec  6 19:18:26 2020
@@ -1,2 +1,5 @@
 value
+make: "(stdin)" line 1: warning: Zero byte read from file, skipping rest of line.
+va
+VALUE2
 exit status 0

Index: src/usr.bin/make/unit-tests/opt-file.mk
diff -u src/usr.bin/make/unit-tests/opt-file.mk:1.3 src/usr.bin/make/unit-tests/opt-file.mk:1.4
--- src/usr.bin/make/unit-tests/opt-file.mk:1.3	Sun Dec  6 19:00:48 2020
+++ src/usr.bin/make/unit-tests/opt-file.mk	Sun Dec  6 19:18:26 2020
@@ -1,17 +1,29 @@
-# $NetBSD: opt-file.mk,v 1.3 2020/12/06 19:00:48 rillig Exp $
+# $NetBSD: opt-file.mk,v 1.4 2020/12/06 19:18:26 rillig Exp $
 #
 # Tests for the -f command line option.
 
 # TODO: Implementation
 
-all: .PHONY file-ending-in-backslash
+all: .PHONY
+all: file-ending-in-backslash
+all: file-containing-null-byte
 
 # Passing '-' as the filename reads from stdin.  This is unusual but possible.
 #
 # In the unlikely case where a file ends in a backslash instead of a newline,
 # that backslash is trimmed.  See ParseGetLine.
 file-ending-in-backslash: .PHONY
-	@printf '%s' 'VAR=value\' | ${MAKE} -r -f - -v VAR
+	@printf '%s' 'VAR=value\' \
+	| ${MAKE} -r -f - -v VAR
+
+# If a file contains null bytes, the rest of the line is skipped, and parsing
+# continues in the next line.
+#
+# XXX: It would be safer to just quit parsing in such a situation.
+file-containing-null-byte: .PHONY
+	@printf '%s\n' 'VAR=value' 'VAR2=VALUE2' \
+	| tr 'l' '\0' \
+	| ${MAKE} -r -f - -v VAR -v VAR2
 
 all:
 	@:;



CVS commit: src/usr.bin/make/unit-tests

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec  6 19:00:48 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: opt-file.exp opt-file.mk

Log Message:
make(1): test parsing a makefile that ends in a backslash


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/opt-file.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/opt-file.mk

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/unit-tests/opt-file.exp
diff -u src/usr.bin/make/unit-tests/opt-file.exp:1.1 src/usr.bin/make/unit-tests/opt-file.exp:1.2
--- src/usr.bin/make/unit-tests/opt-file.exp:1.1	Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/opt-file.exp	Sun Dec  6 19:00:48 2020
@@ -1 +1,2 @@
+value
 exit status 0

Index: src/usr.bin/make/unit-tests/opt-file.mk
diff -u src/usr.bin/make/unit-tests/opt-file.mk:1.2 src/usr.bin/make/unit-tests/opt-file.mk:1.3
--- src/usr.bin/make/unit-tests/opt-file.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/opt-file.mk	Sun Dec  6 19:00:48 2020
@@ -1,8 +1,17 @@
-# $NetBSD: opt-file.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: opt-file.mk,v 1.3 2020/12/06 19:00:48 rillig Exp $
 #
 # Tests for the -f command line option.
 
 # TODO: Implementation
 
+all: .PHONY file-ending-in-backslash
+
+# Passing '-' as the filename reads from stdin.  This is unusual but possible.
+#
+# In the unlikely case where a file ends in a backslash instead of a newline,
+# that backslash is trimmed.  See ParseGetLine.
+file-ending-in-backslash: .PHONY
+	@printf '%s' 'VAR=value\' | ${MAKE} -r -f - -v VAR
+
 all:
 	@:;



CVS commit: src/usr.sbin/acpitools/acpidump

2020-12-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Dec  6 18:38:58 UTC 2020

Modified Files:
src/usr.sbin/acpitools/acpidump: acpi.c

Log Message:
acpidump: Do not print FACS if HW_REDUCED flag is set.

According to ACPI 6.3 spec, FACS is optional when HW_REDUCED is set. ACPICA
ignores the FACS completely when HW_REDUCED is set, so we need to follow
suit since it is not available through /dev/acpi as the table is not
installed.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/usr.sbin/acpitools/acpidump/acpi.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.sbin/acpitools/acpidump/acpi.c
diff -u src/usr.sbin/acpitools/acpidump/acpi.c:1.46 src/usr.sbin/acpitools/acpidump/acpi.c:1.47
--- src/usr.sbin/acpitools/acpidump/acpi.c:1.46	Sat Jun 22 12:39:40 2019
+++ src/usr.sbin/acpitools/acpidump/acpi.c	Sun Dec  6 18:38:58 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi.c,v 1.46 2019/06/22 12:39:40 maxv Exp $ */
+/* $NetBSD: acpi.c,v 1.47 2020/12/06 18:38:58 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 1998 Doug Rabson
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: acpi.c,v 1.46 2019/06/22 12:39:40 maxv Exp $");
+__RCSID("$NetBSD: acpi.c,v 1.47 2020/12/06 18:38:58 jmcneill Exp $");
 
 #include 
 #include 
@@ -836,7 +836,7 @@ acpi_handle_fadt(ACPI_TABLE_HEADER *sdp)
 	if (acpi_select_address(fadt->Facs, fadt->XFacs) == 0) {
 		if ((fadt->Flags & ACPI_FADT_HW_REDUCED) == 0)
 			errx(EXIT_FAILURE, "Missing FACS and HW_REDUCED_ACPI flag not set in FADT");
-	} else {
+	} else if ((fadt->Flags & ACPI_FADT_HW_REDUCED) == 0) {
 		facs = (ACPI_TABLE_FACS *)acpi_map_sdt(
 			acpi_select_address(fadt->Facs, fadt->XFacs));
 		if (memcmp(facs->Signature, ACPI_SIG_FACS, 4) != 0 || facs->Length < 64)



CVS commit: src/usr.bin/make

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec  6 18:37:04 UTC 2020

Modified Files:
src/usr.bin/make: parse.c

Log Message:
make(1): fix undefined behavior in ParseEOF

Adding a number to a null pointer should have been caught by any
Undefined Behavior Sanitizer, but apparently neither GCC nor Clang do
this.


To generate a diff of this commit:
cvs rdiff -u -r1.469 -r1.470 src/usr.bin/make/parse.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/parse.c
diff -u src/usr.bin/make/parse.c:1.469 src/usr.bin/make/parse.c:1.470
--- src/usr.bin/make/parse.c:1.469	Sat Dec  5 19:46:04 2020
+++ src/usr.bin/make/parse.c	Sun Dec  6 18:37:04 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.469 2020/12/05 19:46:04 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.470 2020/12/06 18:37:04 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.469 2020/12/05 19:46:04 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.470 2020/12/06 18:37:04 rillig Exp $");
 
 /* types and constants */
 
@@ -2623,7 +2623,7 @@ ParseEOF(void)
 	ptr = curFile->nextbuf(curFile->nextbuf_arg, );
 	curFile->buf_ptr = ptr;
 	curFile->buf_freeIt = ptr;
-	curFile->buf_end = ptr + len; /* XXX: undefined behavior if ptr == NULL */
+	curFile->buf_end = ptr == NULL ? NULL : ptr + len;
 	curFile->lineno = curFile->first_lineno;
 	if (ptr != NULL)
 		return TRUE;	/* Iterate again */



CVS commit: src/usr.bin/make

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec  6 18:13:17 UTC 2020

Modified Files:
src/usr.bin/make: arch.c dir.c job.c make.c var.c

Log Message:
make(1): remove comment decoration


To generate a diff of this commit:
cvs rdiff -u -r1.186 -r1.187 src/usr.bin/make/arch.c
cvs rdiff -u -r1.250 -r1.251 src/usr.bin/make/dir.c
cvs rdiff -u -r1.337 -r1.338 src/usr.bin/make/job.c
cvs rdiff -u -r1.226 -r1.227 src/usr.bin/make/make.c
cvs rdiff -u -r1.717 -r1.718 src/usr.bin/make/var.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/arch.c
diff -u src/usr.bin/make/arch.c:1.186 src/usr.bin/make/arch.c:1.187
--- src/usr.bin/make/arch.c:1.186	Sat Dec  5 18:15:40 2020
+++ src/usr.bin/make/arch.c	Sun Dec  6 18:13:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: arch.c,v 1.186 2020/12/05 18:15:40 rillig Exp $	*/
+/*	$NetBSD: arch.c,v 1.187 2020/12/06 18:13:17 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -125,7 +125,7 @@
 #include "config.h"
 
 /*	"@(#)arch.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: arch.c,v 1.186 2020/12/05 18:15:40 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.187 2020/12/06 18:13:17 rillig Exp $");
 
 typedef struct List ArchList;
 typedef struct ListNode ArchListNode;
@@ -593,22 +593,18 @@ badarch:
 }
 
 #ifdef SVR4ARCHIVES
-/*-
- *---
- * ArchSVR4Entry --
- *	Parse an SVR4 style entry that begins with a slash.
- *	If it is "//", then load the table of filenames
- *	If it is "/", then try to substitute the long file name
- *	from offset of a table previously read.
- *	If a table is read, the file pointer is moved to the next archive
- *	member.
+/*
+ * Parse an SVR4 style entry that begins with a slash.
+ * If it is "//", then load the table of filenames.
+ * If it is "/", then try to substitute the long file name
+ * from offset of a table previously read.
+ * If a table is read, the file pointer is moved to the next archive member.
  *
  * Results:
  *	-1: Bad data in archive
  *	 0: A table was loaded from the file
  *	 1: Name was successfully substituted from table
  *	 2: Name was not successfully substituted from table
- *---
  */
 static int
 ArchSVR4Entry(Arch *ar, char *inout_name, size_t size, FILE *arch)

Index: src/usr.bin/make/dir.c
diff -u src/usr.bin/make/dir.c:1.250 src/usr.bin/make/dir.c:1.251
--- src/usr.bin/make/dir.c:1.250	Sun Dec  6 10:49:02 2020
+++ src/usr.bin/make/dir.c	Sun Dec  6 18:13:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.250 2020/12/06 10:49:02 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.251 2020/12/06 18:13:17 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -136,7 +136,7 @@
 #include "job.h"
 
 /*	"@(#)dir.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: dir.c,v 1.250 2020/12/06 10:49:02 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.251 2020/12/06 18:13:17 rillig Exp $");
 
 /* A search path is a list of CachedDir structures. A CachedDir has in it the
  * name of the directory and the names of all the files in the directory.
@@ -1554,26 +1554,19 @@ Dir_CopyDirSearchPath(void)
 	return path;
 }
 
-/*-
- *---
- * SearchPath_ToFlags --
- *	Make a string by taking all the directories in the given search
- *	path and preceding them by the given flag. Used by the suffix
- *	module to create variables for compilers based on suffix search
- *	paths.
+/*
+ * Make a string by taking all the directories in the given search path and
+ * preceding them by the given flag. Used by the suffix module to create
+ * variables for compilers based on suffix search paths.
  *
  * Input:
  *	flag		flag which should precede each directory
  *	path		list of directories
  *
  * Results:
- *	The string mentioned above. Note that there is no space between
- *	the given flag and each directory. The empty string is returned if
- *	Things don't go well.
- *
- * Side Effects:
- *	None
- *---
+ *	The string mentioned above. Note that there is no space between the
+ *	given flag and each directory. The empty string is returned if things
+ *	don't go well.
  */
 char *
 SearchPath_ToFlags(const char *flag, SearchPath *path)

Index: src/usr.bin/make/job.c
diff -u src/usr.bin/make/job.c:1.337 src/usr.bin/make/job.c:1.338
--- src/usr.bin/make/job.c:1.337	Sat Dec  5 18:15:40 2020
+++ src/usr.bin/make/job.c	Sun Dec  6 18:13:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.337 2020/12/05 18:15:40 rillig Exp $	*/
+/*	$NetBSD: job.c,v 1.338 2020/12/06 18:13:17 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -143,7 +143,7 @@
 #include "trace.h"
 
 /*	"@(#)job.c	8.2 (Berkeley) 

CVS commit: src/usr.bin/make

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec  6 17:41:53 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): move CleanEnv to UnexportVars

It clearly didn't belong in the GetVarnamesToUnexport part of the code.


To generate a diff of this commit:
cvs rdiff -u -r1.716 -r1.717 src/usr.bin/make/var.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/var.c
diff -u src/usr.bin/make/var.c:1.716 src/usr.bin/make/var.c:1.717
--- src/usr.bin/make/var.c:1.716	Sun Dec  6 17:35:51 2020
+++ src/usr.bin/make/var.c	Sun Dec  6 17:41:52 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.716 2020/12/06 17:35:51 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.717 2020/12/06 17:41:52 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -130,7 +130,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.716 2020/12/06 17:35:51 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.717 2020/12/06 17:41:52 rillig Exp $");
 
 /* A string that may need to be freed after use. */
 typedef struct FStr {
@@ -758,10 +758,9 @@ GetVarnamesToUnexport(const char *str,
 	FStr varnames = FSTR_INIT;
 
 	str += strlen("unexport");
-	if (strncmp(str, "-env", 4) == 0) {
-		ClearEnv();
+	if (strncmp(str, "-env", 4) == 0)
 		what = UNEXPORT_ENV;
-	} else {
+	else {
 		cpp_skip_whitespace();
 		what = str[0] != '\0' ? UNEXPORT_NAMED : UNEXPORT_ALL;
 		if (what == UNEXPORT_NAMED)
@@ -814,8 +813,12 @@ static void
 UnexportVars(FStr *varnames, UnexportWhat what)
 {
 	size_t i;
+	Words words;
+
+	if (what == UNEXPORT_ENV)
+		ClearEnv();
 
-	Words words = Str_Words(varnames->str, FALSE);
+	words = Str_Words(varnames->str, FALSE);
 	for (i = 0; i < words.len; i++) {
 		const char *varname = words.words[i];
 		UnexportVar(varname, what);



CVS commit: src/usr.bin/make

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec  6 17:35:52 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): extract UnexportVars from Var_UnExport


To generate a diff of this commit:
cvs rdiff -u -r1.715 -r1.716 src/usr.bin/make/var.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/var.c
diff -u src/usr.bin/make/var.c:1.715 src/usr.bin/make/var.c:1.716
--- src/usr.bin/make/var.c:1.715	Sun Dec  6 17:27:10 2020
+++ src/usr.bin/make/var.c	Sun Dec  6 17:35:51 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.715 2020/12/06 17:27:10 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.716 2020/12/06 17:35:51 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -130,7 +130,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.715 2020/12/06 17:27:10 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.716 2020/12/06 17:35:51 rillig Exp $");
 
 /* A string that may need to be freed after use. */
 typedef struct FStr {
@@ -810,6 +810,22 @@ UnexportVar(const char *varname, Unexpor
 	}
 }
 
+static void
+UnexportVars(FStr *varnames, UnexportWhat what)
+{
+	size_t i;
+
+	Words words = Str_Words(varnames->str, FALSE);
+	for (i = 0; i < words.len; i++) {
+		const char *varname = words.words[i];
+		UnexportVar(varname, what);
+	}
+	Words_Free(words);
+
+	if (what != UNEXPORT_NAMED)
+		Var_Delete(MAKE_EXPORTED, VAR_GLOBAL);
+}
+
 /*
  * This is called when .unexport[-env] is seen.
  *
@@ -822,21 +838,7 @@ Var_UnExport(const char *str)
 	FStr varnames;
 
 	GetVarnamesToUnexport(str, , );
-
-	{
-		size_t i;
-
-		Words words = Str_Words(varnames.str, FALSE);
-		for (i = 0; i < words.len; i++) {
-			const char *varname = words.words[i];
-			UnexportVar(varname, what);
-		}
-		Words_Free(words);
-
-		if (what != UNEXPORT_NAMED)
-			Var_Delete(MAKE_EXPORTED, VAR_GLOBAL);
-	}
-
+	UnexportVars(, what);
 	FStr_Done();
 }
 



CVS commit: src/usr.bin/make/unit-tests

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec  6 17:29:27 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: directive-unexport-env.mk

Log Message:
make(1): fix comment in test for directive unexport-env


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/usr.bin/make/unit-tests/directive-unexport-env.mk

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/unit-tests/directive-unexport-env.mk
diff -u src/usr.bin/make/unit-tests/directive-unexport-env.mk:1.4 src/usr.bin/make/unit-tests/directive-unexport-env.mk:1.5
--- src/usr.bin/make/unit-tests/directive-unexport-env.mk:1.4	Sun Dec  6 16:06:11 2020
+++ src/usr.bin/make/unit-tests/directive-unexport-env.mk	Sun Dec  6 17:29:27 2020
@@ -1,4 +1,4 @@
-# $NetBSD: directive-unexport-env.mk,v 1.4 2020/12/06 16:06:11 rillig Exp $
+# $NetBSD: directive-unexport-env.mk,v 1.5 2020/12/06 17:29:27 rillig Exp $
 #
 # Tests for the .unexport-env directive.
 
@@ -8,11 +8,8 @@
 .unexport-env			# ok
 .unexport-environment		# oops: misspelled
 
-# Before 2020-12-06, the directive unexport-env was implemented strangely.
-# According to its documentation, it does not take any arguments, but the
-# Implementation accepted variable names as arguments and produced wrong debug
-# logging for them, saying "Unexporting" for variables that at this point were
-# not exported anymore.
+# As of 2020-12-06, the directive unexport-env is not supposed to accept
+# arguments, but it does without complaining about them.
 .MAKEFLAGS: -dv
 UT_EXPORTED=	value
 UT_UNEXPORTED=	value



CVS commit: src/usr.bin/make

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec  6 17:27:11 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): clean up GetVarnamesToUnexport


To generate a diff of this commit:
cvs rdiff -u -r1.714 -r1.715 src/usr.bin/make/var.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/var.c
diff -u src/usr.bin/make/var.c:1.714 src/usr.bin/make/var.c:1.715
--- src/usr.bin/make/var.c:1.714	Sun Dec  6 17:22:44 2020
+++ src/usr.bin/make/var.c	Sun Dec  6 17:27:10 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.714 2020/12/06 17:22:44 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.715 2020/12/06 17:27:10 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -130,7 +130,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.714 2020/12/06 17:22:44 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.715 2020/12/06 17:27:10 rillig Exp $");
 
 /* A string that may need to be freed after use. */
 typedef struct FStr {
@@ -752,8 +752,7 @@ ClearEnv(void)
 
 static void
 GetVarnamesToUnexport(const char *str,
-		  const char **out_args, FStr *out_varnames,
-		  UnexportWhat *out_what)
+		  FStr *out_varnames, UnexportWhat *out_what)
 {
 	UnexportWhat what;
 	FStr varnames = FSTR_INIT;
@@ -768,7 +767,6 @@ GetVarnamesToUnexport(const char *str,
 		if (what == UNEXPORT_NAMED)
 			FStr_Assign(, str, NULL);
 	}
-	*out_args = str;
 
 	if (what != UNEXPORT_NAMED) {
 		char *expanded;
@@ -822,9 +820,8 @@ Var_UnExport(const char *str)
 {
 	UnexportWhat what;
 	FStr varnames;
-	const char *args;
 
-	GetVarnamesToUnexport(str, , , );
+	GetVarnamesToUnexport(str, , );
 
 	{
 		size_t i;
@@ -835,7 +832,8 @@ Var_UnExport(const char *str)
 			UnexportVar(varname, what);
 		}
 		Words_Free(words);
-		if (varnames.str != args)
+
+		if (what != UNEXPORT_NAMED)
 			Var_Delete(MAKE_EXPORTED, VAR_GLOBAL);
 	}
 



CVS commit: src/usr.bin/make

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec  6 17:22:45 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): extract GetVarnamesToUnexport from Var_UnExport


To generate a diff of this commit:
cvs rdiff -u -r1.713 -r1.714 src/usr.bin/make/var.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/var.c
diff -u src/usr.bin/make/var.c:1.713 src/usr.bin/make/var.c:1.714
--- src/usr.bin/make/var.c:1.713	Sun Dec  6 16:24:30 2020
+++ src/usr.bin/make/var.c	Sun Dec  6 17:22:44 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.713 2020/12/06 16:24:30 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.714 2020/12/06 17:22:44 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -130,7 +130,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.713 2020/12/06 16:24:30 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.714 2020/12/06 17:22:44 rillig Exp $");
 
 /* A string that may need to be freed after use. */
 typedef struct FStr {
@@ -725,7 +725,7 @@ Var_Export(const char *str, Boolean isEx
 extern char **environ;
 
 static void
-UnexportEnv(void)
+ClearEnv(void)
 {
 	const char *cp;
 	char **newenv;
@@ -751,6 +751,39 @@ UnexportEnv(void)
 }
 
 static void
+GetVarnamesToUnexport(const char *str,
+		  const char **out_args, FStr *out_varnames,
+		  UnexportWhat *out_what)
+{
+	UnexportWhat what;
+	FStr varnames = FSTR_INIT;
+
+	str += strlen("unexport");
+	if (strncmp(str, "-env", 4) == 0) {
+		ClearEnv();
+		what = UNEXPORT_ENV;
+	} else {
+		cpp_skip_whitespace();
+		what = str[0] != '\0' ? UNEXPORT_NAMED : UNEXPORT_ALL;
+		if (what == UNEXPORT_NAMED)
+			FStr_Assign(, str, NULL);
+	}
+	*out_args = str;
+
+	if (what != UNEXPORT_NAMED) {
+		char *expanded;
+		/* Using .MAKE.EXPORTED */
+		(void)Var_Subst("${" MAKE_EXPORTED ":O:u}", VAR_GLOBAL,
+		VARE_WANTRES, );
+		/* TODO: handle errors */
+		FStr_Assign(, expanded, expanded);
+	}
+
+	*out_varnames = varnames;
+	*out_what = what;
+}
+
+static void
 UnexportVar(const char *varname, UnexportWhat what)
 {
 	Var *v = VarFind(varname, VAR_GLOBAL, FALSE);
@@ -788,27 +821,10 @@ void
 Var_UnExport(const char *str)
 {
 	UnexportWhat what;
-	FStr varnames = FSTR_INIT;
-
-	str += strlen("unexport");
-	if (strncmp(str, "-env", 4) == 0) {
-		UnexportEnv();
-		what = UNEXPORT_ENV;
-	} else {
-		cpp_skip_whitespace();
-		what = str[0] != '\0' ? UNEXPORT_NAMED : UNEXPORT_ALL;
-		if (what == UNEXPORT_NAMED)
-			FStr_Assign(, str, NULL);
-	}
+	FStr varnames;
+	const char *args;
 
-	if (what != UNEXPORT_NAMED) {
-		char *expanded;
-		/* Using .MAKE.EXPORTED */
-		(void)Var_Subst("${" MAKE_EXPORTED ":O:u}", VAR_GLOBAL,
-		VARE_WANTRES, );
-		/* TODO: handle errors */
-		FStr_Assign(, expanded, expanded);
-	}
+	GetVarnamesToUnexport(str, , , );
 
 	{
 		size_t i;
@@ -819,7 +835,7 @@ Var_UnExport(const char *str)
 			UnexportVar(varname, what);
 		}
 		Words_Free(words);
-		if (varnames.str != str)
+		if (varnames.str != args)
 			Var_Delete(MAKE_EXPORTED, VAR_GLOBAL);
 	}
 



CVS commit: src/usr.bin/make

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec  6 16:24:30 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): replace pointer comparisons with enum

Keeping track of what it means if varname.str == str is not as
expressive as declaring what exactly to unexport.


To generate a diff of this commit:
cvs rdiff -u -r1.712 -r1.713 src/usr.bin/make/var.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/var.c
diff -u src/usr.bin/make/var.c:1.712 src/usr.bin/make/var.c:1.713
--- src/usr.bin/make/var.c:1.712	Sun Dec  6 15:40:46 2020
+++ src/usr.bin/make/var.c	Sun Dec  6 16:24:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.712 2020/12/06 15:40:46 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.713 2020/12/06 16:24:30 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -130,7 +130,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.712 2020/12/06 15:40:46 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.713 2020/12/06 16:24:30 rillig Exp $");
 
 /* A string that may need to be freed after use. */
 typedef struct FStr {
@@ -233,6 +233,12 @@ typedef enum VarExportedMode {
 	VAR_EXPORTED_ALL
 } VarExportedMode;
 
+typedef enum UnexportWhat {
+	UNEXPORT_NAMED,
+	UNEXPORT_ALL,
+	UNEXPORT_ENV
+} UnexportWhat;
+
 /* Flags for pattern matching in the :S and :C modifiers */
 typedef enum VarPatternFlags {
 	VARP_NONE		= 0,
@@ -745,7 +751,7 @@ UnexportEnv(void)
 }
 
 static void
-UnexportVar(const char *varname, Boolean unexport_env, Boolean adjust)
+UnexportVar(const char *varname, UnexportWhat what)
 {
 	Var *v = VarFind(varname, VAR_GLOBAL, FALSE);
 	if (v == NULL) {
@@ -754,13 +760,13 @@ UnexportVar(const char *varname, Boolean
 	}
 
 	DEBUG1(VAR, "Unexporting \"%s\"\n", varname);
-	if (!unexport_env && (v->flags & VAR_EXPORTED) &&
-	!(v->flags & VAR_REEXPORT))
+	if (what != UNEXPORT_ENV &&
+	(v->flags & VAR_EXPORTED) && !(v->flags & VAR_REEXPORT))
 		unsetenv(v->name.str);
 	v->flags &= ~(unsigned)(VAR_EXPORTED | VAR_REEXPORT);
 
-	/* If we are unexporting a list, remove each one from .MAKE.EXPORTED. */
-	if (adjust) {
+	if (what == UNEXPORT_NAMED) {
+		/* Remove the variable names from .MAKE.EXPORTED. */
 		/* XXX: v->name is injected without escaping it */
 		char *expr = str_concat3("${" MAKE_EXPORTED ":N",
 		v->name.str, "}");
@@ -781,20 +787,21 @@ UnexportVar(const char *varname, Boolean
 void
 Var_UnExport(const char *str)
 {
+	UnexportWhat what;
 	FStr varnames = FSTR_INIT;
-	Boolean unexport_env;
 
 	str += strlen("unexport");
-	unexport_env = strncmp(str, "-env", 4) == 0;
-	if (unexport_env) {
+	if (strncmp(str, "-env", 4) == 0) {
 		UnexportEnv();
+		what = UNEXPORT_ENV;
 	} else {
 		cpp_skip_whitespace();
-		if (str[0] != '\0')
+		what = str[0] != '\0' ? UNEXPORT_NAMED : UNEXPORT_ALL;
+		if (what == UNEXPORT_NAMED)
 			FStr_Assign(, str, NULL);
 	}
 
-	if (varnames.str == NULL) {
+	if (what != UNEXPORT_NAMED) {
 		char *expanded;
 		/* Using .MAKE.EXPORTED */
 		(void)Var_Subst("${" MAKE_EXPORTED ":O:u}", VAR_GLOBAL,
@@ -809,7 +816,7 @@ Var_UnExport(const char *str)
 		Words words = Str_Words(varnames.str, FALSE);
 		for (i = 0; i < words.len; i++) {
 			const char *varname = words.words[i];
-			UnexportVar(varname, unexport_env, varnames.str == str);
+			UnexportVar(varname, what);
 		}
 		Words_Free(words);
 		if (varnames.str != str)



CVS commit: src/usr.bin/make/unit-tests

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec  6 16:06:11 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: directive-unexport-env.exp
directive-unexport-env.mk

Log Message:
make(1): add test for directive unexport-env


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/usr.bin/make/unit-tests/directive-unexport-env.exp
cvs rdiff -u -r1.3 -r1.4 \
src/usr.bin/make/unit-tests/directive-unexport-env.mk

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/unit-tests/directive-unexport-env.exp
diff -u src/usr.bin/make/unit-tests/directive-unexport-env.exp:1.1 src/usr.bin/make/unit-tests/directive-unexport-env.exp:1.2
--- src/usr.bin/make/unit-tests/directive-unexport-env.exp:1.1	Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/directive-unexport-env.exp	Sun Dec  6 16:06:11 2020
@@ -1 +1,13 @@
+Global:UT_EXPORTED = value
+Global:UT_UNEXPORTED = value
+Global:.MAKE.EXPORTED = UT_EXPORTED
+Var_Parse: ${.MAKE.EXPORTED:O:u} with VARE_WANTRES
+Applying ${.MAKE.EXPORTED:O} to "UT_EXPORTED" (VARE_WANTRES, none, none)
+Result of ${.MAKE.EXPORTED:O} is "UT_EXPORTED" (VARE_WANTRES, none, none)
+Applying ${.MAKE.EXPORTED:u} to "UT_EXPORTED" (VARE_WANTRES, none, none)
+Result of ${.MAKE.EXPORTED:u} is "UT_EXPORTED" (VARE_WANTRES, none, none)
+Unexporting "UT_EXPORTED"
+Global:delete .MAKE.EXPORTED
+Global:.MAKEFLAGS =  -r -k -d v -d
+Global:.MAKEFLAGS =  -r -k -d v -d 0
 exit status 0

Index: src/usr.bin/make/unit-tests/directive-unexport-env.mk
diff -u src/usr.bin/make/unit-tests/directive-unexport-env.mk:1.3 src/usr.bin/make/unit-tests/directive-unexport-env.mk:1.4
--- src/usr.bin/make/unit-tests/directive-unexport-env.mk:1.3	Tue Nov  3 17:17:31 2020
+++ src/usr.bin/make/unit-tests/directive-unexport-env.mk	Sun Dec  6 16:06:11 2020
@@ -1,4 +1,4 @@
-# $NetBSD: directive-unexport-env.mk,v 1.3 2020/11/03 17:17:31 rillig Exp $
+# $NetBSD: directive-unexport-env.mk,v 1.4 2020/12/06 16:06:11 rillig Exp $
 #
 # Tests for the .unexport-env directive.
 
@@ -8,5 +8,17 @@
 .unexport-env			# ok
 .unexport-environment		# oops: misspelled
 
+# Before 2020-12-06, the directive unexport-env was implemented strangely.
+# According to its documentation, it does not take any arguments, but the
+# Implementation accepted variable names as arguments and produced wrong debug
+# logging for them, saying "Unexporting" for variables that at this point were
+# not exported anymore.
+.MAKEFLAGS: -dv
+UT_EXPORTED=	value
+UT_UNEXPORTED=	value
+.export UT_EXPORTED
+.unexport-env UT_EXPORTED UT_UNEXPORTED
+.MAKEFLAGS: -d0
+
 all:
 	@:;



CVS commit: src/usr.bin/make

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec  6 15:40:46 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): use FStr in Var_UnExport


To generate a diff of this commit:
cvs rdiff -u -r1.711 -r1.712 src/usr.bin/make/var.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/var.c
diff -u src/usr.bin/make/var.c:1.711 src/usr.bin/make/var.c:1.712
--- src/usr.bin/make/var.c:1.711	Sun Dec  6 14:50:09 2020
+++ src/usr.bin/make/var.c	Sun Dec  6 15:40:46 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.711 2020/12/06 14:50:09 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.712 2020/12/06 15:40:46 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -130,7 +130,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.711 2020/12/06 14:50:09 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.712 2020/12/06 15:40:46 rillig Exp $");
 
 /* A string that may need to be freed after use. */
 typedef struct FStr {
@@ -311,6 +311,16 @@ ENUM_FLAGS_RTTI_6(VarFlags,
 
 static VarExportedMode var_exportedVars = VAR_EXPORTED_NONE;
 
+#define FSTR_INIT { NULL, NULL }
+
+static void
+FStr_Assign(FStr *fstr, const char *str, void *freeIt)
+{
+	free(fstr->freeIt);
+	fstr->str = str;
+	fstr->freeIt = freeIt;
+}
+
 static void
 FStr_Done(FStr *fstr)
 {
@@ -771,13 +781,9 @@ UnexportVar(const char *varname, Boolean
 void
 Var_UnExport(const char *str)
 {
-	const char *varnames;
-	char *varnames_freeIt;
+	FStr varnames = FSTR_INIT;
 	Boolean unexport_env;
 
-	varnames = NULL;
-	varnames_freeIt = NULL;
-
 	str += strlen("unexport");
 	unexport_env = strncmp(str, "-env", 4) == 0;
 	if (unexport_env) {
@@ -785,31 +791,32 @@ Var_UnExport(const char *str)
 	} else {
 		cpp_skip_whitespace();
 		if (str[0] != '\0')
-			varnames = str;
+			FStr_Assign(, str, NULL);
 	}
 
-	if (varnames == NULL) {
+	if (varnames.str == NULL) {
+		char *expanded;
 		/* Using .MAKE.EXPORTED */
 		(void)Var_Subst("${" MAKE_EXPORTED ":O:u}", VAR_GLOBAL,
-		VARE_WANTRES, _freeIt);
+		VARE_WANTRES, );
 		/* TODO: handle errors */
-		varnames = varnames_freeIt;
+		FStr_Assign(, expanded, expanded);
 	}
 
 	{
 		size_t i;
 
-		Words words = Str_Words(varnames, FALSE);
+		Words words = Str_Words(varnames.str, FALSE);
 		for (i = 0; i < words.len; i++) {
 			const char *varname = words.words[i];
-			UnexportVar(varname, unexport_env, varnames == str);
+			UnexportVar(varname, unexport_env, varnames.str == str);
 		}
 		Words_Free(words);
-		if (varnames != str) {
+		if (varnames.str != str)
 			Var_Delete(MAKE_EXPORTED, VAR_GLOBAL);
-			free(varnames_freeIt);
-		}
 	}
+
+	FStr_Done();
 }
 
 /* See Var_Set for documentation. */



CVS commit: src/external/gpl3/gdb/bin

2020-12-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Dec  6 15:00:25 UTC 2020

Modified Files:
src/external/gpl3/gdb/bin: Makefile

Log Message:
Don't descend to gdbserver for now


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/gpl3/gdb/bin/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/gpl3/gdb/bin/Makefile
diff -u src/external/gpl3/gdb/bin/Makefile:1.3 src/external/gpl3/gdb/bin/Makefile:1.4
--- src/external/gpl3/gdb/bin/Makefile:1.3	Sat Dec  5 16:27:06 2020
+++ src/external/gpl3/gdb/bin/Makefile	Sun Dec  6 10:00:25 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.3 2020/12/05 21:27:06 christos Exp $
+#	$NetBSD: Makefile,v 1.4 2020/12/06 15:00:25 christos Exp $
 
 .include "../Makefile.inc"
 
@@ -9,9 +9,9 @@ SUBDIR+=  gdb
 SUBDIR+= gdbtui
 .endif
 
-.if ${MACHINE} == "amd64"
-SUBDIR+= gdbserver
-.endif
+#.if ${MACHINE} == "amd64"
+#SUBDIR+= gdbserver
+#.endif
 
 .if ${MACHINE_ARCH} == powerpc || ${MACHINE_ARCH} == powerpcle || \
 ${MACHINE_ARCH} == powerpc64



CVS commit: src/usr.bin/make

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec  6 14:50:09 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): add FStr to var.c to make memory handling simpler

The pattern of having a variable and a corresponding freeIt variable
appears over and over again in make, so cast it into a struct.


To generate a diff of this commit:
cvs rdiff -u -r1.710 -r1.711 src/usr.bin/make/var.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/var.c
diff -u src/usr.bin/make/var.c:1.710 src/usr.bin/make/var.c:1.711
--- src/usr.bin/make/var.c:1.710	Sun Dec  6 14:20:20 2020
+++ src/usr.bin/make/var.c	Sun Dec  6 14:50:09 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.710 2020/12/06 14:20:20 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.711 2020/12/06 14:50:09 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -130,8 +130,13 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.710 2020/12/06 14:20:20 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.711 2020/12/06 14:50:09 rillig Exp $");
 
+/* A string that may need to be freed after use. */
+typedef struct FStr {
+	const char *str;
+	void *freeIt;
+} FStr;
 
 typedef enum VarFlags {
 	VAR_NONE	= 0,
@@ -198,8 +203,7 @@ typedef struct Var {
 	 * For context variables, it aliases the corresponding HashEntry name.
 	 * For environment and undefined variables, it is allocated.
 	 */
-	const char *name;
-	void *name_freeIt;
+	FStr name;
 
 	/* The unexpanded value of the variable. */
 	Buffer val;
@@ -307,13 +311,19 @@ ENUM_FLAGS_RTTI_6(VarFlags,
 
 static VarExportedMode var_exportedVars = VAR_EXPORTED_NONE;
 
+static void
+FStr_Done(FStr *fstr)
+{
+	free(fstr->freeIt);
+}
+
 static Var *
 VarNew(const char *name, void *name_freeIt, const char *value, VarFlags flags)
 {
 	size_t value_len = strlen(value);
 	Var *var = bmake_malloc(sizeof *var);
-	var->name = name;
-	var->name_freeIt = name_freeIt;
+	var->name.str = name;
+	var->name.freeIt = name_freeIt;
 	Buf_InitSize(>val, value_len + 1);
 	Buf_AddBytes(>val, value, value_len);
 	var->flags = flags;
@@ -455,7 +465,7 @@ VarFreeEnv(Var *v, Boolean freeValue)
 	if (!(v->flags & VAR_FROM_ENV))
 		return FALSE;
 
-	free(v->name_freeIt);
+	FStr_Done(>name);
 	Buf_Destroy(>val, freeValue);
 	free(v);
 	return TRUE;
@@ -495,10 +505,10 @@ Var_Delete(const char *name, GNode *ctxt
 	if (he != NULL) {
 		Var *v = HashEntry_Get(he);
 		if (v->flags & VAR_EXPORTED)
-			unsetenv(v->name);
-		if (strcmp(v->name, MAKE_EXPORTED) == 0)
+			unsetenv(v->name.str);
+		if (strcmp(v->name.str, MAKE_EXPORTED) == 0)
 			var_exportedVars = VAR_EXPORTED_NONE;
-		assert(v->name_freeIt == NULL);
+		assert(v->name.freeIt == NULL);
 		HashTable_DeleteEntry(>vars, he);
 		Buf_Destroy(>val, TRUE);
 		free(v);
@@ -625,7 +635,7 @@ Var_ExportVars(void)
 		HashIter_Init(, _GLOBAL->vars);
 		while (HashIter_Next() != NULL) {
 			Var *var = hi.entry->value;
-			Var_Export1(var->name, VAR_EXPORT_NORMAL);
+			Var_Export1(var->name.str, VAR_EXPORT_NORMAL);
 		}
 		return;
 	}
@@ -736,13 +746,14 @@ UnexportVar(const char *varname, Boolean
 	DEBUG1(VAR, "Unexporting \"%s\"\n", varname);
 	if (!unexport_env && (v->flags & VAR_EXPORTED) &&
 	!(v->flags & VAR_REEXPORT))
-		unsetenv(v->name);
+		unsetenv(v->name.str);
 	v->flags &= ~(unsigned)(VAR_EXPORTED | VAR_REEXPORT);
 
 	/* If we are unexporting a list, remove each one from .MAKE.EXPORTED. */
 	if (adjust) {
 		/* XXX: v->name is injected without escaping it */
-		char *expr = str_concat3("${" MAKE_EXPORTED ":N", v->name, "}");
+		char *expr = str_concat3("${" MAKE_EXPORTED ":N",
+		v->name.str, "}");
 		char *cp;
 		(void)Var_Subst(expr, VAR_GLOBAL, VARE_WANTRES, );
 		/* TODO: handle errors */
@@ -2047,7 +2058,7 @@ ParseModifierPart(
 	if (*p != delim) {
 		*pp = p;
 		Error("Unfinished modifier for %s ('%c' missing)",
-		st->var->name, delim);
+		st->var->name.str, delim);
 		*out_part = NULL;
 		return VPR_PARSE_MSG;
 	}
@@ -2158,7 +2169,7 @@ ApplyModifier_Loop(const char **pp, Appl
 		Parse_Error(PARSE_FATAL,
 		"In the :@ modifier of \"%s\", the variable name \"%s\" "
 		"must not contain a dollar.",
-		st->var->name, args.tvar);
+		st->var->name.str, args.tvar);
 		return AMR_CLEANUP;
 	}
 
@@ -2246,7 +2257,7 @@ static ApplyModifierResult
 ApplyModifier_Literal(const char **pp, ApplyModifiersState *st)
 {
 	ApplyModifiersState_Define(st);
-	st->newVal = bmake_strdup(st->var->name);
+	st->newVal = bmake_strdup(st->var->name.str);
 	(*pp)++;
 	return AMR_OK;
 }
@@ -2343,17 +2354,17 @@ ApplyModifier_Path(const char **pp, Appl
 
 	ApplyModifiersState_Define(st);
 
-	gn = Targ_FindNode(st->var->name);
+	gn = Targ_FindNode(st->var->name.str);
 	if (gn == NULL || gn->type & OP_NOPATH) {
 		path = NULL;
 	} else if (gn->path != NULL) {
 		path = bmake_strdup(gn->path);
 	} else {
 		

CVS commit: src/share/mk

2020-12-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Dec  6 14:28:34 UTC 2020

Modified Files:
src/share/mk: bsd.own.mk

Log Message:
Move everyone to gdb-11


To generate a diff of this commit:
cvs rdiff -u -r1.1234 -r1.1235 src/share/mk/bsd.own.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/mk/bsd.own.mk
diff -u src/share/mk/bsd.own.mk:1.1234 src/share/mk/bsd.own.mk:1.1235
--- src/share/mk/bsd.own.mk:1.1234	Tue Nov 17 05:49:41 2020
+++ src/share/mk/bsd.own.mk	Sun Dec  6 09:28:34 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: bsd.own.mk,v 1.1234 2020/11/17 10:49:41 rin Exp $
+#	$NetBSD: bsd.own.mk,v 1.1235 2020/12/06 14:28:34 christos Exp $
 
 # This needs to be before bsd.init.mk
 .if defined(BSD_MK_COMPAT_FILE)
@@ -102,11 +102,7 @@ EXTERNAL_BINUTILS_SUBDIR=	/does/not/exis
 #
 # What GDB is used?
 #
-.if ${MACHINE_ARCH} == "x86_64" || ${MACHINE_ARCH} == "i386"
 HAVE_GDB?=	1100
-.else
-HAVE_GDB?=	830
-.endif
 
 .if ${HAVE_GDB} == 1100
 EXTERNAL_GDB_SUBDIR=		gdb



CVS commit: src/external/gpl3/gdb

2020-12-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Dec  6 14:26:41 UTC 2020

Modified Files:
src/external/gpl3/gdb/dist/gdb: ppc-nbsd-tdep.c
src/external/gpl3/gdb/lib/libbfd/arch/powerpc: bfd_stdint.h targmatch.h
src/external/gpl3/gdb/lib/libdecnumber/arch/powerpc: gstdint.h
src/external/gpl3/gdb/lib/libgdb/arch/powerpc: config.h defs.mk init.c
jit-reader.h version.c xml-builtin.c
src/external/gpl3/gdb/lib/libgdbsupport/arch/powerpc: defs.mk
src/external/gpl3/gdb/lib/libgdbsupport/arch/powerpc/gdbsupport:
config.h
src/external/gpl3/gdb/lib/libgnulib/arch/powerpc: defs.mk
src/external/gpl3/gdb/lib/libgnulib/arch/powerpc/gnulib: config.h
src/external/gpl3/gdb/lib/libgnulib/arch/powerpc/gnulib/import:
unistd.h

Log Message:
fix powerpc


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/gpl3/gdb/dist/gdb/ppc-nbsd-tdep.c
cvs rdiff -u -r1.9 -r1.10 \
src/external/gpl3/gdb/lib/libbfd/arch/powerpc/bfd_stdint.h
cvs rdiff -u -r1.11 -r1.12 \
src/external/gpl3/gdb/lib/libbfd/arch/powerpc/targmatch.h
cvs rdiff -u -r1.9 -r1.10 \
src/external/gpl3/gdb/lib/libdecnumber/arch/powerpc/gstdint.h
cvs rdiff -u -r1.13 -r1.14 \
src/external/gpl3/gdb/lib/libgdb/arch/powerpc/config.h \
src/external/gpl3/gdb/lib/libgdb/arch/powerpc/defs.mk
cvs rdiff -u -r1.15 -r1.16 \
src/external/gpl3/gdb/lib/libgdb/arch/powerpc/init.c
cvs rdiff -u -r1.8 -r1.9 \
src/external/gpl3/gdb/lib/libgdb/arch/powerpc/jit-reader.h
cvs rdiff -u -r1.10 -r1.11 \
src/external/gpl3/gdb/lib/libgdb/arch/powerpc/version.c \
src/external/gpl3/gdb/lib/libgdb/arch/powerpc/xml-builtin.c
cvs rdiff -u -r1.2 -r1.3 \
src/external/gpl3/gdb/lib/libgdbsupport/arch/powerpc/defs.mk
cvs rdiff -u -r1.1 -r1.2 \
src/external/gpl3/gdb/lib/libgdbsupport/arch/powerpc/gdbsupport/config.h
cvs rdiff -u -r1.1 -r1.2 \
src/external/gpl3/gdb/lib/libgnulib/arch/powerpc/defs.mk
cvs rdiff -u -r1.1 -r1.2 \
src/external/gpl3/gdb/lib/libgnulib/arch/powerpc/gnulib/config.h
cvs rdiff -u -r1.1 -r1.2 \
src/external/gpl3/gdb/lib/libgnulib/arch/powerpc/gnulib/import/unistd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/gpl3/gdb/dist/gdb/ppc-nbsd-tdep.c
diff -u src/external/gpl3/gdb/dist/gdb/ppc-nbsd-tdep.c:1.6 src/external/gpl3/gdb/dist/gdb/ppc-nbsd-tdep.c:1.7
--- src/external/gpl3/gdb/dist/gdb/ppc-nbsd-tdep.c:1.6	Tue Oct  6 18:14:41 2020
+++ src/external/gpl3/gdb/dist/gdb/ppc-nbsd-tdep.c	Sun Dec  6 09:26:40 2020
@@ -29,6 +29,7 @@
 
 #include "ppc-tdep.h"
 #include "nbsd-tdep.h"
+#include "ppc-nbsd-tdep.h"
 #include "ppc-tdep.h"
 #include "solib-svr4.h"
 

Index: src/external/gpl3/gdb/lib/libbfd/arch/powerpc/bfd_stdint.h
diff -u src/external/gpl3/gdb/lib/libbfd/arch/powerpc/bfd_stdint.h:1.9 src/external/gpl3/gdb/lib/libbfd/arch/powerpc/bfd_stdint.h:1.10
--- src/external/gpl3/gdb/lib/libbfd/arch/powerpc/bfd_stdint.h:1.9	Sun Sep 20 12:54:17 2020
+++ src/external/gpl3/gdb/lib/libbfd/arch/powerpc/bfd_stdint.h	Sun Dec  6 09:26:40 2020
@@ -1,8 +1,8 @@
 /* This file is automatically generated.  DO NOT EDIT! */
-/* Generated from: NetBSD: mknative-gdb,v 1.12 2020/09/17 16:54:31 christos Exp  */
+/* Generated from: NetBSD: mknative-gdb,v 1.15 2020/12/05 21:27:31 christos Exp  */
 /* Generated from: NetBSD: mknative.common,v 1.16 2018/04/15 15:13:37 christos Exp  */
 
-/* generated for  powerpc--netbsd-gcc (NetBSD nb1 20200311) 8.4.0 */
+/* generated for  powerpc--netbsd-gcc (NetBSD nb1 20200907) 9.3.0 */
 
 #ifndef GCC_GENERATED_STDINT_H
 #define GCC_GENERATED_STDINT_H 1

Index: src/external/gpl3/gdb/lib/libbfd/arch/powerpc/targmatch.h
diff -u src/external/gpl3/gdb/lib/libbfd/arch/powerpc/targmatch.h:1.11 src/external/gpl3/gdb/lib/libbfd/arch/powerpc/targmatch.h:1.12
--- src/external/gpl3/gdb/lib/libbfd/arch/powerpc/targmatch.h:1.11	Sun Sep 20 12:54:17 2020
+++ src/external/gpl3/gdb/lib/libbfd/arch/powerpc/targmatch.h	Sun Dec  6 09:26:40 2020
@@ -1,5 +1,5 @@
 /* This file is automatically generated.  DO NOT EDIT! */
-/* Generated from: NetBSD: mknative-gdb,v 1.12 2020/09/17 16:54:31 christos Exp  */
+/* Generated from: NetBSD: mknative-gdb,v 1.15 2020/12/05 21:27:31 christos Exp  */
 /* Generated from: NetBSD: mknative.common,v 1.16 2018/04/15 15:13:37 christos Exp  */
 
 #ifdef BFD64
@@ -42,15 +42,6 @@
 
 #if !defined (SELECT_VECS) || defined (HAVE_aarch64_elf64_le_vec)
 
-{ "aarch64-*-netbsd*",
-_elf64_le_vec },
-#endif
-
-
-
-
-#if !defined (SELECT_VECS) || defined (HAVE_aarch64_elf64_le_vec)
-
 { "aarch64-*-fuchsia*",
 _elf64_le_vec },
 #endif
@@ -69,25 +60,7 @@
 
 #if !defined (SELECT_VECS) || defined (HAVE_aarch64_elf64_le_vec)
 
-{ "aarch64-*-linux*",
-_elf64_le_vec },
-#endif
-
-
-
-
-#if !defined (SELECT_VECS) || defined (HAVE_aarch64_elf64_be_vec)
-
-{ "aarch64_be-*-linux*",

CVS commit: src/usr.bin/make

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec  6 14:20:20 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): move type definitions in var.c to the top


To generate a diff of this commit:
cvs rdiff -u -r1.709 -r1.710 src/usr.bin/make/var.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/var.c
diff -u src/usr.bin/make/var.c:1.709 src/usr.bin/make/var.c:1.710
--- src/usr.bin/make/var.c:1.709	Sun Dec  6 13:51:06 2020
+++ src/usr.bin/make/var.c	Sun Dec  6 14:20:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.709 2020/12/06 13:51:06 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.710 2020/12/06 14:20:20 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -130,57 +130,8 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.709 2020/12/06 13:51:06 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.710 2020/12/06 14:20:20 rillig Exp $");
 
-ENUM_FLAGS_RTTI_3(VarEvalFlags,
-		  VARE_UNDEFERR, VARE_WANTRES, VARE_KEEP_DOLLAR);
-
-/*
- * This lets us tell if we have replaced the original environ
- * (which we cannot free).
- */
-char **savedEnv = NULL;
-
-/* Special return value for Var_Parse, indicating a parse error.  It may be
- * caused by an undefined variable, a syntax error in a modifier or
- * something entirely different. */
-char var_Error[] = "";
-
-/* Special return value for Var_Parse, indicating an undefined variable in
- * a case where VARE_UNDEFERR is not set.  This undefined variable is
- * typically a dynamic variable such as ${.TARGET}, whose expansion needs to
- * be deferred until it is defined in an actual target. */
-static char varUndefined[] = "";
-
-/*
- * Traditionally this make consumed $$ during := like any other expansion.
- * Other make's do not, and this make follows straight since 2016-01-09.
- *
- * This knob allows controlling the behavior.
- * FALSE to consume $$ during := assignment.
- * TRUE to preserve $$ during := assignment.
- */
-#define MAKE_SAVE_DOLLARS ".MAKE.SAVE_DOLLARS"
-static Boolean save_dollars = TRUE;
-
-/*
- * Internally, variables are contained in four different contexts.
- *	1) the environment. They cannot be changed. If an environment
- *	   variable is appended to, the result is placed in the global
- *	   context.
- *	2) the global context. Variables set in the makefiles are located
- *	   here.
- *	3) the command-line context. All variables set on the command line
- *	   are placed in this context.
- *	4) the local context. Each target has associated with it a context
- *	   list. On this list are located the structures describing such
- *	   local variables as $(@) and $(*)
- * The four contexts are searched in the reverse order from which they are
- * listed (but see opts.checkEnvFirst).
- */
-GNode  *VAR_INTERNAL;	/* variables from make itself */
-GNode  *VAR_GLOBAL;	/* variables from the makefile */
-GNode  *VAR_CMDLINE;	/* variables defined on the command-line */
 
 typedef enum VarFlags {
 	VAR_NONE	= 0,
@@ -223,10 +174,6 @@ typedef enum VarFlags {
 	VAR_READONLY = 0x80
 } VarFlags;
 
-ENUM_FLAGS_RTTI_6(VarFlags,
-		  VAR_IN_USE, VAR_FROM_ENV,
-		  VAR_EXPORTED, VAR_REEXPORT, VAR_FROM_CMD, VAR_READONLY);
-
 /* Variables are defined using one of the VAR=value assignments.  Their
  * value can be queried by expressions such as $V, ${VAR}, or with modifiers
  * such as ${VAR:S,from,to,g:Q}.
@@ -260,17 +207,6 @@ typedef struct Var {
 	VarFlags flags;
 } Var;
 
-/*
- * Exporting vars is expensive so skip it if we can
- */
-typedef enum VarExportedMode {
-	VAR_EXPORTED_NONE,
-	VAR_EXPORTED_SOME,
-	VAR_EXPORTED_ALL
-} VarExportedMode;
-
-static VarExportedMode var_exportedVars = VAR_EXPORTED_NONE;
-
 typedef enum VarExportFlags {
 	VAR_EXPORT_NORMAL = 0,
 	/*
@@ -284,6 +220,15 @@ typedef enum VarExportFlags {
 	VAR_EXPORT_LITERAL = 0x02
 } VarExportFlags;
 
+/*
+ * Exporting vars is expensive so skip it if we can
+ */
+typedef enum VarExportedMode {
+	VAR_EXPORTED_NONE,
+	VAR_EXPORTED_SOME,
+	VAR_EXPORTED_ALL
+} VarExportedMode;
+
 /* Flags for pattern matching in the :S and :C modifiers */
 typedef enum VarPatternFlags {
 	VARP_NONE		= 0,
@@ -297,6 +242,71 @@ typedef enum VarPatternFlags {
 	VARP_ANCHOR_END		= 1 << 3
 } VarPatternFlags;
 
+/* SepBuf is a string being built from words, interleaved with separators. */
+typedef struct SepBuf {
+	Buffer buf;
+	Boolean needSep;
+	/* Usually ' ', but see the ':ts' modifier. */
+	char sep;
+} SepBuf;
+
+
+ENUM_FLAGS_RTTI_3(VarEvalFlags,
+		  VARE_UNDEFERR, VARE_WANTRES, VARE_KEEP_DOLLAR);
+
+/*
+ * This lets us tell if we have replaced the original environ
+ * (which we cannot free).
+ */
+char **savedEnv = NULL;
+
+/* Special return value for Var_Parse, indicating a parse error.  It may be
+ * caused by an undefined variable, a syntax error in a modifier or
+ * something entirely 

CVS commit: src/sys/arch/arm/acpi

2020-12-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Dec  6 14:01:40 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpi_platform.c

Log Message:
acpi: Cleanup SPCR setup and style fixes.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/acpi/acpi_platform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_platform.c
diff -u src/sys/arch/arm/acpi/acpi_platform.c:1.21 src/sys/arch/arm/acpi/acpi_platform.c:1.22
--- src/sys/arch/arm/acpi/acpi_platform.c:1.21	Sat Oct 10 15:25:31 2020
+++ src/sys/arch/arm/acpi/acpi_platform.c	Sun Dec  6 14:01:40 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_platform.c,v 1.21 2020/10/10 15:25:31 jmcneill Exp $ */
+/* $NetBSD: acpi_platform.c,v 1.22 2020/12/06 14:01:40 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.21 2020/10/10 15:25:31 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.22 2020/12/06 14:01:40 jmcneill Exp $");
 
 #include 
 #include 
@@ -81,14 +81,24 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_platfor
 
 #include 
 
-#define	SPCR_BAUD_UNKNOWN			0
+#define	SPCR_BAUD_DEFAULT			0
 #define	SPCR_BAUD_96003
 #define	SPCR_BAUD_192004
 #define	SPCR_BAUD_576006
 #define	SPCR_BAUD_115200			7
 
+static const struct acpi_spcr_baud_rate {
+	uint8_t		id;
+	uint32_t	baud_rate;
+} acpi_spcr_baud_rates[] = {
+	{ SPCR_BAUD_DEFAULT,	0 },
+	{ SPCR_BAUD_9600,	9600 },
+	{ SPCR_BAUD_19200,	19200 },
+	{ SPCR_BAUD_57600,	57600 },
+	{ SPCR_BAUD_115200,	115200 },
+};
+
 extern struct bus_space arm_generic_bs_tag;
-extern struct bus_space arm_generic_a4x_bs_tag;
 
 #if NPLCOM > 0
 static struct plcom_instance plcom_console;
@@ -125,75 +135,101 @@ acpi_platform_bootstrap(void)
 }
 
 static void
-acpi_platform_startup(void)
+acpi_platform_attach_uart(ACPI_TABLE_SPCR *spcr)
 {
-	ACPI_TABLE_SPCR *spcr;
-	ACPI_TABLE_FADT *fadt;
-#ifdef MULTIPROCESSOR
-	ACPI_TABLE_MADT *madt;
+#if NCOM > 0
+	struct com_regs regs;
+	bus_space_handle_t dummy_bsh;
+	u_int reg_shift;
 #endif
-	int baud_rate;
+	int baud_rate, n;
 
 	/*
-	 * Setup serial console device
+	 * Only MMIO access is supported today.
 	 */
-	if (ACPI_SUCCESS(acpi_table_find(ACPI_SIG_SPCR, (void ** {
+	if (spcr->SerialPort.SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) {
+		return;
+	}
+	if (le64toh(spcr->SerialPort.Address) == 0) {
+		return;
+	}
 
-		switch (spcr->BaudRate) {
-		case SPCR_BAUD_9600:
-			baud_rate = 9600;
-			break;
-		case SPCR_BAUD_19200:
-			baud_rate = 19200;
-			break;
-		case SPCR_BAUD_57600:
-			baud_rate = 57600;
-			break;
-		case SPCR_BAUD_115200:
-		case SPCR_BAUD_UNKNOWN:
-		default:
-			baud_rate = 115200;
+	/*
+	 * Lookup SPCR baud rate.
+	 */
+	baud_rate = 0;
+	for (n = 0; n < __arraycount(acpi_spcr_baud_rates); n++) {
+		if (acpi_spcr_baud_rates[n].id == spcr->BaudRate) {
+			baud_rate = acpi_spcr_baud_rates[n].baud_rate;
 			break;
 		}
+	}
 
-		if (spcr->SerialPort.SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY &&
-		le64toh(spcr->SerialPort.Address) != 0) {
-			switch (spcr->InterfaceType) {
+	/*
+	 * Attach console device.
+	 */
+	switch (spcr->InterfaceType) {
 #if NPLCOM > 0
-			case ACPI_DBG2_ARM_PL011:
-			case ACPI_DBG2_ARM_SBSA_32BIT:
-			case ACPI_DBG2_ARM_SBSA_GENERIC:
-plcom_console.pi_type = PLCOM_TYPE_PL011;
-plcom_console.pi_iot = _generic_bs_tag;
-plcom_console.pi_iobase = le64toh(spcr->SerialPort.Address);
-plcom_console.pi_size = PL011COM_UART_SIZE;
-plcom_console.pi_flags = PLC_FLAG_32BIT_ACCESS;
+	case ACPI_DBG2_ARM_PL011:
+	case ACPI_DBG2_ARM_SBSA_32BIT:
+	case ACPI_DBG2_ARM_SBSA_GENERIC:
+		plcom_console.pi_type = PLCOM_TYPE_PL011;
+		plcom_console.pi_iot = _generic_bs_tag;
+		plcom_console.pi_iobase = le64toh(spcr->SerialPort.Address);
+		plcom_console.pi_size = PL011COM_UART_SIZE;
+		plcom_console.pi_flags = PLC_FLAG_32BIT_ACCESS;
 
-plcomcnattach(_console, baud_rate, 0, TTYDEF_CFLAG, -1);
-break;
+		plcomcnattach(_console, baud_rate, 0, TTYDEF_CFLAG, -1);
+		break;
 #endif
+
 #if NCOM > 0
-			case ACPI_DBG2_16550_COMPATIBLE:
-			case ACPI_DBG2_16550_SUBSET:
-if (ACPI_ACCESS_BIT_WIDTH(spcr->SerialPort.AccessWidth) == 8) {
-	comcnattach(_generic_bs_tag, le64toh(spcr->SerialPort.Address), baud_rate, -1,
-	COM_TYPE_NORMAL, TTYDEF_CFLAG);
-} else {
-	comcnattach(_generic_a4x_bs_tag, le64toh(spcr->SerialPort.Address), baud_rate, -1,
-	COM_TYPE_NORMAL, TTYDEF_CFLAG);
-}
-break;
-			case ACPI_DBG2_BCM2835:
-comcnattach(_generic_a4x_bs_tag, le64toh(spcr->SerialPort.Address) + 0x40, baud_rate, -1,
-COM_TYPE_BCMAUXUART, TTYDEF_CFLAG);
-cn_set_magic("+");
-break;
-#endif
-			default:
-printf("SPCR: kernel does not support interface type %#x\n", spcr->InterfaceType);
-break;
-			}
+	

CVS commit: src/usr.bin/make

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec  6 13:51:06 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): extract FreeEnvVar from Var_Parse


To generate a diff of this commit:
cvs rdiff -u -r1.708 -r1.709 src/usr.bin/make/var.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/var.c
diff -u src/usr.bin/make/var.c:1.708 src/usr.bin/make/var.c:1.709
--- src/usr.bin/make/var.c:1.708	Sun Dec  6 10:49:02 2020
+++ src/usr.bin/make/var.c	Sun Dec  6 13:51:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.708 2020/12/06 10:49:02 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.709 2020/12/06 13:51:06 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -130,7 +130,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.708 2020/12/06 10:49:02 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.709 2020/12/06 13:51:06 rillig Exp $");
 
 ENUM_FLAGS_RTTI_3(VarEvalFlags,
 		  VARE_UNDEFERR, VARE_WANTRES, VARE_KEEP_DOLLAR);
@@ -3882,6 +3882,20 @@ ParseVarnameLong(
 	return TRUE;
 }
 
+/* Free the environment variable now since we own it. */
+static void
+FreeEnvVar(void **out_val_freeIt, Var *v, const char *value)
+{
+	char *varValue = Buf_Destroy(>val, FALSE);
+	if (value == varValue)
+		*out_val_freeIt = varValue;
+	else
+		free(varValue);
+
+	free(v->name_freeIt);
+	free(v);
+}
+
 /*
  * Given the start of a variable expression (such as $v, $(VAR),
  * ${VAR:Mpattern}), extract the variable name and value, and the modifiers,
@@ -4033,16 +4047,7 @@ Var_Parse(const char **pp, GNode *ctxt, 
 	*pp = p;
 
 	if (v->flags & VAR_FROM_ENV) {
-		/* Free the environment variable now since we own it. */
-
-		char *varValue = Buf_Destroy(>val, FALSE);
-		if (value == varValue)
-			*out_val_freeIt = varValue;
-		else
-			free(varValue);
-
-		free(v->name_freeIt);
-		free(v);
+		FreeEnvVar(out_val_freeIt, v, value);
 
 	} else if (exprFlags & VEF_UNDEF) {
 		if (!(exprFlags & VEF_DEF)) {



CVS commit: src/sys/kern

2020-12-06 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Dec  6 13:45:58 UTC 2020

Modified Files:
src/sys/kern: kern_time.c

Log Message:
Fix an uninitialized pointer deref introduced in rev 1.207.

Reported-by: syzbot+6d69101d5f2fd954c...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.207 -r1.208 src/sys/kern/kern_time.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/kern_time.c
diff -u src/sys/kern/kern_time.c:1.207 src/sys/kern/kern_time.c:1.208
--- src/sys/kern/kern_time.c:1.207	Sat Dec  5 18:17:01 2020
+++ src/sys/kern/kern_time.c	Sun Dec  6 13:45:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_time.c,v 1.207 2020/12/05 18:17:01 thorpej Exp $	*/
+/*	$NetBSD: kern_time.c,v 1.208 2020/12/06 13:45:58 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2004, 2005, 2007, 2008, 2009, 2020
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.207 2020/12/05 18:17:01 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.208 2020/12/06 13:45:58 thorpej Exp $");
 
 #include 
 #include 
@@ -1243,10 +1243,10 @@ timer_create1(timer_t *tid, clockid_t id
 
 	switch (id) {
 	case CLOCK_VIRTUAL:
-		itl = >pt_proc->p_timers->pts_virtual;
+		itl = >pts_virtual;
 		break;
 	case CLOCK_PROF:
-		itl = >pt_proc->p_timers->pts_prof;
+		itl = >pts_prof;
 		break;
 	default:
 		itl = NULL;
@@ -1642,11 +1642,11 @@ dosetitimer(struct proc *p, int which, s
 			pt->pt_ev.sigev_signo = SIGALRM;
 			break;
 		case ITIMER_VIRTUAL:
-			itl = >pt_proc->p_timers->pts_virtual;
+			itl = >pts_virtual;
 			pt->pt_ev.sigev_signo = SIGVTALRM;
 			break;
 		case ITIMER_PROF:
-			itl = >pt_proc->p_timers->pts_prof;
+			itl = >pts_prof;
 			pt->pt_ev.sigev_signo = SIGPROF;
 			break;
 		}



CVS commit: src/usr.bin/make

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec  6 13:29:34 UTC 2020

Modified Files:
src/usr.bin/make: Makefile

Log Message:
make(1): move .include lines as far down as possible


To generate a diff of this commit:
cvs rdiff -u -r1.108 -r1.109 src/usr.bin/make/Makefile

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/Makefile
diff -u src/usr.bin/make/Makefile:1.108 src/usr.bin/make/Makefile:1.109
--- src/usr.bin/make/Makefile:1.108	Sun Dec  6 12:54:32 2020
+++ src/usr.bin/make/Makefile	Sun Dec  6 13:29:34 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.108 2020/12/06 12:54:32 rillig Exp $
+#	$NetBSD: Makefile,v 1.109 2020/12/06 13:29:34 rillig Exp $
 #	@(#)Makefile	5.2 (Berkeley) 12/28/90
 
 PROG=	make
@@ -134,26 +134,23 @@ COPTS.meta.c+=	${GCC_NO_FORMAT_TRUNCATIO
 COPTS.parse.c+=	-Wno-format-nonliteral
 COPTS.var.c+=	-Wno-format-nonliteral
 
-.include 
-.include 
-
 CPPFLAGS+=	-DMAKE_NATIVE
 
 .if ${USE_GCC10} == "yes"
 GCC10BASE?=	/usr/pkg/gcc10
-CC=		${GCC10BASE}/bin/gcc
+LATE_CC=	${GCC10BASE}/bin/gcc
 GCOV=		${GCC10BASE}/bin/gcov
 .endif
 
 .if ${USE_GCC9} == "yes"
 GCC9BASE?=	/usr/pkg/gcc9
-CC=		${GCC9BASE}/bin/gcc
+LATE_CC=	${GCC9BASE}/bin/gcc
 GCOV=		${GCC9BASE}/bin/gcov
 .endif
 
 .if ${USE_GCC8} == "yes"
 GCC8BASE?=	/usr/pkg/gcc8
-CC=		${GCC8BASE}/bin/gcc
+LATE_CC=	${GCC8BASE}/bin/gcc
 GCOV=		${GCC8BASE}/bin/gcov
 .endif
 
@@ -166,11 +163,6 @@ DPADD+=		${LIBUTIL}
 
 COPTS+=		-Wdeclaration-after-statement
 
-# For -DCLEANUP and similar feature toggles.
-CPPFLAGS+=	${USER_CPPFLAGS}
-# For overriding -std=gnu99 or similar options.
-CFLAGS+=	${USER_CFLAGS}
-
 # A simple unit-test driver to help catch regressions
 TEST_MAKE ?= ${.OBJDIR}/${PROG:T}
 test: .MAKE
@@ -197,3 +189,14 @@ retest:
 	${COMPILE.c:S,^-c$,-E,} ${COPTS.${.IMPSRC}} ${.IMPSRC} -o ${.TARGET}
 .c.casm:
 	${COMPILE.c:S,^-c$,-S,} ${COPTS.${.IMPSRC}} ${.IMPSRC} -o ${.TARGET}
+
+.include 
+.include 
+
+# For -DCLEANUP and similar feature toggles.
+CPPFLAGS+=	${USER_CPPFLAGS}
+# For overriding -std=gnu99 or similar options.
+CFLAGS+=	${USER_CFLAGS}
+.if defined(LATE_CC)
+CC=		${LATE_CC}
+.endif



CVS commit: src/usr.bin/make

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec  6 12:54:32 UTC 2020

Modified Files:
src/usr.bin/make: Makefile

Log Message:
make(1): move COPTS above 


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/usr.bin/make/Makefile

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/Makefile
diff -u src/usr.bin/make/Makefile:1.107 src/usr.bin/make/Makefile:1.108
--- src/usr.bin/make/Makefile:1.107	Thu Dec  3 18:43:02 2020
+++ src/usr.bin/make/Makefile	Sun Dec  6 12:54:32 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.107 2020/12/03 18:43:02 rillig Exp $
+#	$NetBSD: Makefile,v 1.108 2020/12/06 12:54:32 rillig Exp $
 #	@(#)Makefile	5.2 (Berkeley) 12/28/90
 
 PROG=	make
@@ -126,13 +126,18 @@ SUBDIR+=	unit-tests
 ${SRCS:M*.c:.c=.o}: ${HDRS}
 CLEANFILES+=	*.o
 
+COPTS.arch.c+=	${GCC_NO_FORMAT_TRUNCATION}
+COPTS.dir.c+=	${GCC_NO_FORMAT_TRUNCATION}
+COPTS.job.c+=	-Wno-format-nonliteral
+COPTS.main.c+=	${GCC_NO_FORMAT_TRUNCATION} ${GCC_NO_STRINGOP_TRUNCATION}
+COPTS.meta.c+=	${GCC_NO_FORMAT_TRUNCATION}
+COPTS.parse.c+=	-Wno-format-nonliteral
+COPTS.var.c+=	-Wno-format-nonliteral
+
 .include 
 .include 
 
 CPPFLAGS+=	-DMAKE_NATIVE
-COPTS.job.c+=	-Wno-format-nonliteral
-COPTS.parse.c+=	-Wno-format-nonliteral
-COPTS.var.c+=	-Wno-format-nonliteral
 
 .if ${USE_GCC10} == "yes"
 GCC10BASE?=	/usr/pkg/gcc10
@@ -159,11 +164,6 @@ LDADD+=		-lutil
 DPADD+=		${LIBUTIL}
 .endif
 
-COPTS.arch.c+=	${GCC_NO_FORMAT_TRUNCATION}
-COPTS.dir.c+=	${GCC_NO_FORMAT_TRUNCATION}
-COPTS.main.c+=	${GCC_NO_FORMAT_TRUNCATION} ${GCC_NO_STRINGOP_TRUNCATION}
-COPTS.meta.c+=	${GCC_NO_FORMAT_TRUNCATION}
-
 COPTS+=		-Wdeclaration-after-statement
 
 # For -DCLEANUP and similar feature toggles.



CVS commit: src/sys/dev/acpi

2020-12-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Dec  6 12:47:12 UTC 2020

Modified Files:
src/sys/dev/acpi: acpi_mcfg.c

Log Message:
Fix typo in comment


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/acpi/acpi_mcfg.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/acpi/acpi_mcfg.c
diff -u src/sys/dev/acpi/acpi_mcfg.c:1.20 src/sys/dev/acpi/acpi_mcfg.c:1.21
--- src/sys/dev/acpi/acpi_mcfg.c:1.20	Tue Jul  7 03:38:48 2020
+++ src/sys/dev/acpi/acpi_mcfg.c	Sun Dec  6 12:47:12 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: acpi_mcfg.c,v 1.20 2020/07/07 03:38:48 thorpej Exp $	*/
+/*	$NetBSD: acpi_mcfg.c,v 1.21 2020/12/06 12:47:12 jmcneill Exp $	*/
 
 /*-
  * Copyright (C) 2015 NONAKA Kimihiro 
@@ -28,7 +28,7 @@
 #include "opt_pci.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_mcfg.c,v 1.20 2020/07/07 03:38:48 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_mcfg.c,v 1.21 2020/12/06 12:47:12 jmcneill Exp $");
 
 #include 
 #include 
@@ -576,7 +576,7 @@ acpimcfg_map_bus(device_t self, pci_chip
 	mb = >ms_bus[boff];
 	baddr = seg->ms_address + (bus * ACPIMCFG_SIZE_PER_BUS);
 
-	/* Map extended configration space of all dev/func. */
+	/* Map extended configuration space of all dev/func. */
 	error = bus_space_map(seg->ms_bst, baddr, ACPIMCFG_SIZE_PER_BUS, 0,
 	);
 	if (error != 0)
@@ -797,7 +797,7 @@ acpimcfg_configure_bus(device_t self, pc
 		mb = >ms_bus[boff];
 		baddr = seg->ms_address + (b * ACPIMCFG_SIZE_PER_BUS);
 
-		/* Map extended configration space of all dev/func. */
+		/* Map extended configuration space of all dev/func. */
 		error = bus_space_map(seg->ms_bst, baddr, ACPIMCFG_SIZE_PER_BUS, 0,
 		[b]);
 		if (error != 0)



CVS commit: src/sys/arch/arm/acpi

2020-12-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Dec  6 12:40:58 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpipchb.c

Log Message:
Style fixes. NFC.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/acpi/acpipchb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpipchb.c
diff -u src/sys/arch/arm/acpi/acpipchb.c:1.21 src/sys/arch/arm/acpi/acpipchb.c:1.22
--- src/sys/arch/arm/acpi/acpipchb.c:1.21	Sat Oct 24 07:08:22 2020
+++ src/sys/arch/arm/acpi/acpipchb.c	Sun Dec  6 12:40:58 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: acpipchb.c,v 1.21 2020/10/24 07:08:22 skrll Exp $ */
+/* $NetBSD: acpipchb.c,v 1.22 2020/12/06 12:40:58 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.21 2020/10/24 07:08:22 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.22 2020/12/06 12:40:58 jmcneill Exp $");
 
 #include 
 #include 
@@ -92,8 +92,10 @@ struct acpipchb_softc {
 static int	acpipchb_match(device_t, cfdata_t, void *);
 static void	acpipchb_attach(device_t, device_t, void *);
 
-static void	acpipchb_setup_ranges(struct acpipchb_softc *, struct pcibus_attach_args *);
-static void	acpipchb_setup_quirks(struct acpipchb_softc *, struct pcibus_attach_args *);
+static void	acpipchb_setup_ranges(struct acpipchb_softc *,
+  struct pcibus_attach_args *);
+static void	acpipchb_setup_quirks(struct acpipchb_softc *,
+  struct pcibus_attach_args *);
 
 CFATTACH_DECL_NEW(acpipchb, sizeof(struct acpipchb_softc),
 	acpipchb_match, acpipchb_attach, NULL, NULL);
@@ -121,6 +123,7 @@ acpipchb_attach(device_t parent, device_
 	struct acpi_attach_args *aa = aux;
 	struct pcibus_attach_args pba;
 	ACPI_INTEGER seg;
+	ACPI_STATUS rv;
 	uint16_t bus_start;
 
 	sc->sc_dev = self;
@@ -134,23 +137,29 @@ acpipchb_attach(device_t parent, device_
 	if (ACPI_SUCCESS(acpi_pcidev_pciroot_bus(sc->sc_handle, _start))) {
 		sc->sc_bus = bus_start;
 	} else {
-		if (ACPI_FAILURE(acpi_eval_integer(sc->sc_handle, "_BBN", >sc_bus)))
+		rv = acpi_eval_integer(sc->sc_handle, "_BBN", >sc_bus);
+		if (ACPI_FAILURE(rv)) {
 			sc->sc_bus = 0;
+		}
 	}
 
-	if (ACPI_FAILURE(acpi_eval_integer(sc->sc_handle, "_SEG", )))
+	if (ACPI_FAILURE(acpi_eval_integer(sc->sc_handle, "_SEG", ))) {
 		seg = 0;
+	}
 
 	aprint_naive("\n");
 	aprint_normal(": PCI Express Host Bridge\n");
 
 	if (acpi_pci_ignore_boot_config(sc->sc_handle)) {
-		if (acpimcfg_configure_bus(self, aa->aa_pc, sc->sc_handle, sc->sc_bus, PCIHOST_CACHELINE_SIZE) != 0)
+		if (acpimcfg_configure_bus(self, aa->aa_pc, sc->sc_handle,
+		sc->sc_bus, PCIHOST_CACHELINE_SIZE) != 0) {
 			aprint_error_dev(self, "failed to configure bus\n");
+		}
 	}
 
 	memset(, 0, sizeof(pba));
-	pba.pba_flags = aa->aa_pciflags & ~(PCI_FLAGS_MEM_OKAY | PCI_FLAGS_IO_OKAY);
+	pba.pba_flags = aa->aa_pciflags &
+			~(PCI_FLAGS_MEM_OKAY | PCI_FLAGS_IO_OKAY);
 	pba.pba_memt = 0;
 	pba.pba_iot = 0;
 	pba.pba_dmat = aa->aa_dmat;
@@ -188,8 +197,10 @@ acpipchb_bus_space_map(void *t, bus_addr
 
 	for (i = 0; i < abs->nrange; i++) {
 		struct acpipchb_bus_range * const range = >range[i];
-		if (bpa >= range->min && bpa + size - 1 <= range->max)
-			return abs->map(t, bpa + range->offset, size, flag, bshp);
+		if (bpa >= range->min && bpa + size - 1 <= range->max) {
+			return abs->map(t, bpa + range->offset, size,
+	flag, bshp);
+		}
 	}
 
 	return ERANGE;
@@ -207,8 +218,9 @@ acpipchb_setup_ranges_cb(ACPI_RESOURCE *
 	u_int pci_flags;
 
 	if (res->Type != ACPI_RESOURCE_TYPE_ADDRESS32 &&
-	res->Type != ACPI_RESOURCE_TYPE_ADDRESS64)
+	res->Type != ACPI_RESOURCE_TYPE_ADDRESS64) {
 		return AE_OK;
+	}
 
 	switch (res->Data.Address.ResourceType) {
 	case ACPI_IO_RANGE:
@@ -227,7 +239,7 @@ acpipchb_setup_ranges_cb(ACPI_RESOURCE *
 
 	if (abs->nrange == ACPIPCHB_MAX_RANGES) {
 		aprint_error_dev(sc->sc_dev,
-		"maximum number of ranges reached, increase ACPIPCHB_MAX_RANGES\n");
+		"maximum number of ranges reached (ACPIPCHB_MAX_RANGES)\n");
 		return AE_LIMIT;
 	}
 
@@ -248,7 +260,8 @@ acpipchb_setup_ranges_cb(ACPI_RESOURCE *
 	}
 	abs->nrange++;
 
-	aprint_debug_dev(sc->sc_dev, "PCI %s [%#lx-%#lx] -> %#lx\n", range_type, range->min, range->max, range->offset);
+	aprint_debug_dev(sc->sc_dev, "PCI %s [%#lx-%#lx] -> %#lx\n",
+	range_type, range->min, range->max, range->offset);
 
 	if ((pba->pba_flags & pci_flags) == 0) {
 		abs->bs = *sc->sc_memt;
@@ -256,10 +269,11 @@ acpipchb_setup_ranges_cb(ACPI_RESOURCE *
 		abs->map = abs->bs.bs_map;
 		abs->flags = pci_flags;
 		abs->bs.bs_map = acpipchb_bus_space_map;
-		if ((pci_flags & PCI_FLAGS_IO_OKAY) != 0)
+		if ((pci_flags & PCI_FLAGS_IO_OKAY) != 0) {
 			pba->pba_iot = >bs;
-		else if ((pci_flags & PCI_FLAGS_MEM_OKAY) != 0)
+		} else if ((pci_flags & PCI_FLAGS_MEM_OKAY) != 0) {
 			

CVS commit: src/sys/dev/acpi

2020-12-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Dec  6 12:23:13 UTC 2020

Modified Files:
src/sys/dev/acpi: amdccp_acpi.c atppc_acpi.c fdc_acpi.c lpt_acpi.c
mpu_acpi.c pckbc_acpi.c spic_acpi.c wb_acpi.c

Log Message:
acpi: Use acpi_intr_establish to install interrupt handlers

Get rid of bus-specific (isa_intr_establish) and MD (intr_establish) calls
from MI ACPI code, and use acpi_intr_establish everywhere.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/acpi/amdccp_acpi.c
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/acpi/atppc_acpi.c
cvs rdiff -u -r1.43 -r1.44 src/sys/dev/acpi/fdc_acpi.c
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/acpi/lpt_acpi.c
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/acpi/mpu_acpi.c
cvs rdiff -u -r1.37 -r1.38 src/sys/dev/acpi/pckbc_acpi.c
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/acpi/spic_acpi.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/acpi/wb_acpi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/acpi/amdccp_acpi.c
diff -u src/sys/dev/acpi/amdccp_acpi.c:1.2 src/sys/dev/acpi/amdccp_acpi.c:1.3
--- src/sys/dev/acpi/amdccp_acpi.c:1.2	Sun Oct 21 11:09:20 2018
+++ src/sys/dev/acpi/amdccp_acpi.c	Sun Dec  6 12:23:13 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: amdccp_acpi.c,v 1.2 2018/10/21 11:09:20 jmcneill Exp $ */
+/* $NetBSD: amdccp_acpi.c,v 1.3 2020/12/06 12:23:13 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2018 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdccp_acpi.c,v 1.2 2018/10/21 11:09:20 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdccp_acpi.c,v 1.3 2020/12/06 12:23:13 jmcneill Exp $");
 
 #include 
 #include 
@@ -36,6 +36,7 @@ __KERNEL_RCSID(0, "$NetBSD: amdccp_acpi.
 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -68,9 +69,6 @@ amdccp_acpi_attach(device_t parent, devi
 	struct acpi_attach_args *aa = aux;
 	struct acpi_resources res;
 	struct acpi_mem *mem;
-#if notyet
-	struct acpi_irq *irq;
-#endif
 	ACPI_STATUS rv;
 #if notyet
 	void *ih;
@@ -89,23 +87,16 @@ amdccp_acpi_attach(device_t parent, devi
 		goto done;
 	}
 
-#if notyet
-	irq = acpi_res_irq(, 0);
-	if (irq == NULL) {
-		aprint_error_dev(self, "couldn't find irq resource\n");
-		goto done;
-	}
-
-#endif
 	sc->sc_bst = aa->aa_memt;
-	if (bus_space_map(aa->aa_memt, mem->ar_base, mem->ar_length, 0, >sc_bsh) != 0) {
+	if (bus_space_map(aa->aa_memt, mem->ar_base, mem->ar_length, 0,
+	>sc_bsh) != 0) {
 		aprint_error_dev(self, "couldn't map registers\n");
 		goto done;
 	}
 
 #if notyet
-	const int type = (irq->ar_type == ACPI_EDGE_SENSITIVE) ? IST_EDGE : IST_LEVEL;
-	ih = intr_establish(irq->ar_irq, IPL_VM, type | IST_MPSAFE, amdccp_intr, sc);
+	ih = acpi_intr_establish(self, (uint64_t)aa->aa_node->ad_handle,
+	IPL_VM, true, amdccp_intr, sc, device_xname(self));
 	if (ih == NULL) {
 		aprint_error_dev(self, "couldn't install interrupt handler\n");
 		return;

Index: src/sys/dev/acpi/atppc_acpi.c
diff -u src/sys/dev/acpi/atppc_acpi.c:1.17 src/sys/dev/acpi/atppc_acpi.c:1.18
--- src/sys/dev/acpi/atppc_acpi.c:1.17	Fri Mar  5 14:00:17 2010
+++ src/sys/dev/acpi/atppc_acpi.c	Sun Dec  6 12:23:13 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: atppc_acpi.c,v 1.17 2010/03/05 14:00:17 jruoho Exp $ */
+/* $NetBSD: atppc_acpi.c,v 1.18 2020/12/06 12:23:13 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: atppc_acpi.c,v 1.17 2010/03/05 14:00:17 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: atppc_acpi.c,v 1.18 2020/12/06 12:23:13 jmcneill Exp $");
 
 #include "opt_atppc.h"
 
@@ -98,10 +98,8 @@ atppc_acpi_attach(device_t parent, devic
 	struct acpi_attach_args *aa = aux;
 	struct acpi_resources res;
 	struct acpi_io *io;
-	struct acpi_irq *irq;
 	struct acpi_drq *drq;
 	ACPI_STATUS rv;
-	int nirq;
 
 	sc->sc_dev_ok = ATPPC_NOATTACH;
 
@@ -120,14 +118,6 @@ atppc_acpi_attach(device_t parent, devic
 		goto out;
 	}
 
-	/* find our IRQ */
-	irq = acpi_res_irq(, 0);
-	if (irq == NULL) {
-		aprint_error_dev(sc->sc_dev, "unable to find irq resource\n");
-		goto out;
-	}
-	nirq = irq->ar_irq;
-
 	/* find our DRQ */
 	drq = acpi_res_drq(, 0);
 	if (drq == NULL) {
@@ -150,9 +140,12 @@ atppc_acpi_attach(device_t parent, devic
 		goto out;
 	}
 
-	sc->sc_ieh = isa_intr_establish(aa->aa_ic, nirq,
-	(irq->ar_type == ACPI_EDGE_SENSITIVE) ? IST_EDGE : IST_LEVEL,
-	IPL_TTY, atppcintr, sc->sc_dev);
+	sc->sc_ieh = acpi_intr_establish(self, (uint64_t)aa->aa_node->ad_handle,
+	IPL_TTY, false, atppcintr, self device_xname(self));
+	if (sc->sc_ieh == NULL) {
+		aprint_error_dev(self, "unable to establish interrupt\n");
+		goto out;
+	}
 
 	/* setup DMA hooks */
 	if (atppc_isadma_setup(sc, asc->sc_ic, asc->sc_drq) == 0) {

Index: src/sys/dev/acpi/fdc_acpi.c
diff -u src/sys/dev/acpi/fdc_acpi.c:1.43 src/sys/dev/acpi/fdc_acpi.c:1.44
--- src/sys/dev/acpi/fdc_acpi.c:1.43	Mon Apr 13 16:33:23 

CVS commit: src/games/backgammon/common_source

2020-12-06 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Dec  6 11:41:47 UTC 2020

Modified Files:
src/games/backgammon/common_source: back.h

Log Message:
speed limit 80


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/games/backgammon/common_source/back.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/backgammon/common_source/back.h
diff -u src/games/backgammon/common_source/back.h:1.21 src/games/backgammon/common_source/back.h:1.22
--- src/games/backgammon/common_source/back.h:1.21	Wed Apr 22 23:36:26 2020
+++ src/games/backgammon/common_source/back.h	Sun Dec  6 11:41:47 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: back.h,v 1.21 2020/04/22 23:36:26 joerg Exp $	*/
+/*	$NetBSD: back.h,v 1.22 2020/12/06 11:41:47 dholland Exp $	*/
 
 /*
  * Copyright (c) 1980, 1993
@@ -46,7 +46,12 @@
 #define rnum(r)	(random()%r)
 #define D0	dice[0]
 #define D1	dice[1]
-#define mswap(m) {(m)->D0 ^= (m)->D1; (m)->D1 ^= (m)->D0; (m)->D0 ^= (m)->D1; (m)->d0 = 1-(m)->d0;}
+#define mswap(m) { \
+	(m)->D0 ^= (m)->D1;  \
+	(m)->D1 ^= (m)->D0;  \
+	(m)->D0 ^= (m)->D1;  \
+	(m)->d0 = 1-(m)->d0; \
+}
 
 struct move {
 	int	dice[2];	/* value of dice */
@@ -121,7 +126,7 @@ extern	char	cin[100];	/* input line of c
 extern	const char	*const color[];
 /* colors as strings */
 extern	const char	*const *colorptr;	/* color of current player */
-extern	const char	*const *Colorptr;	/* color of current player, capitalized */
+extern	const char	*const *Colorptr;	/* ditto, capitalized */
 extern	int	colen;		/* length of color of current player */
 
 extern int buffnum;



CVS commit: src/sys/dev/acpi

2020-12-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Dec  6 11:38:28 UTC 2020

Modified Files:
src/sys/dev/acpi: acpi_quirks.c acpivar.h

Log Message:
acpi: remove unused acpi_quirks_osi_* functions


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/acpi/acpi_quirks.c
cvs rdiff -u -r1.82 -r1.83 src/sys/dev/acpi/acpivar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/acpi/acpi_quirks.c
diff -u src/sys/dev/acpi/acpi_quirks.c:1.21 src/sys/dev/acpi/acpi_quirks.c:1.22
--- src/sys/dev/acpi/acpi_quirks.c:1.21	Mon May  4 20:06:38 2020
+++ src/sys/dev/acpi/acpi_quirks.c	Sun Dec  6 11:38:28 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_quirks.c,v 1.21 2020/05/04 20:06:38 jdolecek Exp $ */
+/* $NetBSD: acpi_quirks.c,v 1.22 2020/12/06 11:38:28 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: acpi_quirks.c,v 1.21 2020/05/04 20:06:38 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_quirks.c,v 1.22 2020/12/06 11:38:28 jmcneill Exp $");
 
 #include "opt_acpi.h"
 
@@ -211,61 +211,3 @@ acpi_find_quirks(void)
 
 	return 0;
 }
-
-/*
- * Add or delete a string to the list that should return
- * true when _OSI is being queried. The defaults are:
- *
- *	"Windows 2000"		# Windows 2000
- *	"Windows 2001"		# Windows XP
- *	"Windows 2001 SP1"	# Windows XP SP1
- *	"Windows 2001.1"	# Windows Server 2003
- *	"Windows 2001 SP2"	# Windows XP SP2
- *	"Windows 2001.1 SP1"	# Windows Server 2003 SP1
- *	"Windows 2006"		# Windows Vista
- *	"Windows 2006.1"	# Windows Server 2008
- *	"Windows 2006 SP1"	# Windows Vista SP1
- *	"Windows 2006 SP2"	# Windows Vista SP2
- *	"Windows 2009"		# Windows 7 and Server 2008
- */
-int
-acpi_quirks_osi_add(const char *str)
-{
-	ACPI_STATUS rv;
-
-	if (str == NULL || *str == '\0')
-		return EINVAL;
-
-	rv = AcpiInstallInterface(__UNCONST(str));
-
-	return (rv != AE_OK) ? EIO : 0;
-}
-
-int
-acpi_quirks_osi_del(const char *str)
-{
-	ACPI_STATUS rv;
-
-	if (str == NULL || *str == '\0')
-		return EINVAL;
-
-	rv = AcpiRemoveInterface(__UNCONST(str));
-
-	return (rv != AE_OK) ? EIO : 0;
-}
-
-#if 0
-static void
-acpi_quirks_osi_linux(void)
-{
-	(void)acpi_quirks_osi_add("Linux");
-}
-
-static void
-acpi_quirks_osi_vista(void)
-{
-	(void)acpi_quirks_osi_del("Windows 2006");
-	(void)acpi_quirks_osi_del("Windows 2006 SP1");
-	(void)acpi_quirks_osi_del("Windows 2006 SP2");
-}
-#endif

Index: src/sys/dev/acpi/acpivar.h
diff -u src/sys/dev/acpi/acpivar.h:1.82 src/sys/dev/acpi/acpivar.h:1.83
--- src/sys/dev/acpi/acpivar.h:1.82	Fri Jan 17 17:06:32 2020
+++ src/sys/dev/acpi/acpivar.h	Sun Dec  6 11:38:28 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: acpivar.h,v 1.82 2020/01/17 17:06:32 jmcneill Exp $	*/
+/*	$NetBSD: acpivar.h,v 1.83 2020/12/06 11:38:28 jmcneill Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -382,8 +382,6 @@ struct acpi_quirk {
 #define ACPI_QUIRK_OLDBIOS	0x0010	/* BIOS date blacklisted */
 
 int	acpi_find_quirks(void);
-int	acpi_quirks_osi_add(const char *);
-int	acpi_quirks_osi_del(const char *);
 
 #ifdef ACPI_DEBUG
 void	acpi_debug_init(void);



CVS commit: src/games/battlestar

2020-12-06 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Dec  6 11:35:27 UTC 2020

Modified Files:
src/games/battlestar: globals.c

Log Message:
speed limit 80


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/games/battlestar/globals.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/battlestar/globals.c
diff -u src/games/battlestar/globals.c:1.19 src/games/battlestar/globals.c:1.20
--- src/games/battlestar/globals.c:1.19	Thu Aug  7 09:37:02 2003
+++ src/games/battlestar/globals.c	Sun Dec  6 11:35:27 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: globals.c,v 1.19 2003/08/07 09:37:02 agc Exp $	*/
+/*	$NetBSD: globals.c,v 1.20 2020/12/06 11:35:27 dholland Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)globals.c	8.2 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: globals.c,v 1.19 2003/08/07 09:37:02 agc Exp $");
+__RCSID("$NetBSD: globals.c,v 1.20 2020/12/06 11:35:27 dholland Exp $");
 #endif
 #endif/* not lint */
 
@@ -67,7 +67,8 @@ const char   *const objdes[NUMOFOBJECTS]
 	"A dead woodsman has fallen here. He was savagely murdered.",
 	"A heavy wooden mallet lies nearby.",
 	"There is a laser pistol here.",
-	"A flower-like young goddess is bathing in the hot mineral pools. She is \nwatching you, but continues to steep and sing softly.",
+	"A flower-like young goddess is bathing in the hot mineral pools. She "
+		"is \nwatching you, but continues to steep and sing softly.",
 	"The goddess is reclining on a bed of ferns and studying you intently.",
 	"There is a grenade here.",
 	"There is a length of heavy chain here.",
@@ -78,7 +79,8 @@ const char   *const objdes[NUMOFOBJECTS]
 	"A long, sharp halberd is propped up here.",
 	"There is a compass here.",
 	"Wreckage and smoldering debris from a crash litter the ground here.",
-	"A woodland Elf armed with a shield and deadly halberd lunges toward you!",
+	"A woodland Elf armed with a shield and deadly halberd lunges toward "
+		"you!",
 	"I think I hear footsteps behind us.",
 	"There are a few coins here.",
 	"There are some matches here.",
@@ -91,15 +93,28 @@ const char   *const objdes[NUMOFOBJECTS]
 	"There is a sparkling diamond ring here.",
 	"There is a colorful pink potion in a small crystal vial here.",
 	"A gold bracelet is on the ground here.",
-	"A swarthy woman with stern features pulls you aside from the crowd,\n'I must talk to you -- but not here.  Meet me at midnight in the gardens.'",
-	"The swarthy woman has been awaiting you anxiously. 'I must warn you that the\nIsland has anticipated your Quest.  You will not be welcomed. The Darkness is\nstrong where you must search.  Seek not the shadows save only at night, for\nthen are they the weakest.  In the mountains far from here a canyon winds\nwith ferns and streams and forgotten vines.  There you must go. Take this\nrope.'",
-	"Out from the shadows a figure leaps!  His black cape swirls around, and he\nholds a laser sword at your chest.  'So, you have come to fulfill the Quest.\nHa! Your weapons are no match for me!'",
-	"An old-timer with one eye missing and no money for a drink sits at the bar.",
+	"A swarthy woman with stern features pulls you aside from the crowd,\n"
+		"'I must talk to you -- but not here.  "
+		"Meet me at midnight in the gardens.'",
+	"The swarthy woman has been awaiting you anxiously. 'I must warn you "
+		"that the\nIsland has anticipated your Quest.  You will not be "
+		"welcomed. The Darkness is\nstrong where you must search.  Seek"
+		" not the shadows save only at night, for\nthen are they the "
+		"weakest.  In the mountains far from here a canyon winds\nwith "
+		"ferns and streams and forgotten vines.  There you must go. "
+		"Take this\nrope.'",
+	"Out from the shadows a figure leaps!  His black cape swirls around,"
+		" and he\nholds a laser sword at your chest.  'So, you have"
+		" come to fulfill the Quest.\nHa! Your weapons are no match for"
+		" me!'",
+	"An old-timer with one eye missing and no money for a drink sits at the"
+		" bar.",
 	"You are flying through an asteroid field!",
 	"A planet is nearby.",
 	"The ground is charred here.",
 	"There is a thermonuclear warhead here.",
-	"The fragile, beautiful young goddess lies here.  You murdered her horribly.",
+	"The fragile, beautiful young goddess lies here.  You murdered her "
+		"horribly.",
 	"The old-timer is lying here.  He is dead.",
 	"The native girl's body is lying here.",
 	"A native girl is sitting here.",



CVS commit: src/usr.bin/make

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec  6 11:00:56 UTC 2020

Modified Files:
src/usr.bin/make: buf.h

Log Message:
make(1): indent buf.h with tabs instead of spaces


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/usr.bin/make/buf.h

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/buf.h
diff -u src/usr.bin/make/buf.h:1.36 src/usr.bin/make/buf.h:1.37
--- src/usr.bin/make/buf.h:1.36	Tue Nov 10 00:32:12 2020
+++ src/usr.bin/make/buf.h	Sun Dec  6 11:00:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: buf.h,v 1.36 2020/11/10 00:32:12 rillig Exp $	*/
+/*	$NetBSD: buf.h,v 1.37 2020/12/06 11:00:56 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -81,9 +81,9 @@
 
 /* An automatically growing null-terminated buffer of characters. */
 typedef struct Buffer {
-size_t cap;		/* Allocated size of the buffer, including the null */
-size_t len;		/* Number of bytes in buffer, excluding the null */
-char *data;		/* The buffer itself (always null-terminated) */
+	size_t cap;	/* Allocated size of the buffer, including the null */
+	size_t len;	/* Number of bytes in buffer, excluding the null */
+	char *data;	/* The buffer itself (always null-terminated) */
 } Buffer;
 
 /* If we aren't on NetBSD, __predict_false() might not be defined. */
@@ -97,25 +97,25 @@ void Buf_Expand_1(Buffer *);
 MAKE_INLINE void
 Buf_AddByte(Buffer *buf, char byte)
 {
-size_t old_len = buf->len++;
-char *end;
-if (__predict_false(old_len + 1 >= buf->cap))
-	Buf_Expand_1(buf);
-end = buf->data + old_len;
-end[0] = byte;
-end[1] = '\0';
+	size_t old_len = buf->len++;
+	char *end;
+	if (__predict_false(old_len + 1 >= buf->cap))
+		Buf_Expand_1(buf);
+	end = buf->data + old_len;
+	end[0] = byte;
+	end[1] = '\0';
 }
 
 MAKE_INLINE size_t
 Buf_Len(const Buffer *buf)
 {
-return buf->len;
+	return buf->len;
 }
 
 MAKE_INLINE Boolean
 Buf_EndsWith(const Buffer *buf, char ch)
 {
-return buf->len > 0 && buf->data[buf->len - 1] == ch;
+	return buf->len > 0 && buf->data[buf->len - 1] == ch;
 }
 
 void Buf_AddBytes(Buffer *, const char *, size_t);



CVS commit: src/usr.bin/make

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec  6 10:49:02 UTC 2020

Modified Files:
src/usr.bin/make: dir.c suff.c targ.c var.c

Log Message:
make(1): inline macros for debug logging

No changes to the resulting binary, except for the line numbers in
assertions.


To generate a diff of this commit:
cvs rdiff -u -r1.249 -r1.250 src/usr.bin/make/dir.c
cvs rdiff -u -r1.326 -r1.327 src/usr.bin/make/suff.c
cvs rdiff -u -r1.152 -r1.153 src/usr.bin/make/targ.c
cvs rdiff -u -r1.707 -r1.708 src/usr.bin/make/var.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/dir.c
diff -u src/usr.bin/make/dir.c:1.249 src/usr.bin/make/dir.c:1.250
--- src/usr.bin/make/dir.c:1.249	Fri Dec  4 14:39:56 2020
+++ src/usr.bin/make/dir.c	Sun Dec  6 10:49:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.249 2020/12/04 14:39:56 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.250 2020/12/06 10:49:02 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -136,11 +136,7 @@
 #include "job.h"
 
 /*	"@(#)dir.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: dir.c,v 1.249 2020/12/04 14:39:56 rillig Exp $");
-
-#define DIR_DEBUG0(text) DEBUG0(DIR, text)
-#define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1)
-#define DIR_DEBUG2(fmt, arg1, arg2) DEBUG2(DIR, fmt, arg1, arg2)
+MAKE_RCSID("$NetBSD: dir.c,v 1.250 2020/12/06 10:49:02 rillig Exp $");
 
 /* A search path is a list of CachedDir structures. A CachedDir has in it the
  * name of the directory and the names of all the files in the directory.
@@ -369,12 +365,12 @@ static void
 OpenDirs_Done(OpenDirs *odirs)
 {
 	CachedDirListNode *ln = odirs->list.first;
-	DIR_DEBUG1("OpenDirs_Done: %u entries to remove\n",
+	DEBUG1(DIR, "OpenDirs_Done: %u entries to remove\n",
 	odirs->table.numEntries);
 	while (ln != NULL) {
 		CachedDirListNode *next = ln->next;
 		CachedDir *dir = ln->datum;
-		DIR_DEBUG2("OpenDirs_Done: refCount %d for \"%s\"\n",
+		DEBUG2(DIR, "OpenDirs_Done: refCount %d for \"%s\"\n",
 		dir->refCount, dir->name);
 		CachedDir_Unref(dir);	/* removes the dir from odirs->list */
 		ln = next;
@@ -429,8 +425,8 @@ cached_stats(const char *pathname, struc
 	cst = HashTable_FindValue(tbl, pathname);
 	if (cst != NULL && !(flags & CST_UPDATE)) {
 		*out_cst = *cst;
-		DIR_DEBUG2("Using cached time %s for %s\n",
-			   Targ_FmtTime(cst->cst_mtime), pathname);
+		DEBUG2(DIR, "Using cached time %s for %s\n",
+		Targ_FmtTime(cst->cst_mtime), pathname);
 		return 0;
 	}
 
@@ -450,8 +446,8 @@ cached_stats(const char *pathname, struc
 	cst->cst_mode = sys_st.st_mode;
 
 	*out_cst = *cst;
-	DIR_DEBUG2("   Caching %s for %s\n",
-		   Targ_FmtTime(sys_st.st_mtime), pathname);
+	DEBUG2(DIR, "   Caching %s for %s\n",
+	Targ_FmtTime(sys_st.st_mtime), pathname);
 
 	return 0;
 }
@@ -838,7 +834,7 @@ Dir_Expand(const char *word, SearchPath 
 	assert(path != NULL);
 	assert(expansions != NULL);
 
-	DIR_DEBUG1("Expanding \"%s\"... ", word);
+	DEBUG1(DIR, "Expanding \"%s\"... ", word);
 
 	cp = strchr(word, '{');
 	if (cp != NULL) {
@@ -942,13 +938,13 @@ DirLookup(CachedDir *dir, const char *ba
 {
 	char *file;		/* the current filename to check */
 
-	DIR_DEBUG1("   %s ...\n", dir->name);
+	DEBUG1(DIR, "   %s ...\n", dir->name);
 
 	if (!HashSet_Contains(>files, base))
 		return NULL;
 
 	file = str_concat3(dir->name, "/", base);
-	DIR_DEBUG1("   returning %s\n", file);
+	DEBUG1(DIR, "   returning %s\n", file);
 	dir->hits++;
 	hits++;
 	return file;
@@ -964,7 +960,7 @@ DirLookupSubdir(CachedDir *dir, const ch
 	char *file = dir == dot ? bmake_strdup(name)
 : str_concat3(dir->name, "/", name);
 
-	DIR_DEBUG1("checking %s ...\n", file);
+	DEBUG1(DIR, "checking %s ...\n", file);
 
 	if (cached_stat(file, ) == 0) {
 		nearmisses++;
@@ -984,7 +980,7 @@ DirLookupAbs(CachedDir *dir, const char 
 	const char *dnp;	/* pointer into dir->name */
 	const char *np;		/* pointer into name */
 
-	DIR_DEBUG1("   %s ...\n", dir->name);
+	DEBUG1(DIR, "   %s ...\n", dir->name);
 
 	/*
 	 * If the file has a leading path component and that component
@@ -999,13 +995,13 @@ DirLookupAbs(CachedDir *dir, const char 
 		return NULL;
 
 	if (!HashSet_Contains(>files, cp)) {
-		DIR_DEBUG0("   must be here but isn't -- returning\n");
+		DEBUG0(DIR, "   must be here but isn't -- returning\n");
 		return bmake_strdup("");	/* to terminate the search */
 	}
 
 	dir->hits++;
 	hits++;
-	DIR_DEBUG1("   returning %s\n", name);
+	DEBUG1(DIR, "   returning %s\n", name);
 	return bmake_strdup(name);
 }
 
@@ -1016,14 +1012,14 @@ DirFindDot(const char *name, const char 
 {
 
 	if (HashSet_Contains(>files, base)) {
-		DIR_DEBUG0("   in '.'\n");
+		DEBUG0(DIR, "   in '.'\n");
 		hits++;
 		dot->hits++;
 		return bmake_strdup(name);
 	}
 
 	if (cur != NULL && HashSet_Contains(>files, base)) {
-		DIR_DEBUG1("   in ${.CURDIR} = %s\n", cur->name);
+		DEBUG1(DIR, "   in 

CVS commit: src/usr.bin/make

2020-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec  6 10:33:42 UTC 2020

Modified Files:
src/usr.bin/make: make.h

Log Message:
make(1): clean up macros for debug logging

Using a do-while loop prevents compiler warnings about possible dangling
else.  It also removes the unnecessary negation.


To generate a diff of this commit:
cvs rdiff -u -r1.231 -r1.232 src/usr.bin/make/make.h

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/make.h
diff -u src/usr.bin/make/make.h:1.231 src/usr.bin/make/make.h:1.232
--- src/usr.bin/make/make.h:1.231	Sat Dec  5 18:38:02 2020
+++ src/usr.bin/make/make.h	Sun Dec  6 10:33:42 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.h,v 1.231 2020/12/05 18:38:02 rillig Exp $	*/
+/*	$NetBSD: make.h,v 1.232 2020/12/06 10:33:42 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -581,29 +581,24 @@ typedef enum DebugFlags {
 
 void debug_printf(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2);
 
-#define DEBUG0(module, text) \
-if (!DEBUG(module)) (void)0; \
-else debug_printf("%s", text)
+#define DEBUG_IMPL(module, args) \
+	do { \
+		if (DEBUG(module)) \
+			debug_printf args; \
+	} while (0)
 
+#define DEBUG0(module, text) \
+	DEBUG_IMPL(module, ("%s", text))
 #define DEBUG1(module, fmt, arg1) \
-if (!DEBUG(module)) (void)0; \
-else debug_printf(fmt, arg1)
-
+	DEBUG_IMPL(module, (fmt, arg1))
 #define DEBUG2(module, fmt, arg1, arg2) \
-if (!DEBUG(module)) (void)0; \
-else debug_printf(fmt, arg1, arg2)
-
+	DEBUG_IMPL(module, (fmt, arg1, arg2))
 #define DEBUG3(module, fmt, arg1, arg2, arg3) \
-if (!DEBUG(module)) (void)0; \
-else debug_printf(fmt, arg1, arg2, arg3)
-
+	DEBUG_IMPL(module, (fmt, arg1, arg2, arg3))
 #define DEBUG4(module, fmt, arg1, arg2, arg3, arg4) \
-if (!DEBUG(module)) (void)0; \
-else debug_printf(fmt, arg1, arg2, arg3, arg4)
-
+	DEBUG_IMPL(module, (fmt, arg1, arg2, arg3, arg4))
 #define DEBUG5(module, fmt, arg1, arg2, arg3, arg4, arg5) \
-if (!DEBUG(module)) (void)0; \
-else debug_printf(fmt, arg1, arg2, arg3, arg4, arg5)
+	DEBUG_IMPL(module, (fmt, arg1, arg2, arg3, arg4, arg5))
 
 typedef enum PrintVarsMode {
 	PVM_NONE,



CVS commit: [netbsd-9] src/doc

2020-12-06 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Dec  6 10:31:48 UTC 2020

Modified Files:
src/doc [netbsd-9]: CHANGES-9.2

Log Message:
Tickets #1139 and #1141


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.16 -r1.1.2.17 src/doc/CHANGES-9.2

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/doc/CHANGES-9.2
diff -u src/doc/CHANGES-9.2:1.1.2.16 src/doc/CHANGES-9.2:1.1.2.17
--- src/doc/CHANGES-9.2:1.1.2.16	Sun Nov 29 11:41:49 2020
+++ src/doc/CHANGES-9.2	Sun Dec  6 10:31:48 2020
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-9.2,v 1.1.2.16 2020/11/29 11:41:49 martin Exp $
+# $NetBSD: CHANGES-9.2,v 1.1.2.17 2020/12/06 10:31:48 martin Exp $
 
 A complete list of changes from the NetBSD 9.1 release to the NetBSD 9.2
 release:
@@ -1129,3 +1129,17 @@ external/cddl/osnet/dist/uts/common/fs/z
 	the vnodes were opened for writing.
 	[yhardy, ticket #1138]
 
+xsrc/external/mit/xorg-server/dist/xkb/xkb.c		apply patch
+
+	Apply upstream patches for:
+	 * CVE-2020-14360 / ZDI CAN 11572 XkbSetMap Out-Of-Bounds Access
+	 * CVE-2020-25712 / ZDI-CAN-11839 XkbSetDeviceInfo Heap-based Buffer
+	   Overflow
+	[mrg, ticket #1141]
+
+sbin/dump/dump.h1.59
+sbin/dump/main.c1.78
+
+	PR 55834: fix status updates for files larger than 2TiB.
+	[kre, ticket #1139]
+



CVS commit: [netbsd-9] src/sbin/dump

2020-12-06 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Dec  6 10:31:02 UTC 2020

Modified Files:
src/sbin/dump [netbsd-9]: dump.h main.c

Log Message:
Pull up following revision(s) (requested by kre in ticket #1139):

sbin/dump/dump.h: revision 1.59
sbin/dump/main.c: revision 1.78

PR bin/55834

count blocks written in unsigned 64 bit counter
rather than signed int which overflows after 2^31-1
blocks (2TiB) after which neither the 5 minute
status updates or SIGINFO (^T) reports are issued
until the negative numbers increase past 0 and
wildly inaccurate reports would be written.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.57.2.1 src/sbin/dump/dump.h
cvs rdiff -u -r1.75 -r1.75.2.1 src/sbin/dump/main.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/dump/dump.h
diff -u src/sbin/dump/dump.h:1.57 src/sbin/dump/dump.h:1.57.2.1
--- src/sbin/dump/dump.h:1.57	Mon Mar 25 02:13:01 2019
+++ src/sbin/dump/dump.h	Sun Dec  6 10:31:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dump.h,v 1.57 2019/03/25 02:13:01 manu Exp $	*/
+/*	$NetBSD: dump.h,v 1.57.2.1 2020/12/06 10:31:02 martin Exp $	*/
 
 /*-
  * Copyright (c) 1980, 1993
@@ -134,7 +134,7 @@ int	unlimited;	/* if set, write to end o
 extern int	density;	/* density in 0.1" units */
 extern int	notify;		/* notify operator flag */
 extern int	timestamp;	/* timestamp messages */
-extern int	blockswritten;	/* number of blocks written on current tape */
+extern u_int64_t	blockswritten;	/* blocks written on current tape */
 extern int	tapeno;		/* current tape number */
 extern int	is_ufs2;
 

Index: src/sbin/dump/main.c
diff -u src/sbin/dump/main.c:1.75 src/sbin/dump/main.c:1.75.2.1
--- src/sbin/dump/main.c:1.75	Mon Mar 25 02:13:01 2019
+++ src/sbin/dump/main.c	Sun Dec  6 10:31:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.75 2019/03/25 02:13:01 manu Exp $	*/
+/*	$NetBSD: main.c,v 1.75.2.1 2020/12/06 10:31:02 martin Exp $	*/
 
 /*-
  * Copyright (c) 1980, 1991, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)main.c	8.6 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: main.c,v 1.75 2019/03/25 02:13:01 manu Exp $");
+__RCSID("$NetBSD: main.c,v 1.75.2.1 2020/12/06 10:31:02 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -71,7 +71,7 @@ __RCSID("$NetBSD: main.c,v 1.75 2019/03/
 
 int	timestamp;		/* print message timestamps */
 int	notify;			/* notify operator flag */
-int	blockswritten;		/* number of blocks written on current tape */
+u_int64_t	blockswritten;	/* number of blocks written on current tape */
 int	tapeno;			/* current tape number */
 int	density;		/* density in bytes/0.1" */
 int	ntrec = NTREC;		/* # tape blocks in each tape record */



CVS commit: [netbsd-8] src/doc

2020-12-06 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Dec  6 10:28:28 UTC 2020

Modified Files:
src/doc [netbsd-8]: CHANGES-8.3

Log Message:
Ticket #1627


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.52 -r1.1.2.53 src/doc/CHANGES-8.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/doc/CHANGES-8.3
diff -u src/doc/CHANGES-8.3:1.1.2.52 src/doc/CHANGES-8.3:1.1.2.53
--- src/doc/CHANGES-8.3:1.1.2.52	Sun Nov 29 11:20:09 2020
+++ src/doc/CHANGES-8.3	Sun Dec  6 10:28:28 2020
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-8.3,v 1.1.2.52 2020/11/29 11:20:09 martin Exp $
+# $NetBSD: CHANGES-8.3,v 1.1.2.53 2020/12/06 10:28:28 martin Exp $
 
 A complete list of changes from the NetBSD 8.2 release to the NetBSD 8.3
 release:
@@ -1337,3 +1337,11 @@ lib/libc/net/gethnamaddr.c			1.93
 	A or .
 	[is, ticket #1625]
 
+xsrc/external/mit/xorg-server/dist/xkb/xkb.c		apply patch
+
+	Apply upstream patches for:
+	 * CVE-2020-14360 / ZDI CAN 11572 XkbSetMap Out-Of-Bounds Access
+	 * CVE-2020-25712 / ZDI-CAN-11839 XkbSetDeviceInfo Heap-based Buffer
+	   Overflow
+	[mrg, ticket #1627]
+



CVS commit: [netbsd-8] xsrc/external/mit/xorg-server/dist/xkb

2020-12-06 Thread Martin Husemann
Module Name:xsrc
Committed By:   martin
Date:   Sun Dec  6 10:24:47 UTC 2020

Modified Files:
xsrc/external/mit/xorg-server/dist/xkb [netbsd-8]: xkb.c

Log Message:
Apply patch, requested by mrg in ticket #1627:

external/mit/xorg-server/dist/xkb/xkb.c apply patch

Apply upstream patches for:
 * CVE-2020-14360 / ZDI CAN 11572 XkbSetMap Out-Of-Bounds Access
 * CVE-2020-25712 / ZDI-CAN-11839 XkbSetDeviceInfo Heap-based Buffer Overflow


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.3.2.1 xsrc/external/mit/xorg-server/dist/xkb/xkb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: xsrc/external/mit/xorg-server/dist/xkb/xkb.c
diff -u xsrc/external/mit/xorg-server/dist/xkb/xkb.c:1.3 xsrc/external/mit/xorg-server/dist/xkb/xkb.c:1.3.2.1
--- xsrc/external/mit/xorg-server/dist/xkb/xkb.c:1.3	Thu Aug 11 00:04:36 2016
+++ xsrc/external/mit/xorg-server/dist/xkb/xkb.c	Sun Dec  6 10:24:47 2020
@@ -152,6 +152,19 @@ static RESTYPE RT_XKBCLIENT;
 #define	CHK_REQ_KEY_RANGE(err,first,num,r)  \
 	CHK_REQ_KEY_RANGE2(err,first,num,r,client->errorValue,BadValue)
 
+static Bool
+_XkbCheckRequestBounds(ClientPtr client, void *stuff, void *from, void *to) {
+char *cstuff = (char *)stuff;
+char *cfrom = (char *)from;
+char *cto = (char *)to;
+
+return cfrom < cto &&
+   cfrom >= cstuff &&
+   cfrom < cstuff + ((size_t)client->req_len << 2) &&
+   cto >= cstuff &&
+   cto <= cstuff + ((size_t)client->req_len << 2);
+}
+
 /******/
 
 int
@@ -1587,7 +1600,7 @@ CheckKeyTypes(ClientPtr client,
   XkbDescPtr xkb,
   xkbSetMapReq * req,
   xkbKeyTypeWireDesc ** wireRtrn,
-  int *nMapsRtrn, CARD8 *mapWidthRtrn)
+  int *nMapsRtrn, CARD8 *mapWidthRtrn, Bool doswap)
 {
 unsigned nMaps;
 register unsigned i, n;
@@ -1626,7 +1639,7 @@ CheckKeyTypes(ClientPtr client,
 for (i = 0; i < req->nTypes; i++) {
 unsigned width;
 
-if (client->swapped) {
+if (client->swapped && doswap) {
 swaps(>virtualMods);
 }
 n = i + req->firstType;
@@ -1653,7 +1666,7 @@ CheckKeyTypes(ClientPtr client,
 mapWire = (xkbKTSetMapEntryWireDesc *) [1];
 preWire = (xkbModsWireDesc *) [wire->nMapEntries];
 for (n = 0; n < wire->nMapEntries; n++) {
-if (client->swapped) {
+if (client->swapped && doswap) {
 swaps([n].virtualMods);
 }
 if (mapWire[n].realMods & (~wire->realMods)) {
@@ -1671,7 +1684,7 @@ CheckKeyTypes(ClientPtr client,
 return 0;
 }
 if (wire->preserve) {
-if (client->swapped) {
+if (client->swapped && doswap) {
 swaps([n].virtualMods);
 }
 if (preWire[n].realMods & (~mapWire[n].realMods)) {
@@ -1710,7 +1723,7 @@ CheckKeySyms(ClientPtr client,
  xkbSetMapReq * req,
  int nTypes,
  CARD8 *mapWidths,
- CARD16 *symsPerKey, xkbSymMapWireDesc ** wireRtrn, int *errorRtrn)
+ CARD16 *symsPerKey, xkbSymMapWireDesc ** wireRtrn, int *errorRtrn, Bool doswap)
 {
 register unsigned i;
 XkbSymMapPtr map;
@@ -1724,7 +1737,7 @@ CheckKeySyms(ClientPtr client,
 KeySym *pSyms;
 register unsigned nG;
 
-if (client->swapped) {
+if (client->swapped && doswap) {
 swaps(>nSyms);
 }
 nG = XkbNumGroups(wire->groupInfo);
@@ -2366,13 +2379,100 @@ SetVirtualModMap(XkbSrvInfoPtr xkbi,
 return (char *) wire;
 }
 
+#define _add_check_len(new) \
+if (len > UINT32_MAX - (new) || len > req_len - (new)) goto bad; \
+else len += new
+
+/**
+ * Check the length of the SetMap request
+ */
+static int
+_XkbSetMapCheckLength(xkbSetMapReq *req)
+{
+size_t len = sz_xkbSetMapReq, req_len = req->length << 2;
+xkbKeyTypeWireDesc *keytype;
+xkbSymMapWireDesc *symmap;
+BOOL preserve;
+int i, map_count, nSyms;
+
+if (req_len < len)
+goto bad;
+/* types */
+if (req->present & XkbKeyTypesMask) {
+keytype = (xkbKeyTypeWireDesc *)(req + 1);
+for (i = 0; i < req->nTypes; i++) {
+_add_check_len(XkbPaddedSize(sz_xkbKeyTypeWireDesc));
+if (req->flags & XkbSetMapResizeTypes) {
+_add_check_len(keytype->nMapEntries
+   * sz_xkbKTSetMapEntryWireDesc);
+preserve = keytype->preserve;
+map_count = keytype->nMapEntries;
+if (preserve) {
+_add_check_len(map_count * sz_xkbModsWireDesc);
+}
+keytype += 1;
+keytype = 

CVS commit: [netbsd-9] xsrc/external/mit/xorg-server/dist/xkb

2020-12-06 Thread Martin Husemann
Module Name:xsrc
Committed By:   martin
Date:   Sun Dec  6 10:18:02 UTC 2020

Modified Files:
xsrc/external/mit/xorg-server/dist/xkb [netbsd-9]: xkb.c

Log Message:
Apply patch, requested by mrg in ticket #1141:

external/mit/xorg-server/dist/xkb/xkb.c apply patch

Apply upstream patches for:
 * CVE-2020-14360 / ZDI CAN 11572 XkbSetMap Out-Of-Bounds Access
 * CVE-2020-25712 / ZDI-CAN-11839 XkbSetDeviceInfo Heap-based Buffer Overflow


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.4.2.1 xsrc/external/mit/xorg-server/dist/xkb/xkb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: xsrc/external/mit/xorg-server/dist/xkb/xkb.c
diff -u xsrc/external/mit/xorg-server/dist/xkb/xkb.c:1.4 xsrc/external/mit/xorg-server/dist/xkb/xkb.c:1.4.2.1
--- xsrc/external/mit/xorg-server/dist/xkb/xkb.c:1.4	Mon Dec 31 09:50:03 2018
+++ xsrc/external/mit/xorg-server/dist/xkb/xkb.c	Sun Dec  6 10:18:02 2020
@@ -152,6 +152,19 @@ static RESTYPE RT_XKBCLIENT;
 #define	CHK_REQ_KEY_RANGE(err,first,num,r)  \
 	CHK_REQ_KEY_RANGE2(err,first,num,r,client->errorValue,BadValue)
 
+static Bool
+_XkbCheckRequestBounds(ClientPtr client, void *stuff, void *from, void *to) {
+char *cstuff = (char *)stuff;
+char *cfrom = (char *)from;
+char *cto = (char *)to;
+
+return cfrom < cto &&
+   cfrom >= cstuff &&
+   cfrom < cstuff + ((size_t)client->req_len << 2) &&
+   cto >= cstuff &&
+   cto <= cstuff + ((size_t)client->req_len << 2);
+}
+
 /******/
 
 int
@@ -1587,7 +1600,7 @@ CheckKeyTypes(ClientPtr client,
   XkbDescPtr xkb,
   xkbSetMapReq * req,
   xkbKeyTypeWireDesc ** wireRtrn,
-  int *nMapsRtrn, CARD8 *mapWidthRtrn)
+  int *nMapsRtrn, CARD8 *mapWidthRtrn, Bool doswap)
 {
 unsigned nMaps;
 register unsigned i, n;
@@ -1626,7 +1639,7 @@ CheckKeyTypes(ClientPtr client,
 for (i = 0; i < req->nTypes; i++) {
 unsigned width;
 
-if (client->swapped) {
+if (client->swapped && doswap) {
 swaps(>virtualMods);
 }
 n = i + req->firstType;
@@ -1653,7 +1666,7 @@ CheckKeyTypes(ClientPtr client,
 mapWire = (xkbKTSetMapEntryWireDesc *) [1];
 preWire = (xkbModsWireDesc *) [wire->nMapEntries];
 for (n = 0; n < wire->nMapEntries; n++) {
-if (client->swapped) {
+if (client->swapped && doswap) {
 swaps([n].virtualMods);
 }
 if (mapWire[n].realMods & (~wire->realMods)) {
@@ -1671,7 +1684,7 @@ CheckKeyTypes(ClientPtr client,
 return 0;
 }
 if (wire->preserve) {
-if (client->swapped) {
+if (client->swapped && doswap) {
 swaps([n].virtualMods);
 }
 if (preWire[n].realMods & (~mapWire[n].realMods)) {
@@ -1710,7 +1723,7 @@ CheckKeySyms(ClientPtr client,
  xkbSetMapReq * req,
  int nTypes,
  CARD8 *mapWidths,
- CARD16 *symsPerKey, xkbSymMapWireDesc ** wireRtrn, int *errorRtrn)
+ CARD16 *symsPerKey, xkbSymMapWireDesc ** wireRtrn, int *errorRtrn, Bool doswap)
 {
 register unsigned i;
 XkbSymMapPtr map;
@@ -1724,7 +1737,7 @@ CheckKeySyms(ClientPtr client,
 KeySym *pSyms;
 register unsigned nG;
 
-if (client->swapped) {
+if (client->swapped && doswap) {
 swaps(>nSyms);
 }
 nG = XkbNumGroups(wire->groupInfo);
@@ -2366,13 +2379,100 @@ SetVirtualModMap(XkbSrvInfoPtr xkbi,
 return (char *) wire;
 }
 
+#define _add_check_len(new) \
+if (len > UINT32_MAX - (new) || len > req_len - (new)) goto bad; \
+else len += new
+
+/**
+ * Check the length of the SetMap request
+ */
+static int
+_XkbSetMapCheckLength(xkbSetMapReq *req)
+{
+size_t len = sz_xkbSetMapReq, req_len = req->length << 2;
+xkbKeyTypeWireDesc *keytype;
+xkbSymMapWireDesc *symmap;
+BOOL preserve;
+int i, map_count, nSyms;
+
+if (req_len < len)
+goto bad;
+/* types */
+if (req->present & XkbKeyTypesMask) {
+keytype = (xkbKeyTypeWireDesc *)(req + 1);
+for (i = 0; i < req->nTypes; i++) {
+_add_check_len(XkbPaddedSize(sz_xkbKeyTypeWireDesc));
+if (req->flags & XkbSetMapResizeTypes) {
+_add_check_len(keytype->nMapEntries
+   * sz_xkbKTSetMapEntryWireDesc);
+preserve = keytype->preserve;
+map_count = keytype->nMapEntries;
+if (preserve) {
+_add_check_len(map_count * sz_xkbModsWireDesc);
+}
+keytype += 1;
+keytype = 

CVS commit: src/sys/dev/i2c

2020-12-06 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Dec  6 10:09:36 UTC 2020

Modified Files:
src/sys/dev/i2c: pcf8574.c

Log Message:
Don't read from the chip when matching, fail the attach instead (requested
by jmcneill).  Reverts previous.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/i2c/pcf8574.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/i2c/pcf8574.c
diff -u src/sys/dev/i2c/pcf8574.c:1.4 src/sys/dev/i2c/pcf8574.c:1.5
--- src/sys/dev/i2c/pcf8574.c:1.4	Sat Dec  5 15:02:29 2020
+++ src/sys/dev/i2c/pcf8574.c	Sun Dec  6 10:09:36 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: pcf8574.c,v 1.4 2020/12/05 15:02:29 jdc Exp $ */
+/* $NetBSD: pcf8574.c,v 1.5 2020/12/06 10:09:36 jdc Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcf8574.c,v 1.4 2020/12/05 15:02:29 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcf8574.c,v 1.5 2020/12/06 10:09:36 jdc Exp $");
 
 #include 
 #include 
@@ -108,21 +108,10 @@ static int
 pcf8574_match(device_t parent, cfdata_t cf, void *aux)
 {
 	struct i2c_attach_args *ia = aux;
-	struct pcf8574_softc sc;
 	int match_result;
 
-	if (!iic_use_direct_match(ia, cf, compat_data, _result))
-		return 0;
-
-	/* Try a read so that we don't match on optional components */
-	if (match_result) {
-		sc.sc_tag = ia->ia_tag;
-		sc.sc_addr = ia->ia_addr;
-		if (pcf8574_read(, _state))
-			return 0;
-		else
-			return match_result;
-	}
+	if (iic_use_direct_match(ia, cf, compat_data, _result))
+		return match_result;
 
 	/* We don't support indirect matches */
 	return 0;
@@ -153,7 +142,11 @@ pcf8574_attach(device_t parent, device_t
 	 */
 	sc->sc_mask = 0xff;
 
-	pcf8574_read(sc, >sc_state);
+	/* Try a read, and fail if this component isn't present */
+	if (pcf8574_read(sc, >sc_state)) {
+		aprint_normal(": read failed\n");
+		return;
+	}
 
 #ifdef PCF8574_DEBUG
 	aprint_normal(": GPIO: state = 0x%02x\n", sc->sc_state);



CVS commit: src/sys/arch/sparc64/dev

2020-12-06 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Dec  6 10:06:15 UTC 2020

Modified Files:
src/sys/arch/sparc64/dev: pcf8591_envctrl.c

Log Message:
Don't read from the chip when matching, fail the attach instead (requested
by jmcneill).  Reverts previous.
While here, handle errors attaching sysmon and acquiring the iic bus lock.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/sparc64/dev/pcf8591_envctrl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/dev/pcf8591_envctrl.c
diff -u src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.12 src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.13
--- src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.12	Sat Dec  5 15:08:21 2020
+++ src/sys/arch/sparc64/dev/pcf8591_envctrl.c	Sun Dec  6 10:06:15 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcf8591_envctrl.c,v 1.12 2020/12/05 15:08:21 jdc Exp $	*/
+/*	$NetBSD: pcf8591_envctrl.c,v 1.13 2020/12/06 10:06:15 jdc Exp $	*/
 /*	$OpenBSD: pcf8591_envctrl.c,v 1.6 2007/10/25 21:17:20 kettenis Exp $ */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.12 2020/12/05 15:08:21 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.13 2020/12/06 10:06:15 jdc Exp $");
 
 #include 
 #include 
@@ -99,28 +99,10 @@ static int
 ecadc_match(device_t parent, cfdata_t cf, void *aux)
 {
 	struct i2c_attach_args *ia = aux;
-	struct ecadc_softc sc;
 	int match_result;
-	u_int8_t junk;
 
-	if (!iic_use_direct_match(ia, cf, compat_data, _result))
-		return 0;
-
-	/* Try a read so that we don't match on optional components */
-	if (match_result) {
-		sc.sc_tag = ia->ia_tag;
-		sc.sc_addr = ia->ia_addr;
-
-		iic_acquire_bus(sc.sc_tag, 0);
-		if (iic_exec(sc.sc_tag, I2C_OP_READ_WITH_STOP, sc.sc_addr,
-		NULL, 0, , 1, 0)) {
-			iic_release_bus(sc.sc_tag, 0);
-			return 0;
-		} else {
-			iic_release_bus(sc.sc_tag, 0);
-			return match_result;
-		}
-	}
+	if (iic_use_direct_match(ia, cf, compat_data, _result))
+		return match_result;
 
 	/* This driver is direct-config only. */
 
@@ -232,10 +214,10 @@ ecadc_attach(device_t parent, device_t s
 
 	iic_acquire_bus(sc->sc_tag, 0);
 
-	/* Try a read now, so we can fail if it doesn't work */
+	/* Try a read now, so we can fail if this component isn't present */
 	if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr,
 	NULL, 0, junk, sc->sc_nchan + 1, 0)) {
-		aprint_error(": read failed\n");
+		aprint_normal(": read failed\n");
 		iic_release_bus(sc->sc_tag, 0);
 		return;
 	}
@@ -259,6 +241,7 @@ ecadc_attach(device_t parent, device_t s
 		aprint_error_dev(self, "error %d registering with sysmon\n",
 			error);
 		sysmon_envsys_destroy(sc->sc_sme);
+		sc->sc_sme = NULL;
 		return;
 	}
 	
@@ -296,7 +279,8 @@ ecadc_refresh(struct sysmon_envsys *sme,
 	u_int8_t ctrl = PCF8591_CTRL_CH0 | PCF8591_CTRL_AUTOINC |
 	PCF8591_CTRL_OSCILLATOR;
 
-	iic_acquire_bus(sc->sc_tag, 0);
+	if (iic_acquire_bus(sc->sc_tag, 0))
+		return;
 	if (iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP, sc->sc_addr,
 	, 1, NULL, 0, 0)) {
 		iic_release_bus(sc->sc_tag, 0);
@@ -386,7 +370,12 @@ ecadc_set_fan_speed(struct ecadc_softc *
 	int ret;
 
 	ctrl |= chan;
-	iic_acquire_bus(sc->sc_tag, 0);
+	ret = iic_acquire_bus(sc->sc_tag, 0);
+	if (ret) {
+		aprint_error_dev(sc->sc_dev,
+		"error acquiring i2c bus (ch %d)\n", chan);
+		return ret;
+	}
 	ret = iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP, sc->sc_addr,
 	, 1, , 1, 0);
 	if (ret)



CVS commit: src/sys/rump/librump/rumpkern

2020-12-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Dec  6 09:03:29 UTC 2020

Modified Files:
src/sys/rump/librump/rumpkern: rump.c

Log Message:
Fix build after interval timers refectoring by thorpej@


To generate a diff of this commit:
cvs rdiff -u -r1.350 -r1.351 src/sys/rump/librump/rumpkern/rump.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/rump/librump/rumpkern/rump.c
diff -u src/sys/rump/librump/rumpkern/rump.c:1.350 src/sys/rump/librump/rumpkern/rump.c:1.351
--- src/sys/rump/librump/rumpkern/rump.c:1.350	Wed Nov  4 22:06:39 2020
+++ src/sys/rump/librump/rumpkern/rump.c	Sun Dec  6 09:03:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rump.c,v 1.350 2020/11/04 22:06:39 christos Exp $	*/
+/*	$NetBSD: rump.c,v 1.351 2020/12/06 09:03:29 skrll Exp $	*/
 
 /*
  * Copyright (c) 2007-2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.350 2020/11/04 22:06:39 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.351 2020/12/06 09:03:29 skrll Exp $");
 
 #include 
 #define ELFSIZE ARCH_ELFSIZE
@@ -412,7 +412,6 @@ rump_init_callback(void (*cpuinit_callba
 	resource_init();
 	procinit_sysctl();
 	time_init();
-	time_init2();
 	config_init();
 
 	/* start page baroness */