CVS commit: src/share/misc

2020-08-01 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Aug  2 01:36:46 UTC 2020

Modified Files:
src/share/misc: style

Log Message:
Remove confusing advice about macros that might expand to nothing.

Such macros should not exist; as advised earlier in the file, they
should expand to `__nothing' (literally) from  which
itself expands to ((void)0) precisely so that the problem this advice
sought to avoid does not arise.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/share/misc/style

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/style
diff -u src/share/misc/style:1.58 src/share/misc/style:1.59
--- src/share/misc/style:1.58	Sun Aug  2 01:35:07 2020
+++ src/share/misc/style	Sun Aug  2 01:36:46 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: style,v 1.58 2020/08/02 01:35:07 riastradh Exp $ */
+/* $NetBSD: style,v 1.59 2020/08/02 01:36:46 riastradh Exp $ */
 
 /*
  * The revision control tag appears first, with a blank line after it.
@@ -30,7 +30,7 @@
 #include 
 __COPYRIGHT("@(#) Copyright (c) 2008\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: style,v 1.58 2020/08/02 01:35:07 riastradh Exp $");
+__RCSID("$NetBSD: style,v 1.59 2020/08/02 01:36:46 riastradh Exp $");
 
 /*
  * VERY important single-line comments look like this.
@@ -267,19 +267,6 @@ main(int argc, char *argv[])
 		stmt;
 
 	/*
-	 * Braces are required for control statements with a single statement
-	 * that may expand to nothing.
-	 */
-#ifdef DEBUG_FOO
-#define DPRINTF(a) printf a
-#else
-#define DPRINTF(a)
-#endif
-	if (broken) {
-		DPRINTF(("broken is %d\n", broken));
-	}
-
-	/*
 	 * Parts of a for loop may be left empty.  Don't put declarations
 	 * inside blocks unless the routine is unusually complicated.
 	 */



CVS commit: src/share/misc

2020-08-01 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Aug  2 01:35:07 UTC 2020

Modified Files:
src/share/misc: style

Log Message:
Update style around single-line braces according to discussion.

https://mail-index.netbsd.org/tech-userlevel/2020/07/12/msg012536.html
https://mail-index.netbsd.org/tech-kern/2020/07/12/msg026594.html

Retain some examples of technically unnecessary braces that likely
aid legibility from the previous commit.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/share/misc/style

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/style
diff -u src/share/misc/style:1.57 src/share/misc/style:1.58
--- src/share/misc/style:1.57	Sun Aug  2 00:20:21 2020
+++ src/share/misc/style	Sun Aug  2 01:35:07 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: style,v 1.57 2020/08/02 00:20:21 lukem Exp $ */
+/* $NetBSD: style,v 1.58 2020/08/02 01:35:07 riastradh Exp $ */
 
 /*
  * The revision control tag appears first, with a blank line after it.
@@ -30,7 +30,7 @@
 #include 
 __COPYRIGHT("@(#) Copyright (c) 2008\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: style,v 1.57 2020/08/02 00:20:21 lukem Exp $");
+__RCSID("$NetBSD: style,v 1.58 2020/08/02 01:35:07 riastradh Exp $");
 
 /*
  * VERY important single-line comments look like this.
@@ -241,8 +241,9 @@ main(int argc, char *argv[])
 			errno = 0;
 			num = strtol(optarg, , 10);
 			if (num <= 0 || *ep != '\0' || (errno == ERANGE &&
-			(num == LONG_MAX || num == LONG_MIN)) )
+			(num == LONG_MAX || num == LONG_MIN)) ) {
 errx(1, "illegal number -- %s", optarg);
+			}
 			break;
 		case '?':
 		default:
@@ -254,9 +255,9 @@ main(int argc, char *argv[])
 	argv += optind;
 
 	/*
-	 * Space after keywords (while, for, return, switch).  No braces are
-	 * required for control statements with only a single statement,
-	 * unless it's a long statement.
+	 * Space after keywords (while, for, return, switch).
+	 *
+	 * Braces around single-line bodies are optional; use discretion.
 	 *
 	 * Forever loops are done with for's, not while's.
 	 */
@@ -288,15 +289,14 @@ main(int argc, char *argv[])
 	}
 
 	/* Second level indents are four spaces. */
-	while (cnt < 20)
+	while (cnt < 20) {
 		z = a + really + long + statement + that + needs + two + lines +
 		gets + indented + four + spaces + on + the + second +
 		and + subsequent + lines;
+	}
 
 	/*
 	 * Closing and opening braces go on the same line as the else.
-	 * Don't add braces that aren't necessary except in cases where
-	 * there are ambiguity or readability issues.
 	 */
 	if (test) {
 		/*
@@ -310,8 +310,9 @@ main(int argc, char *argv[])
 	} else if (bar) {
 		stmt;
 		stmt;
-	} else
+	} else {
 		stmt;
+	}
 
 	/* No spaces after function names. */
 	if ((result = function(a1, a2, a3, a4)) == NULL)



CVS commit: src/sys/dev

2020-08-01 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Aug  2 01:17:57 UTC 2020

Modified Files:
src/sys/dev: ld.c ldvar.h
src/sys/dev/sdmmc: ld_sdmmc.c

Log Message:
Remove unnecessary wait in ldbegindetach.

Like disk_begindetach, ldbegindetach only commits to detaching but
doesn't wait for existing xfers to drain; it is up to the driver to
abort them, once we are committed, and then ldenddetach to wait for
them to drain.


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/sys/dev/ld.c
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/ldvar.h
cvs rdiff -u -r1.40 -r1.41 src/sys/dev/sdmmc/ld_sdmmc.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/ld.c
diff -u src/sys/dev/ld.c:1.110 src/sys/dev/ld.c:1.111
--- src/sys/dev/ld.c:1.110	Mon Apr 13 08:05:02 2020
+++ src/sys/dev/ld.c	Sun Aug  2 01:17:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ld.c,v 1.110 2020/04/13 08:05:02 maxv Exp $	*/
+/*	$NetBSD: ld.c,v 1.111 2020/08/02 01:17:56 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.110 2020/04/13 08:05:02 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.111 2020/08/02 01:17:56 riastradh Exp $");
 
 #include 
 #include 
@@ -189,26 +189,25 @@ int
 ldbegindetach(struct ld_softc *sc, int flags)
 {
 	struct dk_softc *dksc = >sc_dksc;
-	int rv = 0;
+	int error;
 
+	/* If we never attached properly, no problem with detaching.  */
 	if ((sc->sc_flags & LDF_ENABLED) == 0)
-		return (0);
-
-	rv = disk_begindetach(>sc_dkdev, ld_lastclose, dksc->sc_dev, flags);
-
-	if (rv != 0)
-		return rv;
+		return 0;
 
-	mutex_enter(>sc_mutex);
-	sc->sc_maxqueuecnt = 0;
+	/*
+	 * If the disk is still open, back out before we commit to
+	 * detaching.
+	 */
+	error = disk_begindetach(>sc_dkdev, ld_lastclose, dksc->sc_dev,
+	flags);
+	if (error)
+		return error;
 
-	while (sc->sc_queuecnt > 0) {
-		sc->sc_flags |= LDF_DRAIN;
-		cv_wait(>sc_drain, >sc_mutex);
-	}
-	mutex_exit(>sc_mutex);
+	/* We are now committed to detaching.  Prevent new xfers.  */
+	ldadjqparam(sc, 0);
 
-	return (rv);
+	return 0;
 }
 
 void
@@ -220,12 +219,17 @@ ldenddetach(struct ld_softc *sc)
 	if ((sc->sc_flags & LDF_ENABLED) == 0)
 		return;
 
-	mutex_enter(>sc_mutex);
-
 	/* Wait for commands queued with the hardware to complete. */
-	if (sc->sc_queuecnt != 0) {
-		if (cv_timedwait(>sc_drain, >sc_mutex, 30 * hz))
+	mutex_enter(>sc_mutex);
+	while (sc->sc_queuecnt > 0) {
+		if (cv_timedwait(>sc_drain, >sc_mutex, 30 * hz)) {
+			/*
+			 * XXX This seems like a recipe for crashing on
+			 * use after free...
+			 */
 			printf("%s: not drained\n", dksc->sc_xname);
+			break;
+		}
 	}
 	mutex_exit(>sc_mutex);
 
@@ -467,10 +471,7 @@ lddone(struct ld_softc *sc, struct buf *
 
 	mutex_enter(>sc_mutex);
 	if (--sc->sc_queuecnt <= sc->sc_maxqueuecnt) {
-		if ((sc->sc_flags & LDF_DRAIN) != 0) {
-			sc->sc_flags &= ~LDF_DRAIN;
-			cv_broadcast(>sc_drain);
-		}
+		cv_broadcast(>sc_drain);
 		mutex_exit(>sc_mutex);
 		dk_start(dksc, NULL);
 	} else

Index: src/sys/dev/ldvar.h
diff -u src/sys/dev/ldvar.h:1.33 src/sys/dev/ldvar.h:1.34
--- src/sys/dev/ldvar.h:1.33	Tue Mar 19 07:01:14 2019
+++ src/sys/dev/ldvar.h	Sun Aug  2 01:17:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ldvar.h,v 1.33 2019/03/19 07:01:14 mlelstv Exp $	*/
+/*	$NetBSD: ldvar.h,v 1.34 2020/08/02 01:17:56 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@ struct ld_softc {
 
 /* sc_flags */
 #define	LDF_ENABLED	0x001		/* device enabled */
-#define	LDF_DRAIN	0x020		/* maxqueuecnt has changed; drain */
+#define	LDF_UNUSED0	0x020		/* was LDF_DRAIN */
 #define	LDF_NO_RND	0x040		/* do not attach rnd source */
 #define	LDF_MPSAFE	0x080		/* backend is MPSAFE */
 

Index: src/sys/dev/sdmmc/ld_sdmmc.c
diff -u src/sys/dev/sdmmc/ld_sdmmc.c:1.40 src/sys/dev/sdmmc/ld_sdmmc.c:1.41
--- src/sys/dev/sdmmc/ld_sdmmc.c:1.40	Wed Jul 22 17:18:10 2020
+++ src/sys/dev/sdmmc/ld_sdmmc.c	Sun Aug  2 01:17:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ld_sdmmc.c,v 1.40 2020/07/22 17:18:10 riastradh Exp $	*/
+/*	$NetBSD: ld_sdmmc.c,v 1.41 2020/08/02 01:17:56 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2008 KIYOHARA Takashi
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ld_sdmmc.c,v 1.40 2020/07/22 17:18:10 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld_sdmmc.c,v 1.41 2020/08/02 01:17:56 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -344,11 +344,20 @@ ld_sdmmc_detach(device_t dev, int flags)
 	struct ld_sdmmc_softc *sc = device_private(dev);
 	struct ld_softc *ld = >sc_ld;
 	struct ld_sdmmc_task *task;
-	int rv, i;
+	int error, i;
 
 	/*
-	 * Block new xfers, abort all pending tasks, and wait for all
-	 * pending waiters to notice that we're gone.
+	 * Block new xfers, or fail if the disk is still open and the
+	 * detach isn't forced.  

CVS commit: src/share/misc

2020-08-01 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sun Aug  2 00:20:22 UTC 2020

Modified Files:
src/share/misc: style

Log Message:
style: revert previous

I misintepreted the consensus.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/share/misc/style

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/style
diff -u src/share/misc/style:1.56 src/share/misc/style:1.57
--- src/share/misc/style:1.56	Sat Aug  1 02:45:35 2020
+++ src/share/misc/style	Sun Aug  2 00:20:21 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: style,v 1.56 2020/08/01 02:45:35 lukem Exp $ */
+/* $NetBSD: style,v 1.57 2020/08/02 00:20:21 lukem Exp $ */
 
 /*
  * The revision control tag appears first, with a blank line after it.
@@ -30,7 +30,7 @@
 #include 
 __COPYRIGHT("@(#) Copyright (c) 2008\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: style,v 1.56 2020/08/01 02:45:35 lukem Exp $");
+__RCSID("$NetBSD: style,v 1.57 2020/08/02 00:20:21 lukem Exp $");
 
 /*
  * VERY important single-line comments look like this.
@@ -241,9 +241,8 @@ main(int argc, char *argv[])
 			errno = 0;
 			num = strtol(optarg, , 10);
 			if (num <= 0 || *ep != '\0' || (errno == ERANGE &&
-			(num == LONG_MAX || num == LONG_MIN)) ) {
+			(num == LONG_MAX || num == LONG_MIN)) )
 errx(1, "illegal number -- %s", optarg);
-			}
 			break;
 		case '?':
 		default:
@@ -255,18 +254,16 @@ main(int argc, char *argv[])
 	argv += optind;
 
 	/*
-	 * Space after keywords (while, for, return, switch).
-	 * Braces are preferred for control statements
-	 * with only a single statement.
+	 * Space after keywords (while, for, return, switch).  No braces are
+	 * required for control statements with only a single statement,
+	 * unless it's a long statement.
 	 *
 	 * Forever loops are done with for's, not while's.
 	 */
-	for (p = buf; *p != '\0'; ++p) {
+	for (p = buf; *p != '\0'; ++p)
 		continue;		/* Explicit no-op */
-	}
-	for (;;) {
+	for (;;)
 		stmt;
-	}
 
 	/*
 	 * Braces are required for control statements with a single statement
@@ -291,14 +288,15 @@ main(int argc, char *argv[])
 	}
 
 	/* Second level indents are four spaces. */
-	while (cnt < 20) {
+	while (cnt < 20)
 		z = a + really + long + statement + that + needs + two + lines +
 		gets + indented + four + spaces + on + the + second +
 		and + subsequent + lines;
-	}
 
 	/*
 	 * Closing and opening braces go on the same line as the else.
+	 * Don't add braces that aren't necessary except in cases where
+	 * there are ambiguity or readability issues.
 	 */
 	if (test) {
 		/*
@@ -312,14 +310,12 @@ main(int argc, char *argv[])
 	} else if (bar) {
 		stmt;
 		stmt;
-	} else {
+	} else
 		stmt;
-	}
 
 	/* No spaces after function names. */
-	if ((result = function(a1, a2, a3, a4)) == NULL) {
+	if ((result = function(a1, a2, a3, a4)) == NULL)
 		exit(1);
-	}
 
 	/*
 	 * Unary operators don't require spaces, binary operators do.
@@ -397,12 +393,10 @@ function(int a1, int a2, float fl, int a
 	 *
 	 * Use err/warn(3), don't roll your own!
 	 */
-	if ((four = malloc(sizeof(*four))) == NULL) {
+	if ((four = malloc(sizeof(*four))) == NULL)
 		err(1, NULL);
-	}
-	if ((six = (int *)overflow()) == NULL) {
+	if ((six = (int *)overflow()) == NULL)
 		errx(1, "Number overflowed.");
-	}
 
 	/* No parentheses are needed around the return value. */
 	return eight;
@@ -426,9 +420,8 @@ dirinfo(const char *p, struct stat *sb, 
 	_DIAGASSERT(p != NULL);
 	_DIAGASSERT(filedesc != -1);
 
-	if (stat(p, sb) < 0) {
+	if (stat(p, sb) < 0)
 		err(1, "Unable to stat %s", p);
-	}
 
 	/*
 	 * To printf quantities that might be larger than "long", include



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

2020-08-01 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug  1 22:30:57 UTC 2020

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

Log Message:
Define kthread_fpu_enter/exit for rump.

XXX Not 100% sure that it's safe to touch curlwp->l_flag in this
context, but this change will make progress, at least.


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

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

Modified files:

Index: src/sys/rump/librump/rumpkern/threads.c
diff -u src/sys/rump/librump/rumpkern/threads.c:1.26 src/sys/rump/librump/rumpkern/threads.c:1.27
--- src/sys/rump/librump/rumpkern/threads.c:1.26	Fri Apr 21 19:16:10 2017
+++ src/sys/rump/librump/rumpkern/threads.c	Sat Aug  1 22:30:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: threads.c,v 1.26 2017/04/21 19:16:10 kamil Exp $	*/
+/*	$NetBSD: threads.c,v 1.27 2020/08/01 22:30:57 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2007-2009 Antti Kantee.  All Rights Reserved.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: threads.c,v 1.26 2017/04/21 19:16:10 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: threads.c,v 1.27 2020/08/01 22:30:57 riastradh Exp $");
 
 #include 
 #include 
@@ -247,6 +247,32 @@ kthread_join(struct lwp *l)
 	return rv;
 }
 
+int
+kthread_fpu_enter(void)
+{
+	struct lwp *l = curlwp;
+	int s;
+
+	KASSERTMSG(l->l_flag & LW_SYSTEM,
+	"%s is allowed only in kthreads", __func__);
+	s = l->l_flag & LW_SYSTEM_FPU;
+	l->l_flag |= LW_SYSTEM_FPU;
+
+	return s;
+}
+
+void
+kthread_fpu_exit(int s)
+{
+	struct lwp *l = curlwp;
+
+	KASSERT(s == (s & LW_SYSTEM_FPU));
+	KASSERTMSG(l->l_flag & LW_SYSTEM,
+	"%s is allowed only in kthreads", __func__);
+	KASSERT(l->l_flag & LW_SYSTEM_FPU);
+	l->l_flag ^= s ^ LW_SYSTEM_FPU;
+}
+
 /*
  * Create a non-kernel thread that is scheduled by a rump kernel hypercall.
  *



CVS commit: src/usr.bin/make

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 21:51:22 UTC 2020

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

Log Message:
make(1): remove redundant if clause from Buf_DestroyCompact

bmake_realloc can never return NULL.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/usr.bin/make/buf.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/buf.c
diff -u src/usr.bin/make/buf.c:1.29 src/usr.bin/make/buf.c:1.30
--- src/usr.bin/make/buf.c:1.29	Sat Aug  1 21:40:49 2020
+++ src/usr.bin/make/buf.c	Sat Aug  1 21:51:22 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: buf.c,v 1.29 2020/08/01 21:40:49 rillig Exp $	*/
+/*	$NetBSD: buf.c,v 1.30 2020/08/01 21:51:22 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: buf.c,v 1.29 2020/08/01 21:40:49 rillig Exp $";
+static char rcsid[] = "$NetBSD: buf.c,v 1.30 2020/08/01 21:51:22 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)buf.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: buf.c,v 1.29 2020/08/01 21:40:49 rillig Exp $");
+__RCSID("$NetBSD: buf.c,v 1.30 2020/08/01 21:51:22 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -219,11 +219,9 @@ Buf_DestroyCompact(Buffer *buf)
 if (buf->size - buf->count >= BUF_COMPACT_LIMIT) {
 	/* We trust realloc to be smart */
 	Byte *data = bmake_realloc(buf->buffer, buf->count + 1);
-	if (data) {	/* XXX: can never be NULL */
-	data[buf->count] = 0;
-	Buf_Destroy(buf, FALSE);
-	return data;
-	}
+	data[buf->count] = 0;
+	Buf_Destroy(buf, FALSE);
+	return data;
 }
 #endif
 return Buf_Destroy(buf, FALSE);



CVS commit: src/usr.bin/make

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 21:48:17 UTC 2020

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

Log Message:
make(1): remove line numbers from generated code coverage files

The line numbers make it difficult to spot changes in the code and
coverage if a line is added or removed from the code.


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

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

Modified files:

Index: src/usr.bin/make/Makefile
diff -u src/usr.bin/make/Makefile:1.77 src/usr.bin/make/Makefile:1.78
--- src/usr.bin/make/Makefile:1.77	Fri Jul 31 07:29:21 2020
+++ src/usr.bin/make/Makefile	Sat Aug  1 21:48:17 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.77 2020/07/31 07:29:21 rillig Exp $
+#	$NetBSD: Makefile,v 1.78 2020/08/01 21:48:17 rillig Exp $
 #	@(#)Makefile	5.2 (Berkeley) 12/28/90
 
 PROG=	make
@@ -79,6 +79,7 @@ test: .MAKE
 	&& MAKEFLAGS= ${.MAKE} -r -m / TEST_MAKE=${TEST_MAKE:U${.OBJDIR}/${PROG:T}} ${.TARGET}
 .if ${USE_COVERAGE} == yes
 	gcov ${SRCS}
+	sed -i 's,^\([^:]*\): *[0-9]*:,\1: ,' *.gcov
 .endif
 
 accept: .MAKE



CVS commit: src/usr.bin/make

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 21:40:50 UTC 2020

Modified Files:
src/usr.bin/make: buf.c buf.h cond.c for.c main.c var.c

Log Message:
make(1): switch Buffer size from int to size_t

This change helps to make the various integer types compatible and is a
preparational step for setting WARNS=6 in the Makefile.

The documentation of buf.c has been cleaned up and condensed since it
was mostly redundant, and some statements were even slightly wrong.

All code changes are covered by the existing unit tests, except for the
few lines in for.c around for_var_len.  These changes have been reviewed
thoroughly and manually, like all the others in this commit.

Those buffer functions that deal with sizes have been renamed by
appending a Z, to make sure that no function call was accidentally
forgotten.  They will be renamed back in a follow-up commit.

As usual, the scope of a few affected variables has been reduced, and
some variables had to be split since they had been incorrectly merged
before.

The order of the arguments to Buf_AddBytes has changed from (mem_len,
mem) to (mem, mem_len), in order to make it consistent with the
functions from the C standard library, such as snprintf.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/usr.bin/make/buf.c
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/make/buf.h
cvs rdiff -u -r1.86 -r1.87 src/usr.bin/make/cond.c
cvs rdiff -u -r1.58 -r1.59 src/usr.bin/make/for.c
cvs rdiff -u -r1.293 -r1.294 src/usr.bin/make/main.c
cvs rdiff -u -r1.387 -r1.388 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/buf.c
diff -u src/usr.bin/make/buf.c:1.28 src/usr.bin/make/buf.c:1.29
--- src/usr.bin/make/buf.c:1.28	Sun Jul 26 15:09:10 2020
+++ src/usr.bin/make/buf.c	Sat Aug  1 21:40:49 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: buf.c,v 1.28 2020/07/26 15:09:10 rillig Exp $	*/
+/*	$NetBSD: buf.c,v 1.29 2020/08/01 21:40:49 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,40 +70,31 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: buf.c,v 1.28 2020/07/26 15:09:10 rillig Exp $";
+static char rcsid[] = "$NetBSD: buf.c,v 1.29 2020/08/01 21:40:49 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)buf.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: buf.c,v 1.28 2020/07/26 15:09:10 rillig Exp $");
+__RCSID("$NetBSD: buf.c,v 1.29 2020/08/01 21:40:49 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
 
-/*-
- * buf.c --
- *	Functions for automatically-expanded NUL-terminated buffers.
- */
+/* Functions for automatically-expanded NUL-terminated buffers. */
 
 #include 
 #include "make.h"
 #include "buf.h"
 
 #ifndef max
-#define max(a,b)  ((a) > (b) ? (a) : (b))
+#define max(a, b)  ((a) > (b) ? (a) : (b))
 #endif
 
 #define BUF_DEF_SIZE	256 	/* Default buffer size */
 
-/*-
- *---
- * Buf_Expand_1 --
- *	Extend buffer for single byte add.
- *
- *---
- */
+/* Extend the buffer for adding a single byte. */
 void
 Buf_Expand_1(Buffer *bp)
 {
@@ -111,55 +102,38 @@ Buf_Expand_1(Buffer *bp)
 bp->buffer = bmake_realloc(bp->buffer, bp->size);
 }
 
-/*-
- *---
- * Buf_AddBytes --
- *	Add a number of bytes to the buffer.
- *
- * Results:
- *	None.
- *
- * Side Effects:
- *	Guess what?
- *
- *---
- */
+/* Add the given bytes to the buffer. */
 void
-Buf_AddBytes(Buffer *bp, int numBytes, const Byte *bytesPtr)
+Buf_AddBytesZ(Buffer *bp, const Byte *bytesPtr, size_t numBytes)
 {
-int count = bp->count;
-Byte *ptr;
+size_t count = bp->count;
 
 if (__predict_false(count + numBytes >= bp->size)) {
 	bp->size += max(bp->size, numBytes + 16);
 	bp->buffer = bmake_realloc(bp->buffer, bp->size);
 }
 
-ptr = bp->buffer + count;
+Byte *ptr = bp->buffer + count;
 bp->count = count + numBytes;
-ptr[numBytes] = 0;
 memcpy(ptr, bytesPtr, numBytes);
+ptr[numBytes] = '\0';
 }
 
+/* Add the bytes between start and end to the buffer. */
 void
 Buf_AddBytesBetween(Buffer *bp, const char *start, const char *end)
 {
-Buf_AddBytes(bp, (int)(end - start), start);
+Buf_AddBytesZ(bp, start, (size_t)(end - start));
 }
 
+/* Add the given string to the buffer. */
 void
 Buf_AddStr(Buffer *bp, const char *str)
 {
-Buf_AddBytes(bp, (int)strlen(str), str);
+Buf_AddBytesZ(bp, str, strlen(str));
 }
 
-/*-
- *---
- * Buf_AddInt --
- *	Add the given number to the buffer.
- *
- *---
- */
+/* Add the 

CVS commit: src/sys/arch/sh3/sh3

2020-08-01 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat Aug  1 20:54:23 UTC 2020

Modified Files:
src/sys/arch/sh3/sh3: pmap.c

Log Message:
pmap_unwire - deobfuscate.

Don't hide assignments inside if ().  Remove redundant entry == 0 test
b/c _PG_WIRED test afterwards covers that and the compiler actually
elimiates it anyway.  Same object code is generated.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/arch/sh3/sh3/pmap.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/sh3/sh3/pmap.c
diff -u src/sys/arch/sh3/sh3/pmap.c:1.82 src/sys/arch/sh3/sh3/pmap.c:1.83
--- src/sys/arch/sh3/sh3/pmap.c:1.82	Thu Feb  2 21:35:29 2017
+++ src/sys/arch/sh3/sh3/pmap.c	Sat Aug  1 20:54:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.82 2017/02/02 21:35:29 uwe Exp $	*/
+/*	$NetBSD: pmap.c,v 1.83 2020/08/01 20:54:23 uwe Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.82 2017/02/02 21:35:29 uwe Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.83 2020/08/01 20:54:23 uwe Exp $");
 
 #include 
 #include 
@@ -736,9 +736,12 @@ pmap_unwire(pmap_t pmap, vaddr_t va)
 {
 	pt_entry_t *pte, entry;
 
-	if ((pte = __pmap_pte_lookup(pmap, va)) == NULL ||
-	(entry = *pte) == 0 ||
-	(entry & _PG_WIRED) == 0)
+	pte = __pmap_pte_lookup(pmap, va);
+	if (pte == NULL)
+		return;
+
+	entry = *pte;
+	if ((entry & _PG_WIRED) == 0)
 		return;
 
 	*pte = entry & ~_PG_WIRED;



CVS commit: xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k

2020-08-01 Thread Izumi Tsutsui
Module Name:xsrc
Committed By:   tsutsui
Date:   Sat Aug  1 20:21:00 UTC 2020

Modified Files:
xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k: x68kGraph.c
x68kKbd.c x68kMouse.c

Log Message:
Replace 'pointer' type with 'void *' to sync with upstream manner.

https://cgit.freedesktop.org/xorg/xserver/commit/?id=60014a4a98ff924ae7f6840781f768c1cc93bbab


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kGraph.c \
xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kMouse.c
cvs rdiff -u -r1.7 -r1.8 \
xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kKbd.c

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

Modified files:

Index: xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kGraph.c
diff -u xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kGraph.c:1.6 xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kGraph.c:1.7
--- xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kGraph.c:1.6	Sat Aug  1 20:09:03 2020
+++ xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kGraph.c	Sat Aug  1 20:21:00 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: x68kGraph.c,v 1.6 2020/08/01 20:09:03 tsutsui Exp $ */
+/* $NetBSD: x68kGraph.c,v 1.7 2020/08/01 20:21:00 tsutsui Exp $ */
 /*-
  * Copyright (c) 1996 Yasushi Yamasaki
  * All rights reserved.
@@ -116,7 +116,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "fb.h"
 
 /* local functions */
-static Bool x68kCfbFinishScreenInit(ScreenPtr pScreen, pointer pbits,
+static Bool x68kCfbFinishScreenInit(ScreenPtr pScreen, void *pbits,
 int xsize, int ysize,
 int dpix, int dpiy, int width);
 static void x68kInstallColormap(ColormapPtr cmap);
@@ -235,7 +235,7 @@ x68kGraphInit(ScreenPtr pScreen, int arg
  *
  *  purpose:  initialize visuals and perform miscellaneous settings
  *  argument: (ScreenPtr)pScreen : DIX screen record
- *(pointer)pbits : frame buffer
+ *(void *)pbits  : frame buffer
  *(int)xsize, (int)ysize : screen size
  *(int)dpix, (int)dpiy   : screen resolution in dots per inch
  *(int)width : pixel width of frame buffer
@@ -245,7 +245,7 @@ x68kGraphInit(ScreenPtr pScreen, int arg
 static Bool
 x68kCfbFinishScreenInit(
 ScreenPtr pScreen,
-pointer pbits,
+void *pbits,
 int xsize, int ysize,
 int dpix, int dpiy,
 int width)
@@ -361,7 +361,7 @@ x68kInstallColormap(ColormapPtr cmap)
 	return;
 if (pPriv->installedMap)
 	WalkTree(pPriv->installedMap->pScreen, TellLostMap,
-		 (pointer) &(pPriv->installedMap->mid));
+		 (void *) &(pPriv->installedMap->mid));
 
 if (pPriv->class & DynamicClass) {
 if ((cmap->pVisual->class | DynamicClass) == DirectColor) {
@@ -395,7 +395,7 @@ x68kInstallColormap(ColormapPtr cmap)
 x68kUpdateColormap(cmap->pScreen, 0, 1<<(pPriv->depth), rmap, gmap, bmap);
 }
 pPriv->installedMap = cmap;
-WalkTree(cmap->pScreen, TellGainedMap, (pointer) &(cmap->mid));
+WalkTree(cmap->pScreen, TellGainedMap, (void *) &(cmap->mid));
 }
 
 /*-
@@ -414,7 +414,7 @@ x68kUninstallColormap(ColormapPtr cmap)
 	Colormap defMapID = cmap->pScreen->defColormap;
 
 	if (cmap->mid != defMapID) {
-	pointer retval;
+	void *retval;
 	ColormapPtr defMap;
 	dixLookupResourceByType(, defMapID, RT_COLORMAP,
 		serverClient, DixReadAccess);
Index: xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kMouse.c
diff -u xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kMouse.c:1.6 xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kMouse.c:1.7
--- xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kMouse.c:1.6	Sat Aug  1 20:09:03 2020
+++ xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kMouse.c	Sat Aug  1 20:21:00 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: x68kMouse.c,v 1.6 2020/08/01 20:09:03 tsutsui Exp $ */
+/* $NetBSD: x68kMouse.c,v 1.7 2020/08/01 20:21:00 tsutsui Exp $ */
 /*-
  * Copyright (c) 1996 Yasushi Yamasaki
  * All rights reserved.
@@ -131,7 +131,7 @@ x68kMouseProc(DeviceIntPtr device, int w
 
 switch (what) {
 	case DEVICE_INIT:
-pMouse->devicePrivate = (pointer) 
+pMouse->devicePrivate = (void *) 
 if( (x68kMousePriv.fd = open("/dev/mouse", O_RDONLY)) == -1 ) {
 ErrorF("Can't open mouse device");
 return !Success;

Index: xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kKbd.c
diff -u xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kKbd.c:1.7 xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kKbd.c:1.8
--- 

CVS commit: xsrc/external/mit

2020-08-01 Thread Izumi Tsutsui
Module Name:xsrc
Committed By:   tsutsui
Date:   Sat Aug  1 20:09:03 UTC 2020

Modified Files:
xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k: X68k.man
x68kConfig.c x68kFb.c x68kGraph.c x68kInit.c x68kIo.c x68kKbd.c
x68kKeyMap.c x68kMouse.c x68kReg.h x68kText.c
xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k: X68k.man
x68kConfig.c x68kFb.c x68kGraph.c x68kInit.c x68kIo.c x68kKbd.c
x68kKeyMap.c x68kMouse.c x68kReg.h x68kText.c

Log Message:
TAB/space cleanup.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 \
xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/X68k.man
cvs rdiff -u -r1.2 -r1.3 \
xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kConfig.c \
xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kFb.c \
xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kGraph.c \
xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kIo.c \
xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kKeyMap.c \
xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kMouse.c \
xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kReg.h \
xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kText.c
cvs rdiff -u -r1.3 -r1.4 \
xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kInit.c \
xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kKbd.c
cvs rdiff -u -r1.1 -r1.2 \
xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/X68k.man
cvs rdiff -u -r1.4 -r1.5 \
xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kConfig.c
cvs rdiff -u -r1.3 -r1.4 \
xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kFb.c \
xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kText.c
cvs rdiff -u -r1.5 -r1.6 \
xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kGraph.c \
xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kMouse.c
cvs rdiff -u -r1.7 -r1.8 \
xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kInit.c
cvs rdiff -u -r1.2 -r1.3 \
xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kIo.c \
xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kKeyMap.c \
xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kReg.h
cvs rdiff -u -r1.6 -r1.7 \
xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kKbd.c

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

Modified files:

Index: xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/X68k.man
diff -u xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/X68k.man:1.1.1.1 xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/X68k.man:1.2
--- xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/X68k.man:1.1.1.1	Thu Jun  9 09:07:59 2016
+++ xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/X68k.man	Sat Aug  1 20:09:03 2020
@@ -1,4 +1,4 @@
-.\" $NetBSD: X68k.man,v 1.1.1.1 2016/06/09 09:07:59 mrg Exp $
+.\" $NetBSD: X68k.man,v 1.2 2020/08/01 20:09:03 tsutsui Exp $
 .\"
 .\" Copyright (c) 1998 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -39,7 +39,7 @@
 .Sh DESCRIPTION
 .Nm
 is the server for Version 11 of the X Window System on X68k hardware
-running 
+running
 .Nx .
 It will normally be started by the
 .Xr xdm 1
@@ -121,7 +121,7 @@ is either
 or
 .Fa Graphic ,
 and specifies the screen to be used by this mode.  Note that the type
-Graphic requires the 
+Graphic requires the
 .Pa /dev/grf1
 device driver configured in your kernel.
 
@@ -142,7 +142,7 @@ are the size of the screen by pixel.
 Remaining arguments are set to the registers of the CRT controler
 and the video controler of the x68k.
 Be carefull to change these values, or it may
-DAMAGE THE DISPLAY HARDWARE!! 
+DAMAGE THE DISPLAY HARDWARE!!
 
 .It Fn Mode
 One argument
@@ -155,7 +155,7 @@ function.
 .It Fn Mouse
 One argument
 .Fa type
-is required.  Specify the pointing device type; currently 
+is required.  Specify the pointing device type; currently
 .Fa standard
 is the only acceptable argument.
 .It Fn Keyboard

Index: xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kConfig.c
diff -u xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kConfig.c:1.2 xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kConfig.c:1.3
--- xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kConfig.c:1.2	Fri Apr 10 16:49:36 2020
+++ xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kConfig.c	Sat Aug  1 20:09:03 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: x68kConfig.c,v 1.2 2020/04/10 16:49:36 tsutsui Exp $ */
+/* $NetBSD: x68kConfig.c,v 1.3 2020/08/01 20:09:03 tsutsui Exp $ */
 /*-
  * Copyright (c) 1996 Yasushi Yamasaki
  * All rights reserved.
@@ -61,7 +61,7 @@ X68kScreenRec *
 x68kGetScreenRecByType(int type)
 {
 int i;
-
+
 for (i = 0; i < X68K_FB_TYPES; i++) {
 if (x68kScreen[i].type == type)
 return [i];
@@ 

CVS commit: src/usr.bin/make

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 19:19:06 UTC 2020

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

Log Message:
make(1): start nesting level in ApplyModifier_Match at 0

There is no need to start at 1, and starting at 0 generates smaller code
on x86_64.  Reordering the --nest and the following break would increase
the code size though, for unknown reasons.


To generate a diff of this commit:
cvs rdiff -u -r1.386 -r1.387 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.386 src/usr.bin/make/var.c:1.387
--- src/usr.bin/make/var.c:1.386	Sat Aug  1 18:36:49 2020
+++ src/usr.bin/make/var.c	Sat Aug  1 19:19:05 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.386 2020/08/01 18:36:49 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.387 2020/08/01 19:19:05 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.386 2020/08/01 18:36:49 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.387 2020/08/01 19:19:05 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.386 2020/08/01 18:36:49 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.387 2020/08/01 19:19:05 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2273,9 +2273,9 @@ ApplyModifier_Match(const char *mod, App
  * original brace level.
  * XXX This will likely not work right if $() and ${} are intermixed.
  */
-int nest = 1;
+int nest = 0;
 const char *p;
-for (p = mod + 1; *p != '\0' && !(*p == ':' && nest == 1); p++) {
+for (p = mod + 1; *p != '\0' && !(*p == ':' && nest == 0); p++) {
 	if (*p == '\\' &&
 	(p[1] == ':' || p[1] == st->endc || p[1] == st->startc)) {
 	if (!needSubst)
@@ -2289,7 +2289,7 @@ ApplyModifier_Match(const char *mod, App
 	++nest;
 	if (*p == ')' || *p == '}') {
 	--nest;
-	if (nest == 0)
+	if (nest < 0)
 		break;
 	}
 }



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

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 18:59:17 UTC 2020

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

Log Message:
make(1): add test for inconsistent interpretation of :M and :N modifiers


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/modmatch.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/modmatch.mk
diff -u src/usr.bin/make/unit-tests/modmatch.mk:1.6 src/usr.bin/make/unit-tests/modmatch.mk:1.7
--- src/usr.bin/make/unit-tests/modmatch.mk:1.6	Mon Jun 15 14:46:28 2020
+++ src/usr.bin/make/unit-tests/modmatch.mk	Sat Aug  1 18:59:16 2020
@@ -1,3 +1,6 @@
+# $NetBSD: modmatch.mk,v 1.7 2020/08/01 18:59:16 rillig Exp $
+#
+# Tests for the :M and :S modifiers.
 
 X=a b c d e
 
@@ -37,3 +40,18 @@ check-cclass:
 # calling itself 601080390 times for 16 asterisks.
 slow: .PHONY
 	@:;: ${:U:Mb:Q}
+
+# As of 2020-08-01, the :M and :N modifiers interpret backslashes differently,
+# depending on whether there was a variable expression before the first
+# backslash or not.  This can be seen by setting the -dv debug flag, in the
+# lines starting with "Pattern".
+#
+# Apart from the different and possibly confusing debug output, there is no
+# difference in behavior.  When parsing the modifier text, only \{, \} and \:
+# are unescaped, and in the pattern matching these have the same meaning as
+# their plain variants '{', '}' and ':'.  In the pattern matching from
+# Str_Match, only \*, \? or \[ would make a noticeable difference.
+SPECIALS=	\: : \\ * \*
+.if ${SPECIALS:M${:U}\:} != ${SPECIALS:M\:${:U}}
+.warning unexpected
+.endif



CVS commit: src/usr.bin/make

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 18:36:49 UTC 2020

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

Log Message:
make(1): inline and untangle the code for the :range modifier

There's no need to keep the result from brk_string in memory until the
buffer has been filled with the range.  The only thing necessary from
brk_string is the number of words.


To generate a diff of this commit:
cvs rdiff -u -r1.385 -r1.386 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.385 src/usr.bin/make/var.c:1.386
--- src/usr.bin/make/var.c:1.385	Sat Aug  1 18:14:08 2020
+++ src/usr.bin/make/var.c	Sat Aug  1 18:36:49 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.385 2020/08/01 18:14:08 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.386 2020/08/01 18:36:49 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.385 2020/08/01 18:14:08 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.386 2020/08/01 18:36:49 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.385 2020/08/01 18:14:08 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.386 2020/08/01 18:36:49 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1720,47 +1720,6 @@ VarUniq(const char *str)
 return Buf_Destroy(, FALSE);
 }
 
-/*-
- *---
- * VarRange --
- *	Return an integer sequence
- *
- * Input:
- *	str		String whose words provide default range
- *	ac		range length, if 0 use str words
- *
- * Side Effects:
- *	None.
- *
- *---
- */
-static char *
-VarRange(const char *str, int ac)
-{
-Buffer	  buf;		/* Buffer for new string */
-char 	**av;		/* List of words to affect */
-char 	 *as;		/* Word list memory */
-int 	  i;
-
-Buf_Init(, 0);
-if (ac > 0) {
-	as = NULL;
-	av = NULL;
-} else {
-	av = brk_string(str, , FALSE, );
-}
-for (i = 0; i < ac; i++) {
-	if (i != 0)
-	Buf_AddByte(, ' ');
-	Buf_AddInt(, 1 + i);
-}
-
-free(as);
-free(av);
-
-return Buf_Destroy(, FALSE);
-}
-
 
 /*-
  * Parse a text part of a modifier such as the "from" and "to" in :S/from/to/
@@ -2264,7 +2223,8 @@ ApplyModifier_Exclam(const char *mod, Ap
 return AMR_OK;
 }
 
-/* :range */
+/* The :range modifier generates an integer sequence as long as the words.
+ * The :range=7 modifier generates an integer sequence from 1 to 7. */
 static ApplyModifierResult
 ApplyModifier_Range(const char *mod, ApplyModifiersState *st)
 {
@@ -2280,7 +2240,25 @@ ApplyModifier_Range(const char *mod, App
 	n = 0;
 	st->next = mod + 5;
 }
-st->newVal = VarRange(st->val, n);
+
+if (n == 0) {
+	char *as;
+	char **av = brk_string(st->val, , FALSE, );
+	free(as);
+	free(av);
+}
+
+Buffer buf;
+Buf_Init(, 0);
+
+int i;
+for (i = 0; i < n; i++) {
+	if (i != 0)
+	Buf_AddByte(, ' ');
+	Buf_AddInt(, 1 + i);
+}
+
+st->newVal = Buf_Destroy(, FALSE);
 return AMR_OK;
 }
 



CVS commit: src/usr.bin/make

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 18:14:09 UTC 2020

Modified Files:
src/usr.bin/make: var.c
src/usr.bin/make/unit-tests: Makefile modmisc.exp

Log Message:
make(1): fix error message when regcomp fails

If regcomp fails, it's not the regex substitution that is erroneous, but
the regex compilation.


To generate a diff of this commit:
cvs rdiff -u -r1.384 -r1.385 src/usr.bin/make/var.c
cvs rdiff -u -r1.79 -r1.80 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/make/unit-tests/modmisc.exp

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.384 src/usr.bin/make/var.c:1.385
--- src/usr.bin/make/var.c:1.384	Sat Aug  1 18:02:37 2020
+++ src/usr.bin/make/var.c	Sat Aug  1 18:14:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.384 2020/08/01 18:02:37 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.385 2020/08/01 18:14:08 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.384 2020/08/01 18:02:37 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.385 2020/08/01 18:14:08 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.384 2020/08/01 18:02:37 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.385 2020/08/01 18:14:08 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2476,7 +2476,7 @@ ApplyModifier_Regex(const char *mod, App
 int error = regcomp(, re, REG_EXTENDED);
 free(re);
 if (error) {
-	VarREError(error, , "RE substitution error");
+	VarREError(error, , "Regex compilation error");
 	free(args.replace);
 	return AMR_CLEANUP;
 }

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.79 src/usr.bin/make/unit-tests/Makefile:1.80
--- src/usr.bin/make/unit-tests/Makefile:1.79	Sat Aug  1 15:28:28 2020
+++ src/usr.bin/make/unit-tests/Makefile	Sat Aug  1 18:14:08 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.79 2020/08/01 15:28:28 rillig Exp $
+# $NetBSD: Makefile,v 1.80 2020/08/01 18:14:08 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -98,8 +98,8 @@ FLAGS.order=		-j1
 FLAGS.vardebug=		-k -dv FROM_CMDLINE=
 
 # Some tests need extra post-processing.
-SED_CMDS.moderrs+=	-e 's,\(substitution error:\).*,\1 (details omitted),'
-SED_CMDS.modmisc+=	-e 's,\(substitution error:\).*,\1 (details omitted),'
+SED_CMDS.moderrs+=	-e 's,\(Regex compilation error:\).*,\1 (details omitted),'
+SED_CMDS.modmisc+=	-e 's,\(Regex compilation error:\).*,\1 (details omitted),'
 SED_CMDS.varmod-edge+=	-e 's, line [0-9]*:, line omitted:,'
 SED_CMDS.varshell+=	-e 's,^[a-z]*sh: ,,'
 SED_CMDS.varshell+=	-e '/command/s,No such.*,not found,'

Index: src/usr.bin/make/unit-tests/modmisc.exp
diff -u src/usr.bin/make/unit-tests/modmisc.exp:1.34 src/usr.bin/make/unit-tests/modmisc.exp:1.35
--- src/usr.bin/make/unit-tests/modmisc.exp:1.34	Sat Aug  1 17:20:42 2020
+++ src/usr.bin/make/unit-tests/modmisc.exp	Sat Aug  1 18:14:08 2020
@@ -31,7 +31,7 @@ mod-regex:
 :a b b c:
 :a b b c:
 : b c:
-make: RE substitution error: (details omitted)
+make: Regex compilation error: (details omitted)
 :C,word,,:Q}:
 :a c:
 :x__ 3 x__ 3:
@@ -75,7 +75,7 @@ make: No subexpression \2
 mod-regex-limits:22-missing:1 6
 mod-regex-limits:22-ok:1 33 556
 mod-regex-limits:capture:ihgfedcbaabcdefghijABCDEFGHIJa0a1a2rest
-make: RE substitution error: (details omitted)
+make: Regex compilation error: (details omitted)
 mod-regex-errors:
 mod-assign: first=1.
 mod-assign: last=3.



CVS commit: src/usr.bin/make

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 18:02:37 UTC 2020

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

Log Message:
make(1): use enum for return values of Cond_Eval and friends


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.86 src/usr.bin/make/cond.c
cvs rdiff -u -r1.112 -r1.113 src/usr.bin/make/make.h
cvs rdiff -u -r1.88 -r1.89 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.383 -r1.384 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/cond.c
diff -u src/usr.bin/make/cond.c:1.85 src/usr.bin/make/cond.c:1.86
--- src/usr.bin/make/cond.c:1.85	Sat Aug  1 14:47:49 2020
+++ src/usr.bin/make/cond.c	Sat Aug  1 18:02:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.85 2020/08/01 14:47:49 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.86 2020/08/01 18:02:37 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: cond.c,v 1.85 2020/08/01 14:47:49 rillig Exp $";
+static char rcsid[] = "$NetBSD: cond.c,v 1.86 2020/08/01 18:02:37 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)cond.c	8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: cond.c,v 1.85 2020/08/01 14:47:49 rillig Exp $");
+__RCSID("$NetBSD: cond.c,v 1.86 2020/08/01 18:02:37 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -158,7 +158,7 @@ static Token CondToken(Boolean);
 static Token CondT(Boolean);
 static Token CondF(Boolean);
 static Token CondE(Boolean);
-static int do_Cond_EvalExpression(Boolean *);
+static CondEvalResult do_Cond_EvalExpression(Boolean *);
 
 static const struct If {
 const char	*form;	  /* Form of if */
@@ -1147,7 +1147,7 @@ CondE(Boolean doEval)
  *
  *---
  */
-int
+CondEvalResult
 Cond_EvalExpression(const struct If *info, char *line, Boolean *value, int eprint, Boolean strictLHS)
 {
 static const struct If *dflt_info;
@@ -1186,7 +1186,7 @@ Cond_EvalExpression(const struct If *inf
 return rval;
 }
 
-static int
+static CondEvalResult
 do_Cond_EvalExpression(Boolean *value)
 {
 
@@ -1231,16 +1231,12 @@ do_Cond_EvalExpression(Boolean *value)
  *	COND_SKIP	if should skip lines after the conditional
  *	COND_INVALID  	if not a valid conditional.
  *
- * Side Effects:
- *	None.
- *
  * Note that the states IF_ACTIVE and ELSE_ACTIVE are only different in order
- * to detect splurious .else lines (as are SKIP_TO_ELSE and SKIP_TO_ENDIF)
+ * to detect spurious .else lines (as are SKIP_TO_ELSE and SKIP_TO_ENDIF),
  * otherwise .else could be treated as '.elif 1'.
- *
  *---
  */
-int
+CondEvalResult
 Cond_Eval(char *line)
 {
 #define	MAXIF  128	/* maximum depth of .if'ing */

Index: src/usr.bin/make/make.h
diff -u src/usr.bin/make/make.h:1.112 src/usr.bin/make/make.h:1.113
--- src/usr.bin/make/make.h:1.112	Fri Jul 31 20:22:10 2020
+++ src/usr.bin/make/make.h	Sat Aug  1 18:02:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.h,v 1.112 2020/07/31 20:22:10 sjg Exp $	*/
+/*	$NetBSD: make.h,v 1.113 2020/08/01 18:02:37 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -337,9 +337,11 @@ typedef struct GNode {
 /*
  * Values returned by Cond_Eval.
  */
-#define COND_PARSE	0   	/* Parse the next lines */
-#define COND_SKIP 	1   	/* Skip the next lines */
-#define COND_INVALID	2   	/* Not a conditional statement */
+typedef enum {
+COND_PARSE,			/* Parse the next lines */
+COND_SKIP,			/* Skip the next lines */
+COND_INVALID		/* Not a conditional statement */
+} CondEvalResult;
 
 /*
  * Definitions for the "local" variables. Used only for clarity.

Index: src/usr.bin/make/nonints.h
diff -u src/usr.bin/make/nonints.h:1.88 src/usr.bin/make/nonints.h:1.89
--- src/usr.bin/make/nonints.h:1.88	Sat Aug  1 09:25:36 2020
+++ src/usr.bin/make/nonints.h	Sat Aug  1 18:02:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nonints.h,v 1.88 2020/08/01 09:25:36 rillig Exp $	*/
+/*	$NetBSD: nonints.h,v 1.89 2020/08/01 18:02:37 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -91,8 +91,8 @@ int Compat_Make(void *, void *);
 
 /* cond.c */
 struct If;
-int Cond_EvalExpression(const struct If *, char *, Boolean *, int, Boolean);
-int Cond_Eval(char *);
+CondEvalResult Cond_EvalExpression(const struct If *, char *, Boolean *, int, Boolean);
+CondEvalResult Cond_Eval(char *);
 void Cond_restore_depth(unsigned int);
 unsigned int Cond_save_depth(void);
 

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.383 src/usr.bin/make/var.c:1.384
--- src/usr.bin/make/var.c:1.383	Sat Aug  1 17:29:00 2020
+++ src/usr.bin/make/var.c	Sat Aug  1 18:02:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.383 2020/08/01 17:29:00 rillig Exp $	*/
+/*	

CVS commit: src/bin/sh

2020-08-01 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sat Aug  1 17:56:56 UTC 2020

Modified Files:
src/bin/sh: expand.c

Log Message:
Remove a redundant set of parentheses that were added (along with a
extra && or || or something ... forgotten now) as part a failed attempt
to fix an earlier bug (later fixed a better way) - when the extra
test (never committed) was removed, the now-redundant parentheses got
forgotten...

NFC.


To generate a diff of this commit:
cvs rdiff -u -r1.137 -r1.138 src/bin/sh/expand.c

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

Modified files:

Index: src/bin/sh/expand.c
diff -u src/bin/sh/expand.c:1.137 src/bin/sh/expand.c:1.138
--- src/bin/sh/expand.c:1.137	Thu Feb 13 05:19:05 2020
+++ src/bin/sh/expand.c	Sat Aug  1 17:56:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: expand.c,v 1.137 2020/02/13 05:19:05 kre Exp $	*/
+/*	$NetBSD: expand.c,v 1.138 2020/08/01 17:56:56 kre Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)expand.c	8.5 (Berkeley) 5/15/95";
 #else
-__RCSID("$NetBSD: expand.c,v 1.137 2020/02/13 05:19:05 kre Exp $");
+__RCSID("$NetBSD: expand.c,v 1.138 2020/08/01 17:56:56 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -309,7 +309,7 @@ argstr(const char *p, int flag)
 			had_dol_at = 0;
 			break;
 		case CTLESC:
-			if ((quotes || ISCTL(*p)))
+			if (quotes || ISCTL(*p))
 STPUTC(c, expdest);
 			c = *p++;
 			STPUTC(c, expdest);



CVS commit: src/usr.bin/w

2020-08-01 Thread Kimmo Suominen
Module Name:src
Committed By:   kim
Date:   Sat Aug  1 17:53:38 UTC 2020

Modified Files:
src/usr.bin/w: w.c

Log Message:
Skip bracket processing if -n is used.

XXX: This could be improved to skip even more processing.


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 src/usr.bin/w/w.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/w/w.c
diff -u src/usr.bin/w/w.c:1.89 src/usr.bin/w/w.c:1.90
--- src/usr.bin/w/w.c:1.89	Sat Aug  1 17:25:57 2020
+++ src/usr.bin/w/w.c	Sat Aug  1 17:53:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: w.c,v 1.89 2020/08/01 17:25:57 kim Exp $	*/
+/*	$NetBSD: w.c,v 1.90 2020/08/01 17:53:38 kim Exp $	*/
 
 /*-
  * Copyright (c) 1980, 1991, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)w.c	8.6 (Berkeley) 6/30/94";
 #else
-__RCSID("$NetBSD: w.c,v 1.89 2020/08/01 17:25:57 kim Exp $");
+__RCSID("$NetBSD: w.c,v 1.90 2020/08/01 17:53:38 kim Exp $");
 #endif
 #endif /* not lint */
 
@@ -654,7 +654,7 @@ fixhost(struct entry *ep)
 	 * Leading '[' indicates an IP address inside brackets.
 	 */
 	b = NULL;
-	if (*p == '[') {
+	if (!nflag && (*p == '[')) {
 		for (b = p++; b < _buf[sizeof(host_buf)]; b++)
 			if (*b == '\0' || *b == ']')
 break;



CVS commit: src/bin/sh

2020-08-01 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sat Aug  1 17:51:18 UTC 2020

Modified Files:
src/bin/sh: exec.c

Log Message:
PR bin/55526

Fix a bug that has existed since the "command" command was added in
2003.   "command foo" would cause the definition of a function "foo"
to be lost (not freed, simply discarded) if "foo" is (in addition to
being a function) a filesystem command.   The case where "foo" is
a builtin was handled.

For now, when a function exists with the same name as a filesystem
command, the latter can never appear in the command hash table, and
when used (which can only be via "command foo", just "foo" finds
the function) will always result in a full PATH search.

XXX pullup everything (from NetBSD 2.0 onwards).   (really -8 and -9)


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/bin/sh/exec.c

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

Modified files:

Index: src/bin/sh/exec.c
diff -u src/bin/sh/exec.c:1.53 src/bin/sh/exec.c:1.54
--- src/bin/sh/exec.c:1.53	Wed Jul 25 14:42:50 2018
+++ src/bin/sh/exec.c	Sat Aug  1 17:51:18 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec.c,v 1.53 2018/07/25 14:42:50 kre Exp $	*/
+/*	$NetBSD: exec.c,v 1.54 2020/08/01 17:51:18 kre Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)exec.c	8.4 (Berkeley) 6/8/95";
 #else
-__RCSID("$NetBSD: exec.c,v 1.53 2018/07/25 14:42:50 kre Exp $");
+__RCSID("$NetBSD: exec.c,v 1.54 2020/08/01 17:51:18 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -667,6 +667,10 @@ loop:
 			cmdp = _cmd;
 		} else
 			cmdp = cmdlookup(name, 1);
+
+		if (cmdp->cmdtype == CMDFUNCTION)
+			cmdp = _cmd;
+
 		cmdp->cmdtype = CMDNORMAL;
 		cmdp->param.index = idx;
 		INTON;



CVS commit: src/usr.bin/make

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 17:45:32 UTC 2020

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

Log Message:
make(1): fix parameter name in Cmd_Exec

A format string is not a number.


To generate a diff of this commit:
cvs rdiff -u -r1.292 -r1.293 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.292 src/usr.bin/make/main.c:1.293
--- src/usr.bin/make/main.c:1.292	Sat Aug  1 14:52:14 2020
+++ src/usr.bin/make/main.c	Sat Aug  1 17:45:32 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.292 2020/08/01 14:52:14 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.293 2020/08/01 17:45:32 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.292 2020/08/01 14:52:14 rillig Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.293 2020/08/01 17:45:32 rillig Exp $";
 #else
 #include 
 #ifndef lint
@@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #if 0
 static char sccsid[] = "@(#)main.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.292 2020/08/01 14:52:14 rillig Exp $");
+__RCSID("$NetBSD: main.c,v 1.293 2020/08/01 17:45:32 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1581,14 +1581,15 @@ found:
  *	in a string.
  *
  * Results:
- *	A string containing the output of the command, or the empty string
- *	If errnum is not NULL, it contains the reason for the command failure
+ *	A string containing the output of the command, or the empty string.
+ *	*errfmt returns a format string describing the command failure,
+ *	if any, using a single %s conversion specification.
  *
  * Side Effects:
  *	The string must be freed by the caller.
  */
 char *
-Cmd_Exec(const char *cmd, const char **errnum)
+Cmd_Exec(const char *cmd, const char **errfmt)
 {
 const char	*args[4];   	/* Args for invoking the shell */
 int 	fds[2];		/* Pipe streams */
@@ -1602,7 +1603,7 @@ Cmd_Exec(const char *cmd, const char **e
 int		savederr;	/* saved errno */
 
 
-*errnum = NULL;
+*errfmt = NULL;
 
 if (!shellName)
 	Shell_Init();
@@ -1618,7 +1619,7 @@ Cmd_Exec(const char *cmd, const char **e
  * Open a pipe for fetching its output
  */
 if (pipe(fds) == -1) {
-	*errnum = "Couldn't create pipe for \"%s\"";
+	*errfmt = "Couldn't create pipe for \"%s\"";
 	goto bad;
 }
 
@@ -1647,7 +1648,7 @@ Cmd_Exec(const char *cmd, const char **e
 	/*NOTREACHED*/
 
 case -1:
-	*errnum = "Couldn't exec \"%s\"";
+	*errfmt = "Couldn't exec \"%s\"";
 	goto bad;
 
 default:
@@ -1685,12 +1686,12 @@ Cmd_Exec(const char *cmd, const char **e
 	res = Buf_Destroy(, FALSE);
 
 	if (savederr != 0)
-	*errnum = "Couldn't read shell's output for \"%s\"";
+	*errfmt = "Couldn't read shell's output for \"%s\"";
 
 	if (WIFSIGNALED(status))
-	*errnum = "\"%s\" exited on a signal";
+	*errfmt = "\"%s\" exited on a signal";
 	else if (WEXITSTATUS(status) != 0)
-	*errnum = "\"%s\" returned non-zero status";
+	*errfmt = "\"%s\" returned non-zero status";
 
 	/*
 	 * Null-terminate the result, convert newlines to spaces and
@@ -1715,9 +1716,7 @@ Cmd_Exec(const char *cmd, const char **e
 }
 return res;
 bad:
-res = bmake_malloc(1);
-*res = '\0';
-return res;
+return bmake_strdup("");
 }
 
 /*-



CVS commit: src/usr.bin/script

2020-08-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Aug  1 17:31:06 UTC 2020

Modified Files:
src/usr.bin/script: script.c

Log Message:
PR/55529: Soumendra Ganguly: configure the terminal in raw mode during
playback so that output postprocessing is not done and playback of programs
using curses does not appear corrupted.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/script/script.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/script/script.c
diff -u src/usr.bin/script/script.c:1.21 src/usr.bin/script/script.c:1.22
--- src/usr.bin/script/script.c:1.21	Tue Sep  6 14:29:56 2011
+++ src/usr.bin/script/script.c	Sat Aug  1 13:31:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: script.c,v 1.21 2011/09/06 18:29:56 joerg Exp $	*/
+/*	$NetBSD: script.c,v 1.22 2020/08/01 17:31:06 christos Exp $	*/
 
 /*
  * Copyright (c) 1980, 1992, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)script.c	8.1 (Berkeley) 6/6/93";
 #endif
-__RCSID("$NetBSD: script.c,v 1.21 2011/09/06 18:29:56 joerg Exp $");
+__RCSID("$NetBSD: script.c,v 1.22 2020/08/01 17:31:06 christos Exp $");
 #endif /* not lint */
 
 #include 
@@ -81,6 +81,7 @@ static int	usesleep, rawout;
 static int	quiet, flush;
 static const char *fname;
 
+static int	isterm;
 static struct	termios tt;
 
 __dead static void	done(void);
@@ -356,6 +357,34 @@ consume(FILE *fp, off_t len, char *buf, 
 } while (0/*CONSTCOND*/)
 
 static void
+termset(void)
+{
+	struct termios traw;
+
+	isterm = isatty(STDOUT_FILENO);
+	if (!isterm)
+		return;
+
+	if (tcgetattr(STDOUT_FILENO, ) != 0)
+		err(1, "tcgetattr");
+
+	traw = tt;
+	cfmakeraw();
+	traw.c_lflag |= ISIG;
+	if (tcsetattr(STDOUT_FILENO, TCSANOW, ) != 0)
+		err(1, "tcsetattr");
+}
+
+static void
+termreset(void)
+{
+	if (isterm)
+		tcsetattr(STDOUT_FILENO, TCSADRAIN, );
+
+	isterm = 0;
+}
+
+static void
 playback(FILE *fp)
 {
 	struct timespec tsi, tso;
@@ -398,6 +427,8 @@ playback(FILE *fp)
 ctime());
 			tsi = tso;
 			(void)consume(fp, stamp.scr_len, buf, reg);
+			termset();
+			atexit(termreset);
 			break;
 		case 'e':
 			if (!quiet)



CVS commit: src/usr.bin/make

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 17:29:00 UTC 2020

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

Log Message:
make(1): fix documentation, use safer fallback value

The variable res is overwritten in every case, but better be safe than
sorry.  In case of programming errors it's better to issue an error
message than to continue.


To generate a diff of this commit:
cvs rdiff -u -r1.382 -r1.383 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.382 src/usr.bin/make/var.c:1.383
--- src/usr.bin/make/var.c:1.382	Sat Aug  1 16:27:03 2020
+++ src/usr.bin/make/var.c	Sat Aug  1 17:29:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.382 2020/08/01 16:27:03 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.383 2020/08/01 17:29:00 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.382 2020/08/01 16:27:03 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.383 2020/08/01 17:29:00 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.382 2020/08/01 16:27:03 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.383 2020/08/01 17:29:00 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -3008,14 +3008,14 @@ ApplyModifier_SysV(const char *mod, Appl
  *
  *	  :?:
  *			If the variable evaluates to true, return
- *			true value, else return the second value.
- *	  :lhs=rhs  	Like :S, but the rhs goes to the end of
- *			the invocation.
+ *			true-value, else return false-value.
+ *	  :lhs=rhs  	Similar to :S, but the rhs goes to the end of
+ *			the invocation, including any ':'.
  *	  :sh		Treat the current value as a command
  *			to be run, new value is its output.
  * The following added so we can handle ODE makefiles.
  *	  :@@@
- *			Assign a temporary local variable 
+ *			Assign a temporary global variable 
  *			to the current value of each word in turn
  *			and replace each word with the result of
  *			evaluating 
@@ -3028,7 +3028,7 @@ ApplyModifier_SysV(const char *mod, Appl
  *			the common method of refering to the path
  *			of your dependent 'x' in a rule is to use
  *			the form '${x:P}'.
- *	  :!!	Run cmd much the same as :sh run's the
+ *	  :!!	Run cmd much the same as :sh runs the
  *			current value of the variable.
  * Assignment operators (see ApplyModifier_Assign).
  */
@@ -3110,7 +3110,7 @@ ApplyModifiers(
 	}
 	st.newVal = var_Error;		/* default value, in case of errors */
 	st.next = NULL; /* fail fast if an ApplyModifier forgets to set this */
-	ApplyModifierResult res = 0;
+	ApplyModifierResult res = AMR_BAD;	/* just a safe fallback */
 	char modifier = *p;
 	switch (modifier) {
 	case ':':



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

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 17:26:41 UTC 2020

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

Log Message:
make(1): add test for empty indirect modifier


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/usr.bin/make/unit-tests/modmisc.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/modmisc.mk
diff -u src/usr.bin/make/unit-tests/modmisc.mk:1.31 src/usr.bin/make/unit-tests/modmisc.mk:1.32
--- src/usr.bin/make/unit-tests/modmisc.mk:1.31	Sat Aug  1 17:20:42 2020
+++ src/usr.bin/make/unit-tests/modmisc.mk	Sat Aug  1 17:26:41 2020
@@ -1,4 +1,4 @@
-# $Id: modmisc.mk,v 1.31 2020/08/01 17:20:42 rillig Exp $
+# $Id: modmisc.mk,v 1.32 2020/08/01 17:26:41 rillig Exp $
 #
 # miscellaneous modifier tests
 
@@ -313,3 +313,12 @@ mod-range:
 .if ${value:L:${:US,a,A,}:${:US,e,E,}} != "vAluE"
 .warning unexpected
 .endif
+
+# An indirect variable that evaluates to the empty string is allowed though.
+# This makes it possible to define conditional modifiers, like this:
+#
+# M.little-endian=	S,1234,4321,
+# M.big-endian=		# none
+.if ${value:L:${:Dempty}S,a,A,} != "vAlue"
+.warning unexpected
+.endif



CVS commit: src/usr.bin/w

2020-08-01 Thread Kimmo Suominen
Module Name:src
Committed By:   kim
Date:   Sat Aug  1 17:25:57 UTC 2020

Modified Files:
src/usr.bin/w: w.c

Log Message:
Restore ']' if not using a result from an address lookup.


To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.89 src/usr.bin/w/w.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/w/w.c
diff -u src/usr.bin/w/w.c:1.88 src/usr.bin/w/w.c:1.89
--- src/usr.bin/w/w.c:1.88	Sat Aug  1 15:52:50 2020
+++ src/usr.bin/w/w.c	Sat Aug  1 17:25:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: w.c,v 1.88 2020/08/01 15:52:50 kim Exp $	*/
+/*	$NetBSD: w.c,v 1.89 2020/08/01 17:25:57 kim Exp $	*/
 
 /*-
  * Copyright (c) 1980, 1991, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)w.c	8.6 (Berkeley) 6/30/94";
 #else
-__RCSID("$NetBSD: w.c,v 1.88 2020/08/01 15:52:50 kim Exp $");
+__RCSID("$NetBSD: w.c,v 1.89 2020/08/01 17:25:57 kim Exp $");
 #endif
 #endif /* not lint */
 
@@ -621,7 +621,7 @@ static void
 fixhost(struct entry *ep)
 {
 	char host_buf[sizeof(ep->host)];
-	char *p, *r, *x, *m;
+	char *b, *m, *p, *r, *x;
 	struct hostent *hp;
 	union {
 		struct in_addr l4;
@@ -653,19 +653,20 @@ fixhost(struct entry *ep)
 	/*
 	 * Leading '[' indicates an IP address inside brackets.
 	 */
+	b = NULL;
 	if (*p == '[') {
-		for (p++; p < _buf[sizeof(host_buf)]; p++)
-			if (*p == '\0' || *p == ']')
+		for (b = p++; b < _buf[sizeof(host_buf)]; b++)
+			if (*b == '\0' || *b == ']')
 break;
-		if (p < _buf[sizeof(host_buf)] && *p == ']') {
-			*p = '\0';
-			for (x = ++p; x < _buf[sizeof(host_buf)]; x++)
+		if (b < _buf[sizeof(host_buf)] && *b == ']') {
+			*b = '\0';
+			for (x = b + 1; x < _buf[sizeof(host_buf)]; x++)
 if (*x == '\0' || *x == ':')
 	break;
 			if (x < _buf[sizeof(host_buf)] && *x == ':')
 *x++ = '\0';
-		}
-		p = host_buf + 1;
+		} else
+			b = NULL;
 	}
 
 	int af = m ? AF_INET6 : AF_INET;
@@ -673,8 +674,11 @@ fixhost(struct entry *ep)
 	if (!nflag && inet_pton(af, p, ) &&
 	(hp = gethostbyaddr((char *), alen, af)))
 		r = hp->h_name;
-	else
+	else {
+		if (b)
+			*b = ']';
 		r = host_buf;
+	}
 
 	if (domain[0] != '\0') {
 		p = r;



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

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 17:20:42 UTC 2020

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

Log Message:
make(1): add tests for indirect modifiers


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/usr.bin/make/unit-tests/modmisc.exp
cvs rdiff -u -r1.30 -r1.31 src/usr.bin/make/unit-tests/modmisc.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/modmisc.exp
diff -u src/usr.bin/make/unit-tests/modmisc.exp:1.33 src/usr.bin/make/unit-tests/modmisc.exp:1.34
--- src/usr.bin/make/unit-tests/modmisc.exp:1.33	Fri Jul 31 14:36:58 2020
+++ src/usr.bin/make/unit-tests/modmisc.exp	Sat Aug  1 17:20:42 2020
@@ -1,3 +1,4 @@
+make: Unknown modifier '$'
 path=':/bin:/tmp::/:.:/no/such/dir:.'
 path='/bin:/tmp:/:/no/such/dir'
 path='/bin:/tmp:/:/no/such/dir'

Index: src/usr.bin/make/unit-tests/modmisc.mk
diff -u src/usr.bin/make/unit-tests/modmisc.mk:1.30 src/usr.bin/make/unit-tests/modmisc.mk:1.31
--- src/usr.bin/make/unit-tests/modmisc.mk:1.30	Fri Jul 31 14:36:58 2020
+++ src/usr.bin/make/unit-tests/modmisc.mk	Sat Aug  1 17:20:42 2020
@@ -1,4 +1,4 @@
-# $Id: modmisc.mk,v 1.30 2020/07/31 14:36:58 rillig Exp $
+# $Id: modmisc.mk,v 1.31 2020/08/01 17:20:42 rillig Exp $
 #
 # miscellaneous modifier tests
 
@@ -296,3 +296,20 @@ mod-range:
 	@echo ${a b c:L:range}			# ok
 	@echo ${a b c:L:rango}			# misspelled
 	@echo ${a b c:L:ranger}			# modifier name too long
+
+# To apply a modifier indirectly via another variable, the whole
+# modifier must be put into a single variable.
+.if ${value:L:${:US}${:U,value,replacement,}} != "S,value,replacement,}"
+.warning unexpected
+.endif
+
+# Adding another level of indirection (the 2 nested :U expressions) helps.
+.if ${value:L:${:U${:US}${:U,value,replacement,}}} != "replacement"
+.warning unexpected
+.endif
+
+# Multiple indirect modifiers can be applied one after another as long as
+# they are separated with colons.
+.if ${value:L:${:US,a,A,}:${:US,e,E,}} != "vAluE"
+.warning unexpected
+.endif



CVS commit: src/usr.bin/make

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 16:27:03 UTC 2020

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

Log Message:
make(1): make ModifyWords simpler

There is no need to test whether an actual word has been added.  The
rule is simply "add a space before every word, except for the very
first".


To generate a diff of this commit:
cvs rdiff -u -r1.381 -r1.382 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.381 src/usr.bin/make/var.c:1.382
--- src/usr.bin/make/var.c:1.381	Sat Aug  1 15:03:43 2020
+++ src/usr.bin/make/var.c	Sat Aug  1 16:27:03 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.381 2020/08/01 15:03:43 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.382 2020/08/01 16:27:03 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.381 2020/08/01 15:03:43 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.382 2020/08/01 16:27:03 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.381 2020/08/01 15:03:43 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.382 2020/08/01 16:27:03 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1597,10 +1597,8 @@ ModifyWords(GNode *ctx, Byte sep, Boolea
 }
 
 for (i = 0; i < ac; i++) {
-	size_t orig_count = result.buf.count;
 	modifyWord(av[i], , data);
-	size_t count = result.buf.count;
-	if (count != orig_count)
+	if (result.buf.count > 0)
 	SepBuf_Sep();
 }
 



CVS commit: src/usr.bin/w

2020-08-01 Thread Kimmo Suominen
Module Name:src
Committed By:   kim
Date:   Sat Aug  1 15:52:50 UTC 2020

Modified Files:
src/usr.bin/w: w.c

Log Message:
Handle hostname from DISPLAY="[2001:db8::dead:beef]:0" or similar.


To generate a diff of this commit:
cvs rdiff -u -r1.87 -r1.88 src/usr.bin/w/w.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/w/w.c
diff -u src/usr.bin/w/w.c:1.87 src/usr.bin/w/w.c:1.88
--- src/usr.bin/w/w.c:1.87	Sat Jul  4 23:30:31 2020
+++ src/usr.bin/w/w.c	Sat Aug  1 15:52:50 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: w.c,v 1.87 2020/07/04 23:30:31 kim Exp $	*/
+/*	$NetBSD: w.c,v 1.88 2020/08/01 15:52:50 kim Exp $	*/
 
 /*-
  * Copyright (c) 1980, 1991, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)w.c	8.6 (Berkeley) 6/30/94";
 #else
-__RCSID("$NetBSD: w.c,v 1.87 2020/07/04 23:30:31 kim Exp $");
+__RCSID("$NetBSD: w.c,v 1.88 2020/08/01 15:52:50 kim Exp $");
 #endif
 #endif /* not lint */
 
@@ -650,6 +650,24 @@ fixhost(struct entry *ep)
 			x = NULL;
 	}
 
+	/*
+	 * Leading '[' indicates an IP address inside brackets.
+	 */
+	if (*p == '[') {
+		for (p++; p < _buf[sizeof(host_buf)]; p++)
+			if (*p == '\0' || *p == ']')
+break;
+		if (p < _buf[sizeof(host_buf)] && *p == ']') {
+			*p = '\0';
+			for (x = ++p; x < _buf[sizeof(host_buf)]; x++)
+if (*x == '\0' || *x == ':')
+	break;
+			if (x < _buf[sizeof(host_buf)] && *x == ':')
+*x++ = '\0';
+		}
+		p = host_buf + 1;
+	}
+
 	int af = m ? AF_INET6 : AF_INET;
 	size_t alen = m ? sizeof(l.l6) : sizeof(l.l4);
 	if (!nflag && inet_pton(af, p, ) &&



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

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 15:28:28 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: Makefile varmod-edge.exp varmod-edge.mk

Log Message:
make(1): improve output grouping in varmod-edge test

The generated error messages are now closer to the test cases that
produce them.  To keep the expected output stable, the line numbers are
omitted from the .info directives.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varmod-edge.exp
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/varmod-edge.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/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.78 src/usr.bin/make/unit-tests/Makefile:1.79
--- src/usr.bin/make/unit-tests/Makefile:1.78	Fri Jul 31 22:07:28 2020
+++ src/usr.bin/make/unit-tests/Makefile	Sat Aug  1 15:28:28 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.78 2020/07/31 22:07:28 rillig Exp $
+# $NetBSD: Makefile,v 1.79 2020/08/01 15:28:28 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -100,6 +100,7 @@ FLAGS.vardebug=		-k -dv FROM_CMDLINE=
 # Some tests need extra post-processing.
 SED_CMDS.moderrs+=	-e 's,\(substitution error:\).*,\1 (details omitted),'
 SED_CMDS.modmisc+=	-e 's,\(substitution error:\).*,\1 (details omitted),'
+SED_CMDS.varmod-edge+=	-e 's, line [0-9]*:, line omitted:,'
 SED_CMDS.varshell+=	-e 's,^[a-z]*sh: ,,'
 SED_CMDS.varshell+=	-e '/command/s,No such.*,not found,'
 

Index: src/usr.bin/make/unit-tests/varmod-edge.exp
diff -u src/usr.bin/make/unit-tests/varmod-edge.exp:1.6 src/usr.bin/make/unit-tests/varmod-edge.exp:1.7
--- src/usr.bin/make/unit-tests/varmod-edge.exp:1.6	Sat Aug  1 15:16:15 2020
+++ src/usr.bin/make/unit-tests/varmod-edge.exp	Sat Aug  1 15:28:28 2020
@@ -1,21 +1,22 @@
+make: "varmod-edge.mk" line omitted: ok M-paren
+make: "varmod-edge.mk" line omitted: ok M-mixed
+make: "varmod-edge.mk" line omitted: ok M-unescape
 make: Unclosed variable specification (expecting '}') for "" (value "*)") modifier U
+make: "varmod-edge.mk" line omitted: ok M-nest-mix
+make: "varmod-edge.mk" line omitted: ok M-nest-brk
+make: "varmod-edge.mk" line omitted: ok M-pat-err
+make: "varmod-edge.mk" line omitted: ok M-bsbs
+make: "varmod-edge.mk" line omitted: ok M-bs1-par
+make: "varmod-edge.mk" line omitted: ok M-bs2-par
+make: "varmod-edge.mk" line omitted: ok M-128
+make: "varmod-edge.mk" line omitted: ok eq-ext
+make: "varmod-edge.mk" line omitted: ok eq-q
+make: "varmod-edge.mk" line omitted: ok eq-bs
 make: Unclosed substitution for INP.eq-esc (= missing)
+make: "varmod-edge.mk" line omitted: ok eq-esc
+make: "varmod-edge.mk" line omitted: ok colon
 make: Unknown modifier ':'
 make: Unknown modifier ':'
-ok M-paren
-ok M-mixed
-ok M-unescape
-ok M-nest-mix
-ok M-nest-brk
-ok M-pat-err
-ok M-bsbs
-ok M-bs1-par
-ok M-bs2-par
-ok M-128
-ok eq-ext
-ok eq-q
-ok eq-bs
-ok eq-esc
-ok colon
-ok colons
+make: "varmod-edge.mk" line omitted: ok colons
+ok
 exit status 0

Index: src/usr.bin/make/unit-tests/varmod-edge.mk
diff -u src/usr.bin/make/unit-tests/varmod-edge.mk:1.10 src/usr.bin/make/unit-tests/varmod-edge.mk:1.11
--- src/usr.bin/make/unit-tests/varmod-edge.mk:1.10	Sat Aug  1 15:16:15 2020
+++ src/usr.bin/make/unit-tests/varmod-edge.mk	Sat Aug  1 15:28:28 2020
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-edge.mk,v 1.10 2020/08/01 15:16:15 rillig Exp $
+# $NetBSD: varmod-edge.mk,v 1.11 2020/08/01 15:28:28 rillig Exp $
 #
 # Tests for edge cases in variable modifiers.
 #
@@ -161,12 +161,13 @@ INP.colons=	value
 MOD.colons=	${INP.colons}
 EXP.colons=	# empty
 
-all:
 .for test in ${TESTS}
 .  if ${MOD.${test}} == ${EXP.${test}}
-	@printf 'ok %s\n' ${test:Q}''
+.info ok ${test}
 .  else
-	@printf 'error in %s: expected %s, got %s\n' \
-		${test:Q}'' ${EXP.${test}:Q}'' ${MOD.${test}:Q}''
+.warning error in ${test}: expected "${EXP.${test}}", got "${MOD.${test}}"
 .  endif
 .endfor
+
+all:
+	@echo ok



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

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 15:16:15 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: varmod-edge.exp varmod-edge.mk

Log Message:
make(1): add test for ${VAR}

It's a bit unrealistic, but at least there are good diagnostics.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-edge.exp
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/varmod-edge.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/varmod-edge.exp
diff -u src/usr.bin/make/unit-tests/varmod-edge.exp:1.5 src/usr.bin/make/unit-tests/varmod-edge.exp:1.6
--- src/usr.bin/make/unit-tests/varmod-edge.exp:1.5	Sat Aug  1 15:13:45 2020
+++ src/usr.bin/make/unit-tests/varmod-edge.exp	Sat Aug  1 15:16:15 2020
@@ -1,5 +1,7 @@
 make: Unclosed variable specification (expecting '}') for "" (value "*)") modifier U
 make: Unclosed substitution for INP.eq-esc (= missing)
+make: Unknown modifier ':'
+make: Unknown modifier ':'
 ok M-paren
 ok M-mixed
 ok M-unescape
@@ -15,4 +17,5 @@ ok eq-q
 ok eq-bs
 ok eq-esc
 ok colon
+ok colons
 exit status 0

Index: src/usr.bin/make/unit-tests/varmod-edge.mk
diff -u src/usr.bin/make/unit-tests/varmod-edge.mk:1.9 src/usr.bin/make/unit-tests/varmod-edge.mk:1.10
--- src/usr.bin/make/unit-tests/varmod-edge.mk:1.9	Sat Aug  1 15:13:45 2020
+++ src/usr.bin/make/unit-tests/varmod-edge.mk	Sat Aug  1 15:16:15 2020
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-edge.mk,v 1.9 2020/08/01 15:13:45 rillig Exp $
+# $NetBSD: varmod-edge.mk,v 1.10 2020/08/01 15:16:15 rillig Exp $
 #
 # Tests for edge cases in variable modifiers.
 #
@@ -156,6 +156,11 @@ INP.colon=	value
 MOD.colon=	${INP.colon:}
 EXP.colon=	value
 
+TESTS+=		colons
+INP.colons=	value
+MOD.colons=	${INP.colons}
+EXP.colons=	# empty
+
 all:
 .for test in ${TESTS}
 .  if ${MOD.${test}} == ${EXP.${test}}



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

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 15:13:45 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: varmod-edge.exp varmod-edge.mk

Log Message:
make(1): add test for empty modifier list after colon

This is a good candidate for becoming an error in strict mode.
Either write ${VAR} or write ${VAR:modifiers}, but not half-baked.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-edge.exp
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varmod-edge.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/varmod-edge.exp
diff -u src/usr.bin/make/unit-tests/varmod-edge.exp:1.4 src/usr.bin/make/unit-tests/varmod-edge.exp:1.5
--- src/usr.bin/make/unit-tests/varmod-edge.exp:1.4	Mon Dec  2 01:01:08 2019
+++ src/usr.bin/make/unit-tests/varmod-edge.exp	Sat Aug  1 15:13:45 2020
@@ -14,4 +14,5 @@ ok eq-ext
 ok eq-q
 ok eq-bs
 ok eq-esc
+ok colon
 exit status 0

Index: src/usr.bin/make/unit-tests/varmod-edge.mk
diff -u src/usr.bin/make/unit-tests/varmod-edge.mk:1.8 src/usr.bin/make/unit-tests/varmod-edge.mk:1.9
--- src/usr.bin/make/unit-tests/varmod-edge.mk:1.8	Sun Jul 19 16:08:24 2020
+++ src/usr.bin/make/unit-tests/varmod-edge.mk	Sat Aug  1 15:13:45 2020
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-edge.mk,v 1.8 2020/07/19 16:08:24 rillig Exp $
+# $NetBSD: varmod-edge.mk,v 1.9 2020/08/01 15:13:45 rillig Exp $
 #
 # Tests for edge cases in variable modifiers.
 #
@@ -151,6 +151,11 @@ MOD.eq-esc=	${INP.eq-esc:a\=b}
 EXP.eq-esc=	# empty
 # make: Unclosed substitution for INP.eq-esc (= missing)
 
+TESTS+=		colon
+INP.colon=	value
+MOD.colon=	${INP.colon:}
+EXP.colon=	value
+
 all:
 .for test in ${TESTS}
 .  if ${MOD.${test}} == ${EXP.${test}}



CVS commit: src/usr.bin/make

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 15:03:43 UTC 2020

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

Log Message:
make(1): inline literal dollar characters

This reduces the code size when compiling with GCC 5.  Apparently GCC
wasn't sure enough that str[0] and str[1] stay the same around the call
to Buf_AddByte.


To generate a diff of this commit:
cvs rdiff -u -r1.380 -r1.381 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.380 src/usr.bin/make/var.c:1.381
--- src/usr.bin/make/var.c:1.380	Sat Aug  1 14:47:49 2020
+++ src/usr.bin/make/var.c	Sat Aug  1 15:03:43 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.380 2020/08/01 14:47:49 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.381 2020/08/01 15:03:43 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.380 2020/08/01 14:47:49 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.381 2020/08/01 15:03:43 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.380 2020/08/01 14:47:49 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.381 2020/08/01 15:03:43 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -3420,7 +3420,7 @@ Var_Parse(const char * const str, GNode 
 	if (v == NULL) {
 	*lengthPtr = 2;
 
-	if ((ctxt == VAR_CMD) || (ctxt == VAR_GLOBAL)) {
+	if (ctxt == VAR_CMD || ctxt == VAR_GLOBAL) {
 		/*
 		 * If substituting a local variable in a non-local context,
 		 * assume it's for dynamic source stuff. We have to handle
@@ -3689,17 +3689,16 @@ Var_Subst(const char *str, GNode *ctxt, 
 while (*str) {
 	if (*str == '\n' && trailingBslash)
 	Buf_AddByte(, ' ');
-	if ((*str == '$') && (str[1] == '$')) {
+	if (*str == '$' && str[1] == '$') {
 	/*
-	 * A dollar sign may be escaped either with another dollar sign.
+	 * 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.
 	 */
 	if (save_dollars && (eflags & VARE_ASSIGN))
-		Buf_AddByte(, *str);
-	str++;
-	Buf_AddByte(, *str);
-	str++;
+		Buf_AddByte(, '$');
+	Buf_AddByte(, '$');
+	str += 2;
 	} else if (*str != '$') {
 	/*
 	 * Skip as many characters as possible -- either to the end of



CVS commit: src/usr.bin/make

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 14:52:14 UTC 2020

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

Log Message:
make(1): use ordinary string concatenation in usage text


To generate a diff of this commit:
cvs rdiff -u -r1.291 -r1.292 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.291 src/usr.bin/make/main.c:1.292
--- src/usr.bin/make/main.c:1.291	Sat Aug  1 14:47:49 2020
+++ src/usr.bin/make/main.c	Sat Aug  1 14:52:14 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.291 2020/08/01 14:47:49 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.292 2020/08/01 14:52:14 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.291 2020/08/01 14:47:49 rillig Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.292 2020/08/01 14:52:14 rillig Exp $";
 #else
 #include 
 #ifndef lint
@@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #if 0
 static char sccsid[] = "@(#)main.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.291 2020/08/01 14:47:49 rillig Exp $");
+__RCSID("$NetBSD: main.c,v 1.292 2020/08/01 14:52:14 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1921,13 +1921,13 @@ usage(void)
 {
 	char *p;
 	if ((p = strchr(progname, '[')) != NULL)
-	*p = '\0';
+		*p = '\0';
 
 	(void)fprintf(stderr,
-"usage: %s [-BeikNnqrstWwX] \n\
-[-C directory] [-D variable] [-d flags] [-f makefile]\n\
-[-I directory] [-J private] [-j max_jobs] [-m directory] [-T file]\n\
-[-V variable] [-v variable] [variable=value] [target ...]\n",
+"usage: %s [-BeikNnqrstWwX] \n"
+"[-C directory] [-D variable] [-d flags] [-f makefile]\n"
+"[-I directory] [-J private] [-j max_jobs] [-m directory] [-T file]\n"
+"[-V variable] [-v variable] [variable=value] [target ...]\n",
 	progname);
 	exit(2);
 }



CVS commit: src/usr.bin/make

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 14:47:49 UTC 2020

Modified Files:
src/usr.bin/make: arch.c compat.c cond.c dir.c for.c hash.c hash.h
job.c lst.c main.c make_malloc.h parse.c suff.c util.c var.c

Log Message:
make(1): use consistent indentation in source code

Tabs for multiples of 8, then spaces.

The usage string has been kept as-is since the spaces there are
indentional and do influence the output.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/usr.bin/make/arch.c
cvs rdiff -u -r1.117 -r1.118 src/usr.bin/make/compat.c
cvs rdiff -u -r1.84 -r1.85 src/usr.bin/make/cond.c
cvs rdiff -u -r1.82 -r1.83 src/usr.bin/make/dir.c
cvs rdiff -u -r1.57 -r1.58 src/usr.bin/make/for.c src/usr.bin/make/util.c
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/make/hash.c
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/hash.h
cvs rdiff -u -r1.204 -r1.205 src/usr.bin/make/job.c
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/lst.c
cvs rdiff -u -r1.290 -r1.291 src/usr.bin/make/main.c
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/make_malloc.h
cvs rdiff -u -r1.245 -r1.246 src/usr.bin/make/parse.c
cvs rdiff -u -r1.92 -r1.93 src/usr.bin/make/suff.c
cvs rdiff -u -r1.379 -r1.380 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/arch.c
diff -u src/usr.bin/make/arch.c:1.79 src/usr.bin/make/arch.c:1.80
--- src/usr.bin/make/arch.c:1.79	Sat Aug  1 09:55:00 2020
+++ src/usr.bin/make/arch.c	Sat Aug  1 14:47:49 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: arch.c,v 1.79 2020/08/01 09:55:00 rillig Exp $	*/
+/*	$NetBSD: arch.c,v 1.80 2020/08/01 14:47:49 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: arch.c,v 1.79 2020/08/01 09:55:00 rillig Exp $";
+static char rcsid[] = "$NetBSD: arch.c,v 1.80 2020/08/01 14:47:49 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)arch.c	8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: arch.c,v 1.79 2020/08/01 09:55:00 rillig Exp $");
+__RCSID("$NetBSD: arch.c,v 1.80 2020/08/01 14:47:49 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -534,7 +534,7 @@ ArchStatMember(const char *archive, cons
 Hash_Entry	  *he;	  /* Entry containing member's description */
 struct ar_hdr arh;/* archive-member header for reading archive */
 char	  memName[MAXPATHLEN+1];
-			/* Current member name while hashing. */
+			/* Current member name while hashing. */
 
 /*
  * Because of space constraints and similar things, files are archived
@@ -604,7 +604,7 @@ ArchStatMember(const char *archive, cons
  * can handle...
  */
 if ((fread(magic, SARMAG, 1, arch) != 1) ||
-	(strncmp(magic, ARMAG, SARMAG) != 0)) {
+	(strncmp(magic, ARMAG, SARMAG) != 0)) {
 	fclose(arch);
 	return NULL;
 }
@@ -786,7 +786,7 @@ ArchSVR4Entry(Arch *ar, char *name, size
 	}
 	if (DEBUG(ARCH)) {
 	fprintf(debug_file, "Found svr4 archive name table with %lu entries\n",
-	(unsigned long)entry);
+		(unsigned long)entry);
 	}
 	return 0;
 }
@@ -862,7 +862,7 @@ ArchFindMember(const char *archive, cons
  * can handle...
  */
 if ((fread(magic, SARMAG, 1, arch) != 1) ||
-	(strncmp(magic, ARMAG, SARMAG) != 0)) {
+	(strncmp(magic, ARMAG, SARMAG) != 0)) {
 	fclose(arch);
 	return NULL;
 }

Index: src/usr.bin/make/compat.c
diff -u src/usr.bin/make/compat.c:1.117 src/usr.bin/make/compat.c:1.118
--- src/usr.bin/make/compat.c:1.117	Sat Aug  1 09:55:00 2020
+++ src/usr.bin/make/compat.c	Sat Aug  1 14:47:49 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.117 2020/08/01 09:55:00 rillig Exp $	*/
+/*	$NetBSD: compat.c,v 1.118 2020/08/01 14:47:49 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: compat.c,v 1.117 2020/08/01 09:55:00 rillig Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.118 2020/08/01 14:47:49 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)compat.c	8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: compat.c,v 1.117 2020/08/01 09:55:00 rillig Exp $");
+__RCSID("$NetBSD: compat.c,v 1.118 2020/08/01 14:47:49 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -212,7 +212,7 @@ CompatRunCommand(void *cmdp, void *gnp)
 char	  *cmdStart;	/* Start of expanded command */
 char 	  *cp, *bp;
 Boolean 	  silent,   	/* Don't print command */
-		  doIt;		/* Execute even if -n */
+		  doIt;		/* Execute even if -n */
 volatile Boolean errCheck; 	/* Check errors */
 int 	  reason;   	/* Reason for child's death */
 int		  status;   	/* Description of child's death */
@@ -433,18 +433,18 @@ again:
 #endif
 		if (status != 0) {
 		if 

CVS commit: src/usr.bin/make

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 13:51:41 UTC 2020

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

Log Message:
make(1): inline function in SysV modifier processing


To generate a diff of this commit:
cvs rdiff -u -r1.378 -r1.379 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.378 src/usr.bin/make/var.c:1.379
--- src/usr.bin/make/var.c:1.378	Sat Aug  1 13:35:13 2020
+++ src/usr.bin/make/var.c	Sat Aug  1 13:51:40 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.378 2020/08/01 13:35:13 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.379 2020/08/01 13:51:40 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.378 2020/08/01 13:35:13 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.379 2020/08/01 13:51:40 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.378 2020/08/01 13:35:13 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.379 2020/08/01 13:51:40 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1219,36 +1219,6 @@ Str_SYSVMatch(const char *word, const ch
 return w;
 }
 
-
-/*-
- *---
- * Str_SYSVSubst --
- *	Append rhs to the buffer, substituting the first '%' with the
- *	match, but only if the lhs had a '%' as well.
- *	If the rhs does not contain a '%', prepend the match.
- *---
- */
-static void
-Str_SYSVSubst(SepBuf *buf, const char *rhs,
-	  const char *match, size_t match_len, Boolean lhsHasPercent)
-{
-const char *percent = strchr(rhs, '%');
-
-if (percent != NULL && lhsHasPercent) {
-	/* Copy the prefix of the replacement pattern */
-	SepBuf_AddBytesBetween(buf, rhs, percent);
-	rhs = percent + 1;
-}
-if (percent != NULL || !lhsHasPercent) {
-	/* Copy the matched part of the original word */
-	SepBuf_AddBytes(buf, match, match_len);
-}
-
-/* Append the suffix of the replacement pattern */
-SepBuf_AddStr(buf, rhs);
-}
-
-
 typedef struct {
 GNode *ctx;
 const char *lhs;
@@ -1264,13 +1234,31 @@ ModifyWord_SYSVSubst(const char *word, S
 size_t match_len;
 Boolean lhsPercent;
 const char *match = Str_SYSVMatch(word, args->lhs, _len, );
-if (match != NULL) {
-	char *rhs_expanded = Var_Subst(args->rhs, args->ctx, VARE_WANTRES);
-	Str_SYSVSubst(buf, rhs_expanded, match, match_len, lhsPercent);
-	free(rhs_expanded);
-} else {
+if (match == NULL) {
 	SepBuf_AddStr(buf, word);
+	return;
+}
+
+/* Append rhs to the buffer, substituting the first '%' with the
+ * match, but only if the lhs had a '%' as well. */
+
+char *rhs_expanded = Var_Subst(args->rhs, args->ctx, VARE_WANTRES);
+
+const char *rhs = rhs_expanded;
+const char *percent = strchr(rhs, '%');
+
+if (percent != NULL && lhsPercent) {
+	/* Copy the prefix of the replacement pattern */
+	SepBuf_AddBytesBetween(buf, rhs, percent);
+	rhs = percent + 1;
 }
+if (percent != NULL || !lhsPercent)
+	SepBuf_AddBytes(buf, match, match_len);
+
+/* Append the suffix of the replacement pattern */
+SepBuf_AddStr(buf, rhs);
+
+free(rhs_expanded);
 }
 #endif
 



CVS commit: xsrc/external/mit/xorg-server.old/dist/hw/sun

2020-08-01 Thread Izumi Tsutsui
Module Name:xsrc
Committed By:   tsutsui
Date:   Sat Aug  1 13:40:55 UTC 2020

Modified Files:
xsrc/external/mit/xorg-server.old/dist/hw/sun: sun.h sunCfb.c sunFbs.c
sunInit.c sunKbd.c sunKeyMap.c

Log Message:
Cherry-pick non-Xorg-1.20-specific fixes from xorg-server dir.

 Use proper ANSI offsetof(3) to specify framebuffer offset in struct.
 Add prototype declarations for CG2 functions.
 Implement functions to restore palette settings on exiting Xserver.
 Explicitly initialize origColormapValid for readability.
 Fix LED defintions to match xkb/xkbInit.c.
 Remove unused functions required to handle non-XKB autorepeat.
 Initialize ModMap dynamically using keymap data per each keyboard.
 Remove now unused ModMap data for each keyboard.
 Use "empty" for rmlvo model and layout to avoid lingering default settings.
 Trailing whitespace.

Note it looks there is some serious performance regression
between Xorg 1.10 and 1.20 on rendering root_weave to root window
on 3/60 bwtwo mono server.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 xsrc/external/mit/xorg-server.old/dist/hw/sun/sun.h \
xsrc/external/mit/xorg-server.old/dist/hw/sun/sunCfb.c \
xsrc/external/mit/xorg-server.old/dist/hw/sun/sunFbs.c \
xsrc/external/mit/xorg-server.old/dist/hw/sun/sunInit.c \
xsrc/external/mit/xorg-server.old/dist/hw/sun/sunKbd.c \
xsrc/external/mit/xorg-server.old/dist/hw/sun/sunKeyMap.c

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

Modified files:

Index: xsrc/external/mit/xorg-server.old/dist/hw/sun/sun.h
diff -u xsrc/external/mit/xorg-server.old/dist/hw/sun/sun.h:1.1 xsrc/external/mit/xorg-server.old/dist/hw/sun/sun.h:1.2
--- xsrc/external/mit/xorg-server.old/dist/hw/sun/sun.h:1.1	Wed Jul 22 19:17:03 2020
+++ xsrc/external/mit/xorg-server.old/dist/hw/sun/sun.h	Sat Aug  1 13:40:55 2020
@@ -247,11 +247,21 @@ typedef struct {
 CursorPtr	pCursor;		/* current cursor */
 } sunCursorRec, *sunCursorPtr;
 
+#define NCMAP	256
+typedef struct {
+u_char	origRed[NCMAP];
+u_char	origGreen[NCMAP];
+u_char	origBlue[NCMAP];
+} sunCmapRec, *sunCmapPtr;
+
 typedef struct {
 ColormapPtr	installedMap;
 CloseScreenProcPtr CloseScreen;
 void	(*UpdateColormap)(ScreenPtr, int, int, u_char *, u_char *, u_char *);
 void	(*GetColormap)(ScreenPtr, int, int, u_char *, u_char *, u_char *);
+Bool	origColormapValid;
+sunCmapRec	origColormap;
+void	(*RestoreColormap)(ScreenPtr);
 sunCursorRechardwareCursor;
 Bool	hasHardwareCursor;
 } sunScreenRec, *sunScreenPtr;
@@ -296,10 +306,8 @@ extern Bool		sunNoGX;
 
 /* sunKeyMap.c */
 extern KeySymsRec	sunKeySyms[];
-extern const SunModmapRec *sunModMaps[];
 extern const int	sunMaxLayout;
 extern KeySym		*sunType4KeyMaps[];
-extern const SunModmapRec *sunType4ModMaps[];
 
 /* sunKbd.c */
 extern long		sunAutoRepeatInitiate;
@@ -351,8 +359,6 @@ extern Firm_event* sunKbdGetEvents(int, 
 extern void sunKbdEnqueueEvent(DeviceIntPtr, Firm_event *);
 extern int sunKbdProc(DeviceIntPtr, int);
 extern void sunKbdWait(void);
-void sunBlockHandler(int, pointer, pointer, pointer);
-void sunWakeupHandler(int, pointer, unsigned long, pointer);
 
 /* sunMouse.c */
 extern Firm_event* sunMouseGetEvents(int, Bool, int *, Bool *);
Index: xsrc/external/mit/xorg-server.old/dist/hw/sun/sunCfb.c
diff -u xsrc/external/mit/xorg-server.old/dist/hw/sun/sunCfb.c:1.1 xsrc/external/mit/xorg-server.old/dist/hw/sun/sunCfb.c:1.2
--- xsrc/external/mit/xorg-server.old/dist/hw/sun/sunCfb.c:1.1	Wed Jul 22 19:17:03 2020
+++ xsrc/external/mit/xorg-server.old/dist/hw/sun/sunCfb.c	Sat Aug  1 13:40:55 2020
@@ -94,8 +94,18 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 static void CGUpdateColormap(ScreenPtr, int, int, u_char *, u_char *, u_char *);
 static void CGGetColormap(ScreenPtr, int, int, u_char *, u_char *, u_char *);
 static void CGStoreColors(ColormapPtr, int, xColorItem *);
+static void CGSaveColormap(ScreenPtr);
+static void CGRestoreColormap(ScreenPtr);
+static void CGScreenInitCommon(ScreenPtr);
 static void CGScreenInit(ScreenPtr);
 static void checkMono(int, char **);
+#ifdef INCLUDE_CG2_HEADER
+static void CG2UpdateColormap(ScreenPtr, int, int, u_char *, u_char *, u_char *);
+static void CG2GetColormap(ScreenPtr, int, int, u_char *, u_char *, u_char *);
+static void CG2RestoreColormap(ScreenPtr);
+static Bool CG2SaveScreen(ScreenPtr, int);
+static void CG2ScreenInit(ScreenPtr pScreen);
+#endif
 static void CG4Switch(ScreenPtr, int);
 
 static void
@@ -239,22 +249,61 @@ CGStoreColors(ColormapPtr pmap, int ndef
 }
 
 static void
-CGScreenInit(ScreenPtr pScreen)
+CGSaveColormap(ScreenPtr pScreen)
+{
+sunScreenPtr pPrivate = sunGetScreenPrivate(pScreen);
+sunCmapPtr origColormap;
+u_char *rmap, *gmap, *bmap;
+
+origColormap = >origColormap;
+rmap = origColormap->origRed;
+gmap = 

CVS commit: src/usr.bin/make

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 13:35:13 UTC 2020

Modified Files:
src/usr.bin/make: var.c
src/usr.bin/make/unit-tests: sysv.mk

Log Message:
make(1): reduce the number of string comparisons in ${VAR:%.c=%.o}

There is only a single position in the word where the tail ".c" can
match, since it is implicitly anchored at the end.  Therefore there's no
need to do several string comparisons.


To generate a diff of this commit:
cvs rdiff -u -r1.377 -r1.378 src/usr.bin/make/var.c
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/sysv.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/var.c
diff -u src/usr.bin/make/var.c:1.377 src/usr.bin/make/var.c:1.378
--- src/usr.bin/make/var.c:1.377	Sat Aug  1 13:16:29 2020
+++ src/usr.bin/make/var.c	Sat Aug  1 13:35:13 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.377 2020/08/01 13:16:29 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.378 2020/08/01 13:35:13 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.377 2020/08/01 13:16:29 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.378 2020/08/01 13:35:13 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.377 2020/08/01 13:16:29 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.378 2020/08/01 13:35:13 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1205,19 +1205,18 @@ Str_SYSVMatch(const char *word, const ch
 	}
 }
 
-const char *suffix = w;
+/* Test whether the tail matches */
+size_t w_len = strlen(w);
+size_t p_len = strlen(p);
+if (w_len < p_len)
+	return NULL;
 
-/* Find a matching tail */
-/* XXX: This loop should not be necessary since there is only one
- * possible position where strcmp could ever return 0. */
-do {
-	if (strcmp(p, w) == 0) {
-	*match_len = w - suffix;
-	return suffix;
-	}
-} while (*w++ != '\0');
+const char *w_tail = w + w_len - p_len;
+if (memcmp(p, w_tail, p_len) != 0)
+return NULL;
 
-return NULL;
+*match_len = w_tail - w;
+return w;
 }
 
 

Index: src/usr.bin/make/unit-tests/sysv.mk
diff -u src/usr.bin/make/unit-tests/sysv.mk:1.11 src/usr.bin/make/unit-tests/sysv.mk:1.12
--- src/usr.bin/make/unit-tests/sysv.mk:1.11	Sat Aug  1 12:47:56 2020
+++ src/usr.bin/make/unit-tests/sysv.mk	Sat Aug  1 13:35:13 2020
@@ -1,4 +1,4 @@
-# $Id: sysv.mk,v 1.11 2020/08/01 12:47:56 rillig Exp $
+# $Id: sysv.mk,v 1.12 2020/08/01 13:35:13 rillig Exp $
 
 all: foo fun sam bla words ampersand anchor-dollar
 all: mismatch
@@ -87,8 +87,10 @@ EXPR.7=	${LIST:o%%e=X}		# Only the first
 EXP.7=	one two			# None of the words contains a literal '%'.
 EXPR.8=	${LIST:%=%%}
 EXP.8=	one% two%
+EXPR.9=	${LIST:%nes=%xxx}	# lhs is longer than the word "one"
+EXP.9=	one two
 
-.for i in ${:U:range=8}
+.for i in ${:U:range=9}
 .if ${EXPR.$i} != ${EXP.$i}
 .warning test case $i expected "${EXP.$i}", got "${EXPR.$i}
 .endif



CVS commit: src/usr.bin/make

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 13:16:29 UTC 2020

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

Log Message:
make(1): make variable names in SysV modifier more expressive

When matching a word against a substitution having a lhs and a rhs,
including a possible wildcard, there are just too many string variables
around to know what a simple "len" means and where it belongs.


To generate a diff of this commit:
cvs rdiff -u -r1.376 -r1.377 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.376 src/usr.bin/make/var.c:1.377
--- src/usr.bin/make/var.c:1.376	Sat Aug  1 12:04:46 2020
+++ src/usr.bin/make/var.c	Sat Aug  1 13:16:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.376 2020/08/01 12:04:46 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.377 2020/08/01 13:16:29 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.376 2020/08/01 12:04:46 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.377 2020/08/01 13:16:29 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.376 2020/08/01 12:04:46 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.377 2020/08/01 13:16:29 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1165,55 +1165,55 @@ ModifyWord_NoMatch(const char *word, Sep
  * Input:
  *	word		Word to examine
  *	pattern		Pattern to examine against
- *	len		Number of characters to substitute
  *
  * Results:
- *	Returns the beginning position of a match or null. The number
- *	of characters matched is returned in len.
+ *	Returns the start of the match, or NULL.
+ *	*match_len returns the length of the match, if any.
+ *	*hasPercent returns whether the pattern contains a percent.
  *---
  */
 static const char *
-Str_SYSVMatch(const char *word, const char *pattern, size_t *len,
+Str_SYSVMatch(const char *word, const char *pattern, size_t *match_len,
 Boolean *hasPercent)
 {
 const char *p = pattern;
 const char *w = word;
-const char *m;
 
 *hasPercent = FALSE;
-if (*p == '\0') {
-	/* Null pattern is the whole string */
-	*len = strlen(w);
+if (*p == '\0') {		/* ${VAR:=suffix} */
+	*match_len = strlen(w);	/* Null pattern is the whole string */
 	return w;
 }
 
-if ((m = strchr(p, '%')) != NULL) {
+const char *percent = strchr(p, '%');
+if (percent != NULL) {	/* ${VAR:...%...=...} */
 	*hasPercent = TRUE;
-	if (*w == '\0') {
-		/* empty word does not match pattern */
-		return NULL;
-	}
+	if (*w == '\0')
+	return NULL;	/* empty word does not match pattern */
+
 	/* check that the prefix matches */
-	for (; p != m && *w && *w == *p; w++, p++)
+	for (; p != percent && *w != '\0' && *w == *p; w++, p++)
 	 continue;
-
-	if (p != m)
+	if (p != percent)
 	return NULL;	/* No match */
 
-	if (*++p == '\0') {
+	p++;			/* Skip the percent */
+	if (*p == '\0') {
 	/* No more pattern, return the rest of the string */
-	*len = strlen(w);
+	*match_len = strlen(w);
 	return w;
 	}
 }
 
-m = w;
+const char *suffix = w;
 
 /* Find a matching tail */
+/* XXX: This loop should not be necessary since there is only one
+ * possible position where strcmp could ever return 0. */
 do {
 	if (strcmp(p, w) == 0) {
-	*len = w - m;
-	return m;
+	*match_len = w - suffix;
+	return suffix;
 	}
 } while (*w++ != '\0');
 
@@ -1224,32 +1224,29 @@ Str_SYSVMatch(const char *word, const ch
 /*-
  *---
  * Str_SYSVSubst --
- *	Substitute '%' on the pattern with len characters from src.
- *	If the pattern does not contain a '%' prepend len characters
- *	from src.
- *
- * Side Effects:
- *	Places result on buf
+ *	Append rhs to the buffer, substituting the first '%' with the
+ *	match, but only if the lhs had a '%' as well.
+ *	If the rhs does not contain a '%', prepend the match.
  *---
  */
 static void
-Str_SYSVSubst(SepBuf *buf, const char *pat, const char *src, size_t src_len,
-	  Boolean lhsHasPercent)
+Str_SYSVSubst(SepBuf *buf, const char *rhs,
+	  const char *match, size_t match_len, Boolean lhsHasPercent)
 {
-const char *percent = strchr(pat, '%');
+const char *percent = strchr(rhs, '%');
 
 if (percent != NULL && lhsHasPercent) {
-	/* Copy the prefix */
-	SepBuf_AddBytesBetween(buf, pat, percent);
-	pat = percent + 1;
+	/* Copy the prefix of the replacement pattern */
+	SepBuf_AddBytesBetween(buf, rhs, percent);
+	rhs = percent + 1;
 }
 if (percent != NULL || !lhsHasPercent) {
-	/* Copy the 

CVS commit: xsrc/external/mit/xorg-server/dist/hw/sun

2020-08-01 Thread Izumi Tsutsui
Module Name:xsrc
Committed By:   tsutsui
Date:   Sat Aug  1 13:15:57 UTC 2020

Modified Files:
xsrc/external/mit/xorg-server/dist/hw/sun: sunKbd.c

Log Message:
Trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 xsrc/external/mit/xorg-server/dist/hw/sun/sunKbd.c

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

Modified files:

Index: xsrc/external/mit/xorg-server/dist/hw/sun/sunKbd.c
diff -u xsrc/external/mit/xorg-server/dist/hw/sun/sunKbd.c:1.5 xsrc/external/mit/xorg-server/dist/hw/sun/sunKbd.c:1.6
--- xsrc/external/mit/xorg-server/dist/hw/sun/sunKbd.c:1.5	Sat Aug  1 01:49:58 2020
+++ xsrc/external/mit/xorg-server/dist/hw/sun/sunKbd.c	Sat Aug  1 13:15:57 2020
@@ -716,7 +716,7 @@ sunInitModMap(
 {
 KeySym *k;
 int i, min, max, width;
-
+
 for (i = 0; i < MAP_LENGTH; i++)
 ModMap[i] = NoSymbol;
 



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

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 12:47:56 UTC 2020

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

Log Message:
make(1): fix typo in newly added SysV modifier test case

I should have been more suspicious when all my test cases succeeded at
the first try.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/sysv.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/sysv.mk
diff -u src/usr.bin/make/unit-tests/sysv.mk:1.10 src/usr.bin/make/unit-tests/sysv.mk:1.11
--- src/usr.bin/make/unit-tests/sysv.mk:1.10	Sat Aug  1 12:04:00 2020
+++ src/usr.bin/make/unit-tests/sysv.mk	Sat Aug  1 12:47:56 2020
@@ -1,4 +1,4 @@
-# $Id: sysv.mk,v 1.10 2020/08/01 12:04:00 rillig Exp $
+# $Id: sysv.mk,v 1.11 2020/08/01 12:47:56 rillig Exp $
 
 all: foo fun sam bla words ampersand anchor-dollar
 all: mismatch
@@ -76,20 +76,20 @@ EXP.1=	one twX
 EXPR.2=	${LIST:o=}
 EXP.2=	one tw
 EXPR.3=	${LIST:o=%}
-EXP.3=	one twtwo
+EXP.3=	one tw%
 EXPR.4=	${LIST:%o=X}
 EXP.4=	one X
 EXPR.5=	${LIST:o%=X}
-EXP.5=	X twX
+EXP.5=	X two
 EXPR.6=	${LIST:o%e=X}
-EXP.6=	oXe two
+EXP.6=	X two
 EXPR.7=	${LIST:o%%e=X}		# Only the first '%' is the wildcard.
 EXP.7=	one two			# None of the words contains a literal '%'.
 EXPR.8=	${LIST:%=%%}
-EXP.8=	oneone twotwo
+EXP.8=	one% two%
 
 .for i in ${:U:range=8}
-.if ${EXPR.1} != ${EXP.1}
-.warning expected "${EXP.$i}", got "${EXPR.$i}
+.if ${EXPR.$i} != ${EXP.$i}
+.warning test case $i expected "${EXP.$i}", got "${EXPR.$i}
 .endif
 .endfor



CVS commit: src/sys/arch/xen/x86

2020-08-01 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Aug  1 12:39:40 UTC 2020

Modified Files:
src/sys/arch/xen/x86: pintr.c xen_intr.c

Log Message:
adjust includes to pull __HAVE_PCI_MSI_MSIX properly


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/xen/x86/pintr.c
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/xen/x86/xen_intr.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/xen/x86/pintr.c
diff -u src/sys/arch/xen/x86/pintr.c:1.19 src/sys/arch/xen/x86/pintr.c:1.20
--- src/sys/arch/xen/x86/pintr.c:1.19	Sun Jul 19 16:20:36 2020
+++ src/sys/arch/xen/x86/pintr.c	Sat Aug  1 12:39:40 2020
@@ -103,12 +103,13 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pintr.c,v 1.19 2020/07/19 16:20:36 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pintr.c,v 1.20 2020/08/01 12:39:40 jdolecek Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_xen.h"
 #include "isa.h"
 #include "pci.h"
+#include "opt_pci.h"
 
 #include 
 #include 
@@ -126,6 +127,8 @@ __KERNEL_RCSID(0, "$NetBSD: pintr.c,v 1.
 #include 
 #include 
 
+#include 
+
 #ifdef __HAVE_PCI_MSI_MSIX
 #include 
 #endif

Index: src/sys/arch/xen/x86/xen_intr.c
diff -u src/sys/arch/xen/x86/xen_intr.c:1.27 src/sys/arch/xen/x86/xen_intr.c:1.28
--- src/sys/arch/xen/x86/xen_intr.c:1.27	Thu May  7 19:48:58 2020
+++ src/sys/arch/xen/x86/xen_intr.c	Sat Aug  1 12:39:40 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: xen_intr.c,v 1.27 2020/05/07 19:48:58 bouyer Exp $	*/
+/*	$NetBSD: xen_intr.c,v 1.28 2020/08/01 12:39:40 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -30,9 +30,10 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.27 2020/05/07 19:48:58 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.28 2020/08/01 12:39:40 jdolecek Exp $");
 
 #include "opt_multiprocessor.h"
+#include "opt_pci.h"
 
 #include 
 #include 



CVS commit: src/sys/arch/x86

2020-08-01 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Aug  1 12:36:36 UTC 2020

Modified Files:
src/sys/arch/x86/pci: pci_intr_machdep.c
src/sys/arch/x86/x86: mainbus.c

Log Message:
reorder includes to pull __HAVE_PCI_MSI_MSIX properly via



To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/x86/pci/pci_intr_machdep.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/x86/x86/mainbus.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/x86/pci/pci_intr_machdep.c
diff -u src/sys/arch/x86/pci/pci_intr_machdep.c:1.50 src/sys/arch/x86/pci/pci_intr_machdep.c:1.51
--- src/sys/arch/x86/pci/pci_intr_machdep.c:1.50	Mon Jun 17 06:38:29 2019
+++ src/sys/arch/x86/pci/pci_intr_machdep.c	Sat Aug  1 12:36:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_intr_machdep.c,v 1.50 2019/06/17 06:38:29 msaitoh Exp $	*/
+/*	$NetBSD: pci_intr_machdep.c,v 1.51 2020/08/01 12:36:35 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2009 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.50 2019/06/17 06:38:29 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.51 2020/08/01 12:36:35 jdolecek Exp $");
 
 #include 
 #include 
@@ -85,13 +85,14 @@ __KERNEL_RCSID(0, "$NetBSD: pci_intr_mac
 #include 
 #include 
 
-#include 
-
 #include "ioapic.h"
 #include "eisa.h"
 #include "acpica.h"
 #include "opt_mpbios.h"
 #include "opt_acpi.h"
+#include "opt_pci.h"
+
+#include 
 
 #include 
 

Index: src/sys/arch/x86/x86/mainbus.c
diff -u src/sys/arch/x86/x86/mainbus.c:1.4 src/sys/arch/x86/x86/mainbus.c:1.5
--- src/sys/arch/x86/x86/mainbus.c:1.4	Sat Apr 25 15:26:18 2020
+++ src/sys/arch/x86/x86/mainbus.c	Sat Aug  1 12:36:35 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: mainbus.c,v 1.4 2020/04/25 15:26:18 bouyer Exp $ */
+/* $NetBSD: mainbus.c,v 1.5 2020/08/01 12:36:35 jdolecek Exp $ */
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -28,15 +28,18 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.4 2020/04/25 15:26:18 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.5 2020/08/01 12:36:35 jdolecek Exp $");
+
+#include "opt_acpi.h"
+#include "opt_mpbios.h"
+#include "opt_pcifixup.h"
+#include "opt_pci.h"
 
 #include 
 #include 
 #include 
 #include 
 
-#include 
-
 #include 
 #include 
 #include 
@@ -48,10 +51,6 @@ __KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 
 #include "acpica.h"
 #include "ipmi.h"
 
-#include "opt_acpi.h"
-#include "opt_mpbios.h"
-#include "opt_pcifixup.h"
-
 #if NACPICA > 0
 #include 
 #endif
@@ -63,6 +62,7 @@ __KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 
 #endif
 
 #if NPCI > 0
+#include 
 #if defined(PCI_BUS_FIXUP)
 #include 
 #if defined(PCI_ADDR_FIXUP)



CVS commit: src/sys/arch/amd64/conf

2020-08-01 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Aug  1 12:28:19 UTC 2020

Modified Files:
src/sys/arch/amd64/conf: ALL

Log Message:
remove CISS_NO_INTERRUPT_HACK from ALL kernel config too, it's no longer
supported in ciss(4)


To generate a diff of this commit:
cvs rdiff -u -r1.159 -r1.160 src/sys/arch/amd64/conf/ALL

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/amd64/conf/ALL
diff -u src/sys/arch/amd64/conf/ALL:1.159 src/sys/arch/amd64/conf/ALL:1.160
--- src/sys/arch/amd64/conf/ALL:1.159	Sat Aug  1 08:20:47 2020
+++ src/sys/arch/amd64/conf/ALL	Sat Aug  1 12:28:19 2020
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.159 2020/08/01 08:20:47 maxv Exp $
+# $NetBSD: ALL,v 1.160 2020/08/01 12:28:19 jdolecek Exp $
 # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
 #
 # ALL machine description file
@@ -17,7 +17,7 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"ALL-$Revision: 1.159 $"
+#ident		"ALL-$Revision: 1.160 $"
 
 maxusers	64		# estimated number of users
 
@@ -831,7 +831,6 @@ amr*	at pci? dev ? function ?	# AMI/LSI 
 arcmsr* at pci? dev ? function ?	# Areca SATA RAID controllers
 cac*	at pci? dev ? function ?	# Compaq PCI array controllers
 ciss*	at pci? dev ? function ?	# HP Smart Array controllers
-options CISS_NO_INTERRUPT_HACK
 
 icp*	at pci? dev ? function ?	# ICP-Vortex GDT & Intel RAID
 ips*	at pci? dev ? function ?	# Adaptec/IBM ServeRAID



CVS commit: src/sys/arch/x86/conf

2020-08-01 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Aug  1 12:15:40 UTC 2020

Modified Files:
src/sys/arch/x86/conf: files.x86

Log Message:
defflag NO_PCI_MSI_MSIX


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/sys/arch/x86/conf/files.x86

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/x86/conf/files.x86
diff -u src/sys/arch/x86/conf/files.x86:1.118 src/sys/arch/x86/conf/files.x86:1.119
--- src/sys/arch/x86/conf/files.x86:1.118	Sat Jul 25 22:49:20 2020
+++ src/sys/arch/x86/conf/files.x86	Sat Aug  1 12:15:40 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: files.x86,v 1.118 2020/07/25 22:49:20 riastradh Exp $
+#	$NetBSD: files.x86,v 1.119 2020/08/01 12:15:40 jdolecek Exp $
 
 # options for MP configuration through the MP spec
 defflag opt_mpbios.h MPBIOS MPDEBUG MPBIOS_SCANPCI
@@ -13,6 +13,7 @@ defflag opt_intrdebug.h	INTRDEBUG
 # PCI fixup options
 defflag opt_pcifixup.h	PCI_ADDR_FIXUP PCI_BUS_FIXUP
 			PCI_INTR_FIXUP PCI_INTR_FIXUP_FORCE
+defflag opt_pci.h	NO_PCI_MSI_MSIX
 
 # To be able to test for NetBSD/xen in shared files
 defflag	opt_xen.h		DO_NOT_DEFINE



CVS commit: src/sys/arch

2020-08-01 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Aug  1 12:14:40 UTC 2020

Modified Files:
src/sys/arch/amd64/include: types.h
src/sys/arch/i386/include: types.h
src/sys/arch/x86/include: pci_machdep_common.h

Log Message:
move __HAVE_PCI_MSI_MSIX to 


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/sys/arch/amd64/include/types.h
cvs rdiff -u -r1.91 -r1.92 src/sys/arch/i386/include/types.h
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/x86/include/pci_machdep_common.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/amd64/include/types.h
diff -u src/sys/arch/amd64/include/types.h:1.68 src/sys/arch/amd64/include/types.h:1.69
--- src/sys/arch/amd64/include/types.h:1.68	Mon May  4 15:55:56 2020
+++ src/sys/arch/amd64/include/types.h	Sat Aug  1 12:14:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: types.h,v 1.68 2020/05/04 15:55:56 jdolecek Exp $	*/
+/*	$NetBSD: types.h,v 1.69 2020/08/01 12:14:39 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -100,9 +100,6 @@ typedef	unsigned char		__cpu_simple_lock
 #define	__HAVE_MM_MD_DIRECT_MAPPED_IO
 #define	__HAVE_MM_MD_DIRECT_MAPPED_PHYS
 #define	__HAVE_UCAS_FULL
-#if !defined(NO_PCI_MSI_MSIX)
-#define	__HAVE_PCI_MSI_MSIX
-#endif
 
 #ifdef _KERNEL_OPT
 #define	__HAVE_RAS

Index: src/sys/arch/i386/include/types.h
diff -u src/sys/arch/i386/include/types.h:1.91 src/sys/arch/i386/include/types.h:1.92
--- src/sys/arch/i386/include/types.h:1.91	Mon May  4 15:55:56 2020
+++ src/sys/arch/i386/include/types.h	Sat Aug  1 12:14:40 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: types.h,v 1.91 2020/05/04 15:55:56 jdolecek Exp $	*/
+/*	$NetBSD: types.h,v 1.92 2020/08/01 12:14:40 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -133,9 +133,6 @@ typedef __register_t	register_t;
 #define	__HAVE_TLS_VARIANT_II
 #define	__HAVE_COMMON___TLS_GET_ADDR
 #define	__HAVE_UCAS_FULL
-#if !defined(NO_PCI_MSI_MSIX)
-#define __HAVE_PCI_MSI_MSIX
-#endif
 #define	__HAVE_RAS
 
 #endif	/* _I386_MACHTYPES_H_ */

Index: src/sys/arch/x86/include/pci_machdep_common.h
diff -u src/sys/arch/x86/include/pci_machdep_common.h:1.24 src/sys/arch/x86/include/pci_machdep_common.h:1.25
--- src/sys/arch/x86/include/pci_machdep_common.h:1.24	Sat Apr 25 15:26:18 2020
+++ src/sys/arch/x86/include/pci_machdep_common.h	Sat Aug  1 12:14:40 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep_common.h,v 1.24 2020/04/25 15:26:18 bouyer Exp $	*/
+/*	$NetBSD: pci_machdep_common.h,v 1.25 2020/08/01 12:14:40 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -33,6 +33,10 @@
 #ifndef _X86_PCI_MACHDEP_COMMON_H_
 #define _X86_PCI_MACHDEP_COMMON_H_
 
+#if !defined(NO_PCI_MSI_MSIX)
+#define __HAVE_PCI_MSI_MSIX
+#endif
+
 /*
  * Machine-specific definitions for PCI autoconfiguration.
  */



CVS commit: src/usr.bin/make

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 12:04:46 UTC 2020

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

Log Message:
make(1): more descriptive variable names in Str_SYSVSubst


To generate a diff of this commit:
cvs rdiff -u -r1.375 -r1.376 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.375 src/usr.bin/make/var.c:1.376
--- src/usr.bin/make/var.c:1.375	Sat Aug  1 09:25:36 2020
+++ src/usr.bin/make/var.c	Sat Aug  1 12:04:46 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.375 2020/08/01 09:25:36 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.376 2020/08/01 12:04:46 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.375 2020/08/01 09:25:36 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.376 2020/08/01 12:04:46 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.375 2020/08/01 09:25:36 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.376 2020/08/01 12:04:46 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1233,20 +1233,19 @@ Str_SYSVMatch(const char *word, const ch
  *---
  */
 static void
-Str_SYSVSubst(SepBuf *buf, const char *pat, const char *src, size_t len,
+Str_SYSVSubst(SepBuf *buf, const char *pat, const char *src, size_t src_len,
 	  Boolean lhsHasPercent)
 {
-const char *m;
+const char *percent = strchr(pat, '%');
 
-if ((m = strchr(pat, '%')) != NULL && lhsHasPercent) {
+if (percent != NULL && lhsHasPercent) {
 	/* Copy the prefix */
-	SepBuf_AddBytesBetween(buf, pat, m);
-	/* skip the % */
-	pat = m + 1;
+	SepBuf_AddBytesBetween(buf, pat, percent);
+	pat = percent + 1;
 }
-if (m != NULL || !lhsHasPercent) {
+if (percent != NULL || !lhsHasPercent) {
 	/* Copy the pattern */
-	SepBuf_AddBytes(buf, src, len);
+	SepBuf_AddBytes(buf, src, src_len);
 }
 
 /* append the rest */



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

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 12:04:00 UTC 2020

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

Log Message:
make(1): add more tests for the SysV modifier


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/sysv.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/sysv.mk
diff -u src/usr.bin/make/unit-tests/sysv.mk:1.9 src/usr.bin/make/unit-tests/sysv.mk:1.10
--- src/usr.bin/make/unit-tests/sysv.mk:1.9	Sun Jul 26 11:19:04 2020
+++ src/usr.bin/make/unit-tests/sysv.mk	Sat Aug  1 12:04:00 2020
@@ -1,4 +1,4 @@
-# $Id: sysv.mk,v 1.9 2020/07/26 11:19:04 rillig Exp $
+# $Id: sysv.mk,v 1.10 2020/08/01 12:04:00 rillig Exp $
 
 all: foo fun sam bla words ampersand anchor-dollar
 all: mismatch
@@ -68,3 +68,28 @@ anchor-dollar:
 mismatch:
 	@echo $@: ${:Ufile.c file.h:%.c=%.cpp}
 	@echo $@: ${:Ufile.c other.c:file.%=renamed.%}
+
+# Trying to cover all possible variants of the SysV modifier.
+LIST=	one two
+EXPR.1=	${LIST:o=X}
+EXP.1=	one twX
+EXPR.2=	${LIST:o=}
+EXP.2=	one tw
+EXPR.3=	${LIST:o=%}
+EXP.3=	one twtwo
+EXPR.4=	${LIST:%o=X}
+EXP.4=	one X
+EXPR.5=	${LIST:o%=X}
+EXP.5=	X twX
+EXPR.6=	${LIST:o%e=X}
+EXP.6=	oXe two
+EXPR.7=	${LIST:o%%e=X}		# Only the first '%' is the wildcard.
+EXP.7=	one two			# None of the words contains a literal '%'.
+EXPR.8=	${LIST:%=%%}
+EXP.8=	oneone twotwo
+
+.for i in ${:U:range=8}
+.if ${EXPR.1} != ${EXP.1}
+.warning expected "${EXP.$i}", got "${EXPR.$i}
+.endif
+.endfor



CVS commit: src/sys/kern

2020-08-01 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Aug  1 11:18:26 UTC 2020

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

Log Message:
avoid VLA for the sizeof() calculations


To generate a diff of this commit:
cvs rdiff -u -r1.272 -r1.273 src/sys/kern/subr_autoconf.c

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

Modified files:

Index: src/sys/kern/subr_autoconf.c
diff -u src/sys/kern/subr_autoconf.c:1.272 src/sys/kern/subr_autoconf.c:1.273
--- src/sys/kern/subr_autoconf.c:1.272	Sat Jun 27 13:53:10 2020
+++ src/sys/kern/subr_autoconf.c	Sat Aug  1 11:18:26 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_autoconf.c,v 1.272 2020/06/27 13:53:10 jmcneill Exp $ */
+/* $NetBSD: subr_autoconf.c,v 1.273 2020/08/01 11:18:26 jdolecek Exp $ */
 
 /*
  * Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.272 2020/06/27 13:53:10 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.273 2020/08/01 11:18:26 jdolecek Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -1213,7 +1213,7 @@ config_makeroom(int n, struct cfdriver *
 		 * sleep.
 		 */
 		mutex_exit(_lock);
-		nsp = kmem_alloc(sizeof(device_t[nndevs]), KM_SLEEP);
+		nsp = kmem_alloc(sizeof(device_t) * nndevs, KM_SLEEP);
 		mutex_enter(_lock);
 
 		/*
@@ -1222,20 +1222,20 @@ config_makeroom(int n, struct cfdriver *
 		 */
 		if (cd->cd_devs != osp) {
 			mutex_exit(_lock);
-			kmem_free(nsp, sizeof(device_t[nndevs]));
+			kmem_free(nsp, sizeof(device_t) * nndevs);
 			mutex_enter(_lock);
 			continue;
 		}
 
-		memset(nsp + ondevs, 0, sizeof(device_t[nndevs - ondevs]));
+		memset(nsp + ondevs, 0, sizeof(device_t) * (nndevs - ondevs));
 		if (ondevs != 0)
-			memcpy(nsp, cd->cd_devs, sizeof(device_t[ondevs]));
+			memcpy(nsp, cd->cd_devs, sizeof(device_t) * ondevs);
 
 		cd->cd_ndevs = nndevs;
 		cd->cd_devs = nsp;
 		if (ondevs != 0) {
 			mutex_exit(_lock);
-			kmem_free(osp, sizeof(device_t[ondevs]));
+			kmem_free(osp, sizeof(device_t) * ondevs);
 			mutex_enter(_lock);
 		}
 	}
@@ -1314,7 +1314,7 @@ config_devdelete(device_t dev)
 	device_lock_t dvl = device_getlock(dev);
 
 	if (dg->dg_devs != NULL)
-		kmem_free(dg->dg_devs, sizeof(device_t[dg->dg_ndevs]));
+		kmem_free(dg->dg_devs, sizeof(device_t) * dg->dg_ndevs);
 
 	cv_destroy(>dvl_cv);
 	mutex_destroy(>dvl_mtx);
@@ -1447,9 +1447,9 @@ config_devalloc(const device_t parent, c
 		KASSERT(parent); /* no locators at root */
 		ia = cfiattr_lookup(cfdata_ifattr(cf), parent->dv_cfdriver);
 		dev->dv_locators =
-		kmem_alloc(sizeof(int [ia->ci_loclen + 1]), KM_SLEEP);
-		*dev->dv_locators++ = sizeof(int [ia->ci_loclen + 1]);
-		memcpy(dev->dv_locators, locs, sizeof(int [ia->ci_loclen]));
+		kmem_alloc(sizeof(int) * (ia->ci_loclen + 1), KM_SLEEP);
+		*dev->dv_locators++ = sizeof(int) * (ia->ci_loclen + 1);
+		memcpy(dev->dv_locators, locs, sizeof(int) * ia->ci_loclen);
 	}
 	dev->dv_properties = prop_dictionary_create();
 	KASSERT(dev->dv_properties != NULL);
@@ -2710,7 +2710,7 @@ device_active_register(device_t dev, voi
 	}
 
 	new_size = old_size + 4;
-	new_handlers = kmem_alloc(sizeof(void *[new_size]), KM_SLEEP);
+	new_handlers = kmem_alloc(sizeof(void *) * new_size, KM_SLEEP);
 
 	for (i = 0; i < old_size; ++i)
 		new_handlers[i] = old_handlers[i];
@@ -2724,7 +2724,7 @@ device_active_register(device_t dev, voi
 	splx(s);
 
 	if (old_size > 0)
-		kmem_free(old_handlers, sizeof(void * [old_size]));
+		kmem_free(old_handlers, sizeof(void *) * old_size);
 
 	return true;
 }
@@ -2758,7 +2758,7 @@ device_active_deregister(device_t dev, v
 			dev->dv_activity_count = 0;
 			dev->dv_activity_handlers = NULL;
 			splx(s);
-			kmem_free(old_handlers, sizeof(void *[old_size]));
+			kmem_free(old_handlers, sizeof(void *) * old_size);
 		}
 		return;
 	}



CVS commit: src/usr.bin/make

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 10:44:23 UTC 2020

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

Log Message:
make(1): reduce scope of local variables in brk_string

This also removes the unused assignment to words_cap.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/usr.bin/make/str.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/str.c
diff -u src/usr.bin/make/str.c:1.53 src/usr.bin/make/str.c:1.54
--- src/usr.bin/make/str.c:1.53	Sun Jul 26 16:51:53 2020
+++ src/usr.bin/make/str.c	Sat Aug  1 10:44:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: str.c,v 1.53 2020/07/26 16:51:53 rillig Exp $	*/
+/*	$NetBSD: str.c,v 1.54 2020/08/01 10:44:23 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: str.c,v 1.53 2020/07/26 16:51:53 rillig Exp $";
+static char rcsid[] = "$NetBSD: str.c,v 1.54 2020/08/01 10:44:23 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)str.c	5.8 (Berkeley) 6/1/90";
 #else
-__RCSID("$NetBSD: str.c,v 1.53 2020/07/26 16:51:53 rillig Exp $");
+__RCSID("$NetBSD: str.c,v 1.54 2020/08/01 10:44:23 rillig Exp $");
 #endif
 #endif/* not lint */
 #endif
@@ -142,32 +142,26 @@ char **
 brk_string(const char *str, int *out_words_len, Boolean expand,
 	char **out_words_buf)
 {
-	char inquote;
-	const char *str_p;
-	size_t str_len;
-	char **words;
-	int words_len;
-	int words_cap = 50;
-	char *words_buf, *word_start, *word_end;
-
 	/* skip leading space chars. */
 	for (; *str == ' ' || *str == '\t'; ++str)
 		continue;
 
 	/* words_buf holds the words, separated by '\0'. */
-	str_len = strlen(str);
-	words_buf = bmake_malloc(strlen(str) + 1);
+	size_t str_len = strlen(str);
+	char *words_buf = bmake_malloc(strlen(str) + 1);
 
-	words_cap = MAX((str_len / 5), 50);
-	words = bmake_malloc((words_cap + 1) * sizeof(char *));
+	int words_cap = MAX((str_len / 5), 50);
+	char **words = bmake_malloc((words_cap + 1) * sizeof(char *));
 
 	/*
 	 * copy the string; at the same time, parse backslashes,
 	 * quotes and build the word list.
 	 */
-	words_len = 0;
-	inquote = '\0';
-	word_start = word_end = words_buf;
+	int words_len = 0;
+	char inquote = '\0';
+	char *word_start = words_buf;
+	char *word_end = words_buf;
+	const char *str_p;
 	for (str_p = str;; ++str_p) {
 		char ch = *str_p;
 		switch(ch) {



CVS commit: src/usr.bin/make

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 09:55:00 UTC 2020

Modified Files:
src/usr.bin/make: arch.c compat.c cond.c job.c main.c make.c
make_malloc.h meta.c parse.c suff.c trace.c

Log Message:
make(1): avoid calls to free(3) in the common case of a NULL pointer


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/usr.bin/make/arch.c
cvs rdiff -u -r1.116 -r1.117 src/usr.bin/make/compat.c
cvs rdiff -u -r1.83 -r1.84 src/usr.bin/make/cond.c
cvs rdiff -u -r1.203 -r1.204 src/usr.bin/make/job.c
cvs rdiff -u -r1.289 -r1.290 src/usr.bin/make/main.c
cvs rdiff -u -r1.102 -r1.103 src/usr.bin/make/make.c
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/make_malloc.h
cvs rdiff -u -r1.90 -r1.91 src/usr.bin/make/meta.c
cvs rdiff -u -r1.244 -r1.245 src/usr.bin/make/parse.c
cvs rdiff -u -r1.91 -r1.92 src/usr.bin/make/suff.c
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/trace.c

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

Modified files:

Index: src/usr.bin/make/arch.c
diff -u src/usr.bin/make/arch.c:1.78 src/usr.bin/make/arch.c:1.79
--- src/usr.bin/make/arch.c:1.78	Fri Jul 31 16:26:16 2020
+++ src/usr.bin/make/arch.c	Sat Aug  1 09:55:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: arch.c,v 1.78 2020/07/31 16:26:16 rillig Exp $	*/
+/*	$NetBSD: arch.c,v 1.79 2020/08/01 09:55:00 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: arch.c,v 1.78 2020/07/31 16:26:16 rillig Exp $";
+static char rcsid[] = "$NetBSD: arch.c,v 1.79 2020/08/01 09:55:00 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)arch.c	8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: arch.c,v 1.78 2020/07/31 16:26:16 rillig Exp $");
+__RCSID("$NetBSD: arch.c,v 1.79 2020/08/01 09:55:00 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1010,8 +1010,8 @@ Arch_Touch(GNode *gn)
 			  Var_Value(MEMBER, gn, ),
 			  , "r+");
 
-free(p1);
-free(p2);
+bmake_free(p1);
+bmake_free(p2);
 
 snprintf(arh.ar_date, sizeof(arh.ar_date), "%-12ld", (long) now);
 
@@ -1092,8 +1092,8 @@ Arch_MTime(GNode *gn)
 			 Var_Value(MEMBER, gn, ),
 			 TRUE);
 
-free(p1);
-free(p2);
+bmake_free(p1);
+bmake_free(p2);
 
 if (arhPtr != NULL) {
 	modTime = (time_t)strtol(arhPtr->ar_date, NULL, 10);

Index: src/usr.bin/make/compat.c
diff -u src/usr.bin/make/compat.c:1.116 src/usr.bin/make/compat.c:1.117
--- src/usr.bin/make/compat.c:1.116	Sat Aug  1 09:25:36 2020
+++ src/usr.bin/make/compat.c	Sat Aug  1 09:55:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.116 2020/08/01 09:25:36 rillig Exp $	*/
+/*	$NetBSD: compat.c,v 1.117 2020/08/01 09:55:00 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: compat.c,v 1.116 2020/08/01 09:25:36 rillig Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.117 2020/08/01 09:55:00 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)compat.c	8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: compat.c,v 1.116 2020/08/01 09:25:36 rillig Exp $");
+__RCSID("$NetBSD: compat.c,v 1.117 2020/08/01 09:55:00 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -133,7 +133,7 @@ CompatDeleteTarget(GNode *gn)
 	Error("*** %s removed", file);
 	}
 
-	free(p1);
+	bmake_free(p1);
 }
 }
 
@@ -548,7 +548,7 @@ Compat_Make(void *gnp, void *pgnp)
 	if (Lst_Member(gn->iParents, pgn) != NULL) {
 	char *p1;
 	Var_Set(IMPSRC, Var_Value(TARGET, gn, ), pgn);
-	free(p1);
+	bmake_free(p1);
 	}
 
 	/*
@@ -652,7 +652,7 @@ Compat_Make(void *gnp, void *pgnp)
 	if (Lst_Member(gn->iParents, pgn) != NULL) {
 	char *p1;
 	Var_Set(IMPSRC, Var_Value(TARGET, gn, ), pgn);
-	free(p1);
+	bmake_free(p1);
 	}
 	switch(gn->made) {
 	case BEINGMADE:

Index: src/usr.bin/make/cond.c
diff -u src/usr.bin/make/cond.c:1.83 src/usr.bin/make/cond.c:1.84
--- src/usr.bin/make/cond.c:1.83	Sat Aug  1 09:30:17 2020
+++ src/usr.bin/make/cond.c	Sat Aug  1 09:55:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.83 2020/08/01 09:30:17 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.84 2020/08/01 09:55:00 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: cond.c,v 1.83 2020/08/01 09:30:17 rillig Exp $";
+static char rcsid[] = "$NetBSD: cond.c,v 1.84 2020/08/01 09:55:00 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)cond.c	8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: cond.c,v 1.83 2020/08/01 09:30:17 rillig Exp $");
+__RCSID("$NetBSD: cond.c,v 1.84 2020/08/01 09:55:00 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -336,7 +336,7 @@ CondDoDefined(int argLen 

CVS commit: src/share/man/man9

2020-08-01 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat Aug  1 09:51:06 UTC 2020

Modified Files:
src/share/man/man9: workqueue.9

Log Message:
Fix typo.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/share/man/man9/workqueue.9

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

Modified files:

Index: src/share/man/man9/workqueue.9
diff -u src/share/man/man9/workqueue.9:1.13 src/share/man/man9/workqueue.9:1.14
--- src/share/man/man9/workqueue.9:1.13	Sat Aug  1 02:14:43 2020
+++ src/share/man/man9/workqueue.9	Sat Aug  1 09:51:06 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: workqueue.9,v 1.13 2020/08/01 02:14:43 riastradh Exp $
+.\"	$NetBSD: workqueue.9,v 1.14 2020/08/01 09:51:06 wiz Exp $
 .\"
 .\" Copyright (c)2005 YAMAMOTO Takashi,
 .\" All rights reserved.
@@ -87,7 +87,7 @@ flags may be bitwise ORed together:
 Specifies that the kthread must be allowed to use any machine-dependent
 per-CPU floating-point units or SIMD vector units, as in
 .Xr kthread_fpu_enter 9 / Xr kthread_fpu_exit 9 ,
-when it executes the worker function.u
+when it executes the worker function.
 .It Dv WQ_MPSAFE
 Specifies that the workqueue is multiprocessor safe and does its own locking;
 otherwise the kernel lock will be held while processing work.



CVS commit: src/share/man/man9

2020-08-01 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat Aug  1 09:50:43 UTC 2020

Modified Files:
src/share/man/man9: kthread.9

Log Message:
Fix typo in macro and merge to error descriptions for the same error


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/share/man/man9/kthread.9

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

Modified files:

Index: src/share/man/man9/kthread.9
diff -u src/share/man/man9/kthread.9:1.29 src/share/man/man9/kthread.9:1.30
--- src/share/man/man9/kthread.9:1.29	Sat Aug  1 02:04:55 2020
+++ src/share/man/man9/kthread.9	Sat Aug  1 09:50:42 2020
@@ -1,4 +1,4 @@
-.\" $NetBSD: kthread.9,v 1.29 2020/08/01 02:04:55 riastradh Exp $
+.\" $NetBSD: kthread.9,v 1.30 2020/08/01 09:50:42 wiz Exp $
 .\"
 .\" Copyright (c) 2000, 2007, 2008 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -63,7 +63,7 @@ units that are normally available to use
 kthreads between
 .Fn kthread_fpu_enter
 and
-.fn kthread_fpu_exit .
+.Fn kthread_fpu_exit .
 .Sh FUNCTIONS
 .Bl -tag -width compact
 .It Fn kthread_create "pri" "flags" "ci" "func" "arg" "newlp" "fmt" "..."
@@ -201,9 +201,8 @@ returns 0.
 Otherwise, the following error values are returned:
 .Bl -tag -width [EAGAIN]
 .It Bq Er EAGAIN
-The limit on the total number of system processes would be exceeded.
-.It Bq Er EAGAIN
-The limit
+The limit on the total number of system processes would be exceeded;
+or the limit
 .Dv RLIMIT_NPROC
 on the total number of processes under execution by this
 user id would be exceeded.



CVS commit: src/usr.bin/make

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 09:30:18 UTC 2020

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

Log Message:
make(1): make CondDoDefined simpler


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/usr.bin/make/cond.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/cond.c
diff -u src/usr.bin/make/cond.c:1.82 src/usr.bin/make/cond.c:1.83
--- src/usr.bin/make/cond.c:1.82	Sun Jul 26 20:21:31 2020
+++ src/usr.bin/make/cond.c	Sat Aug  1 09:30:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.82 2020/07/26 20:21:31 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.83 2020/08/01 09:30:17 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: cond.c,v 1.82 2020/07/26 20:21:31 rillig Exp $";
+static char rcsid[] = "$NetBSD: cond.c,v 1.83 2020/08/01 09:30:17 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)cond.c	8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: cond.c,v 1.82 2020/07/26 20:21:31 rillig Exp $");
+__RCSID("$NetBSD: cond.c,v 1.83 2020/08/01 09:30:17 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -334,16 +334,9 @@ CondGetArg(Boolean doEval, char **linePt
 static Boolean
 CondDoDefined(int argLen MAKE_ATTR_UNUSED, const char *arg)
 {
-char*p1;
-Boolean result;
-
-if (Var_Value(arg, VAR_CMD, ) != NULL) {
-	result = TRUE;
-} else {
-	result = FALSE;
-}
-
-free(p1);
+char *freeIt;
+Boolean result = Var_Value(arg, VAR_CMD, ) != NULL;
+free(freeIt);
 return result;
 }
 



CVS commit: src/sys/arch/mips/mips

2020-08-01 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Aug  1 09:29:18 UTC 2020

Modified Files:
src/sys/arch/mips/mips: db_interface.c

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/sys/arch/mips/mips/db_interface.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/mips/mips/db_interface.c
diff -u src/sys/arch/mips/mips/db_interface.c:1.86 src/sys/arch/mips/mips/db_interface.c:1.87
--- src/sys/arch/mips/mips/db_interface.c:1.86	Sun Jul 26 07:57:06 2020
+++ src/sys/arch/mips/mips/db_interface.c	Sat Aug  1 09:29:18 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_interface.c,v 1.86 2020/07/26 07:57:06 simonb Exp $	*/
+/*	$NetBSD: db_interface.c,v 1.87 2020/08/01 09:29:18 skrll Exp $	*/
 
 /*
  * Mach Operating System
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.86 2020/07/26 07:57:06 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.87 2020/08/01 09:29:18 skrll Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_cputype.h"	/* which mips CPUs do we support? */
@@ -702,7 +702,7 @@ db_mfcr_cmd(db_expr_t addr, bool have_ad
 		"mfcr %0,%1			\n\t"			\
 		".set pop 			\n\t"			\
 	: "=r"(value) : "r"(addr));
-	
+
 	db_printf("control reg 0x%" DDB_EXPR_FMT "x = 0x%" PRIx64 "\n",
 	addr, value);
 }
@@ -749,7 +749,7 @@ db_mach_nmi_cmd(db_expr_t addr, bool hav
 {
 	CPU_INFO_ITERATOR cii;
 	struct cpu_info *ci;
-	
+
 	if (!have_addr) {
 		db_printf("CPU not specific\n");
 		return;
@@ -803,7 +803,7 @@ const struct db_command db_machine_comma
 #endif	/* (MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2) > 0 */
 	{ DDB_ADD_CMD("kvtop",	db_kvtophys_cmd,	0,
 		"Print the physical address for a given kernel virtual address",
-		"address", 
+		"address",
 		"   address:\tvirtual address to look up") },
 	{ DDB_ADD_CMD("tlb",	db_tlbdump_cmd,		0,
 		"Print out TLB entries. (only works with options DEBUG)",
@@ -991,7 +991,7 @@ next_instr_address(db_addr_t pc, bool bd
 
 	if (bd == false)
 		return (pc + 4);
-	
+
 	if (pc < MIPS_KSEG0_START)
 		ins = mips_ufetch32((void *)pc);
 	else
@@ -1005,15 +1005,15 @@ next_instr_address(db_addr_t pc, bool bd
 
 #ifdef MULTIPROCESSOR
 
-bool 
+bool
 ddb_running_on_this_cpu_p(void)
-{   
+{
 	return ddb_cpu == cpu_number();
 }
 
-bool 
+bool
 ddb_running_on_any_cpu_p(void)
-{   
+{
 	return ddb_cpu != NOCPU;
 }
 
@@ -1031,7 +1031,7 @@ db_mach_cpu_cmd(db_expr_t addr, bool hav
 {
 	CPU_INFO_ITERATOR cii;
 	struct cpu_info *ci;
-	
+
 	if (!have_addr) {
 		cpu_debug_dump();
 		return;



CVS commit: src/common/lib/libc/arch/mips/atomic

2020-08-01 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Aug  1 09:26:49 UTC 2020

Modified Files:
src/common/lib/libc/arch/mips/atomic: atomic_add.S atomic_and.S
atomic_cas.S atomic_cas_up.S atomic_dec.S atomic_inc.S
atomic_op_asm.h atomic_or.S atomic_swap.S membar_ops.S

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/common/lib/libc/arch/mips/atomic/atomic_add.S \
src/common/lib/libc/arch/mips/atomic/atomic_dec.S \
src/common/lib/libc/arch/mips/atomic/atomic_inc.S \
src/common/lib/libc/arch/mips/atomic/atomic_swap.S
cvs rdiff -u -r1.4 -r1.5 src/common/lib/libc/arch/mips/atomic/atomic_and.S \
src/common/lib/libc/arch/mips/atomic/atomic_or.S
cvs rdiff -u -r1.6 -r1.7 src/common/lib/libc/arch/mips/atomic/atomic_cas.S
cvs rdiff -u -r1.2 -r1.3 src/common/lib/libc/arch/mips/atomic/atomic_cas_up.S
cvs rdiff -u -r1.3 -r1.4 src/common/lib/libc/arch/mips/atomic/atomic_op_asm.h
cvs rdiff -u -r1.8 -r1.9 src/common/lib/libc/arch/mips/atomic/membar_ops.S

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

Modified files:

Index: src/common/lib/libc/arch/mips/atomic/atomic_add.S
diff -u src/common/lib/libc/arch/mips/atomic/atomic_add.S:1.5 src/common/lib/libc/arch/mips/atomic/atomic_add.S:1.6
--- src/common/lib/libc/arch/mips/atomic/atomic_add.S:1.5	Mon Jun  1 23:16:54 2015
+++ src/common/lib/libc/arch/mips/atomic/atomic_add.S	Sat Aug  1 09:26:49 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: atomic_add.S,v 1.5 2015/06/01 23:16:54 matt Exp $	*/
+/*	$NetBSD: atomic_add.S,v 1.6 2020/08/01 09:26:49 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -12,7 +12,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *notice, this list of conditions and the following disclaimer in the
  *documentation and/or other materials provided with the distribution.
- *  
+ *
  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
@@ -29,7 +29,7 @@
 #include 
 #include "atomic_op_asm.h"
 
-RCSID("$NetBSD: atomic_add.S,v 1.5 2015/06/01 23:16:54 matt Exp $")
+RCSID("$NetBSD: atomic_add.S,v 1.6 2020/08/01 09:26:49 skrll Exp $")
 
 	.text
 	.set	noreorder
Index: src/common/lib/libc/arch/mips/atomic/atomic_dec.S
diff -u src/common/lib/libc/arch/mips/atomic/atomic_dec.S:1.5 src/common/lib/libc/arch/mips/atomic/atomic_dec.S:1.6
--- src/common/lib/libc/arch/mips/atomic/atomic_dec.S:1.5	Mon Jun  1 23:16:54 2015
+++ src/common/lib/libc/arch/mips/atomic/atomic_dec.S	Sat Aug  1 09:26:49 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: atomic_dec.S,v 1.5 2015/06/01 23:16:54 matt Exp $	*/
+/*	$NetBSD: atomic_dec.S,v 1.6 2020/08/01 09:26:49 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -12,7 +12,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *notice, this list of conditions and the following disclaimer in the
  *documentation and/or other materials provided with the distribution.
- *  
+ *
  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
@@ -29,7 +29,7 @@
 #include 
 #include "atomic_op_asm.h"
 
-RCSID("$NetBSD: atomic_dec.S,v 1.5 2015/06/01 23:16:54 matt Exp $")
+RCSID("$NetBSD: atomic_dec.S,v 1.6 2020/08/01 09:26:49 skrll Exp $")
 
 	.text
 	.set	noreorder
Index: src/common/lib/libc/arch/mips/atomic/atomic_inc.S
diff -u src/common/lib/libc/arch/mips/atomic/atomic_inc.S:1.5 src/common/lib/libc/arch/mips/atomic/atomic_inc.S:1.6
--- src/common/lib/libc/arch/mips/atomic/atomic_inc.S:1.5	Mon Jun  1 23:16:54 2015
+++ src/common/lib/libc/arch/mips/atomic/atomic_inc.S	Sat Aug  1 09:26:49 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: atomic_inc.S,v 1.5 2015/06/01 23:16:54 matt Exp $	*/
+/*	$NetBSD: atomic_inc.S,v 1.6 2020/08/01 09:26:49 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -12,7 +12,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *notice, this list of conditions and the following disclaimer in the
  *documentation and/or other materials provided with the distribution.
- *  
+ *
  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
@@ -29,7 +29,7 @@
 #include 
 #include "atomic_op_asm.h"
 
-RCSID("$NetBSD: atomic_inc.S,v 1.5 2015/06/01 23:16:54 matt Exp $")
+RCSID("$NetBSD: atomic_inc.S,v 1.6 2020/08/01 09:26:49 skrll Exp $")
 
 	.text
 	.set	noreorder
Index: 

CVS commit: src/usr.bin/make

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 09:25:36 UTC 2020

Modified Files:
src/usr.bin/make: compat.c main.c make.c meta.c nonints.h parse.c
trace.c var.c

Log Message:
make(1): let Var_Value return a const char *

The return value must not be modified anyway, so let the compiler check
this for free.


To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.116 src/usr.bin/make/compat.c
cvs rdiff -u -r1.288 -r1.289 src/usr.bin/make/main.c
cvs rdiff -u -r1.101 -r1.102 src/usr.bin/make/make.c
cvs rdiff -u -r1.89 -r1.90 src/usr.bin/make/meta.c
cvs rdiff -u -r1.87 -r1.88 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.243 -r1.244 src/usr.bin/make/parse.c
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/trace.c
cvs rdiff -u -r1.374 -r1.375 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/compat.c
diff -u src/usr.bin/make/compat.c:1.115 src/usr.bin/make/compat.c:1.116
--- src/usr.bin/make/compat.c:1.115	Tue Jul 28 16:42:22 2020
+++ src/usr.bin/make/compat.c	Sat Aug  1 09:25:36 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.115 2020/07/28 16:42:22 rillig Exp $	*/
+/*	$NetBSD: compat.c,v 1.116 2020/08/01 09:25:36 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: compat.c,v 1.115 2020/07/28 16:42:22 rillig Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.116 2020/08/01 09:25:36 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)compat.c	8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: compat.c,v 1.115 2020/07/28 16:42:22 rillig Exp $");
+__RCSID("$NetBSD: compat.c,v 1.116 2020/08/01 09:25:36 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -126,8 +126,8 @@ static void
 CompatDeleteTarget(GNode *gn)
 {
 if ((gn != NULL) && !Targ_Precious (gn)) {
-	char	  *p1;
-	char 	  *file = Var_Value(TARGET, gn, );
+	char *p1;
+	const char *file = Var_Value(TARGET, gn, );
 
 	if (!noExecute && eunlink(file) != -1) {
 	Error("*** %s removed", file);

Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.288 src/usr.bin/make/main.c:1.289
--- src/usr.bin/make/main.c:1.288	Sat Aug  1 09:08:17 2020
+++ src/usr.bin/make/main.c	Sat Aug  1 09:25:36 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.288 2020/08/01 09:08:17 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.289 2020/08/01 09:25:36 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.288 2020/08/01 09:08:17 rillig Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.289 2020/08/01 09:25:36 rillig Exp $";
 #else
 #include 
 #ifndef lint
@@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #if 0
 static char sccsid[] = "@(#)main.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.288 2020/08/01 09:08:17 rillig Exp $");
+__RCSID("$NetBSD: main.c,v 1.289 2020/08/01 09:25:36 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -695,7 +695,7 @@ Main_ParseArgLine(const char *line)
 	int argc;			/* Number of arguments in argv */
 	char *args;			/* Space used by the args */
 	char *p1;
-	char *argv0 = Var_Value(".MAKE", VAR_GLOBAL, );
+	const char *argv0 = Var_Value(".MAKE", VAR_GLOBAL, );
 
 	if (line == NULL)
 		return;
@@ -870,7 +870,7 @@ doPrintVars(void)
 	for (ln = Lst_First(variables); ln != NULL;
 	ln = Lst_Succ(ln)) {
 		char *var = (char *)Lst_Datum(ln);
-		char *value;
+		const char *value;
 		char *p1;
 
 		if (strchr(var, '$')) {
@@ -1975,7 +1975,8 @@ char *
 cached_realpath(const char *pathname, char *resolved)
 {
 GNode *cache;
-char *rp, *cp;
+const char *rp;
+char *cp;
 
 if (!pathname || !pathname[0])
 	return NULL;

Index: src/usr.bin/make/make.c
diff -u src/usr.bin/make/make.c:1.101 src/usr.bin/make/make.c:1.102
--- src/usr.bin/make/make.c:1.101	Tue Jul 28 16:42:22 2020
+++ src/usr.bin/make/make.c	Sat Aug  1 09:25:36 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.c,v 1.101 2020/07/28 16:42:22 rillig Exp $	*/
+/*	$NetBSD: make.c,v 1.102 2020/08/01 09:25:36 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: make.c,v 1.101 2020/07/28 16:42:22 rillig Exp $";
+static char rcsid[] = "$NetBSD: make.c,v 1.102 2020/08/01 09:25:36 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)make.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: make.c,v 1.101 2020/07/28 16:42:22 rillig Exp $");
+__RCSID("$NetBSD: make.c,v 1.102 2020/08/01 09:25:36 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -680,7 +680,7 @@ void
 Make_Update(GNode *cgn)
 {
 GNode 	*pgn;	/* the parent node */
-char  	*cname;	/* the child's name */
+const char	*cname;	/* the 

CVS commit: src/usr.bin/make

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 09:08:17 UTC 2020

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

Log Message:
make(1): make Main_SetVarObjdir const-correct and use separate variables

The return value of Var_Value should be const char *, but changing that
now would be too large a change.


To generate a diff of this commit:
cvs rdiff -u -r1.287 -r1.288 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.287 src/usr.bin/make/main.c:1.288
--- src/usr.bin/make/main.c:1.287	Sat Aug  1 08:55:28 2020
+++ src/usr.bin/make/main.c	Sat Aug  1 09:08:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.287 2020/08/01 08:55:28 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.288 2020/08/01 09:08:17 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.287 2020/08/01 08:55:28 rillig Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.288 2020/08/01 09:08:17 rillig Exp $";
 #else
 #include 
 #ifndef lint
@@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #if 0
 static char sccsid[] = "@(#)main.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.287 2020/08/01 08:55:28 rillig Exp $");
+__RCSID("$NetBSD: main.c,v 1.288 2020/08/01 09:08:17 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -762,23 +762,24 @@ Main_SetObjdir(const char *fmt, ...)
 static Boolean
 Main_SetVarObjdir(const char *var, const char *suffix)
 {
-	char *p, *path, *xpath;
-
-	if ((path = Var_Value(var, VAR_CMD, )) == NULL ||
-	*path == '\0')
+	char *path_freeIt;
+	const char *path = Var_Value(var, VAR_CMD, _freeIt);
+	if (path == NULL || path[0] == '\0') {
+		free(path_freeIt);
 		return FALSE;
+	}
 
 	/* expand variable substitutions */
+	const char *xpath = path;
+	char *xpath_freeIt = NULL;
 	if (strchr(path, '$') != 0)
-		xpath = Var_Subst(path, VAR_GLOBAL, VARE_WANTRES);
-	else
-		xpath = path;
+		xpath = xpath_freeIt = Var_Subst(path, VAR_GLOBAL,
+		 VARE_WANTRES);
 
 	(void)Main_SetObjdir("%s%s", xpath, suffix);
 
-	if (xpath != path)
-		free(xpath);
-	free(p);
+	free(xpath_freeIt);
+	free(path_freeIt);
 	return TRUE;
 }
 



CVS commit: src/usr.bin/make

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 08:55:28 UTC 2020

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

Log Message:
make(1): merge duplicate code for concatenating strings


To generate a diff of this commit:
cvs rdiff -u -r1.286 -r1.287 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.286 src/usr.bin/make/main.c:1.287
--- src/usr.bin/make/main.c:1.286	Sat Aug  1 08:49:47 2020
+++ src/usr.bin/make/main.c	Sat Aug  1 08:55:28 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.286 2020/08/01 08:49:47 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.287 2020/08/01 08:55:28 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.286 2020/08/01 08:49:47 rillig Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.287 2020/08/01 08:55:28 rillig Exp $";
 #else
 #include 
 #ifndef lint
@@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #if 0
 static char sccsid[] = "@(#)main.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.286 2020/08/01 08:49:47 rillig Exp $");
+__RCSID("$NetBSD: main.c,v 1.287 2020/08/01 08:55:28 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -694,9 +694,8 @@ Main_ParseArgLine(const char *line)
 	char **argv;			/* Manufactured argument vector */
 	int argc;			/* Number of arguments in argv */
 	char *args;			/* Space used by the args */
-	char *buf, *p1;
+	char *p1;
 	char *argv0 = Var_Value(".MAKE", VAR_GLOBAL, );
-	size_t len;
 
 	if (line == NULL)
 		return;
@@ -705,8 +704,7 @@ Main_ParseArgLine(const char *line)
 	if (!*line)
 		return;
 
-	buf = bmake_malloc(len = strlen(line) + strlen(argv0) + 2);
-	(void)snprintf(buf, len, "%s %s", argv0, line);
+	char *buf = str_concat(argv0, line, STR_ADDSPACE);
 	free(p1);
 
 	argv = brk_string(buf, , TRUE, );



CVS commit: src/usr.bin/make

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 08:49:47 UTC 2020

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

Log Message:
make(1): eliminate unsatisfiable condition in is_relpath


To generate a diff of this commit:
cvs rdiff -u -r1.285 -r1.286 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.285 src/usr.bin/make/main.c:1.286
--- src/usr.bin/make/main.c:1.285	Fri Jul 31 20:22:10 2020
+++ src/usr.bin/make/main.c	Sat Aug  1 08:49:47 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.285 2020/07/31 20:22:10 sjg Exp $	*/
+/*	$NetBSD: main.c,v 1.286 2020/08/01 08:49:47 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.285 2020/07/31 20:22:10 sjg Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.286 2020/08/01 08:49:47 rillig Exp $";
 #else
 #include 
 #ifndef lint
@@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #if 0
 static char sccsid[] = "@(#)main.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.285 2020/07/31 20:22:10 sjg Exp $");
+__RCSID("$NetBSD: main.c,v 1.286 2020/08/01 08:49:47 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -368,7 +368,7 @@ debug_setbuf:
 /*
  * does path contain any relative components
  */
-static int
+static Boolean
 is_relpath(const char *path)
 {
 	const char *cp;
@@ -376,10 +376,7 @@ is_relpath(const char *path)
 	if (path[0] != '/')
 		return TRUE;
 	cp = path;
-	do {
-		cp = strstr(cp, "/.");
-		if (!cp)
-			break;
+	while ((cp = strstr(cp, "/.")) != NULL) {
 		cp += 2;
 		if (cp[0] == '/' || cp[0] == '\0')
 			return TRUE;
@@ -387,7 +384,7 @@ is_relpath(const char *path)
 			if (cp[1] == '/' || cp[1] == '\0')
 return TRUE;
 		}
-	} while (cp);
+	}
 	return FALSE;
 }
 



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

2020-08-01 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Aug  1 08:47:05 UTC 2020

Modified Files:
src/sys/arch/aarch64/include: armreg.h

Log Message:
The system registers we modify can have an impact on memory accesses, and
we don't want the compiler to randomly re-order the instructions, so add
barriers. Same as WRMSR on x86.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/aarch64/include/armreg.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/aarch64/include/armreg.h
diff -u src/sys/arch/aarch64/include/armreg.h:1.50 src/sys/arch/aarch64/include/armreg.h:1.51
--- src/sys/arch/aarch64/include/armreg.h:1.50	Wed Jul  1 08:01:07 2020
+++ src/sys/arch/aarch64/include/armreg.h	Sat Aug  1 08:47:05 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: armreg.h,v 1.50 2020/07/01 08:01:07 ryo Exp $ */
+/* $NetBSD: armreg.h,v 1.51 2020/08/01 08:47:05 maxv Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@ reg_##regname##_write(uint64_t __val)			
 {\
 	__asm __volatile(	\
 	ASM_ARCH(arch)	\
-	"msr " #regdesc ", %0" :: "r"(__val)		\
+	"msr " #regdesc ", %0" :: "r"(__val) : "memory"	\
 	);			\
 }
 
@@ -77,7 +77,9 @@ reg_##regname##_write(uint64_t __val)			
 static __inline void		\
 reg_##regname##_write(uint64_t __val)\
 {\
-	__asm __volatile("msr " #regdesc ", %0" :: "n"(__val));	\
+	__asm __volatile(	\
+	"msr " #regdesc ", %0" :: "n"(__val) : "memory"	\
+	);			\
 }
 
 #define AARCH64REG_READ_INLINE(regname)\
@@ -97,7 +99,9 @@ reg_##regname##_write(uint64_t __val)			
 static __inline void		\
 reg_##regname##_write(uint64_t __val)\
 {\
-	__asm __volatile("at " #regdesc ", %0" :: "r"(__val));	\
+	__asm __volatile(	\
+	"at " #regdesc ", %0" :: "r"(__val) : "memory"	\
+	);			\
 }
 
 #define AARCH64REG_ATWRITE_INLINE(regname)			\



CVS commit: src/usr.bin/make

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 08:42:33 UTC 2020

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

Log Message:
make(1): fix documentation of Var_Value


To generate a diff of this commit:
cvs rdiff -u -r1.373 -r1.374 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.373 src/usr.bin/make/var.c:1.374
--- src/usr.bin/make/var.c:1.373	Sat Aug  1 07:29:04 2020
+++ src/usr.bin/make/var.c	Sat Aug  1 08:42:33 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.373 2020/08/01 07:29:04 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.374 2020/08/01 08:42:33 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.373 2020/08/01 07:29:04 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.374 2020/08/01 08:42:33 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.373 2020/08/01 07:29:04 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.374 2020/08/01 08:42:33 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1007,7 +1007,7 @@ Var_Exists(const char *name, GNode *ctxt
  *---
  * Var_Value --
  *	Return the unexpanded value of the given variable in the given
- *	context.
+ *	context, or the usual contexts.
  *
  * Input:
  *	name		name to find



CVS commit: src/doc

2020-08-01 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Aug  1 08:22:37 UTC 2020

Modified Files:
src/doc: CHANGES

Log Message:
Note BRIDGE_IPF removal.


To generate a diff of this commit:
cvs rdiff -u -r1.2721 -r1.2722 src/doc/CHANGES

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
diff -u src/doc/CHANGES:1.2721 src/doc/CHANGES:1.2722
--- src/doc/CHANGES:1.2721	Tue Jul 28 10:29:30 2020
+++ src/doc/CHANGES	Sat Aug  1 08:22:37 2020
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2721 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2722 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -262,3 +262,5 @@ Changes from NetBSD 9.0 to NetBSD 10.0:
 		[tsutsui 20200722]
 	wwanc(4): Add driver for Intel XMM7360 LTE modem [jdolecek 20200726]
 	xen: MSI enabled by default [jdolecek 20200728]
+	kernel: remove the BRIDGE_IPF option, build its code by default
+		unconditionally. [maxv 20200801]



CVS commit: src

2020-08-01 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Aug  1 08:20:53 UTC 2020

Modified Files:
src/doc: TODO.smpnet
src/share/man/man4: bridge.4 options.4
src/sys/arch/acorn32/conf: EB7500ATX GENERIC
src/sys/arch/alpha/conf: GENERIC
src/sys/arch/amd64/conf: ALL GENERIC XEN3_DOM0 XEN3_DOMU
src/sys/arch/amiga/conf: DRACO GENERIC GENERIC.in INSTALL
src/sys/arch/amigappc/conf: GENERIC NULL
src/sys/arch/arc/conf: GENERIC
src/sys/arch/bebox/conf: GENERIC
src/sys/arch/cats/conf: GENERIC
src/sys/arch/cesfic/conf: GENERIC
src/sys/arch/cobalt/conf: GENERIC INSTALL
src/sys/arch/dreamcast/conf: G1IDE GENERIC
src/sys/arch/emips/conf: GENERIC
src/sys/arch/evbarm/conf: ARMADILLO210 ARMADILLO9 CUBOX DUOVERO GUMSTIX
HDL_G HPT5325 IYONIX MARVELL_NAS MINI2440 MMNET_GENERIC
MPCSA_GENERIC MV2120 OPENBLOCKS_A6 OPENBLOCKS_AX3 PEPPER SHEEVAPLUG
SMDK2410 SMDK2800 TWINTAIL
src/sys/arch/evbmips/conf: GDIUM LINKITSMART7688 LOONGSON SBMIPS
src/sys/arch/evbppc/conf: EXPLORA451 OPENBLOCKS266 OPENBLOCKS600
src/sys/arch/evbsh3/conf: NEXTVOD
src/sys/arch/ews4800mips/conf: GENERIC
src/sys/arch/hp300/conf: GENERIC
src/sys/arch/hpcmips/conf: GENERIC
src/sys/arch/hppa/conf: GENERIC
src/sys/arch/i386/conf: ALL GENERIC XEN3PAE_DOM0 XEN3PAE_DOMU
src/sys/arch/ia64/conf: GENERIC.SKI
src/sys/arch/iyonix/conf: GENERIC
src/sys/arch/landisk/conf: GENERIC
src/sys/arch/luna68k/conf: GENERIC INSTALL
src/sys/arch/mac68k/conf: GENERIC
src/sys/arch/macppc/conf: GENERIC GENERIC_601
src/sys/arch/mipsco/conf: GENERIC
src/sys/arch/mmeye/conf: GENERIC MMEYE_WLF
src/sys/arch/mvme68k/conf: GENERIC
src/sys/arch/netwinder/conf: GENERIC
src/sys/arch/news68k/conf: GENERIC GENERIC_TINY
src/sys/arch/newsmips/conf: GENERIC
src/sys/arch/next68k/conf: GENERIC
src/sys/arch/ofppc/conf: GENERIC
src/sys/arch/pmax/conf: GENERIC GENERIC64
src/sys/arch/prep/conf: GENERIC
src/sys/arch/rs6000/conf: GENERIC
src/sys/arch/sandpoint/conf: ENCPP1 GENERIC SANDPOINT
src/sys/arch/sbmips/conf: GENERIC
src/sys/arch/sgimips/conf: GENERIC32_IP12 GENERIC32_IP2x GENERIC32_IP3x
src/sys/arch/sparc/conf: GENERIC
src/sys/arch/sparc64/conf: GENERIC
src/sys/arch/sun2/conf: GENERIC
src/sys/arch/sun3/conf: DISKLESS GENERIC GENERIC3X
src/sys/arch/vax/conf: GENERIC VAX780
src/sys/arch/x68k/conf: GENERIC
src/sys/conf: files

Log Message:
Remove references to BRIDGE_IPF, it is now compiled in by default.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/doc/TODO.smpnet
cvs rdiff -u -r1.12 -r1.13 src/share/man/man4/bridge.4
cvs rdiff -u -r1.512 -r1.513 src/share/man/man4/options.4
cvs rdiff -u -r1.71 -r1.72 src/sys/arch/acorn32/conf/EB7500ATX
cvs rdiff -u -r1.131 -r1.132 src/sys/arch/acorn32/conf/GENERIC
cvs rdiff -u -r1.402 -r1.403 src/sys/arch/alpha/conf/GENERIC
cvs rdiff -u -r1.158 -r1.159 src/sys/arch/amd64/conf/ALL
cvs rdiff -u -r1.573 -r1.574 src/sys/arch/amd64/conf/GENERIC
cvs rdiff -u -r1.182 -r1.183 src/sys/arch/amd64/conf/XEN3_DOM0
cvs rdiff -u -r1.93 -r1.94 src/sys/arch/amd64/conf/XEN3_DOMU
cvs rdiff -u -r1.192 -r1.193 src/sys/arch/amiga/conf/DRACO
cvs rdiff -u -r1.327 -r1.328 src/sys/arch/amiga/conf/GENERIC
cvs rdiff -u -r1.143 -r1.144 src/sys/arch/amiga/conf/GENERIC.in
cvs rdiff -u -r1.133 -r1.134 src/sys/arch/amiga/conf/INSTALL
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/amigappc/conf/GENERIC
cvs rdiff -u -r1.57 -r1.58 src/sys/arch/amigappc/conf/NULL
cvs rdiff -u -r1.198 -r1.199 src/sys/arch/arc/conf/GENERIC
cvs rdiff -u -r1.162 -r1.163 src/sys/arch/bebox/conf/GENERIC
cvs rdiff -u -r1.181 -r1.182 src/sys/arch/cats/conf/GENERIC
cvs rdiff -u -r1.72 -r1.73 src/sys/arch/cesfic/conf/GENERIC
cvs rdiff -u -r1.168 -r1.169 src/sys/arch/cobalt/conf/GENERIC
cvs rdiff -u -r1.74 -r1.75 src/sys/arch/cobalt/conf/INSTALL
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/dreamcast/conf/G1IDE
cvs rdiff -u -r1.132 -r1.133 src/sys/arch/dreamcast/conf/GENERIC
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/emips/conf/GENERIC
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/evbarm/conf/ARMADILLO210
cvs rdiff -u -r1.62 -r1.63 src/sys/arch/evbarm/conf/ARMADILLO9 \
src/sys/arch/evbarm/conf/HDL_G
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/evbarm/conf/CUBOX
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/evbarm/conf/DUOVERO
cvs rdiff -u -r1.104 -r1.105 src/sys/arch/evbarm/conf/GUMSTIX
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/evbarm/conf/HPT5325
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/evbarm/conf/IYONIX
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/evbarm/conf/MARVELL_NAS
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/evbarm/conf/MINI2440
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/evbarm/conf/MMNET_GENERIC
cvs rdiff -u -r1.72 

CVS commit: src/sys/dev/nvmm

2020-08-01 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Aug  1 08:18:37 UTC 2020

Modified Files:
src/sys/dev/nvmm: nvmm.c nvmm.h nvmm_internal.h

Log Message:
Put the few x86-specific structures under #ifdef __x86_64__, for clarity.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/nvmm/nvmm.c
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/nvmm/nvmm.h
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/nvmm/nvmm_internal.h

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

Modified files:

Index: src/sys/dev/nvmm/nvmm.c
diff -u src/sys/dev/nvmm/nvmm.c:1.32 src/sys/dev/nvmm/nvmm.c:1.33
--- src/sys/dev/nvmm/nvmm.c:1.32	Fri Jul  3 16:09:54 2020
+++ src/sys/dev/nvmm/nvmm.c	Sat Aug  1 08:18:36 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm.c,v 1.32 2020/07/03 16:09:54 maxv Exp $	*/
+/*	$NetBSD: nvmm.c,v 1.33 2020/08/01 08:18:36 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018-2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.32 2020/07/03 16:09:54 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.33 2020/08/01 08:18:36 maxv Exp $");
 
 #include 
 #include 
@@ -59,8 +59,10 @@ static struct nvmm_machine machines[NVMM
 static volatile unsigned int nmachines __cacheline_aligned;
 
 static const struct nvmm_impl *nvmm_impl_list[] = {
+#if defined(__x86_64__)
 	_x86_svm,	/* x86 AMD SVM */
 	_x86_vmx	/* x86 Intel VMX */
+#endif
 };
 
 static const struct nvmm_impl *nvmm_impl = NULL;

Index: src/sys/dev/nvmm/nvmm.h
diff -u src/sys/dev/nvmm/nvmm.h:1.12 src/sys/dev/nvmm/nvmm.h:1.13
--- src/sys/dev/nvmm/nvmm.h:1.12	Mon Oct 28 08:30:49 2019
+++ src/sys/dev/nvmm/nvmm.h	Sat Aug  1 08:18:36 2020
@@ -1,7 +1,7 @@
-/*	$NetBSD: nvmm.h,v 1.12 2019/10/28 08:30:49 maxv Exp $	*/
+/*	$NetBSD: nvmm.h,v 1.13 2020/08/01 08:18:36 maxv Exp $	*/
 
 /*
- * Copyright (c) 2018-2019 The NetBSD Foundation, Inc.
+ * Copyright (c) 2018-2020 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -44,7 +44,7 @@ typedef uint64_t	gvaddr_t;
 typedef uint32_t	nvmm_machid_t;
 typedef uint32_t	nvmm_cpuid_t;
 
-#ifdef __x86_64__
+#if defined(__x86_64__)
 #include 
 #endif
 

Index: src/sys/dev/nvmm/nvmm_internal.h
diff -u src/sys/dev/nvmm/nvmm_internal.h:1.16 src/sys/dev/nvmm/nvmm_internal.h:1.17
--- src/sys/dev/nvmm/nvmm_internal.h:1.16	Fri Jul  3 16:09:54 2020
+++ src/sys/dev/nvmm/nvmm_internal.h	Sat Aug  1 08:18:36 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm_internal.h,v 1.16 2020/07/03 16:09:54 maxv Exp $	*/
+/*	$NetBSD: nvmm_internal.h,v 1.17 2020/08/01 08:18:36 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018-2020 The NetBSD Foundation, Inc.
@@ -119,8 +119,10 @@ struct nvmm_impl {
 	struct nvmm_vcpu_exit *);
 };
 
+#if defined(__x86_64__)
 extern const struct nvmm_impl nvmm_x86_svm;
 extern const struct nvmm_impl nvmm_x86_vmx;
+#endif
 
 static inline bool
 nvmm_return_needed(void)



CVS commit: src/usr.bin/make

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 07:29:04 UTC 2020

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

Log Message:
make(1): use better variable names in Var_Exists

Calling strchr just to initialize a variable to NULL is not as
straight-forward as possible.

The unspecific variable name cp made it unnecessarily difficult to
understand its purpose.


To generate a diff of this commit:
cvs rdiff -u -r1.372 -r1.373 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.372 src/usr.bin/make/var.c:1.373
--- src/usr.bin/make/var.c:1.372	Sat Aug  1 07:14:04 2020
+++ src/usr.bin/make/var.c	Sat Aug  1 07:29:04 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.372 2020/08/01 07:14:04 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.373 2020/08/01 07:29:04 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.372 2020/08/01 07:14:04 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.373 2020/08/01 07:29:04 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.372 2020/08/01 07:14:04 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.373 2020/08/01 07:29:04 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -990,13 +990,12 @@ Var_Append(const char *name, const char 
 Boolean
 Var_Exists(const char *name, GNode *ctxt)
 {
-Var		  *v;
-char  *cp;
+char *name_freeIt = NULL;
+if (strchr(name, '$') != NULL)
+	name = name_freeIt = Var_Subst(name, ctxt, VARE_WANTRES);
 
-if ((cp = strchr(name, '$')) != NULL)
-	cp = Var_Subst(name, ctxt, VARE_WANTRES);
-v = VarFind(cp ? cp : name, ctxt, FIND_CMD | FIND_GLOBAL | FIND_ENV);
-free(cp);
+Var *v = VarFind(name, ctxt, FIND_CMD | FIND_GLOBAL | FIND_ENV);
+free(name_freeIt);
 if (v == NULL)
 	return FALSE;
 



CVS commit: src/sys/uvm/pmap

2020-08-01 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Aug  1 07:14:05 UTC 2020

Modified Files:
src/sys/uvm/pmap: pmap_tlb.h

Log Message:
Provide a TLBINFO_OWNED


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/uvm/pmap/pmap_tlb.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/uvm/pmap/pmap_tlb.h
diff -u src/sys/uvm/pmap/pmap_tlb.h:1.13 src/sys/uvm/pmap/pmap_tlb.h:1.14
--- src/sys/uvm/pmap/pmap_tlb.h:1.13	Mon Feb 19 22:01:15 2018
+++ src/sys/uvm/pmap/pmap_tlb.h	Sat Aug  1 07:14:05 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap_tlb.h,v 1.13 2018/02/19 22:01:15 jdolecek Exp $	*/
+/*	$NetBSD: pmap_tlb.h,v 1.14 2020/08/01 07:14:05 skrll Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -96,6 +96,7 @@ struct pmap_asid_info {
 
 #define	TLBINFO_LOCK(ti)		mutex_spin_enter((ti)->ti_lock)
 #define	TLBINFO_UNLOCK(ti)		mutex_spin_exit((ti)->ti_lock)
+#define	TLBINFO_OWNED(ti)		mutex_owned((ti)->ti_lock)
 #define	PMAP_PAI_ASIDVALID_P(pai, ti)	((pai)->pai_asid != 0)
 #define	PMAP_PAI(pmap, ti)		(&(pmap)->pm_pai[tlbinfo_index(ti)])
 #define	PAI_PMAP(pai, ti)	\



CVS commit: src/usr.bin/make

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 07:14:04 UTC 2020

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

Log Message:
make(1): make condition in Var_Export1 simpler to read


To generate a diff of this commit:
cvs rdiff -u -r1.371 -r1.372 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.371 src/usr.bin/make/var.c:1.372
--- src/usr.bin/make/var.c:1.371	Sat Aug  1 07:10:37 2020
+++ src/usr.bin/make/var.c	Sat Aug  1 07:14:04 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.371 2020/08/01 07:10:37 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.372 2020/08/01 07:14:04 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.371 2020/08/01 07:10:37 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.372 2020/08/01 07:14:04 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.371 2020/08/01 07:10:37 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.372 2020/08/01 07:14:04 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -524,10 +524,8 @@ Var_Export1(const char *name, VarExportF
 v = VarFind(name, VAR_GLOBAL, 0);
 if (v == NULL)
 	return 0;
-if (!parent &&
-	(v->flags & (VAR_EXPORTED | VAR_REEXPORT)) == VAR_EXPORTED) {
-	return 0;			/* nothing to do */
-}
+if (!parent && (v->flags & VAR_EXPORTED) && !(v->flags & VAR_REEXPORT))
+	return 0;		/* nothing to do */
 val = Buf_GetAll(>val, NULL);
 if (!(flags & VAR_EXPORT_LITERAL) && strchr(val, '$')) {
 	if (parent) {



CVS commit: src/usr.bin/make

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 07:10:37 UTC 2020

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

Log Message:
make(1): use consistent pattern for testing flags


To generate a diff of this commit:
cvs rdiff -u -r1.370 -r1.371 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.370 src/usr.bin/make/var.c:1.371
--- src/usr.bin/make/var.c:1.370	Sat Aug  1 07:03:50 2020
+++ src/usr.bin/make/var.c	Sat Aug  1 07:10:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.370 2020/08/01 07:03:50 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.371 2020/08/01 07:10:37 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.370 2020/08/01 07:03:50 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.371 2020/08/01 07:10:37 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.370 2020/08/01 07:03:50 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.371 2020/08/01 07:10:37 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -529,7 +529,7 @@ Var_Export1(const char *name, VarExportF
 	return 0;			/* nothing to do */
 }
 val = Buf_GetAll(>val, NULL);
-if ((flags & VAR_EXPORT_LITERAL) == 0 && strchr(val, '$')) {
+if (!(flags & VAR_EXPORT_LITERAL) && strchr(val, '$')) {
 	if (parent) {
 	/*
 	 * Flag this as something we need to re-export.
@@ -805,7 +805,7 @@ Var_Set_with_flags(const char *name, con
 if (ctxt == VAR_GLOBAL) {
 	v = VarFind(name, VAR_CMD, 0);
 	if (v != NULL) {
-	if ((v->flags & VAR_FROM_CMD)) {
+	if (v->flags & VAR_FROM_CMD) {
 		if (DEBUG(VAR)) {
 		fprintf(debug_file, "%s:%s = %s ignored!\n", ctxt->name, name, val);
 		}
@@ -816,7 +816,7 @@ Var_Set_with_flags(const char *name, con
 }
 v = VarFind(name, ctxt, 0);
 if (v == NULL) {
-	if (ctxt == VAR_CMD && (flags & VAR_NO_EXPORT) == 0) {
+	if (ctxt == VAR_CMD && !(flags & VAR_NO_EXPORT)) {
 	/*
 	 * This var would normally prevent the same name being added
 	 * to VAR_GLOBAL, so delete it from there if needed.
@@ -833,7 +833,7 @@ Var_Set_with_flags(const char *name, con
 	if (DEBUG(VAR)) {
 	fprintf(debug_file, "%s:%s = %s\n", ctxt->name, name, val);
 	}
-	if ((v->flags & VAR_EXPORTED)) {
+	if (v->flags & VAR_EXPORTED) {
 	Var_Export1(name, VAR_EXPORT_PARENT);
 	}
 }
@@ -841,7 +841,7 @@ Var_Set_with_flags(const char *name, con
  * Any variables given on the command line are automatically exported
  * to the environment (as per POSIX standard)
  */
-if (ctxt == VAR_CMD && (flags & VAR_NO_EXPORT) == 0) {
+if (ctxt == VAR_CMD && !(flags & VAR_NO_EXPORT)) {
 	if (v == NULL) {
 	/* we just added it */
 	v = VarFind(name, ctxt, 0);
@@ -3109,7 +3109,7 @@ ApplyModifiers(
 		st.val = ApplyModifiers(_pp, st.val, 0, 0, v,
 	ctxt, eflags, freePtr);
 		if (st.val == var_Error
-		|| (st.val == varNoError && (st.eflags & VARE_UNDEFERR) == 0)
+		|| (st.val == varNoError && !(st.eflags & VARE_UNDEFERR))
 		|| *rval_pp != '\0') {
 		free(freeIt);
 		goto out;	/* error already reported */



CVS commit: src/sys/arch/mips/mips

2020-08-01 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sat Aug  1 07:09:41 UTC 2020

Modified Files:
src/sys/arch/mips/mips: lock_stubs_llsc.S

Log Message:
Add a comment to say that an Octeon "sync 4" is "syncw" - sync all writes.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/mips/mips/lock_stubs_llsc.S

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/mips/mips/lock_stubs_llsc.S
diff -u src/sys/arch/mips/mips/lock_stubs_llsc.S:1.9 src/sys/arch/mips/mips/lock_stubs_llsc.S:1.10
--- src/sys/arch/mips/mips/lock_stubs_llsc.S:1.9	Sat Apr  6 03:06:26 2019
+++ src/sys/arch/mips/mips/lock_stubs_llsc.S	Sat Aug  1 07:09:41 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lock_stubs_llsc.S,v 1.9 2019/04/06 03:06:26 thorpej Exp $	*/
+/*	$NetBSD: lock_stubs_llsc.S,v 1.10 2020/08/01 07:09:41 simonb Exp $	*/
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 
 #include 
 
-RCSID("$NetBSD: lock_stubs_llsc.S,v 1.9 2019/04/06 03:06:26 thorpej Exp $")
+RCSID("$NetBSD: lock_stubs_llsc.S,v 1.10 2020/08/01 07:09:41 simonb Exp $")
 
 #include "assym.h"
 
@@ -47,8 +47,8 @@ RCSID("$NetBSD: lock_stubs_llsc.S,v 1.9 
 
 #if defined(MULTIPROCESSOR)
 #if defined(__OCTEON__)
-#define	SYNC		sync 4
-#define	BDSYNC		sync 4
+#define	SYNC		sync 4		/* sync 4 == syncw - sync all writes */
+#define	BDSYNC		sync 4		/* sync 4 == syncw - sync all writes */
 #else
 #define	SYNC		sync
 #define	BDSYNC		sync



CVS commit: src/usr.bin/make

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 07:03:50 UTC 2020

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

Log Message:
make(1): clearly mark a variable in Var_Set_with_flags for freeing

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.369 -r1.370 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.369 src/usr.bin/make/var.c:1.370
--- src/usr.bin/make/var.c:1.369	Sat Aug  1 06:35:00 2020
+++ src/usr.bin/make/var.c	Sat Aug  1 07:03:50 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.369 2020/08/01 06:35:00 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.370 2020/08/01 07:03:50 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.369 2020/08/01 06:35:00 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.370 2020/08/01 07:03:50 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.369 2020/08/01 06:35:00 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.370 2020/08/01 07:03:50 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -782,7 +782,7 @@ Var_Set_with_flags(const char *name, con
 		   VarSet_Flags flags)
 {
 Var *v;
-char *expanded_name = NULL;
+char *name_freeIt = NULL;
 
 /*
  * We only look for a variable in the given context since anything set
@@ -790,17 +790,17 @@ Var_Set_with_flags(const char *name, con
  * point in searching them all just to save a bit of memory...
  */
 if (strchr(name, '$') != NULL) {
-	expanded_name = Var_Subst(name, ctxt, VARE_WANTRES);
-	if (expanded_name[0] == '\0') {
+const char *unexpanded_name = name;
+	name = name_freeIt = Var_Subst(name, ctxt, VARE_WANTRES);
+	if (name[0] == '\0') {
 	if (DEBUG(VAR)) {
 		fprintf(debug_file, "Var_Set(\"%s\", \"%s\", ...) "
 			"name expands to empty string - ignored\n",
-			name, val);
+			unexpanded_name, val);
 	}
-	free(expanded_name);
+	free(name_freeIt);
 	return;
 	}
-	name = expanded_name;
 }
 if (ctxt == VAR_GLOBAL) {
 	v = VarFind(name, VAR_CMD, 0);
@@ -863,7 +863,7 @@ Var_Set_with_flags(const char *name, con
 	save_dollars = s2Boolean(val, save_dollars);
 
 out:
-free(expanded_name);
+free(name_freeIt);
 if (v != NULL)
 	VarFreeEnv(v, TRUE);
 }



CVS commit: src/sys

2020-08-01 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Aug  1 06:50:43 UTC 2020

Modified Files:
src/sys/external/bsd/ipf/netinet: ip_nat.c
src/sys/net: if_bridge.c

Log Message:
Remove #ifdef BRIDGE_IPF, compile in the code by default. Sent to
tech-net@.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/external/bsd/ipf/netinet/ip_nat.c
cvs rdiff -u -r1.173 -r1.174 src/sys/net/if_bridge.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/external/bsd/ipf/netinet/ip_nat.c
diff -u src/sys/external/bsd/ipf/netinet/ip_nat.c:1.22 src/sys/external/bsd/ipf/netinet/ip_nat.c:1.23
--- src/sys/external/bsd/ipf/netinet/ip_nat.c:1.22	Wed Jun 24 21:54:57 2020
+++ src/sys/external/bsd/ipf/netinet/ip_nat.c	Sat Aug  1 06:50:42 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_nat.c,v 1.22 2020/06/24 21:54:57 jdolecek Exp $	*/
+/*	$NetBSD: ip_nat.c,v 1.23 2020/08/01 06:50:42 maxv Exp $	*/
 
 /*
  * Copyright (C) 2012 by Darren Reed.
@@ -112,7 +112,7 @@ extern struct ifnet vpnif;
 #if !defined(lint)
 #if defined(__NetBSD__)
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_nat.c,v 1.22 2020/06/24 21:54:57 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_nat.c,v 1.23 2020/08/01 06:50:42 maxv Exp $");
 #else
 static const char sccsid[] = "@(#)ip_nat.c	1.11 6/5/96 (C) 1995 Darren Reed";
 static const char rcsid[] = "@(#)Id: ip_nat.c,v 1.1.1.2 2012/07/22 13:45:27 darrenr Exp";
@@ -5035,7 +5035,7 @@ ipf_nat_out(fr_info_t *fin, nat_t *nat, 
 		ipf_fix_outcksum(0, >fin_ip->ip_sum, msumd, 0);
 	}
 #if !defined(_KERNEL) || defined(MENTAT) || defined(__sgi) || \
-defined(linux) || defined(BRIDGE_IPF)
+defined(linux)
 	else {
 		/*
 		 * Strictly speaking, this isn't necessary on BSD
@@ -5147,7 +5147,7 @@ ipf_nat_out(fr_info_t *fin, nat_t *nat, 
 		uh->uh_ulen += fin->fin_plen;
 		uh->uh_ulen = htons(uh->uh_ulen);
 #if !defined(_KERNEL) || defined(MENTAT) || defined(__sgi) || \
-defined(linux) || defined(BRIDGE_IPF)
+defined(linux)
 		ipf_fix_outcksum(0, >ip_sum, sumd, 0);
 #endif
 

Index: src/sys/net/if_bridge.c
diff -u src/sys/net/if_bridge.c:1.173 src/sys/net/if_bridge.c:1.174
--- src/sys/net/if_bridge.c:1.173	Fri May  1 22:27:42 2020
+++ src/sys/net/if_bridge.c	Sat Aug  1 06:50:43 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bridge.c,v 1.173 2020/05/01 22:27:42 jdolecek Exp $	*/
+/*	$NetBSD: if_bridge.c,v 1.174 2020/08/01 06:50:43 maxv Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -80,10 +80,9 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.173 2020/05/01 22:27:42 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.174 2020/08/01 06:50:43 maxv Exp $");
 
 #ifdef _KERNEL_OPT
-#include "opt_bridge_ipf.h"
 #include "opt_inet.h"
 #include "opt_net_mpsafe.h"
 #endif /* _KERNEL_OPT */
@@ -114,19 +113,16 @@ __KERNEL_RCSID(0, "$NetBSD: if_bridge.c,
 #include 
 #include 
 
-#if defined(BRIDGE_IPF)
 /* Used for bridge_ip[6]_checkbasic */
 #include 
 #include 
 #include 
 #include 
 #include 		/* XXX */
-
 #include 
 #include 
 #include 
 #include 	/* XXX */
-#endif /* BRIDGE_IPF */
 
 /*
  * Size of the route hash table.  Must be a power of two.
@@ -314,7 +310,6 @@ static int	bridge_ioctl_gma(struct bridg
 static int	bridge_ioctl_sma(struct bridge_softc *, void *);
 static int	bridge_ioctl_sifprio(struct bridge_softc *, void *);
 static int	bridge_ioctl_sifcost(struct bridge_softc *, void *);
-#if defined(BRIDGE_IPF)
 static int	bridge_ioctl_gfilt(struct bridge_softc *, void *);
 static int	bridge_ioctl_sfilt(struct bridge_softc *, void *);
 static int	bridge_ipf(void *, struct mbuf **, struct ifnet *, int);
@@ -322,7 +317,6 @@ static int	bridge_ip_checkbasic(struct m
 # ifdef INET6
 static int	bridge_ip6_checkbasic(struct mbuf **mp);
 # endif /* INET6 */
-#endif /* BRIDGE_IPF */
 
 struct bridge_control {
 	int	(*bc_func)(struct bridge_softc *, void *);
@@ -373,10 +367,10 @@ static const struct bridge_control bridg
 [BRDGSIFPRIO] = {bridge_ioctl_sifprio, sizeof(struct ifbreq), BC_F_COPYIN|BC_F_SUSER}, 
 
 [BRDGSIFCOST] = {bridge_ioctl_sifcost, sizeof(struct ifbreq), BC_F_COPYIN|BC_F_SUSER}, 
-#if defined(BRIDGE_IPF)
+
 [BRDGGFILT] = {bridge_ioctl_gfilt, sizeof(struct ifbrparam), BC_F_COPYOUT},
 [BRDGSFILT] = {bridge_ioctl_sfilt, sizeof(struct ifbrparam), BC_F_COPYIN|BC_F_SUSER},
-#endif /* BRIDGE_IPF */
+
 [BRDGGIFS] = {bridge_ioctl_gifs, sizeof(struct ifbifconf), BC_F_XLATEIN|BC_F_XLATEOUT},
 [BRDGRTS] = {bridge_ioctl_rts, sizeof(struct ifbaconf), BC_F_XLATEIN|BC_F_XLATEOUT},
 };
@@ -1313,7 +1307,6 @@ bridge_ioctl_sifprio(struct bridge_softc
 	return 0;
 }
 
-#if defined(BRIDGE_IPF)
 static int
 bridge_ioctl_gfilt(struct bridge_softc *sc, void *arg)
 {
@@ -1349,7 +1342,6 @@ bridge_ioctl_sfilt(struct bridge_softc *
 
 	return 0;
 }
-#endif /* BRIDGE_IPF */
 
 static int
 bridge_ioctl_sifcost(struct bridge_softc *sc, void *arg)
@@ -2636,7 +2628,6 @@ 

CVS commit: src/usr.bin/make

2020-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  1 06:35:00 UTC 2020

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

Log Message:
make(1): remove unnecessary snprintf from Var_ExportVars

String literals can be concatenated at compile time.

Furthermore, MAKE_EXPORTED can now contain percent characters without
invoking undefined behavior.  Not that anyone would ever want to do this.


To generate a diff of this commit:
cvs rdiff -u -r1.368 -r1.369 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.368 src/usr.bin/make/var.c:1.369
--- src/usr.bin/make/var.c:1.368	Fri Jul 31 14:59:53 2020
+++ src/usr.bin/make/var.c	Sat Aug  1 06:35:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.368 2020/07/31 14:59:53 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.369 2020/08/01 06:35:00 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.368 2020/07/31 14:59:53 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.369 2020/08/01 06:35:00 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.368 2020/07/31 14:59:53 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.369 2020/08/01 06:35:00 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -582,7 +582,6 @@ Var_ExportVars(void)
 {
 char tmp[BUFSIZ];
 char *val;
-int n;
 
 /*
  * Several make's support this sort of mechanism for tracking
@@ -601,26 +600,21 @@ Var_ExportVars(void)
 	Hash_ForEach(_GLOBAL->context, Var_ExportVars_callback, NULL);
 	return;
 }
-/*
- * We have a number of exported vars,
- */
-n = snprintf(tmp, sizeof(tmp), "${" MAKE_EXPORTED ":O:u}");
-if (n < (int)sizeof(tmp)) {
+
+val = Var_Subst("${" MAKE_EXPORTED ":O:u}", VAR_GLOBAL, VARE_WANTRES);
+if (*val) {
 	char **av;
 	char *as;
 	int ac;
 	int i;
 
-	val = Var_Subst(tmp, VAR_GLOBAL, VARE_WANTRES);
-	if (*val) {
-	av = brk_string(val, , FALSE, );
-	for (i = 0; i < ac; i++)
-		Var_Export1(av[i], 0);
-	free(as);
-	free(av);
-	}
-	free(val);
+	av = brk_string(val, , FALSE, );
+	for (i = 0; i < ac; i++)
+	Var_Export1(av[i], 0);
+	free(as);
+	free(av);
 }
+free(val);
 }
 
 /*



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

2020-08-01 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Aug  1 06:35:00 UTC 2020

Modified Files:
src/sys/arch/aarch64/include: asan.h

Log Message:
Use large pages for the KASAN shadow, same as amd64, discussed with ryo@.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/aarch64/include/asan.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/aarch64/include/asan.h
diff -u src/sys/arch/aarch64/include/asan.h:1.8 src/sys/arch/aarch64/include/asan.h:1.9
--- src/sys/arch/aarch64/include/asan.h:1.8	Thu Jul 16 11:36:35 2020
+++ src/sys/arch/aarch64/include/asan.h	Sat Aug  1 06:35:00 2020
@@ -1,7 +1,7 @@
-/*	$NetBSD: asan.h,v 1.8 2020/07/16 11:36:35 skrll Exp $	*/
+/*	$NetBSD: asan.h,v 1.9 2020/08/01 06:35:00 maxv Exp $	*/
 
 /*
- * Copyright (c) 2018 The NetBSD Foundation, Inc.
+ * Copyright (c) 2018-2020 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -72,9 +72,28 @@ __md_palloc(void)
 	else
 		pa = pmap_alloc_pdp(pmap_kernel(), NULL, 0, false);
 
+	/* The page is zeroed. */
 	return pa;
 }
 
+static inline paddr_t
+__md_palloc_large(void)
+{
+	struct pglist pglist;
+	int ret;
+
+	if (!uvm.page_init_done)
+		return 0;
+
+	ret = uvm_pglistalloc(L2_SIZE, 0, ~0UL, L2_SIZE, 0,
+	, 1, 0);
+	if (ret != 0)
+		return 0;
+
+	/* The page may not be zeroed. */
+	return VM_PAGE_TO_PHYS(TAILQ_FIRST());
+}
+
 static void
 kasan_md_shadow_map_page(vaddr_t va)
 {
@@ -121,8 +140,20 @@ kasan_md_shadow_map_page(vaddr_t va)
 	idx = l2pde_index(va);
 	pde = l2[idx];
 	if (!l2pde_valid(pde)) {
+		/* If possible, use L2_BLOCK to map it in advance. */
+		if ((pa = __md_palloc_large()) != 0) {
+			atomic_swap_64([idx], pa | L2_BLOCK |
+			LX_BLKPAG_UXN | LX_BLKPAG_PXN | LX_BLKPAG_AF |
+			LX_BLKPAG_SH_IS | LX_BLKPAG_AP_RW);
+			aarch64_tlbi_by_va(va);
+			__builtin_memset((void *)va, 0, L2_SIZE);
+			return;
+		}
 		pa = __md_palloc();
 		atomic_swap_64([idx], pa | L2_TABLE);
+	} else if (l2pde_is_block(pde)) {
+		/* This VA is already mapped as a block. */
+		return;
 	} else {
 		pa = l2pde_pa(pde);
 	}