CVS commit: src/sys/uvm

2020-10-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Oct  5 04:48:24 UTC 2020

Modified Files:
src/sys/uvm: uvm_bio.c

Log Message:
PR kern/55658

ubc_fault_page(): Ignore PG_RDONLY flag and always pmap_enter() the page
with the permissions of the original access_type.

It is the file system's responsibility to allocate blocks that is being
modified by write(), before calling into UBC to fill the pages for that
range. KASSERT() is added there to confirm that no clean page is mapped
writable.

Fix infinite loop in uvm_fault_internal(), observed on 16KB-page systems,
where it continues to try to make a partially-backed page writable.

No regression in ATF and KASSERT() does not fire on several architectures,
as far as I can see.

Fix suggested by chs. Thanks!


To generate a diff of this commit:
cvs rdiff -u -r1.121 -r1.122 src/sys/uvm/uvm_bio.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/uvm/uvm_bio.c
diff -u src/sys/uvm/uvm_bio.c:1.121 src/sys/uvm/uvm_bio.c:1.122
--- src/sys/uvm/uvm_bio.c:1.121	Thu Jul  9 09:24:32 2020
+++ src/sys/uvm/uvm_bio.c	Mon Oct  5 04:48:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_bio.c,v 1.121 2020/07/09 09:24:32 rin Exp $	*/
+/*	$NetBSD: uvm_bio.c,v 1.122 2020/10/05 04:48:23 rin Exp $	*/
 
 /*
  * Copyright (c) 1998 Chuck Silvers.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.121 2020/07/09 09:24:32 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.122 2020/10/05 04:48:23 rin Exp $");
 
 #include "opt_uvmhist.h"
 #include "opt_ubc.h"
@@ -235,9 +235,7 @@ static inline int
 ubc_fault_page(const struct uvm_faultinfo *ufi, const struct ubc_map *umap,
 struct vm_page *pg, vm_prot_t prot, vm_prot_t access_type, vaddr_t va)
 {
-	vm_prot_t mask;
 	int error;
-	bool rdonly;
 
 	KASSERT(rw_write_held(pg->uobject->vmobjlock));
 
@@ -280,11 +278,11 @@ ubc_fault_page(const struct uvm_faultinf
 	pg->offset < umap->writeoff ||
 	pg->offset + PAGE_SIZE > umap->writeoff + umap->writelen);
 
-	rdonly = uvm_pagereadonly_p(pg);
-	mask = rdonly ? ~VM_PROT_WRITE : VM_PROT_ALL;
+	KASSERT((access_type & VM_PROT_WRITE) == 0 ||
+	uvm_pagegetdirty(pg) != UVM_PAGE_STATUS_CLEAN);
 
 	error = pmap_enter(ufi->orig_map->pmap, va, VM_PAGE_TO_PHYS(pg),
-	prot & mask, PMAP_CANFAIL | (access_type & mask));
+	prot, PMAP_CANFAIL | access_type);
 
 	uvm_pagelock(pg);
 	uvm_pageactivate(pg);



CVS commit: src/distrib/sun2/ramdisk

2020-10-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Oct  4 23:50:59 UTC 2020

Modified Files:
src/distrib/sun2/ramdisk: list

Log Message:
Try to fix ramdisk overflow (somehow build succeeds without fix for me);
drop mount_{cd9660,nfs} as cd(4) and NFS are disabled for RAMDISK kernel.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/distrib/sun2/ramdisk/list

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

Modified files:

Index: src/distrib/sun2/ramdisk/list
diff -u src/distrib/sun2/ramdisk/list:1.11 src/distrib/sun2/ramdisk/list:1.12
--- src/distrib/sun2/ramdisk/list:1.11	Wed Mar 10 23:13:09 2010
+++ src/distrib/sun2/ramdisk/list	Sun Oct  4 23:50:59 2020
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: list,v 1.11 2010/03/10 23:13:09 abs Exp $
+#	$NetBSD: list,v 1.12 2020/10/04 23:50:59 rin Exp $
 #
 # ramdisk/list - packing list for the ramdisk.
 #
@@ -58,9 +58,9 @@ PROG		sbin/route
 # From /usr/src/sbin:
 PROG		sbin/mknod
 PROG		sbin/mount
-PROG		sbin/mount_cd9660
+# PROG		sbin/mount_cd9660
 PROG		sbin/mount_ffs
-PROG		sbin/mount_nfs
+# PROG		sbin/mount_nfs
 PROG		sbin/reboot	sbin/halt
 PROG		sbin/umount
 



CVS commit: src/distrib/sun2/miniroot

2020-10-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Oct  4 23:42:43 UTC 2020

Modified Files:
src/distrib/sun2/miniroot: list

Log Message:
Revert previous; ``fix'' against wrong directory...


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/distrib/sun2/miniroot/list

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

Modified files:

Index: src/distrib/sun2/miniroot/list
diff -u src/distrib/sun2/miniroot/list:1.21 src/distrib/sun2/miniroot/list:1.22
--- src/distrib/sun2/miniroot/list:1.21	Sun Oct  4 09:42:48 2020
+++ src/distrib/sun2/miniroot/list	Sun Oct  4 23:42:43 2020
@@ -1,5 +1,5 @@
 #
-# $NetBSD: list,v 1.21 2020/10/04 09:42:48 rin Exp $
+# $NetBSD: list,v 1.22 2020/10/04 23:42:43 rin Exp $
 #
 
 # The PROM provides a default kernel name of "vmunix"
@@ -127,7 +127,7 @@ PROG	usr/bin/chflags
 PROG	usr/bin/cksum
 PROG	usr/bin/cmp
 PROG	usr/bin/ftp
-PROG	usr/bin/more	usr/bin/less
+PROG	usr/bin/less	usr/bin/more
 PROG	usr/bin/rsh
 PROG	usr/bin/sed
 PROG	usr/bin/tip
@@ -138,18 +138,14 @@ PROG	usr/bin/gzip	usr/bin/gzcat usr/bin/
 # install.md still uses sort
 PROG	usr/bin/sort
 
+SPECIAL	less		srcdir	external/bsd/less/bin/less
 SPECIAL	vi		srcdir	external/bsd/nvi/usr.bin/nvi
 
-SPECIAL	disklabel	srcdir	distrib/utils/x_disklabel
 SPECIAL	ed		srcdir	distrib/utils/x_ed
-SPECIAL	fsck_ffs	srcdir	distrib/utils/x_fsck_ffs
 SPECIAL	gzip		srcdir	distrib/utils/x_gzip
 SPECIAL	ifconfig	srcdir	distrib/utils/x_ifconfig
-SPECIAL	newfs		srcdir	distrib/utils/x_newfs
 SPECIAL	ping		srcdir	distrib/utils/x_ping
 SPECIAL	route		srcdir	distrib/utils/x_route
-
-SPECIAL	more		srcdir	distrib/utils/more
 SPECIAL	edlabel		srcdir	distrib/utils/edlabel
 
 ARGVLN	sh -sh



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

2020-10-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct  4 22:41:18 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: directive-ifndef.exp directive-ifndef.mk
directive-ifnmake.exp directive-ifnmake.mk

Log Message:
make(1): add tests for .ifndef and .ifnmake


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/directive-ifndef.exp \
src/usr.bin/make/unit-tests/directive-ifnmake.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/directive-ifndef.mk \
src/usr.bin/make/unit-tests/directive-ifnmake.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-ifndef.exp
diff -u src/usr.bin/make/unit-tests/directive-ifndef.exp:1.1 src/usr.bin/make/unit-tests/directive-ifndef.exp:1.2
--- src/usr.bin/make/unit-tests/directive-ifndef.exp:1.1	Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/directive-ifndef.exp	Sun Oct  4 22:41:18 2020
@@ -1 +1,2 @@
+make: "directive-ifndef.mk" line 10: guarded section
 exit status 0
Index: src/usr.bin/make/unit-tests/directive-ifnmake.exp
diff -u src/usr.bin/make/unit-tests/directive-ifnmake.exp:1.1 src/usr.bin/make/unit-tests/directive-ifnmake.exp:1.2
--- src/usr.bin/make/unit-tests/directive-ifnmake.exp:1.1	Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/directive-ifnmake.exp	Sun Oct  4 22:41:18 2020
@@ -1 +1,3 @@
+Don't forget to run the tests (1)
+Running the tests
 exit status 0

Index: src/usr.bin/make/unit-tests/directive-ifndef.mk
diff -u src/usr.bin/make/unit-tests/directive-ifndef.mk:1.2 src/usr.bin/make/unit-tests/directive-ifndef.mk:1.3
--- src/usr.bin/make/unit-tests/directive-ifndef.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/directive-ifndef.mk	Sun Oct  4 22:41:18 2020
@@ -1,8 +1,24 @@
-# $NetBSD: directive-ifndef.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: directive-ifndef.mk,v 1.3 2020/10/04 22:41:18 rillig Exp $
 #
-# Tests for the .ifndef directive.
+# Tests for the .ifndef directive, which can be used for multiple-inclusion
+# guards.  In contrast to C, where #ifndef and #define nicely line up the
+# macro name, there is no such syntax in make.  Therefore, it is more
+# common to use .if !defined(GUARD) instead.
 
-# TODO: Implementation
+.ifndef GUARD
+GUARD=	# defined
+.info guarded section
+.endif
+
+.ifndef GUARD
+GUARD=	# defined
+.info guarded section
+.endif
+
+.if !defined(GUARD)
+GUARD=	# defined
+.info guarded section
+.endif
 
 all:
 	@:;
Index: src/usr.bin/make/unit-tests/directive-ifnmake.mk
diff -u src/usr.bin/make/unit-tests/directive-ifnmake.mk:1.2 src/usr.bin/make/unit-tests/directive-ifnmake.mk:1.3
--- src/usr.bin/make/unit-tests/directive-ifnmake.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/directive-ifnmake.mk	Sun Oct  4 22:41:18 2020
@@ -1,8 +1,22 @@
-# $NetBSD: directive-ifnmake.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: directive-ifnmake.mk,v 1.3 2020/10/04 22:41:18 rillig Exp $
 #
-# Tests for the .ifnmake directive.
-
-# TODO: Implementation
+# Tests for the .ifnmake directive, which evaluates to true if its argument
+# is _not_ listed in the command-line targets to be created.
 
 all:
 	@:;
+
+.ifnmake(test)
+.BEGIN:
+	@echo "Don't forget to run the tests (1)"
+.endif
+
+.MAKEFLAGS: test
+
+.ifnmake(test)
+.BEGIN:
+	@echo "Don't forget to run the tests (2)"
+.endif
+
+test:
+	@echo "Running the tests"



CVS commit: src/usr.bin/make

2020-10-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct  4 21:53:28 UTC 2020

Modified Files:
src/usr.bin/make: parse.c
src/usr.bin/make/unit-tests: varname-dot-curdir.mk

Log Message:
make(1): fix assignment to .CURDIR via the shell assignment operator

This is probably an edge case that nobody will ever stumble upon, since
.CURDIR is usually regarded as a read-only variable.

The other variable that is affected by this code path is .MAKE.EXPORTED,
and for this variable as well, it would be unusual to assign it a value
from a shell command.


To generate a diff of this commit:
cvs rdiff -u -r1.361 -r1.362 src/usr.bin/make/parse.c
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varname-dot-curdir.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.361 src/usr.bin/make/parse.c:1.362
--- src/usr.bin/make/parse.c:1.361	Sun Oct  4 21:41:44 2020
+++ src/usr.bin/make/parse.c	Sun Oct  4 21:53:28 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.361 2020/10/04 21:41:44 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.362 2020/10/04 21:53:28 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.361 2020/10/04 21:41:44 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.362 2020/10/04 21:53:28 rillig Exp $");
 
 /* types and constants */
 
@@ -1850,29 +1850,26 @@ VarAssign_Eval(VarAssign *var, GNode *ct
 
 	Var_Set(name, avalue, ctxt);
 } else if (type == VAR_SHELL) {
-	char *res;
-	const char *error;
-
-	if (strchr(uvalue, '$') != NULL) {
-	char *evalue;
-	/*
-	 * There's a dollar sign in the command, so perform variable
-	 * expansion on the whole thing. The resulting string will need
-	 * freeing when we're done.
-	 */
-	(void)Var_Subst(uvalue, VAR_CMD, VARE_UNDEFERR|VARE_WANTRES,
-			);
+const char *cmd, *errfmt;
+char *cmdOut;
+void *cmd_freeIt = NULL;
+
+	cmd = uvalue;
+	if (strchr(cmd, '$') != NULL) {
+	char *ecmd;
+	(void)Var_Subst(cmd, VAR_CMD, VARE_UNDEFERR|VARE_WANTRES, );
 	/* TODO: handle errors */
-	avalue = evalue;
-	avalue_freeIt = evalue;
+	cmd = cmd_freeIt = ecmd;
 	}
 
-	res = Cmd_Exec(avalue, );
-	Var_Set(name, res, ctxt);
-	free(res);
+	cmdOut = Cmd_Exec(cmd, );
+	Var_Set(name, cmdOut, ctxt);
+	avalue = avalue_freeIt = cmdOut;
+
+	if (errfmt)
+	Parse_Error(PARSE_WARNING, errfmt, cmd);
 
-	if (error)
-	Parse_Error(PARSE_WARNING, error, avalue);
+	free(cmd_freeIt);
 } else {
 	if (type == VAR_DEFAULT && Var_Exists(var->varname, ctxt)) {
 	*out_avalue_freeIt = NULL;

Index: src/usr.bin/make/unit-tests/varname-dot-curdir.mk
diff -u src/usr.bin/make/unit-tests/varname-dot-curdir.mk:1.3 src/usr.bin/make/unit-tests/varname-dot-curdir.mk:1.4
--- src/usr.bin/make/unit-tests/varname-dot-curdir.mk:1.3	Sun Oct  4 20:06:48 2020
+++ src/usr.bin/make/unit-tests/varname-dot-curdir.mk	Sun Oct  4 21:53:28 2020
@@ -1,15 +1,17 @@
-# $NetBSD: varname-dot-curdir.mk,v 1.3 2020/10/04 20:06:48 rillig Exp $
+# $NetBSD: varname-dot-curdir.mk,v 1.4 2020/10/04 21:53:28 rillig Exp $
 #
 # Tests for the special .CURDIR variable.
 
 # TODO: Implementation
 
-# As of 2020-10-04, assigning the result of a shell command to .CURDIR tries
-# to add the shell command to the .PATH instead of the output of the shell
-# command.  Since "echo /" does not exist, the .PATH is left unmodified.
-# See Parse_DoVar at the very bottom.
+# Until 2020-10-04, assigning the result of a shell assignment to .CURDIR
+# tried to add the shell command ("echo /") to the .PATH instead of the
+# output of the shell command ("/").  Since "echo /" does not exist, the
+# .PATH was left unmodified.  See VarAssign_Eval.
+#
+# Since 2020-10-04, the output of the shell command is added to .PATH.
 .CURDIR!=	echo /
-.if ${.PATH:M/}
+.if ${.PATH:M/} != "/"
 .  error
 .endif
 
@@ -17,7 +19,7 @@
 # Appending to .CURDIR does not make sense, therefore it doesn't matter that
 # this code path is buggy as well.
 .CURDIR=	/
-.if !${.PATH:M/}
+.if ${.PATH:M/} != "/"
 .  error
 .endif
 



CVS commit: src/usr.bin/make

2020-10-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct  4 21:41:44 UTC 2020

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

Log Message:
make(1): rename local variable in VarAssign_Eval

The value to be freed is not always evalue.  In the case of VAR_SUBST,
it will be the output of the command, not the command itself.


To generate a diff of this commit:
cvs rdiff -u -r1.360 -r1.361 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.360 src/usr.bin/make/parse.c:1.361
--- src/usr.bin/make/parse.c:1.360	Sun Oct  4 21:08:37 2020
+++ src/usr.bin/make/parse.c	Sun Oct  4 21:41:44 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.360 2020/10/04 21:08:37 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.361 2020/10/04 21:41:44 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.360 2020/10/04 21:08:37 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.361 2020/10/04 21:41:44 rillig Exp $");
 
 /* types and constants */
 
@@ -1814,11 +1814,12 @@ VarAssign_Eval(VarAssign *var, GNode *ct
 const char *name = var->varname;
 const VarAssignOp type = var->op;
 const char *avalue = uvalue;
-char *evalue = NULL;
+void *avalue_freeIt = NULL;
 
 if (type == VAR_APPEND) {
 	Var_Append(name, uvalue, ctxt);
 } else if (type == VAR_SUBST) {
+char *evalue;
 	/*
 	 * Allow variables in the old value to be undefined, but leave their
 	 * expressions alone -- this is done by forcing oldVars to be false.
@@ -1845,6 +1846,7 @@ VarAssign_Eval(VarAssign *var, GNode *ct
 	/* TODO: handle errors */
 	oldVars = oldOldVars;
 	avalue = evalue;
+	avalue_freeIt = evalue;
 
 	Var_Set(name, avalue, ctxt);
 } else if (type == VAR_SHELL) {
@@ -1852,6 +1854,7 @@ VarAssign_Eval(VarAssign *var, GNode *ct
 	const char *error;
 
 	if (strchr(uvalue, '$') != NULL) {
+	char *evalue;
 	/*
 	 * There's a dollar sign in the command, so perform variable
 	 * expansion on the whole thing. The resulting string will need
@@ -1861,6 +1864,7 @@ VarAssign_Eval(VarAssign *var, GNode *ct
 			);
 	/* TODO: handle errors */
 	avalue = evalue;
+	avalue_freeIt = evalue;
 	}
 
 	res = Cmd_Exec(avalue, );
@@ -1880,7 +1884,7 @@ VarAssign_Eval(VarAssign *var, GNode *ct
 }
 
 *out_avalue = avalue;
-*out_avalue_freeIt = evalue;
+*out_avalue_freeIt = avalue_freeIt;
 return TRUE;
 }
 



CVS commit: src/usr.bin/make

2020-10-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct  4 21:08:37 UTC 2020

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

Log Message:
make(1): hide some more implementation details from Parse_DoVar


To generate a diff of this commit:
cvs rdiff -u -r1.359 -r1.360 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.359 src/usr.bin/make/parse.c:1.360
--- src/usr.bin/make/parse.c:1.359	Sun Oct  4 20:57:26 2020
+++ src/usr.bin/make/parse.c	Sun Oct  4 21:08:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.359 2020/10/04 20:57:26 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.360 2020/10/04 21:08:37 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.359 2020/10/04 20:57:26 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.360 2020/10/04 21:08:37 rillig Exp $");
 
 /* types and constants */
 
@@ -1807,10 +1807,10 @@ VarCheckSyntax(VarAssignOp type, const c
 }
 
 static Boolean
-VarAssign_Eval(VarAssign *var,
-	  const char *const uvalue, const char **out_avalue, char **out_evalue,
-	  GNode *ctxt)
+VarAssign_Eval(VarAssign *var, GNode *ctxt,
+	   const char **out_avalue, void **out_avalue_freeIt)
 {
+const char *uvalue = var->value;
 const char *name = var->varname;
 const VarAssignOp type = var->op;
 const char *avalue = uvalue;
@@ -1857,7 +1857,8 @@ VarAssign_Eval(VarAssign *var,
 	 * expansion on the whole thing. The resulting string will need
 	 * freeing when we're done.
 	 */
-	(void)Var_Subst(uvalue, VAR_CMD, VARE_UNDEFERR|VARE_WANTRES, );
+	(void)Var_Subst(uvalue, VAR_CMD, VARE_UNDEFERR|VARE_WANTRES,
+			);
 	/* TODO: handle errors */
 	avalue = evalue;
 	}
@@ -1869,15 +1870,17 @@ VarAssign_Eval(VarAssign *var,
 	if (error)
 	Parse_Error(PARSE_WARNING, error, avalue);
 } else {
-	if (type == VAR_DEFAULT && Var_Exists(var->varname, ctxt))
+	if (type == VAR_DEFAULT && Var_Exists(var->varname, ctxt)) {
+	*out_avalue_freeIt = NULL;
 	return FALSE;
+	}
 
 	/* Normal assignment -- just do it. */
 	Var_Set(name, uvalue, ctxt);
 }
 
 *out_avalue = avalue;
-*out_evalue = evalue;
+*out_avalue_freeIt = evalue;
 return TRUE;
 }
 
@@ -1917,20 +1920,16 @@ VarAssignSpecial(const char *name, const
 void
 Parse_DoVar(VarAssign *var, GNode *ctxt)
 {
-const char *uvalue;		/* unexpanded value */
-const char *avalue;		/* actual value */
-char *evalue = NULL;	/* expanded value */
+const char *avalue;		/* actual value (maybe expanded) */
+void *avalue_freeIt;
 
 ParseVarassignOp(var);
 
-uvalue = var->value;
-avalue = uvalue;
-
-VarCheckSyntax(var->op, uvalue, ctxt);
-if (VarAssign_Eval(var, uvalue, , , ctxt))
+VarCheckSyntax(var->op, var->value, ctxt);
+if (VarAssign_Eval(var, ctxt, , _freeIt))
 	VarAssignSpecial(var->varname, avalue);
 
-free(evalue);
+free(avalue_freeIt);
 free(var->varname);
 }
 



CVS commit: src/usr.bin/make

2020-10-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct  4 20:57:27 UTC 2020

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

Log Message:
make(1): clean up remaining details in variable assignment parser


To generate a diff of this commit:
cvs rdiff -u -r1.358 -r1.359 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.358 src/usr.bin/make/parse.c:1.359
--- src/usr.bin/make/parse.c:1.358	Sun Oct  4 20:37:11 2020
+++ src/usr.bin/make/parse.c	Sun Oct  4 20:57:26 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.358 2020/10/04 20:37:11 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.359 2020/10/04 20:57:26 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.358 2020/10/04 20:37:11 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.359 2020/10/04 20:57:26 rillig Exp $");
 
 /* types and constants */
 
@@ -1680,6 +1680,10 @@ Parse_IsVar(const char *p, VarAssign *ou
 while (*p == ' ' || *p == '\t')
 	p++;
 
+/* During parsing, the '+' of the '+=' operator is initially parsed
+ * as part of the variable name.  It is later corrected, as is the ':sh'
+ * modifier. Of these two (nameEnd and op), the earlier one determines the
+ * actual end of the variable name. */
 out_var->nameStart = p;
 #ifdef CLEANUP
 out_var->nameEndDraft = NULL;
@@ -1744,13 +1748,12 @@ Parse_IsVar(const char *p, VarAssign *ou
 /* Determine the assignment operator and adjust the end of the variable
  * name accordingly. */
 static void
-ParseVarassignOp(VarAssign *var, const char **out_op, GNode *ctxt)
+ParseVarassignOp(VarAssign *var)
 {
 const char *op = var->eq;
 const char * const name = var->nameStart;
 VarAssignOp type;
 
-var->varname = NULL;
 if (op > name && op[-1] == '+') {
 	type = VAR_APPEND;
 	op--;
@@ -1780,8 +1783,11 @@ ParseVarassignOp(VarAssign *var, const c
 #endif
 }
 
-*out_op = op;
-var->op = type;
+{
+	const char *nameEnd = var->nameEndDraft < op ? var->nameEndDraft : op;
+	var->varname = bmake_strsedup(var->nameStart, nameEnd);
+	var->op = type;
+}
 }
 
 static void
@@ -1915,27 +1921,12 @@ Parse_DoVar(VarAssign *var, GNode *ctxt)
 const char *avalue;		/* actual value */
 char *evalue = NULL;	/* expanded value */
 
-/* The variable name consists of a single word (that is, no whitespace).
- * It ends at the whitespace after that word (nameEnd).  If there is no
- * whitespace, the name is followed directly by the assignment operator
- * (op).  During parsing, the '+' of the '+=' operator is initially parsed
- * as part of the variable name.  It is later corrected, as is the ':sh'
- * modifier. Of these two (nameEnd and op), the earlier one determines the
- * actual end of the variable name. */
-const char *op;
-
-ParseVarassignOp(var, , ctxt);
+ParseVarassignOp(var);
 
 uvalue = var->value;
 avalue = uvalue;
 
 VarCheckSyntax(var->op, uvalue, ctxt);
-
-if (var->varname == NULL) {
-	const char *nameEnd = var->nameEndDraft < op ? var->nameEndDraft : op;
-	var->varname = bmake_strsedup(var->nameStart, nameEnd);
-}
-
 if (VarAssign_Eval(var, uvalue, , , ctxt))
 	VarAssignSpecial(var->varname, avalue);
 



CVS commit: src/usr.bin/make

2020-10-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct  4 20:37:11 UTC 2020

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

Log Message:
make(1): clean up code for parsing ?= variable assignments

There is no need to handle the ?= operator in ParseVarassignOp already,
when all other operators are handled later.


To generate a diff of this commit:
cvs rdiff -u -r1.357 -r1.358 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.357 src/usr.bin/make/parse.c:1.358
--- src/usr.bin/make/parse.c:1.357	Sun Oct  4 20:23:32 2020
+++ src/usr.bin/make/parse.c	Sun Oct  4 20:37:11 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.357 2020/10/04 20:23:32 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.358 2020/10/04 20:37:11 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.357 2020/10/04 20:23:32 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.358 2020/10/04 20:37:11 rillig Exp $");
 
 /* types and constants */
 
@@ -1743,48 +1743,37 @@ Parse_IsVar(const char *p, VarAssign *ou
 
 /* Determine the assignment operator and adjust the end of the variable
  * name accordingly. */
-static Boolean
+static void
 ParseVarassignOp(VarAssign *var, const char **out_op, GNode *ctxt)
 {
 const char *op = var->eq;
-const char * const nameStart = var->nameStart;
+const char * const name = var->nameStart;
 VarAssignOp type;
 
 var->varname = NULL;
-if (op > nameStart && op[-1] == '+') {
+if (op > name && op[-1] == '+') {
 	type = VAR_APPEND;
 	op--;
 
-} else if (op > nameStart && op[-1] == '?') {
-	/* If the variable already has a value, we don't do anything. */
-	Boolean exists;
-	const char *nameEnd;
-
-	op--;
-	nameEnd = var->nameEndDraft < op ? var->nameEndDraft : op;
-	var->varname = bmake_strsedup(nameStart, nameEnd);
-	exists = Var_Exists(var->varname, ctxt);
-	if (exists) {
-	free(var->varname);
-	return FALSE;
-	}
-	type = VAR_NORMAL;
+} else if (op > name && op[-1] == '?') {
+op--;
+type = VAR_DEFAULT;
 
-} else if (op > nameStart && op[-1] == ':') {
+} else if (op > name && op[-1] == ':') {
 	op--;
 	type = VAR_SUBST;
 
-} else if (op > nameStart && op[-1] == '!') {
+} else if (op > name && op[-1] == '!') {
 	op--;
 	type = VAR_SHELL;
 
 } else {
 	type = VAR_NORMAL;
 #ifdef SUNSHCMD
-	while (op > nameStart && ch_isspace(op[-1]))
+	while (op > name && ch_isspace(op[-1]))
 	op--;
 
-	if (op >= nameStart + 3 && op[-3] == ':' && op[-2] == 's' && op[-1] == 'h') {
+	if (op >= name + 3 && op[-3] == ':' && op[-2] == 's' && op[-1] == 'h') {
 	type = VAR_SHELL;
 	op -= 3;
 	}
@@ -1793,7 +1782,6 @@ ParseVarassignOp(VarAssign *var, const c
 
 *out_op = op;
 var->op = type;
-return TRUE;
 }
 
 static void
@@ -1812,7 +1800,7 @@ VarCheckSyntax(VarAssignOp type, const c
 }
 }
 
-static void
+static Boolean
 VarAssign_Eval(VarAssign *var,
 	  const char *const uvalue, const char **out_avalue, char **out_evalue,
 	  GNode *ctxt)
@@ -1875,14 +1863,16 @@ VarAssign_Eval(VarAssign *var,
 	if (error)
 	Parse_Error(PARSE_WARNING, error, avalue);
 } else {
-	/*
-	 * Normal assignment -- just do it.
-	 */
+	if (type == VAR_DEFAULT && Var_Exists(var->varname, ctxt))
+	return FALSE;
+
+	/* Normal assignment -- just do it. */
 	Var_Set(name, uvalue, ctxt);
 }
 
 *out_avalue = avalue;
 *out_evalue = evalue;
+return TRUE;
 }
 
 static void
@@ -1934,8 +1924,7 @@ Parse_DoVar(VarAssign *var, GNode *ctxt)
  * actual end of the variable name. */
 const char *op;
 
-if (!ParseVarassignOp(var, , ctxt))
-	return;
+ParseVarassignOp(var, , ctxt);
 
 uvalue = var->value;
 avalue = uvalue;
@@ -1947,8 +1936,8 @@ Parse_DoVar(VarAssign *var, GNode *ctxt)
 	var->varname = bmake_strsedup(var->nameStart, nameEnd);
 }
 
-VarAssign_Eval(var, uvalue, , , ctxt);
-VarAssignSpecial(var->varname, avalue);
+if (VarAssign_Eval(var, uvalue, , , ctxt))
+	VarAssignSpecial(var->varname, avalue);
 
 free(evalue);
 free(var->varname);



CVS commit: src/usr.sbin/ifwatchd

2020-10-04 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sun Oct  4 20:36:32 UTC 2020

Modified Files:
src/usr.sbin/ifwatchd: ifwatchd.c

Log Message:
ifwatchd: Enable SO_RERROR to re-sync interface state.

Interface arrival, departure and link state changes will sync
and if different will be actioned.

Currently we do not track addresses, so any changes there are still lost.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/usr.sbin/ifwatchd/ifwatchd.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/ifwatchd/ifwatchd.c
diff -u src/usr.sbin/ifwatchd/ifwatchd.c:1.45 src/usr.sbin/ifwatchd/ifwatchd.c:1.46
--- src/usr.sbin/ifwatchd/ifwatchd.c:1.45	Sun Sep 27 19:55:21 2020
+++ src/usr.sbin/ifwatchd/ifwatchd.c	Sun Oct  4 20:36:32 2020
@@ -1,6 +1,6 @@
-/*	$NetBSD: ifwatchd.c,v 1.45 2020/09/27 19:55:21 roy Exp $	*/
+/*	$NetBSD: ifwatchd.c,v 1.46 2020/10/04 20:36:32 roy Exp $	*/
 #include 
-__RCSID("$NetBSD: ifwatchd.c,v 1.45 2020/09/27 19:55:21 roy Exp $");
+__RCSID("$NetBSD: ifwatchd.c,v 1.46 2020/10/04 20:36:32 roy Exp $");
 
 /*-
  * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
@@ -44,15 +44,16 @@ __RCSID("$NetBSD: ifwatchd.c,v 1.45 2020
 #include 
 #include 
 
+#include 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
 #include 
-#include 
-#include 
-#include 
-#include 
 #include 
+#include 
 
 enum event { ARRIVAL, DEPARTURE, UP, DOWN, CARRIER, NO_CARRIER };
 enum addrflag { NOTREADY, DETACHED, READY };
@@ -69,7 +70,7 @@ static void check_announce(const struct 
 static void check_carrier(const struct if_msghdr *ifm);
 static void free_interfaces(void);
 static struct interface_data * find_interface(int index);
-static void run_initial_ups(void);
+static void run_initial_ups(bool);
 
 /* global variables */
 static int verbose = 0, quiet = 0;
@@ -197,9 +198,12 @@ main(int argc, char **argv)
 	if (setsockopt(s, PF_ROUTE, RO_MSGFILTER,
 	, sizeof(msgfilter)) < 0)
 		syslog(LOG_ERR, "RO_MSGFILTER: %m");
+	n = 1;
+	if (setsockopt(s, SOL_SOCKET, SO_RERROR, , sizeof(n)) < 0)
+		syslog(LOG_ERR, "SO_RERROR: %m");
 
 	if (!inhibit_initial)
-		run_initial_ups();
+		run_initial_ups(true);
 
 	iov[0].iov_base = buf;
 	iov[0].iov_len = sizeof(buf);
@@ -210,6 +214,15 @@ main(int argc, char **argv)
 	for (;;) {
 		n = recvmsg(s, , 0);
 		if (n == -1) {
+			if (errno == ENOBUFS) {
+syslog(LOG_ERR,
+"routing socket overflow detected");
+/* XXX We don't track addresses, so they
+ * won't be reported. */
+if (!inhibit_initial)
+	run_initial_ups(false);
+continue;
+			}
 			syslog(LOG_ERR, "recvmsg: %m");
 			exit(EXIT_FAILURE);
 		}
@@ -482,6 +495,28 @@ check_carrier(const struct if_msghdr *if
 }
 
 static void
+do_announce(struct interface_data *ifd,
+unsigned short what, unsigned short index)
+{
+
+	switch (what) {
+	case IFAN_ARRIVAL:
+		ifd->index = index;
+		invoke_script(ifd->ifname, ARRIVAL, NULL, NULL);
+		break;
+	case IFAN_DEPARTURE:
+		ifd->index = -1;
+		ifd->last_carrier_status = -1;
+		invoke_script(ifd->ifname, DEPARTURE, NULL, NULL);
+		break;
+	default:
+		if (verbose)
+			(void) printf("unknown announce: what=%d\n", what);
+		break;
+	}
+}
+
+static void
 check_announce(const struct if_announcemsghdr *ifan)
 {
 	struct interface_data * p;
@@ -491,22 +526,7 @@ check_announce(const struct if_announcem
 		if (strcmp(p->ifname, ifname) != 0)
 			continue;
 
-		switch (ifan->ifan_what) {
-		case IFAN_ARRIVAL:
-			p->index = ifan->ifan_index;
-			invoke_script(p->ifname, ARRIVAL, NULL, NULL);
-			break;
-		case IFAN_DEPARTURE:
-			p->index = -1;
-			p->last_carrier_status = -1;
-			invoke_script(p->ifname, DEPARTURE, NULL, NULL);
-			break;
-		default:
-			if (verbose)
-(void) printf("unknown announce: "
-"what=%d\n", ifan->ifan_what);
-			break;
-		}
+		do_announce(p, ifan->ifan_what, ifan->ifan_index);
 		return;
 	}
 }
@@ -536,7 +556,7 @@ find_interface(int idx)
 }
 
 static void
-run_initial_ups(void)
+run_initial_ups(bool do_addrs)
 {
 	struct interface_data * ifd;
 	struct ifaddrs *res = NULL, *p;
@@ -551,6 +571,19 @@ run_initial_ups(void)
 	if (getifaddrs() != 0)
 		goto out;
 
+	/* Check if any interfaces vanished */
+	SLIST_FOREACH(ifd, , next) {
+		for (p = res; p; p = p->ifa_next) {
+			if (strcmp(ifd->ifname, p->ifa_name) != 0)
+continue;
+			ifa = p->ifa_addr;
+			if (ifa != NULL && ifa->sa_family == AF_LINK)
+break;
+		}
+		if (p == NULL)
+			do_announce(ifd, IFAN_DEPARTURE, ifd->index);
+	}
+
 	for (p = res; p; p = p->ifa_next) {
 		SLIST_FOREACH(ifd, , next) {
 			if (strcmp(ifd->ifname, p->ifa_name) == 0)
@@ -560,7 +593,8 @@ run_initial_ups(void)
 			continue;
 
 		ifa = p->ifa_addr;
-		if (ifa != NULL && ifa->sa_family == AF_LINK)
+		if (ifa != NULL && ifa->sa_family == AF_LINK &&
+		ifd->index == -1)
 			invoke_script(ifd->ifname, ARRIVAL, NULL, NULL);
 
 		if ((p->ifa_flags & 

CVS commit: src/usr.bin/make

2020-10-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct  4 20:23:32 UTC 2020

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

Log Message:
make(1): clean up parsing of variable assignments


To generate a diff of this commit:
cvs rdiff -u -r1.137 -r1.138 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.356 -r1.357 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.137 src/usr.bin/make/nonints.h:1.138
--- src/usr.bin/make/nonints.h:1.137	Sun Oct  4 19:36:32 2020
+++ src/usr.bin/make/nonints.h	Sun Oct  4 20:23:32 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nonints.h,v 1.137 2020/10/04 19:36:32 rillig Exp $	*/
+/*	$NetBSD: nonints.h,v 1.138 2020/10/04 20:23:32 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -130,8 +130,9 @@ typedef enum VarAssignOp {
 } VarAssignOp;
 
 typedef struct VarAssign {
-const char *name;		/* unexpanded */
+const char *nameStart;	/* unexpanded */
 const char *nameEndDraft;	/* before operator adjustment */
+char *varname;
 const char *eq;		/* the '=' of the assignment operator */
 VarAssignOp op;
 const char *value;		/* unexpanded */

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.356 src/usr.bin/make/parse.c:1.357
--- src/usr.bin/make/parse.c:1.356	Sun Oct  4 19:36:32 2020
+++ src/usr.bin/make/parse.c	Sun Oct  4 20:23:32 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.356 2020/10/04 19:36:32 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.357 2020/10/04 20:23:32 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.356 2020/10/04 19:36:32 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.357 2020/10/04 20:23:32 rillig Exp $");
 
 /* types and constants */
 
@@ -1680,7 +1680,14 @@ Parse_IsVar(const char *p, VarAssign *ou
 while (*p == ' ' || *p == '\t')
 	p++;
 
-out_var->name = p;
+out_var->nameStart = p;
+#ifdef CLEANUP
+out_var->nameEndDraft = NULL;
+out_var->varname = NULL;
+out_var->eq = NULL;
+out_var->op = VAR_NORMAL;
+out_var->value = NULL;
+#endif
 
 /* Scan for one of the assignment operators outside a variable expansion */
 while ((ch = *p++) != 0) {
@@ -1734,50 +1741,50 @@ Parse_IsVar(const char *p, VarAssign *ou
 return FALSE;
 }
 
+/* Determine the assignment operator and adjust the end of the variable
+ * name accordingly. */
 static Boolean
-ParseVarassignOp(VarAssign *var,
-		 const char **out_op, const char **inout_name,
-		 VarAssignOp *out_type, void **inout_name_freeIt, GNode *ctxt)
+ParseVarassignOp(VarAssign *var, const char **out_op, GNode *ctxt)
 {
 const char *op = var->eq;
-const char *name = *inout_name;
-void *name_freeIt = *inout_name_freeIt;
+const char * const nameStart = var->nameStart;
 VarAssignOp type;
 
-if (op > name && op[-1] == '+') {
+var->varname = NULL;
+if (op > nameStart && op[-1] == '+') {
 	type = VAR_APPEND;
 	op--;
 
-} else if (op > name && op[-1] == '?') {
+} else if (op > nameStart && op[-1] == '?') {
 	/* If the variable already has a value, we don't do anything. */
 	Boolean exists;
 	const char *nameEnd;
 
 	op--;
 	nameEnd = var->nameEndDraft < op ? var->nameEndDraft : op;
-	name = name_freeIt = bmake_strsedup(name, nameEnd);
-	exists = Var_Exists(name, ctxt);
+	var->varname = bmake_strsedup(nameStart, nameEnd);
+	exists = Var_Exists(var->varname, ctxt);
 	if (exists) {
-	free(name_freeIt);
+	free(var->varname);
 	return FALSE;
 	}
 	type = VAR_NORMAL;
 
-} else if (op > name && op[-1] == ':') {
+} else if (op > nameStart && op[-1] == ':') {
 	op--;
 	type = VAR_SUBST;
 
-} else if (op > name && op[-1] == '!') {
+} else if (op > nameStart && op[-1] == '!') {
 	op--;
 	type = VAR_SHELL;
 
 } else {
 	type = VAR_NORMAL;
 #ifdef SUNSHCMD
-	while (op > name && ch_isspace(op[-1]))
+	while (op > nameStart && ch_isspace(op[-1]))
 	op--;
 
-	if (op >= name + 3 && op[-3] == ':' && op[-2] == 's' && op[-1] == 'h') {
+	if (op >= nameStart + 3 && op[-3] == ':' && op[-2] == 's' && op[-1] == 'h') {
 	type = VAR_SHELL;
 	op -= 3;
 	}
@@ -1785,9 +1792,7 @@ ParseVarassignOp(VarAssign *var,
 }
 
 *out_op = op;
-*inout_name = name;
-*out_type = type;
-*inout_name_freeIt = name_freeIt;
+var->op = type;
 return TRUE;
 }
 
@@ -1808,10 +1813,12 @@ VarCheckSyntax(VarAssignOp type, const c
 }
 
 static void
-VarAssign_Eval(VarAssignOp const type, const char *const name,
+VarAssign_Eval(VarAssign *var,
 	  const char *const uvalue, const char **out_avalue, char **out_evalue,
 	  GNode *ctxt)
 {
+const char *name = var->varname;
+const VarAssignOp type = var->op;
 const char *avalue = uvalue;
 char *evalue = NULL;
 
@@ 

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

2020-10-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct  4 20:06:49 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: varname-dot-curdir.mk

Log Message:
make(1): add test for assigning to .CURDIR


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varname-dot-curdir.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/varname-dot-curdir.mk
diff -u src/usr.bin/make/unit-tests/varname-dot-curdir.mk:1.2 src/usr.bin/make/unit-tests/varname-dot-curdir.mk:1.3
--- src/usr.bin/make/unit-tests/varname-dot-curdir.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/varname-dot-curdir.mk	Sun Oct  4 20:06:48 2020
@@ -1,8 +1,25 @@
-# $NetBSD: varname-dot-curdir.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: varname-dot-curdir.mk,v 1.3 2020/10/04 20:06:48 rillig Exp $
 #
 # Tests for the special .CURDIR variable.
 
 # TODO: Implementation
 
+# As of 2020-10-04, assigning the result of a shell command to .CURDIR tries
+# to add the shell command to the .PATH instead of the output of the shell
+# command.  Since "echo /" does not exist, the .PATH is left unmodified.
+# See Parse_DoVar at the very bottom.
+.CURDIR!=	echo /
+.if ${.PATH:M/}
+.  error
+.endif
+
+# A normal assignment works fine, as does a substitution assignment.
+# Appending to .CURDIR does not make sense, therefore it doesn't matter that
+# this code path is buggy as well.
+.CURDIR=	/
+.if !${.PATH:M/}
+.  error
+.endif
+
 all:
 	@:;



CVS commit: src/usr.bin/make

2020-10-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct  4 19:36:32 UTC 2020

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

Log Message:
make(1): remove duplicate code for parsing a variable name


To generate a diff of this commit:
cvs rdiff -u -r1.365 -r1.366 src/usr.bin/make/main.c
cvs rdiff -u -r1.136 -r1.137 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.355 -r1.356 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/main.c
diff -u src/usr.bin/make/main.c:1.365 src/usr.bin/make/main.c:1.366
--- src/usr.bin/make/main.c:1.365	Sun Oct  4 08:22:59 2020
+++ src/usr.bin/make/main.c	Sun Oct  4 19:36:32 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.365 2020/10/04 08:22:59 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.366 2020/10/04 19:36:32 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -122,7 +122,7 @@
 #endif
 
 /*	"@(#)main.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: main.c,v 1.365 2020/10/04 08:22:59 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.366 2020/10/04 19:36:32 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	"The Regents of the University of California.  "
@@ -673,9 +673,10 @@ rearg:
 	 * perform them if so. Else take them to be targets and stuff them
 	 * on the end of the "create" list.
 	 */
-	for (; argc > 1; ++argv, --argc)
-		if (Parse_IsVar(argv[1])) {
-			Parse_DoVar(argv[1], VAR_CMD);
+	for (; argc > 1; ++argv, --argc) {
+		VarAssign var;
+		if (Parse_IsVar(argv[1], )) {
+			Parse_DoVar(, VAR_CMD);
 		} else {
 			if (!*argv[1])
 Punt("illegal (null) argument.");
@@ -683,6 +684,7 @@ rearg:
 goto rearg;
 			Lst_Append(create, bmake_strdup(argv[1]));
 		}
+	}
 
 	return;
 noarg:

Index: src/usr.bin/make/nonints.h
diff -u src/usr.bin/make/nonints.h:1.136 src/usr.bin/make/nonints.h:1.137
--- src/usr.bin/make/nonints.h:1.136	Sun Oct  4 14:40:13 2020
+++ src/usr.bin/make/nonints.h	Sun Oct  4 19:36:32 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nonints.h,v 1.136 2020/10/04 14:40:13 rillig Exp $	*/
+/*	$NetBSD: nonints.h,v 1.137 2020/10/04 19:36:32 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -120,9 +120,26 @@ Boolean getBoolean(const char *, Boolean
 char *cached_realpath(const char *, char *);
 
 /* parse.c */
+
+typedef enum VarAssignOp {
+VAR_NORMAL,			/* = */
+VAR_SUBST,			/* := */
+VAR_SHELL,			/* != or :sh= */
+VAR_APPEND,			/* += */
+VAR_DEFAULT			/* ?= */
+} VarAssignOp;
+
+typedef struct VarAssign {
+const char *name;		/* unexpanded */
+const char *nameEndDraft;	/* before operator adjustment */
+const char *eq;		/* the '=' of the assignment operator */
+VarAssignOp op;
+const char *value;		/* unexpanded */
+} VarAssign;
+
 void Parse_Error(int, const char *, ...) MAKE_ATTR_PRINTFLIKE(2, 3);
-Boolean Parse_IsVar(const char *);
-void Parse_DoVar(const char *, GNode *);
+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_Init(void);

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.355 src/usr.bin/make/parse.c:1.356
--- src/usr.bin/make/parse.c:1.355	Sun Oct  4 19:21:13 2020
+++ src/usr.bin/make/parse.c	Sun Oct  4 19:36:32 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.355 2020/10/04 19:21:13 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.356 2020/10/04 19:36:32 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.355 2020/10/04 19:21:13 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.356 2020/10/04 19:36:32 rillig Exp $");
 
 /* types and constants */
 
@@ -204,14 +204,6 @@ typedef enum {
 Attribute		/* Generic attribute */
 } ParseSpecial;
 
-typedef enum VarAssignOp {
-VAR_NORMAL,			/* = */
-VAR_SUBST,			/* := */
-VAR_SHELL,			/* != or :sh= */
-VAR_APPEND,			/* += */
-VAR_DEFAULT			/* ?= */
-} VarAssignOp;
-
 /* result data */
 
 /*
@@ -1672,15 +1664,15 @@ out:
 	Lst_Free(curTargs);
 }
 
-/* See if the given string is a variable assignment, consisting of a
- * single-word variable name, optional whitespace, an assignment operator,
- * optional whitespace and the variable value.
+/* Parse a variable assignment, consisting of a single-word variable name,
+ * optional whitespace, an assignment operator, optional whitespace and the
+ * variable value.
  *
  * Used for both lines in a file and command line arguments. */
 Boolean
-Parse_IsVar(const char *p)
+Parse_IsVar(const char *p, VarAssign *out_var)
 {
-Boolean wasSpace = FALSE;	/* set TRUE if found a space */
+const char *firstSpace = NULL;
 char ch;
 int level = 0;
 
@@ -1688,6 +1680,8 @@ Parse_IsVar(const 

CVS commit: src/games/factor

2020-10-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Oct  4 19:32:15 UTC 2020

Modified Files:
src/games/factor: factor.c

Log Message:
- Accept octal input.
- Don't play with the original string so we can print it.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/games/factor/factor.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/factor/factor.c
diff -u src/games/factor/factor.c:1.30 src/games/factor/factor.c:1.31
--- src/games/factor/factor.c:1.30	Sat Oct  3 18:27:00 2020
+++ src/games/factor/factor.c	Sun Oct  4 15:32:15 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: factor.c,v 1.30 2020/10/03 22:27:00 christos Exp $	*/
+/*	$NetBSD: factor.c,v 1.31 2020/10/04 19:32:15 christos Exp $	*/
 /*
  * Copyright (c) 1989, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -41,7 +41,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 19
 __SCCSID("@(#)factor.c	8.4 (Berkeley) 5/4/95");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: factor.c,v 1.30 2020/10/03 22:27:00 christos Exp $");
+__RCSID("$NetBSD: factor.c,v 1.31 2020/10/04 19:32:15 christos Exp $");
 #endif
 #ifdef __FBSDID
 __FBSDID("$FreeBSD: head/usr.bin/factor/factor.c 35 2020-01-12 20:25:11Z gad $");
@@ -424,9 +424,10 @@ convert_str2bn(BIGNUM **val, char *p)
 	if (*p == '-')
 		errx(1, "negative numbers aren't permitted.");
 	if (*p == '0') {
-		p++;
-		if (*p == 'x' || *p == 'X')
-			n = BN_hex2bn(val, ++p);
+		if (p[1] == 'x' || p[1] == 'X')
+			n = BN_hex2bn(val, p + 2);
+		else
+			n = BN_oct2bn(val, p + 1);
 	} else {
 		n = is_hex_str(p) ? BN_hex2bn(val, p) : BN_dec2bn(val, p);
 	}



CVS commit: src/crypto/external/bsd/openssl

2020-10-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Oct  4 19:32:48 UTC 2020

Modified Files:
src/crypto/external/bsd/openssl/dist/crypto/bn: bn_print.c
src/crypto/external/bsd/openssl/dist/include/openssl: bn.h
src/crypto/external/bsd/openssl/lib/libcrypto: crypto.map

Log Message:
Add BN_oct2bn(3) for factor(6)


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.10 -r1.2 \
src/crypto/external/bsd/openssl/dist/crypto/bn/bn_print.c
cvs rdiff -u -r1.1.1.3 -r1.2 \
src/crypto/external/bsd/openssl/dist/include/openssl/bn.h
cvs rdiff -u -r1.8 -r1.9 \
src/crypto/external/bsd/openssl/lib/libcrypto/crypto.map

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

Modified files:

Index: src/crypto/external/bsd/openssl/dist/crypto/bn/bn_print.c
diff -u src/crypto/external/bsd/openssl/dist/crypto/bn/bn_print.c:1.1.1.10 src/crypto/external/bsd/openssl/dist/crypto/bn/bn_print.c:1.2
--- src/crypto/external/bsd/openssl/dist/crypto/bn/bn_print.c:1.1.1.10	Sat Mar 21 20:49:05 2020
+++ src/crypto/external/bsd/openssl/dist/crypto/bn/bn_print.c	Sun Oct  4 15:32:48 2020
@@ -266,6 +266,87 @@ int BN_dec2bn(BIGNUM **bn, const char *a
 return 0;
 }
 
+int BN_oct2bn(BIGNUM **bn, const char *a)
+{
+BIGNUM *ret = NULL;
+BN_ULONG l = 0;
+int neg = 0, h, m, i, j, b, k, c, r;
+int num;
+
+if (a == NULL || *a == '\0')
+return 0;
+
+if (*a == '-') {
+neg = 1;
+a++;
+}
+
+for (i = 0; i <= INT_MAX / 4 && ossl_isdigit(a[i]) && a[i] < '8'; i++)
+continue;
+
+if (i == 0 || i > INT_MAX / 4)
+goto err;
+
+num = i + neg;
+if (bn == NULL)
+return num;
+
+/* a is the start of the hex digits, and it is 'i' long */
+if (*bn == NULL) {
+if ((ret = BN_new()) == NULL)
+return 0;
+} else {
+ret = *bn;
+BN_zero(ret);
+}
+
+/* i is the number of hex digits */
+if (bn_expand(ret, i * 4) == NULL)
+goto err;
+
+j = i;  /* least significant 'oct' */
+h = 0;
+b = 0;
+#define M (BN_BYTES * 8 / 3)
+while (j > 0) {
+m = (M <= j) ? M : j;
+	while (m > 0) {
+	k = a[j - m] - '0';
+	l = (l << 3) | k;
+	b += 3;
+	m--;
+	}
+j -= M;
+	if (j <= 0) {
+	ret->d[h++] = l;
+	break;
+	}
+	b = BN_BYTES * 8 - b;
+	r = 3 - b;
+	k = a[j--] - '0';
+	l = (l << r) | (k >> b);
+	ret->d[h++] = l;
+	l = k & ((2 << r) - 1);
+	if (j == 0) {
+	ret->d[h++] = l;
+	break;
+	}
+}
+ret->top = h;
+bn_correct_top(ret);
+
+*bn = ret;
+bn_check_top(ret);
+/* Don't set the negative flag if it's zero. */
+if (ret->top != 0)
+ret->neg = neg;
+return num;
+ err:
+if (*bn == NULL)
+BN_free(ret);
+return 0;
+}
+
 int BN_asc2bn(BIGNUM **bn, const char *a)
 {
 const char *p = a;
@@ -273,9 +354,14 @@ int BN_asc2bn(BIGNUM **bn, const char *a
 if (*p == '-')
 p++;
 
-if (p[0] == '0' && (p[1] == 'X' || p[1] == 'x')) {
-if (!BN_hex2bn(bn, p + 2))
-return 0;
+if (p[0] == '0') {
+	if (p[1] == 'X' || p[1] == 'x') {
+	if (!BN_hex2bn(bn, p + 2))
+		return 0;
+	} else {
+	if (!BN_oct2bn(bn, p + 1))
+		return 0;
+	}
 } else {
 if (!BN_dec2bn(bn, p))
 return 0;

Index: src/crypto/external/bsd/openssl/dist/include/openssl/bn.h
diff -u src/crypto/external/bsd/openssl/dist/include/openssl/bn.h:1.1.1.3 src/crypto/external/bsd/openssl/dist/include/openssl/bn.h:1.2
--- src/crypto/external/bsd/openssl/dist/include/openssl/bn.h:1.1.1.3	Sun Sep 23 09:17:50 2018
+++ src/crypto/external/bsd/openssl/dist/include/openssl/bn.h	Sun Oct  4 15:32:48 2020
@@ -310,6 +310,7 @@ char *BN_bn2hex(const BIGNUM *a);
 char *BN_bn2dec(const BIGNUM *a);
 int BN_hex2bn(BIGNUM **a, const char *str);
 int BN_dec2bn(BIGNUM **a, const char *str);
+int BN_oct2bn(BIGNUM **a, const char *str);
 int BN_asc2bn(BIGNUM **a, const char *str);
 int BN_gcd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
 int BN_kronecker(const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); /* returns

Index: src/crypto/external/bsd/openssl/lib/libcrypto/crypto.map
diff -u src/crypto/external/bsd/openssl/lib/libcrypto/crypto.map:1.8 src/crypto/external/bsd/openssl/lib/libcrypto/crypto.map:1.9
--- src/crypto/external/bsd/openssl/lib/libcrypto/crypto.map:1.8	Sat Mar 21 20:53:11 2020
+++ src/crypto/external/bsd/openssl/lib/libcrypto/crypto.map	Sun Oct  4 15:32:48 2020
@@ -552,6 +552,7 @@ OPENSSL_1_1_0 {
 BN_nnmod;
 BN_num_bits;
 BN_num_bits_word;
+	BN_oct2bn;
 BN_options;
 BN_print;
 BN_print_fp;



CVS commit: src/usr.bin/make

2020-10-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct  4 19:21:13 UTC 2020

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

Log Message:
make(1): rename parameter of Parse_IsVar


To generate a diff of this commit:
cvs rdiff -u -r1.354 -r1.355 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.354 src/usr.bin/make/parse.c:1.355
--- src/usr.bin/make/parse.c:1.354	Sun Oct  4 16:43:22 2020
+++ src/usr.bin/make/parse.c	Sun Oct  4 19:21:13 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.354 2020/10/04 16:43:22 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.355 2020/10/04 19:21:13 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.354 2020/10/04 16:43:22 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.355 2020/10/04 19:21:13 rillig Exp $");
 
 /* types and constants */
 
@@ -1672,38 +1672,24 @@ out:
 	Lst_Free(curTargs);
 }
 
-/*-
- *-
- * Parse_IsVar  --
- *	Return TRUE if the passed line is a variable assignment. A variable
- *	assignment consists of a single word followed by optional whitespace
- *	followed by either a += or an = operator.
- *	This function is used both by the Parse_File function and main when
- *	parsing the command-line arguments.
- *
- * Input:
- *	line		the line to check
+/* See if the given string is a variable assignment, consisting of a
+ * single-word variable name, optional whitespace, an assignment operator,
+ * optional whitespace and the variable value.
  *
- * Results:
- *	TRUE if it is. FALSE if it ain't
- *
- * Side Effects:
- *	none
- *-
- */
+ * Used for both lines in a file and command line arguments. */
 Boolean
-Parse_IsVar(const char *line)
+Parse_IsVar(const char *p)
 {
 Boolean wasSpace = FALSE;	/* set TRUE if found a space */
 char ch;
 int level = 0;
 
 /* Skip to variable name */
-while (*line == ' ' || *line == '\t')
-	line++;
+while (*p == ' ' || *p == '\t')
+	p++;
 
 /* Scan for one of the assignment operators outside a variable expansion */
-while ((ch = *line++) != 0) {
+while ((ch = *p++) != 0) {
 	if (ch == '(' || ch == '{') {
 	level++;
 	continue;
@@ -1715,18 +1701,18 @@ Parse_IsVar(const char *line)
 	if (level != 0)
 	continue;
 	while (ch == ' ' || ch == '\t') {
-	ch = *line++;
+	ch = *p++;
 	wasSpace = TRUE;
 	}
 #ifdef SUNSHCMD
-	if (ch == ':' && strncmp(line, "sh", 2) == 0) {
-	line += 2;
+	if (ch == ':' && strncmp(p, "sh", 2) == 0) {
+	p += 2;
 	continue;
 	}
 #endif
 	if (ch == '=')
 	return TRUE;
-	if (*line == '=' && (ch == '+' || ch == ':' || ch == '?' || ch == '!'))
+	if (*p == '=' && (ch == '+' || ch == ':' || ch == '?' || ch == '!'))
 	return TRUE;
 	if (wasSpace)
 	return FALSE;



CVS commit: src/usr.sbin/sysinst

2020-10-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct  4 19:05:47 UTC 2020

Modified Files:
src/usr.sbin/sysinst: bsddisklabel.c

Log Message:
When merging existing partitions with desired target system layout
information, only force the "mount" flag if the existing partitions
has a valid mount point.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/usr.sbin/sysinst/bsddisklabel.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/sysinst/bsddisklabel.c
diff -u src/usr.sbin/sysinst/bsddisklabel.c:1.47 src/usr.sbin/sysinst/bsddisklabel.c:1.48
--- src/usr.sbin/sysinst/bsddisklabel.c:1.47	Sun Oct  4 16:09:12 2020
+++ src/usr.sbin/sysinst/bsddisklabel.c	Sun Oct  4 19:05:47 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: bsddisklabel.c,v 1.47 2020/10/04 16:09:12 martin Exp $	*/
+/*	$NetBSD: bsddisklabel.c,v 1.48 2020/10/04 19:05:47 martin Exp $	*/
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -869,7 +869,9 @@ merge_part_with_wanted(struct disk_parti
 		wanted->infos[i].cur_start = info->start;
 		wanted->infos[i].flags &= ~PUIFLAG_EXTEND;
 		if (wanted->infos[i].fs_type != FS_UNUSED &&
-		wanted->infos[i].type != PT_swap)
+		wanted->infos[i].type != PT_swap &&
+		info->last_mounted != NULL &&
+		info->last_mounted[0] != 0)
 			wanted->infos[i].instflags |= PUIINST_MOUNT;
 		if (is_outer)
 			wanted->infos[i].flags |= PUIFLG_IS_OUTER;



CVS commit: src/share/misc

2020-10-04 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sun Oct  4 19:04:48 UTC 2020

Modified Files:
src/share/misc: acronyms acronyms.comp

Log Message:
various vidya, also md = minidisc, dc = data center


To generate a diff of this commit:
cvs rdiff -u -r1.306 -r1.307 src/share/misc/acronyms
cvs rdiff -u -r1.312 -r1.313 src/share/misc/acronyms.comp

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

Modified files:

Index: src/share/misc/acronyms
diff -u src/share/misc/acronyms:1.306 src/share/misc/acronyms:1.307
--- src/share/misc/acronyms:1.306	Sat Aug 29 18:54:33 2020
+++ src/share/misc/acronyms	Sun Oct  4 19:04:48 2020
@@ -1,4 +1,4 @@
-$NetBSD: acronyms,v 1.306 2020/08/29 18:54:33 christos Exp $
+$NetBSD: acronyms,v 1.307 2020/10/04 19:04:48 nia Exp $
 10Q	thank you
 10X	thanks
 1337	elite ("leet")
@@ -118,6 +118,7 @@ D/B/A	doing business as
 D/L	download
 DBA	doing business as
 DBEYR	don't believe everything you read
+DC	Dreamcast
 DIAFYO	did I ask for your opinion?
 DIY	do it yourself
 DKDC	don't know, don't care
@@ -132,6 +133,7 @@ DNFT	do not feed troll
 DOA	dead on arrival
 DOTADIW	do one thing and do it well
 DRY	don't repeat yourself
+DS	Dual Screen
 DSTM	don't shoot the messenger
 DTRT	do the right thing
 DTWT	do the wrong thing
@@ -192,7 +194,11 @@ G2K	good to know
 GA	go ahead
 GAC	get a clue
 GAL	get a life
+GB	Game Boy
+GBA	Game Boy Advance
+GBC	Game Boy Color
 GBTW	get back to work
+GC	GameCube
 GCD	greatest common divisor
 GCHQ	Government Communications Headquarters (UK)
 GDPR	General Data Protection Regulation
@@ -351,6 +357,7 @@ M	management & operations
 M8	mate
 MAD	mutually assured destruction
 MBA	master of business administration
+MD	Mega Drive
 MDMA	methylenedioxy methamphetamine
 MFW	my face when
 MIA	missing in action
@@ -371,8 +378,11 @@ NB	nota bene
 NBD	no big deal
 NE1	anyone
 NEDM	not even Doom music
+NES	Nintendo Entertainment System
 NFA	no flaming allowed
 NFC	no functional change
+NGP	Neo Geo Pocket
+NGP	Neo Geo Pocket Color
 NIFOC	naked in front of computer
 NIH	not invented here
 NIMBY	not in my backyard
@@ -428,6 +438,7 @@ OWTTE	or words to that effect
 PC	player character
 PC	politically correct
 PCB	polychlorinated biphenyl(s)
+PCE 	PC Engine
 PD	police department
 PDA	public display of affection
 PDQ	pretty darn quick
@@ -460,6 +471,7 @@ PPS	pulse per second (signal)
 PR	public relations
 PSA 	prostate-specific antigen
 PSA 	public service announcement
+PSX	PlayStation
 PTA	parent-teacher association
 PTO	{paid,personal} time off
 PTO	parent-teacher organization
@@ -510,7 +522,9 @@ SMAP	Soil Moisture Active Passive
 SMH	shaking my head
 SMLSFB	so many losers, so few bullets
 SMOP	simple matter of programming
+SMS	Sega Master System
 SNERT	snot-nosed egotistical rude teenager
+SNES	Super Nintendo Entertainment System
 SNMP	sorry, not my problem
 SO	significant other
 SOB	son of [a] bitch

Index: src/share/misc/acronyms.comp
diff -u src/share/misc/acronyms.comp:1.312 src/share/misc/acronyms.comp:1.313
--- src/share/misc/acronyms.comp:1.312	Sat Sep 19 01:43:20 2020
+++ src/share/misc/acronyms.comp	Sun Oct  4 19:04:48 2020
@@ -1,4 +1,4 @@
-$NetBSD: acronyms.comp,v 1.312 2020/09/19 01:43:20 ginsbach Exp $
+$NetBSD: acronyms.comp,v 1.313 2020/10/04 19:04:48 nia Exp $
 3WHS	three-way handshake
 8VSB	8-state vestigial side band modulation
 AA	anti-aliasing
@@ -359,6 +359,7 @@ DBC	design by contract
 DBL	dynamic buffer limiting
 DBMS	database management system
 DBS	database server
+DC	data center
 DC	direct current
 DCC	Direct Client-to-Client
 DCC	direct cable connect
@@ -935,6 +936,7 @@ MCLAG	multi-chassis link aggregation gro
 MCM	multi-chip module
 MCQ	memory controlled queue
 MD	machine-dependent
+MD	MiniDisc
 MD-SAL	model-driven service abstraction layer
 MDA	mail delivery agent
 MDA	Monochrome Display Adapter



CVS commit: [netbsd-9] src/doc

2020-10-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct  4 18:24:08 UTC 2020

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

Log Message:
Tickets #1095 and #1096


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.117 -r1.1.2.118 src/doc/CHANGES-9.1

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.1
diff -u src/doc/CHANGES-9.1:1.1.2.117 src/doc/CHANGES-9.1:1.1.2.118
--- src/doc/CHANGES-9.1:1.1.2.117	Sun Sep 27 10:31:09 2020
+++ src/doc/CHANGES-9.1	Sun Oct  4 18:24:07 2020
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-9.1,v 1.1.2.117 2020/09/27 10:31:09 martin Exp $
+# $NetBSD: CHANGES-9.1,v 1.1.2.118 2020/10/04 18:24:07 martin Exp $
 
 A complete list of changes from the NetBSD 9.0 release to the NetBSD 9.1
 release:
@@ -5035,3 +5035,16 @@ sys/dev/ic/nvme.c1.50
 	with multiple (partialy unused) name spaces.
 	[kardel, ticket #1094]
 
+sys/uvm/uvm_amap.c1.124,1.125 (patch)
+sys/uvm/uvm_io.c1.29 (patch)
+
+	Effectively disable the AMAP_REFALL flag because it is unsafe.
+	[chs, ticket #1095]
+
+sys/dev/fdt/dw_apb_uart.c			1.8
+
+	The device is capable to recognize break signal, reset cnmagic
+	from + to default.
+	[rin, ticket #1096]
+
+



CVS commit: [netbsd-9] src/sys/dev/fdt

2020-10-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct  4 18:22:00 UTC 2020

Modified Files:
src/sys/dev/fdt [netbsd-9]: dw_apb_uart.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #1096):

sys/dev/fdt/dw_apb_uart.c: revision 1.8

Revert rev 1.5:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/fdt/dw_apb_uart.c#rev1.5

The device is capable to recognize break signal actually.
Reset cnmagic from + to default.

Pointed out by jakllsch. Thanks!


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.5.2.1 src/sys/dev/fdt/dw_apb_uart.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/fdt/dw_apb_uart.c
diff -u src/sys/dev/fdt/dw_apb_uart.c:1.5 src/sys/dev/fdt/dw_apb_uart.c:1.5.2.1
--- src/sys/dev/fdt/dw_apb_uart.c:1.5	Sun Jul 21 15:57:23 2019
+++ src/sys/dev/fdt/dw_apb_uart.c	Sun Oct  4 18:22:00 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: dw_apb_uart.c,v 1.5 2019/07/21 15:57:23 rin Exp $ */
+/* $NetBSD: dw_apb_uart.c,v 1.5.2.1 2020/10/04 18:22:00 martin Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: dw_apb_uart.c,v 1.5 2019/07/21 15:57:23 rin Exp $");
+__KERNEL_RCSID(1, "$NetBSD: dw_apb_uart.c,v 1.5.2.1 2020/10/04 18:22:00 martin Exp $");
 
 #include 
 #include 
@@ -182,8 +182,6 @@ dw_apb_uart_console_consinit(struct fdt_
 
 	if (comcnattach(bst, addr, speed, uart_freq, COM_TYPE_DW_APB, flags))
 		panic("Cannot initialize dw-apb-uart console");
-
-	cn_set_magic("+");
 }
 
 static const struct fdt_console dw_apb_uart_console = {



CVS commit: src/usr.bin/make

2020-10-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct  4 18:16:09 UTC 2020

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

Log Message:
make(1): merge duplicate code in Hash_FindEntry and Hash_CreateEntry


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/usr.bin/make/hash.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/hash.c
diff -u src/usr.bin/make/hash.c:1.40 src/usr.bin/make/hash.c:1.41
--- src/usr.bin/make/hash.c:1.40	Sun Oct  4 17:50:41 2020
+++ src/usr.bin/make/hash.c	Sun Oct  4 18:16:09 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: hash.c,v 1.40 2020/10/04 17:50:41 rillig Exp $	*/
+/*	$NetBSD: hash.c,v 1.41 2020/10/04 18:16:09 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -79,7 +79,7 @@
 #include "make.h"
 
 /*	"@(#)hash.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: hash.c,v 1.40 2020/10/04 17:50:41 rillig Exp $");
+MAKE_RCSID("$NetBSD: hash.c,v 1.41 2020/10/04 18:16:09 rillig Exp $");
 
 /*
  * The ratio of # entries to # buckets at which we rebuild the table to
@@ -100,6 +100,28 @@ hash(const char *key, size_t *out_keylen
 	return h;
 }
 
+static Hash_Entry *
+HashTable_Find(Hash_Table *t, unsigned int h, const char *key)
+{
+	Hash_Entry *e;
+	int chainlen = 0;
+
+#ifdef DEBUG_HASH_LOOKUP
+	DEBUG4(HASH, "%s: %p h=%x key=%s\n", __func__, t, h, key);
+#endif
+
+	for (e = t->buckets[h & t->bucketsMask]; e != NULL; e = e->next) {
+		chainlen++;
+		if (e->namehash == h && strcmp(e->name, key) == 0)
+			break;
+	}
+
+	if (chainlen > t->maxchain)
+		t->maxchain = chainlen;
+
+	return e;
+}
+
 /* Sets up the hash table. */
 void
 Hash_InitTable(Hash_Table *t)
@@ -152,23 +174,8 @@ Hash_DeleteTable(Hash_Table *t)
 Hash_Entry *
 Hash_FindEntry(Hash_Table *t, const char *key)
 {
-	Hash_Entry *e;
-	unsigned h;
-	int chainlen;
-
-	h = hash(key, NULL);
-	chainlen = 0;
-#ifdef DEBUG_HASH_LOOKUP
-	DEBUG4(HASH, "%s: %p h=%x key=%s\n", __func__, t, h, key);
-#endif
-	for (e = t->buckets[h & t->bucketsMask]; e != NULL; e = e->next) {
-		chainlen++;
-		if (e->namehash == h && strcmp(e->name, key) == 0)
-			break;
-	}
-	if (chainlen > t->maxchain)
-		t->maxchain = chainlen;
-	return e;
+	unsigned int h = hash(key, NULL);
+	return HashTable_Find(t, h, key);
 }
 
 void *
@@ -225,30 +232,15 @@ Hash_CreateEntry(Hash_Table *t, const ch
 	Hash_Entry *e;
 	unsigned h;
 	size_t keylen;
-	int chainlen;
 	struct Hash_Entry **hp;
 
-	/*
-	 * Hash the key.  As a side effect, save the length (strlen) of the
-	 * key in case we need to create the entry.
-	 */
 	h = hash(key, );
-	chainlen = 0;
-#ifdef DEBUG_HASH_LOOKUP
-	DEBUG4(HASH, "%s: %p h=%x key=%s\n", __func__, t, h, key);
-#endif
-	for (e = t->buckets[h & t->bucketsMask]; e != NULL; e = e->next) {
-		chainlen++;
-		if (e->namehash == h && strcmp(e->name, key) == 0) {
-			if (newPtr != NULL)
-*newPtr = FALSE;
-			break;
-		}
-	}
-	if (chainlen > t->maxchain)
-		t->maxchain = chainlen;
-	if (e)
+	e = HashTable_Find(t, h, key);
+	if (e) {
+		if (newPtr != NULL)
+			*newPtr = FALSE;
 		return e;
+	}
 
 	/*
 	 * The desired entry isn't there.  Before allocating a new entry,



CVS commit: [netbsd-9] src/sys/uvm

2020-10-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct  4 18:14:13 UTC 2020

Modified Files:
src/sys/uvm [netbsd-9]: uvm_amap.c uvm_io.c

Log Message:
Pull up following revision(s) (requested by chs in ticket #1095):

sys/uvm/uvm_amap.c: revision 1.124 (via patch)
sys/uvm/uvm_amap.c: revision 1.125 (via patch)
sys/uvm/uvm_io.c: revision 1.29 (via patch)

Effectively disable the AMAP_REFALL flag because it is unsafe.

This flag tells the amap code that it does not need to allocate ppref
as part of adding or removing a reference, but that is only correct
if the range of the reference being added or removed is the same
as the range of all other references to the amap, and the point of
this flag is exactly to try to optimize the case where the range is
different and thus this flag would not be correct to use.
Fixes PR 55366.

The previous fix for PR 55366 in uvm_amap.c 1.124 was incomplete:
 - amap_adjref_anons() must also ignore AMAP_REFALL when updating
   the ppref, not just when deciding whether or not to initialize ppref.
 - UVM_EXTRACT_QREF relies on AMAP_REFALL to work properly,
   and since we can't use AMAP_REFALL then we can't use QREF either.


To generate a diff of this commit:
cvs rdiff -u -r1.109.4.1 -r1.109.4.2 src/sys/uvm/uvm_amap.c
cvs rdiff -u -r1.28 -r1.28.22.1 src/sys/uvm/uvm_io.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/uvm/uvm_amap.c
diff -u src/sys/uvm/uvm_amap.c:1.109.4.1 src/sys/uvm/uvm_amap.c:1.109.4.2
--- src/sys/uvm/uvm_amap.c:1.109.4.1	Wed Aug 19 18:36:59 2020
+++ src/sys/uvm/uvm_amap.c	Sun Oct  4 18:14:13 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_amap.c,v 1.109.4.1 2020/08/19 18:36:59 martin Exp $	*/
+/*	$NetBSD: uvm_amap.c,v 1.109.4.2 2020/10/04 18:14:13 martin Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_amap.c,v 1.109.4.1 2020/08/19 18:36:59 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_amap.c,v 1.109.4.2 2020/10/04 18:14:13 martin Exp $");
 
 #include "opt_uvmhist.h"
 
@@ -1588,7 +1588,7 @@ amap_adjref_anons(struct vm_amap *amap, 
 	 * so that the ppref values match the current amap refcount.
 	 */
 
-	if (amap->am_ppref == NULL && !all && len != amap->am_nslot) {
+	if (amap->am_ppref == NULL) {
 		amap_pp_establish(amap, offset);
 	}
 #endif
@@ -1597,11 +1597,7 @@ amap_adjref_anons(struct vm_amap *amap, 
 
 #ifdef UVM_AMAP_PPREF
 	if (amap->am_ppref && amap->am_ppref != PPREF_NONE) {
-		if (all) {
-			amap_pp_adjref(amap, 0, amap->am_nslot, refv, );
-		} else {
-			amap_pp_adjref(amap, offset, len, refv, );
-		}
+		amap_pp_adjref(amap, offset, len, refv, );
 	}
 #endif
 	uvm_anon_freelst(amap, tofree);

Index: src/sys/uvm/uvm_io.c
diff -u src/sys/uvm/uvm_io.c:1.28 src/sys/uvm/uvm_io.c:1.28.22.1
--- src/sys/uvm/uvm_io.c:1.28	Wed May 25 17:43:58 2016
+++ src/sys/uvm/uvm_io.c	Sun Oct  4 18:14:13 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_io.c,v 1.28 2016/05/25 17:43:58 christos Exp $	*/
+/*	$NetBSD: uvm_io.c,v 1.28.22.1 2020/10/04 18:14:13 martin Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_io.c,v 1.28 2016/05/25 17:43:58 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_io.c,v 1.28.22.1 2020/10/04 18:14:13 martin Exp $");
 
 #include 
 #include 
@@ -87,6 +87,10 @@ uvm_io(struct vm_map *map, struct uio *u
 	error = 0;
 
 	flags |= UVM_EXTRACT_QREF | UVM_EXTRACT_CONTIG | UVM_EXTRACT_FIXPROT;
+
+	/* XXX cannot use QREF with without AMAP_REFALL, and REFALL is unsafe */
+	flags &= ~UVM_EXTRACT_QREF;
+
 	/*
 	 * step 1: main loop...  while we've got data to move
 	 */



CVS commit: src/usr.bin/make

2020-10-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct  4 17:50:41 UTC 2020

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

Log Message:
make(1): avoid forward declaration for RebuildTable


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/usr.bin/make/hash.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/hash.c
diff -u src/usr.bin/make/hash.c:1.39 src/usr.bin/make/hash.c:1.40
--- src/usr.bin/make/hash.c:1.39	Sun Oct  4 17:21:28 2020
+++ src/usr.bin/make/hash.c	Sun Oct  4 17:50:41 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: hash.c,v 1.39 2020/10/04 17:21:28 rillig Exp $	*/
+/*	$NetBSD: hash.c,v 1.40 2020/10/04 17:50:41 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -79,20 +79,12 @@
 #include "make.h"
 
 /*	"@(#)hash.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: hash.c,v 1.39 2020/10/04 17:21:28 rillig Exp $");
+MAKE_RCSID("$NetBSD: hash.c,v 1.40 2020/10/04 17:50:41 rillig Exp $");
 
 /*
- * Forward references to local procedures that are used before they're
- * defined:
+ * The ratio of # entries to # buckets at which we rebuild the table to
+ * make it larger.
  */
-
-static void RebuildTable(Hash_Table *);
-
-/*
- * The following defines the ratio of # entries to # buckets
- * at which we rebuild the table to make it larger.
- */
-
 #define rebuildLimit 3
 
 /* This hash function matches Gosling's emacs. */
@@ -182,8 +174,40 @@ Hash_FindEntry(Hash_Table *t, const char
 void *
 Hash_FindValue(Hash_Table *t, const char *key)
 {
-Hash_Entry *he = Hash_FindEntry(t, key);
-return he != NULL ? he->value : NULL;
+	Hash_Entry *he = Hash_FindEntry(t, key);
+	return he != NULL ? he->value : NULL;
+}
+
+/* Makes a new hash table that is larger than the old one. The entire hash
+ * table is moved, so any bucket numbers from the old table become invalid. */
+static void
+RebuildTable(Hash_Table *t)
+{
+	Hash_Entry *e, *next = NULL, **hp, **xp;
+	int i, mask;
+	Hash_Entry **oldhp;
+	int oldsize;
+
+	oldhp = t->buckets;
+	oldsize = i = t->bucketsSize;
+	i <<= 1;
+	t->bucketsSize = i;
+	t->bucketsMask = mask = i - 1;
+	t->buckets = hp = bmake_malloc(sizeof(*hp) * i);
+	while (--i >= 0)
+		*hp++ = NULL;
+	for (hp = oldhp, i = oldsize; --i >= 0;) {
+		for (e = *hp++; e != NULL; e = next) {
+			next = e->next;
+			xp = >buckets[e->namehash & mask];
+			e->next = *xp;
+			*xp = e;
+		}
+	}
+	free(oldhp);
+	DEBUG5(HASH, "%s: %p size=%d entries=%d maxchain=%d\n",
+	   __func__, t, t->bucketsSize, t->numEntries, t->maxchain);
+	t->maxchain = 0;
 }
 
 /* Searches the hash table for an entry corresponding to the key.
@@ -318,38 +342,6 @@ Hash_EnumNext(Hash_Search *searchPtr)
 	return e;
 }
 
-/* Makes a new hash table that is larger than the old one. The entire hash
- * table is moved, so any bucket numbers from the old table become invalid. */
-static void
-RebuildTable(Hash_Table *t)
-{
-	Hash_Entry *e, *next = NULL, **hp, **xp;
-	int i, mask;
-	Hash_Entry **oldhp;
-	int oldsize;
-
-	oldhp = t->buckets;
-	oldsize = i = t->bucketsSize;
-	i <<= 1;
-	t->bucketsSize = i;
-	t->bucketsMask = mask = i - 1;
-	t->buckets = hp = bmake_malloc(sizeof(*hp) * i);
-	while (--i >= 0)
-		*hp++ = NULL;
-	for (hp = oldhp, i = oldsize; --i >= 0;) {
-		for (e = *hp++; e != NULL; e = next) {
-			next = e->next;
-			xp = >buckets[e->namehash & mask];
-			e->next = *xp;
-			*xp = e;
-		}
-	}
-	free(oldhp);
-	DEBUG5(HASH, "%s: %p size=%d entries=%d maxchain=%d\n",
-	   __func__, t, t->bucketsSize, t->numEntries, t->maxchain);
-	t->maxchain = 0;
-}
-
 void
 Hash_ForEach(Hash_Table *t, void (*action)(void *, void *), void *data)
 {
@@ -365,6 +357,6 @@ Hash_ForEach(Hash_Table *t, void (*actio
 void
 Hash_DebugStats(Hash_Table *t, const char *name)
 {
-DEBUG4(HASH, "Hash_Table %s: size=%d numEntries=%d maxchain=%d\n",
-	   name, t->bucketsSize, t->numEntries, t->maxchain);
+	DEBUG4(HASH, "Hash_Table %s: size=%d numEntries=%d maxchain=%d\n",
+	   name, t->bucketsSize, t->numEntries, t->maxchain);
 }



CVS commit: src/usr.bin/make

2020-10-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct  4 17:21:28 UTC 2020

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

Log Message:
make(1): remove dead code from Hash_FindEntry

All callers pass a properly initialized table.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/usr.bin/make/hash.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/hash.c
diff -u src/usr.bin/make/hash.c:1.38 src/usr.bin/make/hash.c:1.39
--- src/usr.bin/make/hash.c:1.38	Sat Oct  3 23:16:28 2020
+++ src/usr.bin/make/hash.c	Sun Oct  4 17:21:28 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: hash.c,v 1.38 2020/10/03 23:16:28 rillig Exp $	*/
+/*	$NetBSD: hash.c,v 1.39 2020/10/04 17:21:28 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -79,7 +79,7 @@
 #include "make.h"
 
 /*	"@(#)hash.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: hash.c,v 1.38 2020/10/03 23:16:28 rillig Exp $");
+MAKE_RCSID("$NetBSD: hash.c,v 1.39 2020/10/04 17:21:28 rillig Exp $");
 
 /*
  * Forward references to local procedures that are used before they're
@@ -164,9 +164,6 @@ Hash_FindEntry(Hash_Table *t, const char
 	unsigned h;
 	int chainlen;
 
-	if (t == NULL || t->buckets == NULL)
-	return NULL;
-
 	h = hash(key, NULL);
 	chainlen = 0;
 #ifdef DEBUG_HASH_LOOKUP



CVS commit: src/usr.bin/make

2020-10-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct  4 16:50:37 UTC 2020

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

Log Message:
make(1): remove dead code from JobOutput


To generate a diff of this commit:
cvs rdiff -u -r1.257 -r1.258 src/usr.bin/make/job.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/job.c
diff -u src/usr.bin/make/job.c:1.257 src/usr.bin/make/job.c:1.258
--- src/usr.bin/make/job.c:1.257	Sat Oct  3 21:19:54 2020
+++ src/usr.bin/make/job.c	Sun Oct  4 16:50:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.257 2020/10/03 21:19:54 rillig Exp $	*/
+/*	$NetBSD: job.c,v 1.258 2020/10/04 16:50:37 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) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: job.c,v 1.257 2020/10/03 21:19:54 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.258 2020/10/04 16:50:37 rillig Exp $");
 
 # define STATIC static
 
@@ -1575,7 +1575,7 @@ JobStart(GNode *gn, int flags)
 }
 
 static char *
-JobOutput(Job *job, char *cp, char *endp, int msg)
+JobOutput(Job *job, char *cp, char *endp)
 {
 char *ecp;
 
@@ -1583,10 +1583,6 @@ JobOutput(Job *job, char *cp, char *endp
 	while ((ecp = strstr(cp, commandShell->noPrint)) != NULL) {
 	if (cp != ecp) {
 		*ecp = '\0';
-		if (!beSilent && msg && job->node != lastNode) {
-		MESSAGE(stdout, job->node);
-		lastNode = job->node;
-		}
 		/*
 		 * The only way there wouldn't be a newline after
 		 * this line is if it were the last in the buffer.
@@ -1735,7 +1731,7 @@ end_loop:
 	if (i >= job->curPos) {
 	char *cp;
 
-	cp = JobOutput(job, job->outBuf, >outBuf[i], FALSE);
+	cp = JobOutput(job, job->outBuf, >outBuf[i]);
 
 	/*
 	 * There's still more in that thar buffer. This time, though,



CVS commit: src/usr.bin/make

2020-10-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct  4 16:43:22 UTC 2020

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

Log Message:
make(1): split Parse_DoVar into manageable pieces

This makes it easier to eliminate duplicate code, for example in
Parse_IsVar and Parse_DoVar.


To generate a diff of this commit:
cvs rdiff -u -r1.353 -r1.354 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.353 src/usr.bin/make/parse.c:1.354
--- src/usr.bin/make/parse.c:1.353	Sun Oct  4 14:40:13 2020
+++ src/usr.bin/make/parse.c	Sun Oct  4 16:43:22 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.353 2020/10/04 14:40:13 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.354 2020/10/04 16:43:22 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.353 2020/10/04 14:40:13 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.354 2020/10/04 16:43:22 rillig Exp $");
 
 /* types and constants */
 
@@ -204,6 +204,14 @@ typedef enum {
 Attribute		/* Generic attribute */
 } ParseSpecial;
 
+typedef enum VarAssignOp {
+VAR_NORMAL,			/* = */
+VAR_SUBST,			/* := */
+VAR_SHELL,			/* != or :sh= */
+VAR_APPEND,			/* += */
+VAR_DEFAULT			/* ?= */
+} VarAssignOp;
+
 /* result data */
 
 /*
@@ -1727,56 +1735,18 @@ Parse_IsVar(const char *line)
 return FALSE;
 }
 
-/* Take the variable assignment in the passed line and execute it.
- *
- * Note: There is a lexical ambiguity with assignment modifier characters
- * in variable names. This routine interprets the character before the =
- * as a modifier. Therefore, an assignment like
- *	C++=/usr/bin/CC
- * is interpreted as "C+ +=" instead of "C++ =".
- *
- * Input:
- *	p		A line guaranteed to be a variable assignment
- *			(see Parse_IsVar).
- *	ctxt		Context in which to do the assignment
- */
-void
-Parse_DoVar(const char *p, GNode *ctxt)
+/*
+* Parse the variable name, up to the assignment operator.
+* XXX Rather than counting () and {} we should look for $ and
+* then expand the variable.
+*/
+static const char *
+ParseVarname(const char **pp)
 {
-enum {
-	VAR_SUBST, VAR_APPEND, VAR_SHELL, VAR_NORMAL
-} type;			/* Type of assignment */
+const char *p = *pp;
+const char *nameEnd = NULL;
 int depth;
-const char *name;
-void *name_freeIt;
-const char *uvalue;		/* unexpanded value */
-const char *avalue;		/* actual value */
-char *evalue = NULL;	/* expanded value */
-
-/* The variable name consists of a single word (that is, no whitespace).
- * It ends at the whitespace after that word (nameEnd).  If there is no
- * whitespace, the name is followed directly by the assignment operator
- * (op).  During parsing, the '+' of the '+=' operator is initially parsed
- * as part of the variable name.  It is later corrected, as is the ':sh'
- * modifier. Of these two (nameEnd and op), the earlier one determines the
- * actual end of the variable name. */
-const char *nameEnd, *op;
-
-/*
- * Skip to variable name
- */
-while (*p == ' ' || *p == '\t')
-	p++;
-
-name = p;
-name_freeIt = NULL;
 
-/*
- * Parse the variable name, up to the assignment operator.
- * XXX Rather than counting () and {} we should look for $ and
- * then expand the variable.
- */
-nameEnd = NULL;
 for (depth = 0; depth > 0 || *p != '='; p++) {
 	if (*p == '(' || *p == '{') {
 	depth++;
@@ -1794,32 +1764,47 @@ Parse_DoVar(const char *p, GNode *ctxt)
 
 if (nameEnd == NULL)
 	nameEnd = p;
+
+*pp = p;
+return nameEnd;
+}
+
+static Boolean
+ParseVarassignOp(const char *p, const char *const nameEnd, const char **out_op,
+		 const char **inout_name, VarAssignOp *out_type,
+		 void **inout_name_freeIt, GNode *ctxt)
+{
+const char *op;
+const char *name = *inout_name;
+void *name_freeIt = *inout_name_freeIt;
+VarAssignOp type;
+
 op = p;			/* points at the '=' */
 
 if (op > name && op[-1] == '+') {
-type = VAR_APPEND;
-op--;
+	type = VAR_APPEND;
+	op--;
 
 } else if (op > name && op[-1] == '?') {
 	/* If the variable already has a value, we don't do anything. */
-Boolean exists;
+	Boolean exists;
 
-op--;
+	op--;
 	name = name_freeIt = bmake_strsedup(name, nameEnd < op ? nameEnd : op);
-exists = Var_Exists(name, ctxt);
+	exists = Var_Exists(name, ctxt);
 	if (exists) {
 	free(name_freeIt);
-	return;
+	return FALSE;
 	}
 	type = VAR_NORMAL;
 
 } else if (op > name && op[-1] == ':') {
-op--;
+	op--;
 	type = VAR_SUBST;
 
 } else if (op > name && op[-1] == '!') {
-op--;
-type = VAR_SHELL;
+	op--;
+	type = VAR_SHELL;
 
 } else {
 	type = VAR_NORMAL;
@@ -1834,11 

CVS commit: src/sys/dev/pci

2020-10-04 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Oct  4 16:23:05 UTC 2020

Modified Files:
src/sys/dev/pci: if_msk.c

Log Message:
device_printf() instead of aprint_error_dev() where appropriate


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 src/sys/dev/pci/if_msk.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/pci/if_msk.c
diff -u src/sys/dev/pci/if_msk.c:1.113 src/sys/dev/pci/if_msk.c:1.114
--- src/sys/dev/pci/if_msk.c:1.113	Mon May 11 23:47:45 2020
+++ src/sys/dev/pci/if_msk.c	Sun Oct  4 16:23:04 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: if_msk.c,v 1.113 2020/05/11 23:47:45 jakllsch Exp $ */
+/* $NetBSD: if_msk.c,v 1.114 2020/10/04 16:23:04 jakllsch Exp $ */
 /*	$OpenBSD: if_msk.c,v 1.79 2009/10/15 17:54:56 deraadt Exp $	*/
 
 /*
@@ -52,7 +52,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.113 2020/05/11 23:47:45 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.114 2020/10/04 16:23:04 jakllsch Exp $");
 
 #include 
 #include 
@@ -255,7 +255,7 @@ msk_miibus_readreg(device_t dev, int phy
 	}
 
 	if (i == SK_TIMEOUT) {
-		aprint_error_dev(sc_if->sk_dev, "phy failed to come ready\n");
+		device_printf(sc_if->sk_dev, "phy failed to come ready\n");
 		return ETIMEDOUT;
 	}
 
@@ -289,7 +289,7 @@ msk_miibus_writereg(device_t dev, int ph
 	}
 
 	if (i == SK_TIMEOUT) {
-		aprint_error_dev(sc_if->sk_dev, "phy write timed out\n");
+		device_printf(sc_if->sk_dev, "phy write timed out\n");
 		return ETIMEDOUT;
 	}
 
@@ -2035,7 +2035,7 @@ msk_watchdog(struct ifnet *ifp)
 	 */
 	msk_txeof(sc_if);
 	if (sc_if->sk_cdata.sk_tx_cnt != 0) {
-		aprint_error_dev(sc_if->sk_dev, "watchdog timeout\n");
+		device_printf(sc_if->sk_dev, "watchdog timeout\n");
 
 		if_statinc(ifp, if_oerrors);
 



CVS commit: src/usr.sbin/sysinst

2020-10-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct  4 16:09:13 UTC 2020

Modified Files:
src/usr.sbin/sysinst: bsddisklabel.c

Log Message:
If we have no explicitly marke target root partition, make sure to set
the proper flag on the implicit one.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/usr.sbin/sysinst/bsddisklabel.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/sysinst/bsddisklabel.c
diff -u src/usr.sbin/sysinst/bsddisklabel.c:1.46 src/usr.sbin/sysinst/bsddisklabel.c:1.47
--- src/usr.sbin/sysinst/bsddisklabel.c:1.46	Sat Oct  3 18:54:18 2020
+++ src/usr.sbin/sysinst/bsddisklabel.c	Sun Oct  4 16:09:12 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: bsddisklabel.c,v 1.46 2020/10/03 18:54:18 martin Exp $	*/
+/*	$NetBSD: bsddisklabel.c,v 1.47 2020/10/04 16:09:12 martin Exp $	*/
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -1774,6 +1774,35 @@ make_bsd_partitions(struct install_parti
 	}
 
 	/*
+	 * Make sure the target root partition is properly marked
+	 */
+	bool have_inst_target = false;
+	for (size_t i = 0; i < wanted.num; i++) {
+		if (wanted.infos[i].cur_flags & PTI_INSTALL_TARGET) {
+			have_inst_target = true;
+			break;
+		 }
+	}
+	if (!have_inst_target) {
+		for (size_t i = 0; i < wanted.num; i++) {
+			struct disk_part_info info;
+
+			if (wanted.infos[i].type != PT_root ||
+			strcmp(wanted.infos[i].mount, "/") != 0) 
+continue;
+			wanted.infos[i].cur_flags |= PTI_INSTALL_TARGET;
+
+			if (!wanted.parts->pscheme->get_part_info(wanted.parts,
+			wanted.infos[i].cur_part_id, ))
+break;
+			info.flags |= PTI_INSTALL_TARGET;
+			wanted.parts->pscheme->set_part_info(wanted.parts,
+			wanted.infos[i].cur_part_id, , NULL);
+			break;
+		}
+	}
+
+	/*
 	 * OK, we have a partition table. Give the user the chance to
 	 * edit it and verify it's OK, or abort altogether.
 	 */



CVS commit: src/external/gpl3/gcc/dist/gcc

2020-10-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Oct  4 14:44:48 UTC 2020

Modified Files:
src/external/gpl3/gcc/dist/gcc: builtins.c fold-const.c tree.c tree.h

Log Message:
Apply by hand a patch to fix http://r6.ca/blog/20200929T023701Z.html
aka "the memcmp bug", from a patch for gcc-10 in
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95189
Tested on x86_64 by running a full build, install and running it.
Testing that the problem has been fixed with one of the unit tests provided.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/external/gpl3/gcc/dist/gcc/builtins.c
cvs rdiff -u -r1.1.1.19 -r1.2 src/external/gpl3/gcc/dist/gcc/fold-const.c
cvs rdiff -u -r1.1.1.14 -r1.2 src/external/gpl3/gcc/dist/gcc/tree.c
cvs rdiff -u -r1.1.1.12 -r1.2 src/external/gpl3/gcc/dist/gcc/tree.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/gcc/dist/gcc/builtins.c
diff -u src/external/gpl3/gcc/dist/gcc/builtins.c:1.16 src/external/gpl3/gcc/dist/gcc/builtins.c:1.17
--- src/external/gpl3/gcc/dist/gcc/builtins.c:1.16	Sat Sep  5 05:12:23 2020
+++ src/external/gpl3/gcc/dist/gcc/builtins.c	Sun Oct  4 10:44:47 2020
@@ -118,7 +118,7 @@ static rtx expand_builtin_next_arg (void
 static rtx expand_builtin_va_start (tree);
 static rtx expand_builtin_va_end (tree);
 static rtx expand_builtin_va_copy (tree);
-static rtx inline_expand_builtin_string_cmp (tree, rtx);
+static rtx inline_expand_builtin_bytecmp (tree, rtx);
 static rtx expand_builtin_strcmp (tree, rtx);
 static rtx expand_builtin_strncmp (tree, rtx, machine_mode);
 static rtx builtin_memcpy_read_str (void *, HOST_WIDE_INT, scalar_int_mode);
@@ -3199,20 +3199,18 @@ expand_builtin_strnlen (tree exp, rtx ta
 }
 
 /* Callback routine for store_by_pieces.  Read GET_MODE_BITSIZE (MODE)
-   bytes from constant string DATA + OFFSET and return it as target
-   constant.  */
+   bytes from bytes at DATA + OFFSET and return it reinterpreted as
+   a target constant.  */
 
 static rtx
 builtin_memcpy_read_str (void *data, HOST_WIDE_INT offset,
 			 scalar_int_mode mode)
 {
-  const char *str = (const char *) data;
+  /* The REPresentation pointed to by DATA need not be a nul-terminated
+ string but the caller guarantees it's large enough for MODE.  */
+  const char *rep = (const char *) data;
 
-  gcc_assert (offset >= 0
-	  && ((unsigned HOST_WIDE_INT) offset + GET_MODE_SIZE (mode)
-		  <= strlen (str) + 1));
-
-  return c_readstr (str + offset, mode);
+  return c_readstr (rep + offset, mode, /*nul_terminated=*/false);
 }
 
 /* LEN specify length of the block of memcpy/memset operation.
@@ -3829,7 +3827,6 @@ static rtx
 expand_builtin_memory_copy_args (tree dest, tree src, tree len,
  rtx target, tree exp, memop_ret retmode)
 {
-  const char *src_str;
   unsigned int src_align = get_pointer_alignment (src);
   unsigned int dest_align = get_pointer_alignment (dest);
   rtx dest_mem, src_mem, dest_addr, len_rtx;
@@ -3859,21 +3856,29 @@ expand_builtin_memory_copy_args (tree de
   len_rtx = expand_normal (len);
   determine_block_size (len, len_rtx, _size, _size,
 			_max_size);
-  src_str = c_getstr (src);
 
-  /* If SRC is a string constant and block move would be done
- by pieces, we can avoid loading the string from memory
- and only stored the computed constants.  */
-  if (src_str
+  /* Try to get the byte representation of the constant SRC points to,
+ with its byte size in NBYTES.  */
+  unsigned HOST_WIDE_INT nbytes;
+  const char *rep = c_getstr (src, );
+
+  /* If the function's constant bound LEN_RTX is less than or equal
+ to the byte size of the representation of the constant argument,
+ and if block move would be done by pieces, we can avoid loading
+ the bytes from memory and only store the computed constant.
+ This works in the overlap (memmove) case as well because
+ store_by_pieces just generates a series of stores of constants
+ from the representation returned by c_getstr().  */
+  if (rep
   && CONST_INT_P (len_rtx)
-  && (unsigned HOST_WIDE_INT) INTVAL (len_rtx) <= strlen (src_str) + 1
+  && (unsigned HOST_WIDE_INT) INTVAL (len_rtx) <= nbytes
   && can_store_by_pieces (INTVAL (len_rtx), builtin_memcpy_read_str,
-			  CONST_CAST (char *, src_str),
+			  CONST_CAST (char *, rep),
 			  dest_align, false))
 {
   dest_mem = store_by_pieces (dest_mem, INTVAL (len_rtx),
   builtin_memcpy_read_str,
-  CONST_CAST (char *, src_str),
+  CONST_CAST (char *, rep),
   dest_align, false, retmode);
   dest_mem = force_operand (XEXP (dest_mem, 0), target);
   dest_mem = convert_memory_address (ptr_mode, dest_mem);
@@ -3889,11 +3894,9 @@ expand_builtin_memory_copy_args (tree de
   && (retmode == RETURN_BEGIN || target == const0_rtx))
 method = BLOCK_OP_TAILCALL;
   if (retmode == RETURN_END && target != const0_rtx)
-

CVS commit: src/usr.bin/make

2020-10-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct  4 14:40:13 UTC 2020

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

Log Message:
make(1): don't modify the given line during Parse_DoVar

Placing null characters all over the line made the code hard to
understand.  The null characters were placed for top-level whitespace as
well as the operator.

Working with a read-only line makes it easier to inspect the parsing
state during debugging.

This change involves an additional bmake_malloc for each variable name.
This will be compensated later by extending the API of the Var module to
also accept a pair of pointers (start, end) as the variable name.


To generate a diff of this commit:
cvs rdiff -u -r1.135 -r1.136 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.352 -r1.353 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.135 src/usr.bin/make/nonints.h:1.136
--- src/usr.bin/make/nonints.h:1.135	Sun Oct  4 10:35:25 2020
+++ src/usr.bin/make/nonints.h	Sun Oct  4 14:40:13 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nonints.h,v 1.135 2020/10/04 10:35:25 rillig Exp $	*/
+/*	$NetBSD: nonints.h,v 1.136 2020/10/04 14:40:13 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -122,7 +122,7 @@ char *cached_realpath(const char *, char
 /* parse.c */
 void Parse_Error(int, const char *, ...) MAKE_ATTR_PRINTFLIKE(2, 3);
 Boolean Parse_IsVar(const char *);
-void Parse_DoVar(char *, GNode *);
+void Parse_DoVar(const char *, GNode *);
 void Parse_AddIncludeDir(const char *);
 void Parse_File(const char *, int);
 void Parse_Init(void);

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.352 src/usr.bin/make/parse.c:1.353
--- src/usr.bin/make/parse.c:1.352	Sun Oct  4 13:24:59 2020
+++ src/usr.bin/make/parse.c	Sun Oct  4 14:40:13 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.352 2020/10/04 13:24:59 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.353 2020/10/04 14:40:13 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.352 2020/10/04 13:24:59 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.353 2020/10/04 14:40:13 rillig Exp $");
 
 /* types and constants */
 
@@ -1738,23 +1738,30 @@ Parse_IsVar(const char *line)
  * Input:
  *	p		A line guaranteed to be a variable assignment
  *			(see Parse_IsVar).
- *			Is destroyed but not freed during parsing.
  *	ctxt		Context in which to do the assignment
  */
 void
-Parse_DoVar(char *p, GNode *ctxt)
+Parse_DoVar(const char *p, GNode *ctxt)
 {
 enum {
 	VAR_SUBST, VAR_APPEND, VAR_SHELL, VAR_NORMAL
 } type;			/* Type of assignment */
-char *opc;			/* ptr to operator character to
- * null-terminate the variable name */
 int depth;
 const char *name;
+void *name_freeIt;
 const char *uvalue;		/* unexpanded value */
 const char *avalue;		/* actual value */
 char *evalue = NULL;	/* expanded value */
 
+/* The variable name consists of a single word (that is, no whitespace).
+ * It ends at the whitespace after that word (nameEnd).  If there is no
+ * whitespace, the name is followed directly by the assignment operator
+ * (op).  During parsing, the '+' of the '+=' operator is initially parsed
+ * as part of the variable name.  It is later corrected, as is the ':sh'
+ * modifier. Of these two (nameEnd and op), the earlier one determines the
+ * actual end of the variable name. */
+const char *nameEnd, *op;
+
 /*
  * Skip to variable name
  */
@@ -1762,12 +1769,14 @@ Parse_DoVar(char *p, GNode *ctxt)
 	p++;
 
 name = p;
+name_freeIt = NULL;
 
 /*
- * Skip to operator character, nulling out whitespace as we go
+ * Parse the variable name, up to the assignment operator.
  * XXX Rather than counting () and {} we should look for $ and
  * then expand the variable.
  */
+nameEnd = NULL;
 for (depth = 0; depth > 0 || *p != '='; p++) {
 	if (*p == '(' || *p == '{') {
 	depth++;
@@ -1778,61 +1787,55 @@ Parse_DoVar(char *p, GNode *ctxt)
 	continue;
 	}
 	if (depth == 0 && ch_isspace(*p)) {
-	*p = '\0';
+	if (nameEnd == NULL)
+		nameEnd = p;
 	}
 }
-opc = p > name ? p - 1 : p;	/* operator is the previous character */
-*p++ = '\0';		/* nuke the = */
 
-/*
- * Check operator type
- */
-switch (*opc) {
-	case '+':
-	type = VAR_APPEND;
-	*opc = '\0';
-	break;
+if (nameEnd == NULL)
+	nameEnd = p;
+op = p;			/* points at the '=' */
 
-	case '?':
-	/*
-	 * If the variable already has a value, we don't do anything.
-	 */
-	*opc = '\0';
-	if (Var_Exists(name, ctxt)) {
-		return;
-	} else {
-		type = VAR_NORMAL;
-	}
-	break;
+if (op > name && op[-1] 

CVS commit: src/games/factor

2020-10-04 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sun Oct  4 14:22:52 UTC 2020

Modified Files:
src/games/factor: factor.6

Log Message:
Fix a typo (s/int/in/)


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/games/factor/factor.6

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

Modified files:

Index: src/games/factor/factor.6
diff -u src/games/factor/factor.6:1.15 src/games/factor/factor.6:1.16
--- src/games/factor/factor.6:1.15	Sat Oct  3 22:27:00 2020
+++ src/games/factor/factor.6	Sun Oct  4 14:22:52 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: factor.6,v 1.15 2020/10/03 22:27:00 christos Exp $
+.\"	$NetBSD: factor.6,v 1.16 2020/10/04 14:22:52 kre Exp $
 .\"
 .\" Copyright (c) 1989, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -101,7 +101,7 @@ If a factor x divides a value n (>1) tim
 .It Fl x
 If the
 .Fl x
-flag is specified, factors will be printed int hexadecimal format.
+flag is specified, factors will be printed in hexadecimal format.
 .El
 .Sh DIAGNOSTICS
 Out of range or invalid input results in



CVS commit: src/etc

2020-10-04 Thread Kimmo Suominen
Module Name:src
Committed By:   kim
Date:   Sun Oct  4 13:50:44 UTC 2020

Modified Files:
src/etc: ntp.conf

Log Message:
Use "pool" for the pool.ntp.org servers. Add some new hints.

- Use the "pool" keyword for obtaining servers from ntp.pool.org.
  - Add "tos minclock" and "tos maxclock" to limit the number of servers.
  - Add "restrict source" to apply appropriate restrictions to servers.
(Specifically "nopeer" cannot be applied to "pool" servers.)
  - A single "pool" entry suffices -- using "2.netbsd.pool.ntp.org" so
that we get both IPv4 and IPv6 addresses. (No addresses are returned
for just "netbsd.pool.ntp.org.")
- Add a comment about "tinker panic 0" -- useful for VMs and laptops.
- Add a comment about "discard minimum" -- useful for some SNTP clients.
- Add an explanation for the "limited" restriction keyword.
- Unify whitespace and comment formatting.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/etc/ntp.conf

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

Modified files:

Index: src/etc/ntp.conf
diff -u src/etc/ntp.conf:1.20 src/etc/ntp.conf:1.21
--- src/etc/ntp.conf:1.20	Mon Jan  9 20:05:29 2017
+++ src/etc/ntp.conf	Sun Oct  4 13:50:44 2020
@@ -1,4 +1,4 @@
-# $NetBSD: ntp.conf,v 1.20 2017/01/09 20:05:29 christos Exp $
+# $NetBSD: ntp.conf,v 1.21 2020/10/04 13:50:44 kim Exp $
 #
 # NetBSD default Network Time Protocol (NTP) configuration file for ntpd
 
@@ -8,34 +8,52 @@
 # other guides, may be found on the official NTP web site, in particular
 #
 #	http://www.ntp.org/documentation.html
-#
 
 # Process ID file, so that the daemon can be signalled from scripts
 
-pidfile		/var/run/ntpd.pid
+pidfile /var/run/ntpd.pid
+
+# Don't give up even if the reference time is hugely different. This can
+# happen if the system was suspended and resumed.
+
+#tinker panic 0
 
 # The correction calculated by ntpd(8) for the local system clock's
 # drift is stored here.
 
-driftfile	/var/db/ntp.drift
+driftfile /var/db/ntp.drift
 
 # Suppress the syslog(3) message for each peer synchronization change.
 
-logconfig	-syncstatus
+logconfig -syncstatus
 
 # Refuse to set the local clock if there are too few good peers or servers.
 # This may help minimize disruptions due to network congestion. Don't
 # do this if you configure only one server!
 
-tos		minsane 2
+tos minsane 2
+
+# Set the target and limit for adding servers configured via pool statements
+# or discovered dynamically via mechanisms such as broadcast and manycast.
+# Ntpd automatically adds maxclock-1 servers from configured pools, and may
+# add as many as maxclock*2 if necessary to ensure that at least minclock
+# servers are providing good consistent time.
+
+tos minclock 3 maxclock 6
 
 # Set the number of tries to register with mdns. 0 means never
-#
-mdnstries	0
+
+mdnstries 0
 
 # New ntpd disables the ntpdc protocol by default, to re-enable uncomment
 # the following line
-# enable mode7
+
+#enable mode7
+
+# Allow hasty ntpdate clients to avoid rate limiting / kod responses.
+# The default is 2 seconds between packets from the client.
+
+#discard minimum 1
 
 # Access control restrictions.
 # See /usr/share/doc/html/ntp/accopt.html for syntax.
@@ -44,10 +62,13 @@ mdnstries	0
 #
 # Some of the more common keywords are:
 #   ignore  Deny packets of all kinds.
-#   kod Send "kiss-o'-death" packets if clients exceed rate
-#   limits.
-#   nomodifyDeny attempts to modify the state of the server via
-#   ntpq or ntpdc queries.
+#   limited Deny time service if the packet violates the rate limits
+#   established by the discard command. Does not affect ntpq or
+#   ntpdc queries.
+#   kod Send "kiss-o'-death" packets if clients exceed rate limits.
+#   No affect without the limited flag.
+#   nomodifyDeny attempts to modify the state of the server via ntpq or
+#   ntpdc queries.
 #   noquery Deny all ntpq and ntpdc queries.  Does not affect time
 #   synchronisation.
 #   nopeer  Prevent establishing new peer associations.
@@ -61,22 +82,26 @@ mdnstries	0
 # By default, allow client/server time exchange without prior
 # arrangement, but deny configuration changes, queries, and peer
 # associations that were not explicitly configured.
-#
-restrict default kod limited nopeer noquery
+
+restrict default limited kod nomodify notrap nopeer noquery
+
+# Restrictions used for associations (peer, server, pool).
+
+restrict source nomodify notrap noquery
 
 # Fewer restrictions for the local subnet.
 # (Uncomment and adjust as appropriate.)
-#
-#restrict 192.0.2.0 mask 255.255.255.0 kod limited nomodify notrap nopeer
-#restrict 2001:db8:: mask :::  kod limited nomodify notrap nopeer
+
+#restrict 192.0.2.0 mask 255.255.255.0 limited kod nomodify notrap nopeer
+#restrict 2001:db8:: mask :::  limited kod 

CVS commit: src/usr.bin/make

2020-10-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct  4 13:24:59 UTC 2020

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

Log Message:
make(1): clean up local variables in Parse_DoVar

The variable "line" was misnamed since it turned from the beginning of
the line to the variable name.  The variable "cp" was named too broadly.
Having two moving pointers in a single parsing function was too much.

Now p is the only moving pointer.  From it, the variable name and value
are extracted as the pointer flies by.  These more specific names make
the lower half of the function more readable since Var_Set(name, value)
sounds more correct and to the point than Var_Set(line, cp).

Memory management for the possibly expanded variable value is now
simpler as there may or may not be an expanded value, and that is freed
in every case.  No need for another Boolean variable called freeCp
anymore.  Distinguishing between the unexpanded value and the actual
value highlights the data flow.

Using const pointers is a step into the direction of having a parser
that operates on a read-only string.  Right now the string is destroyed
upon parsing.


To generate a diff of this commit:
cvs rdiff -u -r1.351 -r1.352 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.351 src/usr.bin/make/parse.c:1.352
--- src/usr.bin/make/parse.c:1.351	Sun Oct  4 11:58:57 2020
+++ src/usr.bin/make/parse.c	Sun Oct  4 13:24:59 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.351 2020/10/04 11:58:57 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.352 2020/10/04 13:24:59 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.351 2020/10/04 11:58:57 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.352 2020/10/04 13:24:59 rillig Exp $");
 
 /* types and constants */
 
@@ -1727,71 +1727,62 @@ Parse_IsVar(const char *line)
 return FALSE;
 }
 
-/*-
- *-
- * Parse_DoVar  --
- *	Take the variable assignment in the passed line and do it in the
- *	global context.
- *
- *	Note: There is a lexical ambiguity with assignment modifier characters
- *	in variable names. This routine interprets the character before the =
- *	as a modifier. Therefore, an assignment like
- *	C++=/usr/bin/CC
- *	is interpreted as "C+ +=" instead of "C++ =".
+/* Take the variable assignment in the passed line and execute it.
+ *
+ * Note: There is a lexical ambiguity with assignment modifier characters
+ * in variable names. This routine interprets the character before the =
+ * as a modifier. Therefore, an assignment like
+ *	C++=/usr/bin/CC
+ * is interpreted as "C+ +=" instead of "C++ =".
  *
  * Input:
- *	line		a line guaranteed to be a variable assignment.
- *			This reduces error checks
+ *	p		A line guaranteed to be a variable assignment
+ *			(see Parse_IsVar).
+ *			Is destroyed but not freed during parsing.
  *	ctxt		Context in which to do the assignment
- *
- * Results:
- *	none
- *
- * Side Effects:
- *	the variable structure of the given variable name is altered in the
- *	global context.
- *-
  */
 void
-Parse_DoVar(char *line, GNode *ctxt)
+Parse_DoVar(char *p, GNode *ctxt)
 {
-char *cp;			/* pointer into line */
 enum {
 	VAR_SUBST, VAR_APPEND, VAR_SHELL, VAR_NORMAL
 } type;			/* Type of assignment */
 char *opc;			/* ptr to operator character to
  * null-terminate the variable name */
-Boolean	   freeCp = FALSE; /* TRUE if cp needs to be freed,
-* i.e. if any variable expansion was
-* performed */
 int depth;
+const char *name;
+const char *uvalue;		/* unexpanded value */
+const char *avalue;		/* actual value */
+char *evalue = NULL;	/* expanded value */
 
 /*
  * Skip to variable name
  */
-while (*line == ' ' || *line == '\t')
-	line++;
+while (*p == ' ' || *p == '\t')
+	p++;
+
+name = p;
 
 /*
  * Skip to operator character, nulling out whitespace as we go
  * XXX Rather than counting () and {} we should look for $ and
  * then expand the variable.
  */
-for (depth = 0, cp = line; depth > 0 || *cp != '='; cp++) {
-	if (*cp == '(' || *cp == '{') {
+for (depth = 0; depth > 0 || *p != '='; p++) {
+	if (*p == '(' || *p == '{') {
 	depth++;
 	continue;
 	}
-	if (*cp == ')' || *cp == '}') {
+	if (*p == ')' || *p == '}') {
 	depth--;
 	continue;
 	}
-	if (depth == 0 && ch_isspace(*cp)) {
-	*cp = '\0';
+	if (depth == 0 && ch_isspace(*p)) {
+	*p = '\0';
 	}
 }
-opc = cp > line ? cp - 1 : cp;	/* operator is the previous character */
-*cp++ = '\0';	/* nuke the = */
+opc = p > name ? p - 

CVS commit: src/usr.bin/make

2020-10-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct  4 11:58:57 UTC 2020

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

Log Message:
make(1): fix out-of-bounds memory access in Parse_DoVar

When a line starts with "=value", this is interpreted as a variable
assignment, with an empty variable name.  In that case, there is no
"previous character" from the '='.  Accessing that character therefore
was an out-of-bounds read access.

If a whole file starts with "=value", instead of just a single line,
this out-of-bounds access can actually lead to a segmentation fault.
This depends on the memory allocator though.


To generate a diff of this commit:
cvs rdiff -u -r1.350 -r1.351 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.350 src/usr.bin/make/parse.c:1.351
--- src/usr.bin/make/parse.c:1.350	Sun Oct  4 10:35:25 2020
+++ src/usr.bin/make/parse.c	Sun Oct  4 11:58:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.350 2020/10/04 10:35:25 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.351 2020/10/04 11:58:57 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.350 2020/10/04 10:35:25 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.351 2020/10/04 11:58:57 rillig Exp $");
 
 /* types and constants */
 
@@ -1790,7 +1790,7 @@ Parse_DoVar(char *line, GNode *ctxt)
 	*cp = '\0';
 	}
 }
-opc = cp-1;		/* operator is the previous character */
+opc = cp > line ? cp - 1 : cp;	/* operator is the previous character */
 *cp++ = '\0';	/* nuke the = */
 
 /*



CVS commit: src/usr.bin/make

2020-10-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct  4 10:35:25 UTC 2020

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

Log Message:
make(1): only use the VARE_ASSIGN flag if necessary

When checking the right-hand side of a variable assignment for syntax
errors, it does not matter  whether a '$$' is expanded to '$' or kept as
'$$'.


To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.135 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.349 -r1.350 src/usr.bin/make/parse.c
cvs rdiff -u -r1.564 -r1.565 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/nonints.h
diff -u src/usr.bin/make/nonints.h:1.134 src/usr.bin/make/nonints.h:1.135
--- src/usr.bin/make/nonints.h:1.134	Sat Oct  3 15:00:57 2020
+++ src/usr.bin/make/nonints.h	Sun Oct  4 10:35:25 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nonints.h,v 1.134 2020/10/03 15:00:57 rillig Exp $	*/
+/*	$NetBSD: nonints.h,v 1.135 2020/10/04 10:35:25 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -192,10 +192,13 @@ void Targ_Propagate(void);
 /* var.c */
 
 typedef enum {
+VARE_NONE		= 0,
 /* Treat undefined variables as errors. */
 VARE_UNDEFERR	= 0x01,
 /* Expand and evaluate variables during parsing. */
 VARE_WANTRES	= 0x02,
+/* In an assignment using the ':=' operator, keep '$$' as '$$' instead
+ * of reducing it to a single '$'. */
 VARE_ASSIGN		= 0x04
 } VarEvalFlags;
 

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.349 src/usr.bin/make/parse.c:1.350
--- src/usr.bin/make/parse.c:1.349	Sun Oct  4 07:49:45 2020
+++ src/usr.bin/make/parse.c	Sun Oct  4 10:35:25 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.349 2020/10/04 07:49:45 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.350 2020/10/04 10:35:25 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.349 2020/10/04 07:49:45 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.350 2020/10/04 10:35:25 rillig Exp $");
 
 /* types and constants */
 
@@ -1845,10 +1845,11 @@ Parse_DoVar(char *line, GNode *ctxt)
 
 if (DEBUG(LINT)) {
 	if (type != VAR_SUBST && strchr(cp, '$') != NULL) {
-	/* sanity check now */
+	/* Check for syntax errors such as unclosed expressions or
+	 * unknown modifiers. */
 	char *expandedValue;
 
-	(void)Var_Subst(cp, ctxt, VARE_ASSIGN, );
+	(void)Var_Subst(cp, ctxt, VARE_NONE, );
 	/* TODO: handle errors */
 	free(expandedValue);
 	}

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.564 src/usr.bin/make/var.c:1.565
--- src/usr.bin/make/var.c:1.564	Sat Oct  3 21:19:54 2020
+++ src/usr.bin/make/var.c	Sun Oct  4 10:35:25 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.564 2020/10/03 21:19:54 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.565 2020/10/04 10:35:25 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -121,7 +121,7 @@
 #include"metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.564 2020/10/03 21:19:54 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.565 2020/10/04 10:35:25 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -3768,11 +3768,7 @@ Var_Subst(const char *str, GNode *ctxt, 
 
 while (*p != '\0') {
 	if (p[0] == '$' && p[1] == '$') {
-	/*
-	 * A dollar sign may be escaped with another dollar sign.
-	 * In such a case, we skip over the escape character and store the
-	 * dollar sign into the buffer directly.
-	 */
+	/* A dollar sign may be escaped with another dollar sign. */
 	if (save_dollars && (eflags & VARE_ASSIGN))
 		Buf_AddByte(, '$');
 	Buf_AddByte(, '$');



CVS commit: src/sys/arch

2020-10-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Oct  4 10:34:18 UTC 2020

Modified Files:
src/sys/arch/m68k/include: mcontext.h
src/sys/arch/powerpc/include: mcontext.h

Log Message:
Add missing __{BEGIN,END}_DECLS in order to catch up with
sanitizer_linux_libcdep.cc rev 1.17:

http://cvsweb.netbsd.org/bsdweb.cgi/src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cc#rev1.17

Fix build with HAVE_GCC=9.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/m68k/include/mcontext.h
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/powerpc/include/mcontext.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/arch/m68k/include/mcontext.h
diff -u src/sys/arch/m68k/include/mcontext.h:1.11 src/sys/arch/m68k/include/mcontext.h:1.12
--- src/sys/arch/m68k/include/mcontext.h:1.11	Mon Sep  7 00:32:00 2020
+++ src/sys/arch/m68k/include/mcontext.h	Sun Oct  4 10:34:18 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: mcontext.h,v 1.11 2020/09/07 00:32:00 mrg Exp $	*/
+/*	$NetBSD: mcontext.h,v 1.12 2020/10/04 10:34:18 rin Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -119,6 +119,8 @@ typedef struct {
 __CTASSERT(TLS_TP_OFFSET + sizeof(struct tls_tcb) < 0x8000);
 __CTASSERT(TLS_TP_OFFSET % sizeof(struct tls_tcb) == 0);
 
+__BEGIN_DECLS
+
 void *_lwp_getprivate(void);
 void _lwp_setprivate(void *);
 
@@ -136,6 +138,7 @@ __lwp_settcb(struct tls_tcb *__tcb)
 	__tcb += TLS_TP_OFFSET / sizeof(*__tcb) + 1;
 	_lwp_setprivate(__tcb);
 }
+__END_DECLS
 #endif
 
 #endif	/* !_M68K_MCONTEXT_H_ */

Index: src/sys/arch/powerpc/include/mcontext.h
diff -u src/sys/arch/powerpc/include/mcontext.h:1.21 src/sys/arch/powerpc/include/mcontext.h:1.22
--- src/sys/arch/powerpc/include/mcontext.h:1.21	Mon Jun 22 05:34:57 2020
+++ src/sys/arch/powerpc/include/mcontext.h	Sun Oct  4 10:34:18 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: mcontext.h,v 1.21 2020/06/22 05:34:57 rin Exp $	*/
+/*	$NetBSD: mcontext.h,v 1.22 2020/10/04 10:34:18 rin Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -153,6 +153,8 @@ typedef struct {
 #define	TLS_DTV_OFFSET	0x8000
 __CTASSERT(TLS_TP_OFFSET + sizeof(struct tls_tcb) < 0x8000);
 
+__BEGIN_DECLS
+
 static __inline void *
 __lwp_gettcb_fast(void)
 {
@@ -180,6 +182,7 @@ __lwp_settcb(void *__tcb)
 
 	_lwp_setprivate(__tcb);
 }
+__END_DECLS
 #endif /* _RTLD_SOURCE || _LIBC_SOURCE || __LIBPTHREAD_SOURCE__ */
 
 #endif	/* !_POWERPC_MCONTEXT_H_ */



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

2020-10-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct  4 10:16:10 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: var-op-append.mk

Log Message:
make(1): add basic tests for the += assignment operator


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/var-op-append.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/var-op-append.mk
diff -u src/usr.bin/make/unit-tests/var-op-append.mk:1.2 src/usr.bin/make/unit-tests/var-op-append.mk:1.3
--- src/usr.bin/make/unit-tests/var-op-append.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/var-op-append.mk	Sun Oct  4 10:16:09 2020
@@ -1,9 +1,36 @@
-# $NetBSD: var-op-append.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: var-op-append.mk,v 1.3 2020/10/04 10:16:09 rillig Exp $
 #
 # Tests for the += variable assignment operator, which appends to a variable,
 # creating it if necessary.
 
-# TODO: Implementation
+# Appending to an undefined variable is possible.
+# The variable is created, and no extra space is added before the value.
+VAR+=	one
+.if ${VAR} != "one"
+.  error
+.endif
+
+# Appending to an existing variable adds a single space and the value.
+VAR+=	two
+.if ${VAR} != "one two"
+.  error
+.endif
+
+# Appending an empty string nevertheless adds a single space.
+VAR+=	# empty
+.if ${VAR} != "one two "
+.  error
+.endif
+
+# Variable names may contain '+', and this character is also part of the
+# '+=' assignment operator.  As far as possible, the '+' is interpreted as
+# part of the assignment operator.
+#
+# See Parse_DoVar
+C++=value
+.if ${C+} != "value" || defined(C++)
+.  error
+.endif
 
 all:
 	@:;



CVS commit: src/distrib/cobalt/ramdisk

2020-10-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Oct  4 09:45:44 UTC 2020

Modified Files:
src/distrib/cobalt/ramdisk: list

Log Message:
Fix ramdisk overflow:

- switch to x_disklabel (drop non-native label support)
- switch to x_fsck_ffs and x_newfs (drop byte-swapped and Apple UFS support)
- switch to more


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/distrib/cobalt/ramdisk/list

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

Modified files:

Index: src/distrib/cobalt/ramdisk/list
diff -u src/distrib/cobalt/ramdisk/list:1.12 src/distrib/cobalt/ramdisk/list:1.13
--- src/distrib/cobalt/ramdisk/list:1.12	Fri Mar 22 10:52:21 2013
+++ src/distrib/cobalt/ramdisk/list	Sun Oct  4 09:45:44 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: list,v 1.12 2013/03/22 10:52:21 tsutsui Exp $
+#	$NetBSD: list,v 1.13 2020/10/04 09:45:44 rin Exp $
 
 SRCDIRS external/bsd/less/bin
 SRCDIRS	bin sbin usr.bin usr.sbin
@@ -53,7 +53,7 @@ PROG	sbin/umount
 
 PROG	usr/bin/ftp
 PROG	usr/bin/gzip	usr/bin/gzcat	usr/bin/gunzip
-PROG	usr/bin/less	usr/bin/more
+PROG	usr/bin/more	usr/bin/less
 PROG	usr/bin/sed
 PROG	usr/bin/tset
 
@@ -62,13 +62,18 @@ PROG	usr/sbin/chroot
 # init invokes the shell as -sh
 ARGVLN	sh	-sh
 
+SPECIAL	disklabel	srcdir	distrib/utils/x_disklabel
 SPECIAL	ed		srcdir	distrib/utils/x_ed
+SPECIAL	fsck_ffs	srcdir	distrib/utils/x_fsck_ffs
 SPECIAL	gzip		srcdir	distrib/utils/x_gzip
 SPECIAL	ifconfig	srcdir	distrib/utils/x_ifconfig
+SPECIAL	newfs		srcdir	distrib/utils/x_newfs
 SPECIAL	ping		srcdir	distrib/utils/x_ping
 SPECIAL	route		srcdir	distrib/utils/x_route
 SPECIAL	umount		srcdir	distrib/utils/x_umount
 
+SPECIAL	more		srcdir	distrib/utils/more
+
 LIBS	libhack.o -ledit -lutil -lcurses -lterminfo -lrmt -ll -lm -lz -lprop
 
 COPY	${DESTDIR}/usr/mdec/boot	usr/mdec/boot



CVS commit: src/distrib/sun2/miniroot

2020-10-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Oct  4 09:42:48 UTC 2020

Modified Files:
src/distrib/sun2/miniroot: list

Log Message:
Fix ramdisk overflow:

- switch to x_disklabel (drop non-native label support)
- switch to x_fsck_ffs and x_newfs (drop byte-swapped and Apple UFS support)
- switch to more


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/distrib/sun2/miniroot/list

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

Modified files:

Index: src/distrib/sun2/miniroot/list
diff -u src/distrib/sun2/miniroot/list:1.20 src/distrib/sun2/miniroot/list:1.21
--- src/distrib/sun2/miniroot/list:1.20	Sat Nov 30 08:27:18 2013
+++ src/distrib/sun2/miniroot/list	Sun Oct  4 09:42:48 2020
@@ -1,5 +1,5 @@
 #
-# $NetBSD: list,v 1.20 2013/11/30 08:27:18 nakayama Exp $
+# $NetBSD: list,v 1.21 2020/10/04 09:42:48 rin Exp $
 #
 
 # The PROM provides a default kernel name of "vmunix"
@@ -127,7 +127,7 @@ PROG	usr/bin/chflags
 PROG	usr/bin/cksum
 PROG	usr/bin/cmp
 PROG	usr/bin/ftp
-PROG	usr/bin/less	usr/bin/more
+PROG	usr/bin/more	usr/bin/less
 PROG	usr/bin/rsh
 PROG	usr/bin/sed
 PROG	usr/bin/tip
@@ -138,14 +138,18 @@ PROG	usr/bin/gzip	usr/bin/gzcat usr/bin/
 # install.md still uses sort
 PROG	usr/bin/sort
 
-SPECIAL	less		srcdir	external/bsd/less/bin/less
 SPECIAL	vi		srcdir	external/bsd/nvi/usr.bin/nvi
 
+SPECIAL	disklabel	srcdir	distrib/utils/x_disklabel
 SPECIAL	ed		srcdir	distrib/utils/x_ed
+SPECIAL	fsck_ffs	srcdir	distrib/utils/x_fsck_ffs
 SPECIAL	gzip		srcdir	distrib/utils/x_gzip
 SPECIAL	ifconfig	srcdir	distrib/utils/x_ifconfig
+SPECIAL	newfs		srcdir	distrib/utils/x_newfs
 SPECIAL	ping		srcdir	distrib/utils/x_ping
 SPECIAL	route		srcdir	distrib/utils/x_route
+
+SPECIAL	more		srcdir	distrib/utils/more
 SPECIAL	edlabel		srcdir	distrib/utils/edlabel
 
 ARGVLN	sh -sh



CVS commit: src/distrib/dreamcast/ramdisk

2020-10-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Oct  4 09:34:18 UTC 2020

Modified Files:
src/distrib/dreamcast/ramdisk: list

Log Message:
Fix miniroot overflow by switching to x_fsck_ffs and x_newfs
(drop byte-swapped and Apple UFS support).


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/distrib/dreamcast/ramdisk/list

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

Modified files:

Index: src/distrib/dreamcast/ramdisk/list
diff -u src/distrib/dreamcast/ramdisk/list:1.17 src/distrib/dreamcast/ramdisk/list:1.18
--- src/distrib/dreamcast/ramdisk/list:1.17	Tue Oct  4 14:00:27 2016
+++ src/distrib/dreamcast/ramdisk/list	Sun Oct  4 09:34:18 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: list,v 1.17 2016/10/04 14:00:27 christos Exp $
+#	$NetBSD: list,v 1.18 2020/10/04 09:34:18 rin Exp $
 
 SRCDIRS	bin sbin usr.bin usr.sbin
 
@@ -51,9 +51,11 @@ ARGVLN	sh	-sh
 
 SPECIAL	disklabel	srcdir	distrib/utils/x_disklabel
 SPECIAL	ed		srcdir	distrib/utils/x_ed
+SPECIAL	fsck_ffs	srcdir	distrib/utils/x_fsck_ffs
 SPECIAL	gzip		srcdir	distrib/utils/x_gzip
 SPECIAL	ifconfig	srcdir	distrib/utils/x_ifconfig
 SPECIAL	more		srcdir	distrib/utils/more
+SPECIAL	newfs		srcdir	distrib/utils/x_newfs
 SPECIAL	ping		srcdir	distrib/utils/x_ping
 SPECIAL	route		srcdir	distrib/utils/x_route
 SPECIAL	umount		srcdir	distrib/utils/x_umount



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

2020-10-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct  4 08:32:52 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: var-op-sunsh.mk

Log Message:
make(1): add test for combining :sh with +=


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/var-op-sunsh.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/var-op-sunsh.mk
diff -u src/usr.bin/make/unit-tests/var-op-sunsh.mk:1.4 src/usr.bin/make/unit-tests/var-op-sunsh.mk:1.5
--- src/usr.bin/make/unit-tests/var-op-sunsh.mk:1.4	Sun Oct  4 08:14:35 2020
+++ src/usr.bin/make/unit-tests/var-op-sunsh.mk	Sun Oct  4 08:32:52 2020
@@ -1,4 +1,4 @@
-# $NetBSD: var-op-sunsh.mk,v 1.4 2020/10/04 08:14:35 rillig Exp $
+# $NetBSD: var-op-sunsh.mk,v 1.5 2020/10/04 08:32:52 rillig Exp $
 #
 # Tests for the :sh= variable assignment operator, which runs its right-hand
 # side through the shell.  It is a seldom-used alternative to the !=
@@ -82,8 +82,9 @@ VAR.key:shift=		Shift
 # Parse_DoVar completely trusts Parse_IsVar to properly verify the syntax.
 #
 # The ':sh' is the only word that may occur between the variable name and
-# the assignment operator.  All other words would lead to a parse error
-# since the left-hand side of an assignment must be exactly one word.
+# the assignment operator at nesting level 0.  All other words would lead
+# to a parse error since the left-hand side of an assignment must be
+# exactly one word.
 VAR :sh :sh :sh :sh=	echo multiple
 .if ${VAR} != "multiple"
 .  error
@@ -107,5 +108,15 @@ VAR :sh{Put}a}{comment{here}=	co
 .  error
 .endif
 
+# Syntactically, the ':sh' modifier can be combined with the '+=' assignment
+# operator.  In such a case the ':sh' modifier is silently ignored.
+#
+# XXX: This combination should not be allowed at all.
+VAR=		one
+VAR :sh +=	echo two
+.if ${VAR} != "one echo two"
+.  error ${VAR}
+.endif
+
 all:
 	@:;



CVS commit: src/usr.bin/make

2020-10-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct  4 08:22:59 UTC 2020

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

Log Message:
make(1): make documentation of Error more precise


To generate a diff of this commit:
cvs rdiff -u -r1.364 -r1.365 src/usr.bin/make/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/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.364 src/usr.bin/make/main.c:1.365
--- src/usr.bin/make/main.c:1.364	Sat Oct  3 21:52:50 2020
+++ src/usr.bin/make/main.c	Sun Oct  4 08:22:59 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.364 2020/10/03 21:52:50 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.365 2020/10/04 08:22:59 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -122,7 +122,7 @@
 #endif
 
 /*	"@(#)main.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: main.c,v 1.364 2020/10/03 21:52:50 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.365 2020/10/04 08:22:59 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	"The Regents of the University of California.  "
@@ -1715,16 +1715,10 @@ bad:
 return bmake_strdup("");
 }
 
-/*-
- * Error --
- *	Print an error message given its format.
- *
- * Results:
- *	None.
+/* Print a printf-style error message.
  *
- * Side Effects:
- *	The message is printed.
- */
+ * This error message has no consequences, in particular it does not affect
+ * the exit status. */
 void
 Error(const char *fmt, ...)
 {



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

2020-10-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct  4 08:14:35 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: var-op-sunsh.mk

Log Message:
make(1): add another test for parsing :sh assignments


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/var-op-sunsh.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/var-op-sunsh.mk
diff -u src/usr.bin/make/unit-tests/var-op-sunsh.mk:1.3 src/usr.bin/make/unit-tests/var-op-sunsh.mk:1.4
--- src/usr.bin/make/unit-tests/var-op-sunsh.mk:1.3	Sun Oct  4 08:02:17 2020
+++ src/usr.bin/make/unit-tests/var-op-sunsh.mk	Sun Oct  4 08:14:35 2020
@@ -1,4 +1,4 @@
-# $NetBSD: var-op-sunsh.mk,v 1.3 2020/10/04 08:02:17 rillig Exp $
+# $NetBSD: var-op-sunsh.mk,v 1.4 2020/10/04 08:14:35 rillig Exp $
 #
 # Tests for the :sh= variable assignment operator, which runs its right-hand
 # side through the shell.  It is a seldom-used alternative to the !=
@@ -89,5 +89,23 @@ VAR :sh :sh :sh :sh=	echo multiple
 .  error
 .endif
 
+# The word ':sh' is not the only thing that can occur after a variable name.
+# Since the parser just counts braces and parentheses instead of properly
+# expanding nested expressions, the token ' :sh' can be used to add arbitrary
+# text between the variable name and the assignment operator, it just has to
+# be enclosed in braces or parentheses.
+VAR :sh(Put a comment here)=	comment in parentheses
+.if ${VAR} != "comment in parentheses"
+.  error
+.endif
+
+# The unintended comment can include multiple levels of nested braces and
+# parentheses, they don't even need to be balanced since they are only
+# counted by Parse_IsVar and ignored by Parse_DoVar.
+VAR :sh{Put}a}{comment{here}=	comment in braces
+.if ${VAR} != "comment in braces"
+.  error
+.endif
+
 all:
 	@:;



CVS commit: src/sys/arch/aarch64/aarch64

2020-10-04 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct  4 08:09:12 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: aarch64_machdep.c

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/aarch64/aarch64/aarch64_machdep.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/aarch64/aarch64/aarch64_machdep.c
diff -u src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.50 src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.51
--- src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.50	Sat Oct  3 05:56:26 2020
+++ src/sys/arch/aarch64/aarch64/aarch64_machdep.c	Sun Oct  4 08:09:12 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: aarch64_machdep.c,v 1.50 2020/10/03 05:56:26 skrll Exp $ */
+/* $NetBSD: aarch64_machdep.c,v 1.51 2020/10/04 08:09:12 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,14 +30,14 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.50 2020/10/03 05:56:26 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.51 2020/10/04 08:09:12 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_cpuoptions.h"
 #include "opt_ddb.h"
+#include "opt_fdt.h"
 #include "opt_kernhist.h"
 #include "opt_modular.h"
-#include "opt_fdt.h"
 
 #include 
 #include 



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

2020-10-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct  4 08:02:17 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: var-op-sunsh.mk

Log Message:
make(1): test another edge case for the :sh assignment


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/var-op-sunsh.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/var-op-sunsh.mk
diff -u src/usr.bin/make/unit-tests/var-op-sunsh.mk:1.2 src/usr.bin/make/unit-tests/var-op-sunsh.mk:1.3
--- src/usr.bin/make/unit-tests/var-op-sunsh.mk:1.2	Sun Oct  4 07:49:45 2020
+++ src/usr.bin/make/unit-tests/var-op-sunsh.mk	Sun Oct  4 08:02:17 2020
@@ -1,4 +1,4 @@
-# $NetBSD: var-op-sunsh.mk,v 1.2 2020/10/04 07:49:45 rillig Exp $
+# $NetBSD: var-op-sunsh.mk,v 1.3 2020/10/04 08:02:17 rillig Exp $
 #
 # Tests for the :sh= variable assignment operator, which runs its right-hand
 # side through the shell.  It is a seldom-used alternative to the !=
@@ -71,5 +71,23 @@ VAR.key:shift=		Shift
 .  error
 .endif
 
+# Just for fun: The code in Parse_IsVar allows for multiple appearances of
+# the ':sh' assignment operator modifier.  Let's see what happens ...
+#
+# Well, the end result is correct but the way until there is rather
+# adventurous.  This only works because the parser replaces each an every
+# whitespace character that is not nested with '\0' (see Parse_DoVar).
+# The variable name therefore ends before the first ':sh', and the last
+# ':sh' turns the assignment operator into the shell command evaluation.
+# Parse_DoVar completely trusts Parse_IsVar to properly verify the syntax.
+#
+# The ':sh' is the only word that may occur between the variable name and
+# the assignment operator.  All other words would lead to a parse error
+# since the left-hand side of an assignment must be exactly one word.
+VAR :sh :sh :sh :sh=	echo multiple
+.if ${VAR} != "multiple"
+.  error
+.endif
+
 all:
 	@:;



CVS commit: src/usr.bin/make

2020-10-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct  4 07:49:45 UTC 2020

Modified Files:
src/usr.bin/make: parse.c
src/usr.bin/make/unit-tests: var-op-sunsh.exp var-op-sunsh.mk

Log Message:
make(1): fix parsing of the :sh assignment operator modifier


To generate a diff of this commit:
cvs rdiff -u -r1.348 -r1.349 src/usr.bin/make/parse.c
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/var-op-sunsh.exp \
src/usr.bin/make/unit-tests/var-op-sunsh.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.348 src/usr.bin/make/parse.c:1.349
--- src/usr.bin/make/parse.c:1.348	Sat Oct  3 21:52:50 2020
+++ src/usr.bin/make/parse.c	Sun Oct  4 07:49:45 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.348 2020/10/03 21:52:50 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.349 2020/10/04 07:49:45 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.348 2020/10/03 21:52:50 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.349 2020/10/04 07:49:45 rillig Exp $");
 
 /* types and constants */
 
@@ -1826,12 +1826,14 @@ Parse_DoVar(char *line, GNode *ctxt)
 
 	default:
 #ifdef SUNSHCMD
-	while (opc > line && *opc != ':')
+	while (opc > line && *opc == '\0')
 		opc--;
 
-	if (strncmp(opc, ":sh", 3) == 0) {
+	if (opc >= line + 2 &&
+		opc[-2] == ':' && opc[-1] == 's' && opc[0] == 'h')
+	{
 		type = VAR_SHELL;
-		*opc = '\0';
+		opc[-2] = '\0';
 		break;
 	}
 #endif

Index: src/usr.bin/make/unit-tests/var-op-sunsh.exp
diff -u src/usr.bin/make/unit-tests/var-op-sunsh.exp:1.1 src/usr.bin/make/unit-tests/var-op-sunsh.exp:1.2
--- src/usr.bin/make/unit-tests/var-op-sunsh.exp:1.1	Sun Oct  4 06:53:15 2020
+++ src/usr.bin/make/unit-tests/var-op-sunsh.exp	Sun Oct  4 07:49:45 2020
@@ -1,3 +1 @@
-make: Unclosed variable specification (expecting '}') for "" (value "echo 123") modifier U
-make: Unclosed variable specification (expecting '}') for "" (value " echo\") modifier U
 exit status 0
Index: src/usr.bin/make/unit-tests/var-op-sunsh.mk
diff -u src/usr.bin/make/unit-tests/var-op-sunsh.mk:1.1 src/usr.bin/make/unit-tests/var-op-sunsh.mk:1.2
--- src/usr.bin/make/unit-tests/var-op-sunsh.mk:1.1	Sun Oct  4 06:53:15 2020
+++ src/usr.bin/make/unit-tests/var-op-sunsh.mk	Sun Oct  4 07:49:45 2020
@@ -1,8 +1,8 @@
-# $NetBSD: var-op-sunsh.mk,v 1.1 2020/10/04 06:53:15 rillig Exp $
+# $NetBSD: var-op-sunsh.mk,v 1.2 2020/10/04 07:49:45 rillig Exp $
 #
 # Tests for the :sh= variable assignment operator, which runs its right-hand
 # side through the shell.  It is a seldom-used alternative to the !=
-# assignment operator.
+# assignment operator, adopted from Sun make.
 
 .MAKEFLAGS: -dL			# Enable sane error messages
 
@@ -13,54 +13,63 @@ VAR:sh=		echo colon-sh
 .  error
 .endif
 
-# XXX: As of 2020-10-04, the ':sh' can even be followed by other characters.
-# This is neither documented by NetBSD make nor by Solaris make.
+# It is also possible to have whitespace around the :sh assignment
+# operator modifier.
+VAR :sh =	echo colon-sh-spaced
+.if ${VAR} != "colon-sh-spaced"
+.  error
+.endif
+
+# Until 2020-10-04, the ':sh' could even be followed by other characters.
+# This was neither documented by NetBSD make nor by Solaris make and was
+# an implementation error.
+#
+# Since 2020-10-04, this is a normal variable assignment using the '='
+# assignment operator.
 VAR:shell=	echo colon-shell
-.if ${VAR} != "colon-shell"
+.if ${${:UVAR\:shell}} != "echo colon-shell"
 .  error
 .endif
 
-# XXX: Several colons can syntactically appear in a variable name.
-# Neither of these should be interpreted as the ':sh' assignment operator
-# modifier.
+# Several colons can syntactically appear in a variable name.
+# Until 2020-10-04, the last of them was interpreted as the ':sh'
+# assignment operator.
+#
+# Since 2020-10-04, the colons are part of the variable name.
 VAR:shoe:shore=	echo two-colons
-.if ${VAR${:U\:}shoe} != "two-colons"
+.if ${${:UVAR\:shoe\:shore}} != "echo two-colons"
 .  error
 .endif
 
-#.MAKEFLAGS: -dcpv
-
-# XXX: As of 2020-10-04, the following expression is wrongly marked as
-# a parse error.  This is caused by the ':sh' modifier.
+# Until 2020-10-04, the following expression was wrongly marked as
+# a parse error.  This was because the parser for variable assignments
+# just looked for the previous ":sh", without taking any contextual
+# information into account.
 #
 # There are two different syntactical elements that look exactly the same:
 # The variable modifier ':sh' and the assignment operator modifier ':sh'.
-# Intuitively this variable name contains the variable modifier, but the
-# parser sees it as operator modifier, in Parse_DoVar.
-#
-VAR.${:Uecho 123:sh}=	echo oops
-.if ${VAR.echo 123} != "oops"
+# 

CVS commit: src

2020-10-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct  4 06:53:15 UTC 2020

Modified Files:
src/distrib/sets/lists/tests: mi
src/usr.bin/make/unit-tests: Makefile
Added Files:
src/usr.bin/make/unit-tests: parse-var.exp parse-var.mk
var-op-sunsh.exp var-op-sunsh.mk

Log Message:
make(1): add tests for parsing assignments, especially :sh

Luckily nobody uses the :sh variable assignment modifier since its
syntactical variant != is simpler.


To generate a diff of this commit:
cvs rdiff -u -r1.937 -r1.938 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.159 -r1.160 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/parse-var.exp \
src/usr.bin/make/unit-tests/parse-var.mk \
src/usr.bin/make/unit-tests/var-op-sunsh.exp \
src/usr.bin/make/unit-tests/var-op-sunsh.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.937 src/distrib/sets/lists/tests/mi:1.938
--- src/distrib/sets/lists/tests/mi:1.937	Sat Oct  3 20:34:06 2020
+++ src/distrib/sets/lists/tests/mi	Sun Oct  4 06:53:15 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.937 2020/10/03 20:34:06 rillig Exp $
+# $NetBSD: mi,v 1.938 2020/10/04 06:53:15 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4945,6 +4945,8 @@
 ./usr/tests/usr.bin/make/unit-tests/opt.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/order.exp	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/order.mk	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/parse-var.exptests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/parse-var.mktests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/phony-end.exptests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/phony-end.mktests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/posix.exp	tests-usr.bin-tests	compattestfile,atf
@@ -5021,6 +5023,8 @@
 ./usr/tests/usr.bin/make/unit-tests/var-op-expand.mktests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/var-op-shell.exptests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/var-op-shell.mktests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/var-op-sunsh.exptests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/var-op-sunsh.mktests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/var-op.exp	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/var-op.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varcmd.exp	tests-usr.bin-tests	compattestfile,atf

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.159 src/usr.bin/make/unit-tests/Makefile:1.160
--- src/usr.bin/make/unit-tests/Makefile:1.159	Sat Oct  3 17:30:54 2020
+++ src/usr.bin/make/unit-tests/Makefile	Sun Oct  4 06:53:15 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.159 2020/10/03 17:30:54 rillig Exp $
+# $NetBSD: Makefile,v 1.160 2020/10/04 06:53:15 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -230,6 +230,7 @@ TESTS+=		opt-warnings-as-errors
 TESTS+=		opt-where-am-i
 TESTS+=		opt-x-reduce-exported
 TESTS+=		order
+TESTS+=		parse-var
 TESTS+=		phony-end
 TESTS+=		posix
 TESTS+=		# posix1	# broken by reverting POSIX changes
@@ -269,6 +270,7 @@ TESTS+=		var-op-assign
 TESTS+=		var-op-default
 TESTS+=		var-op-expand
 TESTS+=		var-op-shell
+TESTS+=		var-op-sunsh
 TESTS+=		varcmd
 TESTS+=		vardebug
 TESTS+=		varfind

Added files:

Index: src/usr.bin/make/unit-tests/parse-var.exp
diff -u /dev/null src/usr.bin/make/unit-tests/parse-var.exp:1.1
--- /dev/null	Sun Oct  4 06:53:16 2020
+++ src/usr.bin/make/unit-tests/parse-var.exp	Sun Oct  4 06:53:15 2020
@@ -0,0 +1 @@
+exit status 0
Index: src/usr.bin/make/unit-tests/parse-var.mk
diff -u /dev/null src/usr.bin/make/unit-tests/parse-var.mk:1.1
--- /dev/null	Sun Oct  4 06:53:16 2020
+++ src/usr.bin/make/unit-tests/parse-var.mk	Sun Oct  4 06:53:15 2020
@@ -0,0 +1,13 @@
+# $NetBSD: parse-var.mk,v 1.1 2020/10/04 06:53:15 rillig Exp $
+
+.MAKEFLAGS: -dL
+
+# In variable assignments, there may be spaces on the left-hand side of the
+# assignment, but only if they occur inside variable expressions.
+VAR.${:U param }=	value
+.if ${VAR.${:U param }} != "value"
+.  error
+.endif
+
+all:
+	@:;
Index: src/usr.bin/make/unit-tests/var-op-sunsh.exp
diff -u /dev/null src/usr.bin/make/unit-tests/var-op-sunsh.exp:1.1
--- /dev/null	Sun Oct  4 06:53:16 2020
+++ src/usr.bin/make/unit-tests/var-op-sunsh.exp	Sun Oct  4 06:53:15 2020
@@ -0,0 +1,3 @@
+make: Unclosed variable specification (expecting '}') for "" (value 

CVS commit: src/sys/dev/cardbus

2020-10-04 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Sun Oct  4 06:15:55 UTC 2020

Modified Files:
src/sys/dev/cardbus: cardslot.c

Log Message:
Ensure event_thread stays in event loop upon creation.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/dev/cardbus/cardslot.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/cardbus/cardslot.c
diff -u src/sys/dev/cardbus/cardslot.c:1.56 src/sys/dev/cardbus/cardslot.c:1.57
--- src/sys/dev/cardbus/cardslot.c:1.56	Sat Sep 24 23:54:49 2016
+++ src/sys/dev/cardbus/cardslot.c	Sun Oct  4 06:15:54 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cardslot.c,v 1.56 2016/09/24 23:54:49 mrg Exp $	*/
+/*	$NetBSD: cardslot.c,v 1.57 2020/10/04 06:15:54 nat Exp $	*/
 
 /*
  * Copyright (c) 1999 and 2000
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cardslot.c,v 1.56 2016/09/24 23:54:49 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cardslot.c,v 1.57 2020/10/04 06:15:54 nat Exp $");
 
 #include "opt_cardslot.h"
 
@@ -157,6 +157,7 @@ cardslotattach(device_t parent, device_t
 	}
 
 	if (csc != NULL || psc != NULL) {
+		sc->sc_th_enable = 1;
 		config_pending_incr(self);
 		if (kthread_create(PRI_NONE, 0, NULL, cardslot_event_thread,
 		sc, >sc_event_thread, "%s", device_xname(self))) {
@@ -164,7 +165,6 @@ cardslotattach(device_t parent, device_t
 	 "unable to create thread\n");
 			panic("cardslotattach");
 		}
-		sc->sc_th_enable = 1;
 	}
 
 	if (csc && (csc->sc_cf->cardbus_ctrl)(csc->sc_cc, CARDBUS_CD)) {