CVS commit: src/sys/kern

2023-04-15 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Apr 16 04:52:19 UTC 2023

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

Log Message:
pserialize(9): Fix buggy assertion inside assertion.

If there has been a context switch, then we can't be in a pserialize
read section -- _and_ whatever we read out of curcpu() is stale, so
we can't assert anything based on it.  So just delete the assertion.

Reported-by: syzbot+d7065ab16d7cd9cc0...@syzkaller.appspotmail.com
https://syzkaller.appspot.com/bug?id=0c63db890575d29c6a51fb24b003d3bab1f7f04b


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/kern/subr_pserialize.c

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

Modified files:

Index: src/sys/kern/subr_pserialize.c
diff -u src/sys/kern/subr_pserialize.c:1.22 src/sys/kern/subr_pserialize.c:1.23
--- src/sys/kern/subr_pserialize.c:1.22	Fri Apr 14 16:51:46 2023
+++ src/sys/kern/subr_pserialize.c	Sun Apr 16 04:52:19 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_pserialize.c,v 1.22 2023/04/14 16:51:46 riastradh Exp $	*/
+/*	$NetBSD: subr_pserialize.c,v 1.23 2023/04/16 04:52:19 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_pserialize.c,v 1.22 2023/04/14 16:51:46 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pserialize.c,v 1.23 2023/04/16 04:52:19 riastradh Exp $");
 
 #include 
 
@@ -188,10 +188,8 @@ pserialize_not_in_read_section(void)
 	 * pserialize read section because pserialize read sections
 	 * block preemption.
 	 */
-	if (__predict_false(ncsw != l->l_ncsw)) {
-		KDASSERT(notin);
+	if (__predict_false(ncsw != l->l_ncsw))
 		notin = true;
-	}
 
 	return notin;
 }



CVS commit: src/sys/kern

2023-04-15 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Apr 16 04:52:19 UTC 2023

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

Log Message:
pserialize(9): Fix buggy assertion inside assertion.

If there has been a context switch, then we can't be in a pserialize
read section -- _and_ whatever we read out of curcpu() is stale, so
we can't assert anything based on it.  So just delete the assertion.

Reported-by: syzbot+d7065ab16d7cd9cc0...@syzkaller.appspotmail.com
https://syzkaller.appspot.com/bug?id=0c63db890575d29c6a51fb24b003d3bab1f7f04b


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/kern/subr_pserialize.c

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



CVS commit: src/doc

2023-04-15 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Apr 15 18:16:28 UTC 2023

Modified Files:
src/doc: CHANGES.prev

Log Message:
Fix a wrong year in r1.168.  Pointed out by Nishi.


To generate a diff of this commit:
cvs rdiff -u -r1.168 -r1.169 src/doc/CHANGES.prev

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



CVS commit: src/doc

2023-04-15 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Apr 15 18:16:28 UTC 2023

Modified Files:
src/doc: CHANGES.prev

Log Message:
Fix a wrong year in r1.168.  Pointed out by Nishi.


To generate a diff of this commit:
cvs rdiff -u -r1.168 -r1.169 src/doc/CHANGES.prev

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

Modified files:

Index: src/doc/CHANGES.prev
diff -u src/doc/CHANGES.prev:1.168 src/doc/CHANGES.prev:1.169
--- src/doc/CHANGES.prev:1.168	Fri Mar 10 18:26:46 2023
+++ src/doc/CHANGES.prev	Sat Apr 15 18:16:28 2023
@@ -1,4 +1,4 @@
-LIST OF CHANGES FROM PREVIOUS RELEASES:			<$Revision: 1.168 $>
+LIST OF CHANGES FROM PREVIOUS RELEASES:			<$Revision: 1.169 $>
 
 
 Changes from 386bsd 0.1 + patchkit 0.2.2 to NetBSD 0.8:
@@ -13393,7 +13393,7 @@ Changes from NetBSD 9.0 to NetBSD 10.0:
 		tprof(8). [msaitoh 20221208]
 	acpi(4): Updated ACPICA to 20221020. [christos 20221210]
 	tzdata: updated to 2022g (using the 2022ggtz fork) [kre 20221211]
-	i386: Enable options DISKLABEL_EI in GENERIC kernel. [tsutsui 20231211]
+	i386: Enable options DISKLABEL_EI in GENERIC kernel. [tsutsui 20221211]
 	tzcode: Updated to 2022g. [christos 20221211]
 	wbsio(4),lm(4): Add Nuvoton NCT6797D support. [msaitoh 20221215]
 	m68k: Fix out of bounds invalidate and writeback bug in



CVS commit: src/usr.bin/audio/play

2023-04-15 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Apr 15 16:54:39 UTC 2023

Modified Files:
src/usr.bin/audio/play: play.c

Log Message:
Revert accidentially committed part. The 'latency' report isn't ready
to be useful.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/usr.bin/audio/play/play.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/audio/play/play.c
diff -u src/usr.bin/audio/play/play.c:1.62 src/usr.bin/audio/play/play.c:1.63
--- src/usr.bin/audio/play/play.c:1.62	Sat Apr 15 12:39:44 2023
+++ src/usr.bin/audio/play/play.c	Sat Apr 15 16:54:39 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: play.c,v 1.62 2023/04/15 12:39:44 mlelstv Exp $	*/
+/*	$NetBSD: play.c,v 1.63 2023/04/15 16:54:39 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1999, 2000, 2001, 2002, 2010, 2015, 2019, 2021 Matthew R. Green
@@ -28,7 +28,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: play.c,v 1.62 2023/04/15 12:39:44 mlelstv Exp $");
+__RCSID("$NetBSD: play.c,v 1.63 2023/04/15 16:54:39 mlelstv Exp $");
 #endif
 
 #include 
@@ -65,7 +65,6 @@ static int	volume;
 static int	balance;
 static int	port;
 static int	fflag;
-static int	lflag;
 static int	qflag;
 int	verbose;
 static int	sample_rate;
@@ -88,7 +87,7 @@ main(int argc, char *argv[])
 	const char *defdevice = _PATH_SOUND;
 	const char *device = NULL;
 
-	while ((ch = getopt(argc, argv, "b:B:C:c:d:e:fhilp:P:qs:Vv:")) != -1) {
+	while ((ch = getopt(argc, argv, "b:B:C:c:d:e:fhip:P:qs:Vv:")) != -1) {
 		switch (ch) {
 		case 'b':
 			decode_int(optarg, );
@@ -119,9 +118,6 @@ main(int argc, char *argv[])
 		case 'i':
 			iflag++;
 			break;
-		case 'l':
-			lflag++;
-			break;
 		case 'q':
 			qflag++;
 			break;
@@ -301,57 +297,6 @@ audio_write(int fd, void *buf, size_t le
 	return write(fd, convert_buffer, len);
 }
 
-/*
- * print audio output offset
- */
-static void
-print_offset(off_t written, int ratelimit)
-{
-	static time_t last;
-	time_t now;
-	static off_t base = 0;
-	static off_t played = 0;
-	off_t bps;
-	audio_offset_t aoff;
-	u_int blocksize;
-
-	if (!lflag)
-		return;
-
-	if (ioctl(audiofd, AUDIO_GETOOFFS, ))
-		return;
-
-	bps = info.play.sample_rate
-	  * info.play.channels
-	  * info.play.precision / NBBY;
-	blocksize = info.blocksize > 0 ? info.blocksize : 1;
-
-	/* Check if aoff.samples overflowed */
-	if (aoff.samples < played) {
-		base += UINT_MAX;
-		base += 1;
-	}
-
-	/* Overflow base + number of samples in completed blocks + offset in currently played block */
-	played = base + aoff.samples + (aoff.offset % blocksize);
-
-	/* Print only every second */
-	if (ratelimit) {
-		time();
-		if (now == last)
-			return;
-		last = now;
-	}
-
-	if (bps > 0) {
-		printf("%jdms\n", (written - played) * 1000 / bps);
-	} else {
-		/* unknown rate, report bytes */
-		printf("%jd\n", written - played);
-	}
-	fflush(stdout);
-}
-
 static void
 play(char *file)
 {
@@ -360,7 +305,7 @@ play(char *file)
 	void *addr, *oaddr;
 	off_t	filesize;
 	size_t	sizet_filesize;
-	off_t datasize = 0, written = 0;
+	off_t datasize = 0;
 	ssize_t	hdrlen;
 	int fd;
 	int nw;
@@ -424,7 +369,6 @@ play(char *file)
 	}
 
 	while ((uint64_t)datasize > bufsize) {
-		print_offset(written, 0);
 		nw = audio_write(audiofd, addr, bufsize, conv);
 		if (nw == -1)
 			err(1, "write failed");
@@ -432,17 +376,13 @@ play(char *file)
 			errx(1, "write failed");
 		addr = (char *)addr + bufsize;
 		datasize -= bufsize;
-		written += nw;
 	}
-	print_offset(written, 0);
 	nw = audio_write(audiofd, addr, datasize, conv);
 	if (nw == -1)
 		err(1, "final write failed");
 	if ((off_t)nw != datasize)
 		errx(1, "final write failed");
-	written += nw;
 
-	print_offset(written, 0);
 	if (ioctl(audiofd, AUDIO_DRAIN) < 0 && !qflag)
 		warn("audio drain ioctl failed");
 	if (munmap(oaddr, sizet_filesize) < 0)
@@ -461,7 +401,7 @@ play_fd(const char *file, int fd)
 	char*buffer = malloc(bufsize);
 	ssize_t hdrlen;
 	int nr, nw;
-	off_t	datasize = 0, written = 0;
+	off_t	datasize = 0;
 	off_t	dataout = 0;
 
 	if (buffer == NULL)
@@ -490,8 +430,6 @@ play_fd(const char *file, int fd)
 		memmove(buffer, buffer + hdrlen, nr - hdrlen);
 		nr -= hdrlen;
 	}
-
-	print_offset(written, 0);
 	while (datasize == 0 || dataout < datasize) {
 		if (datasize != 0 && dataout + nr > datasize)
 			nr = datasize - dataout;
@@ -506,13 +444,10 @@ play_fd(const char *file, int fd)
 			goto read_error;
 		if (nr == 0)
 			break;
-		print_offset(written, 1);
-		written += nw;
 	}
 	/* something to think about: no message given for dataout < datasize */
 	if (ioctl(audiofd, AUDIO_DRAIN) < 0 && !qflag)
 		warn("audio drain ioctl failed");
-	print_offset(written, 0);
 	return;
 read_error:
 	err(1, "read of standard input failed");
@@ -638,8 +573,6 @@ set_audio_mode:
 
 	if (ioctl(fd, AUDIO_SETINFO, ) < 0)
 		err(1, "failed to set audio info");
-	if (ioctl(fd, AUDIO_GETINFO, ) < 0)
-		err(1, 

CVS commit: src/usr.bin/audio/play

2023-04-15 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Apr 15 16:54:39 UTC 2023

Modified Files:
src/usr.bin/audio/play: play.c

Log Message:
Revert accidentially committed part. The 'latency' report isn't ready
to be useful.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/usr.bin/audio/play/play.c

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



CVS commit: src/games/worms

2023-04-15 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sat Apr 15 15:21:56 UTC 2023

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

Log Message:
When worms default delay was changed from 0, to 20ms (Oct 2020)
it lost the ability to run flat out (no sleeps) - which while not
very useful for actually observing the behaviour of various Nematoda,
can be useful when 'worms' is being used to generate cpu heat - it
turns out to be a simple tool to make all of the app itself, the
xterm it runs in (when running under X) and the X server, all more
or less continuously busy - a trivial perpetual CPU load generator.

Changing that was not a simple matter of just allowing -d 0..1000
rather than -d 1..1000 which had always been the limits on -d, as
previously, simply by excluding 0, common error checking wasn't
essential.  -djunk would return 0 which was invalid, and so an error
- that it was invalid because 0 < 1, rather than because "junk" is not
a number wasn't material.

Now we need some slightly more elaborate error checking code for the
-d value, and if we're going to do that, may as well do the same for
the -l and -n options, which also take numeric values.  That is, it
will no longer be possible to say:
worms -n "5 worms"
Just the number is allowed (but -d now allows a "ms" or "us" suffix).

While here, place a reasonable upper limit (depending upon the
screen size, and worm length) upon the number of worms, so they
have somewhere to go, rather than just on top of each other.

exit(1) from the errx() rather than 0, in the case that curses
initscr() fails (doesn't seem right that it should appear as a
successful run of worms, if it never managed to start).

A couple more minor 80 column violations are handled, without
further penalty, in this update (one simply vanishes, the other
is wrapped).

Note that this sounds like a lot, but it is really all just minor
internal bookkeeping updates - the only real advertised user visible
change is the ability to use -d0 which just restores that which was
the default (though it could never be set via the option) until Oct 2020
- so really all that's happening is replacing minor functionality lost
then, while leaving the change of the default delay that that change
made, untouched.

No man page update required (that never excluded -d0).


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/games/worms/worms.c

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



CVS commit: src/games/worms

2023-04-15 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sat Apr 15 15:21:56 UTC 2023

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

Log Message:
When worms default delay was changed from 0, to 20ms (Oct 2020)
it lost the ability to run flat out (no sleeps) - which while not
very useful for actually observing the behaviour of various Nematoda,
can be useful when 'worms' is being used to generate cpu heat - it
turns out to be a simple tool to make all of the app itself, the
xterm it runs in (when running under X) and the X server, all more
or less continuously busy - a trivial perpetual CPU load generator.

Changing that was not a simple matter of just allowing -d 0..1000
rather than -d 1..1000 which had always been the limits on -d, as
previously, simply by excluding 0, common error checking wasn't
essential.  -djunk would return 0 which was invalid, and so an error
- that it was invalid because 0 < 1, rather than because "junk" is not
a number wasn't material.

Now we need some slightly more elaborate error checking code for the
-d value, and if we're going to do that, may as well do the same for
the -l and -n options, which also take numeric values.  That is, it
will no longer be possible to say:
worms -n "5 worms"
Just the number is allowed (but -d now allows a "ms" or "us" suffix).

While here, place a reasonable upper limit (depending upon the
screen size, and worm length) upon the number of worms, so they
have somewhere to go, rather than just on top of each other.

exit(1) from the errx() rather than 0, in the case that curses
initscr() fails (doesn't seem right that it should appear as a
successful run of worms, if it never managed to start).

A couple more minor 80 column violations are handled, without
further penalty, in this update (one simply vanishes, the other
is wrapped).

Note that this sounds like a lot, but it is really all just minor
internal bookkeeping updates - the only real advertised user visible
change is the ability to use -d0 which just restores that which was
the default (though it could never be set via the option) until Oct 2020
- so really all that's happening is replacing minor functionality lost
then, while leaving the change of the default delay that that change
made, untouched.

No man page update required (that never excluded -d0).


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/games/worms/worms.c

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

Modified files:

Index: src/games/worms/worms.c
diff -u src/games/worms/worms.c:1.25 src/games/worms/worms.c:1.26
--- src/games/worms/worms.c:1.25	Sat Apr 15 13:40:23 2023
+++ src/games/worms/worms.c	Sat Apr 15 15:21:56 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: worms.c,v 1.25 2023/04/15 13:40:23 kre Exp $	*/
+/*	$NetBSD: worms.c,v 1.26 2023/04/15 15:21:56 kre Exp $	*/
 
 /*
  * Copyright (c) 1980, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)worms.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: worms.c,v 1.25 2023/04/15 13:40:23 kre Exp $");
+__RCSID("$NetBSD: worms.c,v 1.26 2023/04/15 15:21:56 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -62,11 +62,14 @@ __RCSID("$NetBSD: worms.c,v 1.25 2023/04
  */
 #include 
 
+#include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
+#include 
 #include 
 
 static const struct options {
@@ -193,7 +196,9 @@ main(int argc, char *argv[])
 	int CO, LI, last, bottom, ch, length, number, trail;
 	short **ref;
 	const char *field;
+	char *ep;
 	unsigned int delay = 2;
+	unsigned long ul;
 
 	length = 16;
 	number = 3;
@@ -202,23 +207,54 @@ main(int argc, char *argv[])
 	while ((ch = getopt(argc, argv, "d:fl:n:t")) != -1)
 		switch(ch) {
 		case 'd':
-			if ((delay = (unsigned int)strtoul(optarg, NULL, 10)) < 1 || delay > 1000)
-errx(1, "invalid delay (1-1000)");
-			delay *= 1000;  /* ms -> us */
+			ul = strtoul(optarg, , 10);
+			if (ep != optarg) {
+while (isspace(*(unsigned char *)ep))
+	ep++;
+			}
+			if (ep == optarg ||
+			(*ep != '\0' &&
+( ep[1] == '\0' ? (*ep != 'm' && *ep != 'u') :
+( strcasecmp(ep, "ms") != 0 &&
+  strcasecmp(ep, "us") != 0 )) )) {
+errx(1, "-d: invalid delay (%s)", optarg);
+			}
+			/*
+			 * if ul >= INT_MAX/1000 we don't need the *1000,
+			 * as even without that it will exceed the limit
+			 * just below and be treated as an error.
+			 * (This does assume >=32 bit int, but so does POSIX)
+			 */
+			if (*ep != 'u' && ul < INT_MAX / 1000)
+ul *= 1000;  /* ms -> us */
+			if (ul > 1000*1000) {
+errx(1,
+   "-d: delay (%s) out of rannge [0 - 1000]",
+   optarg);
+			}
+			delay = (unsigned int)ul;
 			break;
 		case 'f':
 			field = "WORM";
 			break;
 		case 'l':
-			if ((length = atoi(optarg)) < 2 || length > 1024) {
-errx(1, "invalid length (%d - %d).",
- 2, 1024);
+			ul = strtoul(optarg, , 10);
+			if (ep == optarg || *ep != 

CVS commit: src/games/worms

2023-04-15 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sat Apr 15 13:40:23 UTC 2023

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

Log Message:
80 column police.

If this code were just a few chars over the limit, it might get
let off with a warning, but 214 in an 80 zone is way beyond that.

Six months loss of coding licence, and a 214000 character fine.

NFCI.

(I verified the the code was unchanged by joining the resulting
lines back into one again, and then diff'ing that line against
the original - it is identical).


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/games/worms/worms.c

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



CVS commit: src/games/worms

2023-04-15 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sat Apr 15 13:40:23 UTC 2023

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

Log Message:
80 column police.

If this code were just a few chars over the limit, it might get
let off with a warning, but 214 in an 80 zone is way beyond that.

Six months loss of coding licence, and a 214000 character fine.

NFCI.

(I verified the the code was unchanged by joining the resulting
lines back into one again, and then diff'ing that line against
the original - it is identical).


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/games/worms/worms.c

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

Modified files:

Index: src/games/worms/worms.c
diff -u src/games/worms/worms.c:1.24 src/games/worms/worms.c:1.25
--- src/games/worms/worms.c:1.24	Sat Apr 15 13:00:30 2023
+++ src/games/worms/worms.c	Sat Apr 15 13:40:23 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: worms.c,v 1.24 2023/04/15 13:00:30 kre Exp $	*/
+/*	$NetBSD: worms.c,v 1.25 2023/04/15 13:40:23 kre Exp $	*/
 
 /*
  * Copyright (c) 1980, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)worms.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: worms.c,v 1.24 2023/04/15 13:00:30 kre Exp $");
+__RCSID("$NetBSD: worms.c,v 1.25 2023/04/15 13:40:23 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -313,7 +313,18 @@ main(int argc, char *argv[])
 	mvaddch(y1, x1, trail);
 }
 			}
-			op = &(!x ? (!y ? upleft : (y == bottom ? lowleft : left)) : (x == last ? (!y ? upright : (y == bottom ? lowright : right)) : (!y ? upper : (y == bottom ? lower : normal[w->orientation];
+
+			op = &(!x
+? (!y
+? upleft
+: (y == bottom ? lowleft : left))
+: (x == last
+? (!y ? upright
+	  : (y == bottom ? lowright : right))
+: (!y ? upper
+	  : (y == bottom ? lower : normal)))
+			  )[w->orientation];
+
 			switch (op->nopts) {
 			case 0:
 refresh();



CVS commit: src/games/worms

2023-04-15 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sat Apr 15 13:00:30 UTC 2023

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

Log Message:
Garbage collect "char *mp" - it used to point at memory malloc()'d
to hold the termcap entry, back when worms used termcap rather than
curses, and termcap was termcap, rather that a terminfo wannabe.

This should have been removed when worms was converted to curses in
1999, but wasn't, so worms has been doing a meaningless malloc(1024)
and never using the result, ever since.

While here, since the line needed changing anyway to remove mp,
change a malloc() of a product into calloc() so it can deal with
any possible (admittedly extremely unlikely here) integer overflows.

NFCI


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/games/worms/worms.c

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

Modified files:

Index: src/games/worms/worms.c
diff -u src/games/worms/worms.c:1.23 src/games/worms/worms.c:1.24
--- src/games/worms/worms.c:1.23	Wed Oct 14 07:32:53 2020
+++ src/games/worms/worms.c	Sat Apr 15 13:00:30 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: worms.c,v 1.23 2020/10/14 07:32:53 nia Exp $	*/
+/*	$NetBSD: worms.c,v 1.24 2023/04/15 13:00:30 kre Exp $	*/
 
 /*
  * Copyright (c) 1980, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)worms.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: worms.c,v 1.23 2020/10/14 07:32:53 nia Exp $");
+__RCSID("$NetBSD: worms.c,v 1.24 2023/04/15 13:00:30 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -193,10 +193,8 @@ main(int argc, char *argv[])
 	int CO, LI, last, bottom, ch, length, number, trail;
 	short **ref;
 	const char *field;
-	char *mp;
 	unsigned int delay = 2;
 
-	mp = NULL;
 	length = 16;
 	number = 3;
 	trail = ' ';
@@ -232,8 +230,7 @@ main(int argc, char *argv[])
 			exit(1);
 		}
 
-	if (!(worm = malloc((size_t)number *
-	sizeof(struct worm))) || !(mp = malloc((size_t)1024)))
+	if (!(worm = calloc((size_t)number, sizeof(struct worm
 		nomem();
 	if (!initscr())
 		errx(0, "couldn't initialize screen");



CVS commit: src/games/worms

2023-04-15 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sat Apr 15 13:00:30 UTC 2023

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

Log Message:
Garbage collect "char *mp" - it used to point at memory malloc()'d
to hold the termcap entry, back when worms used termcap rather than
curses, and termcap was termcap, rather that a terminfo wannabe.

This should have been removed when worms was converted to curses in
1999, but wasn't, so worms has been doing a meaningless malloc(1024)
and never using the result, ever since.

While here, since the line needed changing anyway to remove mp,
change a malloc() of a product into calloc() so it can deal with
any possible (admittedly extremely unlikely here) integer overflows.

NFCI


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/games/worms/worms.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

2023-04-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Apr 15 12:59:02 UTC 2023

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

Log Message:
tests/lint: remove wrong comment

GCC 10 does warn about returning a temporary object, but only when
optimizations are enabled.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/msg_302.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_302.c
diff -u src/tests/usr.bin/xlint/lint1/msg_302.c:1.6 src/tests/usr.bin/xlint/lint1/msg_302.c:1.7
--- src/tests/usr.bin/xlint/lint1/msg_302.c:1.6	Sat Apr 15 12:47:32 2023
+++ src/tests/usr.bin/xlint/lint1/msg_302.c	Sat Apr 15 12:59:02 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_302.c,v 1.6 2023/04/15 12:47:32 rillig Exp $	*/
+/*	$NetBSD: msg_302.c,v 1.7 2023/04/15 12:59:02 rillig Exp $	*/
 # 3 "msg_302.c"
 
 // Test for message: '%s' returns pointer to automatic object [302]
@@ -47,7 +47,6 @@ return_local_array(int x)
 		return (local);
 	case 7:
 		/* C99 6.5.2.5p6 */
-		/* Neither GCC 10 nor Clang 15 warn about this case. */
 		/* expect+1: warning: 'return_local_array' returns pointer to automatic object [302] */
 		return (char[]){"local string"};
 	default:



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

2023-04-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Apr 15 12:59:02 UTC 2023

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

Log Message:
tests/lint: remove wrong comment

GCC 10 does warn about returning a temporary object, but only when
optimizations are enabled.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/msg_302.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

2023-04-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Apr 15 12:47:32 UTC 2023

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

Log Message:
tests/lint: add more tests for returning local objects


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_302.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_302.c
diff -u src/tests/usr.bin/xlint/lint1/msg_302.c:1.5 src/tests/usr.bin/xlint/lint1/msg_302.c:1.6
--- src/tests/usr.bin/xlint/lint1/msg_302.c:1.5	Sat Apr 15 10:53:59 2023
+++ src/tests/usr.bin/xlint/lint1/msg_302.c	Sat Apr 15 12:47:32 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_302.c,v 1.5 2023/04/15 10:53:59 rillig Exp $	*/
+/*	$NetBSD: msg_302.c,v 1.6 2023/04/15 12:47:32 rillig Exp $	*/
 # 3 "msg_302.c"
 
 // Test for message: '%s' returns pointer to automatic object [302]
@@ -42,6 +42,14 @@ return_local_array(int x)
 	case 5:
 		/* XXX: lint doesn't track this indirection, but Clang-tidy does. */
 		return indirect;
+	case 6:
+		/* expect+1: warning: 'return_local_array' returns pointer to automatic object [302] */
+		return (local);
+	case 7:
+		/* C99 6.5.2.5p6 */
+		/* Neither GCC 10 nor Clang 15 warn about this case. */
+		/* expect+1: warning: 'return_local_array' returns pointer to automatic object [302] */
+		return (char[]){"local string"};
 	default:
 		return "OK";
 	}



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

2023-04-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Apr 15 12:47:32 UTC 2023

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

Log Message:
tests/lint: add more tests for returning local objects


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_302.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/audio

2023-04-15 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Apr 15 12:39:44 UTC 2023

Modified Files:
src/usr.bin/audio/common: auconv.h wav.c
src/usr.bin/audio/play: play.c
src/usr.bin/audio/record: record.c

Log Message:
Add support for recording 24bit wav files.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/audio/common/auconv.h
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/audio/common/wav.c
cvs rdiff -u -r1.61 -r1.62 src/usr.bin/audio/play/play.c
cvs rdiff -u -r1.56 -r1.57 src/usr.bin/audio/record/record.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/audio/common/auconv.h
diff -u src/usr.bin/audio/common/auconv.h:1.5 src/usr.bin/audio/common/auconv.h:1.6
--- src/usr.bin/audio/common/auconv.h:1.5	Mon Apr 28 20:24:12 2008
+++ src/usr.bin/audio/common/auconv.h	Sat Apr 15 12:39:44 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: auconv.h,v 1.5 2008/04/28 20:24:12 martin Exp $	*/
+/*	$NetBSD: auconv.h,v 1.6 2023/04/15 12:39:44 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -78,6 +78,24 @@ change_sign16_be(u_char *p, int cc)
 }
 
 static inline void
+change_sign24_le(u_char *p, int cc)
+{
+	while ((cc -= 3) >= 0) {
+		p[2] ^= 0x80;
+		p += 3;
+	}
+}
+
+static inline void
+change_sign24_be(u_char *p, int cc)
+{
+	while ((cc -= 3) >= 0) {
+		p[0] ^= 0x80;
+		p += 3;
+	}
+}
+
+static inline void
 change_sign32_le(u_char *p, int cc)
 {
 	while ((cc -= 4) >= 0) {
@@ -163,6 +181,44 @@ change_sign16_swap_bytes_be(u_char *p, i
 }
 
 static inline void
+swap_bytes_change_sign24_le(u_char *p, int cc)
+{
+	u_char t;
+
+	while ((cc -= 3) >= 0) {
+		t = p[2];
+		p[2] = p[0] ^ 0x80;
+		p[0] = t;
+		p += 3;
+	}
+}
+
+static inline void
+swap_bytes_change_sign24_be(u_char *p, int cc)
+{
+	u_char t;
+
+	while ((cc -= 3) >= 0) {
+		t = p[0];
+		p[0] = p[2] ^ 0x80;
+		p[2] = t;
+		p += 3;
+	}
+}
+
+static inline void
+change_sign24_swap_bytes_le(u_char *p, int cc)
+{
+	swap_bytes_change_sign24_be(p, cc);
+}
+
+static inline void
+change_sign24_swap_bytes_be(u_char *p, int cc)
+{
+	swap_bytes_change_sign24_le(p, cc);
+}
+
+static inline void
 swap_bytes_change_sign32_le(u_char *p, int cc)
 {
 	u_char t;

Index: src/usr.bin/audio/common/wav.c
diff -u src/usr.bin/audio/common/wav.c:1.15 src/usr.bin/audio/common/wav.c:1.16
--- src/usr.bin/audio/common/wav.c:1.15	Sat Nov  9 12:46:44 2019
+++ src/usr.bin/audio/common/wav.c	Sat Apr 15 12:39:44 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: wav.c,v 1.15 2019/11/09 12:46:44 mrg Exp $	*/
+/*	$NetBSD: wav.c,v 1.16 2023/04/15 12:39:44 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 2002, 2009, 2013, 2015, 2019 Matthew R. Green
@@ -33,7 +33,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: wav.c,v 1.15 2019/11/09 12:46:44 mrg Exp $");
+__RCSID("$NetBSD: wav.c,v 1.16 2023/04/15 12:39:44 mlelstv Exp $");
 #endif
 
 
@@ -287,6 +287,8 @@ wav_prepare_header(struct track_info *ti
 		break;
 	case 16:
 		break;
+	case 24:
+		break;
 	case 32:
 		break;
 	default:

Index: src/usr.bin/audio/play/play.c
diff -u src/usr.bin/audio/play/play.c:1.61 src/usr.bin/audio/play/play.c:1.62
--- src/usr.bin/audio/play/play.c:1.61	Sun May 15 02:16:06 2022
+++ src/usr.bin/audio/play/play.c	Sat Apr 15 12:39:44 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: play.c,v 1.61 2022/05/15 02:16:06 mrg Exp $	*/
+/*	$NetBSD: play.c,v 1.62 2023/04/15 12:39:44 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1999, 2000, 2001, 2002, 2010, 2015, 2019, 2021 Matthew R. Green
@@ -28,7 +28,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: play.c,v 1.61 2022/05/15 02:16:06 mrg Exp $");
+__RCSID("$NetBSD: play.c,v 1.62 2023/04/15 12:39:44 mlelstv Exp $");
 #endif
 
 #include 
@@ -65,6 +65,7 @@ static int	volume;
 static int	balance;
 static int	port;
 static int	fflag;
+static int	lflag;
 static int	qflag;
 int	verbose;
 static int	sample_rate;
@@ -87,7 +88,7 @@ main(int argc, char *argv[])
 	const char *defdevice = _PATH_SOUND;
 	const char *device = NULL;
 
-	while ((ch = getopt(argc, argv, "b:B:C:c:d:e:fhip:P:qs:Vv:")) != -1) {
+	while ((ch = getopt(argc, argv, "b:B:C:c:d:e:fhilp:P:qs:Vv:")) != -1) {
 		switch (ch) {
 		case 'b':
 			decode_int(optarg, );
@@ -118,6 +119,9 @@ main(int argc, char *argv[])
 		case 'i':
 			iflag++;
 			break;
+		case 'l':
+			lflag++;
+			break;
 		case 'q':
 			qflag++;
 			break;
@@ -297,6 +301,57 @@ audio_write(int fd, void *buf, size_t le
 	return write(fd, convert_buffer, len);
 }
 
+/*
+ * print audio output offset
+ */
+static void
+print_offset(off_t written, int ratelimit)
+{
+	static time_t last;
+	time_t now;
+	static off_t base = 0;
+	static off_t played = 0;
+	off_t bps;
+	audio_offset_t aoff;
+	u_int blocksize;
+
+	if (!lflag)
+		return;
+
+	if (ioctl(audiofd, AUDIO_GETOOFFS, ))
+		return;
+
+	bps = info.play.sample_rate
+	  * info.play.channels
+	  * info.play.precision / NBBY;
+	blocksize = info.blocksize > 0 ? info.blocksize : 1;
+
+	/* 

CVS commit: src/usr.bin/audio

2023-04-15 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Apr 15 12:39:44 UTC 2023

Modified Files:
src/usr.bin/audio/common: auconv.h wav.c
src/usr.bin/audio/play: play.c
src/usr.bin/audio/record: record.c

Log Message:
Add support for recording 24bit wav files.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/audio/common/auconv.h
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/audio/common/wav.c
cvs rdiff -u -r1.61 -r1.62 src/usr.bin/audio/play/play.c
cvs rdiff -u -r1.56 -r1.57 src/usr.bin/audio/record/record.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/xlint/xlint

2023-04-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Apr 15 12:29:43 UTC 2023

Modified Files:
src/usr.bin/xlint/xlint: lint.1

Log Message:
lint.1: remove extra space from -q option


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/usr.bin/xlint/xlint/lint.1

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



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

2023-04-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Apr 15 12:29:43 UTC 2023

Modified Files:
src/usr.bin/xlint/xlint: lint.1

Log Message:
lint.1: remove extra space from -q option


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/usr.bin/xlint/xlint/lint.1

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/xlint/xlint/lint.1
diff -u src/usr.bin/xlint/xlint/lint.1:1.56 src/usr.bin/xlint/xlint/lint.1:1.57
--- src/usr.bin/xlint/xlint/lint.1:1.56	Sun Jan 22 15:20:01 2023
+++ src/usr.bin/xlint/xlint/lint.1	Sat Apr 15 12:29:43 2023
@@ -1,4 +1,4 @@
-.\" $NetBSD: lint.1,v 1.56 2023/01/22 15:20:01 rillig Exp $
+.\" $NetBSD: lint.1,v 1.57 2023/04/15 12:29:43 rillig Exp $
 .\"
 .\" Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
 .\" Copyright (c) 1994, 1995 Jochen Pohl
@@ -344,7 +344,7 @@ when assigning to wider integer types, o
 to wider types.
 .It Fl p
 Attempt to check portability of code to other platforms of C.
-.It Fl q Ar id Op ,id ...
+.It Fl q Ar id Ns Op ,id ...
 In addition to the usual warnings and errors, run the selected queries,
 which are listed in
 .Xr lint 7 Ns .



CVS commit: src/share/misc

2023-04-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Apr 15 12:22:37 UTC 2023

Modified Files:
src/share/misc: style

Log Message:
style: fix spelling of plural parentheses


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

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

Modified files:

Index: src/share/misc/style
diff -u src/share/misc/style:1.71 src/share/misc/style:1.72
--- src/share/misc/style:1.71	Fri Apr 14 16:53:13 2023
+++ src/share/misc/style	Sat Apr 15 12:22:37 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: style,v 1.71 2023/04/14 16:53:13 rillig Exp $ */
+/* $NetBSD: style,v 1.72 2023/04/15 12:22:37 rillig Exp $ */
 
 /*
  * The revision control tag appears first, with a blank line after it.
@@ -30,7 +30,7 @@
 #include 
 __COPYRIGHT("@(#) Copyright (c) 2008\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: style,v 1.71 2023/04/14 16:53:13 rillig Exp $");
+__RCSID("$NetBSD: style,v 1.72 2023/04/15 12:22:37 rillig Exp $");
 
 /*
  * VERY important single-line comments look like this.
@@ -151,7 +151,7 @@ static void usage(void) __dead;	/* decla
  * use of TABs should be consistent through a file.
  * If they are an inline expansion of a function, the function is defined
  * all in lowercase, the macro has the same name all in uppercase.
- * If the macro is an expression, wrap the expression in parenthesis.
+ * If the macro is an expression, wrap the expression in parentheses.
  * If the macro is more than a single statement, use ``do { ... } while (0)''
  * or ``do { ... } while (false)'', so that a trailing semicolon works.
  * Right-justify the backslashes; it makes it easier to read.
@@ -328,7 +328,7 @@ main(int argc, char *argv[])
 
 	/*
 	 * Unary operators don't require spaces, binary operators do.
-	 * Don't excessively use parenthesis, but they should be used if
+	 * Don't excessively use parentheses, but they should be used if a
 	 * statement is really confusing without them, such as:
 	 * a = b->c[0] + ~d == (e || f) || g && h ? i : j >> 1;
 	 */



CVS commit: src/share/misc

2023-04-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Apr 15 12:22:37 UTC 2023

Modified Files:
src/share/misc: style

Log Message:
style: fix spelling of plural parentheses


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

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



CVS commit: [netbsd-10] src/doc

2023-04-15 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Apr 15 12:09:08 UTC 2023

Modified Files:
src/doc [netbsd-10]: CHANGES-10.0

Log Message:
Ticket #127


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

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



CVS commit: [netbsd-10] src/doc

2023-04-15 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Apr 15 12:09:08 UTC 2023

Modified Files:
src/doc [netbsd-10]: CHANGES-10.0

Log Message:
Ticket #127


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

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

Modified files:

Index: src/doc/CHANGES-10.0
diff -u src/doc/CHANGES-10.0:1.1.2.53 src/doc/CHANGES-10.0:1.1.2.54
--- src/doc/CHANGES-10.0:1.1.2.53	Mon Apr  3 18:36:09 2023
+++ src/doc/CHANGES-10.0	Sat Apr 15 12:09:07 2023
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-10.0,v 1.1.2.53 2023/04/03 18:36:09 martin Exp $
+# $NetBSD: CHANGES-10.0,v 1.1.2.54 2023/04/15 12:09:07 jdc Exp $
 
 A complete list of changes from the initial NetBSD 10.0 branch on 2022-12-16
 until the 10.0 release:
@@ -1523,6 +1523,12 @@ sys/dev/fss.c	1.114
 	this flag and may trigger an assertion.
 	[hannken, ticket #126]
 
+src/tests/sbin/envstat/t_envstat.sh		1.2
+	PR 57284: rewrite test to extract all temperaturs from all local sensors
+	and test them (instead of only one temperature from a tiny list of hard
+	coded possible devices).
+	[martin, ticket #127]
+
 sys/dev/pci/if_vioif.c1.83-1.102,1.105-1.107
 sys/arch/mips/include/bus_space_defs.h		1.5
 sys/arch/mips/include/types.h			1.78



CVS commit: [netbsd-10] src/tests/sbin/envstat

2023-04-15 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Apr 15 12:08:42 UTC 2023

Modified Files:
src/tests/sbin/envstat [netbsd-10]: t_envstat.sh

Log Message:
Pull up the following revision (requested by martin in ticket #127):

tests/sbin/envstat/t_envstat.sh: revision 1.2

PR 57284: rewrite test to extract all temperaturs from all local sensors
and test them (instead of only one temperature from a tiny list of hard
coded possible devices).


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.1.6.1 src/tests/sbin/envstat/t_envstat.sh

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



CVS commit: [netbsd-10] src/tests/sbin/envstat

2023-04-15 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Apr 15 12:08:42 UTC 2023

Modified Files:
src/tests/sbin/envstat [netbsd-10]: t_envstat.sh

Log Message:
Pull up the following revision (requested by martin in ticket #127):

tests/sbin/envstat/t_envstat.sh: revision 1.2

PR 57284: rewrite test to extract all temperaturs from all local sensors
and test them (instead of only one temperature from a tiny list of hard
coded possible devices).


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.1.6.1 src/tests/sbin/envstat/t_envstat.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/envstat/t_envstat.sh
diff -u src/tests/sbin/envstat/t_envstat.sh:1.1 src/tests/sbin/envstat/t_envstat.sh:1.1.6.1
--- src/tests/sbin/envstat/t_envstat.sh:1.1	Thu Jun 25 15:01:35 2020
+++ src/tests/sbin/envstat/t_envstat.sh	Sat Apr 15 12:08:42 2023
@@ -1,4 +1,4 @@
-# $NetBSD: t_envstat.sh,v 1.1 2020/06/25 15:01:35 jruoho Exp $
+# $NetBSD: t_envstat.sh,v 1.1.6.1 2023/04/15 12:08:42 jdc Exp $
 #
 # Copyright (c) 2020 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -36,9 +36,8 @@ zerotemp_head() {
 
 zerotemp_body() {
 
-	devices="amdtemp0 coretemp0 acpitz0" # XXX: What else?
-
-	for dev in $devices; do
+	for dev in $( envstat -D | awk '{print $1}' )
+	do
 
 		envstat -d $dev >/dev/null 2>&1
 
@@ -47,18 +46,23 @@ zerotemp_body() {
 			continue
 		fi
 
-		if [ $dev = "amdtemp0" ]; then
-			atf_expect_fail "PR kern/53410"
-		fi
-
-		tempf=$(envstat -d $dev | awk '/Current/{getline;print $3}')
-		tempi=$(printf "%.0f" $tempf)
-
-		echo "$dev = $tempf =~ $tempi"
-
-		if [ $tempi -eq 0 ]; then
-			atf_fail "Zero-temperature from $dev"
-		fi
+		# extract all temperatures from $dev
+		for tempf in $(envstat -d $dev | \
+			awk -F: '/degC$/{print $2}' | \
+			awk '{print $1}' )
+		do
+			tempi=$(printf "%.0f" $tempf)
+
+			echo "$dev = $tempf =~ $tempi"
+
+			if [ $tempi -eq 0 ]; then
+
+if [ $dev = "amdtemp0" ]; then
+	atf_expect_fail "PR kern/53410"
+fi
+atf_fail "Zero-temperature from $dev"
+			fi
+		done
 	done
 }
 



CVS commit: src

2023-04-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Apr 15 11:34:45 UTC 2023

Modified Files:
src/tests/usr.bin/xlint/lint1: queries.c
src/usr.bin/xlint/lint1: err.c func.c

Log Message:
lint: add query for parenthesized return value


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/tests/usr.bin/xlint/lint1/queries.c
cvs rdiff -u -r1.192 -r1.193 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.152 -r1.153 src/usr.bin/xlint/lint1/func.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/queries.c
diff -u src/tests/usr.bin/xlint/lint1/queries.c:1.11 src/tests/usr.bin/xlint/lint1/queries.c:1.12
--- src/tests/usr.bin/xlint/lint1/queries.c:1.11	Fri Mar 31 13:03:05 2023
+++ src/tests/usr.bin/xlint/lint1/queries.c	Sat Apr 15 11:34:45 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: queries.c,v 1.11 2023/03/31 13:03:05 rillig Exp $	*/
+/*	$NetBSD: queries.c,v 1.12 2023/04/15 11:34:45 rillig Exp $	*/
 # 3 "queries.c"
 
 /*
@@ -15,7 +15,7 @@
  * 	such as casts between arithmetic types.
  */
 
-/* lint1-extra-flags: -q 1,2,3,4,5,6,7,8 -X 351 */
+/* lint1-extra-flags: -q 1,2,3,4,5,6,7,8,9 -X 351 */
 
 typedef unsigned char u8_t;
 typedef unsigned short u16_t;
@@ -310,6 +310,49 @@ Q8(void)
 	u16 = 644;
 }
 
+int
+Q9(int x)
+{
+	switch (x) {
+	case 0:
+		return 0;
+	case 1:
+		/* expect+1: parenthesized return value [Q9] */
+		return (0);
+	case 2:
+		return +(0);
+	case 3:
+		return -(13);
+	case 4:
+		/* expect+1: parenthesized return value [Q9] */
+		return (0), (1);
+	case 5:
+		/* expect+1: parenthesized return value [Q9] */
+		return (0, 1);
+	case 6:
+		return 0, 1;
+	case 7:
+		/* expect+1: implicit conversion from floating point 'double' to integer 'int' [Q1] */
+		return 0.0;
+	case 8:
+		/* expect+2: parenthesized return value [Q9] */
+		/* expect+1: implicit conversion from floating point 'double' to integer 'int' [Q1] */
+		return (0.0);
+	case 9:
+		return
+# 344 "queries.c" 3 4
+		((void *)0)
+# 346 "queries.c"
+		/* expect+1: warning: illegal combination of integer 'int' and pointer 'pointer to void' [183] */
+		;
+	case 10:
+		/* expect+1: warning: illegal combination of integer 'int' and pointer 'pointer to void' [183] */
+		return (void *)(0);
+	default:
+		return 0;
+	}
+}
+
 /*
  * Since queries do not affect the exit status, force a warning to make this
  * test conform to the general expectation that a test that produces output

Index: src/usr.bin/xlint/lint1/err.c
diff -u src/usr.bin/xlint/lint1/err.c:1.192 src/usr.bin/xlint/lint1/err.c:1.193
--- src/usr.bin/xlint/lint1/err.c:1.192	Fri Mar 31 13:03:05 2023
+++ src/usr.bin/xlint/lint1/err.c	Sat Apr 15 11:34:45 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: err.c,v 1.192 2023/03/31 13:03:05 rillig Exp $	*/
+/*	$NetBSD: err.c,v 1.193 2023/04/15 11:34:45 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID)
-__RCSID("$NetBSD: err.c,v 1.192 2023/03/31 13:03:05 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.193 2023/04/15 11:34:45 rillig Exp $");
 #endif
 
 #include 
@@ -699,6 +699,7 @@ static const char *queries[] = {
 	"no-op cast from '%s' to '%s'",  /* Q6 */
 	"redundant cast from '%s' to '%s' before assignment",	  /* Q7 */
 	"octal number '%.*s'",	  /* Q8 */
+	"parenthesized return value",  /* Q9 */
 };
 
 bool any_query_enabled;		/* for optimizing non-query scenarios */

Index: src/usr.bin/xlint/lint1/func.c
diff -u src/usr.bin/xlint/lint1/func.c:1.152 src/usr.bin/xlint/lint1/func.c:1.153
--- src/usr.bin/xlint/lint1/func.c:1.152	Sat Apr 15 10:32:46 2023
+++ src/usr.bin/xlint/lint1/func.c	Sat Apr 15 11:34:45 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: func.c,v 1.152 2023/04/15 10:32:46 rillig Exp $	*/
+/*	$NetBSD: func.c,v 1.153 2023/04/15 11:34:45 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID)
-__RCSID("$NetBSD: func.c,v 1.152 2023/04/15 10:32:46 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.153 2023/04/15 11:34:45 rillig Exp $");
 #endif
 
 #include 
@@ -1047,9 +1047,24 @@ do_continue(void)
 	set_reached(false);
 }
 
+static bool
+is_parenthesized(const tnode_t *tn)
+{
+
+	while (!tn->tn_parenthesized && tn->tn_op == COMMA)
+		tn = tn->tn_right;
+	return tn->tn_parenthesized && !tn->tn_sys;
+}
+
 static void
 check_return_value(bool sys, tnode_t *tn)
 {
+
+	if (any_query_enabled && is_parenthesized(tn)) {
+		/* parenthesized return value */
+		query_message(9);
+	}
+
 	/* Create a temporary node for the left side */
 	tnode_t *ln = expr_zero_alloc(sizeof(*ln));
 	ln->tn_op = NAME;



CVS commit: src

2023-04-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Apr 15 11:34:45 UTC 2023

Modified Files:
src/tests/usr.bin/xlint/lint1: queries.c
src/usr.bin/xlint/lint1: err.c func.c

Log Message:
lint: add query for parenthesized return value


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/tests/usr.bin/xlint/lint1/queries.c
cvs rdiff -u -r1.192 -r1.193 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.152 -r1.153 src/usr.bin/xlint/lint1/func.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

2023-04-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Apr 15 10:53:59 UTC 2023

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

Log Message:
tests/lint: extend test for returning local address


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_302.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_302.c
diff -u src/tests/usr.bin/xlint/lint1/msg_302.c:1.4 src/tests/usr.bin/xlint/lint1/msg_302.c:1.5
--- src/tests/usr.bin/xlint/lint1/msg_302.c:1.4	Wed Jun 22 19:23:18 2022
+++ src/tests/usr.bin/xlint/lint1/msg_302.c	Sat Apr 15 10:53:59 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_302.c,v 1.4 2022/06/22 19:23:18 rillig Exp $	*/
+/*	$NetBSD: msg_302.c,v 1.5 2023/04/15 10:53:59 rillig Exp $	*/
 # 3 "msg_302.c"
 
 // Test for message: '%s' returns pointer to automatic object [302]
@@ -19,17 +19,32 @@ return_local(void)
 }
 
 void *
-return_local_array(_Bool cond)
+return_local_array(int x)
 {
-	int local[5];
-	int *p = local;
+	int local[5], *indirect = local;
 
-	/* XXX: lint doesn't track this indirection, but Clang-tidy does. */
-	if (cond)
-		return p;
-
-	/* expect+1: warning: 'return_local_array' returns pointer to automatic object [302] */
-	return local + 5;
+	switch (x) {
+	case 0:
+		/* expect+1: warning: 'return_local_array' returns pointer to automatic object [302] */
+		return local;
+	case 1:
+		/* expect+1: warning: 'return_local_array' returns pointer to automatic object [302] */
+		return [3];
+	case 2:
+		/* expect+1: warning: 'return_local_array' returns pointer to automatic object [302] */
+		return 5 + local;
+	case 3:
+		/* expect+1: warning: 'return_local_array' returns pointer to automatic object [302] */
+		return local + 5;
+	case 4:
+		/* XXX: lint only checks '+' but not '-'. */
+		return local - -3;
+	case 5:
+		/* XXX: lint doesn't track this indirection, but Clang-tidy does. */
+		return indirect;
+	default:
+		return "OK";
+	}
 }
 
 void *



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

2023-04-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Apr 15 10:53:59 UTC 2023

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

Log Message:
tests/lint: extend test for returning local address


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_302.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/xlint/lint1

2023-04-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Apr 15 10:32:46 UTC 2023

Modified Files:
src/usr.bin/xlint/lint1: func.c

Log Message:
lint: extract checking the return value to separate function

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.151 -r1.152 src/usr.bin/xlint/lint1/func.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/xlint/lint1/func.c
diff -u src/usr.bin/xlint/lint1/func.c:1.151 src/usr.bin/xlint/lint1/func.c:1.152
--- src/usr.bin/xlint/lint1/func.c:1.151	Tue Mar 28 20:01:21 2023
+++ src/usr.bin/xlint/lint1/func.c	Sat Apr 15 10:32:46 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: func.c,v 1.151 2023/03/28 20:01:21 rillig Exp $	*/
+/*	$NetBSD: func.c,v 1.152 2023/04/15 10:32:46 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID)
-__RCSID("$NetBSD: func.c,v 1.151 2023/03/28 20:01:21 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.152 2023/04/15 10:32:46 rillig Exp $");
 #endif
 
 #include 
@@ -1047,6 +1047,32 @@ do_continue(void)
 	set_reached(false);
 }
 
+static void
+check_return_value(bool sys, tnode_t *tn)
+{
+	/* Create a temporary node for the left side */
+	tnode_t *ln = expr_zero_alloc(sizeof(*ln));
+	ln->tn_op = NAME;
+	ln->tn_type = expr_unqualified_type(funcsym->s_type->t_subt);
+	ln->tn_lvalue = true;
+	ln->tn_sym = funcsym;	/* better than nothing */
+
+	tnode_t *retn = build_binary(ln, RETURN, sys, tn);
+
+	if (retn != NULL) {
+		const tnode_t *rn = retn->tn_right;
+		while (rn->tn_op == CVT || rn->tn_op == PLUS)
+			rn = rn->tn_left;
+		if (rn->tn_op == ADDR && rn->tn_left->tn_op == NAME &&
+		rn->tn_left->tn_sym->s_scl == AUTO) {
+			/* '%s' returns pointer to automatic object */
+			warning(302, funcsym->s_name);
+		}
+	}
+
+	expr(retn, true, false, true, false);
+}
+
 /*
  * T_RETURN T_SEMI
  * T_RETURN expr T_SEMI
@@ -1054,11 +1080,8 @@ do_continue(void)
 void
 do_return(bool sys, tnode_t *tn)
 {
-	tnode_t	*ln, *rn;
-	control_statement *cs;
-	op_t	op;
+	control_statement *cs = cstmt;
 
-	cs = cstmt;
 	if (cs == NULL) {
 		/* syntax error '%s' */
 		error(249, "return outside function");
@@ -1088,36 +,11 @@ do_return(bool sys, tnode_t *tn)
 			warning(214, funcsym->s_name);
 	}
 
-	if (tn != NULL) {
-
-		/* Create a temporary node for the left side */
-		ln = expr_zero_alloc(sizeof(*ln));
-		ln->tn_op = NAME;
-		ln->tn_type = expr_unqualified_type(funcsym->s_type->t_subt);
-		ln->tn_lvalue = true;
-		ln->tn_sym = funcsym;		/* better than nothing */
-
-		tn = build_binary(ln, RETURN, sys, tn);
-
-		if (tn != NULL) {
-			rn = tn->tn_right;
-			while ((op = rn->tn_op) == CVT || op == PLUS)
-rn = rn->tn_left;
-			if (rn->tn_op == ADDR && rn->tn_left->tn_op == NAME &&
-			rn->tn_left->tn_sym->s_scl == AUTO) {
-/* '%s' returns pointer to automatic object */
-warning(302, funcsym->s_name);
-			}
-		}
-
-		expr(tn, true, false, true, false);
-
-	} else {
-
+	if (tn != NULL)
+		check_return_value(sys, tn);
+	else
 		check_statement_reachable();
 
-	}
-
 	set_reached(false);
 }
 



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

2023-04-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Apr 15 10:32:46 UTC 2023

Modified Files:
src/usr.bin/xlint/lint1: func.c

Log Message:
lint: extract checking the return value to separate function

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.151 -r1.152 src/usr.bin/xlint/lint1/func.c

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