CVS commit: src/sbin/fsck_msdos

2022-04-23 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Apr 23 22:40:28 UTC 2022

Modified Files:
src/sbin/fsck_msdos: boot.c

Log Message:
Support large disk sectors.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sbin/fsck_msdos/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/sbin/fsck_msdos/boot.c
diff -u src/sbin/fsck_msdos/boot.c:1.23 src/sbin/fsck_msdos/boot.c:1.24
--- src/sbin/fsck_msdos/boot.c:1.23	Sat Feb 22 09:59:22 2020
+++ src/sbin/fsck_msdos/boot.c	Sat Apr 23 22:40:28 2022
@@ -27,7 +27,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: boot.c,v 1.23 2020/02/22 09:59:22 kamil Exp $");
+__RCSID("$NetBSD: boot.c,v 1.24 2022/04/23 22:40:28 mlelstv Exp $");
 #endif /* not lint */
 
 #include 
@@ -36,6 +36,8 @@ __RCSID("$NetBSD: boot.c,v 1.23 2020/02/
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include "ext.h"
 #include "fsutil.h"
@@ -43,19 +45,34 @@ __RCSID("$NetBSD: boot.c,v 1.23 2020/02/
 int
 readboot(int dosfs, struct bootblock *boot)
 {
-	u_char block[DOSBOOTBLOCKSIZE];
-	u_char fsinfo[2 * DOSBOOTBLOCKSIZE];
-	u_char backup[DOSBOOTBLOCKSIZE];
+	u_char *block;
+	u_char *fsinfo;
+	u_char *backup;
 	int ret = FSOK;
-	int i;
+	int i, err;
+	u_int secsize;
+
+	secsize = 0;
+	err = ioctl(dosfs, DIOCGSECTORSIZE, );
+	if (err != 0 || secsize == 0)
+		secsize = DOSBOOTBLOCKSIZE;
+
+	if (secsize < DOSBOOTBLOCKSIZE)
+		pfatal("Invalid sector size %u\n", secsize);
+
+	block = calloc(1, secsize);
+	if (block == NULL)
+		pfatal("Out of memory");
 	
-	if ((size_t)read(dosfs, block, sizeof block) != sizeof block) {
+	if ((size_t)read(dosfs, block, secsize) != secsize) {
 		perr("could not read boot block");
+		free(block);
 		return FSFATAL;
 	}
 
 	if (block[510] != 0x55 || block[511] != 0xaa) {
 		pfatal("Invalid signature in boot block: %02x%02x", block[511], block[510]);
+		free(block);
 		return FSFATAL;
 	}
 
@@ -86,6 +103,13 @@ readboot(int dosfs, struct bootblock *bo
 
 	boot->FATsecs = boot->FATsmall;
 
+	fsinfo = calloc(2, secsize);
+	if (fsinfo == NULL)
+		pfatal("Out of memory");
+	backup = calloc(1, secsize);
+	if (backup == NULL)
+		pfatal("Out of memory");
+
 	if (!boot->RootDirEnts)
 		boot->flags |= FAT32;
 	if (boot->flags & FAT32) {
@@ -108,8 +132,7 @@ readboot(int dosfs, struct bootblock *bo
 
 		if (lseek(dosfs, boot->FSInfo * boot->BytesPerSec, SEEK_SET)
 		!= boot->FSInfo * boot->BytesPerSec
-		|| read(dosfs, fsinfo, sizeof fsinfo)
-		!= sizeof fsinfo) {
+		|| read(dosfs, fsinfo, 2 * secsize) != 2 * secsize) {
 			perr("could not read fsinfo block");
 			return FSFATAL;
 		}
@@ -138,6 +161,9 @@ readboot(int dosfs, struct bootblock *bo
 || write(dosfs, fsinfo, sizeof fsinfo)
 != sizeof fsinfo) {
 	perr("Unable to write FSInfo");
+	free(fsinfo);
+	free(backup);
+	free(block);
 	return FSFATAL;
 }
 ret = FSBOOTMOD;
@@ -155,8 +181,11 @@ readboot(int dosfs, struct bootblock *bo
 
 		if (lseek(dosfs, boot->Backup * boot->BytesPerSec, SEEK_SET)
 		!= boot->Backup * boot->BytesPerSec
-		|| read(dosfs, backup, sizeof backup) != sizeof  backup) {
+		|| read(dosfs, backup, secsize) != secsize) {
 			perr("could not read backup bootblock");
+			free(fsinfo);
+			free(backup);
+			free(block);
 			return FSFATAL;
 		}
 		backup[65] = block[65];/* XXX */
@@ -180,6 +209,11 @@ readboot(int dosfs, struct bootblock *bo
 		}
 		/* Check backup FSInfo?	XXX */
 	}
+
+	free(fsinfo);
+	free(backup);
+	free(block);
+
 	if (boot->FATsecs == 0) {
 		pfatal("Invalid number of FAT sectors: %u\n", boot->FATsecs);
 		return FSFATAL;
@@ -265,12 +299,17 @@ readboot(int dosfs, struct bootblock *bo
 int
 writefsinfo(int dosfs, struct bootblock *boot)
 {
-	u_char fsinfo[2 * DOSBOOTBLOCKSIZE];
+	u_char *fsinfo;
+
+	fsinfo = calloc(2, boot->BytesPerSec);
+	if (fsinfo == NULL)
+		pfatal("Out of memory");
 
 	if (lseek(dosfs, boot->FSInfo * boot->BytesPerSec, SEEK_SET)
 	!= boot->FSInfo * boot->BytesPerSec
-	|| read(dosfs, fsinfo, sizeof fsinfo) != sizeof fsinfo) {
+	|| read(dosfs, fsinfo, 2 * boot->BytesPerSec) != 2 * boot->BytesPerSec) {
 		perr("could not read fsinfo block");
+		free(fsinfo);
 		return FSFATAL;
 	}
 	fsinfo[0x1e8] = (u_char)boot->FSFree;
@@ -283,11 +322,14 @@ writefsinfo(int dosfs, struct bootblock 
 	fsinfo[0x1ef] = (u_char)(boot->FSNext >> 24);
 	if (lseek(dosfs, boot->FSInfo * boot->BytesPerSec, SEEK_SET)
 	!= boot->FSInfo * boot->BytesPerSec
-	|| write(dosfs, fsinfo, sizeof fsinfo)
-	!= sizeof fsinfo) {
+	|| write(dosfs, fsinfo, 2 * boot->BytesPerSec) != 2 * boot->BytesPerSec) {
 		perr("Unable to write FSInfo");
+		free(fsinfo);
 		return FSFATAL;
 	}
+
+	free(fsinfo);
+
 	/*
 	 * Technically, we should return FSBOOTMOD here.
 	 *



CVS commit: src/sbin/fsck_msdos

2022-04-23 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Apr 23 22:40:28 UTC 2022

Modified Files:
src/sbin/fsck_msdos: boot.c

Log Message:
Support large disk sectors.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sbin/fsck_msdos/boot.c

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



CVS commit: src/doc

2022-04-23 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat Apr 23 20:56:43 UTC 2022

Modified Files:
src/doc: 3RDPARTY

Log Message:
gcc-11.3 out.


To generate a diff of this commit:
cvs rdiff -u -r1.1851 -r1.1852 src/doc/3RDPARTY

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

Modified files:

Index: src/doc/3RDPARTY
diff -u src/doc/3RDPARTY:1.1851 src/doc/3RDPARTY:1.1852
--- src/doc/3RDPARTY:1.1851	Fri Apr 15 14:02:08 2022
+++ src/doc/3RDPARTY	Sat Apr 23 20:56:43 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: 3RDPARTY,v 1.1851 2022/04/15 14:02:08 christos Exp $
+#	$NetBSD: 3RDPARTY,v 1.1852 2022/04/23 20:56:43 wiz Exp $
 #
 # This file contains a list of the software that has been integrated into
 # NetBSD where we are not the primary maintainer.
@@ -451,7 +451,7 @@ There is a flex2netbsd script to help ne
 
 Package:	gcc
 Version:	9.3.0/10.3.0
-Current Vers:	9.3.0/10.3.0/11.2.0
+Current Vers:	9.3.0/10.3.0/11.3.0
 Maintainer:	FSF
 Archive Site:	ftp://ftp.gnu.org/gnu/gcc/
 Home Page:	http://www.gnu.org/software/gcc/



CVS commit: src/doc

2022-04-23 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat Apr 23 20:56:43 UTC 2022

Modified Files:
src/doc: 3RDPARTY

Log Message:
gcc-11.3 out.


To generate a diff of this commit:
cvs rdiff -u -r1.1851 -r1.1852 src/doc/3RDPARTY

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



CVS commit: src/sys/compat/netbsd32

2022-04-23 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Sat Apr 23 17:46:23 UTC 2022

Modified Files:
src/sys/compat/netbsd32: netbsd32.h netbsd32_fs.c

Log Message:
Implement support for mounting UDF in compat32
Fixes PR#56801


To generate a diff of this commit:
cvs rdiff -u -r1.139 -r1.140 src/sys/compat/netbsd32/netbsd32.h
cvs rdiff -u -r1.94 -r1.95 src/sys/compat/netbsd32/netbsd32_fs.c

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



CVS commit: src/sys/compat/netbsd32

2022-04-23 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Sat Apr 23 17:46:23 UTC 2022

Modified Files:
src/sys/compat/netbsd32: netbsd32.h netbsd32_fs.c

Log Message:
Implement support for mounting UDF in compat32
Fixes PR#56801


To generate a diff of this commit:
cvs rdiff -u -r1.139 -r1.140 src/sys/compat/netbsd32/netbsd32.h
cvs rdiff -u -r1.94 -r1.95 src/sys/compat/netbsd32/netbsd32_fs.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/compat/netbsd32/netbsd32.h
diff -u src/sys/compat/netbsd32/netbsd32.h:1.139 src/sys/compat/netbsd32/netbsd32.h:1.140
--- src/sys/compat/netbsd32/netbsd32.h:1.139	Thu Nov 11 17:32:46 2021
+++ src/sys/compat/netbsd32/netbsd32.h	Sat Apr 23 17:46:23 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32.h,v 1.139 2021/11/11 17:32:46 martin Exp $	*/
+/*	$NetBSD: netbsd32.h,v 1.140 2022/04/23 17:46:23 reinoud Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001, 2008, 2015 Matthew R. Green
@@ -1140,6 +1140,25 @@ struct netbsd32_msdosfs_args {
 	int	gmtoff;		/* v3: offset from UTC in seconds */
 };
 
+/* from  */
+struct netbsd32_udf_args {
+	uint32_t	 version;	/* version of this structure */
+	netbsd32_charp	 fspec;		/* mount specifier   */
+	int32_t		 sessionnr;	/* session specifier, rel of abs */
+	uint32_t	 udfmflags;	/* mount options */
+	int32_t		 gmtoff;	/* offset from UTC in seconds*/
+
+	uid_t		 anon_uid;	/* mapping of anonymous files uid*/
+	gid_t		 anon_gid;	/* mapping of anonymous files gid*/
+	uid_t		 nobody_uid;	/* nobody:nobody will map to -1:-1   */
+	gid_t		 nobody_gid;	/* nobody:nobody will map to -1:-1   */
+
+	uint32_t	 sector_size;	/* for mounting dumps/files  */
+
+	/* extendable */
+	uint8_t	 reserved[32];
+};
+
 /* from  */
 struct netbsd32_layer_args {
 	netbsd32_charp target;		/* Target of loopback  */

Index: src/sys/compat/netbsd32/netbsd32_fs.c
diff -u src/sys/compat/netbsd32/netbsd32_fs.c:1.94 src/sys/compat/netbsd32/netbsd32_fs.c:1.95
--- src/sys/compat/netbsd32/netbsd32_fs.c:1.94	Sat Sep 11 10:08:55 2021
+++ src/sys/compat/netbsd32/netbsd32_fs.c	Sat Apr 23 17:46:23 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_fs.c,v 1.94 2021/09/11 10:08:55 riastradh Exp $	*/
+/*	$NetBSD: netbsd32_fs.c,v 1.95 2022/04/23 17:46:23 reinoud Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_fs.c,v 1.94 2021/09/11 10:08:55 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_fs.c,v 1.95 2022/04/23 17:46:23 reinoud Exp $");
 
 #include 
 #include 
@@ -53,6 +53,7 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_fs.
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -790,6 +791,7 @@ netbsd32___mount50(struct lwp *l, const 
 		struct netbsd32_iso_args iso_args;
 		struct netbsd32_nfs_args nfs_args;
 		struct netbsd32_msdosfs_args msdosfs_args;
+		struct netbsd32_udf_args udf_args;
 		struct netbsd32_tmpfs_args tmpfs_args;
 		struct netbsd32_null_args null_args;
 	} fs_args32;
@@ -799,6 +801,7 @@ netbsd32___mount50(struct lwp *l, const 
 		struct iso_args iso_args;
 		struct nfs_args nfs_args;
 		struct msdosfs_args msdosfs_args;
+		struct udf_args udf_args;
 		struct tmpfs_args tmpfs_args;
 		struct null_args null_args;
 	} fs_args;
@@ -925,6 +928,40 @@ netbsd32___mount50(struct lwp *l, const 
 		data_seg = UIO_SYSSPACE;
 		data = _args.msdosfs_args;
 		data_len = sizeof(fs_args.msdosfs_args);
+	} else if (strcmp(mtype, MOUNT_UDF) == 0) {
+		if (data_len != 0 && data_len < sizeof(fs_args32.udf_args))
+			return EINVAL;
+		if ((flags & MNT_GETARGS) == 0) {
+			error = copyin(data, _args32.udf_args,
+			sizeof(fs_args32.udf_args));
+			if (error)
+return error;
+			fs_args.udf_args.version =
+			fs_args32.udf_args.version;
+			fs_args.udf_args.fspec =
+			NETBSD32PTR64(fs_args32.udf_args.fspec);
+			fs_args.udf_args.sessionnr =
+			fs_args32.udf_args.sessionnr;
+			fs_args.udf_args.udfmflags =
+			fs_args32.udf_args.udfmflags;
+			fs_args.udf_args.gmtoff =
+			fs_args32.udf_args.gmtoff;
+			fs_args.udf_args.anon_uid =
+			fs_args32.udf_args.anon_uid;
+			fs_args.udf_args.anon_gid =
+			fs_args32.udf_args.anon_gid;
+			fs_args.udf_args.nobody_uid =
+			fs_args32.udf_args.nobody_uid;
+			fs_args.udf_args.nobody_gid =
+			fs_args32.udf_args.nobody_gid;
+			fs_args.udf_args.sector_size =
+			fs_args32.udf_args.sector_size;
+			memset(fs_args.udf_args.reserved, 0,
+			sizeof(fs_args.udf_args.reserved));
+		}
+		data_seg = UIO_SYSSPACE;
+		data = _args.udf_args;
+		data_len = sizeof(fs_args.udf_args);
 	} else if (strcmp(mtype, MOUNT_NFS) == 0) {
 		if (data_len != 0 && data_len < sizeof(fs_args32.nfs_args))
 			return EINVAL;
@@ -1032,6 +1069,35 @@ netbsd32___mount50(struct lwp *l, const 
 			error = copyout(_args32.iso_args, udata,
 sizeof(fs_args32.iso_args));
 			

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

2022-04-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Apr 23 17:25:58 UTC 2022

Modified Files:
src/tests/usr.bin/indent: lsym_lparen_or_lbracket.c token_binary_op.c

Log Message:
tests/indent: add tests for unary and binary operators


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

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

Modified files:

Index: src/tests/usr.bin/indent/lsym_lparen_or_lbracket.c
diff -u src/tests/usr.bin/indent/lsym_lparen_or_lbracket.c:1.4 src/tests/usr.bin/indent/lsym_lparen_or_lbracket.c:1.5
--- src/tests/usr.bin/indent/lsym_lparen_or_lbracket.c:1.4	Fri Apr 22 21:21:20 2022
+++ src/tests/usr.bin/indent/lsym_lparen_or_lbracket.c	Sat Apr 23 17:25:58 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_lparen_or_lbracket.c,v 1.4 2022/04/22 21:21:20 rillig Exp $ */
+/* $NetBSD: lsym_lparen_or_lbracket.c,v 1.5 2022/04/23 17:25:58 rillig Exp $ */
 
 /*
  * Tests for the token lsym_lparen_or_lbracket, which represents a '(' or '['
@@ -15,12 +15,102 @@
  * In a 'sizeof' expression, '(' is required if the argument is a type name.
  *
  * After one of the keywords 'for', 'if', 'switch' or 'while', the controlling
- * expression must be enclosed in '(' and ')'.
+ * expression must be enclosed in '(' and ')'; see lsym_for.c, lsym_if.c,
+ * lsym_switch.c, lsym_while.c.
  *
- * In an expression, '(' followed by a type name starts a cast expression.
+ * In an expression, '(' followed by a type name starts a cast expression or
+ * a compound literal.
+ *
+ * In a declaration, '[' derives an array type.
+ *
+ * In an expression, '[' starts an array subscript.
+ */
+
+/* The '(' in a type name derives a function type. */
+#indent input
+typedef void signal_handler(int);
+void (*signal(void (*)(int)))(int);
+#indent end
+
+#indent run
+typedef void signal_handler(int);
+void		(*signal(void (*)(int)))(int);
+#indent end
+
+
+/*
+ * The '(' in an expression overrides operator precedence.  In multi-line
+ * expressions, the continuation lines are aligned on the parentheses.
  */
+#indent input
+int nested = (
+	(
+		(
+			(
+1 + 4
+			)
+		)
+	)
+);
+#indent end
+
+#indent run
+int		nested = (
+			  (
+			   (
+			(
+			 1 + 4
+			 )
+			)
+			   )
+);
+#indent end
+
+
+/* The '(' in a function call expression starts the argument list. */
+#indent input
+int var = macro_call ( arg1,  arg2  ,arg3);
+#indent end
+
+#indent run
+int		var = macro_call(arg1, arg2, arg3);
+#indent end
+
+
+/*
+ * The '(' in a sizeof expression is required for type names and optional for
+ * expressions.
+ */
+#indent input
+size_t sizeof_typename = sizeof ( int );
+size_t sizeof_expr = sizeof ( 12345 ) ;
+#indent end
+
+#indent run
+size_t		sizeof_typename = sizeof(int);
+size_t		sizeof_expr = sizeof(12345);
+#indent end
+
+
+/* The '[' in a type name derives an array type. */
+#indent input
+int array_of_numbers[100];
+#indent end
+
+#indent run
+int		array_of_numbers[100];
+#indent end
+
+
+/* The '[' in an expression accesses an array element. */
+#indent input
+int second_prime = [1];
+#indent end
+
+#indent run
+int		second_prime = [1];
+#indent end
 
-// TODO: Add systematic tests for all cases.
 
 #indent input
 void

Index: src/tests/usr.bin/indent/token_binary_op.c
diff -u src/tests/usr.bin/indent/token_binary_op.c:1.11 src/tests/usr.bin/indent/token_binary_op.c:1.12
--- src/tests/usr.bin/indent/token_binary_op.c:1.11	Sat Apr 23 09:35:26 2022
+++ src/tests/usr.bin/indent/token_binary_op.c	Sat Apr 23 17:25:58 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: token_binary_op.c,v 1.11 2022/04/23 09:35:26 rillig Exp $ */
+/* $NetBSD: token_binary_op.c,v 1.12 2022/04/23 17:25:58 rillig Exp $ */
 
 /*
  * Tests for binary operators like '+', '&&' and several others.
@@ -15,15 +15,10 @@
 void
 punctuators(void)
 {
-	int brackets = array[subscript];
-	int parentheses = function(argument);
 	int braces = { initializer };
 	int period = structure.member;
 	int arrow = structure->member;
 
-	number = function(argument1, argument2);
-	number = function(argument), number;
-
 	/* digraphs */
 	number = array<:subscript:>;
 	number = (int)<% initializer %>;
@@ -34,16 +29,11 @@ punctuators(void)
 void
 punctuators(void)
 {
-	int brackets = array[subscript];
-	int parentheses = function(argument);
 /* $ XXX: The spaces around the initializer are gone. */
 	int braces = {initializer};
 	int period = structure.member;
 	int arrow = structure->member;
 
-	number = function(argument1, argument2);
-	number = function(argument), number;
-
 	/* digraphs */
 /* $ XXX: indent is confused by the digraphs for '[' and ']'. */
 /* $ This probably doesn't matter since digraphs are not used in practice. */
@@ -83,9 +73,9 @@ long_run_of_operators(void)
 
 
 /*
- * For '+' and '-', this does not work since the lexer has to
- * distinguish 

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

2022-04-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Apr 23 17:25:58 UTC 2022

Modified Files:
src/tests/usr.bin/indent: lsym_lparen_or_lbracket.c token_binary_op.c

Log Message:
tests/indent: add tests for unary and binary operators


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

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



CVS commit: src/sys

2022-04-23 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Apr 23 16:22:23 UTC 2022

Modified Files:
src/sys/dev/dkwedge: dk.c
src/sys/ufs/ffs: ffs_alloc.c

Log Message:
Need vnode locked fot VOP_FDISCARD().


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/sys/dev/dkwedge/dk.c
cvs rdiff -u -r1.170 -r1.171 src/sys/ufs/ffs/ffs_alloc.c

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



CVS commit: src/sys

2022-04-23 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Apr 23 16:22:23 UTC 2022

Modified Files:
src/sys/dev/dkwedge: dk.c
src/sys/ufs/ffs: ffs_alloc.c

Log Message:
Need vnode locked fot VOP_FDISCARD().


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/sys/dev/dkwedge/dk.c
cvs rdiff -u -r1.170 -r1.171 src/sys/ufs/ffs/ffs_alloc.c

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

Modified files:

Index: src/sys/dev/dkwedge/dk.c
diff -u src/sys/dev/dkwedge/dk.c:1.110 src/sys/dev/dkwedge/dk.c:1.111
--- src/sys/dev/dkwedge/dk.c:1.110	Sat Jan 15 19:34:11 2022
+++ src/sys/dev/dkwedge/dk.c	Sat Apr 23 16:22:23 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: dk.c,v 1.110 2022/01/15 19:34:11 riastradh Exp $	*/
+/*	$NetBSD: dk.c,v 1.111 2022/04/23 16:22:23 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2004, 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.110 2022/01/15 19:34:11 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.111 2022/04/23 16:22:23 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_dkwedge.h"
@@ -1592,6 +1592,7 @@ dkdiscard(dev_t dev, off_t pos, off_t le
 	struct dkwedge_softc *sc = dkwedge_lookup(dev);
 	unsigned shift;
 	off_t offset, maxlen;
+	int error;
 
 	if (sc == NULL)
 		return (ENODEV);
@@ -1615,7 +1616,12 @@ dkdiscard(dev_t dev, off_t pos, off_t le
 		return (EINVAL);
 
 	pos += offset;
-	return VOP_FDISCARD(sc->sc_parent->dk_rawvp, pos, len);
+
+	vn_lock(sc->sc_parent->dk_rawvp, LK_EXCLUSIVE | LK_RETRY);
+	error = VOP_FDISCARD(sc->sc_parent->dk_rawvp, pos, len);
+	VOP_UNLOCK(sc->sc_parent->dk_rawvp);
+
+	return error;
 }
 
 /*

Index: src/sys/ufs/ffs/ffs_alloc.c
diff -u src/sys/ufs/ffs/ffs_alloc.c:1.170 src/sys/ufs/ffs/ffs_alloc.c:1.171
--- src/sys/ufs/ffs/ffs_alloc.c:1.170	Fri Sep  3 21:55:01 2021
+++ src/sys/ufs/ffs/ffs_alloc.c	Sat Apr 23 16:22:23 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_alloc.c,v 1.170 2021/09/03 21:55:01 andvar Exp $	*/
+/*	$NetBSD: ffs_alloc.c,v 1.171 2022/04/23 16:22:23 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.170 2021/09/03 21:55:01 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.171 2022/04/23 16:22:23 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -1649,10 +1649,12 @@ ffs_discardcb(struct work *wk, void *arg
 
 	start = FFS_FSBTOBYTES(fs, td->bno);
 	len = td->size;
+	vn_lock(td->devvp, LK_EXCLUSIVE | LK_RETRY);
 #ifdef TRIMDEBUG
 	error =
 #endif
 		VOP_FDISCARD(td->devvp, start, len);
+	VOP_UNLOCK(td->devvp);
 #ifdef TRIMDEBUG
 	printf("trim(%" PRId64 ",%ld):%d\n", td->bno, td->size, error);
 #endif



CVS commit: src/tests/lib/libutil

2022-04-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Apr 23 13:08:49 UTC 2022

Modified Files:
src/tests/lib/libutil: t_parsedate.c

Log Message:
1. add check for December in MM/DD/
2. unsetenv("TZ") since tests assume UTC (all relative tests and one date test
   fail otherwise)


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/tests/lib/libutil/t_parsedate.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/lib/libutil/t_parsedate.c
diff -u src/tests/lib/libutil/t_parsedate.c:1.31 src/tests/lib/libutil/t_parsedate.c:1.32
--- src/tests/lib/libutil/t_parsedate.c:1.31	Mon Oct 19 11:06:49 2020
+++ src/tests/lib/libutil/t_parsedate.c	Sat Apr 23 09:08:49 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: t_parsedate.c,v 1.31 2020/10/19 15:06:49 kre Exp $ */
+/* $NetBSD: t_parsedate.c,v 1.32 2022/04/23 13:08:49 christos Exp $ */
 /*-
  * Copyright (c) 2010, 2015 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_parsedate.c,v 1.31 2020/10/19 15:06:49 kre Exp $");
+__RCSID("$NetBSD: t_parsedate.c,v 1.32 2022/04/23 13:08:49 christos Exp $");
 
 #include 
 #include 
@@ -137,6 +137,8 @@ ATF_TC_BODY(dates, tc)
 		2006, 11, 17, 0, 0, 0);
 	parsecheck("10/1/2000", NULL, NULL, localtime_r,
 		2000, 10, 1, 0, 0, 0); /* month/day/year */
+	parsecheck("12/01/2022", NULL, NULL, localtime_r,
+		2022, 12, 1, 0, 0, 0); /* month/day/year, December */
 	parsecheck("20 Jun 1994", NULL, NULL, localtime_r,
 		1994, 6, 20, 0, 0, 0);
 	parsecheck("97 September 2", NULL, NULL, localtime_r,
@@ -618,6 +620,7 @@ ATF_TC_BODY(gibberish, tc)
 
 ATF_TP_ADD_TCS(tp)
 {
+	unsetenv("TZ");
 	ATF_TP_ADD_TC(tp, dates);
 	ATF_TP_ADD_TC(tp, times);
 	ATF_TP_ADD_TC(tp, dsttimes);



CVS commit: src/tests/lib/libutil

2022-04-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Apr 23 13:08:49 UTC 2022

Modified Files:
src/tests/lib/libutil: t_parsedate.c

Log Message:
1. add check for December in MM/DD/
2. unsetenv("TZ") since tests assume UTC (all relative tests and one date test
   fail otherwise)


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/tests/lib/libutil/t_parsedate.c

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



CVS commit: src/lib/libutil

2022-04-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Apr 23 13:02:04 UTC 2022

Modified Files:
src/lib/libutil: parsedate.y

Log Message:
fix date -d 12/01/2022, found by Anon Ymous


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/lib/libutil/parsedate.y

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

Modified files:

Index: src/lib/libutil/parsedate.y
diff -u src/lib/libutil/parsedate.y:1.36 src/lib/libutil/parsedate.y:1.37
--- src/lib/libutil/parsedate.y:1.36	Fri Oct 30 18:03:11 2020
+++ src/lib/libutil/parsedate.y	Sat Apr 23 09:02:04 2022
@@ -14,7 +14,7 @@
 
 #include 
 #ifdef __RCSID
-__RCSID("$NetBSD: parsedate.y,v 1.36 2020/10/30 22:03:11 kre Exp $");
+__RCSID("$NetBSD: parsedate.y,v 1.37 2022/04/23 13:02:04 christos Exp $");
 #endif
 
 #include 
@@ -359,7 +359,7 @@ date:
 			param->yyMonth = $3;
 			param->yyDay = $5;
 		} else {
-			if ($1 >= 12 || $3 > 31 || $1 == 0 || $3 == 0)
+			if ($1 > 12 || $3 > 31 || $1 == 0 || $3 == 0)
 YYREJECT;
 			param->yyMonth = $1;
 			param->yyDay = $3;



CVS commit: src/lib/libutil

2022-04-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Apr 23 13:02:04 UTC 2022

Modified Files:
src/lib/libutil: parsedate.y

Log Message:
fix date -d 12/01/2022, found by Anon Ymous


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/lib/libutil/parsedate.y

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



CVS commit: src/sys/dev/audio

2022-04-23 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Apr 23 11:44:01 UTC 2022

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
audio(4): Fix a typo in comment.  Remove several old comments.


To generate a diff of this commit:
cvs rdiff -u -r1.132 -r1.133 src/sys/dev/audio/audio.c

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

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.132 src/sys/dev/audio/audio.c:1.133
--- src/sys/dev/audio/audio.c:1.132	Sat Apr 23 11:30:57 2022
+++ src/sys/dev/audio/audio.c	Sat Apr 23 11:44:01 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.132 2022/04/23 11:30:57 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.133 2022/04/23 11:44:01 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -181,7 +181,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.132 2022/04/23 11:30:57 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.133 2022/04/23 11:44:01 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -3160,7 +3160,6 @@ audio_ioctl(dev_t dev, struct audio_soft
 			audio_exlock_exit(sc);
 			break;
 		}
-		/* XXX TODO: update last_ai if /dev/sound ? */
 		if (ISDEVSOUND(dev))
 			error = audiogetinfo(sc, >sc_ai, 0, file);
 		audio_exlock_exit(sc);
@@ -4514,7 +4513,7 @@ audio_track_init_freq(audio_track_t *tra
 
 		arg = >freq.arg;
 		arg->srcfmt = >fmt;
-		arg->dstfmt = dstfmt;/*_dst->fmt;*/
+		arg->dstfmt = dstfmt;
 		arg->context = track;
 
 		*last_dstp = srcbuf;
@@ -4780,7 +4779,7 @@ audio_track_set_format(audio_track_t *tr
 
 	/*
 	 * On the recording track, expand the input stage buffer, which is
-	 * the closest buffer to rmixer, to NBLKOUT blocks.
+	 * the closest buffer to rmixer, to NBLKIN blocks.
 	 * Note that input buffer may point to outbuf.
 	 */
 	if (!is_playback) {



CVS commit: src/sys/dev/audio

2022-04-23 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Apr 23 11:44:01 UTC 2022

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
audio(4): Fix a typo in comment.  Remove several old comments.


To generate a diff of this commit:
cvs rdiff -u -r1.132 -r1.133 src/sys/dev/audio/audio.c

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



CVS commit: src/sys/dev/audio

2022-04-23 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Apr 23 11:30:57 UTC 2022

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
audio(4): Clean up about audio_realloc().
- audio_realloc() never returns NULL, so there is no need to check it.
- audio_free() is no point in this case.


To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 src/sys/dev/audio/audio.c

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

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.131 src/sys/dev/audio/audio.c:1.132
--- src/sys/dev/audio/audio.c:1.131	Sat Apr 23 07:55:07 2022
+++ src/sys/dev/audio/audio.c	Sat Apr 23 11:30:57 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.131 2022/04/23 07:55:07 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.132 2022/04/23 11:30:57 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -181,7 +181,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.131 2022/04/23 07:55:07 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.132 2022/04/23 11:30:57 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -3689,7 +3689,8 @@ audio_realloc(void *memblock, size_t byt
 {
 
 	KASSERT(bytes != 0);
-	audio_free(memblock);
+	if (memblock)
+		kern_free(memblock);
 	return kern_malloc(bytes, M_WAITOK);
 }
 
@@ -4776,11 +4777,6 @@ audio_track_set_format(audio_track_t *tr
 		track->outbuf.capacity *= NBLKOUT;
 	len = auring_bytelen(>outbuf);
 	track->outbuf.mem = audio_realloc(track->outbuf.mem, len);
-	if (track->outbuf.mem == NULL) {
-		device_printf(sc->sc_dev, "malloc outbuf(%d) failed\n", len);
-		error = ENOMEM;
-		goto error;
-	}
 
 	/*
 	 * On the recording track, expand the input stage buffer, which is
@@ -5387,12 +5383,6 @@ audio_mixer_init(struct audio_softc *sc,
 		mixer->codecbuf.capacity = mixer->frames_per_block;
 		len = auring_bytelen(>codecbuf);
 		mixer->codecbuf.mem = audio_realloc(mixer->codecbuf.mem, len);
-		if (mixer->codecbuf.mem == NULL) {
-			device_printf(sc->sc_dev,
-			"malloc codecbuf(%d) failed\n", len);
-			error = ENOMEM;
-			goto abort;
-		}
 	}
 
 	/* Succeeded so display it. */



CVS commit: src/sys/dev/audio

2022-04-23 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Apr 23 11:30:57 UTC 2022

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
audio(4): Clean up about audio_realloc().
- audio_realloc() never returns NULL, so there is no need to check it.
- audio_free() is no point in this case.


To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 src/sys/dev/audio/audio.c

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



CVS commit: src

2022-04-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Apr 23 09:59:14 UTC 2022

Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/usr.bin/indent: Makefile lsym_lbrace.c lsym_period.c
Removed Files:
src/tests/usr.bin/indent: token_lbrace.c token_period.c

Log Message:
tests/indent: migrate tests for the tokens '{' and '.'


To generate a diff of this commit:
cvs rdiff -u -r1.1195 -r1.1196 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.41 -r1.42 src/tests/usr.bin/indent/Makefile
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/lsym_lbrace.c
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/lsym_period.c
cvs rdiff -u -r1.2 -r0 src/tests/usr.bin/indent/token_lbrace.c
cvs rdiff -u -r1.3 -r0 src/tests/usr.bin/indent/token_period.c

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1195 src/distrib/sets/lists/tests/mi:1.1196
--- src/distrib/sets/lists/tests/mi:1.1195	Sat Apr 23 09:01:03 2022
+++ src/distrib/sets/lists/tests/mi	Sat Apr 23 09:59:13 2022
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1195 2022/04/23 09:01:03 rillig Exp $
+# $NetBSD: mi,v 1.1196 2022/04/23 09:59:13 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -5273,10 +5273,10 @@
 ./usr/tests/usr.bin/indent/token_keyword_else.ctests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/token_keyword_for_if_while.c			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/token_keyword_struct_union_enum.c		tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/indent/token_lbrace.ctests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/token_lbrace.ctests-obsolete		obsolete,atf
 ./usr/tests/usr.bin/indent/token_lparen.ctests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/token_newline.ctests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/indent/token_period.ctests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/token_period.ctests-obsolete		obsolete,atf
 ./usr/tests/usr.bin/indent/token_postfix_op.ctests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/token_preprocessing.c			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/token_question.ctests-obsolete		obsolete,atf

Index: src/tests/usr.bin/indent/Makefile
diff -u src/tests/usr.bin/indent/Makefile:1.41 src/tests/usr.bin/indent/Makefile:1.42
--- src/tests/usr.bin/indent/Makefile:1.41	Sat Apr 23 09:01:03 2022
+++ src/tests/usr.bin/indent/Makefile	Sat Apr 23 09:59:14 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.41 2022/04/23 09:01:03 rillig Exp $
+#	$NetBSD: Makefile,v 1.42 2022/04/23 09:59:14 rillig Exp $
 
 .include 
 
@@ -124,10 +124,8 @@ FILES+=		token_keyword_do_else.c
 FILES+=		token_keyword_else.c
 FILES+=		token_keyword_for_if_while.c
 FILES+=		token_keyword_struct_union_enum.c
-FILES+=		token_lbrace.c
 FILES+=		token_lparen.c
 FILES+=		token_newline.c
-FILES+=		token_period.c
 FILES+=		token_postfix_op.c
 FILES+=		token_preprocessing.c
 FILES+=		token_rbrace.c

Index: src/tests/usr.bin/indent/lsym_lbrace.c
diff -u src/tests/usr.bin/indent/lsym_lbrace.c:1.4 src/tests/usr.bin/indent/lsym_lbrace.c:1.5
--- src/tests/usr.bin/indent/lsym_lbrace.c:1.4	Fri Apr 22 21:21:20 2022
+++ src/tests/usr.bin/indent/lsym_lbrace.c	Sat Apr 23 09:59:14 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_lbrace.c,v 1.4 2022/04/22 21:21:20 rillig Exp $ */
+/* $NetBSD: lsym_lbrace.c,v 1.5 2022/04/23 09:59:14 rillig Exp $ */
 
 /*
  * Tests for the token lsym_lbrace, which represents a '{' in these contexts:
@@ -11,11 +11,64 @@
  * In an expression, '(type){' starts a compound literal that is typically
  * used in an assignment to a struct or array.
  *
+ * In macro arguments, a '{' is an ordinary character, it does not need to be
+ * balanced.  This is in contrast to '(', which must be balanced with ')'.
+ *
  * TODO: try to split this token into lsym_lbrace_block and lsym_lbrace_init.
  */
 
+/* Brace level in an initializer */
 #indent input
-// TODO: add input
+void
+function(void)
+{
+	struct person	p = {
+		.name = "Name",
+		.age = {{{35}}},	/* C11 6.7.9 allows this. */
+	};
+}
 #indent end
 
 #indent run-equals-input
+
+
+/* Begin of a block of statements */
+#indent input
+void function(void) {{{ body(); }}}
+#indent end
+
+#indent run
+void
+function(void)
+/* $ FIXME: Each '{' must be properly indented. */
+{{{
+			body();
+}
+}
+}
+#indent end
+
+
+/* Compound literal */
+#indent input
+struct point
+origin(void)
+{
+	return (struct point){
+		.x = 0,
+		.y = 0,
+	};
+}
+#indent end
+
+#indent run
+struct point
+origin(void)
+{
+	return (struct point){
+		.x = 0,
+/* $ FIXME: All initializers must be indented to the same level. */
+			.y = 0,
+	};
+}
+#indent end

Index: src/tests/usr.bin/indent/lsym_period.c
diff -u 

CVS commit: src

2022-04-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Apr 23 09:59:14 UTC 2022

Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/usr.bin/indent: Makefile lsym_lbrace.c lsym_period.c
Removed Files:
src/tests/usr.bin/indent: token_lbrace.c token_period.c

Log Message:
tests/indent: migrate tests for the tokens '{' and '.'


To generate a diff of this commit:
cvs rdiff -u -r1.1195 -r1.1196 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.41 -r1.42 src/tests/usr.bin/indent/Makefile
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/lsym_lbrace.c
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/lsym_period.c
cvs rdiff -u -r1.2 -r0 src/tests/usr.bin/indent/token_lbrace.c
cvs rdiff -u -r1.3 -r0 src/tests/usr.bin/indent/token_period.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

2022-04-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Apr 23 09:35:26 UTC 2022

Modified Files:
src/tests/usr.bin/indent: lsym_binary_op.c lsym_unary_op.c
token_binary_op.c

Log Message:
tests/indent: migrate tests for unary and binary operators


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/indent/lsym_binary_op.c
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/lsym_unary_op.c
cvs rdiff -u -r1.10 -r1.11 src/tests/usr.bin/indent/token_binary_op.c

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

Modified files:

Index: src/tests/usr.bin/indent/lsym_binary_op.c
diff -u src/tests/usr.bin/indent/lsym_binary_op.c:1.3 src/tests/usr.bin/indent/lsym_binary_op.c:1.4
--- src/tests/usr.bin/indent/lsym_binary_op.c:1.3	Fri Apr 22 21:21:20 2022
+++ src/tests/usr.bin/indent/lsym_binary_op.c	Sat Apr 23 09:35:26 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_binary_op.c,v 1.3 2022/04/22 21:21:20 rillig Exp $ */
+/* $NetBSD: lsym_binary_op.c,v 1.4 2022/04/23 09:35:26 rillig Exp $ */
 
 /*
  * Tests for the token lsym_binary_op, which represents a binary operator in
@@ -22,7 +22,42 @@
  */
 
 #indent input
-// TODO: add input
+void
+binary_operators(void)
+{
+	/* In the order of appearance in C11 6.5. */
+	a = a * a;
+	a = a / a;
+	a = a % a;
+	a = a + a;
+	a = a - a;
+	a = a << a;
+	a = a >> a;
+	a = a < a;
+	a = a > a;
+	a = a <= a;
+	a = a >= a;
+	a = a == a;
+	a = a != a;
+	a = a & a;
+	a = a ^ a;
+	a = a | a;
+	a = a && a;
+	a = a || a;
+	a = a ? a : a;
+	a = a;
+	a *= a;
+	a /= a;
+	a %= a;
+	a += a;
+	a -= a;
+	a <<= a;
+	a >>= a;
+	a &= a;
+	a ^= a;
+	a |= a;
+	a = a, a;
+}
 #indent end
 
 #indent run-equals-input

Index: src/tests/usr.bin/indent/lsym_unary_op.c
diff -u src/tests/usr.bin/indent/lsym_unary_op.c:1.2 src/tests/usr.bin/indent/lsym_unary_op.c:1.3
--- src/tests/usr.bin/indent/lsym_unary_op.c:1.2	Fri Apr 22 21:21:20 2022
+++ src/tests/usr.bin/indent/lsym_unary_op.c	Sat Apr 23 09:35:26 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_unary_op.c,v 1.2 2022/04/22 21:21:20 rillig Exp $ */
+/* $NetBSD: lsym_unary_op.c,v 1.3 2022/04/23 09:35:26 rillig Exp $ */
 
 /*
  * Tests for the token lsym_unary_op, which represents a unary operator.
@@ -11,7 +11,12 @@
  */
 
 #indent input
-// TODO: add input
+void
+unary_operators(void)
+{
+	/* In the order of appearance in C11 6.5. */
+	function(a++, a--, ++a, --a, , *a, +a, -a, ~a, !a);
+}
 #indent end
 
 #indent run-equals-input

Index: src/tests/usr.bin/indent/token_binary_op.c
diff -u src/tests/usr.bin/indent/token_binary_op.c:1.10 src/tests/usr.bin/indent/token_binary_op.c:1.11
--- src/tests/usr.bin/indent/token_binary_op.c:1.10	Fri Apr 22 21:21:20 2022
+++ src/tests/usr.bin/indent/token_binary_op.c	Sat Apr 23 09:35:26 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: token_binary_op.c,v 1.10 2022/04/22 21:21:20 rillig Exp $ */
+/* $NetBSD: token_binary_op.c,v 1.11 2022/04/23 09:35:26 rillig Exp $ */
 
 /*
  * Tests for binary operators like '+', '&&' and several others.
@@ -21,50 +21,6 @@ punctuators(void)
 	int period = structure.member;
 	int arrow = structure->member;
 
-	++prefix_increment;
-	postfix_increment++;
-	--prefix_decrement;
-	postfix_decrement--;
-	int *address = 
-	int bitwise_and = value & mask;
-	int product = factor * factor;
-	int dereferenced = *address;
-	int positive = +number;
-	int sum = number + number;
-	int negative = -number;
-	int difference = number - number;
-	bool negated = !condition;
-
-	int quotient = number / number;
-	int modulo = number % number;
-	int shifted_left = number << number;
-	int shifted_right = number >> number;
-	bool less_than = number < number;
-	bool greater_than = number > number;
-	bool less_equal = number <= number;
-	bool greater_equal = number >= number;
-	bool equal = number == number;
-	bool unequal = number != number;
-	int bitwise_exclusive_or = number ^ number;
-	int bitwise_or = number | number;
-	bool logical_and = condition && condition;
-	bool logical_or = condition || condition;
-
-	int conditional = condition ? number : number;
-
-	/* combined assignment operators */
-	number = (expression);
-	number *= number;
-	number /= number;
-	number %= number;
-	number += number;
-	number -= number;
-	number <<= number;
-	number >>= number;
-	number &= number;
-	number ^= number;
-	number |= number;
-
 	number = function(argument1, argument2);
 	number = function(argument), number;
 
@@ -85,50 +41,6 @@ punctuators(void)
 	int period = structure.member;
 	int arrow = structure->member;
 
-	++prefix_increment;
-	postfix_increment++;
-	--prefix_decrement;
-	postfix_decrement--;
-	int *address = 
-	int bitwise_and = value & mask;
-	int product = factor * factor;
-	int dereferenced = *address;
-	int positive = +number;
-	int sum = number + number;
-	int negative = -number;
-	int difference = number - number;
-	bool negated = !condition;
-
-	int quotient = number / number;
-	int modulo = number % number;
-	int 

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

2022-04-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Apr 23 09:35:26 UTC 2022

Modified Files:
src/tests/usr.bin/indent: lsym_binary_op.c lsym_unary_op.c
token_binary_op.c

Log Message:
tests/indent: migrate tests for unary and binary operators


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/indent/lsym_binary_op.c
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/lsym_unary_op.c
cvs rdiff -u -r1.10 -r1.11 src/tests/usr.bin/indent/token_binary_op.c

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



CVS commit: src

2022-04-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Apr 23 09:01:03 UTC 2022

Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/usr.bin/indent: Makefile psym_if_expr.c psym_if_expr_stmt.c
psym_if_expr_stmt_else.c
Removed Files:
src/tests/usr.bin/indent: token_if_expr.c token_if_expr_stmt.c
token_if_expr_stmt_else.c

Log Message:
tests/indent: migrate a few token tests to psym tests


To generate a diff of this commit:
cvs rdiff -u -r1.1194 -r1.1195 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.40 -r1.41 src/tests/usr.bin/indent/Makefile
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/psym_if_expr.c \
src/tests/usr.bin/indent/psym_if_expr_stmt.c \
src/tests/usr.bin/indent/psym_if_expr_stmt_else.c
cvs rdiff -u -r1.2 -r0 src/tests/usr.bin/indent/token_if_expr.c \
src/tests/usr.bin/indent/token_if_expr_stmt.c \
src/tests/usr.bin/indent/token_if_expr_stmt_else.c

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1194 src/distrib/sets/lists/tests/mi:1.1195
--- src/distrib/sets/lists/tests/mi:1.1194	Wed Apr 20 07:41:04 2022
+++ src/distrib/sets/lists/tests/mi	Sat Apr 23 09:01:03 2022
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1194 2022/04/20 07:41:04 blymn Exp $
+# $NetBSD: mi,v 1.1195 2022/04/23 09:01:03 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -5265,9 +5265,9 @@
 ./usr/tests/usr.bin/indent/token_form_feed.ctests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/token_funcname.ctests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/token_ident.ctests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/indent/token_if_expr.ctests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/indent/token_if_expr_stmt.ctests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/indent/token_if_expr_stmt_else.c			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/token_if_expr.ctests-obsolete		obsolete,atf
+./usr/tests/usr.bin/indent/token_if_expr_stmt.ctests-obsolete		obsolete,atf
+./usr/tests/usr.bin/indent/token_if_expr_stmt_else.c			tests-obsolete		obsolete,atf
 ./usr/tests/usr.bin/indent/token_keyword_do.ctests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/token_keyword_do_else.c			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/token_keyword_else.ctests-usr.bin-tests	compattestfile,atf

Index: src/tests/usr.bin/indent/Makefile
diff -u src/tests/usr.bin/indent/Makefile:1.40 src/tests/usr.bin/indent/Makefile:1.41
--- src/tests/usr.bin/indent/Makefile:1.40	Fri Apr 22 21:21:20 2022
+++ src/tests/usr.bin/indent/Makefile	Sat Apr 23 09:01:03 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.40 2022/04/22 21:21:20 rillig Exp $
+#	$NetBSD: Makefile,v 1.41 2022/04/23 09:01:03 rillig Exp $
 
 .include 
 
@@ -119,9 +119,6 @@ FILES+=		token_for_exprs.c
 FILES+=		token_form_feed.c
 FILES+=		token_funcname.c
 FILES+=		token_ident.c
-FILES+=		token_if_expr.c
-FILES+=		token_if_expr_stmt.c
-FILES+=		token_if_expr_stmt_else.c
 FILES+=		token_keyword_do.c
 FILES+=		token_keyword_do_else.c
 FILES+=		token_keyword_else.c

Index: src/tests/usr.bin/indent/psym_if_expr.c
diff -u src/tests/usr.bin/indent/psym_if_expr.c:1.2 src/tests/usr.bin/indent/psym_if_expr.c:1.3
--- src/tests/usr.bin/indent/psym_if_expr.c:1.2	Fri Apr 22 21:21:20 2022
+++ src/tests/usr.bin/indent/psym_if_expr.c	Sat Apr 23 09:01:03 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: psym_if_expr.c,v 1.2 2022/04/22 21:21:20 rillig Exp $ */
+/* $NetBSD: psym_if_expr.c,v 1.3 2022/04/23 09:01:03 rillig Exp $ */
 
 /*
  * Tests for the parser symbol psym_if_expr, representing the parser state
@@ -7,7 +7,16 @@
  */
 
 #indent input
-// TODO: add input
+void function(void) {
+	if(cond) stmt();
+}
 #indent end
 
-#indent run-equals-input
+#indent run
+void
+function(void)
+{
+	if (cond)
+		stmt();
+}
+#indent end
Index: src/tests/usr.bin/indent/psym_if_expr_stmt.c
diff -u src/tests/usr.bin/indent/psym_if_expr_stmt.c:1.2 src/tests/usr.bin/indent/psym_if_expr_stmt.c:1.3
--- src/tests/usr.bin/indent/psym_if_expr_stmt.c:1.2	Fri Apr 22 21:21:20 2022
+++ src/tests/usr.bin/indent/psym_if_expr_stmt.c	Sat Apr 23 09:01:03 2022
@@ -1,14 +1,27 @@
-/* $NetBSD: psym_if_expr_stmt.c,v 1.2 2022/04/22 21:21:20 rillig Exp $ */
+/* $NetBSD: psym_if_expr_stmt.c,v 1.3 2022/04/23 09:01:03 rillig Exp $ */
 
 /*
  * Tests for the parser symbol psym_if_expr_stmt, which represents the state
  * after reading the keyword 'if', the controlling expression and the
- * statement for the 'then' branch.  If the next token is 'else', another
- * statement will follow, otherwise the 'if' statement is finished already.
+ * statement for the 'then' branch.
+ *
+ * At this point, the 'if' statement is not necessarily complete, it can be
+ * 

CVS commit: src

2022-04-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Apr 23 09:01:03 UTC 2022

Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/usr.bin/indent: Makefile psym_if_expr.c psym_if_expr_stmt.c
psym_if_expr_stmt_else.c
Removed Files:
src/tests/usr.bin/indent: token_if_expr.c token_if_expr_stmt.c
token_if_expr_stmt_else.c

Log Message:
tests/indent: migrate a few token tests to psym tests


To generate a diff of this commit:
cvs rdiff -u -r1.1194 -r1.1195 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.40 -r1.41 src/tests/usr.bin/indent/Makefile
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/psym_if_expr.c \
src/tests/usr.bin/indent/psym_if_expr_stmt.c \
src/tests/usr.bin/indent/psym_if_expr_stmt_else.c
cvs rdiff -u -r1.2 -r0 src/tests/usr.bin/indent/token_if_expr.c \
src/tests/usr.bin/indent/token_if_expr_stmt.c \
src/tests/usr.bin/indent/token_if_expr_stmt_else.c

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



CVS commit: src/sys/dev/audio

2022-04-23 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Apr 23 07:55:07 UTC 2022

Modified Files:
src/sys/dev/audio: audio.c audiodef.h

Log Message:
audio(4): Remove no longer used counters.
These were used at very early phase of development.


To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.131 src/sys/dev/audio/audio.c
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/audio/audiodef.h

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

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.130 src/sys/dev/audio/audio.c:1.131
--- src/sys/dev/audio/audio.c:1.130	Sat Apr 23 07:43:16 2022
+++ src/sys/dev/audio/audio.c	Sat Apr 23 07:55:07 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.130 2022/04/23 07:43:16 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.131 2022/04/23 07:55:07 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -181,7 +181,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.130 2022/04/23 07:43:16 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.131 2022/04/23 07:55:07 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -2825,7 +2825,6 @@ audio_read(struct audio_softc *sc, struc
 			goto abort;
 		}
 		auring_take(usrbuf, bytes);
-		track->useriobytes += bytes;
 		TRACET(3, track, "uiomove(len=%d) usrbuf=%d/%d/C%d",
 		bytes,
 		usrbuf->head, usrbuf->used, usrbuf->capacity);
@@ -2953,7 +2952,6 @@ audio_write(struct audio_softc *sc, stru
 goto abort;
 			}
 			auring_push(usrbuf, len);
-			track->useriobytes += len;
 			TRACET(3, track, "uiomove(len=%d) usrbuf=%d/%d/C%d",
 			len,
 			usrbuf->head, usrbuf->used, usrbuf->capacity);
@@ -4955,9 +4953,6 @@ audio_track_play(audio_track_t *track)
 	"count=%d fpb=%d",
 	count, frame_per_block(track->mixer, >outbuf.fmt));
 
-	/* XXX TODO: is this necessary for now? */
-	int track_count_0 = track->outbuf.used;
-
 	usrbuf = >usrbuf;
 	input = track->input;
 
@@ -5068,12 +5063,6 @@ audio_track_play(audio_track_t *track)
 		}
 	}
 
-	if (track->input == >outbuf) {
-		track->outputcounter = track->inputcounter;
-	} else {
-		track->outputcounter += track->outbuf.used - track_count_0;
-	}
-
 	track->stamp++;
 
 #if defined(AUDIO_DEBUG)
@@ -6389,8 +6378,7 @@ audio_track_drain(struct audio_softc *sc
 	}
 
 	track->pstate = AUDIO_STATE_CLEAR;
-	TRACET(3, track, "done trk_inp=%d trk_out=%d",
-		(int)track->inputcounter, (int)track->outputcounter);
+	TRACET(3, track, "done");
 	return 0;
 }
 

Index: src/sys/dev/audio/audiodef.h
diff -u src/sys/dev/audio/audiodef.h:1.18 src/sys/dev/audio/audiodef.h:1.19
--- src/sys/dev/audio/audiodef.h:1.18	Wed Apr 20 07:11:13 2022
+++ src/sys/dev/audio/audiodef.h	Sat Apr 23 07:55:07 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: audiodef.h,v 1.18 2022/04/20 07:11:13 isaki Exp $	*/
+/*	$NetBSD: audiodef.h,v 1.19 2022/04/23 07:55:07 isaki Exp $	*/
 
 /*
  * Copyright (C) 2017 Tetsuya Isaki. All rights reserved.
@@ -175,11 +175,7 @@ struct audio_track {
 	audio_state_t	pstate;		/* playback state */
 	bool		is_pause;
 
-	/* Statistic counters. */
-	uint64_t	inputcounter;	/* # of frames input to track */
-	uint64_t	outputcounter;	/* # of frames output from track */
-	uint64_t	useriobytes;	/* # of bytes xfer to/from userland */
-	uint64_t	dropframes;	/* # of frames dropped */
+	uint64_t	dropframes;	/* number of dropped frames */
 	int		eofcounter;	/* count of zero-sized write */
 
 	/*



CVS commit: src/sys/dev/audio

2022-04-23 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Apr 23 07:55:07 UTC 2022

Modified Files:
src/sys/dev/audio: audio.c audiodef.h

Log Message:
audio(4): Remove no longer used counters.
These were used at very early phase of development.


To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.131 src/sys/dev/audio/audio.c
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/audio/audiodef.h

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



CVS commit: src/tests/dev/audio

2022-04-23 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Apr 23 07:47:42 UTC 2022

Modified Files:
src/tests/dev/audio: audiotest.c

Log Message:
tests: Add tests for AUDIO_GET[IO]OFFS ioctls.
- AUDIO_GETIOFFS_one_{RDONLY,RDWR,WRONLY}
- AUDIO_GETOOFFS_one_{RDONLY,RDWR,WRONLY}
- AUDIO_GETOOFFS_wrap_{RDONLY,RDWR,WRONLY}
- AUDIO_GETOOFFS_flush_{RDONLY,RDWR,WRONLY}
- AUDIO_GETOOFFS_set_{RDONLY,RDWR,WRONLY}


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/tests/dev/audio/audiotest.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/dev/audio/audiotest.c
diff -u src/tests/dev/audio/audiotest.c:1.18 src/tests/dev/audio/audiotest.c:1.19
--- src/tests/dev/audio/audiotest.c:1.18	Fri Dec 10 20:36:05 2021
+++ src/tests/dev/audio/audiotest.c	Sat Apr 23 07:47:42 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: audiotest.c,v 1.18 2021/12/10 20:36:05 andvar Exp $	*/
+/*	$NetBSD: audiotest.c,v 1.19 2022/04/23 07:47:42 isaki Exp $	*/
 
 /*
  * Copyright (C) 2019 Tetsuya Isaki. All rights reserved.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: audiotest.c,v 1.18 2021/12/10 20:36:05 andvar Exp $");
+__RCSID("$NetBSD: audiotest.c,v 1.19 2022/04/23 07:47:42 isaki Exp $");
 
 #include 
 #include 
@@ -1395,6 +1395,11 @@ int getenc_make_table(int, int[][5]);
 void xp_getenc(int[][5], int, int, int, struct audio_prinfo *);
 void getenc_check_encodings(int, int[][5]);
 void test_AUDIO_ERROR(int);
+void test_AUDIO_GETIOFFS_one(int);
+void test_AUDIO_GETOOFFS_one(int);
+void test_AUDIO_GETOOFFS_wrap(int);
+void test_AUDIO_GETOOFFS_flush(int);
+void test_AUDIO_GETOOFFS_set(int);
 void test_audioctl_open_1(int, int);
 void test_audioctl_open_2(int, int);
 void try_audioctl_open_multiuser(const char *, const char *);
@@ -6175,6 +6180,553 @@ DEF(AUDIO_ERROR_WRONLY)	{ test_AUDIO_ERR
 DEF(AUDIO_ERROR_RDWR)	{ test_AUDIO_ERROR(O_RDWR); }
 
 /*
+ * AUDIO_GETIOFFS at least one block.
+ */
+void
+test_AUDIO_GETIOFFS_one(int openmode)
+{
+	struct audio_info ai;
+	audio_offset_t o;
+	int fd;
+	int r;
+	u_int blocksize;
+	u_int blk_ms;
+
+	TEST("AUDIO_GETIOFFS_one_%s", openmode_str[openmode] + 2);
+	if (mode2aumode(openmode) == 0) {
+		XP_SKIP("Operation not allowed on this hardware property");
+		return;
+	}
+
+	fd = OPEN(devaudio, openmode);
+	REQUIRED_SYS_OK(fd);
+
+#if 0
+	/*
+	 * On NetBSD7/8, native encodings and emulated encodings behave
+	 * differently.  But it's hard to identify which encoding is native.
+	 * If you try other encodings, edit these parameters manually.
+	 */
+	AUDIO_INITINFO();
+	ai.record.encoding = AUDIO_ENCODING_SLINEAR_NE;
+	ai.record.precision = 16;
+	ai.record.channels = 2;
+	ai.record.sample_rate = 48000;
+	/* ai.blocksize is shared by play and record, so set both the same. */
+	*ai.play = *ai.record;
+	r = IOCTL(fd, AUDIO_SETINFO, , "");
+	REQUIRED_SYS_EQ(0, r);
+#endif
+
+	/* Get blocksize to calc blk_ms. */
+	r = IOCTL(fd, AUDIO_GETBUFINFO, , "");
+	REQUIRED_SYS_EQ(0, r);
+	blocksize = ai.blocksize;
+	if (netbsd < 9) {
+		blk_ms = 0;
+	} else {
+		/* On NetBSD9, blocktime can always be calculated. */
+		blk_ms = blocksize * 1000 /
+		(ai.play.precision / 8 * ai.play.channels *
+		 ai.play.sample_rate);
+	}
+	if (blk_ms == 0)
+		blk_ms = 50;
+	DPRINTF("  > blocksize=%u, estimated blk_ms=%u\n", blocksize, blk_ms);
+
+	/*
+	 * Even when just opened, recording counters will start.
+	 * Wait a moment, about one block time.
+	 */
+	usleep(blk_ms * 1000);
+
+	r = IOCTL(fd, AUDIO_GETIOFFS, , "");
+	XP_SYS_EQ(0, r);
+	if (mode2rec(openmode)) {
+		/*
+		 * It's difficult to know exact values.
+		 * But at least these should not be zero.
+		 */
+		DPRINTF("  > %d: samples=%u deltablks=%u offset=%u\n",
+		__LINE__, o.samples, o.deltablks, o.offset);
+		XP_NE(0, o.samples);
+		XP_NE(0, o.deltablks);
+		XP_NE(0, o.offset);
+	} else {
+		/* All are zero on playback track. */
+		XP_EQ(0, o.samples);
+		XP_EQ(0, o.deltablks);
+		XP_EQ(0, o.offset);
+	}
+
+	r = CLOSE(fd);
+	XP_SYS_EQ(0, r);
+}
+DEF(AUDIO_GETIOFFS_one_RDONLY) { test_AUDIO_GETIOFFS_one(O_RDONLY); }
+DEF(AUDIO_GETIOFFS_one_WRONLY) { test_AUDIO_GETIOFFS_one(O_WRONLY); }
+DEF(AUDIO_GETIOFFS_one_RDWR)   { test_AUDIO_GETIOFFS_one(O_RDWR); }
+
+/*
+ * AUDIO_GETOOFFS for one block.
+ */
+void
+test_AUDIO_GETOOFFS_one(int openmode)
+{
+	struct audio_info ai;
+	audio_offset_t o;
+	char *buf;
+	int fd;
+	int r;
+	u_int blocksize;
+	u_int initial_offset;
+	u_int blk_ms;
+
+	TEST("AUDIO_GETOOFFS_one_%s", openmode_str[openmode] + 2);
+	if (mode2aumode(openmode) == 0) {
+		XP_SKIP("Operation not allowed on this hardware property");
+		return;
+	}
+
+	fd = OPEN(devaudio, openmode);
+	REQUIRED_SYS_OK(fd);
+
+#if 0
+	/*
+	 * On NetBSD7/8, native encodings and emulated encodings behave
+	 * differently.  But it's hard to identify which encoding is native.
+	 * If you try other encodings, edit these parameters manually.
+	 */
+	AUDIO_INITINFO();
+	

CVS commit: src/tests/dev/audio

2022-04-23 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Apr 23 07:47:42 UTC 2022

Modified Files:
src/tests/dev/audio: audiotest.c

Log Message:
tests: Add tests for AUDIO_GET[IO]OFFS ioctls.
- AUDIO_GETIOFFS_one_{RDONLY,RDWR,WRONLY}
- AUDIO_GETOOFFS_one_{RDONLY,RDWR,WRONLY}
- AUDIO_GETOOFFS_wrap_{RDONLY,RDWR,WRONLY}
- AUDIO_GETOOFFS_flush_{RDONLY,RDWR,WRONLY}
- AUDIO_GETOOFFS_set_{RDONLY,RDWR,WRONLY}


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/tests/dev/audio/audiotest.c

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



CVS commit: src/sys/dev/audio

2022-04-23 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Apr 23 07:43:16 UTC 2022

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
audio(4): Restore(implement) AUDIO_GETIOFFS ioctl.


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/sys/dev/audio/audio.c

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

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.129 src/sys/dev/audio/audio.c:1.130
--- src/sys/dev/audio/audio.c:1.129	Sat Apr 23 06:17:59 2022
+++ src/sys/dev/audio/audio.c	Sat Apr 23 07:43:16 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.129 2022/04/23 06:17:59 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.130 2022/04/23 07:43:16 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -181,7 +181,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.129 2022/04/23 06:17:59 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.130 2022/04/23 07:43:16 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -3086,12 +3086,31 @@ audio_ioctl(dev_t dev, struct audio_soft
 		break;
 
 	case AUDIO_GETIOFFS:
-		/* XXX TODO */
-		TRACEF(2, file, "%s", pre);
 		ao = (struct audio_offset *)addr;
-		ao->samples = 0;
-		ao->deltablks = 0;
-		ao->offset = 0;
+		track = file->rtrack;
+		if (track == NULL) {
+			ao->samples = 0;
+			ao->deltablks = 0;
+			ao->offset = 0;
+			TRACEF(2, file, "%s no rtrack", pre);
+			break;
+		}
+		mutex_enter(sc->sc_lock);
+		mutex_enter(sc->sc_intr_lock);
+		/* figure out where next transfer will start */
+		stamp = track->stamp;
+		offset = auring_tail(track->input);
+		mutex_exit(sc->sc_intr_lock);
+		mutex_exit(sc->sc_lock);
+
+		/* samples will overflow soon but is as per spec. */
+		ao->samples = stamp * track->usrbuf_blksize;
+		ao->deltablks = stamp - track->last_stamp;
+		ao->offset = audio_track_inputblk_as_usrbyte(track, offset);
+		TRACET(2, track, "%s samples=%u deltablks=%u offset=%u",
+		pre, ao->samples, ao->deltablks, ao->offset);
+
+		track->last_stamp = stamp;
 		break;
 
 	case AUDIO_GETOOFFS:
@@ -5152,8 +5171,6 @@ audio_track_record(audio_track_t *track)
 		auring_take(outbuf, bytes2 / framesize);
 	}
 
-	/* XXX TODO: any counters here? */
-
 #if defined(AUDIO_DEBUG)
 	if (audiodebug >= 3) {
 		struct audio_track_debugbuf m;
@@ -6098,7 +6115,7 @@ audio_rmixer_process(struct audio_softc 
 		bytes);
 		auring_push(input, count);
 
-		/* XXX sequence counter? */
+		track->stamp++;
 
 		audio_track_lock_exit(track);
 	}



CVS commit: src/sys/dev/audio

2022-04-23 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Apr 23 07:43:16 UTC 2022

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
audio(4): Restore(implement) AUDIO_GETIOFFS ioctl.


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/sys/dev/audio/audio.c

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



CVS commit: src

2022-04-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Apr 23 06:43:23 UTC 2022

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

Log Message:
indent: group global variables related to output control

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/indent/opt_bacc.c
cvs rdiff -u -r1.243 -r1.244 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.111 -r1.112 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.147 -r1.148 src/usr.bin/indent/io.c
cvs rdiff -u -r1.126 -r1.127 src/usr.bin/indent/pr_comment.c

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

Modified files:

Index: src/tests/usr.bin/indent/opt_bacc.c
diff -u src/tests/usr.bin/indent/opt_bacc.c:1.7 src/tests/usr.bin/indent/opt_bacc.c:1.8
--- src/tests/usr.bin/indent/opt_bacc.c:1.7	Fri Apr 22 21:21:20 2022
+++ src/tests/usr.bin/indent/opt_bacc.c	Sat Apr 23 06:43:23 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_bacc.c,v 1.7 2022/04/22 21:21:20 rillig Exp $ */
+/* $NetBSD: opt_bacc.c,v 1.8 2022/04/23 06:43:23 rillig Exp $ */
 
 /*
  * Tests for the options '-bacc' and '-nbacc' ("blank line around conditional
@@ -23,7 +23,7 @@ int		c;
 
 /*
  * XXX: As of 2021-11-19, the option -bacc has no effect on declarations since
- * process_type resets blank_line_before unconditionally.
+ * process_type resets out.blank_line_before unconditionally.
  */
 #indent run -bacc
 int		a;

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.243 src/usr.bin/indent/indent.c:1.244
--- src/usr.bin/indent/indent.c:1.243	Sat Apr 23 06:32:20 2022
+++ src/usr.bin/indent/indent.c	Sat Apr 23 06:43:22 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.243 2022/04/23 06:32:20 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.244 2022/04/23 06:43:22 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.243 2022/04/23 06:32:20 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.244 2022/04/23 06:43:22 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -91,9 +91,6 @@ struct buffer code;
 struct buffer com;
 
 bool found_err;
-int blank_lines_to_output;
-bool blank_line_before;
-bool blank_line_after;
 bool break_comma;
 float case_ind;
 bool had_eof;
@@ -105,6 +102,7 @@ static struct parser_state state_stack[5
 
 FILE *input;
 FILE *output;
+struct output_control out;
 
 static const char *in_name = "Standard Input";
 static const char *out_name = "Standard Output";
@@ -903,7 +901,7 @@ process_lbrace(bool *force_nl, bool *spa
 }
 
 if (ps.in_func_def_params)
-	blank_line_before = false;
+	out.blank_line_before = false;
 
 if (ps.nparen > 0) {
 	diag(1, "Unbalanced parentheses");
@@ -929,7 +927,7 @@ process_lbrace(bool *force_nl, bool *spa
 	 * declaration, so don't do special
 	 * indentation of comments */
 	if (opt.blanklines_after_decl_at_top && ps.in_func_def_params)
-	blank_line_after = true;
+	out.blank_line_after = true;
 	ps.in_func_def_params = false;
 	ps.in_decl = false;
 }
@@ -981,14 +979,14 @@ process_rbrace(bool *spaced_expr, int *d
 	ps.in_decl = true;
 }
 
-blank_line_before = false;
+out.blank_line_before = false;
 parse(psym_rbrace);
 ps.search_stmt = opt.cuddle_else
 	&& ps.s_sym[ps.tos] == psym_if_expr_stmt
 	&& ps.s_ind_level[ps.tos] >= ps.ind_level;
 
 if (ps.tos <= 1 && opt.blanklines_after_procs && ps.decl_level <= 0)
-	blank_line_after = true;
+	out.blank_line_after = true;
 }
 
 static void
@@ -1048,7 +1046,7 @@ process_type(int *decl_ind, bool *tabs_t
 if (ps.decl_level <= 0)
 	ps.just_saw_decl = 2;
 
-blank_line_before = false;
+out.blank_line_before = false;
 
 int len = (int)buf_len() + 1;
 int ind = ps.ind_level == 0 || ps.decl_level > 0
@@ -1242,11 +1240,11 @@ process_preprocessing(void)
 }
 
 if (opt.blanklines_around_conditional_compilation) {
-	blank_line_after = true;
-	blank_lines_to_output = 0;
+	out.blank_line_after = true;
+	out.blank_lines_to_output = 0;
 } else {
-	blank_line_after = false;
-	blank_line_before = false;
+	out.blank_line_after = false;
+	out.blank_line_before = false;
 }
 
 /*
@@ -1386,7 +1384,7 @@ main_loop(void)
 
 	case lsym_typedef:
 	case lsym_storage_class:
-	blank_line_before = false;
+	out.blank_line_before = false;
 	goto copy_token;
 
 	case lsym_tag:

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.111 src/usr.bin/indent/indent.h:1.112
--- src/usr.bin/indent/indent.h:1.111	Sun Feb 13 12:43:26 2022
+++ src/usr.bin/indent/indent.h	Sat Apr 23 06:43:22 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.111 2022/02/13 12:43:26 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.112 

CVS commit: src

2022-04-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Apr 23 06:43:23 UTC 2022

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

Log Message:
indent: group global variables related to output control

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/indent/opt_bacc.c
cvs rdiff -u -r1.243 -r1.244 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.111 -r1.112 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.147 -r1.148 src/usr.bin/indent/io.c
cvs rdiff -u -r1.126 -r1.127 src/usr.bin/indent/pr_comment.c

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



CVS commit: src/usr.bin/indent

2022-04-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Apr 23 06:32:20 UTC 2022

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

Log Message:
indent: remove Capsicum support

NetBSD doesn't have Capsicum.


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

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

Modified files:

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.242 src/usr.bin/indent/indent.c:1.243
--- src/usr.bin/indent/indent.c:1.242	Sun Feb 13 12:43:26 2022
+++ src/usr.bin/indent/indent.c	Sat Apr 23 06:32:20 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.242 2022/02/13 12:43:26 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.243 2022/04/23 06:32:20 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,16 +43,12 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.242 2022/02/13 12:43:26 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.243 2022/04/23 06:32:20 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
 
 #include 
-#if HAVE_CAPSICUM
-#include 
-#include 
-#endif
 #include 
 #include 
 #include 
@@ -115,23 +111,6 @@ static const char *out_name = "Standard 
 static const char *backup_suffix = ".BAK";
 static char bakfile[MAXPATHLEN] = "";
 
-#if HAVE_CAPSICUM
-static void
-init_capsicum(void)
-{
-cap_rights_t rights;
-
-/* Restrict input/output descriptors and enter Capsicum sandbox. */
-cap_rights_init(, CAP_FSTAT, CAP_WRITE);
-if (caph_rights_limit(fileno(output), ) < 0)
-	err(EXIT_FAILURE, "unable to limit rights for %s", out_name);
-cap_rights_init(, CAP_FSTAT, CAP_READ);
-if (caph_rights_limit(fileno(input), ) < 0)
-	err(EXIT_FAILURE, "unable to limit rights for %s", in_name);
-if (caph_enter() < 0)
-	err(EXIT_FAILURE, "unable to enter capability mode");
-}
-#endif
 
 static void
 buf_init(struct buffer *buf)



CVS commit: src/usr.bin/indent

2022-04-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Apr 23 06:32:20 UTC 2022

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

Log Message:
indent: remove Capsicum support

NetBSD doesn't have Capsicum.


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

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



CVS commit: src/sys/dev/audio

2022-04-23 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Apr 23 06:17:59 UTC 2022

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
audio(4): Fix an (unintended) minor behavior on AUDIO_FLUSH.
On NetBSD7, when AUDIO_FLUSH was issued, .offset of AUDIO_GETOOFFS was
reinitialized (to one block ahead from zero) or unchanged depend on
whether the user encoding is hardware native or not (probably).
I don't believe that it's intended or we need to maintain it.
Now, AUDIO_FLUSH always clears the offset to zero.


To generate a diff of this commit:
cvs rdiff -u -r1.128 -r1.129 src/sys/dev/audio/audio.c

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



CVS commit: src/sys/dev/audio

2022-04-23 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Apr 23 06:17:59 UTC 2022

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
audio(4): Fix an (unintended) minor behavior on AUDIO_FLUSH.
On NetBSD7, when AUDIO_FLUSH was issued, .offset of AUDIO_GETOOFFS was
reinitialized (to one block ahead from zero) or unchanged depend on
whether the user encoding is hardware native or not (probably).
I don't believe that it's intended or we need to maintain it.
Now, AUDIO_FLUSH always clears the offset to zero.


To generate a diff of this commit:
cvs rdiff -u -r1.128 -r1.129 src/sys/dev/audio/audio.c

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

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.128 src/sys/dev/audio/audio.c:1.129
--- src/sys/dev/audio/audio.c:1.128	Thu Apr 21 01:15:24 2022
+++ src/sys/dev/audio/audio.c	Sat Apr 23 06:17:59 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.128 2022/04/21 01:15:24 macallan Exp $	*/
+/*	$NetBSD: audio.c,v 1.129 2022/04/23 06:17:59 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -181,7 +181,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.128 2022/04/21 01:15:24 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.129 2022/04/23 06:17:59 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -6280,8 +6280,9 @@ audio_track_clear(struct audio_softc *sc
 
 	audio_track_lock_enter(track);
 
-	track->usrbuf.used = 0;
 	/* Clear all internal parameters. */
+	track->usrbuf.used = 0;
+	track->usrbuf.head = 0;
 	if (track->codec.filter) {
 		track->codec.srcbuf.used = 0;
 		track->codec.srcbuf.head = 0;