CVS commit: src/tests/usr.bin/xlint/lint1

2021-10-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct  9 22:03:38 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_230.c msg_230.exp

Log Message:
tests/lint: demonstrate wrong warning about nonportable char comparison

Seen in bin/sh/expand.c:273.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/xlint/lint1/msg_230.c
cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/xlint/lint1/msg_230.exp

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/xlint/lint1/msg_230.c
diff -u src/tests/usr.bin/xlint/lint1/msg_230.c:1.9 src/tests/usr.bin/xlint/lint1/msg_230.c:1.10
--- src/tests/usr.bin/xlint/lint1/msg_230.c:1.9	Sat Oct  9 21:56:12 2021
+++ src/tests/usr.bin/xlint/lint1/msg_230.c	Sat Oct  9 22:03:38 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_230.c,v 1.9 2021/10/09 21:56:12 rillig Exp $	*/
+/*	$NetBSD: msg_230.c,v 1.10 2021/10/09 22:03:38 rillig Exp $	*/
 # 3 "msg_230.c"
 
 // Test for message: nonportable character comparison '%s %d' [230]
@@ -112,3 +112,21 @@ compare_lt(char c)
 	if (c >= 129)
 		return;
 }
+
+void
+compare_with_character_literal(char ch)
+{
+	/*
+	 * FIXME: These comparisons are portable since the character constant
+	 *  is interpreted using the type 'char' on the exact same platform
+	 *  as where the comparison takes place.
+	 */
+	/* expect+1: warning: nonportable character comparison '== -128' [230] */
+	if (ch == '\200')
+		return;
+	/* expect+1: warning: nonportable character comparison '== -1' [230] */
+	if (ch == '\377')
+		return;
+	if (ch == '\000')
+		return;
+}

Index: src/tests/usr.bin/xlint/lint1/msg_230.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_230.exp:1.8 src/tests/usr.bin/xlint/lint1/msg_230.exp:1.9
--- src/tests/usr.bin/xlint/lint1/msg_230.exp:1.8	Sat Oct  9 21:56:12 2021
+++ src/tests/usr.bin/xlint/lint1/msg_230.exp	Sat Oct  9 22:03:38 2021
@@ -16,3 +16,5 @@ msg_230.c(89): warning: nonportable char
 msg_230.c(105): warning: nonportable character comparison '>= 128' [230]
 msg_230.c(109): warning: nonportable character comparison '> 128' [230]
 msg_230.c(112): warning: nonportable character comparison '>= 129' [230]
+msg_230.c(125): warning: nonportable character comparison '== -128' [230]
+msg_230.c(128): warning: nonportable character comparison '== -1' [230]



CVS commit: src/tests/usr.bin/xlint/lint1

2021-10-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct  9 22:03:38 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_230.c msg_230.exp

Log Message:
tests/lint: demonstrate wrong warning about nonportable char comparison

Seen in bin/sh/expand.c:273.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/xlint/lint1/msg_230.c
cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/xlint/lint1/msg_230.exp

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



CVS commit: src

2021-10-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct  9 21:56:12 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_230.c msg_230.exp
src/usr.bin/xlint/lint1: err.c tree.c

Log Message:
lint: add more details to warning about nonportable character comparison

Especially when macros are involved, this makes it easier to see that
there is a real problem.

Seen in bin/sh/expand.c:273, where a plain char is compared to numbers
larger than 127.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/xlint/lint1/msg_230.c
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/xlint/lint1/msg_230.exp
cvs rdiff -u -r1.145 -r1.146 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.384 -r1.385 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

2021-10-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct  9 21:56:12 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_230.c msg_230.exp
src/usr.bin/xlint/lint1: err.c tree.c

Log Message:
lint: add more details to warning about nonportable character comparison

Especially when macros are involved, this makes it easier to see that
there is a real problem.

Seen in bin/sh/expand.c:273, where a plain char is compared to numbers
larger than 127.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/xlint/lint1/msg_230.c
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/xlint/lint1/msg_230.exp
cvs rdiff -u -r1.145 -r1.146 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.384 -r1.385 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/tests/usr.bin/xlint/lint1/msg_230.c
diff -u src/tests/usr.bin/xlint/lint1/msg_230.c:1.8 src/tests/usr.bin/xlint/lint1/msg_230.c:1.9
--- src/tests/usr.bin/xlint/lint1/msg_230.c:1.8	Sat Aug 28 15:25:10 2021
+++ src/tests/usr.bin/xlint/lint1/msg_230.c	Sat Oct  9 21:56:12 2021
@@ -1,7 +1,7 @@
-/*	$NetBSD: msg_230.c,v 1.8 2021/08/28 15:25:10 rillig Exp $	*/
+/*	$NetBSD: msg_230.c,v 1.9 2021/10/09 21:56:12 rillig Exp $	*/
 # 3 "msg_230.c"
 
-// Test for message: nonportable character comparison, op %s [230]
+// Test for message: nonportable character comparison '%s %d' [230]
 
 /* lint1-flags: -S -g -p -w */
 /* lint1-only-if: schar */
@@ -19,26 +19,26 @@
 void
 compare_plain_char(char c)
 {
-	/* expect+1: warning: nonportable character comparison, op == [230] */
+	/* expect+1: warning: nonportable character comparison '== -129' [230] */
 	if (c == -129)
 		return;
-	/* expect+1: warning: nonportable character comparison, op == [230] */
+	/* expect+1: warning: nonportable character comparison '== -128' [230] */
 	if (c == -128)
 		return;
-	/* expect+1: warning: nonportable character comparison, op == [230] */
+	/* expect+1: warning: nonportable character comparison '== -1' [230] */
 	if (c == -1)
 		return;
 	if (c == 0)
 		return;
 	if (c == 127)
 		return;
-	/* expect+1: warning: nonportable character comparison, op == [230] */
+	/* expect+1: warning: nonportable character comparison '== 128' [230] */
 	if (c == 128)
 		return;
-	/* expect+1: warning: nonportable character comparison, op == [230] */
+	/* expect+1: warning: nonportable character comparison '== 255' [230] */
 	if (c == 255)
 		return;
-	/* expect+1: warning: nonportable character comparison, op == [230] */
+	/* expect+1: warning: nonportable character comparison '== 256' [230] */
 	if (c == 256)
 		return;
 }
@@ -46,26 +46,26 @@ compare_plain_char(char c)
 void
 compare_plain_char_yoda(char c)
 {
-	/* expect+1: warning: nonportable character comparison, op == [230] */
+	/* expect+1: warning: nonportable character comparison '== -129' [230] */
 	if (-129 == c)
 		return;
-	/* expect+1: warning: nonportable character comparison, op == [230] */
+	/* expect+1: warning: nonportable character comparison '== -128' [230] */
 	if (-128 == c)
 		return;
-	/* expect+1: warning: nonportable character comparison, op == [230] */
+	/* expect+1: warning: nonportable character comparison '== -1' [230] */
 	if (-1 == c)
 		return;
 	if (0 == c)
 		return;
 	if (127 == c)
 		return;
-	/* expect+1: warning: nonportable character comparison, op == [230] */
+	/* expect+1: warning: nonportable character comparison '== 128' [230] */
 	if (128 == c)
 		return;
-	/* expect+1: warning: nonportable character comparison, op == [230] */
+	/* expect+1: warning: nonportable character comparison '== 255' [230] */
 	if (255 == c)
 		return;
-	/* expect+1: warning: nonportable character comparison, op == [230] */
+	/* expect+1: warning: nonportable character comparison '== 256' [230] */
 	if (256 == c)
 		return;
 }
@@ -74,10 +74,10 @@ void
 compare_lt(char c)
 {
 
-	/* expect+1: warning: nonportable character comparison, op > [230] */
+	/* expect+1: warning: nonportable character comparison '> -2' [230] */
 	if (c > -2)
 		return;
-	/* expect+1: warning: nonportable character comparison, op >= [230] */
+	/* expect+1: warning: nonportable character comparison '>= -1' [230] */
 	if (c >= -1)
 		return;
 
@@ -85,7 +85,7 @@ compare_lt(char c)
 	 * XXX: The following two comparisons have the same effect, yet lint
 	 * only warns about one of them.
 	 */
-	/* expect+1: warning: nonportable character comparison, op > [230] */
+	/* expect+1: warning: nonportable character comparison '> -1' [230] */
 	if (c > -1)
 		return;
 	/*
@@ -101,14 +101,14 @@ compare_lt(char c)
 	 */
 	if (c > 127)
 		return;
-	/* expect+1: warning: nonportable character comparison, op >= [230] */
+	/* expect+1: warning: nonportable character comparison '>= 128' [230] */
 	if (c >= 128)
 		return;
 
-	/* expect+1: warning: nonportable character comparison, op > [230] */
+	/* expect+1: warning: nonportable character 

CVS commit: src/bin/dd

2021-10-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct  9 21:31:36 UTC 2021

Modified Files:
src/bin/dd: args.c

Log Message:
dd: fix lint warnings about effectively discarding 'const'

args.c(153): warning: call to 'bsearch' effectively discards 'const'
from argument [346]
args.c(383): dito
args.c(475): dito

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/bin/dd/args.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/dd/args.c
diff -u src/bin/dd/args.c:1.40 src/bin/dd/args.c:1.41
--- src/bin/dd/args.c:1.40	Wed Jan 30 01:40:02 2019
+++ src/bin/dd/args.c	Sat Oct  9 21:31:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: args.c,v 1.40 2019/01/30 01:40:02 mrg Exp $	*/
+/*	$NetBSD: args.c,v 1.41 2021/10/09 21:31:36 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)args.c	8.3 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: args.c,v 1.40 2019/01/30 01:40:02 mrg Exp $");
+__RCSID("$NetBSD: args.c,v 1.41 2021/10/09 21:31:36 rillig Exp $");
 #endif
 #endif /* not lint */
 
@@ -127,7 +127,8 @@ static const struct arg {
 void
 jcl(char **argv)
 {
-	struct arg *ap, tmp;
+	const struct arg *ap;
+	struct arg tmp;
 	char *oper, *arg;
 
 	in.dbsz = out.dbsz = 512;
@@ -375,7 +376,8 @@ static const struct conv {
 static void
 f_conv(char *arg)
 {
-	struct conv *cp, tmp;
+	const struct conv *cp;
+	struct conv tmp;
 
 	while (arg != NULL) {
 		tmp.name = strsep(, ",");
@@ -466,7 +468,8 @@ static u_int
 f_ioflag(char *arg, u_int flagtype)
 {
 	u_int ioflag = 0;
-	struct ioflag *cp, tmp;
+	const struct ioflag *cp;
+	struct ioflag tmp;
 	const char *flagstr = (flagtype == C_IFLAG) ? "iflag" : "oflag";
 
 	while (arg != NULL) {



CVS commit: src/bin/dd

2021-10-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct  9 21:31:36 UTC 2021

Modified Files:
src/bin/dd: args.c

Log Message:
dd: fix lint warnings about effectively discarding 'const'

args.c(153): warning: call to 'bsearch' effectively discards 'const'
from argument [346]
args.c(383): dito
args.c(475): dito

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/bin/dd/args.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/xlint/lint1

2021-10-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct  9 21:25:39 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_160.c msg_160.exp msg_323.c
msg_323.exp

Log Message:
tests/lint: add examples for bogus warning 160 and for error 323


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_160.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_160.exp
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_323.c \
src/tests/usr.bin/xlint/lint1/msg_323.exp

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/xlint/lint1

2021-10-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct  9 21:25:39 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_160.c msg_160.exp msg_323.c
msg_323.exp

Log Message:
tests/lint: add examples for bogus warning 160 and for error 323


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_160.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_160.exp
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_323.c \
src/tests/usr.bin/xlint/lint1/msg_323.exp

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/xlint/lint1/msg_160.c
diff -u src/tests/usr.bin/xlint/lint1/msg_160.c:1.5 src/tests/usr.bin/xlint/lint1/msg_160.c:1.6
--- src/tests/usr.bin/xlint/lint1/msg_160.c:1.5	Sun Jan 31 12:20:00 2021
+++ src/tests/usr.bin/xlint/lint1/msg_160.c	Sat Oct  9 21:25:39 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_160.c,v 1.5 2021/01/31 12:20:00 rillig Exp $	*/
+/*	$NetBSD: msg_160.c,v 1.6 2021/10/09 21:25:39 rillig Exp $	*/
 # 3 "msg_160.c"
 
 // Test for message: operator '==' found where '=' was expected [160]
@@ -56,3 +56,15 @@ unparenthesized(int a, int b, int c, _Bo
 	 */
 	eval(a == (b == c));
 }
+
+/* Seen in bin/csh/dir.c 1.35 from 2020-08-09, line 223. */
+void
+assignment_in_comma_expression(void)
+{
+	int len;
+
+	/* FIXME: The following code is totally fine. */
+	/* expect+1: warning: operator '==' found where '=' was expected [160] */
+	if ((len = 3, len == 0))
+		return;
+}

Index: src/tests/usr.bin/xlint/lint1/msg_160.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_160.exp:1.4 src/tests/usr.bin/xlint/lint1/msg_160.exp:1.5
--- src/tests/usr.bin/xlint/lint1/msg_160.exp:1.4	Sun Jan 31 12:20:00 2021
+++ src/tests/usr.bin/xlint/lint1/msg_160.exp	Sat Oct  9 21:25:39 2021
@@ -1,2 +1,3 @@
 msg_160.c(30): warning: operator '==' found where '=' was expected [160]
 msg_160.c(43): warning: operator '==' found where '=' was expected [160]
+msg_160.c(68): warning: operator '==' found where '=' was expected [160]

Index: src/tests/usr.bin/xlint/lint1/msg_323.c
diff -u src/tests/usr.bin/xlint/lint1/msg_323.c:1.2 src/tests/usr.bin/xlint/lint1/msg_323.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_323.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_323.c	Sat Oct  9 21:25:39 2021
@@ -1,7 +1,21 @@
-/*	$NetBSD: msg_323.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_323.c,v 1.3 2021/10/09 21:25:39 rillig Exp $	*/
 # 3 "msg_323.c"
 
 // Test for message: continue in 'do ... while (0)' loop [323]
+void println(const char *);
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+void
+example(const char *p)
+{
+	do {
+		switch (*p) {
+		case 'a':
+			continue;	/* leaves the 'do while 0' */
+		case 'b':
+			break;		/* leaves the 'switch' */
+		}
+		println("b");
+	/* XXX: Is that really worth an error? */
+	/* expect+1: error: continue in 'do ... while (0)' loop [323] */
+	} while (0);
+}
Index: src/tests/usr.bin/xlint/lint1/msg_323.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_323.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_323.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_323.exp:1.2	Sun Mar 21 20:45:00 2021
+++ src/tests/usr.bin/xlint/lint1/msg_323.exp	Sat Oct  9 21:25:39 2021
@@ -1 +1 @@
-msg_323.c(6): error: syntax error ':' [249]
+msg_323.c(20): error: continue in 'do ... while (0)' loop [323]



CVS commit: src/bin

2021-10-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct  9 21:06:31 UTC 2021

Modified Files:
src/bin: Makefile.inc
src/bin/sh: Makefile

Log Message:
bin: in builds with MKLINT=yes, run lint on all programs


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/bin/Makefile.inc
cvs rdiff -u -r1.118 -r1.119 src/bin/sh/Makefile

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

Modified files:

Index: src/bin/Makefile.inc
diff -u src/bin/Makefile.inc:1.17 src/bin/Makefile.inc:1.18
--- src/bin/Makefile.inc:1.17	Wed Mar 21 05:47:53 2012
+++ src/bin/Makefile.inc	Sat Oct  9 21:06:31 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.17 2012/03/21 05:47:53 matt Exp $
+#	$NetBSD: Makefile.inc,v 1.18 2021/10/09 21:06:31 rillig Exp $
 #	@(#)Makefile.inc	8.1 (Berkeley) 5/31/93
 
 .include 		# for MKDYNAMICROOT definition
@@ -9,3 +9,7 @@ BINDIR?=	/bin
 .if (${MKDYNAMICROOT} == "no")
 LDSTATIC?=	-static
 .endif
+
+.if ${MKLINT} != "no" && ${LINT_SUPPORTED:Uyes} == "yes"
+realall: lint
+.endif

Index: src/bin/sh/Makefile
diff -u src/bin/sh/Makefile:1.118 src/bin/sh/Makefile:1.119
--- src/bin/sh/Makefile:1.118	Sat Oct  9 21:02:53 2021
+++ src/bin/sh/Makefile	Sat Oct  9 21:06:31 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.118 2021/10/09 21:02:53 rillig Exp $
+#	$NetBSD: Makefile,v 1.119 2021/10/09 21:06:31 rillig Exp $
 #	@(#)Makefile	8.4 (Berkeley) 5/5/95
 
 .include 
@@ -30,7 +30,7 @@ CPPFLAGS+= -DUSE_LRAND48
 #COPTS+=-g
 #CFLAGS+=-funsigned-char
 #TARGET_CHARFLAG?= -DTARGET_CHAR="unsigned char" -funsigned-char
-#LINTFLAGS+=	-X 323		# continue in 'do ... while (0)' loop
+LINTFLAGS+=	-X 323		# continue in 'do ... while (0)' loop
 
 # Reproducible build parameters ... export into sh for NETBSD_SHELL setting
 .if ${MKREPRO_TIMESTAMP:Uno} != "no"



CVS commit: src/bin

2021-10-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct  9 21:06:31 UTC 2021

Modified Files:
src/bin: Makefile.inc
src/bin/sh: Makefile

Log Message:
bin: in builds with MKLINT=yes, run lint on all programs


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/bin/Makefile.inc
cvs rdiff -u -r1.118 -r1.119 src/bin/sh/Makefile

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-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct  9 21:02:53 UTC 2021

Modified Files:
src/bin/sh: Makefile

Log Message:
sh: ignore lint error about 'continue' in 'do while' loop

exec.c(575): error: continue in 'do ... while (0)' loop [323]
jobs.c(203): error: continue in 'do ... while (0)' loop [323]

It is certainly a rarely used feature, I saw it the first time today and
had to look up its meaning in the C standard. But after that, I don't
see why a 'continue' statement in a 'do while' loop should be an error.
Maybe a warning since up to now I thought that 'continue' would jump
back to the top of the loop, while it really jumps to the bottom of the
loop body, for all 3 kinds of loops.


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/bin/sh/Makefile

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/Makefile
diff -u src/bin/sh/Makefile:1.117 src/bin/sh/Makefile:1.118
--- src/bin/sh/Makefile:1.117	Sun Aug 15 11:57:17 2021
+++ src/bin/sh/Makefile	Sat Oct  9 21:02:53 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.117 2021/08/15 11:57:17 christos Exp $
+#	$NetBSD: Makefile,v 1.118 2021/10/09 21:02:53 rillig Exp $
 #	@(#)Makefile	8.4 (Berkeley) 5/5/95
 
 .include 
@@ -30,6 +30,7 @@ CPPFLAGS+= -DUSE_LRAND48
 #COPTS+=-g
 #CFLAGS+=-funsigned-char
 #TARGET_CHARFLAG?= -DTARGET_CHAR="unsigned char" -funsigned-char
+#LINTFLAGS+=	-X 323		# continue in 'do ... while (0)' loop
 
 # Reproducible build parameters ... export into sh for NETBSD_SHELL setting
 .if ${MKREPRO_TIMESTAMP:Uno} != "no"



CVS commit: src/bin/sh

2021-10-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct  9 21:02:53 UTC 2021

Modified Files:
src/bin/sh: Makefile

Log Message:
sh: ignore lint error about 'continue' in 'do while' loop

exec.c(575): error: continue in 'do ... while (0)' loop [323]
jobs.c(203): error: continue in 'do ... while (0)' loop [323]

It is certainly a rarely used feature, I saw it the first time today and
had to look up its meaning in the C standard. But after that, I don't
see why a 'continue' statement in a 'do while' loop should be an error.
Maybe a warning since up to now I thought that 'continue' would jump
back to the top of the loop, while it really jumps to the bottom of the
loop body, for all 3 kinds of loops.


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/bin/sh/Makefile

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



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

2021-10-09 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Oct  9 20:59:47 UTC 2021

Modified Files:
src/sys/arch/luna68k/dev: lunaws.c

Log Message:
Handle wskbd(9) .set_leds op in cngetc(9) using wskbd_cnattach(9) cookie.

XXX1: LUNA's keyboards emulate "mechanical lock" for CAP and Kana keys,
  i.e. it sends "DOWN" code only when CAP/Kana LEDs are turned on
  and send "UP" code only when the LEDs are turned off.
  The MD omkbd_input() via wskbd_input(9) for the normal wskbd(4)
  (i.e. ttyE0) devices handles this quirk, but MI wskbd_cngetc()
  in sys/dev/wscons/wskbd.c can do nothing for this.

XXX2: I wonder if we should have an independent .set_leds op for cons(9)
  as cnbell(9), rather than referring a device specific softc stuff
  during .set_leds op in struct wskbd_accessop (registered during
  autoconf(9) via struct wskbddev_attach_args passed to config_found(9))
  even for wskbd cngetc(9) op in struct wskbd_consops (registered
  via early wskbd_cnattach(9)).


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/luna68k/dev/lunaws.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/luna68k/dev/lunaws.c
diff -u src/sys/arch/luna68k/dev/lunaws.c:1.39 src/sys/arch/luna68k/dev/lunaws.c:1.40
--- src/sys/arch/luna68k/dev/lunaws.c:1.39	Sat Sep 25 15:18:38 2021
+++ src/sys/arch/luna68k/dev/lunaws.c	Sat Oct  9 20:59:47 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lunaws.c,v 1.39 2021/09/25 15:18:38 tsutsui Exp $ */
+/* $NetBSD: lunaws.c,v 1.40 2021/10/09 20:59:47 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: lunaws.c,v 1.39 2021/09/25 15:18:38 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lunaws.c,v 1.40 2021/10/09 20:59:47 tsutsui Exp $");
 
 #include "opt_wsdisplay_compat.h"
 #include "wsmouse.h"
@@ -101,6 +101,12 @@ static const uint8_t ch1_regs[6] = {
 	WR5_TX8BIT | WR5_TXENBL,		/* Tx */
 };
 
+struct ws_conscookie {
+	struct sioreg	*cc_sio;
+	int		cc_polling;
+	struct ws_softc	*cc_sc;
+};
+
 struct ws_softc {
 	device_t	sc_dev;
 	struct sioreg	*sc_ctl;
@@ -122,6 +128,8 @@ struct ws_softc {
 	int		sc_msreport;
 	void		*sc_si;
 	int		sc_rawkbd;
+
+	struct ws_conscookie *sc_conscookie;
 };
 
 static void omkbd_input(struct ws_softc *, int);
@@ -155,6 +163,7 @@ static const struct wskbd_consops ws_con
 	.pollc = ws_cnpollc,
 	.bell  = ws_cnbell,
 };
+static struct ws_conscookie ws_conscookie;
 
 #if NWSMOUSE > 0
 static int  omms_enable(void *);
@@ -214,6 +223,10 @@ wsattach(device_t parent, device_t self,
 	siosc->sc_intrhand[channel].ih_func = wsintr;
 	siosc->sc_intrhand[channel].ih_arg = sc;
 
+	sc->sc_conscookie = _conscookie;
+	sc->sc_conscookie->cc_sc = sc;
+	sc->sc_conscookie->cc_polling = 0;
+
 	setsioreg(sc->sc_ctl, WR0, sc->sc_wr[WR0]);
 	setsioreg(sc->sc_ctl, WR4, sc->sc_wr[WR4]);
 	setsioreg(sc->sc_ctl, WR3, sc->sc_wr[WR3]);
@@ -514,13 +527,11 @@ omkbd_get_buzcmd(struct ws_softc *sc, st
 static void
 ws_cngetc(void *cookie, u_int *type, int *data)
 {
-	struct ws_softc *sc = cookie;	/* currently unused */
-	struct sioreg *sio, *sio_base;
+	struct ws_conscookie *conscookie = cookie;
+	struct sioreg *sio = conscookie->cc_sio;
+	struct ws_softc *sc = conscookie->cc_sc;	/* currently unused */
 	int code;
 
-	sio_base = (struct sioreg *)OBIO_SIO;
-	sio = _base[1];	/* channel B */
-
 	code = siogetc(sio);
 	omkbd_decode(sc, code, type, data);
 }
@@ -528,19 +539,20 @@ ws_cngetc(void *cookie, u_int *type, int
 static void
 ws_cnpollc(void *cookie, int on)
 {
+	struct ws_conscookie *conscookie = cookie;
+
+	conscookie->cc_polling = on;
 }
 
 static void
 ws_cnbell(void *cookie, u_int pitch, u_int period, u_int volume)
 {
-	struct ws_softc *sc = cookie;	/* currently unused */
-	struct sioreg *sio, *sio_base;
+	struct ws_conscookie *conscookie = cookie;
+	struct sioreg *sio = conscookie->cc_sio;
+	struct ws_softc *sc = conscookie->cc_sc;	/* currently unused */
 	struct wskbd_bell_data wbd;
 	uint8_t buzcmd;
 
-	sio_base = (struct sioreg *)OBIO_SIO;
-	sio = _base[1];	/* channel B */
-
 	/*
 	 * XXX cnbell(9) man page should describe each args..
 	 * (it looks similar to the struct wskbd_bell_data)
@@ -560,11 +572,14 @@ ws_cnbell(void *cookie, u_int pitch, u_i
 /* EXPORT */ void
 ws_cnattach(void)
 {
-	static int voidfill;
+	struct sioreg *sio_base;
+
+	sio_base = (struct sioreg *)OBIO_SIO;
+	ws_conscookie.cc_sio = _base[1];	/* channel B */
 
 	/* XXX need CH.B initialization XXX */
 
-	wskbd_cnattach(_consops, , _keymapdata);
+	wskbd_cnattach(_consops, _conscookie, _keymapdata);
 }
 
 static int
@@ -578,35 +593,41 @@ static void
 omkbd_set_leds(void *cookie, int leds)
 {
 	struct ws_softc *sc = cookie;
-	uint8_t ledcmd;
+	uint8_t capsledcmd, kanaledcmd;
 
-	/*
-	 * XXX:
-	 *  Why does MI wskbd(4) use a common 

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

2021-10-09 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Oct  9 20:59:47 UTC 2021

Modified Files:
src/sys/arch/luna68k/dev: lunaws.c

Log Message:
Handle wskbd(9) .set_leds op in cngetc(9) using wskbd_cnattach(9) cookie.

XXX1: LUNA's keyboards emulate "mechanical lock" for CAP and Kana keys,
  i.e. it sends "DOWN" code only when CAP/Kana LEDs are turned on
  and send "UP" code only when the LEDs are turned off.
  The MD omkbd_input() via wskbd_input(9) for the normal wskbd(4)
  (i.e. ttyE0) devices handles this quirk, but MI wskbd_cngetc()
  in sys/dev/wscons/wskbd.c can do nothing for this.

XXX2: I wonder if we should have an independent .set_leds op for cons(9)
  as cnbell(9), rather than referring a device specific softc stuff
  during .set_leds op in struct wskbd_accessop (registered during
  autoconf(9) via struct wskbddev_attach_args passed to config_found(9))
  even for wskbd cngetc(9) op in struct wskbd_consops (registered
  via early wskbd_cnattach(9)).


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/luna68k/dev/lunaws.c

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



CVS commit: src/bin/dd

2021-10-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct  9 20:44:55 UTC 2021

Modified Files:
src/bin/dd: misc.c

Log Message:
dd: clean up function summary

No functional change. Ideally the binary would have stayed the same, but
GCC 10.3.0 inserts a nop and reorders the code.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/bin/dd/misc.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/dd/misc.c
diff -u src/bin/dd/misc.c:1.25 src/bin/dd/misc.c:1.26
--- src/bin/dd/misc.c:1.25	Sat Oct  9 20:29:23 2021
+++ src/bin/dd/misc.c	Sat Oct  9 20:44:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: misc.c,v 1.25 2021/10/09 20:29:23 rillig Exp $	*/
+/*	$NetBSD: misc.c,v 1.26 2021/10/09 20:44:55 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)misc.c	8.3 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: misc.c,v 1.25 2021/10/09 20:29:23 rillig Exp $");
+__RCSID("$NetBSD: misc.c,v 1.26 2021/10/09 20:44:55 rillig Exp $");
 #endif
 #endif /* not lint */
 
@@ -78,13 +78,11 @@ summary(void)
 #ifdef NO_MSGFMT
 	posix_summary();
 #else /* NO_MSGFMT */
-	if (strcmp(msgfmt, "human") == 0) {
+	if (strcmp(msgfmt, "human") == 0)
 		human_summary();
-		return;
-	} else if (strcmp(msgfmt, "posix") == 0) {
+	else if (strcmp(msgfmt, "posix") == 0)
 		posix_summary();
-		return;
-	} else if (strcmp(msgfmt, "quiet") == 0)
+	else if (strcmp(msgfmt, "quiet") == 0)
 		quiet_summary();
 	else
 		custom_summary();



CVS commit: src/bin/dd

2021-10-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct  9 20:44:55 UTC 2021

Modified Files:
src/bin/dd: misc.c

Log Message:
dd: clean up function summary

No functional change. Ideally the binary would have stayed the same, but
GCC 10.3.0 inserts a nop and reorders the code.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/bin/dd/misc.c

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



CVS commit: src/bin/dd

2021-10-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct  9 20:29:23 UTC 2021

Modified Files:
src/bin/dd: misc.c

Log Message:
dd: fix lint error about 'return expr' from void function

No change to the resulting binary. The 'return' statements are necessary
for GCC to generate the exact same object code, even though they can be
removed without affecting the functionality, as seen before the 'else'.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/bin/dd/misc.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/dd/misc.c
diff -u src/bin/dd/misc.c:1.24 src/bin/dd/misc.c:1.25
--- src/bin/dd/misc.c:1.24	Fri Sep 10 22:11:03 2021
+++ src/bin/dd/misc.c	Sat Oct  9 20:29:23 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: misc.c,v 1.24 2021/09/10 22:11:03 rillig Exp $	*/
+/*	$NetBSD: misc.c,v 1.25 2021/10/09 20:29:23 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)misc.c	8.3 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: misc.c,v 1.24 2021/09/10 22:11:03 rillig Exp $");
+__RCSID("$NetBSD: misc.c,v 1.25 2021/10/09 20:29:23 rillig Exp $");
 #endif
 #endif /* not lint */
 
@@ -76,18 +76,18 @@ summary(void)
 		(void)write(STDERR_FILENO, "\n", 1);
 
 #ifdef NO_MSGFMT
-	return posix_summary();
+	posix_summary();
 #else /* NO_MSGFMT */
-	if (strncmp(msgfmt, "human", sizeof("human")) == 0)
-		return human_summary();
-
-	if (strncmp(msgfmt, "posix", sizeof("posix")) == 0)
-		return posix_summary();
-
-	if (strncmp(msgfmt, "quiet", sizeof("quiet")) == 0)
-		return quiet_summary();
-
-	return custom_summary();
+	if (strcmp(msgfmt, "human") == 0) {
+		human_summary();
+		return;
+	} else if (strcmp(msgfmt, "posix") == 0) {
+		posix_summary();
+		return;
+	} else if (strcmp(msgfmt, "quiet") == 0)
+		quiet_summary();
+	else
+		custom_summary();
 #endif /* NO_MSGFMT */
 }
 



CVS commit: src/bin/dd

2021-10-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct  9 20:29:23 UTC 2021

Modified Files:
src/bin/dd: misc.c

Log Message:
dd: fix lint error about 'return expr' from void function

No change to the resulting binary. The 'return' statements are necessary
for GCC to generate the exact same object code, even though they can be
removed without affecting the functionality, as seen before the 'else'.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/bin/dd/misc.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-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct  9 20:07:37 UTC 2021

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

Log Message:
indent: fix lint warning about bsearch discarding 'const'

lexi.c(433): warning: call to 'bsearch' effectively discards 'const'
from argument [346]


To generate a diff of this commit:
cvs rdiff -u -r1.87 -r1.88 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.87 src/usr.bin/indent/lexi.c:1.88
--- src/usr.bin/indent/lexi.c:1.87	Fri Oct  8 23:55:44 2021
+++ src/usr.bin/indent/lexi.c	Sat Oct  9 20:07:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lexi.c,v 1.87 2021/10/08 23:55:44 rillig Exp $	*/
+/*	$NetBSD: lexi.c,v 1.88 2021/10/09 20:07:37 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.87 2021/10/08 23:55:44 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.88 2021/10/09 20:07:37 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -401,7 +401,6 @@ lexi(struct parser_state *state)
 if (isalnum((unsigned char)*inp.s) ||
 	*inp.s == '_' || *inp.s == '$' ||
 	(inp.s[0] == '.' && isdigit((unsigned char)inp.s[1]))) {
-	struct keyword *kw;
 
 	if (isdigit((unsigned char)*inp.s) ||
 	(inp.s[0] == '.' && isdigit((unsigned char)inp.s[1]))) {
@@ -429,8 +428,8 @@ lexi(struct parser_state *state)
 	 */
 	state->last_u_d = (state->last_token == keyword_struct_union_enum);
 
-	kw = bsearch(token.s, keywords, nitems(keywords),
-	sizeof(keywords[0]), cmp_keyword_by_name);
+	const struct keyword *kw = bsearch(token.s, keywords,
+	nitems(keywords), sizeof(keywords[0]), cmp_keyword_by_name);
 	if (kw == NULL) {
 	if (is_typename()) {
 		state->keyword = kw_type;



CVS commit: src/usr.bin/indent

2021-10-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct  9 20:07:37 UTC 2021

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

Log Message:
indent: fix lint warning about bsearch discarding 'const'

lexi.c(433): warning: call to 'bsearch' effectively discards 'const'
from argument [346]


To generate a diff of this commit:
cvs rdiff -u -r1.87 -r1.88 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-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct  9 20:03:20 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_346.c msg_346.exp
src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: warn that bsearch effectively discards 'const'

Just like strchr, bsearch takes a const pointer and returns a non-const
pointer into the same object.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_346.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_346.exp
cvs rdiff -u -r1.383 -r1.384 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/tests/usr.bin/xlint/lint1/msg_346.c
diff -u src/tests/usr.bin/xlint/lint1/msg_346.c:1.5 src/tests/usr.bin/xlint/lint1/msg_346.c:1.6
--- src/tests/usr.bin/xlint/lint1/msg_346.c:1.5	Sat Oct  9 19:18:52 2021
+++ src/tests/usr.bin/xlint/lint1/msg_346.c	Sat Oct  9 20:03:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_346.c,v 1.5 2021/10/09 19:18:52 rillig Exp $	*/
+/*	$NetBSD: msg_346.c,v 1.6 2021/10/09 20:03:20 rillig Exp $	*/
 # 3 "msg_346.c"
 
 // Test for message: call to '%s' effectively discards 'const' from argument [346]
@@ -71,18 +71,18 @@ void *bsearch(const void *key, const voi
 int cmp(const void *, const void *);
 
 void take_void_ptr(void *);
-void take_const_void_ptr(void *);
+void take_const_void_ptr(const void *);
 
 void
 bsearch_example(void)
 {
+	int arr[] = { 1 };
 	const int const_arr[] = { 1 };
-	const int arr[] = { 1 };
 
 	take_const_void_ptr(bsearch("", const_arr, 4, 1, cmp));
 	take_const_void_ptr(bsearch("", arr, 4, 1, cmp));
 	take_void_ptr(bsearch("", arr, 4, 1, cmp));
 
-	/* TODO: expect+1: warning: call to 'bsearch' effectively discards 'const' from argument [346] */
+	/* expect+1: warning: call to 'bsearch' effectively discards 'const' from argument [346] */
 	take_void_ptr(bsearch("", const_arr, 4, 1, cmp));
 }

Index: src/tests/usr.bin/xlint/lint1/msg_346.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_346.exp:1.4 src/tests/usr.bin/xlint/lint1/msg_346.exp:1.5
--- src/tests/usr.bin/xlint/lint1/msg_346.exp:1.4	Mon Aug 16 18:51:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_346.exp	Sat Oct  9 20:03:20 2021
@@ -7,3 +7,4 @@ msg_346.c(48): warning: call to 'strpbrk
 msg_346.c(50): warning: call to 'strrchr' effectively discards 'const' from argument [346]
 msg_346.c(52): warning: call to 'strstr' effectively discards 'const' from argument [346]
 msg_346.c(60): error: argument mismatch: 0 arg passed, 2 expected [150]
+msg_346.c(87): warning: call to 'bsearch' effectively discards 'const' from argument [346]

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.383 src/usr.bin/xlint/lint1/tree.c:1.384
--- src/usr.bin/xlint/lint1/tree.c:1.383	Sun Sep 26 14:52:37 2021
+++ src/usr.bin/xlint/lint1/tree.c	Sat Oct  9 20:03:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.383 2021/09/26 14:52:37 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.384 2021/10/09 20:03:20 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.383 2021/09/26 14:52:37 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.384 2021/10/09 20:03:20 rillig Exp $");
 #endif
 
 #include 
@@ -1412,7 +1412,16 @@ is_const_char_pointer(const tnode_t *tn)
 }
 
 static bool
-is_first_arg_const(const tnode_t *tn)
+is_const_pointer(const tnode_t *tn)
+{
+	const type_t *tp;
+
+	tp = before_conversion(tn)->tn_type;
+	return tp->t_tspec == PTR && tp->t_subt->t_const;
+}
+
+static bool
+is_first_arg_const_char_pointer(const tnode_t *tn)
 {
 	const tnode_t *an;
 
@@ -1425,6 +1434,20 @@ is_first_arg_const(const tnode_t *tn)
 	return is_const_char_pointer(an->tn_left);
 }
 
+static bool
+is_second_arg_const_pointer(const tnode_t *tn)
+{
+	const tnode_t *an;
+
+	an = tn->tn_right;
+	if (an == NULL || an->tn_right == NULL)
+		return false;
+
+	while (an->tn_right->tn_right != NULL)
+		an = an->tn_right;
+	return is_const_pointer(an->tn_left);
+}
+
 static void
 check_unconst_function(const type_t *lstp, const tnode_t *rn)
 {
@@ -1433,7 +1456,15 @@ check_unconst_function(const type_t *lst
 	if (lstp->t_tspec == CHAR && !lstp->t_const &&
 	is_direct_function_call(rn, _name) &&
 	is_unconst_function(function_name) &&
-	is_first_arg_const(rn)) {
+	is_first_arg_const_char_pointer(rn)) {
+		/* call to '%s' effectively discards 'const' from argument */
+		warning(346, function_name);
+	}
+
+	if (!lstp->t_const &&
+	is_direct_function_call(rn, _name) &&
+	strcmp(function_name, "bsearch") == 0 &&
+	is_second_arg_const_pointer(rn)) {
 		/* call to '%s' effectively discards 'const' from argument */
 		warning(346, function_name);
 	}



CVS commit: src

2021-10-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct  9 20:03:20 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_346.c msg_346.exp
src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: warn that bsearch effectively discards 'const'

Just like strchr, bsearch takes a const pointer and returns a non-const
pointer into the same object.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_346.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_346.exp
cvs rdiff -u -r1.383 -r1.384 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/sys/arch

2021-10-09 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Oct  9 20:00:42 UTC 2021

Modified Files:
src/sys/arch/atari/atari: machdep.c
src/sys/arch/cesfic/cesfic: machdep.c
src/sys/arch/hp300/hp300: machdep.c
src/sys/arch/luna68k/luna68k: machdep.c
src/sys/arch/mac68k/mac68k: machdep.c
src/sys/arch/mvme68k/mvme68k: machdep.c
src/sys/arch/news68k/news68k: machdep.c
src/sys/arch/next68k/next68k: machdep.c
src/sys/arch/x68k/x68k: machdep.c

Log Message:
Call cnpollc(9) before cngetc(9) as the cons(9) man page says.

Currently most ports do nothing in cnpollc(9), but this is required to
handle wskbd(9) .set_leds op in cngetc(9) properly, at least on luna68k.


To generate a diff of this commit:
cvs rdiff -u -r1.184 -r1.185 src/sys/arch/atari/atari/machdep.c
cvs rdiff -u -r1.71 -r1.72 src/sys/arch/cesfic/cesfic/machdep.c
cvs rdiff -u -r1.235 -r1.236 src/sys/arch/hp300/hp300/machdep.c
cvs rdiff -u -r1.107 -r1.108 src/sys/arch/luna68k/luna68k/machdep.c
cvs rdiff -u -r1.362 -r1.363 src/sys/arch/mac68k/mac68k/machdep.c
cvs rdiff -u -r1.158 -r1.159 src/sys/arch/mvme68k/mvme68k/machdep.c
cvs rdiff -u -r1.109 -r1.110 src/sys/arch/news68k/news68k/machdep.c
cvs rdiff -u -r1.115 -r1.116 src/sys/arch/next68k/next68k/machdep.c
cvs rdiff -u -r1.206 -r1.207 src/sys/arch/x68k/x68k/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/atari/atari/machdep.c
diff -u src/sys/arch/atari/atari/machdep.c:1.184 src/sys/arch/atari/atari/machdep.c:1.185
--- src/sys/arch/atari/atari/machdep.c:1.184	Sun Jan  3 17:42:10 2021
+++ src/sys/arch/atari/atari/machdep.c	Sat Oct  9 20:00:41 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.184 2021/01/03 17:42:10 thorpej Exp $	*/
+/*	$NetBSD: machdep.c,v 1.185 2021/10/09 20:00:41 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.184 2021/01/03 17:42:10 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.185 2021/10/09 20:00:41 tsutsui Exp $");
 
 #include "opt_ddb.h"
 #include "opt_compat_netbsd.h"
@@ -440,7 +440,10 @@ dumpsys(void)
 
 #if defined(DDB) || defined(PANICWAIT)
 	printf("Do you want to dump memory? [y]");
-	cnputc(i = cngetc());
+	cnpollc(1);
+	i = cngetc();
+	cnpollc(0);
+	cnputc(i);
 	switch (i) {
 	case 'n':
 	case 'N':

Index: src/sys/arch/cesfic/cesfic/machdep.c
diff -u src/sys/arch/cesfic/cesfic/machdep.c:1.71 src/sys/arch/cesfic/cesfic/machdep.c:1.72
--- src/sys/arch/cesfic/cesfic/machdep.c:1.71	Thu Jun 11 19:20:43 2020
+++ src/sys/arch/cesfic/cesfic/machdep.c	Sat Oct  9 20:00:41 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.71 2020/06/11 19:20:43 ad Exp $	*/
+/*	$NetBSD: machdep.c,v 1.72 2021/10/09 20:00:41 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.71 2020/06/11 19:20:43 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.72 2021/10/09 20:00:41 tsutsui Exp $");
 
 #include "opt_bufcache.h"
 #include "opt_ddb.h"
@@ -337,7 +337,9 @@ cpu_reboot(int howto, char *bootstr)
 #if defined(PANICWAIT) && !defined(DDB)
 	if ((howto & RB_HALT) == 0 && panicstr) {
 		printf("hit any key to reboot...\n");
+		cnpollc(1);
 		(void)cngetc();
+		cnpollc(0);
 		printf("\n");
 	}
 #endif
@@ -345,7 +347,9 @@ cpu_reboot(int howto, char *bootstr)
 	/* Finally, halt/reboot the system. */
 	if (howto & RB_HALT) {
 		printf("System halted.  Hit any key to reboot.\n\n");
+		cnpollc(1);
 		(void)cngetc();
+		cnpollc(0);
 	}
 
 	printf("rebooting...\n");

Index: src/sys/arch/hp300/hp300/machdep.c
diff -u src/sys/arch/hp300/hp300/machdep.c:1.235 src/sys/arch/hp300/hp300/machdep.c:1.236
--- src/sys/arch/hp300/hp300/machdep.c:1.235	Fri Aug  6 05:22:21 2021
+++ src/sys/arch/hp300/hp300/machdep.c	Sat Oct  9 20:00:41 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.235 2021/08/06 05:22:21 tsutsui Exp $	*/
+/*	$NetBSD: machdep.c,v 1.236 2021/10/09 20:00:41 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.235 2021/08/06 05:22:21 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.236 2021/10/09 20:00:41 tsutsui Exp $");
 
 #include "opt_ddb.h"
 #include "opt_compat_netbsd.h"
@@ -612,7 +612,9 @@ cpu_reboot(int howto, char *bootstr)
 #if defined(PANICWAIT) && !defined(DDB)
 	if ((howto & RB_HALT) == 0 && panicstr) {
 		printf("hit any key to reboot...\n");
+		cnpollc(1);
 		(void)cngetc();
+		cnpollc(0);
 		printf("\n");
 	}
 #endif
@@ -620,7 +622,9 @@ cpu_reboot(int howto, char *bootstr)
 	/* Finally, halt/reboot the system. */
 	if (howto & RB_HALT) {
 		printf("System halted.  Hit any key to reboot.\n\n");
+		cnpollc(1);
 		(void)cngetc();
+		cnpollc(0);
 	}
 
 	printf("rebooting...\n");

Index: 

CVS commit: src/sys/arch

2021-10-09 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Oct  9 20:00:42 UTC 2021

Modified Files:
src/sys/arch/atari/atari: machdep.c
src/sys/arch/cesfic/cesfic: machdep.c
src/sys/arch/hp300/hp300: machdep.c
src/sys/arch/luna68k/luna68k: machdep.c
src/sys/arch/mac68k/mac68k: machdep.c
src/sys/arch/mvme68k/mvme68k: machdep.c
src/sys/arch/news68k/news68k: machdep.c
src/sys/arch/next68k/next68k: machdep.c
src/sys/arch/x68k/x68k: machdep.c

Log Message:
Call cnpollc(9) before cngetc(9) as the cons(9) man page says.

Currently most ports do nothing in cnpollc(9), but this is required to
handle wskbd(9) .set_leds op in cngetc(9) properly, at least on luna68k.


To generate a diff of this commit:
cvs rdiff -u -r1.184 -r1.185 src/sys/arch/atari/atari/machdep.c
cvs rdiff -u -r1.71 -r1.72 src/sys/arch/cesfic/cesfic/machdep.c
cvs rdiff -u -r1.235 -r1.236 src/sys/arch/hp300/hp300/machdep.c
cvs rdiff -u -r1.107 -r1.108 src/sys/arch/luna68k/luna68k/machdep.c
cvs rdiff -u -r1.362 -r1.363 src/sys/arch/mac68k/mac68k/machdep.c
cvs rdiff -u -r1.158 -r1.159 src/sys/arch/mvme68k/mvme68k/machdep.c
cvs rdiff -u -r1.109 -r1.110 src/sys/arch/news68k/news68k/machdep.c
cvs rdiff -u -r1.115 -r1.116 src/sys/arch/next68k/next68k/machdep.c
cvs rdiff -u -r1.206 -r1.207 src/sys/arch/x68k/x68k/machdep.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/xlint/lint1

2021-10-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct  9 19:18:53 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_346.c

Log Message:
tests/lint: test effective unconst cast using bsearch

Seen in usr.bin/indent/lexi.c, function lexi.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_346.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/xlint/lint1/msg_346.c
diff -u src/tests/usr.bin/xlint/lint1/msg_346.c:1.4 src/tests/usr.bin/xlint/lint1/msg_346.c:1.5
--- src/tests/usr.bin/xlint/lint1/msg_346.c:1.4	Mon Aug 16 18:51:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_346.c	Sat Oct  9 19:18:52 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_346.c,v 1.4 2021/08/16 18:51:58 rillig Exp $	*/
+/*	$NetBSD: msg_346.c,v 1.5 2021/10/09 19:18:52 rillig Exp $	*/
 # 3 "msg_346.c"
 
 // Test for message: call to '%s' effectively discards 'const' from argument [346]
@@ -59,3 +59,30 @@ edge_cases(void)
 	/* expect+1: error: argument mismatch: 0 arg passed, 2 expected [150] */
 	take_char_ptr(strchr());
 }
+
+/*
+ * Bsearch is another standard function that effectively discards the 'const'
+ * modifier, but from the second argument, not the first.
+ */
+
+void *bsearch(const void *key, const void *base, size_t nmemb, size_t size,
+	int (*compar) (const void *, const void *));
+
+int cmp(const void *, const void *);
+
+void take_void_ptr(void *);
+void take_const_void_ptr(void *);
+
+void
+bsearch_example(void)
+{
+	const int const_arr[] = { 1 };
+	const int arr[] = { 1 };
+
+	take_const_void_ptr(bsearch("", const_arr, 4, 1, cmp));
+	take_const_void_ptr(bsearch("", arr, 4, 1, cmp));
+	take_void_ptr(bsearch("", arr, 4, 1, cmp));
+
+	/* TODO: expect+1: warning: call to 'bsearch' effectively discards 'const' from argument [346] */
+	take_void_ptr(bsearch("", const_arr, 4, 1, cmp));
+}



CVS commit: src/tests/usr.bin/xlint/lint1

2021-10-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct  9 19:18:53 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_346.c

Log Message:
tests/lint: test effective unconst cast using bsearch

Seen in usr.bin/indent/lexi.c, function lexi.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_346.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-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct  9 14:22:42 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_338.c msg_338.exp
src/usr.bin/xlint/lint1: ckgetopt.c

Log Message:
lint: warn if a getopt switch tries to handle unreachable ':'


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/msg_338.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_338.exp
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/xlint/lint1/ckgetopt.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/xlint/lint1/msg_338.c
diff -u src/tests/usr.bin/xlint/lint1/msg_338.c:1.6 src/tests/usr.bin/xlint/lint1/msg_338.c:1.7
--- src/tests/usr.bin/xlint/lint1/msg_338.c:1.6	Sat Oct  9 13:57:55 2021
+++ src/tests/usr.bin/xlint/lint1/msg_338.c	Sat Oct  9 14:22:42 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_338.c,v 1.6 2021/10/09 13:57:55 rillig Exp $	*/
+/*	$NetBSD: msg_338.c,v 1.7 2021/10/09 14:22:42 rillig Exp $	*/
 # 3 "msg_338.c"
 
 // Test for message: option '%c' should be handled in the switch [338]
@@ -141,7 +141,7 @@ unreachable_colon(int argc, char **argv)
 	/* expect+1: warning: option 'b' should be handled in the switch [338] */
 	while ((c = getopt(argc, argv, "b:")) != -1) {
 		switch (c) {
-		/* TODO: expect+1: warning: option ':' should be listed in the options string [339] */
+		/* expect+1: warning: option ':' should be listed in the options string [339] */
 		case ':':
 			return 'm';
 		default:

Index: src/tests/usr.bin/xlint/lint1/msg_338.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_338.exp:1.4 src/tests/usr.bin/xlint/lint1/msg_338.exp:1.5
--- src/tests/usr.bin/xlint/lint1/msg_338.exp:1.4	Sat Oct  9 13:57:55 2021
+++ src/tests/usr.bin/xlint/lint1/msg_338.exp	Sat Oct  9 14:22:42 2021
@@ -4,4 +4,5 @@ msg_338.c(14): warning: option 'c' shoul
 msg_338.c(14): warning: option 'd' should be handled in the switch [338]
 msg_338.c(94): warning: option 'o' should be handled in the switch [338]
 msg_338.c(116): warning: option 'o' should be handled in the switch [338]
+msg_338.c(145): warning: option ':' should be listed in the options string [339]
 msg_338.c(142): warning: option 'b' should be handled in the switch [338]

Index: src/usr.bin/xlint/lint1/ckgetopt.c
diff -u src/usr.bin/xlint/lint1/ckgetopt.c:1.11 src/usr.bin/xlint/lint1/ckgetopt.c:1.12
--- src/usr.bin/xlint/lint1/ckgetopt.c:1.11	Sun Aug 22 22:15:07 2021
+++ src/usr.bin/xlint/lint1/ckgetopt.c	Sat Oct  9 14:22:42 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ckgetopt.c,v 1.11 2021/08/22 22:15:07 rillig Exp $ */
+/* $NetBSD: ckgetopt.c,v 1.12 2021/10/09 14:22:42 rillig Exp $ */
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: ckgetopt.c,v 1.11 2021/08/22 22:15:07 rillig Exp $");
+__RCSID("$NetBSD: ckgetopt.c,v 1.12 2021/10/09 14:22:42 rillig Exp $");
 #endif
 
 #include 
@@ -113,13 +113,16 @@ check_unlisted_option(char opt)
 {
 	lint_assert(ck.options != NULL);
 
+	if (opt == ':' && ck.options[0] != ':')
+		goto warn;
+
 	char *optptr = strchr(ck.options, opt);
 	if (optptr != NULL)
 		*optptr = ' ';
 	else if (opt != '?') {
+	warn:
 		/* option '%c' should be listed in the options string */
 		warning(339, opt);
-		return;
 	}
 }
 



CVS commit: src

2021-10-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct  9 14:22:42 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_338.c msg_338.exp
src/usr.bin/xlint/lint1: ckgetopt.c

Log Message:
lint: warn if a getopt switch tries to handle unreachable ':'


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/msg_338.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_338.exp
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/xlint/lint1/ckgetopt.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/xlint/lint1

2021-10-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct  9 13:57:55 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_338.c msg_338.exp

Log Message:
tests/lint: test getopt with an options string starting with ':'


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_338.c
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_338.exp

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/xlint/lint1/msg_338.c
diff -u src/tests/usr.bin/xlint/lint1/msg_338.c:1.5 src/tests/usr.bin/xlint/lint1/msg_338.c:1.6
--- src/tests/usr.bin/xlint/lint1/msg_338.c:1.5	Sun Aug 22 22:15:07 2021
+++ src/tests/usr.bin/xlint/lint1/msg_338.c	Sat Oct  9 13:57:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_338.c,v 1.5 2021/08/22 22:15:07 rillig Exp $	*/
+/*	$NetBSD: msg_338.c,v 1.6 2021/10/09 13:57:55 rillig Exp $	*/
 # 3 "msg_338.c"
 
 // Test for message: option '%c' should be handled in the switch [338]
@@ -79,3 +79,74 @@ question_option(int argc, char **argv)
 	}
 	return 0;
 }
+
+/*
+ * If the first character of the options string is ':', getopt does not print
+ * its own error messages. Getopt returns ':' if an option is missing its
+ * argument; that is handled by the 'default:' already.
+ */
+int
+suppress_errors(int argc, char **argv)
+{
+	int c;
+
+	/* expect+1: warning: option 'o' should be handled in the switch [338] */
+	while ((c = getopt(argc, argv, ":b:o")) != -1) {
+		switch (c) {
+		case 'b':
+			return 'b';
+		default:
+			usage();
+		}
+	}
+	return 0;
+}
+
+/*
+ * If the first character of the options string is ':', getopt returns ':'
+ * if an option is missing its argument. This condition can be handled
+ * separately from '?', which getopt returns for unknown options.
+ */
+int
+missing_argument(int argc, char **argv)
+{
+	int c;
+
+	/* expect+1: warning: option 'o' should be handled in the switch [338] */
+	while ((c = getopt(argc, argv, ":b:o")) != -1) {
+		switch (c) {
+		case 'b':
+			return 'b';
+		case ':':
+			return 'm';
+		default:
+			usage();
+		}
+	}
+	return 0;
+}
+
+/*
+ * Getopt only returns ':' if ':' is the first character in the options
+ * string. Everywhere else, a ':' marks the preceding option as having a
+ * required argument. In theory, if the options string contained "a::x",
+ * that could be interpreted as '-a argument', followed by '-:' and '-x',
+ * but nobody does that.
+ */
+int
+unreachable_colon(int argc, char **argv)
+{
+	int c;
+
+	/* expect+1: warning: option 'b' should be handled in the switch [338] */
+	while ((c = getopt(argc, argv, "b:")) != -1) {
+		switch (c) {
+		/* TODO: expect+1: warning: option ':' should be listed in the options string [339] */
+		case ':':
+			return 'm';
+		default:
+			usage();
+		}
+	}
+	return 0;
+}

Index: src/tests/usr.bin/xlint/lint1/msg_338.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_338.exp:1.3 src/tests/usr.bin/xlint/lint1/msg_338.exp:1.4
--- src/tests/usr.bin/xlint/lint1/msg_338.exp:1.3	Sun Aug 22 22:15:07 2021
+++ src/tests/usr.bin/xlint/lint1/msg_338.exp	Sat Oct  9 13:57:55 2021
@@ -2,3 +2,6 @@ msg_338.c(26): warning: option 'e' shoul
 msg_338.c(28): warning: option 'f' should be listed in the options string [339]
 msg_338.c(14): warning: option 'c' should be handled in the switch [338]
 msg_338.c(14): warning: option 'd' should be handled in the switch [338]
+msg_338.c(94): warning: option 'o' should be handled in the switch [338]
+msg_338.c(116): warning: option 'o' should be handled in the switch [338]
+msg_338.c(142): warning: option 'b' should be handled in the switch [338]



CVS commit: src/tests/usr.bin/xlint/lint1

2021-10-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct  9 13:57:55 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_338.c msg_338.exp

Log Message:
tests/lint: test getopt with an options string starting with ':'


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_338.c
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_338.exp

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-09 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct  9 13:09:17 UTC 2021

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

Log Message:
efiboot: add "setup" command

The "setup" command sets the 64-bit "OsIndications" variable to the value of
EFI_OS_INDICATIONS_BOOT_TO_FW_UI and requests a reboot. On firmware that
supports this, after reboot the user will be presented with the firmware
setup menu.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/stand/efiboot/boot.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/boot.c
diff -u src/sys/stand/efiboot/boot.c:1.38 src/sys/stand/efiboot/boot.c:1.39
--- src/sys/stand/efiboot/boot.c:1.38	Wed Oct  6 10:13:19 2021
+++ src/sys/stand/efiboot/boot.c	Sat Oct  9 13:09:17 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.38 2021/10/06 10:13:19 jmcneill Exp $	*/
+/*	$NetBSD: boot.c,v 1.39 2021/10/09 13:09:17 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -111,6 +111,7 @@ void	command_gop(char *);
 void	command_mem(char *);
 void	command_menu(char *);
 void	command_reset(char *);
+void	command_setup(char *);
 void	command_version(char *);
 void	command_quit(char *);
 
@@ -134,6 +135,7 @@ const struct boot_command commands[] = {
 	{ "menu",	command_menu,		"menu" },
 	{ "reboot",	command_reset,		"reboot|reset" },
 	{ "reset",	command_reset,		NULL },
+	{ "setup",	command_setup,		"setup" },
 	{ "version",	command_version,	"version" },
 	{ "ver",	command_version,	NULL },
 	{ "help",	command_help,		"help|?" },
@@ -355,6 +357,7 @@ command_version(char *arg)
 {
 	char pathbuf[80];
 	char *ufirmware;
+	const UINT64 *osindsup;
 	int rv;
 
 	printf("Version: %s (%s)\n", bootprog_rev, bootprog_kernrev);
@@ -371,6 +374,11 @@ command_version(char *arg)
 		printf("Config path: %s\n", pathbuf);
 	}
 
+	osindsup = LibGetVariable(L"OsIndicationsSupported", );
+	if (osindsup != NULL) {
+		printf("UEFI OS indications supported: 0x%" PRIx64 "\n", *osindsup);
+	}
+
 #ifdef EFIBOOT_FDT
 	efi_fdt_show();
 #endif
@@ -394,6 +402,29 @@ command_reset(char *arg)
 	efi_reboot();
 }
 
+void
+command_setup(char *arg)
+{
+	EFI_STATUS status;
+	const UINT64 *osindsup;
+	UINT64 osind;
+
+	osindsup = LibGetVariable(L"OsIndicationsSupported", );
+	if (osindsup == NULL || (*osindsup & EFI_OS_INDICATIONS_BOOT_TO_FW_UI) == 0) {
+		printf("Not supported by firmware\n");
+		return;
+	}
+
+	osind = EFI_OS_INDICATIONS_BOOT_TO_FW_UI;
+	status = LibSetNVVariable(L"OsIndications", , sizeof(osind), );
+	if (EFI_ERROR(status)) {
+		printf("Failed to set OsIndications variable: %lu\n", (u_long)status);
+		return;
+	}
+
+	efi_reboot();
+}
+
 int
 set_default_device(const char *arg)
 {



CVS commit: src/sys/stand/efiboot

2021-10-09 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct  9 13:09:17 UTC 2021

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

Log Message:
efiboot: add "setup" command

The "setup" command sets the 64-bit "OsIndications" variable to the value of
EFI_OS_INDICATIONS_BOOT_TO_FW_UI and requests a reboot. On firmware that
supports this, after reboot the user will be presented with the firmware
setup menu.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/stand/efiboot/boot.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-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct  9 11:13:25 UTC 2021

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

Log Message:
indent: condense code for calculating indentations

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.136 -r1.137 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.91 -r1.92 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.c
diff -u src/usr.bin/indent/indent.c:1.136 src/usr.bin/indent/indent.c:1.137
--- src/usr.bin/indent/indent.c:1.136	Sat Oct  9 11:00:27 2021
+++ src/usr.bin/indent/indent.c	Sat Oct  9 11:13:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.136 2021/10/09 11:00:27 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.137 2021/10/09 11:13: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.136 2021/10/09 11:00:27 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.137 2021/10/09 11:13:25 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -572,18 +572,16 @@ main_prepare_parsing(void)
 
 parse(semicolon);
 
-char *p = inp.s;
 int ind = 0;
-
-for (;;) {
+for (const char *p = inp.s;; p++) {
 	if (*p == ' ')
 	ind++;
 	else if (*p == '\t')
 	ind = next_tab(ind);
 	else
 	break;
-	p++;
 }
+
 if (ind >= opt.indent_size)
 	ps.ind_level = ps.ind_level_follow = ind / opt.indent_size;
 }
@@ -591,7 +589,7 @@ main_prepare_parsing(void)
 static void
 indent_declaration(int cur_decl_ind, bool tabs_to_var)
 {
-int pos = (int)buf_len();
+int ind = (int)buf_len();
 char *orig_code_e = code.e;
 
 /*
@@ -599,23 +597,17 @@ indent_declaration(int cur_decl_ind, boo
  * tabsize
  */
 if ((ps.ind_level * opt.indent_size) % opt.tabsize != 0) {
-	pos += (ps.ind_level * opt.indent_size) % opt.tabsize;
+	ind += (ps.ind_level * opt.indent_size) % opt.tabsize;
 	cur_decl_ind += (ps.ind_level * opt.indent_size) % opt.tabsize;
 }
 
 if (tabs_to_var) {
-	int tpos;
-
-	while ((tpos = next_tab(pos)) <= cur_decl_ind) {
+	for (int next; (next = next_tab(ind)) <= cur_decl_ind; ind = next)
 	buf_add_char(, '\t');
-	pos = tpos;
-	}
 }
 
-while (pos < cur_decl_ind) {
+for (; ind < cur_decl_ind; ind++)
 	buf_add_char(, ' ');
-	pos++;
-}
 
 if (code.e == orig_code_e && ps.want_blank) {
 	*code.e++ = ' ';

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.91 src/usr.bin/indent/io.c:1.92
--- src/usr.bin/indent/io.c:1.91	Sat Oct  9 11:00:27 2021
+++ src/usr.bin/indent/io.c	Sat Oct  9 11:13:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.91 2021/10/09 11:00:27 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.92 2021/10/09 11:13:25 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.91 2021/10/09 11:00:27 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.92 2021/10/09 11:13:25 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -177,22 +177,23 @@ static void
 dump_line_comment(int ind)
 {
 int target_ind = ps.com_ind;
-char *com_st = com.s;
+const char *p = com.s;
 
 target_ind += ps.comment_delta;
 
 /* consider original indentation in case this is a box comment */
-while (*com_st == '\t')
-	com_st++, target_ind += opt.tabsize;
+for (; *p == '\t'; p++)
+	target_ind += opt.tabsize;
 
-while (target_ind < 0) {
-	if (*com_st == ' ')
-	target_ind++, com_st++;
-	else if (*com_st == '\t') {
+for (; target_ind < 0; p++) {
+	if (*p == ' ')
+	target_ind++;
+	else if (*p == '\t')
 	target_ind = next_tab(target_ind);
-	com_st++;
-	} else
+	else {
 	target_ind = 0;
+	break;
+	}
 }
 
 /* if comment can't fit on this line, put it on next line */
@@ -202,11 +203,11 @@ dump_line_comment(int ind)
 	ps.stats.lines++;
 }
 
-while (com.e > com_st && isspace((unsigned char)com.e[-1]))
+while (com.e > p && isspace((unsigned char)com.e[-1]))
 	com.e--;
 
 (void)output_indent(ind, target_ind);
-output_range(com_st, com.e);
+output_range(p, com.e);
 
 ps.comment_delta = ps.n_comment_delta;
 ps.stats.comment_lines++;



CVS commit: src/usr.bin/indent

2021-10-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct  9 11:13:25 UTC 2021

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

Log Message:
indent: condense code for calculating indentations

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.136 -r1.137 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.91 -r1.92 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-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct  9 11:00:27 UTC 2021

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

Log Message:
indent: extract common code for advancing a single tab

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.135 -r1.136 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.37 -r1.38 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.90 -r1.91 src/usr.bin/indent/io.c
cvs rdiff -u -r1.68 -r1.69 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/indent.c
diff -u src/usr.bin/indent/indent.c:1.135 src/usr.bin/indent/indent.c:1.136
--- src/usr.bin/indent/indent.c:1.135	Fri Oct  8 23:47:40 2021
+++ src/usr.bin/indent/indent.c	Sat Oct  9 11:00:27 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.135 2021/10/08 23:47:40 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.136 2021/10/09 11:00:27 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.135 2021/10/08 23:47:40 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.136 2021/10/09 11:00:27 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -579,7 +579,7 @@ main_prepare_parsing(void)
 	if (*p == ' ')
 	ind++;
 	else if (*p == '\t')
-	ind = opt.tabsize * (1 + ind / opt.tabsize);
+	ind = next_tab(ind);
 	else
 	break;
 	p++;
@@ -606,7 +606,7 @@ indent_declaration(int cur_decl_ind, boo
 if (tabs_to_var) {
 	int tpos;
 
-	while ((tpos = opt.tabsize * (1 + pos / opt.tabsize)) <= cur_decl_ind) {
+	while ((tpos = next_tab(pos)) <= cur_decl_ind) {
 	buf_add_char(, '\t');
 	pos = tpos;
 	}

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.37 src/usr.bin/indent/indent.h:1.38
--- src/usr.bin/indent/indent.h:1.37	Fri Oct  8 23:43:33 2021
+++ src/usr.bin/indent/indent.h	Sat Oct  9 11:00:27 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.37 2021/10/08 23:43:33 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.38 2021/10/09 11:00:27 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -367,3 +367,9 @@ is_hspace(char ch)
 {
 return ch == ' ' || ch == '\t';
 }
+
+static inline int
+next_tab(int ind)
+{
+return ind - ind % opt.tabsize + opt.tabsize;
+}

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.90 src/usr.bin/indent/io.c:1.91
--- src/usr.bin/indent/io.c:1.90	Fri Oct  8 21:16:23 2021
+++ src/usr.bin/indent/io.c	Sat Oct  9 11:00:27 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.90 2021/10/08 21:16:23 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.91 2021/10/09 11:00:27 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.90 2021/10/08 21:16:23 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.91 2021/10/09 11:00:27 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -189,7 +189,7 @@ dump_line_comment(int ind)
 	if (*com_st == ' ')
 	target_ind++, com_st++;
 	else if (*com_st == '\t') {
-	target_ind = opt.tabsize * (1 + target_ind / opt.tabsize);
+	target_ind = next_tab(target_ind);
 	com_st++;
 	} else
 	target_ind = 0;
@@ -473,7 +473,7 @@ indentation_after_range(int ind, const c
 	if (*p == '\n' || *p == '\f')
 	ind = 0;
 	else if (*p == '\t')
-	ind = opt.tabsize * (ind / opt.tabsize + 1);
+	ind = next_tab(ind);
 	else if (*p == '\b')
 	--ind;
 	else

Index: src/usr.bin/indent/pr_comment.c
diff -u src/usr.bin/indent/pr_comment.c:1.68 src/usr.bin/indent/pr_comment.c:1.69
--- src/usr.bin/indent/pr_comment.c:1.68	Fri Oct  8 22:37:33 2021
+++ src/usr.bin/indent/pr_comment.c	Sat Oct  9 11:00:27 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pr_comment.c,v 1.68 2021/10/08 22:37:33 rillig Exp $	*/
+/*	$NetBSD: pr_comment.c,v 1.69 2021/10/09 11:00:27 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.68 2021/10/08 22:37:33 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.69 2021/10/09 11:00:27 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -131,7 +131,7 @@ process_comment(void)
 	ps.com_ind = ps.decl_on_line || ps.ind_level == 0
 		? opt.decl_comment_column - 1 : opt.comment_column - 1;
 	if (ps.com_ind <= target_ind)
-		ps.com_ind = opt.tabsize * (1 + target_ind / opt.tabsize);
+		ps.com_ind = next_tab(target_ind);
 	/* XXX: the '+ 1' smells like an off-by-one error */

CVS commit: src/usr.bin/indent

2021-10-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct  9 11:00:27 UTC 2021

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

Log Message:
indent: extract common code for advancing a single tab

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.135 -r1.136 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.37 -r1.38 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.90 -r1.91 src/usr.bin/indent/io.c
cvs rdiff -u -r1.68 -r1.69 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-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct  9 10:56:13 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token-preprocessing.0
token-preprocessing.0.stdout

Log Message:
tests/indent: test fixing of invalid preprocessor directives


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/indent/token-preprocessing.0
cvs rdiff -u -r1.7 -r1.8 \
src/tests/usr.bin/indent/token-preprocessing.0.stdout

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-preprocessing.0
diff -u src/tests/usr.bin/indent/token-preprocessing.0:1.5 src/tests/usr.bin/indent/token-preprocessing.0:1.6
--- src/tests/usr.bin/indent/token-preprocessing.0:1.5	Fri Oct  8 21:32:28 2021
+++ src/tests/usr.bin/indent/token-preprocessing.0	Sat Oct  9 10:56:13 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token-preprocessing.0,v 1.5 2021/10/08 21:32:28 rillig Exp $ */
+/* $NetBSD: token-preprocessing.0,v 1.6 2021/10/09 10:56:13 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*-
@@ -68,3 +68,27 @@ int binary_plus = 3
 int unary_plus =
 #define intermediate 1
 	+ 4;
+
+/*
+ * Preprocessing lines that don't expect an argument but have one are fixed.
+ * They are indented with a single tab.
+ */
+#if 0
+#elif 1
+#else if 3
+#endif 0
+
+/*
+ * Existing comments are indented just like code comments.
+ *
+ * This means that the above wrong preprocessing lines need to be fed through
+ * indent twice until they become stable. Since compilers issue warnings about
+ * these invalid lines, not much code still has these.
+ */
+#if 0		/* comment */
+#else		/* comment */
+#endif		/* comment */
+
+#if 0/* comment */
+#else/* comment */
+#endif/* comment */

Index: src/tests/usr.bin/indent/token-preprocessing.0.stdout
diff -u src/tests/usr.bin/indent/token-preprocessing.0.stdout:1.7 src/tests/usr.bin/indent/token-preprocessing.0.stdout:1.8
--- src/tests/usr.bin/indent/token-preprocessing.0.stdout:1.7	Fri Oct  8 21:32:28 2021
+++ src/tests/usr.bin/indent/token-preprocessing.0.stdout	Sat Oct  9 10:56:13 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token-preprocessing.0.stdout,v 1.7 2021/10/08 21:32:28 rillig Exp $ */
+/* $NetBSD: token-preprocessing.0.stdout,v 1.8 2021/10/09 10:56:13 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*-
@@ -69,3 +69,27 @@ int		binary_plus = 3
 int		unary_plus =
 #define intermediate 1
 +4;
+
+/*
+ * Preprocessing lines that don't expect an argument but have one are fixed.
+ * They are indented with a single tab.
+ */
+#if 0
+#elif 1
+#else	/* if 3 */
+#endif	/* 0 */
+
+/*
+ * Existing comments are indented just like code comments.
+ *
+ * This means that the above wrong preprocessing lines need to be fed through
+ * indent twice until they become stable. Since compilers issue warnings about
+ * these invalid lines, not much code still has these.
+ */
+#if 0/* comment */
+#else/* comment */
+#endif/* comment */
+
+#if 0/* comment */
+#else/* comment */
+#endif/* comment */



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

2021-10-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct  9 10:56:13 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token-preprocessing.0
token-preprocessing.0.stdout

Log Message:
tests/indent: test fixing of invalid preprocessor directives


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/indent/token-preprocessing.0
cvs rdiff -u -r1.7 -r1.8 \
src/tests/usr.bin/indent/token-preprocessing.0.stdout

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



CVS commit: src/usr.bin/ftp

2021-10-09 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sat Oct  9 09:07:21 UTC 2021

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

Log Message:
ftp: fix -? more portably

Start the optstring with ":" (which implicitly disables opterr),
and handle '?' with optopt=='?' separately to ':'.
Fixes -? display of full usage on other platforms.


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.128 src/usr.bin/ftp/main.c

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

Modified files:

Index: src/usr.bin/ftp/main.c
diff -u src/usr.bin/ftp/main.c:1.127 src/usr.bin/ftp/main.c:1.128
--- src/usr.bin/ftp/main.c:1.127	Sat Jul 18 03:00:37 2020
+++ src/usr.bin/ftp/main.c	Sat Oct  9 09:07:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.127 2020/07/18 03:00:37 lukem Exp $	*/
+/*	$NetBSD: main.c,v 1.128 2021/10/09 09:07:20 lukem Exp $	*/
 
 /*-
  * Copyright (c) 1996-2015 The NetBSD Foundation, Inc.
@@ -98,7 +98,7 @@ __COPYRIGHT("@(#) Copyright (c) 1985, 19
 #if 0
 static char sccsid[] = "@(#)main.c	8.6 (Berkeley) 10/9/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.127 2020/07/18 03:00:37 lukem Exp $");
+__RCSID("$NetBSD: main.c,v 1.128 2021/10/09 09:07:20 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -267,7 +267,7 @@ main(int volatile argc, char **volatile 
 		}
 	}
 
-	while ((ch = getopt(argc, argv, "?46AadefginN:o:pP:q:r:Rs:tT:u:vVx:")) != -1) {
+	while ((ch = getopt(argc, argv, ":46AadefginN:o:pP:q:r:Rs:tT:u:vVx:")) != -1) {
 		switch (ch) {
 		case '4':
 			family = AF_INET;
@@ -420,6 +420,11 @@ main(int volatile argc, char **volatile 
 			if (optopt == '?') {
 return usage_help();
 			}
+			warnx("-%c: unknown option", optopt);
+			return usage();
+
+		case ':':
+			warnx("-%c: missing argument", optopt);
 			return usage();
 
 		default:



CVS commit: src/usr.bin/ftp

2021-10-09 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sat Oct  9 09:07:21 UTC 2021

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

Log Message:
ftp: fix -? more portably

Start the optstring with ":" (which implicitly disables opterr),
and handle '?' with optopt=='?' separately to ':'.
Fixes -? display of full usage on other platforms.


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.128 src/usr.bin/ftp/main.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/sysinst

2021-10-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Oct  9 09:06:28 UTC 2021

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

Log Message:
Consistent #if for static helper function add_entropy


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/sysinst/configmenu.c

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

Modified files:

Index: src/usr.sbin/sysinst/configmenu.c
diff -u src/usr.sbin/sysinst/configmenu.c:1.13 src/usr.sbin/sysinst/configmenu.c:1.14
--- src/usr.sbin/sysinst/configmenu.c:1.13	Fri Oct  8 15:59:55 2021
+++ src/usr.sbin/sysinst/configmenu.c	Sat Oct  9 09:06:28 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: configmenu.c,v 1.13 2021/10/08 15:59:55 martin Exp $ */
+/* $NetBSD: configmenu.c,v 1.14 2021/10/09 09:06:28 martin Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -45,7 +45,9 @@ static int set_timezone_menu(struct menu
 static int set_root_shell(struct menudesc *, void *);
 static int change_root_password(struct menudesc *, void *);
 static int add_new_user(struct menudesc *, void *);
+#if CHECK_ENTROPY
 static int add_entropy(struct menudesc *, void *);
+#endif
 static int set_binpkg(struct menudesc *, void *);
 static int set_pkgsrc(struct menudesc *, void *);
 static void config_list_init(void);



CVS commit: src/usr.sbin/sysinst

2021-10-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Oct  9 09:06:28 UTC 2021

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

Log Message:
Consistent #if for static helper function add_entropy


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/sysinst/configmenu.c

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



CVS commit: src/share/man/man4/man4.amiga

2021-10-09 Thread Jukka Andberg
Module Name:src
Committed By:   jandberg
Date:   Sat Oct  9 08:25:33 UTC 2021

Modified Files:
src/share/man/man4/man4.amiga: amidisplaycc.4

Log Message:
Update documentation to mention current status of X11


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/share/man/man4/man4.amiga/amidisplaycc.4

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



CVS commit: src/share/man/man4/man4.amiga

2021-10-09 Thread Jukka Andberg
Module Name:src
Committed By:   jandberg
Date:   Sat Oct  9 08:25:33 UTC 2021

Modified Files:
src/share/man/man4/man4.amiga: amidisplaycc.4

Log Message:
Update documentation to mention current status of X11


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/share/man/man4/man4.amiga/amidisplaycc.4

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

Modified files:

Index: src/share/man/man4/man4.amiga/amidisplaycc.4
diff -u src/share/man/man4/man4.amiga/amidisplaycc.4:1.13 src/share/man/man4/man4.amiga/amidisplaycc.4:1.14
--- src/share/man/man4/man4.amiga/amidisplaycc.4:1.13	Sun Feb  7 14:06:04 2016
+++ src/share/man/man4/man4.amiga/amidisplaycc.4	Sat Oct  9 08:25:33 2021
@@ -22,7 +22,7 @@
 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.\" $NetBSD: amidisplaycc.4,v 1.13 2016/02/07 14:06:04 wiz Exp $
+.\" $NetBSD: amidisplaycc.4,v 1.14 2021/10/09 08:25:33 jandberg Exp $
 .Dd November 12, 2003
 .Dt AMIDISPLAYCC 4 amiga
 .Os
@@ -43,11 +43,9 @@ operate a text terminal with virtual scr
 It uses the Amiga abstract graphic driver (grfabs) functions for
 the low-level display management.
 .Pp
-Currently it does not support running X.
-It can however coexist well enough with grf0 to make possible running
-X the old way, but be warned, you cannot switch screens while
-in X and when quitting it, it seems to hang.
-Switching a screen then will bring up the text console.
+The X11 server works in monochrome mode using the
+.Xr wsfb 4
+driver.
 .Pp
 It supports foreground and background color, and the hilite (bold),
 underline, and reverse text attributes.



CVS commit: src/usr.sbin/sysinst/arch/mipsco

2021-10-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Oct  9 08:21:03 UTC 2021

Modified Files:
src/usr.sbin/sysinst/arch/mipsco: Makefile

Log Message:
Disable some installer options to shrink the ramdisk image


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/sysinst/arch/mipsco/Makefile

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

Modified files:

Index: src/usr.sbin/sysinst/arch/mipsco/Makefile
diff -u src/usr.sbin/sysinst/arch/mipsco/Makefile:1.1 src/usr.sbin/sysinst/arch/mipsco/Makefile:1.2
--- src/usr.sbin/sysinst/arch/mipsco/Makefile:1.1	Sat Jul 26 19:30:46 2014
+++ src/usr.sbin/sysinst/arch/mipsco/Makefile	Sat Oct  9 08:21:03 2021
@@ -1,6 +1,11 @@
-#	$NetBSD: Makefile,v 1.1 2014/07/26 19:30:46 dholland Exp $
+#	$NetBSD: Makefile,v 1.2 2021/10/09 08:21:03 martin Exp $
 #
 # Makefile for mipsco
 #
 
+.ifdef SMALLPROG
+NOPARTMAN=	yes
+NO_CLONES=	yes
+.endif
+
 .include "../../Makefile.inc"



CVS commit: src/usr.sbin/sysinst/arch/mipsco

2021-10-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Oct  9 08:21:03 UTC 2021

Modified Files:
src/usr.sbin/sysinst/arch/mipsco: Makefile

Log Message:
Disable some installer options to shrink the ramdisk image


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/sysinst/arch/mipsco/Makefile

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



CVS commit: src

2021-10-09 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Sat Oct  9 07:01:35 UTC 2021

Modified Files:
src/distrib/sets/lists/debug: module.ad.aarch64
src/distrib/sets/lists/modules: ad.aarch64
src/sys/compat/linux/arch/aarch64: linux_machdep.c
src/sys/modules: Makefile
src/sys/modules/compat_linux: Makefile

Log Message:
Modularize compat_linux(8) for aarch64.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/distrib/sets/lists/debug/module.ad.aarch64
cvs rdiff -u -r1.8 -r1.9 src/distrib/sets/lists/modules/ad.aarch64
cvs rdiff -u -r1.1 -r1.2 src/sys/compat/linux/arch/aarch64/linux_machdep.c
cvs rdiff -u -r1.257 -r1.258 src/sys/modules/Makefile
cvs rdiff -u -r1.5 -r1.6 src/sys/modules/compat_linux/Makefile

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/debug/module.ad.aarch64
diff -u src/distrib/sets/lists/debug/module.ad.aarch64:1.2 src/distrib/sets/lists/debug/module.ad.aarch64:1.3
--- src/distrib/sets/lists/debug/module.ad.aarch64:1.2	Sun Nov  1 18:51:34 2020
+++ src/distrib/sets/lists/debug/module.ad.aarch64	Sat Oct  9 07:01:34 2021
@@ -1,6 +1,8 @@
-# $NetBSD: module.ad.aarch64,v 1.2 2020/11/01 18:51:34 pgoyette Exp $
+# $NetBSD: module.ad.aarch64,v 1.3 2021/10/09 07:01:34 ryo Exp $
 ./usr/libdata/debug/@MODULEDIR@/bpfjitmodules-base-kernel	kmod,sljit,debug
 ./usr/libdata/debug/@MODULEDIR@/bpfjit/bpfjit.kmod.debug		modules-base-kernel	kmod,sljit,debug
+./usr/libdata/debug/@MODULEDIR@/compat_linux			modules-base-kernel	kmod,debug
+./usr/libdata/debug/@MODULEDIR@/compat_linux/compat_linux.kmod.debug	modules-base-kernel	kmod,debug
 ./usr/libdata/debug/@MODULEDIR@/compat_netbsd32			modules-base-kernel	kmod,debug
 ./usr/libdata/debug/@MODULEDIR@/compat_netbsd32/compat_netbsd32.kmod.debug modules-base-kernel	kmod,debug
 ./usr/libdata/debug/@MODULEDIR@/compat_netbsd32_09		modules-base-kernel	kmod,debug

Index: src/distrib/sets/lists/modules/ad.aarch64
diff -u src/distrib/sets/lists/modules/ad.aarch64:1.8 src/distrib/sets/lists/modules/ad.aarch64:1.9
--- src/distrib/sets/lists/modules/ad.aarch64:1.8	Sun Nov  1 18:51:34 2020
+++ src/distrib/sets/lists/modules/ad.aarch64	Sat Oct  9 07:01:34 2021
@@ -1,6 +1,8 @@
-# $NetBSD: ad.aarch64,v 1.8 2020/11/01 18:51:34 pgoyette Exp $
+# $NetBSD: ad.aarch64,v 1.9 2021/10/09 07:01:34 ryo Exp $
 ./@MODULEDIR@/bpfjitmodules-base-kernel	kmod,sljit
 ./@MODULEDIR@/bpfjit/bpfjit.kmod		modules-base-kernel	kmod,sljit
+./@MODULEDIR@/compat_linux			modules-base-kernel	kmod
+./@MODULEDIR@/compat_linux/compat_linux.kmod	modules-base-kernel	kmod
 ./@MODULEDIR@/compat_netbsd32			modules-base-kernel	kmod
 ./@MODULEDIR@/compat_netbsd32/compat_netbsd32.kmod modules-base-kernel	kmod
 ./@MODULEDIR@/compat_netbsd32_09		modules-base-kernel	kmod

Index: src/sys/compat/linux/arch/aarch64/linux_machdep.c
diff -u src/sys/compat/linux/arch/aarch64/linux_machdep.c:1.1 src/sys/compat/linux/arch/aarch64/linux_machdep.c:1.2
--- src/sys/compat/linux/arch/aarch64/linux_machdep.c:1.1	Thu Sep 23 06:56:27 2021
+++ src/sys/compat/linux/arch/aarch64/linux_machdep.c	Sat Oct  9 07:01:34 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_machdep.c,v 1.1 2021/09/23 06:56:27 ryo Exp $	*/
+/*	$NetBSD: linux_machdep.c,v 1.2 2021/10/09 07:01:34 ryo Exp $	*/
 
 /*-
  * Copyright (c) 2021 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.1 2021/09/23 06:56:27 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.2 2021/10/09 07:01:34 ryo Exp $");
 
 #include 
 #include 
@@ -42,6 +42,8 @@ __KERNEL_RCSID(0, "$NetBSD: linux_machde
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 

Index: src/sys/modules/Makefile
diff -u src/sys/modules/Makefile:1.257 src/sys/modules/Makefile:1.258
--- src/sys/modules/Makefile:1.257	Sun Oct  3 17:27:02 2021
+++ src/sys/modules/Makefile	Sat Oct  9 07:01:34 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.257 2021/10/03 17:27:02 brad Exp $
+#	$NetBSD: Makefile,v 1.258 2021/10/09 07:01:34 ryo Exp $
 
 .include 
 
@@ -361,6 +361,10 @@ SUBDIR+=	lm_wbsio
 SUBDIR+=	wbsio
 .endif
 
+.if ${MACHINE_CPU} == "aarch64"
+SUBDIR+=	compat_linux
+.endif
+
 .if ${MACHINE_CPU} == "m68k"
 SUBDIR+=	compat_aoutm68k
 #SUBDIR+=	compat_linux

Index: src/sys/modules/compat_linux/Makefile
diff -u src/sys/modules/compat_linux/Makefile:1.5 src/sys/modules/compat_linux/Makefile:1.6
--- src/sys/modules/compat_linux/Makefile:1.5	Sun Feb 17 04:05:45 2019
+++ src/sys/modules/compat_linux/Makefile	Sat Oct  9 07:01:35 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.5 2019/02/17 04:05:45 rin Exp $
+#	$NetBSD: Makefile,v 1.6 2021/10/09 07:01:35 ryo Exp $
 
 .include "../Makefile.inc"
 .include "../Makefile.assym"
@@ -14,6 +14,15 @@ SRCS+=	linux_ipc.c linux_misc.c linux_mt
 SRCS+=	linux_sg.c linux_signal.c linux_signo.c linux_socket.c
 SRCS+=	linux_sysctl.c linux_termios.c linux_time.c 

CVS commit: src

2021-10-09 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Sat Oct  9 07:01:35 UTC 2021

Modified Files:
src/distrib/sets/lists/debug: module.ad.aarch64
src/distrib/sets/lists/modules: ad.aarch64
src/sys/compat/linux/arch/aarch64: linux_machdep.c
src/sys/modules: Makefile
src/sys/modules/compat_linux: Makefile

Log Message:
Modularize compat_linux(8) for aarch64.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/distrib/sets/lists/debug/module.ad.aarch64
cvs rdiff -u -r1.8 -r1.9 src/distrib/sets/lists/modules/ad.aarch64
cvs rdiff -u -r1.1 -r1.2 src/sys/compat/linux/arch/aarch64/linux_machdep.c
cvs rdiff -u -r1.257 -r1.258 src/sys/modules/Makefile
cvs rdiff -u -r1.5 -r1.6 src/sys/modules/compat_linux/Makefile

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