CVS commit: src/sys/dev/sbus

2021-10-30 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sun Oct 31 05:31:12 UTC 2021

Modified Files:
src/sys/dev/sbus: mgx.c

Log Message:
remove accidentially committed debug goop
thanks ryo@


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/sbus/mgx.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/sbus/mgx.c
diff -u src/sys/dev/sbus/mgx.c:1.18 src/sys/dev/sbus/mgx.c:1.19
--- src/sys/dev/sbus/mgx.c:1.18	Sat Oct 30 05:37:39 2021
+++ src/sys/dev/sbus/mgx.c	Sun Oct 31 05:31:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mgx.c,v 1.18 2021/10/30 05:37:39 macallan Exp $ */
+/*	$NetBSD: mgx.c,v 1.19 2021/10/31 05:31:12 macallan Exp $ */
 
 /*-
  * Copyright (c) 2014 Michael Lorenz
@@ -29,7 +29,7 @@
 /* a console driver for the SSB 4096V-MGX graphics card */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mgx.c,v 1.18 2021/10/30 05:37:39 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mgx.c,v 1.19 2021/10/31 05:31:12 macallan Exp $");
 
 #include 
 #include 
@@ -684,8 +684,6 @@ mgx_putchar_aa(void *cookie, int row, in
 	uint32_t fg, bg;
 	int x, y, wi, he, rv;
 
-if (sc->sc_mode != WSDISPLAYIO_MODE_EMUL) return;
-
 	wi = font->fontwidth;
 	he = font->fontheight;
 
@@ -733,8 +731,6 @@ mgx_putchar_mono(void *cookie, int row, 
 	uint32_t fg, bg, scratch = ((sc->sc_stride * sc->sc_height) + 7) & ~7;
 	int x, y, wi, he, len, i;
 
-if (sc->sc_mode != WSDISPLAYIO_MODE_EMUL) return;
-
 	wi = font->fontwidth;
 	he = font->fontheight;
 



CVS commit: src/sys/dev/sbus

2021-10-30 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sun Oct 31 05:31:12 UTC 2021

Modified Files:
src/sys/dev/sbus: mgx.c

Log Message:
remove accidentially committed debug goop
thanks ryo@


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/sbus/mgx.c

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



CVS commit: src/bin/sh

2021-10-30 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sun Oct 31 02:12:08 UTC 2021

Modified Files:
src/bin/sh: sh.1

Log Message:
PR bin/45390

Be explicit about what happens to PWD after a successful cd command.
Also be very clear  that "cd" and "cd -P" are the same thing, and
the only cd variant implemented.

Also, when it is appropriate to print the new directory after a cd
command, note that it happens if interactive (as it always has here)
and also if the posix option is set (for POSIX compat, where "interactive"
is irrelevant).  Mention that "cd -" is a case where the new directory
is printed (along with paths relative to a non-empty CDPATH entry,
and where the "cd old new" (string replacement in curdir) is used.

While here document the new -e option to cd.

XXX pullup -9


To generate a diff of this commit:
cvs rdiff -u -r1.235 -r1.236 src/bin/sh/sh.1

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/sh.1
diff -u src/bin/sh/sh.1:1.235 src/bin/sh/sh.1:1.236
--- src/bin/sh/sh.1:1.235	Tue Oct 26 00:05:38 2021
+++ src/bin/sh/sh.1	Sun Oct 31 02:12:08 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: sh.1,v 1.235 2021/10/26 00:05:38 kre Exp $
+.\"	$NetBSD: sh.1,v 1.236 2021/10/31 02:12:08 kre Exp $
 .\" Copyright (c) 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
 .\"
@@ -31,7 +31,7 @@
 .\"
 .\"	@(#)sh.1	8.6 (Berkeley) 5/4/95
 .\"
-.Dd October 25, 2021
+.Dd October 31, 2021
 .Dt SH 1
 .\" everything except c o and s (keep them ordered)
 .ds flags abCEeFfhIiLmnpquVvXx
@@ -83,10 +83,7 @@
 .Sh DESCRIPTION
 .Nm
 is the standard command interpreter for the system.
-The current version of
-.Nm
-is in the process of being changed to conform more closely to the
-POSIX 1003.2 and 1003.2a specifications for the shell.
+It is a re-implementation and extension of the Bourne shell.
 This version has many
 features which make it appear similar in some respects to the Korn shell,
 but it is not a Korn shell clone (see
@@ -2445,7 +2442,7 @@ of utilities, the name for built-ins or 
 .El
 .\"
 .Pp
-.It Ic cd Oo Fl P Oc Op Ar directory Op Ar replace
+.It Ic cd Oo Fl Pe Oc Op Ar directory Op Ar replace
 Switch to the specified directory (default
 .Ev $HOME ) .
 If
@@ -2480,14 +2477,44 @@ is the same as that of
 .Pp
 The
 .Fl P
-option instructs the shell to update
+option
+(which is the unalterable default in this
+.Nm )
+instructs the shell to
+change to the directory specified (or determined)
+and if successful
+update
+.Ev PWD
+with the new physical directory path.
+That is the path name, not traversing any symbolic links,
+of the altered working directory of the shell.
+.Pp
+The
+.Fl e
+option alters the interpretation of the exit status.
+.Ic cd
+will exit with status 0 if successful.
+If the directory was successfully changed, but
 .Ev PWD
-with the specified physical directory path and change to that directory.
-This is the default.
+was unable to be updated,
+.Ic cd
+will exit with status 1 if the
+.Fl e
+option was given, and status 0 otherwise.
+Upon any other error,
+including usage errors,
+and failing to successfully change directory,
+.Ic cd
+will exit with status 2.
 .Pp
-When the directory changes, the variable
+When the directory changes,
+and
+.Ev PWD
+is updated, the variable
 .Ev OLDPWD
-is set to the working directory before the change.
+is set to the working directory
+.Po \&\$ Ns Ev PWD Ns Pc
+as it was before the change.
 .Pp
 Some shells also support a
 .Fl L
@@ -2497,21 +2524,32 @@ with the logical path and to change the 
 accordingly.
 This is not supported.
 .Pp
-In an interactive shell, the
+In an interactive shell, or if the
+.Cm posix
+option is set, the
 .Ic cd
 command will print out the name of the
-directory that it actually switched to if this is different from the name
+directory that it actually switched to
+.Po that is, the pathname passed to the successful
+.Xr chdir 2
+.No system call Pc
+if this is different from the name
 that the user gave,
-or always if the
+or if the
 .Cm cdprint
 option is set.
-The destination may be different either because the
+The destination may be different because
+a non-empty element of the
 .Ev CDPATH
-mechanism was used
-.\" or because a symbolic link was crossed.
-or if the
+mechanism was used,
+.\" or because a symbolic link was crossed.   XXX Definitively not.
+or because the
 .Ar replace
-argument was used.
+argument was used,
+or because the
+.Ar directory
+parameter was specified as
+.Dq \&\- .
 .\"
 .Pp
 .It Ic eval Ar string ...



CVS commit: src/bin/sh

2021-10-30 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sun Oct 31 02:12:01 UTC 2021

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

Log Message:
PR bin/45390 - fix for folly four

In the pwd builtin, verify that curdir names '.' before
simply printing it.   Never alter PWD or OLDPWD in the
pwd command.

Also while here, implement the (new: coming in POSIX, but has existed
for a while in several other shells) -e option to cd (with -e, cd -P
will exit(1) if the chdir() succeeds, but PWD cannot be discovered).

cd now prints the directory name used (if different from that given,
or cdprint is on) if interactive or (the new bit)in posix mode.

Some additional/changed comments added, and a DEBUG mode trace call
that was accidentally put inside an #if 0 block moved to where it
can do some good.

XXX pullup -9


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/bin/sh/cd.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/cd.c
diff -u src/bin/sh/cd.c:1.50 src/bin/sh/cd.c:1.51
--- src/bin/sh/cd.c:1.50	Wed Jul  5 20:00:27 2017
+++ src/bin/sh/cd.c	Sun Oct 31 02:12:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd.c,v 1.50 2017/07/05 20:00:27 kre Exp $	*/
+/*	$NetBSD: cd.c,v 1.51 2021/10/31 02:12:01 kre Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,12 +37,13 @@
 #if 0
 static char sccsid[] = "@(#)cd.c	8.2 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: cd.c,v 1.50 2017/07/05 20:00:27 kre Exp $");
+__RCSID("$NetBSD: cd.c,v 1.51 2021/10/31 02:12:01 kre Exp $");
 #endif
 #endif /* not lint */
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -67,10 +68,11 @@ __RCSID("$NetBSD: cd.c,v 1.50 2017/07/05
 #include "show.h"
 #include "cd.h"
 
-STATIC int docd(const char *, int);
+STATIC int docd(const char *, bool, bool);
 STATIC char *getcomponent(void);
-STATIC void updatepwd(const char *);
+STATIC bool updatepwd(const char *);
 STATIC void find_curdir(int noerror);
+STATIC bool is_curdir(const char *);
 
 char *curdir = NULL;		/* current working directory */
 char *prevdir;			/* previous working directory */
@@ -84,10 +86,13 @@ cdcmd(int argc, char **argv)
 	char *p;
 	char *d;
 	struct stat statb;
+	char opt;
+	bool eopt = false;
 	int print = cdprint;	/* set -o cdprint to enable */
 
-	while (nextopt("P") != '\0')
-		;
+	while ((opt = nextopt("Pe")) != '\0')
+		if (opt == 'e')
+			eopt = true;
 
 	/*
 	 * Try (quite hard) to have 'curdir' defined, nothing has set
@@ -128,19 +133,13 @@ cdcmd(int argc, char **argv)
 		stunalloc(p);
 		if (stat(p, ) >= 0 && S_ISDIR(statb.st_mode)) {
 			int dopr = print;
+			int x;
 
-			if (!print) {
-/*
- * XXX - rethink
- */
-if (p[0] == '.' && p[1] == '/' && p[2] != '\0')
-	dopr = strcmp(p + 2, dest);
-else
-	dopr = strcmp(p, dest);
-			}
-			if (docd(p, dopr) >= 0)
-return 0;
+			if (!print)
+dopr = strcmp(p, dest);
 
+			if ((x = docd(p, dopr != 0, eopt)) >= 0)
+return x;
 		}
 	}
 	error("can't cd to %s", dest);
@@ -154,8 +153,10 @@ cdcmd(int argc, char **argv)
  */
 
 STATIC int
-docd(const char *dest, int print)
+docd(const char *dest, bool print, bool eopt)
 {
+	bool gotpwd;
+
 #if 0		/* no "cd -L" (ever) so all this is just a waste of time ... */
 	char *p;
 	char *q;
@@ -164,8 +165,6 @@ docd(const char *dest, int print)
 	int first;
 	int badstat;
 
-	CTRACE(DBG_CMDS, ("docd(\"%s\", %d) called\n", dest, print));
-
 	/*
 	 *  Check each component of the path. If we find a symlink or
 	 *  something we can't stat, clear curdir to force a getcwd()
@@ -199,16 +198,19 @@ docd(const char *dest, int print)
 	}
 #endif
 
+	CTRACE(DBG_CMDS, ("docd(\"%s\", %s, %s) called\n", dest,
+	print ? "true" : "false", eopt ? "true" : "false"));
+
 	INTOFF;
 	if (chdir(dest) < 0) {
 		INTON;
 		return -1;
 	}
-	updatepwd(NULL);	/* only do cd -P, no "pretend" -L mode */
+	gotpwd = updatepwd(NULL);   /* only do cd -P, no "pretend" -L mode */
 	INTON;
-	if (print && iflag == 1 && curdir)
-		out1fmt("%s\n", curdir);
-	return 0;
+	if (print && (iflag || posix))
+		out1fmt("%s\n", gotpwd ? curdir : dest);
+	return gotpwd || !eopt ? 0 : 1;
 }
 
 
@@ -245,7 +247,7 @@ getcomponent(void)
  * that the current directory has changed.
  */
 
-STATIC void
+STATIC bool
 updatepwd(const char *dir)
 {
 	char *new;
@@ -256,7 +258,7 @@ updatepwd(const char *dir)
 	/*
 	 * If our argument is NULL, we don't know the current directory
 	 * any more because we traversed a symbolic link or something
-	 * we couldn't stat().
+	 * we couldn't stat().   Or we simply don't trust what we had.
 	 */
 	if (dir == NULL || curdir == NULL)  {
 		if (prevdir)
@@ -269,10 +271,14 @@ updatepwd(const char *dir)
 		if (curdir) {
 			setvar("OLDPWD", prevdir, VEXPORT);
 			setvar("PWD", curdir, VEXPORT);
+			return true;
 		} else
 			unsetvar("PWD", 0);
-		return;
+		return false;
 	}
+
+	/* XXX none of the following code is ever executed any more */
+
 	cdcomppath = 

CVS commit: src/bin/sh

2021-10-30 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sun Oct 31 02:12:08 UTC 2021

Modified Files:
src/bin/sh: sh.1

Log Message:
PR bin/45390

Be explicit about what happens to PWD after a successful cd command.
Also be very clear  that "cd" and "cd -P" are the same thing, and
the only cd variant implemented.

Also, when it is appropriate to print the new directory after a cd
command, note that it happens if interactive (as it always has here)
and also if the posix option is set (for POSIX compat, where "interactive"
is irrelevant).  Mention that "cd -" is a case where the new directory
is printed (along with paths relative to a non-empty CDPATH entry,
and where the "cd old new" (string replacement in curdir) is used.

While here document the new -e option to cd.

XXX pullup -9


To generate a diff of this commit:
cvs rdiff -u -r1.235 -r1.236 src/bin/sh/sh.1

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



CVS commit: src/bin/sh

2021-10-30 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sun Oct 31 02:12:01 UTC 2021

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

Log Message:
PR bin/45390 - fix for folly four

In the pwd builtin, verify that curdir names '.' before
simply printing it.   Never alter PWD or OLDPWD in the
pwd command.

Also while here, implement the (new: coming in POSIX, but has existed
for a while in several other shells) -e option to cd (with -e, cd -P
will exit(1) if the chdir() succeeds, but PWD cannot be discovered).

cd now prints the directory name used (if different from that given,
or cdprint is on) if interactive or (the new bit)in posix mode.

Some additional/changed comments added, and a DEBUG mode trace call
that was accidentally put inside an #if 0 block moved to where it
can do some good.

XXX pullup -9


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/bin/sh/cd.c

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



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

2021-10-30 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sun Oct 31 00:31:48 UTC 2021

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

Log Message:
options


To generate a diff of this commit:
cvs rdiff -u -r1.592 -r1.593 src/sys/arch/amd64/conf/GENERIC

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/GENERIC
diff -u src/sys/arch/amd64/conf/GENERIC:1.592 src/sys/arch/amd64/conf/GENERIC:1.593
--- src/sys/arch/amd64/conf/GENERIC:1.592	Sat Oct 16 13:09:40 2021
+++ src/sys/arch/amd64/conf/GENERIC	Sun Oct 31 00:31:48 2021
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.592 2021/10/16 13:09:40 jmcneill Exp $
+# $NetBSD: GENERIC,v 1.593 2021/10/31 00:31:48 simonb Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.592 $"
+#ident		"GENERIC-$Revision: 1.593 $"
 
 maxusers	64		# estimated number of users
 
@@ -138,7 +138,7 @@ options 	KDTRACE_HOOKS	# kernel DTrace h
 # Use KASAN_PANIC if you want panics instead of warnings.
 #makeoptions 	KASAN=1		# mandatory
 #options 	KASAN		# mandatory
-#no options	SVS		# mandatory
+#no options 	SVS		# mandatory
 #options 	POOL_QUARANTINE	# optional
 #options 	KASAN_PANIC	# optional
 
@@ -152,7 +152,7 @@ options 	KDTRACE_HOOKS	# kernel DTrace h
 # memory in pool caches. Note that KMSAN requires at least 4GB of RAM.
 #makeoptions 	KMSAN=1		# mandatory
 #options 	KMSAN		# mandatory
-#no options	SVS		# mandatory
+#no options 	SVS		# mandatory
 #no options 	MODULAR		# mandatory
 #no options 	MODULAR_DEFAULT_AUTOLOAD	# mandatory
 #options 	POOL_NOCACHE	# optional
@@ -201,7 +201,7 @@ options 	WAPBL		# File system journaling
 # Note that UFS_DIRHASH is suspected of causing kernel memory corruption.
 # It is not recommended for general use.
 #options 	UFS_DIRHASH	# UFS Large Directory Hashing - Experimental
-options		UFS_ACL		# UFS Access Control Lists
+options 	UFS_ACL		# UFS Access Control Lists
 #options 	FFS_NO_SNAPSHOT	# No FFS snapshot support
 options 	UFS_EXTATTR	# Extended attribute support for UFS1
 # ext2fs
@@ -1153,7 +1153,7 @@ options 	RAID_AUTOCONFIG		# auto-configu
 pseudo-device	fss			# file system snapshot device
 
 pseudo-device	md			# memory disk device (ramdisk)
-options		MEMORY_DISK_HOOKS	# enable md specific hooks
+options 	MEMORY_DISK_HOOKS	# enable md specific hooks
 options 	MEMORY_DISK_DYNAMIC	# enable dynamic resizing
 
 pseudo-device	vnd			# disk-like interface to files



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

2021-10-30 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sun Oct 31 00:31:48 UTC 2021

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

Log Message:
options


To generate a diff of this commit:
cvs rdiff -u -r1.592 -r1.593 src/sys/arch/amd64/conf/GENERIC

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



CVS commit: src/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 23:27:33 UTC 2021

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

Log Message:
indent: push down variable comment_buffered

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.195 -r1.196 src/usr.bin/indent/indent.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/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.195 src/usr.bin/indent/indent.c:1.196
--- src/usr.bin/indent/indent.c:1.195	Sat Oct 30 22:36:07 2021
+++ src/usr.bin/indent/indent.c	Sat Oct 30 23:27:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.195 2021/10/30 22:36:07 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.196 2021/10/30 23:27:33 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.195 2021/10/30 22:36:07 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.196 2021/10/30 23:27:33 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -289,7 +289,7 @@ search_stmt_newline(bool *force_nl)
 }
 
 static void
-search_stmt_comment(bool *comment_buffered)
+search_stmt_comment(void)
 {
 if (sc_end == NULL) {
 	/*
@@ -316,7 +316,6 @@ search_stmt_comment(bool *comment_buffer
 	save_com, sc_end, "\"\n");
 }
 
-*comment_buffered = true;
 sc_add_char('/');
 sc_add_char('*');
 
@@ -466,9 +465,10 @@ search_stmt_lookahead(lexer_symbol *lsym
  * "cuddling else" (-ce).
  */
 static void
-search_stmt(lexer_symbol *lsym, bool *force_nl,
-bool *comment_buffered, bool *last_else)
+search_stmt(lexer_symbol *lsym, bool *force_nl, bool *last_else)
 {
+bool comment_buffered = false;
+
 while (ps.search_stmt) {
 	switch (*lsym) {
 	case lsym_newline:
@@ -477,15 +477,16 @@ search_stmt(lexer_symbol *lsym, bool *fo
 	case lsym_form_feed:
 	break;
 	case lsym_comment:
-	search_stmt_comment(comment_buffered);
+	search_stmt_comment();
+	comment_buffered = true;
 	break;
 	case lsym_lbrace:
 	if (search_stmt_lbrace())
 		goto switch_buffer;
 	/* FALLTHROUGH */
 	default:		/* it is the start of a normal statement */
-	if (!search_stmt_other(*lsym, force_nl,
-		*comment_buffered, *last_else))
+	if (!search_stmt_other(*lsym, force_nl, comment_buffered,
+		*last_else))
 		return;
 switch_buffer:
 	switch_buffer();
@@ -1377,15 +1378,10 @@ main_loop(void)
 
 di_stack[ps.decl_nest = 0] = 0;
 
-for (;;) {			/* this is the main loop.  it will go until we
- * reach eof */
-	bool comment_buffered = false;
-
-	lexer_symbol lsym = lexi();	/* Read the next token.  The actual
-	 * characters read are stored in
-	 * "token". */
+for (;;) {			/* loop until we reach eof */
+	lexer_symbol lsym = lexi();
 
-	search_stmt(, _nl, _buffered, _else);
+	search_stmt(, _nl, _else);
 
 	if (lsym == lsym_eof) {
 	process_end_of_file();



CVS commit: src/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 23:27:33 UTC 2021

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

Log Message:
indent: push down variable comment_buffered

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.195 -r1.196 src/usr.bin/indent/indent.c

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



CVS commit: src/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 22:41:18 UTC 2021

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

Log Message:
indent: move debugging functions to a separate section


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/usr.bin/indent/indent.h

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

Modified files:

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.66 src/usr.bin/indent/indent.h:1.67
--- src/usr.bin/indent/indent.h:1.66	Sat Oct 30 22:36:07 2021
+++ src/usr.bin/indent/indent.h	Sat Oct 30 22:41:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.66 2021/10/30 22:36:07 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.67 2021/10/30 22:41:18 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -277,10 +277,6 @@ extern bool inhibit_formatting;	/* true 
 #define	STACKSIZE 256
 
 extern struct parser_state {
-/*
- * TODO: Double-check that the word 'prev' in the following variables
- * means exactly the same thing.
- */
 lexer_symbol prev_token;
 enum keyword_kind prev_keyword;
 enum keyword_kind curr_keyword;
@@ -370,11 +366,6 @@ extern struct parser_state {
 
 #define array_length(array) (sizeof(array) / sizeof((array)[0]))
 
-void add_typename(const char *);
-int compute_code_indent(void);
-int compute_label_indent(void);
-int indentation_after_range(int, const char *, const char *);
-int indentation_after(int, const char *);
 #ifdef debug
 void
 debug_vis_range(const char *, const char *, const char *,
@@ -386,6 +377,13 @@ void debug_println(const char *, ...)__p
 #define		debug_println(fmt, ...) do { } while (false)
 #define		debug_vis_range(prefix, s, e, suffix) do { } while (false)
 #endif
+
+void add_typename(const char *);
+int compute_code_indent(void);
+int compute_label_indent(void);
+int indentation_after_range(int, const char *, const char *);
+int indentation_after(int, const char *);
+
 void inbuf_skip(void);
 char inbuf_next(void);
 lexer_symbol lexi(void);



CVS commit: src/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 22:41:18 UTC 2021

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

Log Message:
indent: move debugging functions to a separate section


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/usr.bin/indent/indent.h

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



CVS commit: src

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 22:36:07 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token_binary_op.c token_comment.c
src/usr.bin/indent: indent.c indent.h lexi.c pr_comment.c

Log Message:
indent: rename prev_newline and prev_col_1 to curr

These two flags describe the token that is currently processed.

In process_binary_op, curr_newline can never be true since newline is
not a binary operator, so remove that condition.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/indent/token_binary_op.c
cvs rdiff -u -r1.14 -r1.15 src/tests/usr.bin/indent/token_comment.c
cvs rdiff -u -r1.194 -r1.195 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.65 -r1.66 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.116 -r1.117 src/usr.bin/indent/lexi.c
cvs rdiff -u -r1.92 -r1.93 src/usr.bin/indent/pr_comment.c

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

Modified files:

Index: src/tests/usr.bin/indent/token_binary_op.c
diff -u src/tests/usr.bin/indent/token_binary_op.c:1.5 src/tests/usr.bin/indent/token_binary_op.c:1.6
--- src/tests/usr.bin/indent/token_binary_op.c:1.5	Fri Oct 29 22:37:25 2021
+++ src/tests/usr.bin/indent/token_binary_op.c	Sat Oct 30 22:36:07 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token_binary_op.c,v 1.5 2021/10/29 22:37:25 rillig Exp $ */
+/* $NetBSD: token_binary_op.c,v 1.6 2021/10/30 22:36:07 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -245,7 +245,7 @@ char *(*fn)(int, int) = NULL;
  * Ensure that the result of the indentation does not depend on whether a
  * token from the input starts in column 1 or 9.
  *
- * See process_binary_op, ps.prev_col_1.
+ * See process_binary_op, ps.curr_col_1.
  */
 #indent input
 int col_1 //

Index: src/tests/usr.bin/indent/token_comment.c
diff -u src/tests/usr.bin/indent/token_comment.c:1.14 src/tests/usr.bin/indent/token_comment.c:1.15
--- src/tests/usr.bin/indent/token_comment.c:1.14	Sat Oct 30 16:57:18 2021
+++ src/tests/usr.bin/indent/token_comment.c	Sat Oct 30 22:36:07 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token_comment.c,v 1.14 2021/10/30 16:57:18 rillig Exp $ */
+/* $NetBSD: token_comment.c,v 1.15 2021/10/30 22:36:07 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -41,7 +41,7 @@
  * - with varying opt.comment_column (-c0, -c1, -c33, -c80)
  * - with varying opt.decl_comment_column (-cd0, -cd1, -cd20, -cd33, -cd80)
  * - with/without ps.decl_on_line
- * - with/without ps.prev_newline
+ * - with/without ps.curr_newline
  *
  * - very long comments that overflow the buffer 'com'
  * - comments that come from save_com

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.194 src/usr.bin/indent/indent.c:1.195
--- src/usr.bin/indent/indent.c:1.194	Sat Oct 30 20:01:46 2021
+++ src/usr.bin/indent/indent.c	Sat Oct 30 22:36:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.194 2021/10/30 20:01:46 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.195 2021/10/30 22:36:07 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.194 2021/10/30 20:01:46 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.195 2021/10/30 22:36:07 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -512,7 +512,7 @@ main_init_globals(void)
 
 ps.s_sym[0] = psym_stmt_list;
 ps.prev_token = lsym_semicolon;
-ps.prev_newline = true;
+ps.curr_newline = true;
 
 const char *suffix = getenv("SIMPLE_BACKUP_SUFFIX");
 if (suffix != NULL)
@@ -850,7 +850,7 @@ process_unary_op(int decl_ind, bool tabs
 static void
 process_binary_op(void)
 {
-if (!ps.prev_newline && buf_len() > 0)
+if (buf_len() > 0)
 	buf_add_char(, ' ');
 buf_add_buf(, );
 ps.want_blank = true;

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.65 src/usr.bin/indent/indent.h:1.66
--- src/usr.bin/indent/indent.h:1.65	Sat Oct 30 22:15:51 2021
+++ src/usr.bin/indent/indent.h	Sat Oct 30 22:36:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.65 2021/10/30 22:15:51 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.66 2021/10/30 22:36:07 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -282,12 +282,11 @@ extern struct parser_state {
  * means exactly the same thing.
  */
 lexer_symbol prev_token;
-bool prev_newline;		/* whether the last thing scanned was a
- * newline */
-bool prev_col_1;		/* whether the last token started in column 1
- * of the unformatted input */
 enum keyword_kind prev_keyword;
 enum keyword_kind curr_keyword;
+bool curr_newline;
+bool curr_col_1;		/* whether the current token started in column
+ * 1 of the unformatted input */
 bool next_unary;		/* whether the following operator should be
  * unary */

CVS commit: src

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 22:36:07 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token_binary_op.c token_comment.c
src/usr.bin/indent: indent.c indent.h lexi.c pr_comment.c

Log Message:
indent: rename prev_newline and prev_col_1 to curr

These two flags describe the token that is currently processed.

In process_binary_op, curr_newline can never be true since newline is
not a binary operator, so remove that condition.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/indent/token_binary_op.c
cvs rdiff -u -r1.14 -r1.15 src/tests/usr.bin/indent/token_comment.c
cvs rdiff -u -r1.194 -r1.195 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.65 -r1.66 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.116 -r1.117 src/usr.bin/indent/lexi.c
cvs rdiff -u -r1.92 -r1.93 src/usr.bin/indent/pr_comment.c

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



CVS commit: src/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 22:25:11 UTC 2021

Modified Files:
src/usr.bin/indent: lexi.c

Log Message:
indent: in debug output, list the new token first


To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.116 src/usr.bin/indent/lexi.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/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.115 src/usr.bin/indent/lexi.c:1.116
--- src/usr.bin/indent/lexi.c:1.115	Sat Oct 30 22:15:51 2021
+++ src/usr.bin/indent/lexi.c	Sat Oct 30 22:25:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lexi.c,v 1.115 2021/10/30 22:15:51 rillig Exp $	*/
+/*	$NetBSD: lexi.c,v 1.116 2021/10/30 22:25:11 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)lexi.c	8.1 (
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: lexi.c,v 1.115 2021/10/30 22:15:51 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.116 2021/10/30 22:25:11 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -303,12 +303,11 @@ debug_lexi(lexer_symbol lsym)
 static struct parser_state prev_ps;
 
 debug_println("");
-debug_printf("line %d\n", line_no);
+debug_printf("line %d: %s", line_no, lsym_name(lsym));
+debug_vis_range(" \"", token.s, token.e, "\"\n");
 debug_print_buf("label", );
 debug_print_buf("code", );
 debug_print_buf("comment", );
-debug_printf("lexi: %s", lsym_name(lsym));
-debug_vis_range(" \"", token.s, token.e, "\"\n");
 
 // prev_token
 debug_ps_bool(prev_newline);



CVS commit: src/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 22:25:11 UTC 2021

Modified Files:
src/usr.bin/indent: lexi.c

Log Message:
indent: in debug output, list the new token first


To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.116 src/usr.bin/indent/lexi.c

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



CVS commit: src/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 22:15:51 UTC 2021

Modified Files:
src/usr.bin/indent: indent.h lexi.c

Log Message:
indent: clean up lexical analyzer

Use traditional type for small unsigned numbers instead of uint8_t; the
required header was not included.

Remove assertion for debug mode; lint takes care of ensuring that the
enum constants match the length of the names array.

Constify a name array.

Move the comparison function for bsearch closer to its caller.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.114 -r1.115 src/usr.bin/indent/lexi.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/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.64 src/usr.bin/indent/indent.h:1.65
--- src/usr.bin/indent/indent.h:1.64	Sat Oct 30 11:49:38 2021
+++ src/usr.bin/indent/indent.h	Sat Oct 30 22:15:51 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.64 2021/10/30 11:49:38 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.65 2021/10/30 22:15:51 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -69,6 +69,7 @@ __FBSDID("$FreeBSD: head/usr.bin/indent/
 #endif
 
 #include 
+#include 
 
 typedef enum lexer_symbol {
 lsym_eof,

Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.114 src/usr.bin/indent/lexi.c:1.115
--- src/usr.bin/indent/lexi.c:1.114	Fri Oct 29 23:48:50 2021
+++ src/usr.bin/indent/lexi.c	Sat Oct 30 22:15:51 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lexi.c,v 1.114 2021/10/29 23:48:50 rillig Exp $	*/
+/*	$NetBSD: lexi.c,v 1.115 2021/10/30 22:15:51 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,14 +43,11 @@ static char sccsid[] = "@(#)lexi.c	8.1 (
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: lexi.c,v 1.114 2021/10/29 23:48:50 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.115 2021/10/30 22:15:51 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
 
-#include 
-#include 
-#include 
 #include 
 #include 
 #include 
@@ -157,7 +154,7 @@ static const unsigned char lex_number_st
 };
 /* INDENT ON */
 
-static const uint8_t lex_number_row[] = {
+static const unsigned char lex_number_row[] = {
 ['0'] = 1,
 ['1'] = 2,
 ['2'] = 3, ['3'] = 3, ['4'] = 3, ['5'] = 3, ['6'] = 3, ['7'] = 3,
@@ -211,12 +208,6 @@ token_add_char(char ch)
 *token.e++ = ch;
 }
 
-static int
-cmp_keyword_by_name(const void *key, const void *elem)
-{
-return strcmp(key, ((const struct keyword *)elem)->name);
-}
-
 #ifdef debug
 static const char *
 lsym_name(lexer_symbol sym)
@@ -255,15 +246,13 @@ lsym_name(lexer_symbol sym)
 	"while",
 };
 
-assert(array_length(name) == (int)lsym_while + 1);
-
 return name[sym];
 }
 
 static const char *
 kw_name(enum keyword_kind kw)
 {
-static const char *name[] = {
+static const char *const name[] = {
 	"0",
 	"offsetof",
 	"sizeof",
@@ -376,12 +365,12 @@ lexi_end(lexer_symbol lsym)
 static void
 lex_number(void)
 {
-for (uint8_t s = 'A'; s != 'f' && s != 'i' && s != 'u';) {
-	uint8_t ch = (uint8_t)*inp.s;
+for (unsigned char s = 'A'; s != 'f' && s != 'i' && s != 'u';) {
+	unsigned char ch = (unsigned char)*inp.s;
 	if (ch >= array_length(lex_number_row) || lex_number_row[ch] == 0)
 	break;
 
-	uint8_t row = lex_number_row[ch];
+	unsigned char row = lex_number_row[ch];
 	if (lex_number_state[row][s - 'A'] == ' ') {
 	/*-
 	 * lex_number_state[0][s - 'A'] now indicates the type:
@@ -485,6 +474,12 @@ is_typename(void)
 return bsearch_typenames(token.s) >= 0;
 }
 
+static int
+cmp_keyword_by_name(const void *key, const void *elem)
+{
+return strcmp(key, ((const struct keyword *)elem)->name);
+}
+
 /* Read an alphanumeric token into 'token', or return end_of_file. */
 static lexer_symbol
 lexi_alnum(void)



CVS commit: src/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 22:15:51 UTC 2021

Modified Files:
src/usr.bin/indent: indent.h lexi.c

Log Message:
indent: clean up lexical analyzer

Use traditional type for small unsigned numbers instead of uint8_t; the
required header was not included.

Remove assertion for debug mode; lint takes care of ensuring that the
enum constants match the length of the names array.

Constify a name array.

Move the comparison function for bsearch closer to its caller.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.114 -r1.115 src/usr.bin/indent/lexi.c

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



CVS commit: src

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 22:04:42 UTC 2021

Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/usr.bin/xlint/lint1: Makefile msg_241.c
src/usr.bin/xlint/lint1: err.c tree.c
Added Files:
src/tests/usr.bin/xlint/lint1: msg_348.c msg_348.exp

Log Message:
lint: warn if an enum name is used for mismatched array access

This helps to keep the enum definition and the straight-forward
implementation of a to_string or name function in sync.

The test for message 241 had to be adjusted because of exactly this bug.
That test defined a bit mask enum but accessed it like a value enum
type.


To generate a diff of this commit:
cvs rdiff -u -r1.1161 -r1.1162 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.113 -r1.114 src/tests/usr.bin/xlint/lint1/Makefile
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/msg_241.c
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint1/msg_348.c \
src/tests/usr.bin/xlint/lint1/msg_348.exp
cvs rdiff -u -r1.146 -r1.147 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.385 -r1.386 src/usr.bin/xlint/lint1/tree.c

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1161 src/distrib/sets/lists/tests/mi:1.1162
--- src/distrib/sets/lists/tests/mi:1.1161	Sat Oct 23 21:45:14 2021
+++ src/distrib/sets/lists/tests/mi	Sat Oct 30 22:04:42 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1161 2021/10/23 21:45:14 rillig Exp $
+# $NetBSD: mi,v 1.1162 2021/10/30 22:04:42 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -7151,6 +7151,8 @@
 ./usr/tests/usr.bin/xlint/lint1/msg_346.exp			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_347.c			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_347.exp			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_348.c			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_348.exp			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/op_colon.c			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/op_colon.exp			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/op_shl_lp64.c			tests-usr.bin-tests	compattestfile,atf

Index: src/tests/usr.bin/xlint/lint1/Makefile
diff -u src/tests/usr.bin/xlint/lint1/Makefile:1.113 src/tests/usr.bin/xlint/lint1/Makefile:1.114
--- src/tests/usr.bin/xlint/lint1/Makefile:1.113	Sun Sep 26 03:17:59 2021
+++ src/tests/usr.bin/xlint/lint1/Makefile	Sat Oct 30 22:04:42 2021
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.113 2021/09/26 03:17:59 rillig Exp $
+# $NetBSD: Makefile,v 1.114 2021/10/30 22:04:42 rillig Exp $
 
 NOMAN=		# defined
-MAX_MESSAGE=	347		# see lint1/err.c
+MAX_MESSAGE=	348		# see lint1/err.c
 
 .include 
 

Index: src/tests/usr.bin/xlint/lint1/msg_241.c
diff -u src/tests/usr.bin/xlint/lint1/msg_241.c:1.6 src/tests/usr.bin/xlint/lint1/msg_241.c:1.7
--- src/tests/usr.bin/xlint/lint1/msg_241.c:1.6	Mon Aug 16 20:11:03 2021
+++ src/tests/usr.bin/xlint/lint1/msg_241.c	Sat Oct 30 22:04:42 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_241.c,v 1.6 2021/08/16 20:11:03 rillig Exp $	*/
+/*	$NetBSD: msg_241.c,v 1.7 2021/10/30 22:04:42 rillig Exp $	*/
 # 3 "msg_241.c"
 
 // Test for message: dubious operation on enum, op %s [241]
@@ -86,7 +86,11 @@ cover_typeok_enum(enum color c, int i)
 const char *
 color_name(enum color c)
 {
-	static const char *name[] = { "red", "green", "blue" };
+	static const char *name[] = {
+	[RED] = "red",
+	[GREEN] = "green",
+	[BLUE] = "blue",
+	};
 
 	if (c == RED)
 		return *(c + name); /* unusual but allowed */

Index: src/usr.bin/xlint/lint1/err.c
diff -u src/usr.bin/xlint/lint1/err.c:1.146 src/usr.bin/xlint/lint1/err.c:1.147
--- src/usr.bin/xlint/lint1/err.c:1.146	Sat Oct  9 21:56:12 2021
+++ src/usr.bin/xlint/lint1/err.c	Sat Oct 30 22:04:42 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: err.c,v 1.146 2021/10/09 21:56:12 rillig Exp $	*/
+/*	$NetBSD: err.c,v 1.147 2021/10/30 22:04:42 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: err.c,v 1.146 2021/10/09 21:56:12 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.147 2021/10/30 22:04:42 rillig Exp $");
 #endif
 
 #include 
@@ -402,6 +402,7 @@ const char *const msgs[] = {
 	"generic selection requires C11 or later",		  /* 345 */
 	"call to '%s' effectively discards 'const' from argument",/* 346 */
 	"redeclaration of '%s' with type '%s', expected '%s'",	  /* 347 */
+	"maximum value %d of '%s' does not match maximum array index %d", /* 348 */
 };
 
 static struct include_level {

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.385 src/usr.bin/xlint/lint1/tree.c:1.386
--- 

CVS commit: src

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 22:04:42 UTC 2021

Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/usr.bin/xlint/lint1: Makefile msg_241.c
src/usr.bin/xlint/lint1: err.c tree.c
Added Files:
src/tests/usr.bin/xlint/lint1: msg_348.c msg_348.exp

Log Message:
lint: warn if an enum name is used for mismatched array access

This helps to keep the enum definition and the straight-forward
implementation of a to_string or name function in sync.

The test for message 241 had to be adjusted because of exactly this bug.
That test defined a bit mask enum but accessed it like a value enum
type.


To generate a diff of this commit:
cvs rdiff -u -r1.1161 -r1.1162 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.113 -r1.114 src/tests/usr.bin/xlint/lint1/Makefile
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/msg_241.c
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint1/msg_348.c \
src/tests/usr.bin/xlint/lint1/msg_348.exp
cvs rdiff -u -r1.146 -r1.147 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.385 -r1.386 src/usr.bin/xlint/lint1/tree.c

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



CVS commit: src/lib/libc/compat/arch/hppa/sys

2021-10-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Oct 30 21:39:28 UTC 2021

Modified Files:
src/lib/libc/compat/arch/hppa/sys: Makefile.inc
Added Files:
src/lib/libc/compat/arch/hppa/sys: compat___sigtramp1.S

Log Message:
Put back the sigcontext sigtramp code.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libc/compat/arch/hppa/sys/Makefile.inc
cvs rdiff -u -r0 -r1.1 src/lib/libc/compat/arch/hppa/sys/compat___sigtramp1.S

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

Modified files:

Index: src/lib/libc/compat/arch/hppa/sys/Makefile.inc
diff -u src/lib/libc/compat/arch/hppa/sys/Makefile.inc:1.2 src/lib/libc/compat/arch/hppa/sys/Makefile.inc:1.3
--- src/lib/libc/compat/arch/hppa/sys/Makefile.inc:1.2	Sun Mar  6 12:08:13 2011
+++ src/lib/libc/compat/arch/hppa/sys/Makefile.inc	Sat Oct 30 17:39:28 2021
@@ -1,6 +1,6 @@
-#	$NetBSD: Makefile.inc,v 1.2 2011/03/06 17:08:13 bouyer Exp $
+#	$NetBSD: Makefile.inc,v 1.3 2021/10/30 21:39:28 christos Exp $
 
 SRCS+=compat_Ovfork.S compat___semctl.S compat___sigreturn14.S \
 compat_msgctl.S compat_shmctl.S compat_sigaction.S \
 compat_sigpending.S compat_sigprocmask.S compat_sigreturn.S \
-compat_sigsuspend.S compat_quotactl.S
+compat_sigsuspend.S compat_quotactl.S compat___sigtramp1.S

Added files:

Index: src/lib/libc/compat/arch/hppa/sys/compat___sigtramp1.S
diff -u /dev/null src/lib/libc/compat/arch/hppa/sys/compat___sigtramp1.S:1.1
--- /dev/null	Sat Oct 30 17:39:28 2021
+++ src/lib/libc/compat/arch/hppa/sys/compat___sigtramp1.S	Sat Oct 30 17:39:28 2021
@@ -0,0 +1,112 @@
+/*	$NetBSD: compat___sigtramp1.S,v 1.1 2021/10/30 21:39:28 christos Exp $	*/
+
+/*
+ * Copyright (c) 1998-2001 Michael Shalayeff
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ *must display the following acknowledgement:
+ *  This product includes software developed by Michael Shalayeff.
+ * 4. The name of the author may not be used to endorse or promote products
+ *derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Portitions of this file are derived from other sources, see
+ * the copyrights and acknowledgements below.
+ */
+/*
+ * Copyright (c) 1990,1991,1992,1994 The University of Utah and
+ * the Computer Systems Laboratory (CSL).  All rights reserved.
+ *
+ * THE UNIVERSITY OF UTAH AND CSL PROVIDE THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION, AND DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM ITS USE.
+ *
+ * CSL requests users of this software to return to csl-d...@cs.utah.edu any
+ * improvements that they make and grant CSL redistribution rights.
+ *
+ *	Utah $Hdr: locore.s 1.62 94/12/15$
+ */
+/*
+ *  (c) Copyright 1988 HEWLETT-PACKARD COMPANY
+ *
+ *  To anyone who acknowledges that this file is provided "AS IS"
+ *  without any express or implied warranty:
+ *  permission to use, copy, modify, and distribute this file
+ *  for any purpose is hereby granted without fee, provided that
+ *  the above copyright notice and this notice appears in all
+ *  copies, and that the name of Hewlett-Packard Company not be
+ *  used in advertising or publicity pertaining to distribution
+ *  of the software without specific, written prior permission.
+ *  Hewlett-Packard Company makes no representations about the
+ *  suitability of this software for any purpose.
+ */
+
+#include "SYS.h"
+
+ENTRY_NOPROFILE(__sigtramp_sigcontext_1,0)
+	.call
+	/*
+	 * Our sendsig() places the address of the signal handler 
+	 * in %arg3.  It may actually be a PLABEL.
+	 */
+	bb,>=,n	

CVS commit: src/lib/libc/compat/arch/hppa/sys

2021-10-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Oct 30 21:39:28 UTC 2021

Modified Files:
src/lib/libc/compat/arch/hppa/sys: Makefile.inc
Added Files:
src/lib/libc/compat/arch/hppa/sys: compat___sigtramp1.S

Log Message:
Put back the sigcontext sigtramp code.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libc/compat/arch/hppa/sys/Makefile.inc
cvs rdiff -u -r0 -r1.1 src/lib/libc/compat/arch/hppa/sys/compat___sigtramp1.S

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



CVS commit: src

2021-10-30 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sat Oct 30 21:08:58 UTC 2021

Modified Files:
src/bin/ksh: ksh.Man
src/share/man/man5: nologin.5
src/sys/dev/marvell: gtreg.h

Log Message:
"no affect" -> "no effect" in man pages and comments.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/bin/ksh/ksh.Man
cvs rdiff -u -r1.2 -r1.3 src/share/man/man5/nologin.5
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/marvell/gtreg.h

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

Modified files:

Index: src/bin/ksh/ksh.Man
diff -u src/bin/ksh/ksh.Man:1.26 src/bin/ksh/ksh.Man:1.27
--- src/bin/ksh/ksh.Man:1.26	Sun Aug 26 22:52:34 2018
+++ src/bin/ksh/ksh.Man	Sat Oct 30 21:08:58 2021
@@ -1,5 +1,5 @@
 '\" t
-.\" $NetBSD: ksh.Man,v 1.26 2018/08/26 22:52:34 sevan Exp $
+.\" $NetBSD: ksh.Man,v 1.27 2021/10/30 21:08:58 andvar Exp $
 .\"{{{}}}
 .\"{{{  Notes about man page
 .\" - use the pseudo-macros .sh( and .sh) to begin and end sh-specific
@@ -1699,7 +1699,7 @@ is prefixed with the string "\fBalias\fP
 .sp
 The \fB\-x\fP option sets (\fB+x\fP clears) the export attribute of an alias,
 or, if no names are given, lists the aliases with the export attribute
-(exporting an alias has no affect).
+(exporting an alias has no effect).
 .sp
 The \fB\-t\fP option indicates that tracked aliases are to be listed/set
 (values specified on the command line are ignored for tracked aliases).

Index: src/share/man/man5/nologin.5
diff -u src/share/man/man5/nologin.5:1.2 src/share/man/man5/nologin.5:1.3
--- src/share/man/man5/nologin.5:1.2	Fri May  2 19:09:56 2008
+++ src/share/man/man5/nologin.5	Sat Oct 30 21:08:58 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: nologin.5,v 1.2 2008/05/02 19:09:56 martin Exp $
+.\"	$NetBSD: nologin.5,v 1.3 2021/10/30 21:08:58 andvar Exp $
 .\"
 .\" Copyright (c) 2005 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -63,7 +63,7 @@ see
 .Pp
 The file
 .Pa /etc/nologin
-has no affect on the login procedure for the root user.
+has no effect on the login procedure for the root user.
 .Sh FILES
 .Bl -tag -width /etc/nologin -compact
 .It Pa /etc/nologin

Index: src/sys/dev/marvell/gtreg.h
diff -u src/sys/dev/marvell/gtreg.h:1.5 src/sys/dev/marvell/gtreg.h:1.6
--- src/sys/dev/marvell/gtreg.h:1.5	Wed Jun  9 02:19:51 2010
+++ src/sys/dev/marvell/gtreg.h	Sat Oct 30 21:08:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: gtreg.h,v 1.5 2010/06/09 02:19:51 kiyohara Exp $	*/
+/*	$NetBSD: gtreg.h,v 1.6 2021/10/30 21:08:58 andvar Exp $	*/
 
 /*
  * Copyright (c) 2002 Allegro Networks, Inc., Wasabi Systems, Inc.
@@ -375,7 +375,7 @@
  *   Results in writing of the corresponding
  *   Remap register.
  *1: Write to Low Address decode register.  No
- *   affect on the corresponding Remap register.
+ *   effect on the corresponding Remap register.
  * 28:28 ConfSBDis		Configuration Read Sync Barrier Disable
  *0: enabled; 1: disabled
  * 29:29 IOSBDis		I/O Read Sync Barrier Disable
@@ -666,7 +666,7 @@
  * Table 136: CPU Error Cause, Offset: 0x140
  *   Bits[7:0] are clear only. A cause bit is set upon an error condition
  *   occurrence. Write a 0 value to clear the bit.  Writing a 1 value has
- *   no affect.
+ *   no effect.
  * 00:00 AddrOut		CPU Address Out of Range
  * 01:01 AddrPErr		Bad Address Parity Detected
  * 02:02 TTErr			Transfer Type Violation.



CVS commit: src

2021-10-30 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sat Oct 30 21:08:58 UTC 2021

Modified Files:
src/bin/ksh: ksh.Man
src/share/man/man5: nologin.5
src/sys/dev/marvell: gtreg.h

Log Message:
"no affect" -> "no effect" in man pages and comments.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/bin/ksh/ksh.Man
cvs rdiff -u -r1.2 -r1.3 src/share/man/man5/nologin.5
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/marvell/gtreg.h

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



CVS commit: src/sys/arch

2021-10-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 30 20:23:12 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64: genassym.cf
src/sys/arch/arm/cortex: gic_splfuncs_armv8.S

Log Message:
Add __HAVE_PREEMPTION support to gic_splfuncs asm funcs.

"looks right to me" - thorpej


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/aarch64/aarch64/genassym.cf
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/cortex/gic_splfuncs_armv8.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/aarch64/aarch64/genassym.cf
diff -u src/sys/arch/aarch64/aarch64/genassym.cf:1.36 src/sys/arch/aarch64/aarch64/genassym.cf:1.37
--- src/sys/arch/aarch64/aarch64/genassym.cf:1.36	Sat Oct 30 18:49:47 2021
+++ src/sys/arch/aarch64/aarch64/genassym.cf	Sat Oct 30 20:23:11 2021
@@ -1,4 +1,4 @@
-# $NetBSD: genassym.cf,v 1.36 2021/10/30 18:49:47 jmcneill Exp $
+# $NetBSD: genassym.cf,v 1.37 2021/10/30 20:23:11 jmcneill Exp $
 #-
 # Copyright (c) 2014 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -163,6 +163,7 @@ define	L_MD_IB_USER		offsetof(struct lwp
 define	L_MD_DA_USER		offsetof(struct lwp, l_md.md_da_user)
 define	L_MD_DB_USER		offsetof(struct lwp, l_md.md_db_user)
 define	L_MD_GA_USER		offsetof(struct lwp, l_md.md_ga_user)
+define	L_NOPREEMPT		offsetof(struct lwp, l_nopreempt)
 define	LW_SYSTEM		LW_SYSTEM
 
 define	FB_X19			FB_X19

Index: src/sys/arch/arm/cortex/gic_splfuncs_armv8.S
diff -u src/sys/arch/arm/cortex/gic_splfuncs_armv8.S:1.1 src/sys/arch/arm/cortex/gic_splfuncs_armv8.S:1.2
--- src/sys/arch/arm/cortex/gic_splfuncs_armv8.S:1.1	Sat Oct 30 18:44:24 2021
+++ src/sys/arch/arm/cortex/gic_splfuncs_armv8.S	Sat Oct 30 20:23:12 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: gic_splfuncs_armv8.S,v 1.1 2021/10/30 18:44:24 jmcneill Exp $ */
+/* $NetBSD: gic_splfuncs_armv8.S,v 1.2 2021/10/30 20:23:12 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2021 Jared McNeill 
@@ -29,7 +29,21 @@
 #include 
 #include "assym.h"
 
-RCSID("$NetBSD: gic_splfuncs_armv8.S,v 1.1 2021/10/30 18:44:24 jmcneill Exp $")
+RCSID("$NetBSD: gic_splfuncs_armv8.S,v 1.2 2021/10/30 20:23:12 jmcneill Exp $")
+
+#ifdef __HAVE_PREEMPTION
+#define	DISABLE_PREEMPTION			\
+	ldr	w1, [x3, #L_NOPREEMPT];		\
+	add	w1, w1, #1;			\
+	str	w1, [x3, #L_NOPREEMPT]
+#define	ENABLE_PREEMPTION			\
+	ldr	w1, [x3, #L_NOPREEMPT];		\
+	sub	w1, w1, #1;			\
+	str	w1, [x3, #L_NOPREEMPT]
+#else
+#define	DISABLE_PREEMPTION
+#define	ENABLE_PREEMPTION
+#endif
 
 /*
  * int
@@ -39,9 +53,10 @@ RCSID("$NetBSD: gic_splfuncs_armv8.S,v 1
  */
 	.align 7/* cacheline-aligned */
 ENTRY_NP(gic_splraise)
-	/* Save cpu_info pointer in x1 */
-	mrs	x1, tpidr_el1			/* get curlwp */
-	ldr	x1, [x1, #L_CPU]		/* get curcpu */
+	/* Save curlwp in x3, curcpu in x1 */
+	mrs	x3, tpidr_el1			/* get curlwp */
+	DISABLE_PREEMPTION
+	ldr	x1, [x3, #L_CPU]		/* get curcpu */
 
 	/* If newipl > cpl, update cpl */
 	ldr	w2, [x1, #CI_CPL]
@@ -50,6 +65,7 @@ ENTRY_NP(gic_splraise)
 	str	w0, [x1, #CI_CPL]
 
 .Lnoraise:
+	ENABLE_PREEMPTION
 	mov	w0, w2/* return oldipl */
 	ret
 END(gic_splraise)
@@ -63,9 +79,10 @@ END(gic_splraise)
  */
 	.align 7/* cacheline-aligned */
 ENTRY_NP(gic_splx)
-	/* Save cpu_info pointer in x1 */
-	mrs	x1, tpidr_el1			/* get curlwp */
-	ldr	x1, [x1, #L_CPU]		/* get curcpu */
+	/* Save curlwp in x3, curcpu in x1 */
+	mrs	x3, tpidr_el1			/* get curlwp */
+	DISABLE_PREEMPTION
+	ldr	x1, [x3, #L_CPU]		/* get curcpu */
 
 	/* If newipl >= cpl, just return */
 	ldr	w2, [x1, #CI_CPL]
@@ -99,6 +116,7 @@ ENTRY_NP(gic_splx)
 	cbnz	w2, _C_LABEL(dosoftints)
 
 .Ldone:
+	ENABLE_PREEMPTION
 	ret
 
 .Lrestart:
@@ -113,6 +131,7 @@ ENTRY_NP(gic_splx)
 	str	xzr, [x1, #CI_SPLX_RESTART]
 
 .Lslow:
+	ENABLE_PREEMPTION
 	/* Jump to slow path */
 	b	_C_LABEL(Xgic_splx)
 END(gic_splx)



CVS commit: src/sys/arch

2021-10-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 30 20:23:12 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64: genassym.cf
src/sys/arch/arm/cortex: gic_splfuncs_armv8.S

Log Message:
Add __HAVE_PREEMPTION support to gic_splfuncs asm funcs.

"looks right to me" - thorpej


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/aarch64/aarch64/genassym.cf
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/cortex/gic_splfuncs_armv8.S

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



CVS commit: src/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 20:01:46 UTC 2021

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

Log Message:
indent: reorder assignments in switch_buffer

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.193 -r1.194 src/usr.bin/indent/indent.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/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.193 src/usr.bin/indent/indent.c:1.194
--- src/usr.bin/indent/indent.c:1.193	Sat Oct 30 18:58:04 2021
+++ src/usr.bin/indent/indent.c	Sat Oct 30 20:01:46 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.193 2021/10/30 18:58:04 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.194 2021/10/30 20:01:46 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.193 2021/10/30 18:58:04 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.194 2021/10/30 20:01:46 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -408,12 +408,13 @@ static void
 switch_buffer(void)
 {
 ps.search_stmt = false;
-saved_inp_s = inp.s;	/* save current input buffer */
-saved_inp_e = inp.e;
-debug_save_com(__func__);
-inp.s = save_com;		/* fix so that subsequent calls to lexi will
- * take tokens out of save_com */
 sc_add_char(' ');		/* add trailing blank, just in case */
+debug_save_com(__func__);
+
+saved_inp_s = inp.s;
+saved_inp_e = inp.e;
+
+inp.s = save_com;		/* redirect lexi input to save_com */
 inp.e = sc_end;
 sc_end = NULL;
 debug_println("switched inp.s to save_com");



CVS commit: src/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 20:01:46 UTC 2021

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

Log Message:
indent: reorder assignments in switch_buffer

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.193 -r1.194 src/usr.bin/indent/indent.c

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



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

2021-10-30 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Oct 30 19:54:58 UTC 2021

Modified Files:
src/sys/arch/arm/include: signal.h

Log Message:
Fix the previous to only apply to the non-AArch64 case.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/include/signal.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/arm/include/signal.h
diff -u src/sys/arch/arm/include/signal.h:1.19 src/sys/arch/arm/include/signal.h:1.20
--- src/sys/arch/arm/include/signal.h:1.19	Sat Oct 30 15:51:52 2021
+++ src/sys/arch/arm/include/signal.h	Sat Oct 30 19:54:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: signal.h,v 1.19 2021/10/30 15:51:52 thorpej Exp $	*/
+/*	$NetBSD: signal.h,v 1.20 2021/10/30 19:54:58 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1994-1996 Mark Brinicombe.
@@ -49,14 +49,14 @@
 #include 
 #include 
 
-#define	__HAVE_STRUCT_SIGCONTEXT
-
 #ifndef _LOCORE
 typedef int sig_atomic_t;
 #endif
 
 #if defined(__arm__)
 
+#define	__HAVE_STRUCT_SIGCONTEXT
+
 #if defined(_NETBSD_SOURCE)
 
 #ifndef _LOCORE



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

2021-10-30 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Oct 30 19:54:58 UTC 2021

Modified Files:
src/sys/arch/arm/include: signal.h

Log Message:
Fix the previous to only apply to the non-AArch64 case.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/include/signal.h

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



CVS commit: src/sys/arch/powerpc

2021-10-30 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Oct 30 19:44:56 UTC 2021

Modified Files:
src/sys/arch/powerpc/oea: altivec.c
src/sys/arch/powerpc/powerpc: compat_16_machdep.c

Log Message:
- In vec_restore_from_mcontext() and vec_save_to_mcontext(), allows the
  mcontext argument to be NULL.
- In sendsig_sigcontext(), don't set PSL_VEC in the saved MSR; we can't
  actually round-trip the AltiVec registers.  At least get them saved
  into the PCB by calling vec_save_to_mcontext() (with a NULL mcontext
  argument).
- In compat_16_sys___sigreturn14(), call vec_restore_from_mcontext()
  with a NULL mcontext argument, which will force any subsequent use
  of AltiVec to re-load the AltiVec registers from the PCB.

This isn't ideal, but it's the best we can do with the limited capability
of sigcontext.

Fixes PR port-powerpc/56471.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/powerpc/oea/altivec.c
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/powerpc/powerpc/compat_16_machdep.c

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



CVS commit: src/sys/arch/powerpc

2021-10-30 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Oct 30 19:44:56 UTC 2021

Modified Files:
src/sys/arch/powerpc/oea: altivec.c
src/sys/arch/powerpc/powerpc: compat_16_machdep.c

Log Message:
- In vec_restore_from_mcontext() and vec_save_to_mcontext(), allows the
  mcontext argument to be NULL.
- In sendsig_sigcontext(), don't set PSL_VEC in the saved MSR; we can't
  actually round-trip the AltiVec registers.  At least get them saved
  into the PCB by calling vec_save_to_mcontext() (with a NULL mcontext
  argument).
- In compat_16_sys___sigreturn14(), call vec_restore_from_mcontext()
  with a NULL mcontext argument, which will force any subsequent use
  of AltiVec to re-load the AltiVec registers from the PCB.

This isn't ideal, but it's the best we can do with the limited capability
of sigcontext.

Fixes PR port-powerpc/56471.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/powerpc/oea/altivec.c
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/powerpc/powerpc/compat_16_machdep.c

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

Modified files:

Index: src/sys/arch/powerpc/oea/altivec.c
diff -u src/sys/arch/powerpc/oea/altivec.c:1.33 src/sys/arch/powerpc/oea/altivec.c:1.34
--- src/sys/arch/powerpc/oea/altivec.c:1.33	Mon Jul  6 10:52:12 2020
+++ src/sys/arch/powerpc/oea/altivec.c	Sat Oct 30 19:44:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: altivec.c,v 1.33 2020/07/06 10:52:12 rin Exp $	*/
+/*	$NetBSD: altivec.c,v 1.34 2021/10/30 19:44:56 thorpej Exp $	*/
 
 /*
  * Copyright (C) 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: altivec.c,v 1.33 2020/07/06 10:52:12 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: altivec.c,v 1.34 2021/10/30 19:44:56 thorpej Exp $");
 
 #include 
 #include 
@@ -166,10 +166,13 @@ vec_restore_from_mcontext(struct lwp *l,
 	/* we don't need to save the state, just drop it */
 	pcu_discard(_ops, l, true);
 
-	memcpy(pcb->pcb_vr.vreg, >__vrf.__vrs, sizeof (pcb->pcb_vr.vreg));
-	pcb->pcb_vr.vscr = mcp->__vrf.__vscr;
-	pcb->pcb_vr.vrsave = mcp->__vrf.__vrsave;
-	l->l_md.md_utf->tf_vrsave = pcb->pcb_vr.vrsave;
+	if (mcp != NULL) {	/* XXX see compat_16_sys___sigreturn14() */
+		memcpy(pcb->pcb_vr.vreg, >__vrf.__vrs,
+		sizeof (pcb->pcb_vr.vreg));
+		pcb->pcb_vr.vscr = mcp->__vrf.__vscr;
+		pcb->pcb_vr.vrsave = mcp->__vrf.__vrsave;
+		l->l_md.md_utf->tf_vrsave = pcb->pcb_vr.vrsave;
+	}
 }
 
 bool
@@ -188,11 +191,14 @@ vec_save_to_mcontext(struct lwp *l, mcon
 	 */
 	pcu_save(_ops, l);
 
-	mcp->__gregs[_REG_MSR] |= PSL_VEC;
-	mcp->__vrf.__vscr = pcb->pcb_vr.vscr;
-	mcp->__vrf.__vrsave = l->l_md.md_utf->tf_vrsave;
-	memcpy(mcp->__vrf.__vrs, pcb->pcb_vr.vreg, sizeof (mcp->__vrf.__vrs));
-	*flagp |= _UC_POWERPC_VEC;
+	if (mcp != NULL) {	/* XXX see sendsig_sigcontext() */
+		mcp->__gregs[_REG_MSR] |= PSL_VEC;
+		mcp->__vrf.__vscr = pcb->pcb_vr.vscr;
+		mcp->__vrf.__vrsave = l->l_md.md_utf->tf_vrsave;
+		memcpy(mcp->__vrf.__vrs, pcb->pcb_vr.vreg,
+		sizeof (mcp->__vrf.__vrs));
+		*flagp |= _UC_POWERPC_VEC;
+	}
 	return true;
 }
 

Index: src/sys/arch/powerpc/powerpc/compat_16_machdep.c
diff -u src/sys/arch/powerpc/powerpc/compat_16_machdep.c:1.21 src/sys/arch/powerpc/powerpc/compat_16_machdep.c:1.22
--- src/sys/arch/powerpc/powerpc/compat_16_machdep.c:1.21	Wed Oct 27 04:15:00 2021
+++ src/sys/arch/powerpc/powerpc/compat_16_machdep.c	Sat Oct 30 19:44:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_16_machdep.c,v 1.21 2021/10/27 04:15:00 thorpej Exp $	*/
+/*	$NetBSD: compat_16_machdep.c,v 1.22 2021/10/30 19:44:56 thorpej Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: compat_16_machdep.c,v 1.21 2021/10/27 04:15:00 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_16_machdep.c,v 1.22 2021/10/30 19:44:56 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_altivec.h"
@@ -104,7 +104,12 @@ sendsig_sigcontext(const ksiginfo_t *ksi
 	utf->srr1 |= pcb->pcb_flags & (PCB_FE0|PCB_FE1);
 #endif
 #if defined(ALTIVEC) || defined(PPC_HAVE_SPE)
-	utf->srr1 |= vec_used_p(l) ? PSL_VEC : 0;
+	/*
+	 * We can't round-trip the vector unit registers with a
+	 * sigcontext, so at least get them saved into the PCB.
+	 * XXX vec_save_to_mcontext() has a special hack for this.
+	 */
+	vec_save_to_mcontext(l, NULL, NULL);
 #endif
 #ifdef PPC_OEA
 	utf->vrsave = tf->tf_vrsave;
@@ -221,6 +226,15 @@ compat_16_sys___sigreturn14(struct lwp *
 	pcb->pcb_flags &= ~(PCB_FE0|PCB_FE1);
 	pcb->pcb_flags |= utf->srr1 & (PCB_FE0|PCB_FE1);
 #endif
+#if defined(ALTIVEC) || defined(PPC_HAVE_SPE)
+	/*
+	 * We can't round-trip the vector unit registers with a
+	 * sigcontext, so at least force them to get reloaded from
+	 * the PCB (we saved them into the PCB in sendsig_sigcontext()).
+	 * XXX vec_restore_from_mcontext() has a special hack for this.
+	 */
+	vec_restore_from_mcontext(l, NULL);
+#endif
 #ifdef PPC_OEA

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

2021-10-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 30 19:28:40 UTC 2021

Modified Files:
src/sys/arch/evbarm/conf: std.generic64

Log Message:
Enable GIC_SPLFUNCS again. Hopefully stable now.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/evbarm/conf/std.generic64

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/evbarm/conf/std.generic64
diff -u src/sys/arch/evbarm/conf/std.generic64:1.16 src/sys/arch/evbarm/conf/std.generic64:1.17
--- src/sys/arch/evbarm/conf/std.generic64:1.16	Sun Oct  3 23:19:26 2021
+++ src/sys/arch/evbarm/conf/std.generic64	Sat Oct 30 19:28:40 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: std.generic64,v 1.16 2021/10/03 23:19:26 jmcneill Exp $
+#	$NetBSD: std.generic64,v 1.17 2021/10/30 19:28:40 jmcneill Exp $
 #
 #	generic NetBSD/evbarm64 with FDT support
 
@@ -16,7 +16,7 @@ options 	DRAM_BLOCKS=256
 options 	EVBARM_BOARDTYPE="FDT"
 options 	FDT# Flattened Device Tree support
 options 	FPU_VFP
-#options 	GIC_SPLFUNCS
+options 	GIC_SPLFUNCS
 options 	MODULAR
 options 	MODULAR_DEFAULT_AUTOLOAD
 options 	PCI_NETBSD_CONFIGURE



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

2021-10-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 30 19:28:40 UTC 2021

Modified Files:
src/sys/arch/evbarm/conf: std.generic64

Log Message:
Enable GIC_SPLFUNCS again. Hopefully stable now.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/evbarm/conf/std.generic64

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



CVS commit: src/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 18:58:05 UTC 2021

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

Log Message:
indent: move buffer functions further up

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.192 -r1.193 src/usr.bin/indent/indent.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/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.192 src/usr.bin/indent/indent.c:1.193
--- src/usr.bin/indent/indent.c:1.192	Sat Oct 30 18:47:36 2021
+++ src/usr.bin/indent/indent.c	Sat Oct 30 18:58:04 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.192 2021/10/30 18:47:36 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.193 2021/10/30 18:58:04 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.192 2021/10/30 18:47:36 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.193 2021/10/30 18:58:04 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -142,6 +142,72 @@ init_capsicum(void)
 }
 #endif
 
+static void
+buf_init(struct buffer *buf)
+{
+size_t size = 200;
+buf->buf = xmalloc(size);
+buf->l = buf->buf + size - 5 /* safety margin */;
+buf->s = buf->buf + 1;	/* allow accessing buf->e[-1] */
+buf->e = buf->s;
+buf->buf[0] = ' ';
+buf->buf[1] = '\0';
+}
+
+static size_t
+buf_len(const struct buffer *buf)
+{
+return (size_t)(buf->e - buf->s);
+}
+
+void
+buf_expand(struct buffer *buf, size_t add_size)
+{
+size_t new_size = (size_t)(buf->l - buf->s) + 400 + add_size;
+size_t len = buf_len(buf);
+buf->buf = xrealloc(buf->buf, new_size);
+buf->l = buf->buf + new_size - 5;
+buf->s = buf->buf + 1;
+buf->e = buf->s + len;
+/* At this point, the buffer may not be null-terminated anymore. */
+}
+
+static void
+buf_reserve(struct buffer *buf, size_t n)
+{
+if (n >= (size_t)(buf->l - buf->e))
+	buf_expand(buf, n);
+}
+
+static void
+buf_add_char(struct buffer *buf, char ch)
+{
+buf_reserve(buf, 1);
+*buf->e++ = ch;
+}
+
+static void
+buf_add_buf(struct buffer *buf, const struct buffer *add)
+{
+size_t len = buf_len(add);
+buf_reserve(buf, len);
+memcpy(buf->e, add->s, len);
+buf->e += len;
+}
+
+static void
+buf_terminate(struct buffer *buf)
+{
+buf_reserve(buf, 1);
+*buf->e = '\0';
+}
+
+static void
+buf_reset(struct buffer *buf)
+{
+buf->e = buf->s;
+}
+
 void
 diag(int level, const char *msg, ...)
 {
@@ -430,72 +496,6 @@ search_stmt(lexer_symbol *lsym, bool *fo
 }
 
 static void
-buf_init(struct buffer *buf)
-{
-size_t size = 200;
-buf->buf = xmalloc(size);
-buf->l = buf->buf + size - 5 /* safety margin */;
-buf->s = buf->buf + 1;	/* allow accessing buf->e[-1] */
-buf->e = buf->s;
-buf->buf[0] = ' ';
-buf->buf[1] = '\0';
-}
-
-static size_t
-buf_len(const struct buffer *buf)
-{
-return (size_t)(buf->e - buf->s);
-}
-
-void
-buf_expand(struct buffer *buf, size_t add_size)
-{
-size_t new_size = (size_t)(buf->l - buf->s) + 400 + add_size;
-size_t len = buf_len(buf);
-buf->buf = xrealloc(buf->buf, new_size);
-buf->l = buf->buf + new_size - 5;
-buf->s = buf->buf + 1;
-buf->e = buf->s + len;
-/* At this point, the buffer may not be null-terminated anymore. */
-}
-
-static void
-buf_reserve(struct buffer *buf, size_t n)
-{
-if (n >= (size_t)(buf->l - buf->e))
-	buf_expand(buf, n);
-}
-
-static void
-buf_add_char(struct buffer *buf, char ch)
-{
-buf_reserve(buf, 1);
-*buf->e++ = ch;
-}
-
-static void
-buf_add_buf(struct buffer *buf, const struct buffer *add)
-{
-size_t len = buf_len(add);
-buf_reserve(buf, len);
-memcpy(buf->e, add->s, len);
-buf->e += len;
-}
-
-static void
-buf_terminate(struct buffer *buf)
-{
-buf_reserve(buf, 1);
-*buf->e = '\0';
-}
-
-static void
-buf_reset(struct buffer *buf)
-{
-buf->e = buf->s;
-}
-
-static void
 main_init_globals(void)
 {
 inp.buf = xmalloc(10);



CVS commit: src/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 18:58:05 UTC 2021

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

Log Message:
indent: move buffer functions further up

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.192 -r1.193 src/usr.bin/indent/indent.c

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



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

2021-10-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 30 18:49:47 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64: genassym.cf

Log Message:
Add CI_SPLX_SAVEDIPL and CI_HWPL


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/aarch64/aarch64/genassym.cf

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

Modified files:

Index: src/sys/arch/aarch64/aarch64/genassym.cf
diff -u src/sys/arch/aarch64/aarch64/genassym.cf:1.35 src/sys/arch/aarch64/aarch64/genassym.cf:1.36
--- src/sys/arch/aarch64/aarch64/genassym.cf:1.35	Thu Sep 30 21:19:16 2021
+++ src/sys/arch/aarch64/aarch64/genassym.cf	Sat Oct 30 18:49:47 2021
@@ -1,4 +1,4 @@
-# $NetBSD: genassym.cf,v 1.35 2021/09/30 21:19:16 skrll Exp $
+# $NetBSD: genassym.cf,v 1.36 2021/10/30 18:49:47 jmcneill Exp $
 #-
 # Copyright (c) 2014 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -298,6 +298,8 @@ define	CI_SOFTINTS		offsetof(struct cpu_
 define	CI_IDLELWP		offsetof(struct cpu_info, ci_data.cpu_idlelwp)
 define	CI_CC_NINTR		offsetof(struct cpu_info, ci_data.cpu_nintr)
 define	CI_SPLX_RESTART		offsetof(struct cpu_info, ci_splx_restart)
+define	CI_SPLX_SAVEDIPL	offsetof(struct cpu_info, ci_splx_savedipl)
+define	CI_HWPL			offsetof(struct cpu_info, ci_hwpl)
 
 define	V_RESCHED_KPREEMPT	ilog2(RESCHED_KPREEMPT)
 



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

2021-10-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 30 18:49:47 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64: genassym.cf

Log Message:
Add CI_SPLX_SAVEDIPL and CI_HWPL


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/aarch64/aarch64/genassym.cf

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



CVS commit: src/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 18:47:36 UTC 2021

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

Log Message:
indent: group variables by topic

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.191 -r1.192 src/usr.bin/indent/indent.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/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.191 src/usr.bin/indent/indent.c:1.192
--- src/usr.bin/indent/indent.c:1.191	Sat Oct 30 17:55:44 2021
+++ src/usr.bin/indent/indent.c	Sat Oct 30 18:47:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.191 2021/10/30 17:55:44 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.192 2021/10/30 18:47:36 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.191 2021/10/30 17:55:44 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.192 2021/10/30 18:47:36 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -88,12 +88,13 @@ struct options opt = {
 
 struct parser_state ps;
 
+struct buffer inp;
+
+struct buffer token;
+
 struct buffer lab;
 struct buffer code;
 struct buffer com;
-struct buffer token;
-
-struct buffer inp;
 
 char sc_buf[sc_size];
 char *save_com;



CVS commit: src/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 18:47:36 UTC 2021

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

Log Message:
indent: group variables by topic

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.191 -r1.192 src/usr.bin/indent/indent.c

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



CVS commit: src/sys/arch

2021-10-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 30 18:44:24 UTC 2021

Modified Files:
src/sys/arch/aarch64/conf: files.aarch64
src/sys/arch/arm/cortex: gic_splfuncs.c
Added Files:
src/sys/arch/arm/cortex: gic_splfuncs_armv8.S

Log Message:
Implement gic_splraise and the gic_splx fast path in asm (armv8).


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/aarch64/conf/files.aarch64
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/cortex/gic_splfuncs.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/cortex/gic_splfuncs_armv8.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/aarch64/conf/files.aarch64
diff -u src/sys/arch/aarch64/conf/files.aarch64:1.34 src/sys/arch/aarch64/conf/files.aarch64:1.35
--- src/sys/arch/aarch64/conf/files.aarch64:1.34	Sun Oct 10 07:15:25 2021
+++ src/sys/arch/aarch64/conf/files.aarch64	Sat Oct 30 18:44:24 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: files.aarch64,v 1.34 2021/10/10 07:15:25 skrll Exp $
+#	$NetBSD: files.aarch64,v 1.35 2021/10/30 18:44:24 jmcneill Exp $
 
 defflag opt_cpuoptions.h	AARCH64_ALIGNMENT_CHECK
 defflag opt_cpuoptions.h	AARCH64_EL0_STACK_ALIGNMENT_CHECK
@@ -119,6 +119,9 @@ file	arch/aarch64/aarch64/pmap_page.S
 file	uvm/pmap/pmap_tlb.c
 file	uvm/pmap/pmap_pvt.c
 
+# GIC
+file	arch/arm/cortex/gic_splfuncs_armv8.S		gic_splfuncs
+
 # EFI runtime (machdep)
 file	arch/aarch64/aarch64/efi_machdep.c		efi_runtime
 

Index: src/sys/arch/arm/cortex/gic_splfuncs.c
diff -u src/sys/arch/arm/cortex/gic_splfuncs.c:1.4 src/sys/arch/arm/cortex/gic_splfuncs.c:1.5
--- src/sys/arch/arm/cortex/gic_splfuncs.c:1.4	Sun Sep 26 20:55:15 2021
+++ src/sys/arch/arm/cortex/gic_splfuncs.c	Sat Oct 30 18:44:24 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: gic_splfuncs.c,v 1.4 2021/09/26 20:55:15 jmcneill Exp $ */
+/* $NetBSD: gic_splfuncs.c,v 1.5 2021/10/30 18:44:24 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2021 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gic_splfuncs.c,v 1.4 2021/09/26 20:55:15 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gic_splfuncs.c,v 1.5 2021/10/30 18:44:24 jmcneill Exp $");
 
 #include 
 #include 
@@ -41,16 +41,12 @@ __KERNEL_RCSID(0, "$NetBSD: gic_splfuncs
 
 #include 
 
-static int
-gic_splraise(int newipl)
-{
-	struct cpu_info * const ci = curcpu();
-	const int oldipl = ci->ci_cpl;
-	if (__predict_true(newipl > oldipl)) {
-		ci->ci_cpl = newipl;
-	}
-	return oldipl;
-}
+/* Prototypes for functions in gic_splfuncs_.S */
+int	gic_splraise(int);
+void	gic_splx(int);
+
+/* Local functions */
+void	Xgic_splx(int);	
 
 static int
 gic_spllower(int newipl)
@@ -72,8 +68,8 @@ gic_spllower(int newipl)
 	return oldipl;
 }
 
-static void
-gic_splx(int newipl)
+void
+Xgic_splx(int newipl)
 {
 	struct cpu_info *ci = curcpu();
 	register_t psw;
@@ -82,37 +78,6 @@ gic_splx(int newipl)
 		return;
 	}
 
-	/*
-	 * Try to avoid touching any hardware registers (DAIF, PMR) as an
-	 * optimization for the common case of splraise followed by splx
-	 * with no interrupts in between.
-	 *
-	 * If an interrupt fires in this critical section, the vector
-	 * handler is responsible for returning to the address pointed
-	 * to by ci_splx_restart to restart the sequence.
-	 */
-	if (__predict_true(ci->ci_intr_depth == 0)) {
-		ci->ci_splx_savedipl = newipl;
-		__insn_barrier();
-		ci->ci_splx_restart = &
-		__insn_barrier();
-checkhwpl:
-		if (ci->ci_hwpl <= newipl) {
-			ci->ci_cpl = newipl;
-			__insn_barrier();
-			ci->ci_splx_restart = NULL;
-			goto dosoft;
-		} else {
-			ci->ci_splx_restart = NULL;
-			goto dohard;
-		}
-restart:
-		ci = curcpu();
-		newipl = ci->ci_splx_savedipl;
-		goto checkhwpl;
-	}
-
-dohard:
 	psw = DISABLE_INTERRUPT_SAVE();
 	ci->ci_intr_depth++;
 	pic_do_pending_ints(psw, newipl, NULL);
@@ -121,7 +86,6 @@ dohard:
 		ENABLE_INTERRUPT();
 	}
 
-dosoft:
 	cpu_dosoftints();
 }
 

Added files:

Index: src/sys/arch/arm/cortex/gic_splfuncs_armv8.S
diff -u /dev/null src/sys/arch/arm/cortex/gic_splfuncs_armv8.S:1.1
--- /dev/null	Sat Oct 30 18:44:24 2021
+++ src/sys/arch/arm/cortex/gic_splfuncs_armv8.S	Sat Oct 30 18:44:24 2021
@@ -0,0 +1,118 @@
+/* $NetBSD: gic_splfuncs_armv8.S,v 1.1 2021/10/30 18:44:24 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2021 Jared McNeill 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 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 AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, 

CVS commit: src/sys/arch

2021-10-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 30 18:44:24 UTC 2021

Modified Files:
src/sys/arch/aarch64/conf: files.aarch64
src/sys/arch/arm/cortex: gic_splfuncs.c
Added Files:
src/sys/arch/arm/cortex: gic_splfuncs_armv8.S

Log Message:
Implement gic_splraise and the gic_splx fast path in asm (armv8).


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/aarch64/conf/files.aarch64
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/cortex/gic_splfuncs.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/cortex/gic_splfuncs_armv8.S

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



CVS commit: src/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 18:23:17 UTC 2021

Modified Files:
src/usr.bin/indent: pr_comment.c

Log Message:
indent: fix bounds check for sc_buf

Some years ago, save_com was an array of characters, used as temporary
storage. When sc_buf was added, this code was forgotten. The bounds
check must be on the array itself, not on an iterator that points
somewhere in that array.


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/usr.bin/indent/pr_comment.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/indent/pr_comment.c
diff -u src/usr.bin/indent/pr_comment.c:1.91 src/usr.bin/indent/pr_comment.c:1.92
--- src/usr.bin/indent/pr_comment.c:1.91	Sat Oct 30 16:57:18 2021
+++ src/usr.bin/indent/pr_comment.c	Sat Oct 30 18:23:17 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pr_comment.c,v 1.91 2021/10/30 16:57:18 rillig Exp $	*/
+/*	$NetBSD: pr_comment.c,v 1.92 2021/10/30 18:23:17 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)pr_comment.c
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: pr_comment.c,v 1.91 2021/10/30 16:57:18 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.92 2021/10/30 18:23:17 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -189,11 +189,8 @@ process_comment(void)
 	/*
 	 * XXX: ordered comparison between pointers from different objects
 	 * invokes undefined behavior (C99 6.5.8).
-	 *
-	 * XXX: It's easier to understand if inp.s is used instead of inp.buf,
-	 * since inp.buf is only intended to be used for allocation purposes.
 	 */
-	start = inp.s >= save_com && inp.s < save_com + sc_size ?
+	start = inp.s >= sc_buf && inp.s < sc_buf + sc_size ?
 	sc_buf : inp.buf;
 	ps.n_comment_delta = -indentation_after_range(0, start, inp.s - 2);
 } else {



CVS commit: src/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 18:23:17 UTC 2021

Modified Files:
src/usr.bin/indent: pr_comment.c

Log Message:
indent: fix bounds check for sc_buf

Some years ago, save_com was an array of characters, used as temporary
storage. When sc_buf was added, this code was forgotten. The bounds
check must be on the array itself, not on an iterator that points
somewhere in that array.


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/usr.bin/indent/pr_comment.c

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



CVS commit: src/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 17:55:45 UTC 2021

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

Log Message:
indent: prevent buffer overflow in search_stmt_comment

printf '{ if (%01d) /*comment*/ ; }' '0' | indent


To generate a diff of this commit:
cvs rdiff -u -r1.190 -r1.191 src/usr.bin/indent/indent.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/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.190 src/usr.bin/indent/indent.c:1.191
--- src/usr.bin/indent/indent.c:1.190	Sat Oct 30 17:18:25 2021
+++ src/usr.bin/indent/indent.c	Sat Oct 30 17:55:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.190 2021/10/30 17:18:25 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.191 2021/10/30 17:55:44 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.190 2021/10/30 17:18:25 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.191 2021/10/30 17:55:44 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -237,8 +237,10 @@ search_stmt_comment(bool *comment_buffer
 	 * (size_t)-1 bytes.
 	 */
 	assert((size_t)(inp.s - inp.buf) >= 4);
-	memcpy(sc_buf, inp.buf, (size_t)(inp.s - inp.buf) - 4);
-	save_com = sc_buf + (inp.s - inp.buf - 4);
+	size_t line_len = (size_t)(inp.s - inp.buf) - 4;
+	assert(line_len < array_length(sc_buf));
+	memcpy(sc_buf, inp.buf, line_len);
+	save_com = sc_buf + line_len;
 	save_com[0] = save_com[1] = ' ';
 	sc_end = _com[2];
 	debug_vis_range("search_stmt_comment: before save_com is \"",



CVS commit: src/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 17:55:45 UTC 2021

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

Log Message:
indent: prevent buffer overflow in search_stmt_comment

printf '{ if (%01d) /*comment*/ ; }' '0' | indent


To generate a diff of this commit:
cvs rdiff -u -r1.190 -r1.191 src/usr.bin/indent/indent.c

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



CVS commit: src/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 17:18:26 UTC 2021

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

Log Message:
indent: add debug logging for save_com

This will help in finding the proper fix for the assertion failure in
search_stmt_comment.

Add an assertion in search_stmt_lbrace to prevent the previous,
incomplete fix from being applied again.


To generate a diff of this commit:
cvs rdiff -u -r1.189 -r1.190 src/usr.bin/indent/indent.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/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.189 src/usr.bin/indent/indent.c:1.190
--- src/usr.bin/indent/indent.c:1.189	Sat Oct 30 16:18:51 2021
+++ src/usr.bin/indent/indent.c	Sat Oct 30 17:18:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.189 2021/10/30 16:18:51 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.190 2021/10/30 17:18:25 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.189 2021/10/30 16:18:51 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.190 2021/10/30 17:18:25 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -157,6 +157,17 @@ diag(int level, const char *msg, ...)
 va_end(ap);
 }
 
+#ifdef debug
+static void
+debug_save_com(const char *prefix)
+{
+debug_printf("%s: save_com is ", prefix);
+debug_vis_range("\"", save_com, sc_end, "\"\n");
+}
+#else
+#define debug_save_com(prefix) do { } while (false)
+#endif
+
 static void
 sc_check_size(size_t n)
 {
@@ -192,8 +203,10 @@ search_stmt_newline(bool *force_nl)
 	save_com = sc_buf;
 	save_com[0] = save_com[1] = ' ';
 	sc_end = _com[2];
+	debug_save_com("search_stmt_newline init");
 }
 sc_add_char('\n');
+debug_save_com(__func__);
 
 line_no++;
 
@@ -228,6 +241,10 @@ search_stmt_comment(bool *comment_buffer
 	save_com = sc_buf + (inp.s - inp.buf - 4);
 	save_com[0] = save_com[1] = ' ';
 	sc_end = _com[2];
+	debug_vis_range("search_stmt_comment: before save_com is \"",
+	sc_buf, save_com, "\"\n");
+	debug_vis_range("search_stmt_comment: save_com is \"",
+	save_com, sc_end, "\"\n");
 }
 
 *comment_buffered = true;
@@ -238,6 +255,7 @@ search_stmt_comment(bool *comment_buffer
 	sc_add_char(inbuf_next());
 	if (sc_end[-1] == '*' && *inp.s == '/') {
 	sc_add_char(inbuf_next());
+	debug_save_com("search_stmt_comment end");
 	break;
 	}
 }
@@ -251,6 +269,7 @@ search_stmt_lbrace(void)
  * this loop in order to avoid copying the token again.
  */
 if (sc_end != NULL && opt.brace_same_line) {
+	assert(save_com[0] == ' ');	/* see search_stmt_comment */
 	save_com[0] = '{';
 	/*
 	 * Originally the lbrace may have been alone on its own line, but it
@@ -262,6 +281,7 @@ search_stmt_lbrace(void)
 	if (*inp.s == '\n')
 		break;
 	}
+	debug_save_com(__func__);
 	return true;
 }
 return false;
@@ -287,6 +307,7 @@ search_stmt_other(lexer_symbol lsym, boo
 	return false;
 }
 
+debug_save_com(__func__);
 while (sc_end > save_com && ch_isblank(sc_end[-1]))
 	sc_end--;
 
@@ -310,6 +331,7 @@ search_stmt_other(lexer_symbol lsym, boo
 
 for (const char *t_ptr = token.s; *t_ptr != '\0'; ++t_ptr)
 	sc_add_char(*t_ptr);
+debug_save_com("search_stmt_other end");
 return true;
 }
 
@@ -319,6 +341,7 @@ switch_buffer(void)
 ps.search_stmt = false;
 saved_inp_s = inp.s;	/* save current input buffer */
 saved_inp_e = inp.e;
+debug_save_com(__func__);
 inp.s = save_com;		/* fix so that subsequent calls to lexi will
  * take tokens out of save_com */
 sc_add_char(' ');		/* add trailing blank, just in case */
@@ -353,6 +376,7 @@ search_stmt_lookahead(lexer_symbol *lsym
 if (sc_end != NULL) {
 	while (ch_isblank(*inp.s))
 	sc_add_char(inbuf_next());
+	debug_save_com(__func__);
 }
 
 struct parser_state backup_ps = ps;
@@ -1267,6 +1291,7 @@ read_preprocessing_line(void)
 	inp.s = save_com;	/* fix so that subsequent calls to lexi will
  * take tokens out of save_com */
 	sc_add_char(' ');	/* add trailing blank, just in case */
+	debug_save_com(__func__);
 	inp.e = sc_end;
 	sc_end = NULL;
 	debug_println("switched inp.s to save_com");



CVS commit: src/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 17:18:26 UTC 2021

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

Log Message:
indent: add debug logging for save_com

This will help in finding the proper fix for the assertion failure in
search_stmt_comment.

Add an assertion in search_stmt_lbrace to prevent the previous,
incomplete fix from being applied again.


To generate a diff of this commit:
cvs rdiff -u -r1.189 -r1.190 src/usr.bin/indent/indent.c

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



CVS commit: src

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 16:57:18 UTC 2021

Modified Files:
src/tests/usr.bin/indent: t_errors.sh token_comment.c
src/usr.bin/indent: pr_comment.c

Log Message:
indent: fix assertion in fits_in_one_line


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/tests/usr.bin/indent/t_errors.sh
cvs rdiff -u -r1.13 -r1.14 src/tests/usr.bin/indent/token_comment.c
cvs rdiff -u -r1.90 -r1.91 src/usr.bin/indent/pr_comment.c

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

Modified files:

Index: src/tests/usr.bin/indent/t_errors.sh
diff -u src/tests/usr.bin/indent/t_errors.sh:1.16 src/tests/usr.bin/indent/t_errors.sh:1.17
--- src/tests/usr.bin/indent/t_errors.sh:1.16	Sat Oct 30 16:43:23 2021
+++ src/tests/usr.bin/indent/t_errors.sh	Sat Oct 30 16:57:18 2021
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: t_errors.sh,v 1.16 2021/10/30 16:43:23 rillig Exp $
+# $NetBSD: t_errors.sh,v 1.17 2021/10/30 16:57:18 rillig Exp $
 #
 # Copyright (c) 2021 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -435,6 +435,8 @@ search_stmt_fits_in_one_line_body()
 	# The comment is placed after 'if (0) ...', where it is processed
 	# by search_stmt_comment. That function redirects the input buffer to
 	# a temporary buffer that is not guaranteed to be terminated by '\n'.
+	# Before NetBSD pr_comment.c 1.91 from 2021-10-30, this produced an
+	# assertion failure in fits_in_one_line.
 	cat < code.c
 int f(void)
 {
@@ -443,7 +445,20 @@ int f(void)
 }
 EOF
 
-	atf_check -s 'signal' -o 'ignore' -e 'match:assert' \
+	# Indent tries hard to make the comment fit to the 34-character line
+	# length, but it is just not possible.
+	cat < expected.out
+int
+f(void)
+{
+	if (0)
+		/*
+		 * 0123456789012345678901
+		  */ ;
+}
+EOF
+
+	atf_check -o 'file:expected.out' \
 	"$indent" -l34 code.c -st
 }
 

Index: src/tests/usr.bin/indent/token_comment.c
diff -u src/tests/usr.bin/indent/token_comment.c:1.13 src/tests/usr.bin/indent/token_comment.c:1.14
--- src/tests/usr.bin/indent/token_comment.c:1.13	Sat Oct 30 15:26:58 2021
+++ src/tests/usr.bin/indent/token_comment.c	Sat Oct 30 16:57:18 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token_comment.c,v 1.13 2021/10/30 15:26:58 rillig Exp $ */
+/* $NetBSD: token_comment.c,v 1.14 2021/10/30 16:57:18 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -913,3 +913,38 @@ end */
  * Ümläute
  */
 #indent end
+
+
+/*
+ *
+ */
+#indent input
+int f(void)
+{
+	if (0)
+		/* 12 1234 123 123456 1234 1234567 123 1234.  */;
+}
+#indent end
+
+/* The comment is too long to fit in a single line. */
+#indent run -l54
+int
+f(void)
+{
+	if (0)
+		/*
+		 * 12 1234 123 123456 1234 1234567 123
+		 * 1234.
+		  */ ;
+}
+#indent end
+
+/* The comment fits in a single line. */
+#indent run
+int
+f(void)
+{
+	if (0)
+		 /* 12 1234 123 123456 1234 1234567 123 1234.  */ ;
+}
+#indent end

Index: src/usr.bin/indent/pr_comment.c
diff -u src/usr.bin/indent/pr_comment.c:1.90 src/usr.bin/indent/pr_comment.c:1.91
--- src/usr.bin/indent/pr_comment.c:1.90	Fri Oct 29 20:27:42 2021
+++ src/usr.bin/indent/pr_comment.c	Sat Oct 30 16:57:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pr_comment.c,v 1.90 2021/10/29 20:27:42 rillig Exp $	*/
+/*	$NetBSD: pr_comment.c,v 1.91 2021/10/30 16:57:18 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)pr_comment.c
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: pr_comment.c,v 1.90 2021/10/29 20:27:42 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.91 2021/10/30 16:57:18 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -94,8 +94,7 @@ fits_in_one_line(int max_line_length)
 
 	int len = indentation_after_range(ps.com_ind + 3, inp.s, p);
 	len += ch_isblank(p[-1]) ? 2 : 3;
-	if (len <= max_line_length)
-	return true;
+	return len <= max_line_length;
 }
 return false;
 }



CVS commit: src

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 16:57:18 UTC 2021

Modified Files:
src/tests/usr.bin/indent: t_errors.sh token_comment.c
src/usr.bin/indent: pr_comment.c

Log Message:
indent: fix assertion in fits_in_one_line


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/tests/usr.bin/indent/t_errors.sh
cvs rdiff -u -r1.13 -r1.14 src/tests/usr.bin/indent/token_comment.c
cvs rdiff -u -r1.90 -r1.91 src/usr.bin/indent/pr_comment.c

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



CVS commit: src/tests/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 16:43:23 UTC 2021

Modified Files:
src/tests/usr.bin/indent: t_errors.sh

Log Message:
tests/indent: demonstrate assertion failure in fits_in_one_line


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/tests/usr.bin/indent/t_errors.sh

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

Modified files:

Index: src/tests/usr.bin/indent/t_errors.sh
diff -u src/tests/usr.bin/indent/t_errors.sh:1.15 src/tests/usr.bin/indent/t_errors.sh:1.16
--- src/tests/usr.bin/indent/t_errors.sh:1.15	Sat Oct 30 15:26:58 2021
+++ src/tests/usr.bin/indent/t_errors.sh	Sat Oct 30 16:43:23 2021
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: t_errors.sh,v 1.15 2021/10/30 15:26:58 rillig Exp $
+# $NetBSD: t_errors.sh,v 1.16 2021/10/30 16:43:23 rillig Exp $
 #
 # Copyright (c) 2021 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -429,6 +429,25 @@ EOF
 	"$indent" code.c -st
 }
 
+atf_test_case 'search_stmt_fits_in_one_line'
+search_stmt_fits_in_one_line_body()
+{
+	# The comment is placed after 'if (0) ...', where it is processed
+	# by search_stmt_comment. That function redirects the input buffer to
+	# a temporary buffer that is not guaranteed to be terminated by '\n'.
+	cat < code.c
+int f(void)
+{
+	if (0)
+		/* 0123456789012345678901 */;
+}
+EOF
+
+	atf_check -s 'signal' -o 'ignore' -e 'match:assert' \
+	"$indent" -l34 code.c -st
+}
+
+
 atf_init_test_cases()
 {
 	atf_add_test_case 'option_unknown'
@@ -461,4 +480,5 @@ atf_init_test_cases()
 	atf_add_test_case 'unbalanced_parentheses_2'
 	atf_add_test_case 'unbalanced_parentheses_3'
 	atf_add_test_case 'search_stmt_comment_segv'
+	atf_add_test_case 'search_stmt_fits_in_one_line'
 }



CVS commit: src/tests/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 16:43:23 UTC 2021

Modified Files:
src/tests/usr.bin/indent: t_errors.sh

Log Message:
tests/indent: demonstrate assertion failure in fits_in_one_line


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/tests/usr.bin/indent/t_errors.sh

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



CVS commit: src/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 16:18:51 UTC 2021

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

Log Message:
indent: prevent buffer overflows in 'if (expr) ... stmt'


To generate a diff of this commit:
cvs rdiff -u -r1.188 -r1.189 src/usr.bin/indent/indent.c

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



CVS commit: src/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 16:18:51 UTC 2021

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

Log Message:
indent: prevent buffer overflows in 'if (expr) ... stmt'


To generate a diff of this commit:
cvs rdiff -u -r1.188 -r1.189 src/usr.bin/indent/indent.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/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.188 src/usr.bin/indent/indent.c:1.189
--- src/usr.bin/indent/indent.c:1.188	Sat Oct 30 15:26:58 2021
+++ src/usr.bin/indent/indent.c	Sat Oct 30 16:18:51 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.188 2021/10/30 15:26:58 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.189 2021/10/30 16:18:51 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.188 2021/10/30 15:26:58 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.189 2021/10/30 16:18:51 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -158,6 +158,34 @@ diag(int level, const char *msg, ...)
 }
 
 static void
+sc_check_size(size_t n)
+{
+if ((size_t)(sc_end - sc_buf) + n <= sc_size)
+	return;
+
+diag(1, "Internal buffer overflow - "
+	"Move big comment from right after if, while, or whatever");
+fflush(output);
+exit(1);
+}
+
+static void
+sc_add_char(char ch)
+{
+sc_check_size(1);
+*sc_end++ = ch;
+}
+
+static void
+sc_add_range(const char *s, const char *e)
+{
+size_t len = (size_t)(e - s);
+sc_check_size(len);
+memcpy(sc_end, s, len);
+sc_end += len;
+}
+
+static void
 search_stmt_newline(bool *force_nl)
 {
 if (sc_end == NULL) {
@@ -165,7 +193,7 @@ search_stmt_newline(bool *force_nl)
 	save_com[0] = save_com[1] = ' ';
 	sc_end = _com[2];
 }
-*sc_end++ = '\n';
+sc_add_char('\n');
 
 line_no++;
 
@@ -203,23 +231,16 @@ search_stmt_comment(bool *comment_buffer
 }
 
 *comment_buffered = true;
-*sc_end++ = '/';		/* copy in start of comment */
-*sc_end++ = '*';
+sc_add_char('/');
+sc_add_char('*');
 
 for (;;) {			/* loop until the end of the comment */
-	*sc_end++ = inbuf_next();
-	if (sc_end[-1] == '*' && *inp.s == '/')
-	break;		/* we are at end of comment */
-	if (sc_end >= _com[sc_size]) {	/* check for temp buffer
-		 * overflow */
-	diag(1, "Internal buffer overflow - Move big comment from right after if, while, or whatever");
-	fflush(output);
-	exit(1);
+	sc_add_char(inbuf_next());
+	if (sc_end[-1] == '*' && *inp.s == '/') {
+	sc_add_char(inbuf_next());
+	break;
 	}
 }
-
-*sc_end++ = '/';		/* add ending slash */
-inbuf_skip();		/* get past / in buffer */
 }
 
 static bool
@@ -272,9 +293,8 @@ search_stmt_other(lexer_symbol lsym, boo
 if (opt.swallow_optional_blanklines ||
 	(!comment_buffered && remove_newlines)) {
 	*force_nl = !remove_newlines;
-	while (sc_end > save_com && sc_end[-1] == '\n') {
+	while (sc_end > save_com && sc_end[-1] == '\n')
 	sc_end--;
-	}
 }
 
 if (*force_nl) {		/* if we should insert a nl here, put it into
@@ -282,15 +302,14 @@ search_stmt_other(lexer_symbol lsym, boo
 	*force_nl = false;
 	--line_no;		/* this will be re-increased when the newline
  * is read from the buffer */
-	*sc_end++ = '\n';
-	*sc_end++ = ' ';
+	sc_add_char('\n');
+	sc_add_char(' ');
 	if (opt.verbose)	/* warn if the line was not already broken */
 	diag(0, "Line broken");
 }
 
-/* XXX: buffer overflow? This is essentially a strcpy. */
 for (const char *t_ptr = token.s; *t_ptr != '\0'; ++t_ptr)
-	*sc_end++ = *t_ptr;
+	sc_add_char(*t_ptr);
 return true;
 }
 
@@ -302,7 +321,7 @@ switch_buffer(void)
 saved_inp_e = inp.e;
 inp.s = save_com;		/* fix so that subsequent calls to lexi will
  * take tokens out of save_com */
-*sc_end++ = ' ';		/* add trailing blank, just in case */
+sc_add_char(' ');		/* add trailing blank, just in case */
 inp.e = sc_end;
 sc_end = NULL;
 debug_println("switched inp.s to save_com");
@@ -332,13 +351,8 @@ search_stmt_lookahead(lexer_symbol *lsym
  * into the buffer so that the later lexi() call will read them.
  */
 if (sc_end != NULL) {
-	while (ch_isblank(*inp.s)) {
-	*sc_end++ = *inp.s++;
-	if (sc_end >= _com[sc_size])
-		errx(1, "input too long");
-	}
-	if (inp.s >= inp.e)
-	inbuf_read_line();
+	while (ch_isblank(*inp.s))
+	sc_add_char(inbuf_next());
 }
 
 struct parser_state backup_ps = ps;
@@ -1240,14 +1254,11 @@ read_preprocessing_line(void)
 	save_com = sc_buf;
 	sc_end = save_com;
 	} else {
-	*sc_end++ = '\n';	/* add newline between comments */
-	*sc_end++ = ' ';
+	sc_add_char('\n');	/* add newline between comments */
+	sc_add_char(' 

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

2021-10-30 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Oct 30 15:51:52 UTC 2021

Modified Files:
src/sys/arch/arm/include: signal.h

Log Message:
Define __HAVE_STRUCT_SIGCONTEXT regardless of its current visibility.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/include/signal.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/arm/include/signal.h
diff -u src/sys/arch/arm/include/signal.h:1.18 src/sys/arch/arm/include/signal.h:1.19
--- src/sys/arch/arm/include/signal.h:1.18	Wed Oct 27 01:09:36 2021
+++ src/sys/arch/arm/include/signal.h	Sat Oct 30 15:51:52 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: signal.h,v 1.18 2021/10/27 01:09:36 thorpej Exp $	*/
+/*	$NetBSD: signal.h,v 1.19 2021/10/30 15:51:52 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1994-1996 Mark Brinicombe.
@@ -49,6 +49,8 @@
 #include 
 #include 
 
+#define	__HAVE_STRUCT_SIGCONTEXT
+
 #ifndef _LOCORE
 typedef int sig_atomic_t;
 #endif
@@ -93,7 +95,6 @@ struct sigcontext13 {
 #endif /* _KERNEL */
 
 #if defined(_LIBC) || defined(_KERNEL)
-#define	__HAVE_STRUCT_SIGCONTEXT
 struct sigcontext {
 	int	sc_onstack;		/* sigstack state to restore */
 	int	__sc_mask13;		/* signal mask to restore (old style) */



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

2021-10-30 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Oct 30 15:51:52 UTC 2021

Modified Files:
src/sys/arch/arm/include: signal.h

Log Message:
Define __HAVE_STRUCT_SIGCONTEXT regardless of its current visibility.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/include/signal.h

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



CVS commit: src

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 15:26:58 UTC 2021

Modified Files:
src/tests/usr.bin/indent: t_errors.sh token_comment.c
src/usr.bin/indent: indent.c

Log Message:
indent: revert previous fix of assertion failure

The strange code with the out of bounds memory access is needed to
transform 'if (expr) /* comment */ {' to 'if (expr) { /* comment */',
that is, to move the comment to the right.

Add a test that prevents "repairing" this code again.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/tests/usr.bin/indent/t_errors.sh
cvs rdiff -u -r1.12 -r1.13 src/tests/usr.bin/indent/token_comment.c
cvs rdiff -u -r1.187 -r1.188 src/usr.bin/indent/indent.c

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

Modified files:

Index: src/tests/usr.bin/indent/t_errors.sh
diff -u src/tests/usr.bin/indent/t_errors.sh:1.14 src/tests/usr.bin/indent/t_errors.sh:1.15
--- src/tests/usr.bin/indent/t_errors.sh:1.14	Sat Oct 30 13:30:26 2021
+++ src/tests/usr.bin/indent/t_errors.sh	Sat Oct 30 15:26:58 2021
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: t_errors.sh,v 1.14 2021/10/30 13:30:26 rillig Exp $
+# $NetBSD: t_errors.sh,v 1.15 2021/10/30 15:26:58 rillig Exp $
 #
 # Copyright (c) 2021 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -411,7 +411,7 @@ unbalanced_parentheses_3_body()
 atf_test_case 'search_stmt_comment_segv'
 search_stmt_comment_segv_body()
 {
-	# Before NetBSD indent.c 1.187 from 2021-10-30, indent crashed while
+	# As of NetBSD indent.c 1.188 from 2021-10-30, indent crashes while
 	# trying to format the following artificial code.
 
 	printf '{if(expr\n)/*c*/;}\n' > code.c
@@ -423,7 +423,9 @@ search_stmt_comment_segv_body()
 		;
 }
 EOF
-	atf_check -o 'file:code.exp' \
+
+	# TODO: actually produce code.exp instead of an assertion failure.
+	atf_check -s 'signal' -o 'ignore' -e 'match:assert' \
 	"$indent" code.c -st
 }
 

Index: src/tests/usr.bin/indent/token_comment.c
diff -u src/tests/usr.bin/indent/token_comment.c:1.12 src/tests/usr.bin/indent/token_comment.c:1.13
--- src/tests/usr.bin/indent/token_comment.c:1.12	Sat Oct 30 13:06:43 2021
+++ src/tests/usr.bin/indent/token_comment.c	Sat Oct 30 15:26:58 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token_comment.c,v 1.12 2021/10/30 13:06:43 rillig Exp $ */
+/* $NetBSD: token_comment.c,v 1.13 2021/10/30 15:26:58 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -325,6 +325,25 @@ tab1+++	tab2---	tab3+++	tab4---	tab5+++	
 
 
 /*
+ * Ensure that '{' after a search_stmt_comment is preserved.
+ */
+#indent input
+{
+	if(0)/*comment*/{
+	}
+}
+#indent end
+
+/* The comment in the output has moved to the right of the '{'. */
+#indent run
+{
+	if (0) {		/* comment */
+	}
+}
+#indent end
+
+
+/*
  * The following comments test line breaking when the comment ends with a
  * space.
  */

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.187 src/usr.bin/indent/indent.c:1.188
--- src/usr.bin/indent/indent.c:1.187	Sat Oct 30 13:30:26 2021
+++ src/usr.bin/indent/indent.c	Sat Oct 30 15:26:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.187 2021/10/30 13:30:26 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.188 2021/10/30 15:26:58 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.187 2021/10/30 13:30:26 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.188 2021/10/30 15:26:58 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -189,10 +189,17 @@ search_stmt_comment(bool *comment_buffer
 	 * process_comment() will use that to calculate original indentation
 	 * of a boxed comment.
 	 */
-	size_t line_len = (size_t)(inp.s - inp.buf) - strlen("/*");
-	memcpy(sc_buf, inp.buf, line_len);
-	save_com = sc_buf + line_len;
-	sc_end = save_com;
+	/*
+	 * FIXME: This '4' needs an explanation. For example, in the snippet
+	 * 'if(expr)/''*comment', the 'r)' of the code is not copied. If there
+	 * is an additional line break before the ')', memcpy tries to copy
+	 * (size_t)-1 bytes.
+	 */
+	assert((size_t)(inp.s - inp.buf) >= 4);
+	memcpy(sc_buf, inp.buf, (size_t)(inp.s - inp.buf) - 4);
+	save_com = sc_buf + (inp.s - inp.buf - 4);
+	save_com[0] = save_com[1] = ' ';
+	sc_end = _com[2];
 }
 
 *comment_buffered = true;



CVS commit: src

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 15:26:58 UTC 2021

Modified Files:
src/tests/usr.bin/indent: t_errors.sh token_comment.c
src/usr.bin/indent: indent.c

Log Message:
indent: revert previous fix of assertion failure

The strange code with the out of bounds memory access is needed to
transform 'if (expr) /* comment */ {' to 'if (expr) { /* comment */',
that is, to move the comment to the right.

Add a test that prevents "repairing" this code again.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/tests/usr.bin/indent/t_errors.sh
cvs rdiff -u -r1.12 -r1.13 src/tests/usr.bin/indent/token_comment.c
cvs rdiff -u -r1.187 -r1.188 src/usr.bin/indent/indent.c

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



Re: CVS commit: src/sys/dev/sbus

2021-10-30 Thread Ryo Shimizu


>Module Name:   src
>Committed By:  macallan
>Date:  Sat Oct 30 05:37:39 UTC 2021
>
>Modified Files:
>   src/sys/dev/sbus: mgx.c mgxreg.h
>
>Log Message:
>actually mmap() the blitter registers when asked to, while there do some
>magic number reduction
>
>
>To generate a diff of this commit:
>cvs rdiff -u -r1.17 -r1.18 src/sys/dev/sbus/mgx.c
>cvs rdiff -u -r1.5 -r1.6 src/sys/dev/sbus/mgxreg.h

@@ -684,6 +684,8 @@
uint32_t fg, bg;
int x, y, wi, he, rv;
 
+if (sc->sc_mode != WSDISPLAYIO_MODE_EMUL) return;
+
wi = font->fontwidth;
he = font->fontheight;
 
@@ -731,6 +733,8 @@
uint32_t fg, bg, scratch = ((sc->sc_stride * sc->sc_height) + 7) & ~7;
int x, y, wi, he, len, i;
 
+if (sc->sc_mode != WSDISPLAYIO_MODE_EMUL) return;
+
wi = font->fontwidth;
he = font->fontheight;
 

This seems to be a strange indent.
Or debugging code mixed in?

-- 
ryo shimizu


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

2021-10-30 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Oct 30 14:05:40 UTC 2021

Modified Files:
src/sys/arch/mips/include: signal.h

Log Message:
Adjust the rules for sigcontext visibility on MIPS:
- Define __HAVE_STRUCT_SIGCONTEXT if _KERNEL (because it's needed for
  32-bit binary compatibility) or if the O32 ABI is active (because
  that's the only ABI that ever used sigcontext for signal delivery).
- For _KERNEL, define a "struct sigcontext" suitable only for 32-bit
  compatible signal delivery.
- For userspace, define a "struct sigcontext" appropriate for any ABI
  if _LIBC is defined (it's used for setjmp / longjmp) or if O32 is
  the active ABI (because it was part of the old BSD signal API).


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/mips/include/signal.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/mips/include/signal.h
diff -u src/sys/arch/mips/include/signal.h:1.32 src/sys/arch/mips/include/signal.h:1.33
--- src/sys/arch/mips/include/signal.h:1.32	Wed Oct 27 02:00:46 2021
+++ src/sys/arch/mips/include/signal.h	Sat Oct 30 14:05:40 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: signal.h,v 1.32 2021/10/27 02:00:46 thorpej Exp $	*/
+/*	$NetBSD: signal.h,v 1.33 2021/10/30 14:05:40 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -78,8 +78,12 @@ struct sigcontext13 {
 };
 #endif /* _KERNEL && COMPAT_13 */
 
-#if defined(_LIBC) || (defined(_KERNEL) && (defined(COMPAT_16) || defined(COMPAT_ULTRIX)))
+#if defined(_KERNEL) || defined(__mips_o32)
 #define	__HAVE_STRUCT_SIGCONTEXT
+#endif
+
+#if defined(_NETBSD_SOURCE)
+#include 
 /*
  * Only need an O32 version.
  */
@@ -98,19 +102,17 @@ struct sigcontext { \
 }
 
 /*
- * These will be identical in O32
- */
-#ifdef _KERNEL
-/*
- * We need this only compatibility.
+ * The only binaries that used sigcontext used the O32 ABI.  The kernel
+ * needs this for 32-bit compatibility, and O32 ABI user-space needs this
+ * natively.
  */
+#if defined(_KERNEL)
 _SIGCONTEXT_DEFINE(sigcontext, int, int);
-#endif
-#ifdef _LIBC
+#elif defined(__mips_o32) || defined(_LIBC)
 _SIGCONTEXT_DEFINE(sigcontext, __register_t, __fpregister_t);
 #endif
 
-#endif /* _LIBC || _KERNEL */
+#endif /* _NETBSD_SOURCE */
 
 #endif	/* !_LANGUAGE_ASSEMBLY */
 #endif	/* !_MIPS_SIGNAL_H_ */



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

2021-10-30 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Oct 30 14:05:40 UTC 2021

Modified Files:
src/sys/arch/mips/include: signal.h

Log Message:
Adjust the rules for sigcontext visibility on MIPS:
- Define __HAVE_STRUCT_SIGCONTEXT if _KERNEL (because it's needed for
  32-bit binary compatibility) or if the O32 ABI is active (because
  that's the only ABI that ever used sigcontext for signal delivery).
- For _KERNEL, define a "struct sigcontext" suitable only for 32-bit
  compatible signal delivery.
- For userspace, define a "struct sigcontext" appropriate for any ABI
  if _LIBC is defined (it's used for setjmp / longjmp) or if O32 is
  the active ABI (because it was part of the old BSD signal API).


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/mips/include/signal.h

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



CVS commit: src/tests/sbin/resize_ffs

2021-10-30 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Sat Oct 30 13:50:12 UTC 2021

Modified Files:
src/tests/sbin/resize_ffs: common.sh

Log Message:
Delete trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/tests/sbin/resize_ffs/common.sh

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

Modified files:

Index: src/tests/sbin/resize_ffs/common.sh
diff -u src/tests/sbin/resize_ffs/common.sh:1.17 src/tests/sbin/resize_ffs/common.sh:1.18
--- src/tests/sbin/resize_ffs/common.sh:1.17	Sun Mar 15 11:17:59 2020
+++ src/tests/sbin/resize_ffs/common.sh	Sat Oct 30 13:50:12 2021
@@ -1,6 +1,6 @@
 
 # Common settings and functions for the various resize_ffs tests.
-# 
+#
 
 # called from atf_init_test_cases
 setupvars()



CVS commit: src/tests/sbin/resize_ffs

2021-10-30 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Sat Oct 30 13:50:12 UTC 2021

Modified Files:
src/tests/sbin/resize_ffs: common.sh

Log Message:
Delete trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/tests/sbin/resize_ffs/common.sh

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



CVS commit: src/usr.bin/telnet

2021-10-30 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Oct 30 13:43:40 UTC 2021

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

Log Message:
Obvious typo ':' -> ';'.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/usr.bin/telnet/telnet.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/telnet/telnet.c
diff -u src/usr.bin/telnet/telnet.c:1.43 src/usr.bin/telnet/telnet.c:1.44
--- src/usr.bin/telnet/telnet.c:1.43	Sat Oct 30 11:37:18 2021
+++ src/usr.bin/telnet/telnet.c	Sat Oct 30 13:43:40 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: telnet.c,v 1.43 2021/10/30 11:37:18 nia Exp $	*/
+/*	$NetBSD: telnet.c,v 1.44 2021/10/30 13:43:40 hannken Exp $	*/
 
 /*
  * Copyright (c) 1988, 1990, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)telnet.c	8.4 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: telnet.c,v 1.43 2021/10/30 11:37:18 nia Exp $");
+__RCSID("$NetBSD: telnet.c,v 1.44 2021/10/30 13:43:40 hannken Exp $");
 #endif
 #endif /* not lint */
 
@@ -578,7 +578,7 @@ mklist(char *buf, char *name)
 	/*
 	 * Allocate an array to put the name pointers into
 	 */
-	argv = NULL:
+	argv = NULL;
 	if (reallocarr(, n + 3, sizeof(char *)) != 0)
 		return(unknown);
 



CVS commit: src/usr.bin/telnet

2021-10-30 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Oct 30 13:43:40 UTC 2021

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

Log Message:
Obvious typo ':' -> ';'.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/usr.bin/telnet/telnet.c

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



CVS commit: src

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 13:30:26 UTC 2021

Modified Files:
src/tests/usr.bin/indent: t_errors.sh
src/usr.bin/indent: indent.c

Log Message:
indent: fix assertion failure in search_stmt_comment

I have no idea why the code was written in such a convoluted way before.
By removing all the code that didn't make sense, everything just works
as expected, and the existing tests all pass, especially those in
token_comment.c that mention search_stmt_comment.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/tests/usr.bin/indent/t_errors.sh
cvs rdiff -u -r1.186 -r1.187 src/usr.bin/indent/indent.c

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

Modified files:

Index: src/tests/usr.bin/indent/t_errors.sh
diff -u src/tests/usr.bin/indent/t_errors.sh:1.13 src/tests/usr.bin/indent/t_errors.sh:1.14
--- src/tests/usr.bin/indent/t_errors.sh:1.13	Fri Oct 29 20:05:58 2021
+++ src/tests/usr.bin/indent/t_errors.sh	Sat Oct 30 13:30:26 2021
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: t_errors.sh,v 1.13 2021/10/29 20:05:58 rillig Exp $
+# $NetBSD: t_errors.sh,v 1.14 2021/10/30 13:30:26 rillig Exp $
 #
 # Copyright (c) 2021 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -411,9 +411,19 @@ unbalanced_parentheses_3_body()
 atf_test_case 'search_stmt_comment_segv'
 search_stmt_comment_segv_body()
 {
+	# Before NetBSD indent.c 1.187 from 2021-10-30, indent crashed while
+	# trying to format the following artificial code.
+
 	printf '{if(expr\n)/*c*/;}\n' > code.c
 
-	atf_check -s 'signal' -o 'ignore' -e 'match:assert' \
+	cat <<\EOF > code.exp
+{
+	if (expr
+		)		/* c */
+		;
+}
+EOF
+	atf_check -o 'file:code.exp' \
 	"$indent" code.c -st
 }
 

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.186 src/usr.bin/indent/indent.c:1.187
--- src/usr.bin/indent/indent.c:1.186	Sat Oct 30 11:37:38 2021
+++ src/usr.bin/indent/indent.c	Sat Oct 30 13:30:26 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.186 2021/10/30 11:37:38 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.187 2021/10/30 13:30:26 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.186 2021/10/30 11:37:38 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.187 2021/10/30 13:30:26 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -189,17 +189,10 @@ search_stmt_comment(bool *comment_buffer
 	 * process_comment() will use that to calculate original indentation
 	 * of a boxed comment.
 	 */
-	/*
-	 * FIXME: This '4' needs an explanation. For example, in the snippet
-	 * 'if(expr)/''*comment', the 'r)' of the code is not copied. If there
-	 * is an additional line break before the ')', memcpy tries to copy
-	 * (size_t)-1 bytes.
-	 */
-	assert((size_t)(inp.s - inp.buf) >= 4);
-	memcpy(sc_buf, inp.buf, (size_t)(inp.s - inp.buf) - 4);
-	save_com = sc_buf + (inp.s - inp.buf - 4);
-	save_com[0] = save_com[1] = ' ';
-	sc_end = _com[2];
+	size_t line_len = (size_t)(inp.s - inp.buf) - strlen("/*");
+	memcpy(sc_buf, inp.buf, line_len);
+	save_com = sc_buf + line_len;
+	sc_end = save_com;
 }
 
 *comment_buffered = true;



CVS commit: src

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 13:30:26 UTC 2021

Modified Files:
src/tests/usr.bin/indent: t_errors.sh
src/usr.bin/indent: indent.c

Log Message:
indent: fix assertion failure in search_stmt_comment

I have no idea why the code was written in such a convoluted way before.
By removing all the code that didn't make sense, everything just works
as expected, and the existing tests all pass, especially those in
token_comment.c that mention search_stmt_comment.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/tests/usr.bin/indent/t_errors.sh
cvs rdiff -u -r1.186 -r1.187 src/usr.bin/indent/indent.c

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



CVS commit: src/tests/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 13:06:43 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token_comment.c

Log Message:
tests/indent: add more tests for the assertion in search_stmt_comment


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/tests/usr.bin/indent/token_comment.c

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



CVS commit: src/tests/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 13:06:43 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token_comment.c

Log Message:
tests/indent: add more tests for the assertion in search_stmt_comment


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/tests/usr.bin/indent/token_comment.c

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

Modified files:

Index: src/tests/usr.bin/indent/token_comment.c
diff -u src/tests/usr.bin/indent/token_comment.c:1.11 src/tests/usr.bin/indent/token_comment.c:1.12
--- src/tests/usr.bin/indent/token_comment.c:1.11	Sat Oct 30 12:28:42 2021
+++ src/tests/usr.bin/indent/token_comment.c	Sat Oct 30 13:06:43 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token_comment.c,v 1.11 2021/10/30 12:28:42 rillig Exp $ */
+/* $NetBSD: token_comment.c,v 1.12 2021/10/30 13:06:43 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -134,9 +134,44 @@ t(void)
  *
  * The other Christmas tree is a standalone block comment, therefore the
  * comment starts in the code column.
+ *
+ * Since the comments occur between psym_if_expr and the following statement,
+ * they are handled by search_stmt_comment.
+ */
+#indent input
+{
+	if (1) /*- a Christmas tree  *  search_stmt_comment
+***
+   * */
+		/*- another one *  search_stmt_comment
+   ***
+  * */
+		1;
+}
+#indent end
+
+#indent run -bbb
+{
+	if (1)			/*- a Christmas tree  *  search_stmt_comment
+		 ***
+		* */
+		/*- another one *  search_stmt_comment
+			   ***
+			  * */
+		1;
+}
+#indent end
+
+
+/*
+ * The first Christmas tree is to the right of the code, therefore the comment
+ * is moved to the code comment column; the follow-up lines of that comment
+ * are moved by the same distance, to preserve the internal layout.
+ *
+ * The other Christmas tree is a standalone block comment, therefore the
+ * comment starts in the code column.
  */
 #indent input
-int c(void)
 {
 	if (7) { /*- a Christmas tree  *
   ***
@@ -144,22 +179,12 @@ int c(void)
 		/*- another one *
    ***
   * */
-		7;
+		stmt();
 	}
-
-	if (1) /*- a Christmas tree  *
-***
-   * */
-		/*- another one *
-   ***
-  * */
-		1;
 }
 #indent end
 
 #indent run -bbb
-int
-c(void)
 {
 	if (7) {		/*- a Christmas tree  *
 	 ***
@@ -167,16 +192,8 @@ c(void)
 		/*- another one *
 			   ***
 			  * */
-		7;
+		stmt();
 	}
-
-	if (1)			/*- a Christmas tree  *
-		 ***
-		* */
-		/*- another one *
-			   ***
-			  * */
-		1;
 }
 #indent end
 
@@ -196,6 +213,23 @@ int decl;			/*-fixed comment
  */
 
 
+#indent input
+{
+	if (0)/*-search_stmt_comment   |
+	   search_stmt_comment |*/
+		;
+}
+#indent end
+
+#indent run -di0
+{
+	if (0)			/*-search_stmt_comment   |
+			 search_stmt_comment |*/
+		;
+}
+#indent end
+
+
 /*
  * Ensure that all text of the comment is preserved when the comment is moved
  * to the right.
@@ -213,6 +247,29 @@ int decl;			/*-fixed comment
 
 /*
  * Ensure that all text of the comment is preserved when the comment is moved
+ * to the right.
+ *
+ * This comment is handled by search_stmt_comment.
+ */
+#indent input
+{
+	if(0)/*-search_stmt_comment
+123456789ab search_stmt_comment   |*/
+	;
+}
+#indent end
+
+#indent run -di0
+{
+	if (0)			/*-search_stmt_comment
+		   123456789ab search_stmt_comment   |*/
+		;
+}
+#indent end
+
+
+/*
+ * Ensure that all text of the comment is preserved when the comment is moved
  * to the left. In this case, the internal layout of the comment cannot be
  * preserved since the second line already starts in column 1.
  */
@@ -236,6 +293,38 @@ tab1+++	tab2---	tab3+++	tab4---	tab5+++	
 
 
 /*
+ * Ensure that all text of the comment is preserved when the comment is moved
+ * to the left. In this case, the internal layout of the comment cannot be
+ * preserved since the second line already starts in column 1.
+ *
+ * This comment is processed by search_stmt_comment.
+ */
+#indent input
+{
+	if(0)	/*-|search_stmt_comment
+	| minus 12 |
+		| tabs inside		|
+	|---|
+|---|
+tab1+++	tab2---	tab3+++	tab4---	tab5+++	tab6---	tab7+++fixed comment*/
+		;
+}
+#indent end
+
+#indent run -di0
+{
+	if (0)			/*-|search_stmt_comment
+		| minus 12 |
+| tabs inside		|
+|---|
+|---|
+tab1+++	tab2---	tab3+++	tab4---	tab5+++	tab6---	tab7+++fixed comment*/
+		;
+}
+#indent end
+
+
+/*
  * The following comments test line breaking when the comment ends with a
  * space.
  */



CVS commit: src/tests/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 12:28:42 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token_comment.c

Log Message:
tests/indent: test preserving the internal layout of box comments


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/tests/usr.bin/indent/token_comment.c

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

Modified files:

Index: src/tests/usr.bin/indent/token_comment.c
diff -u src/tests/usr.bin/indent/token_comment.c:1.10 src/tests/usr.bin/indent/token_comment.c:1.11
--- src/tests/usr.bin/indent/token_comment.c:1.10	Sat Oct 30 12:24:03 2021
+++ src/tests/usr.bin/indent/token_comment.c	Sat Oct 30 12:28:42 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token_comment.c,v 1.10 2021/10/30 12:24:03 rillig Exp $ */
+/* $NetBSD: token_comment.c,v 1.11 2021/10/30 12:28:42 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -217,12 +217,20 @@ int decl;			/*-fixed comment
  * preserved since the second line already starts in column 1.
  */
 #indent input
-int decl;	/*-fixed comment
+int decl;	/*-|fixed comment
+	| minus 12 |
+		| tabs inside		|
+	|---|
+|---|
 tab1+++	tab2---	tab3+++	tab4---	tab5+++	tab6---	tab7+++fixed comment*/
 #indent end
 
 #indent run -di0
-int decl;			/*-fixed comment
+int decl;			/*-|fixed comment
+		| minus 12 |
+| tabs inside		|
+|---|
+|---|
 tab1+++	tab2---	tab3+++	tab4---	tab5+++	tab6---	tab7+++fixed comment*/
 #indent end
 



CVS commit: src/tests/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 12:28:42 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token_comment.c

Log Message:
tests/indent: test preserving the internal layout of box comments


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/tests/usr.bin/indent/token_comment.c

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



CVS commit: src/tests/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 12:24:03 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token_comment.c

Log Message:
tests/lint: explain and extend the tests for box comments

These tests are in preparation of removing the magic number 4 from
search_stmt_comment.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/indent/token_comment.c

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

Modified files:

Index: src/tests/usr.bin/indent/token_comment.c
diff -u src/tests/usr.bin/indent/token_comment.c:1.9 src/tests/usr.bin/indent/token_comment.c:1.10
--- src/tests/usr.bin/indent/token_comment.c:1.9	Fri Oct 29 17:50:37 2021
+++ src/tests/usr.bin/indent/token_comment.c	Sat Oct 30 12:24:03 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token_comment.c,v 1.9 2021/10/29 17:50:37 rillig Exp $ */
+/* $NetBSD: token_comment.c,v 1.10 2021/10/30 12:24:03 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -126,25 +126,34 @@ t(void)
 }
 #indent end
 
+
+/*
+ * The first Christmas tree is to the right of the code, therefore the comment
+ * is moved to the code comment column; the follow-up lines of that comment
+ * are moved by the same distance, to preserve the internal layout.
+ *
+ * The other Christmas tree is a standalone block comment, therefore the
+ * comment starts in the code column.
+ */
 #indent input
 int c(void)
 {
-	if (1) { /*- a christmas tree  *
+	if (7) { /*- a Christmas tree  *
   ***
  * */
 		/*- another one *
    ***
   * */
-	7;
+		7;
 	}
 
-	if (1) /*- a christmas tree  *
+	if (1) /*- a Christmas tree  *
 ***
    * */
 		/*- another one *
    ***
   * */
-	1;
+		1;
 }
 #indent end
 
@@ -152,7 +161,7 @@ int c(void)
 int
 c(void)
 {
-	if (1) {		/*- a christmas tree  *
+	if (7) {		/*- a Christmas tree  *
 	 ***
 	* */
 		/*- another one *
@@ -161,7 +170,7 @@ c(void)
 		7;
 	}
 
-	if (1)			/*- a christmas tree  *
+	if (1)			/*- a Christmas tree  *
 		 ***
 		* */
 		/*- another one *
@@ -171,6 +180,53 @@ c(void)
 }
 #indent end
 
+
+#indent input
+int decl;/*-fixed comment
+	fixed comment*/
+#indent end
+
+#indent run -di0
+int decl;			/*-fixed comment
+			   fixed comment*/
+#indent end
+/*
+ * XXX: The second line of the above comment contains 11 spaces in a row,
+ * instead of using as many tabs as possible.
+ */
+
+
+/*
+ * Ensure that all text of the comment is preserved when the comment is moved
+ * to the right.
+ */
+#indent input
+int decl;/*-fixed comment
+123456789ab fixed comment*/
+#indent end
+
+#indent run -di0
+int decl;			/*-fixed comment
+		   123456789ab fixed comment*/
+#indent end
+
+
+/*
+ * Ensure that all text of the comment is preserved when the comment is moved
+ * to the left. In this case, the internal layout of the comment cannot be
+ * preserved since the second line already starts in column 1.
+ */
+#indent input
+int decl;	/*-fixed comment
+tab1+++	tab2---	tab3+++	tab4---	tab5+++	tab6---	tab7+++fixed comment*/
+#indent end
+
+#indent run -di0
+int decl;			/*-fixed comment
+tab1+++	tab2---	tab3+++	tab4---	tab5+++	tab6---	tab7+++fixed comment*/
+#indent end
+
+
 /*
  * The following comments test line breaking when the comment ends with a
  * space.



CVS commit: src/tests/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 12:24:03 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token_comment.c

Log Message:
tests/lint: explain and extend the tests for box comments

These tests are in preparation of removing the magic number 4 from
search_stmt_comment.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/indent/token_comment.c

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



CVS commit: src/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 11:49:38 UTC 2021

Modified Files:
src/usr.bin/indent: indent.h io.c

Log Message:
indent: inline macro label_offset

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.107 -r1.108 src/usr.bin/indent/io.c

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



CVS commit: src/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 11:49:38 UTC 2021

Modified Files:
src/usr.bin/indent: indent.h io.c

Log Message:
indent: inline macro label_offset

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.107 -r1.108 src/usr.bin/indent/io.c

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

Modified files:

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.63 src/usr.bin/indent/indent.h:1.64
--- src/usr.bin/indent/indent.h:1.63	Fri Oct 29 21:56:36 2021
+++ src/usr.bin/indent/indent.h	Sat Oct 30 11:49:38 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.63 2021/10/29 21:56:36 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.64 2021/10/30 11:49:38 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -131,8 +131,6 @@ typedef enum stmt_head {
 } stmt_head;
 
 #define sc_size 5000		/* size of save_com buffer */
-#define label_offset 2		/* number of levels a label is placed to left
- * of code */
 
 
 /* A range of characters, in some cases null-terminated. */

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.107 src/usr.bin/indent/io.c:1.108
--- src/usr.bin/indent/io.c:1.107	Fri Oct 29 20:27:42 2021
+++ src/usr.bin/indent/io.c	Sat Oct 30 11:49:38 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.107 2021/10/29 20:27:42 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.108 2021/10/30 11:49:38 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)io.c	8.1 (Be
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.107 2021/10/29 20:27:42 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.108 2021/10/30 11:49:38 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -340,7 +340,7 @@ compute_label_indent(void)
 	return (int)(case_ind * (float)opt.indent_size);
 if (lab.s[0] == '#')
 	return 0;
-return opt.indent_size * (ps.ind_level - label_offset);
+return opt.indent_size * (ps.ind_level - 2);
 }
 
 static void



Re: CVS commit: src/usr.sbin/rpcbind

2021-10-30 Thread nia
On Sat, Oct 30, 2021 at 08:25:42PM +0900, Rin Okuyama wrote:
> We should not break from infinite loop here, even if svc_fdset_getmax()
> fails. Please restore the old behavior. And please be more careful before
> making such a non-trivial change.

Ah, thank you. I incorrectly assumed that "out" must be a label
at the end of a block. I've restored the behaviour and renamed
the label to "wait".


CVS commit: src/sys/dev/ic

2021-10-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 30 11:43:17 UTC 2021

Modified Files:
src/sys/dev/ic: com.c

Log Message:
For the DW APB busy bit workaround, only attempt to re-apply LCR and DLB
settings for non-console devices. In the console case, simply clear the
busy bit and continue. Fixes an interrupt storm observed on Macchiatobin.


To generate a diff of this commit:
cvs rdiff -u -r1.371 -r1.372 src/sys/dev/ic/com.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/ic/com.c
diff -u src/sys/dev/ic/com.c:1.371 src/sys/dev/ic/com.c:1.372
--- src/sys/dev/ic/com.c:1.371	Thu Oct 21 10:22:54 2021
+++ src/sys/dev/ic/com.c	Sat Oct 30 11:43:17 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: com.c,v 1.371 2021/10/21 10:22:54 jmcneill Exp $ */
+/* $NetBSD: com.c,v 1.372 2021/10/30 11:43:17 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2004, 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.371 2021/10/21 10:22:54 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.372 2021/10/30 11:43:17 jmcneill Exp $");
 
 #include "opt_com.h"
 #include "opt_ddb.h"
@@ -2147,7 +2147,9 @@ comintr(void *arg)
 	/* DesignWare APB UART BUSY interrupt */
 	if (sc->sc_type == COM_TYPE_DW_APB &&
 	(iir & IIR_BUSY) == IIR_BUSY) {
-		if ((CSR_READ_1(regsp, COM_REG_USR) & 0x1) != 0) {
+		if (ISSET(sc->sc_hwflags, COM_HW_CONSOLE)) {
+			(void)CSR_READ_1(regsp, COM_REG_USR);
+		} else if ((CSR_READ_1(regsp, COM_REG_USR) & 0x1) != 0) {
 			CSR_WRITE_1(regsp, COM_REG_HALT, HALT_CHCFG_EN);
 			CSR_WRITE_1(regsp, COM_REG_LCR, sc->sc_lcr | LCR_DLAB);
 			CSR_WRITE_1(regsp, COM_REG_DLBL, sc->sc_dlbl);



CVS commit: src/sys/dev/ic

2021-10-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 30 11:43:17 UTC 2021

Modified Files:
src/sys/dev/ic: com.c

Log Message:
For the DW APB busy bit workaround, only attempt to re-apply LCR and DLB
settings for non-console devices. In the console case, simply clear the
busy bit and continue. Fixes an interrupt storm observed on Macchiatobin.


To generate a diff of this commit:
cvs rdiff -u -r1.371 -r1.372 src/sys/dev/ic/com.c

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



CVS commit: src/tests/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 11:41:49 UTC 2021

Modified Files:
src/tests/usr.bin/indent: fmt_decl.c

Log Message:
tests/indent: document why declaration lines are broken unnecessarily


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/indent/fmt_decl.c

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

Modified files:

Index: src/tests/usr.bin/indent/fmt_decl.c
diff -u src/tests/usr.bin/indent/fmt_decl.c:1.6 src/tests/usr.bin/indent/fmt_decl.c:1.7
--- src/tests/usr.bin/indent/fmt_decl.c:1.6	Wed Oct 27 00:04:51 2021
+++ src/tests/usr.bin/indent/fmt_decl.c	Sat Oct 30 11:41:49 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: fmt_decl.c,v 1.6 2021/10/27 00:04:51 rillig Exp $	*/
+/*	$NetBSD: fmt_decl.c,v 1.7 2021/10/30 11:41:49 rillig Exp $	*/
 /* $FreeBSD: head/usr.bin/indent/tests/declarations.0 334478 2018-06-01 09:41:15Z pstef $ */
 
 /* See FreeBSD r303570 */
@@ -235,6 +235,7 @@ old_style_definition(a, b, c)
  * the line length limit is set quite low.
  */
 #indent input
+struct s a,b;
 struct s0 a,b;
 struct s01 a,b;
 struct s012 a,b;
@@ -252,9 +253,13 @@ struct s01234567890123 a,b;
 #indent end
 
 #indent run -l20 -di0
-/* $ XXX: Why is this declaration broken? There's plenty of space left. */
+struct s a, b;
+/* $ XXX: See process_comma, varname_len for why this line is broken. */
 struct s0 a,
b;
+/* $ XXX: The indentation of the second line is wrong. The variable names */
+/* $ XXX: 'a' and 'b' should be in the same column; the word 'struct' is */
+/* $ XXX: missing in the calculation for the indentation. */
 struct s01 a,
 b;
 struct s012 a,



CVS commit: src/tests/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 11:41:49 UTC 2021

Modified Files:
src/tests/usr.bin/indent: fmt_decl.c

Log Message:
tests/indent: document why declaration lines are broken unnecessarily


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/indent/fmt_decl.c

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



CVS commit: src/usr.sbin/rpcbind

2021-10-30 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sat Oct 30 11:41:45 UTC 2021

Modified Files:
src/usr.sbin/rpcbind: rpcb_svc_com.c

Log Message:
rpcbind(8): restore previous behaviour. Wait instead of breaking from
the loop if svc_fdset_getmax fails.

thanks rin.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/usr.sbin/rpcbind/rpcb_svc_com.c

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

Modified files:

Index: src/usr.sbin/rpcbind/rpcb_svc_com.c
diff -u src/usr.sbin/rpcbind/rpcb_svc_com.c:1.26 src/usr.sbin/rpcbind/rpcb_svc_com.c:1.27
--- src/usr.sbin/rpcbind/rpcb_svc_com.c:1.26	Sat Oct 30 11:04:48 2021
+++ src/usr.sbin/rpcbind/rpcb_svc_com.c	Sat Oct 30 11:41:45 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: rpcb_svc_com.c,v 1.26 2021/10/30 11:04:48 nia Exp $	*/
+/*	$NetBSD: rpcb_svc_com.c,v 1.27 2021/10/30 11:41:45 nia Exp $	*/
 /*	$FreeBSD: head/usr.sbin/rpcbind/rpcb_svc_com.c 301770 2016-06-09 22:25:00Z pfg $ */
 
 /*-
@@ -1122,6 +1122,7 @@ my_svc_run(void)
 		if (newfdcount != npollfds) {
 			if (reallocarr(,
 			newfdcount, sizeof(*pollfds)) != 0) {
+wait:
 syslog(LOG_ERR, "Cannot allocate pollfds");
 sleep(1);
 continue;
@@ -1130,7 +1131,7 @@ my_svc_run(void)
 		}
 		p = pollfds;
 		if ((m = svc_fdset_getmax()) == NULL)
-			break;
+			goto wait;
 		for (n = 0; n <= *m; n++) {
 			if (svc_fdset_isset(n)) {
 p->fd = n;



CVS commit: src/usr.sbin/rpcbind

2021-10-30 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sat Oct 30 11:41:45 UTC 2021

Modified Files:
src/usr.sbin/rpcbind: rpcb_svc_com.c

Log Message:
rpcbind(8): restore previous behaviour. Wait instead of breaking from
the loop if svc_fdset_getmax fails.

thanks rin.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/usr.sbin/rpcbind/rpcb_svc_com.c

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



CVS commit: src/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 11:37:38 UTC 2021

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

Log Message:
indent: replace tabsize with hardcoded 8 in process_comma

On 2018-07-25, FreeBSD added the option '-ts' to make the tabulator size
configurable, replacing several constants 7, 8, 9 with tabsize. The 8 in
the expression 'max_col - 8' was not related to the tabulator size but
instead represents the typical width of a variable name. Subtracting a
tab from the right margin doesn't make sense since the right margin need
not be aligned on a tabstop.

See the test fmt_decl.c, where the declaration 'struct s0 a,b;' is split
into several lines because the estimate for the variable name following
the comma is too high. There would have been plenty of space to the
right to keep the whole declaration in a single line.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.185 -r1.186 src/usr.bin/indent/indent.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/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.185 src/usr.bin/indent/indent.c:1.186
--- src/usr.bin/indent/indent.c:1.185	Sat Oct 30 11:10:36 2021
+++ src/usr.bin/indent/indent.c	Sat Oct 30 11:37:38 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.185 2021/10/30 11:10:36 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.186 2021/10/30 11:37:38 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.185 2021/10/30 11:10:36 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.186 2021/10/30 11:37:38 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -1169,9 +1169,11 @@ process_comma(int decl_ind, bool tabs_to
 if (ps.p_l_follow == 0) {
 	if (ps.block_init_level <= 0)
 	ps.block_init = false;
+	int varname_len = 8;	/* rough estimate for the length of a typical
+ * variable name */
 	if (break_comma && (opt.break_after_comma ||
 		indentation_after_range(compute_code_indent(), code.s, code.e)
-		>= opt.max_line_length - opt.tabsize))
+		>= opt.max_line_length - varname_len))
 	*force_nl = true;
 }
 }



CVS commit: src/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 11:37:38 UTC 2021

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

Log Message:
indent: replace tabsize with hardcoded 8 in process_comma

On 2018-07-25, FreeBSD added the option '-ts' to make the tabulator size
configurable, replacing several constants 7, 8, 9 with tabsize. The 8 in
the expression 'max_col - 8' was not related to the tabulator size but
instead represents the typical width of a variable name. Subtracting a
tab from the right margin doesn't make sense since the right margin need
not be aligned on a tabstop.

See the test fmt_decl.c, where the declaration 'struct s0 a,b;' is split
into several lines because the estimate for the variable name following
the comma is too high. There would have been plenty of space to the
right to keep the whole declaration in a single line.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.185 -r1.186 src/usr.bin/indent/indent.c

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



CVS commit: src/usr.bin/telnet

2021-10-30 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sat Oct 30 11:37:18 UTC 2021

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

Log Message:
telnet(1): use reallocarr instead of malloc(x * y)


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/usr.bin/telnet/telnet.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/telnet/telnet.c
diff -u src/usr.bin/telnet/telnet.c:1.42 src/usr.bin/telnet/telnet.c:1.43
--- src/usr.bin/telnet/telnet.c:1.42	Sat Jan  5 06:47:24 2019
+++ src/usr.bin/telnet/telnet.c	Sat Oct 30 11:37:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: telnet.c,v 1.42 2019/01/05 06:47:24 maya Exp $	*/
+/*	$NetBSD: telnet.c,v 1.43 2021/10/30 11:37:18 nia Exp $	*/
 
 /*
  * Copyright (c) 1988, 1990, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)telnet.c	8.4 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: telnet.c,v 1.42 2019/01/05 06:47:24 maya Exp $");
+__RCSID("$NetBSD: telnet.c,v 1.43 2021/10/30 11:37:18 nia Exp $");
 #endif
 #endif /* not lint */
 
@@ -578,8 +578,8 @@ mklist(char *buf, char *name)
 	/*
 	 * Allocate an array to put the name pointers into
 	 */
-	argv = (char **)malloc((n+3)*sizeof(char *));
-	if (argv == 0)
+	argv = NULL:
+	if (reallocarr(, n + 3, sizeof(char *)) != 0)
 		return(unknown);
 
 	/*



CVS commit: src/usr.bin/telnet

2021-10-30 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sat Oct 30 11:37:18 UTC 2021

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

Log Message:
telnet(1): use reallocarr instead of malloc(x * y)


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/usr.bin/telnet/telnet.c

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



CVS commit: src/lib/libpam/modules/pam_exec

2021-10-30 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sat Oct 30 11:34:59 UTC 2021

Modified Files:
src/lib/libpam/modules/pam_exec: pam_exec.c

Log Message:
pam_exec: Convert realloc(x * y) to reallocarr.

Eliminate a now-redundant temporary variable.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libpam/modules/pam_exec/pam_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/lib/libpam/modules/pam_exec/pam_exec.c
diff -u src/lib/libpam/modules/pam_exec/pam_exec.c:1.7 src/lib/libpam/modules/pam_exec/pam_exec.c:1.8
--- src/lib/libpam/modules/pam_exec/pam_exec.c:1.7	Sun Dec 29 22:54:58 2013
+++ src/lib/libpam/modules/pam_exec/pam_exec.c	Sat Oct 30 11:34:59 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pam_exec.c,v 1.7 2013/12/29 22:54:58 christos Exp $	*/
+/*	$NetBSD: pam_exec.c,v 1.8 2021/10/30 11:34:59 nia Exp $	*/
 
 /*-
  * Copyright (c) 2001,2003 Networks Associates Technology, Inc.
@@ -38,7 +38,7 @@
 #ifdef __FreeBSD__
 __FBSDID("$FreeBSD: src/lib/libpam/modules/pam_exec/pam_exec.c,v 1.4 2005/02/01 10:37:07 des Exp $");
 #else
-__RCSID("$NetBSD: pam_exec.c,v 1.7 2013/12/29 22:54:58 christos Exp $");
+__RCSID("$NetBSD: pam_exec.c,v 1.8 2021/10/30 11:34:59 nia Exp $");
 #endif
 
 #include 
@@ -72,7 +72,7 @@ _pam_exec(pam_handle_t *pamh __unused, i
 {
 	size_t envlen, i, nitems;
 	int pam_err, status;
-	char **envlist, **tmp;
+	char **envlist;
 	volatile int childerr;
 	pid_t pid;
 
@@ -92,12 +92,10 @@ _pam_exec(pam_handle_t *pamh __unused, i
 	for (envlen = 0; envlist[envlen] != NULL; ++envlen)
 		/* nothing */ ;
 	nitems = sizeof(env_items) / sizeof(*env_items);
-	tmp = realloc(envlist, (envlen + nitems + 1) * sizeof(*envlist));
-	if (tmp == NULL) {
+	if (reallocarr(, envlen + nitems + 1, sizeof(*envlist)) != 0) {
 		openpam_free_envlist(envlist);
 		return (PAM_BUF_ERR);
 	}
-	envlist = tmp;
 	for (i = 0; i < nitems; ++i) {
 		const void *item;
 		char *envstr;



CVS commit: src/lib/libpam/modules/pam_exec

2021-10-30 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sat Oct 30 11:34:59 UTC 2021

Modified Files:
src/lib/libpam/modules/pam_exec: pam_exec.c

Log Message:
pam_exec: Convert realloc(x * y) to reallocarr.

Eliminate a now-redundant temporary variable.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libpam/modules/pam_exec/pam_exec.c

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



CVS commit: src/usr.bin/systat

2021-10-30 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sat Oct 30 11:31:51 UTC 2021

Modified Files:
src/usr.bin/systat: netcmds.c

Log Message:
netstat(1): use reallocarr instead of realloc(x * y)


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/systat/netcmds.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/systat/netcmds.c
diff -u src/usr.bin/systat/netcmds.c:1.21 src/usr.bin/systat/netcmds.c:1.22
--- src/usr.bin/systat/netcmds.c:1.21	Sat Feb 26 22:12:33 2005
+++ src/usr.bin/systat/netcmds.c	Sat Oct 30 11:31:51 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: netcmds.c,v 1.21 2005/02/26 22:12:33 dsl Exp $	*/
+/*	$NetBSD: netcmds.c,v 1.22 2021/10/30 11:31:51 nia Exp $	*/
 
 /*-
  * Copyright (c) 1980, 1992, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)netcmds.c	8.1 (Berkeley) 6/6/93";
 #endif
-__RCSID("$NetBSD: netcmds.c,v 1.21 2005/02/26 22:12:33 dsl Exp $");
+__RCSID("$NetBSD: netcmds.c,v 1.22 2021/10/30 11:31:51 nia Exp $");
 #endif /* not lint */
 
 /*
@@ -223,12 +223,10 @@ selectport(long port, int onoff)
 			p->onoff = onoff;
 			return (0);
 		}
-	p = (struct pitem *)realloc(ports, (nports+1)*sizeof (*p));
-	if (p == NULL) {
+	if (reallocarr(, nports + 1, sizeof(*p)) != 0) {
 		error("malloc failed");
 		die(0);
 	}
-	ports = p;
 	p = [nports++];
 	p->port = port;
 	p->onoff = onoff;
@@ -326,12 +324,10 @@ selecthost(struct sockaddr *sa, int onof
 		}
 	if (sa->sa_len > sizeof(struct sockaddr_storage))
 		return (-1);	/*XXX*/
-	p = (struct hitem *)realloc(hosts, (nhosts+1)*sizeof (*p));
-	if (p == NULL) {
+	if (reallocarr(, nhosts + 1, sizeof(*p)) != 0) {
 		error("malloc failed");
 		die(0);
 	}
-	hosts = p;
 	p = [nhosts++];
 	memcpy(>addr, sa, sa->sa_len);
 	p->onoff = onoff;



CVS commit: src/usr.bin/systat

2021-10-30 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sat Oct 30 11:31:51 UTC 2021

Modified Files:
src/usr.bin/systat: netcmds.c

Log Message:
netstat(1): use reallocarr instead of realloc(x * y)


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/systat/netcmds.c

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



Re: CVS commit: src/usr.sbin/rpcbind

2021-10-30 Thread Rin Okuyama

On 2021/10/30 20:04, Nia Alarie wrote:

This function
previously tried to go to a label that doesn't exist. I wonder why
GCC didn't catch this before but does now.


This is not true. You deleted the label:


-   if (p == NULL) {
-out:
-   syslog(LOG_ERR, "Cannot allocate pollfds");
-   sleep(1);
-   continue;
-   }
if ((m = svc_fdset_getmax()) == NULL)
-   goto out;
+   break;


We should not break from infinite loop here, even if svc_fdset_getmax()
fails. Please restore the old behavior. And please be more careful before
making such a non-trivial change.

Thanks,
rin


CVS commit: src/usr.bin/su

2021-10-30 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sat Oct 30 11:25:30 UTC 2021

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

Log Message:
su(1): use reallocarr instead of malloc(x * y)


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/usr.bin/su/su.c

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



CVS commit: src/usr.bin/su

2021-10-30 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sat Oct 30 11:25:30 UTC 2021

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

Log Message:
su(1): use reallocarr instead of malloc(x * y)


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/usr.bin/su/su.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/su/su.c
diff -u src/usr.bin/su/su.c:1.73 src/usr.bin/su/su.c:1.74
--- src/usr.bin/su/su.c:1.73	Sun Oct 17 10:33:57 2021
+++ src/usr.bin/su/su.c	Sat Oct 30 11:25:30 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: su.c,v 1.73 2021/10/17 10:33:57 nia Exp $	*/
+/*	$NetBSD: su.c,v 1.74 2021/10/30 11:25:30 nia Exp $	*/
 
 /*
  * Copyright (c) 1988 The Regents of the University of California.
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988\
 #if 0
 static char sccsid[] = "@(#)su.c	8.3 (Berkeley) 4/2/94";*/
 #else
-__RCSID("$NetBSD: su.c,v 1.73 2021/10/17 10:33:57 nia Exp $");
+__RCSID("$NetBSD: su.c,v 1.74 2021/10/30 11:25:30 nia Exp $");
 #endif
 #endif /* not lint */
 
@@ -569,7 +569,8 @@ check_ingroup(int gid, const char *gname
 	 * each member to see if it is a group, and if so whether user is
 	 * in it.
 	 */
-	gr_mem = emalloc((n + 1) * sizeof (char *));
+	gr_mem = NULL;
+	ereallocarr(_mem, n + 1, sizeof(char *));
 	for (g = gr->gr_mem, i = 0; *g; ++g) {
 		gr_mem[i] = estrdup(*g);
 		i++;



CVS commit: src/usr.bin/netstat

2021-10-30 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sat Oct 30 11:23:07 UTC 2021

Modified Files:
src/usr.bin/netstat: inet.c inet6.c vtw.c

Log Message:
netstat(1): convert malloc(x * y) and realloc(x * y) to reallocarr


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 src/usr.bin/netstat/inet.c
cvs rdiff -u -r1.78 -r1.79 src/usr.bin/netstat/inet6.c
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/netstat/vtw.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/netstat/inet.c
diff -u src/usr.bin/netstat/inet.c:1.113 src/usr.bin/netstat/inet.c:1.114
--- src/usr.bin/netstat/inet.c:1.113	Fri Aug 28 07:23:48 2020
+++ src/usr.bin/netstat/inet.c	Sat Oct 30 11:23:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: inet.c,v 1.113 2020/08/28 07:23:48 ozaki-r Exp $	*/
+/*	$NetBSD: inet.c,v 1.114 2021/10/30 11:23:07 nia Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "from: @(#)inet.c	8.4 (Berkeley) 4/20/94";
 #else
-__RCSID("$NetBSD: inet.c,v 1.113 2020/08/28 07:23:48 ozaki-r Exp $");
+__RCSID("$NetBSD: inet.c,v 1.114 2021/10/30 11:23:07 nia Exp $");
 #endif
 #endif /* not lint */
 
@@ -293,8 +293,9 @@ getpcblist_kmem(u_long off, const char *
 	next = TAILQ_FIRST(head);
 	prev = TAILQ_END(head);
 
-	if ((pcblist = malloc(size * sizeof(*pcblist))) == NULL)
-		err(1, "malloc");
+	pcblist = NULL;
+	if (reallocarr(, size, sizeof(*pcblist)) != 0)
+		err(1, "reallocarr");
 
 	i = 0;
 	while (next != TAILQ_END(head)) {
@@ -325,11 +326,8 @@ getpcblist_kmem(u_long off, const char *
 		pcblist[i].ki_pflags = inpcb.inp_flags;
 		if (i++ == size) {
 			size += 100;
-			struct kinfo_pcb *n = realloc(pcblist,
-			size * sizeof(*pcblist));
-			if (n == NULL)
-err(1, "realloc");
-			pcblist = n;
+			if (reallocarr(, size, sizeof(*pcblist)) != 0)
+err(1, "reallocarr");
 		}
 	}
 	*len = i;

Index: src/usr.bin/netstat/inet6.c
diff -u src/usr.bin/netstat/inet6.c:1.78 src/usr.bin/netstat/inet6.c:1.79
--- src/usr.bin/netstat/inet6.c:1.78	Fri Sep 10 21:52:18 2021
+++ src/usr.bin/netstat/inet6.c	Sat Oct 30 11:23:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: inet6.c,v 1.78 2021/09/10 21:52:18 rillig Exp $	*/
+/*	$NetBSD: inet6.c,v 1.79 2021/10/30 11:23:07 nia Exp $	*/
 /*	BSDI inet.c,v 2.3 1995/10/24 02:19:29 prb Exp	*/
 
 /*
@@ -64,7 +64,7 @@
 #if 0
 static char sccsid[] = "@(#)inet.c	8.4 (Berkeley) 4/20/94";
 #else
-__RCSID("$NetBSD: inet6.c,v 1.78 2021/09/10 21:52:18 rillig Exp $");
+__RCSID("$NetBSD: inet6.c,v 1.79 2021/10/30 11:23:07 nia Exp $");
 #endif
 #endif /* not lint */
 
@@ -302,8 +302,9 @@ getpcblist_kmem(u_long off, const char *
 	next = TAILQ_FIRST(head);
 	prev = TAILQ_END(head);
 
-	if ((pcblist = malloc(size * sizeof(*pcblist))) == NULL)
-		err(1, "malloc");
+	pcblist = NULL;
+	if (reallocarr(, size, sizeof(*pcblist)) != 0)
+		err(1, "reallocarr");
 
 	i = 0;
 	while (next != TAILQ_END(head)) {
@@ -338,11 +339,8 @@ getpcblist_kmem(u_long off, const char *
 		pcblist[i].ki_tstate = tcpcb.t_state;
 		if (i++ == size) {
 			size += 100;
-			struct kinfo_pcb *n = realloc(pcblist,
-			size * sizeof(*pcblist));
-			if (n == NULL)
-err(1, "realloc");
-			pcblist = n;
+			if (reallocarr(, size, sizeof(*pcblist)) != 0)
+err(1, "reallocarr");
 		}
 	}
 	*len = i;

Index: src/usr.bin/netstat/vtw.c
diff -u src/usr.bin/netstat/vtw.c:1.11 src/usr.bin/netstat/vtw.c:1.12
--- src/usr.bin/netstat/vtw.c:1.11	Tue Mar  2 01:02:12 2021
+++ src/usr.bin/netstat/vtw.c	Sat Oct 30 11:23:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: vtw.c,v 1.11 2021/03/02 01:02:12 simonb Exp $	*/
+/*	$NetBSD: vtw.c,v 1.12 2021/10/30 11:23:07 nia Exp $	*/
 
 /*
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
 #if 0
 static char sccsid[] = "from: @(#)inet.c	8.4 (Berkeley) 4/20/94";
 #else
-__RCSID("$NetBSD: vtw.c,v 1.11 2021/03/02 01:02:12 simonb Exp $");
+__RCSID("$NetBSD: vtw.c,v 1.12 2021/10/30 11:23:07 nia Exp $");
 #endif
 #endif /* not lint */
 
@@ -303,8 +303,9 @@ show_vtw_v4(void (*print)(const vtw_t *)
 		n = (klim - kbase + 1);
 
 		if (!i) {
-			if ((ubase = malloc(n * sizeof(*kbase))) == NULL)
-err(EXIT_FAILURE, NULL);
+			ubase = NULL;
+			if (reallocarr(, n, sizeof(*kbase)) != 0)
+err(EXIT_FAILURE, "reallocarr");
 			snarf(kbase, ubase, n * sizeof(*ubase));
 
 			mem += n * sizeof(*ubase);
@@ -333,9 +334,9 @@ show_vtw_v4(void (*print)(const vtw_t *)
 
 	mem += (lim - base + 1) * sizeof(*base);
 
-	fat_tcpv4.base = malloc((lim - base + 1) * sizeof(*base));
-	if (fat_tcpv4.base == NULL)
-		err(EXIT_FAILURE, NULL);
+	fat_tcpv4.base = NULL;
+	if (reallocarr(_tcpv4.base, lim - base + 1, sizeof(*base)) != 0)
+		err(EXIT_FAILURE, "reallocarr");
 	fat_tcpv4.lim = fat_tcpv4.base + (lim - base);
 
 	snarf(base, fat_tcpv4.base, sizeof(*base) * (lim - base + 1));
@@ -347,10 +348,13 @@ show_vtw_v4(void (*print)(const vtw_t *)
 	hash = fat_tcpv4.hash;
 	port = fat_tcpv4.port;
 
-	

CVS commit: src/usr.bin/netstat

2021-10-30 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sat Oct 30 11:23:07 UTC 2021

Modified Files:
src/usr.bin/netstat: inet.c inet6.c vtw.c

Log Message:
netstat(1): convert malloc(x * y) and realloc(x * y) to reallocarr


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 src/usr.bin/netstat/inet.c
cvs rdiff -u -r1.78 -r1.79 src/usr.bin/netstat/inet6.c
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/netstat/vtw.c

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



CVS commit: src/sys/stand/efiboot

2021-10-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 30 11:18:51 UTC 2021

Modified Files:
src/sys/stand/efiboot: efiblock.c

Log Message:
If a path is not specified, assume /. This makes "ls" and "ls hd0b:" work
as expected.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/stand/efiboot/efiblock.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/stand/efiboot/efiblock.c
diff -u src/sys/stand/efiboot/efiblock.c:1.17 src/sys/stand/efiboot/efiblock.c:1.18
--- src/sys/stand/efiboot/efiblock.c:1.17	Wed Jun 23 21:42:43 2021
+++ src/sys/stand/efiboot/efiblock.c	Sat Oct 30 11:18:51 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: efiblock.c,v 1.17 2021/06/23 21:42:43 jmcneill Exp $ */
+/* $NetBSD: efiblock.c,v 1.18 2021/10/30 11:18:51 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -85,6 +85,10 @@ efi_block_parse(const char *fname, struc
 		*pfile = strchr(fname, ':') + 1;
 	}
 
+	if (*pfile[0] == '\0') {
+		*pfile = __UNCONST("/");
+	}
+
 	if (strncasecmp(full_path, "hd", 2) != 0)
 		return EINVAL;
 	dev = strtoimax(full_path + 2, , 10);



CVS commit: src/sys/stand/efiboot

2021-10-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 30 11:18:51 UTC 2021

Modified Files:
src/sys/stand/efiboot: efiblock.c

Log Message:
If a path is not specified, assume /. This makes "ls" and "ls hd0b:" work
as expected.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/stand/efiboot/efiblock.c

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



CVS commit: src/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 11:10:36 UTC 2021

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

Log Message:
indent: don't risk a buffer overflow in code_add_decl_indent

The buffers have a safety margin of 5 characters, so the bounds check is
not strictly necessary. It makes the code more uniform though.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.184 -r1.185 src/usr.bin/indent/indent.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/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.184 src/usr.bin/indent/indent.c:1.185
--- src/usr.bin/indent/indent.c:1.184	Sat Oct 30 11:05:26 2021
+++ src/usr.bin/indent/indent.c	Sat Oct 30 11:10:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.184 2021/10/30 11:05:26 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.185 2021/10/30 11:10:36 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.184 2021/10/30 11:05:26 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.185 2021/10/30 11:10:36 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -616,7 +616,7 @@ code_add_decl_indent(int decl_ind, bool 
 	buf_add_char(, ' ');
 
 if (code.e == orig_code_e && ps.want_blank) {
-	*code.e++ = ' ';
+	buf_add_char(, ' ');
 	ps.want_blank = false;
 }
 }



CVS commit: src/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 11:10:36 UTC 2021

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

Log Message:
indent: don't risk a buffer overflow in code_add_decl_indent

The buffers have a safety margin of 5 characters, so the bounds check is
not strictly necessary. It makes the code more uniform though.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.184 -r1.185 src/usr.bin/indent/indent.c

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



CVS commit: src/usr.bin/indent

2021-10-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 30 11:05:26 UTC 2021

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

Log Message:
indent: clean up code_add_decl_indent

In layout computations, it is helpful for human readers to list the
summands in logical order. In this case, the expression 'code_len +
base_ind' was rather confusing, so replace it with 'base_ind +
code_len'. This makes the code straight-forward enough that it doesn't
need any comments anymore.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.183 -r1.184 src/usr.bin/indent/indent.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/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.183 src/usr.bin/indent/indent.c:1.184
--- src/usr.bin/indent/indent.c:1.183	Sat Oct 30 10:59:07 2021
+++ src/usr.bin/indent/indent.c	Sat Oct 30 11:05:26 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.183 2021/10/30 10:59:07 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.184 2021/10/30 11:05:26 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.183 2021/10/30 10:59:07 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.184 2021/10/30 11:05:26 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -601,26 +601,18 @@ main_prepare_parsing(void)
 }
 
 static void
-code_add_decl_indent(int cur_decl_ind, bool tabs_to_var)
+code_add_decl_indent(int decl_ind, bool tabs_to_var)
 {
-int ind = (int)buf_len();
+int base_ind = ps.ind_level * opt.indent_size;
+int ind = base_ind + (int)buf_len();
+int target_ind = base_ind + decl_ind;
 char *orig_code_e = code.e;
 
-/*
- * get the tab math right for indentations that are not multiples of
- * tabsize
- */
-if (ps.ind_level * opt.indent_size != 0) {
-	ind += ps.ind_level * opt.indent_size;
-	cur_decl_ind += ps.ind_level * opt.indent_size;
-}
-
-if (tabs_to_var) {
-	for (int next; (next = next_tab(ind)) <= cur_decl_ind; ind = next)
+if (tabs_to_var)
+	for (int next; (next = next_tab(ind)) <= target_ind; ind = next)
 	buf_add_char(, '\t');
-}
 
-for (; ind < cur_decl_ind; ind++)
+for (; ind < target_ind; ind++)
 	buf_add_char(, ' ');
 
 if (code.e == orig_code_e && ps.want_blank) {



  1   2   >