CVS commit: src

2021-07-08 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Fri Jul  9 05:54:11 UTC 2021

Modified Files:
src/distrib/sets/lists/debug: mi
src/distrib/sets/lists/tests: mi
src/tests/net: net_common.sh
src/tests/net/if_vlan: Makefile t_vlan.sh
Added Files:
src/tests/net/if_vlan: bpfopen.c

Log Message:
added tests for IFF_PROMISC of vlan(4)


To generate a diff of this commit:
cvs rdiff -u -r1.354 -r1.355 src/distrib/sets/lists/debug/mi
cvs rdiff -u -r1.1079 -r1.1080 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.41 -r1.42 src/tests/net/net_common.sh
cvs rdiff -u -r1.2 -r1.3 src/tests/net/if_vlan/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/net/if_vlan/bpfopen.c
cvs rdiff -u -r1.19 -r1.20 src/tests/net/if_vlan/t_vlan.sh

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

Modified files:

Index: src/distrib/sets/lists/debug/mi
diff -u src/distrib/sets/lists/debug/mi:1.354 src/distrib/sets/lists/debug/mi:1.355
--- src/distrib/sets/lists/debug/mi:1.354	Thu Jul  8 09:16:24 2021
+++ src/distrib/sets/lists/debug/mi	Fri Jul  9 05:54:11 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.354 2021/07/08 09:16:24 christos Exp $
+# $NetBSD: mi,v 1.355 2021/07/09 05:54:11 yamaguchi Exp $
 ./etc/mtree/set.debug   comp-sys-root
 ./usr/lib	comp-sys-usr		compatdir
 ./usr/lib/i18n/libBIG5_g.a			comp-c-debuglib		debuglib,compatfile
@@ -2396,6 +2396,7 @@
 ./usr/libdata/debug/usr/tests/net/if/t_compat.debug		tests-net-debug		debug,atf,rump
 ./usr/libdata/debug/usr/tests/net/if_loop/t_pr.debug		tests-net-debug		debug,atf,rump
 ./usr/libdata/debug/usr/tests/net/if_tap/rump_open_tap.debug	tests-net-debug		debug,atf,rump
+./usr/libdata/debug/usr/tests/net/if_vlan/bpfopen.debug		tests-net-debug		debug,atf,rump
 ./usr/libdata/debug/usr/tests/net/if_vlan/siocXmulti.debug	tests-net-debug		debug,atf,rump
 ./usr/libdata/debug/usr/tests/net/in_cksum/in_cksum.debug	tests-net-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/net/ipsec/natt_terminator.debug	tests-net-debug		debug,atf,rump

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1079 src/distrib/sets/lists/tests/mi:1.1080
--- src/distrib/sets/lists/tests/mi:1.1079	Thu Jul  8 09:16:24 2021
+++ src/distrib/sets/lists/tests/mi	Fri Jul  9 05:54:11 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1079 2021/07/08 09:16:24 christos Exp $
+# $NetBSD: mi,v 1.1080 2021/07/09 05:54:11 yamaguchi Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4142,6 +4142,7 @@
 ./usr/tests/net/if_vlan	tests-net-tests		compattestfile,atf
 ./usr/tests/net/if_vlan/Atffiletests-net-tests		atf,rump
 ./usr/tests/net/if_vlan/Kyuafile			tests-net-tests		atf,rump,kyua
+./usr/tests/net/if_vlan/bpfopentests-net-tests		atf,rump
 ./usr/tests/net/if_vlan/siocXmulti			tests-net-tests		atf,rump
 ./usr/tests/net/if_vlan/t_vlantests-net-tests		atf,rump
 ./usr/tests/net/if_wg	tests-net-tests		compattestfile,atf

Index: src/tests/net/net_common.sh
diff -u src/tests/net/net_common.sh:1.41 src/tests/net/net_common.sh:1.42
--- src/tests/net/net_common.sh:1.41	Wed Apr  1 00:49:04 2020
+++ src/tests/net/net_common.sh	Fri Jul  9 05:54:11 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: net_common.sh,v 1.41 2020/04/01 00:49:04 christos Exp $
+#	$NetBSD: net_common.sh,v 1.42 2021/07/09 05:54:11 yamaguchi Exp $
 #
 # Copyright (c) 2016 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -180,6 +180,7 @@ CRYPTO_LIBS="$BASIC_LIBS -lrumpdev -lrum
 -lrumpkern_z -lrumpkern_crypto"
 NPF_LIBS="$BASIC_LIBS -lrumpdev -lrumpvfs -lrumpdev_bpf -lrumpnet_npf"
 CRYPTO_NPF_LIBS="$CRYPTO_LIBS -lrumpvfs -lrumpdev_bpf -lrumpnet_npf"
+BPF_LIBS="$BASIC_LIBS -lrumpdev -lrumpvfs -lrumpdev_bpf"
 
 # We cannot keep variables between test phases, so need to store in files
 _rump_server_socks=./.__socks
@@ -315,6 +316,24 @@ rump_server_crypto_npf_start()
 	return 0
 }
 
+rump_server_bpf_start()
+{
+	local sock=$1
+	local lib=
+	local libs="$BPF_LIBS"
+
+	shift 1
+
+	for lib
+	do
+		libs="$libs -lrumpnet_$lib"
+	done
+
+	_rump_server_start_common $sock $libs
+
+	return 0
+}
+
 rump_server_add_iface()
 {
 	local sock=$1

Index: src/tests/net/if_vlan/Makefile
diff -u src/tests/net/if_vlan/Makefile:1.2 src/tests/net/if_vlan/Makefile:1.3
--- src/tests/net/if_vlan/Makefile:1.2	Thu Jun 14 08:22:52 2018
+++ src/tests/net/if_vlan/Makefile	Fri Jul  9 05:54:11 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.2 2018/06/14 08:22:52 yamaguchi Exp $
+# $NetBSD: Makefile,v 1.3 2021/07/09 05:54:11 yamaguchi Exp $
 #
 
 .include 
@@ -14,4 +14,8 @@ PROGS=			siocXmulti
 MAN.siocXmulti=		#empty
 BINDIR.siocXmulti=	${TESTSDIR}
 
+PROGS+=			bpfopen
+MAN.bpfopen=	#empty
+BINDIR.bpfopen=	${TESTSDIR}
+
 .include 

Index: src/tests/net/if_vlan/t_vlan.sh
diff -u src/tests/net/if_vlan/t_vlan.sh:1.19 src/tests/net/if_vlan/t_vlan.sh:1.20
--- src/tests/net/if_vlan/t_vlan.sh:1.19	Tue Jul  6 

CVS commit: src

2021-07-08 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Fri Jul  9 05:54:11 UTC 2021

Modified Files:
src/distrib/sets/lists/debug: mi
src/distrib/sets/lists/tests: mi
src/tests/net: net_common.sh
src/tests/net/if_vlan: Makefile t_vlan.sh
Added Files:
src/tests/net/if_vlan: bpfopen.c

Log Message:
added tests for IFF_PROMISC of vlan(4)


To generate a diff of this commit:
cvs rdiff -u -r1.354 -r1.355 src/distrib/sets/lists/debug/mi
cvs rdiff -u -r1.1079 -r1.1080 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.41 -r1.42 src/tests/net/net_common.sh
cvs rdiff -u -r1.2 -r1.3 src/tests/net/if_vlan/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/net/if_vlan/bpfopen.c
cvs rdiff -u -r1.19 -r1.20 src/tests/net/if_vlan/t_vlan.sh

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



CVS commit: src/sys/arch/alpha/alpha

2021-07-08 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Jul  9 01:29:21 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: autoconf.c

Log Message:
If we're netbooting on a system with, for example, an ISA DE204 Ethernet
interface, we don't have sufficient information to find the device using
the bus/slot scheme that we do with a PCI network interface.  However, in
these cases, some versions of the SRM console supply the MAC address of
the interface in the booted_dev environment variable, like so:

BOOTP 1 1 0 0 0 5 0 08-00-2B-xx-xx-xx 1

So, if we weren't able to find the booted device by the usual means,
check for this and, if we find a MAC address, try to find the network
interface by the MAC address.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sys/arch/alpha/alpha/autoconf.c

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

Modified files:

Index: src/sys/arch/alpha/alpha/autoconf.c
diff -u src/sys/arch/alpha/alpha/autoconf.c:1.57 src/sys/arch/alpha/alpha/autoconf.c:1.58
--- src/sys/arch/alpha/alpha/autoconf.c:1.57	Sat May 22 15:05:36 2021
+++ src/sys/arch/alpha/alpha/autoconf.c	Fri Jul  9 01:29:20 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: autoconf.c,v 1.57 2021/05/22 15:05:36 thorpej Exp $ */
+/* $NetBSD: autoconf.c,v 1.58 2021/07/09 01:29:20 thorpej Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.57 2021/05/22 15:05:36 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.58 2021/07/09 01:29:20 thorpej Exp $");
 
 #include "pci.h"
 
@@ -57,6 +57,9 @@ __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v
 
 #include 
 
+#include 
+#include 
+
 #include 
 #include 
 #include 
@@ -66,8 +69,7 @@ __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v
 
 struct bootdev_data	*bootdev_data;
 
-void	parse_prom_bootdev(void);
-static inline int atoi(const char *);
+static void	parse_prom_bootdev(void);
 
 /*
  * cpu_configure:
@@ -138,6 +140,86 @@ qemu_find_rootdev(void)
 	booted_device = device_find_by_xname(cp);
 }
 
+static bool
+parse_dec_macaddr(const char *str, uint8_t enaddr[ETHER_ADDR_LEN])
+{
+	char *cp;
+	long long l;
+	int i;
+
+	/*
+	 * DEC Ethernet address strings are formatted like so:
+	 *
+	 *	XX-XX-XX-XX-XX-XX
+	 */
+
+	for (i = 0; i < ETHER_ADDR_LEN; i++) {
+		l = strtoll(str, , 16);
+		if (l < 0 || l > 0xff) {
+			/* Not a valid MAC address. */
+			return false;
+		}
+		if (*cp == '-') {
+			/* Octet separator. */
+			enaddr[i] = (uint8_t)l;
+			str = cp + 1;
+			continue;
+		}
+		if (*cp == ' ' || *cp == '\0') {
+			/* End of the string. */
+			enaddr[i] = (uint8_t)l;
+			return i == ETHER_ADDR_LEN - 1;
+		}
+		/* Bogus character. */
+		break;
+	}
+
+	/* Encountered bogus character or didn't reach end of string. */
+	return false;
+}
+
+static void
+netboot_find_rootdev_planb(void)
+{
+	struct psref psref;
+	uint8_t enaddr[ETHER_ADDR_LEN];
+	char ifname[IFNAMSIZ];
+	int i;
+
+	if (strncasecmp(bootinfo.booted_dev, "BOOTP ", 6) != 0 &&
+	strncasecmp(bootinfo.booted_dev, "MOP ", 4) != 0) {
+		/* We weren't netbooted. */
+		return;
+	}
+
+	for (i = 2; bootinfo.booted_dev[i] != '\0'; i++) {
+		if (bootinfo.booted_dev[i] == '-') {
+			if (parse_dec_macaddr(_dev[i - 2],
+	  enaddr)) {
+/* Found it! */
+break;
+			}
+		}
+	}
+	if (bootinfo.booted_dev[i] == '\0') {
+		/* No MAC address in string. */
+		return;
+	}
+
+	/* Now try to look up the interface by the link address. */
+	struct ifnet *ifp = if_get_bylla(enaddr, ETHER_ADDR_LEN, );
+	if (ifp == NULL) {
+		/* No interface attached with that MAC address. */
+		return;
+	}
+
+	strlcpy(ifname, if_name(ifp), sizeof(ifname));
+	if_put(ifp, );
+
+	/* Ok! Now look up the device_t by name! */
+	booted_device = device_find_by_xname(ifname);
+}
+
 void
 cpu_rootconf(void)
 {
@@ -147,13 +229,33 @@ cpu_rootconf(void)
 	}
 
 	if (booted_device == NULL) {
+		/*
+		 * It's possible that we netbooted from an Ethernet
+		 * interface that can't be matched via the usual
+		 * logic in device_register() (a DE204 in an ISA slot,
+		 * for example).  In these cases, the console may have
+		 * provided us with a MAC address that we can use to
+		 * try and find the interface, * e.g.:
+		 *
+		 *	BOOTP 1 1 0 0 0 5 0 08-00-2B-xx-xx-xx 1
+		 */
+		netboot_find_rootdev_planb();
+	}
+
+	if (booted_device == NULL) {
 		printf("WARNING: can't figure what device matches \"%s\"\n",
 		bootinfo.booted_dev);
 	}
 	rootconf();
 }
 
-void
+static inline int
+atoi(const char *s)
+{
+	return (int)strtoll(s, NULL, 10);
+}
+
+static void
 parse_prom_bootdev(void)
 {
 	static char hacked_boot_dev[128];
@@ -213,12 +315,6 @@ parse_prom_bootdev(void)
 	bootdev_data = 
 }
 
-static inline int
-atoi(const char *s)
-{
-	return (int)strtoll(s, NULL, 10);
-}
-
 void
 device_register(device_t dev, void *aux)
 {



CVS commit: src/sys/arch/alpha/alpha

2021-07-08 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Jul  9 01:29:21 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: autoconf.c

Log Message:
If we're netbooting on a system with, for example, an ISA DE204 Ethernet
interface, we don't have sufficient information to find the device using
the bus/slot scheme that we do with a PCI network interface.  However, in
these cases, some versions of the SRM console supply the MAC address of
the interface in the booted_dev environment variable, like so:

BOOTP 1 1 0 0 0 5 0 08-00-2B-xx-xx-xx 1

So, if we weren't able to find the booted device by the usual means,
check for this and, if we find a MAC address, try to find the network
interface by the MAC address.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sys/arch/alpha/alpha/autoconf.c

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



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

2021-07-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jul  8 20:11:15 UTC 2021

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

Log Message:
tests/lint: test error recovery of the parser


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_249.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_249.c
diff -u src/tests/usr.bin/xlint/lint1/msg_249.c:1.4 src/tests/usr.bin/xlint/lint1/msg_249.c:1.5
--- src/tests/usr.bin/xlint/lint1/msg_249.c:1.4	Thu Jul  8 18:02:22 2021
+++ src/tests/usr.bin/xlint/lint1/msg_249.c	Thu Jul  8 20:11:15 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_249.c,v 1.4 2021/07/08 18:02:22 rillig Exp $	*/
+/*	$NetBSD: msg_249.c,v 1.5 2021/07/08 20:11:15 rillig Exp $	*/
 # 3 "msg_249.c"
 
 // Test for message: syntax error '%s' [249]
@@ -33,5 +33,15 @@ function(void)
 	);			/* expect: syntax error ')' */
 }
 
+/* XXX: It is unexpected that this error is not detected. */
+"This syntax error is not detected.";
+
 /* XXX: This is necessary to recover the yacc parser. */
-int recover_from_rparen;
+double recover_from_rparen;
+
+/* Ensure that the declaration after the syntax error is processed. */
+double *
+access_declaration_after_syntax_error(void)
+{
+	return _from_rparen;
+}



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

2021-07-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jul  8 20:11:15 UTC 2021

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

Log Message:
tests/lint: test error recovery of the parser


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

2021-07-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jul  8 19:08:03 UTC 2021

Modified Files:
src/usr.bin/xlint/lint1: cgram.y

Log Message:
lint: fix assignment to midrule in grammar (since today)

When compiling the grammar with Bison, it complains:

error: $$ for the midrule at $2 of 'struct' has no declared type

Yacc does not complain, instead it assumes that a midrule has the same
type as the rule itself.

The assignment '$$ = $1' in the midrule action does not influence the $$
of the whole rule, it only assigns to $2.  The assignment to $$ was done
via the default action, therefore everything worked as expected.  Any
missing assignment in this rule would have been caught quickly by the
strict assertion in mktag.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.273 -r1.274 src/usr.bin/xlint/lint1/cgram.y

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/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.273 src/usr.bin/xlint/lint1/cgram.y:1.274
--- src/usr.bin/xlint/lint1/cgram.y:1.273	Thu Jul  8 18:53:57 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Thu Jul  8 19:08:03 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.273 2021/07/08 18:53:57 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.274 2021/07/08 19:08:03 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.273 2021/07/08 18:53:57 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.274 2021/07/08 19:08:03 rillig Exp $");
 #endif
 
 #include 
@@ -649,7 +649,6 @@ struct:
 		begin_declaration_level($1 == STRUCT ? MOS : MOU);
 		dcs->d_offset = 0;
 		dcs->d_sou_align_in_bits = CHAR_SIZE;
-		$$ = $1;
 	  } type_attribute_list_opt
 	;
 



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

2021-07-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jul  8 19:08:03 UTC 2021

Modified Files:
src/usr.bin/xlint/lint1: cgram.y

Log Message:
lint: fix assignment to midrule in grammar (since today)

When compiling the grammar with Bison, it complains:

error: $$ for the midrule at $2 of 'struct' has no declared type

Yacc does not complain, instead it assumes that a midrule has the same
type as the rule itself.

The assignment '$$ = $1' in the midrule action does not influence the $$
of the whole rule, it only assigns to $2.  The assignment to $$ was done
via the default action, therefore everything worked as expected.  Any
missing assignment in this rule would have been caught quickly by the
strict assertion in mktag.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.273 -r1.274 src/usr.bin/xlint/lint1/cgram.y

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



CVS commit: src

2021-07-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jul  8 18:53:58 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_206.c msg_206.exp
src/usr.bin/xlint/lint1: cgram.y

Log Message:
lint: fix wrong check for enum constants in switch (since today)


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_206.c \
src/tests/usr.bin/xlint/lint1/msg_206.exp
cvs rdiff -u -r1.272 -r1.273 src/usr.bin/xlint/lint1/cgram.y

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_206.c
diff -u src/tests/usr.bin/xlint/lint1/msg_206.c:1.3 src/tests/usr.bin/xlint/lint1/msg_206.c:1.4
--- src/tests/usr.bin/xlint/lint1/msg_206.c:1.3	Thu Jul  8 18:50:57 2021
+++ src/tests/usr.bin/xlint/lint1/msg_206.c	Thu Jul  8 18:53:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_206.c,v 1.3 2021/07/08 18:50:57 rillig Exp $	*/
+/*	$NetBSD: msg_206.c,v 1.4 2021/07/08 18:53:57 rillig Exp $	*/
 # 3 "msg_206.c"
 
 // Test for message: enumeration value(s) not handled in switch [206]
@@ -25,5 +25,4 @@ test(enum number num)
 	case THREE:
 		break;
 	}
-	/* FIXME *//* expect-1: warning: enumeration value(s) not handled in switch [206] */
 }
Index: src/tests/usr.bin/xlint/lint1/msg_206.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_206.exp:1.3 src/tests/usr.bin/xlint/lint1/msg_206.exp:1.4
--- src/tests/usr.bin/xlint/lint1/msg_206.exp:1.3	Thu Jul  8 18:50:57 2021
+++ src/tests/usr.bin/xlint/lint1/msg_206.exp	Thu Jul  8 18:53:57 2021
@@ -1,2 +1 @@
 msg_206.c(19): warning: enumeration value(s) not handled in switch [206]
-msg_206.c(27): warning: enumeration value(s) not handled in switch [206]

Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.272 src/usr.bin/xlint/lint1/cgram.y:1.273
--- src/usr.bin/xlint/lint1/cgram.y:1.272	Thu Jul  8 18:50:57 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Thu Jul  8 18:53:57 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.272 2021/07/08 18:50:57 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.273 2021/07/08 18:53:57 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.272 2021/07/08 18:50:57 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.273 2021/07/08 18:53:57 rillig Exp $");
 #endif
 
 #include 
@@ -853,8 +853,7 @@ enum_declaration:
 		symtyp = FVFT;
 		enumval = 0;
 	  } enumerator_list enumerator_list_comma_opt T_RBRACE {
-	  	/* FIXME: $2 must be $3 */
-		$$ = $2;
+		$$ = $3;
 	  }
 	;
 



CVS commit: src

2021-07-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jul  8 18:53:58 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_206.c msg_206.exp
src/usr.bin/xlint/lint1: cgram.y

Log Message:
lint: fix wrong check for enum constants in switch (since today)


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_206.c \
src/tests/usr.bin/xlint/lint1/msg_206.exp
cvs rdiff -u -r1.272 -r1.273 src/usr.bin/xlint/lint1/cgram.y

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



CVS commit: src

2021-07-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jul  8 18:50:57 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_206.c msg_206.exp
src/usr.bin/xlint/lint1: cgram.y

Log Message:
lint: demonstrate bug in handling enum declarations (since today)

Since cgram.y 1.270 from today (a "cleanup" commit), the enum constants
were only registered in the symbol table, but they were not added to the
enum type (en_first_enumerator).  That information is used for
validating switch statements on enum types.

The actual bug is an off-by-one error in the grammar, in the grammar
rule 'enum_declaration'.  Yacc does not notice this obvious error.
Bison does, but it is not involved in building lint.

In the grammar rule 'enum_declaration', the intended $3 contains the
first enumeration constant of the type, while $2, which yacc interprets
as a symbol, contains a null pointer, at least on x86_64.

The existing tests did not cover this scenario, so the bug went
unnoticed.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_206.c \
src/tests/usr.bin/xlint/lint1/msg_206.exp
cvs rdiff -u -r1.271 -r1.272 src/usr.bin/xlint/lint1/cgram.y

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_206.c
diff -u src/tests/usr.bin/xlint/lint1/msg_206.c:1.2 src/tests/usr.bin/xlint/lint1/msg_206.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_206.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_206.c	Thu Jul  8 18:50:57 2021
@@ -1,7 +1,29 @@
-/*	$NetBSD: msg_206.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_206.c,v 1.3 2021/07/08 18:50:57 rillig Exp $	*/
 # 3 "msg_206.c"
 
 // Test for message: enumeration value(s) not handled in switch [206]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* lint1-extra-flags: -eh */
+
+enum number {
+	ONE, TWO, THREE
+};
+
+void
+test(enum number num)
+{
+	switch (num) {
+	case ONE:
+	case TWO:
+		break;
+	}
+	/* expect-1: warning: enumeration value(s) not handled in switch [206] */
+
+	switch (num) {
+	case ONE:
+	case TWO:
+	case THREE:
+		break;
+	}
+	/* FIXME *//* expect-1: warning: enumeration value(s) not handled in switch [206] */
+}
Index: src/tests/usr.bin/xlint/lint1/msg_206.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_206.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_206.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_206.exp:1.2	Sun Mar 21 20:45:00 2021
+++ src/tests/usr.bin/xlint/lint1/msg_206.exp	Thu Jul  8 18:50:57 2021
@@ -1 +1,2 @@
-msg_206.c(6): error: syntax error ':' [249]
+msg_206.c(19): warning: enumeration value(s) not handled in switch [206]
+msg_206.c(27): warning: enumeration value(s) not handled in switch [206]

Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.271 src/usr.bin/xlint/lint1/cgram.y:1.272
--- src/usr.bin/xlint/lint1/cgram.y:1.271	Thu Jul  8 04:09:10 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Thu Jul  8 18:50:57 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.271 2021/07/08 04:09:10 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.272 2021/07/08 18:50:57 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.271 2021/07/08 04:09:10 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.272 2021/07/08 18:50:57 rillig Exp $");
 #endif
 
 #include 
@@ -853,6 +853,7 @@ enum_declaration:
 		symtyp = FVFT;
 		enumval = 0;
 	  } enumerator_list enumerator_list_comma_opt T_RBRACE {
+	  	/* FIXME: $2 must be $3 */
 		$$ = $2;
 	  }
 	;



CVS commit: src

2021-07-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jul  8 18:50:57 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_206.c msg_206.exp
src/usr.bin/xlint/lint1: cgram.y

Log Message:
lint: demonstrate bug in handling enum declarations (since today)

Since cgram.y 1.270 from today (a "cleanup" commit), the enum constants
were only registered in the symbol table, but they were not added to the
enum type (en_first_enumerator).  That information is used for
validating switch statements on enum types.

The actual bug is an off-by-one error in the grammar, in the grammar
rule 'enum_declaration'.  Yacc does not notice this obvious error.
Bison does, but it is not involved in building lint.

In the grammar rule 'enum_declaration', the intended $3 contains the
first enumeration constant of the type, while $2, which yacc interprets
as a symbol, contains a null pointer, at least on x86_64.

The existing tests did not cover this scenario, so the bug went
unnoticed.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_206.c \
src/tests/usr.bin/xlint/lint1/msg_206.exp
cvs rdiff -u -r1.271 -r1.272 src/usr.bin/xlint/lint1/cgram.y

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



CVS commit: src/external/bsd/atf/dist/tools

2021-07-08 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Thu Jul  8 18:10:52 UTC 2021

Modified Files:
src/external/bsd/atf/dist/tools: atf-run.cpp

Log Message:
When running an individual test case under isolation, make the test
case count on the tp-start line of the output match the number of test
cases actually executed (one) so that the atf-run output is valid
input to atf-report.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/bsd/atf/dist/tools/atf-run.cpp

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

Modified files:

Index: src/external/bsd/atf/dist/tools/atf-run.cpp
diff -u src/external/bsd/atf/dist/tools/atf-run.cpp:1.6 src/external/bsd/atf/dist/tools/atf-run.cpp:1.7
--- src/external/bsd/atf/dist/tools/atf-run.cpp:1.6	Sat Apr 10 10:32:57 2021
+++ src/external/bsd/atf/dist/tools/atf-run.cpp	Thu Jul  8 18:10:52 2021
@@ -388,7 +388,22 @@ atf_run::run_test_program(const tools::f
 tools::fs::temp_dir resdir(
 tools::fs::path(tools::config::get("atf_workdir")) / "atf-run.XX");
 
-w.start_tp(tp.str(), md.test_cases.size());
+size_t nseltcs;
+if (tc.empty()) {
+nseltcs = md.test_cases.size();
+} else {
+nseltcs = 0;
+for (std::map< std::string, vars_map >::const_iterator iter
+ = md.test_cases.begin(); iter != md.test_cases.end(); iter++) {
+const std::string& tcname = (*iter).first;
+if (tcname == tc)
+nseltcs++;
+}
+if (nseltcs == 0)
+throw std::runtime_error("No such test case");
+}
+
+w.start_tp(tp.str(), nseltcs);
 if (md.test_cases.empty()) {
 w.end_tp("Bogus test program: reported 0 test cases");
 errcode = EXIT_FAILURE;



CVS commit: src/external/bsd/atf/dist/tools

2021-07-08 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Thu Jul  8 18:10:52 UTC 2021

Modified Files:
src/external/bsd/atf/dist/tools: atf-run.cpp

Log Message:
When running an individual test case under isolation, make the test
case count on the tp-start line of the output match the number of test
cases actually executed (one) so that the atf-run output is valid
input to atf-report.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/bsd/atf/dist/tools/atf-run.cpp

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



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

2021-07-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jul  8 18:02:22 UTC 2021

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

Log Message:
tests/lint: add test coverage for some parse errors


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

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_249.c
diff -u src/tests/usr.bin/xlint/lint1/msg_249.c:1.3 src/tests/usr.bin/xlint/lint1/msg_249.c:1.4
--- src/tests/usr.bin/xlint/lint1/msg_249.c:1.3	Sat Jun 19 16:05:07 2021
+++ src/tests/usr.bin/xlint/lint1/msg_249.c	Thu Jul  8 18:02:22 2021
@@ -1,9 +1,27 @@
-/*	$NetBSD: msg_249.c,v 1.3 2021/06/19 16:05:07 rillig Exp $	*/
+/*	$NetBSD: msg_249.c,v 1.4 2021/07/08 18:02:22 rillig Exp $	*/
 # 3 "msg_249.c"
 
 // Test for message: syntax error '%s' [249]
 
 /*
+ * Cover the grammar rule 'top_level_declaration: error T_SEMI'.
+ */
+/* expect+1: syntax error '"' [249] */
+"syntax error in top_level_declaration";
+
+/* XXX: This is necessary to recover the yacc parser. */
+int recover_from_semi;
+
+/*
+ * Cover the grammar rule 'top_level_declaration: error T_RBRACE'.
+ */
+/* expect+1: syntax error '"' [249] */
+"syntax error in top_level_declaration"}
+
+/* XXX: This is necessary to recover the yacc parser. */
+int recover_from_rbrace;
+
+/*
  * Before func.c 1.110 from 2021-06-19, lint ran into this:
  * assertion "cstmt->c_kind == kind" failed in end_control_statement
  */
@@ -14,3 +32,6 @@ function(void)
 		;
 	);			/* expect: syntax error ')' */
 }
+
+/* XXX: This is necessary to recover the yacc parser. */
+int recover_from_rparen;
Index: src/tests/usr.bin/xlint/lint1/msg_249.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_249.exp:1.3 src/tests/usr.bin/xlint/lint1/msg_249.exp:1.4
--- src/tests/usr.bin/xlint/lint1/msg_249.exp:1.3	Sat Jun 19 16:05:07 2021
+++ src/tests/usr.bin/xlint/lint1/msg_249.exp	Thu Jul  8 18:02:22 2021
@@ -1 +1,3 @@
-msg_249.c(15): error: syntax error ')' [249]
+msg_249.c(10): error: syntax error '"' [249]
+msg_249.c(19): error: syntax error '"' [249]
+msg_249.c(33): error: syntax error ')' [249]



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

2021-07-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jul  8 18:02:22 UTC 2021

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

Log Message:
tests/lint: add test coverage for some parse errors


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

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



CVS commit: src/lib/libc/stdio

2021-07-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jul  8 15:44:44 UTC 2021

Modified Files:
src/lib/libc/stdio: fflush.c

Log Message:
Include the 0 return from write. Although the real write system call does
not return 0, the synthetic writes from funopen/fmemopen could. This avoids
infinite loops in >= test19 in fmemopen, but the tests still fail, perhaps
because they assume the previous behavior, where flush does not adjust the
stdio pointers on error.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/lib/libc/stdio/fflush.c

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



CVS commit: src/lib/libc/stdio

2021-07-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jul  8 15:44:44 UTC 2021

Modified Files:
src/lib/libc/stdio: fflush.c

Log Message:
Include the 0 return from write. Although the real write system call does
not return 0, the synthetic writes from funopen/fmemopen could. This avoids
infinite loops in >= test19 in fmemopen, but the tests still fail, perhaps
because they assume the previous behavior, where flush does not adjust the
stdio pointers on error.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/lib/libc/stdio/fflush.c

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

Modified files:

Index: src/lib/libc/stdio/fflush.c
diff -u src/lib/libc/stdio/fflush.c:1.21 src/lib/libc/stdio/fflush.c:1.22
--- src/lib/libc/stdio/fflush.c:1.21	Thu Jul  8 05:06:51 2021
+++ src/lib/libc/stdio/fflush.c	Thu Jul  8 11:44:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: fflush.c,v 1.21 2021/07/08 09:06:51 christos Exp $	*/
+/*	$NetBSD: fflush.c,v 1.22 2021/07/08 15:44:44 christos Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)fflush.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: fflush.c,v 1.21 2021/07/08 09:06:51 christos Exp $");
+__RCSID("$NetBSD: fflush.c,v 1.22 2021/07/08 15:44:44 christos Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -107,7 +107,7 @@ __sflush(FILE *fp)
 
 	for (; n > 0; n -= t, p += t) {
 		t = (*fp->_write)(fp->_cookie, (char *)p, n);
-		if (t < 0) {
+		if (t <= 0) {
 			/* Reset _p and _w. */
 			if (p > fp->_p) {
 /* Some was written. */



CVS commit: src/tests/lib/libc/stdio

2021-07-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jul  8 15:21:40 UTC 2021

Modified Files:
src/tests/lib/libc/stdio: h_intr.c

Log Message:
fix printf format strings


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/stdio/h_intr.c

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

Modified files:

Index: src/tests/lib/libc/stdio/h_intr.c
diff -u src/tests/lib/libc/stdio/h_intr.c:1.1 src/tests/lib/libc/stdio/h_intr.c:1.2
--- src/tests/lib/libc/stdio/h_intr.c:1.1	Thu Jul  8 05:07:46 2021
+++ src/tests/lib/libc/stdio/h_intr.c	Thu Jul  8 11:21:40 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: h_intr.c,v 1.1 2021/07/08 09:07:46 christos Exp $	*/
+/*	$NetBSD: h_intr.c,v 1.2 2021/07/08 15:21:40 christos Exp $	*/
 
 /**
  * Test of interrupted writes to popen()'ed commands.
@@ -25,7 +25,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: h_intr.c,v 1.1 2021/07/08 09:07:46 christos Exp $");
+__RCSID("$NetBSD: h_intr.c,v 1.2 2021/07/08 15:21:40 christos Exp $");
 
 #include 
 #include 
@@ -144,7 +144,7 @@ process(const char *fn)
 		nw += i;
 	}
 	alarmtimer(0);
-	// printf("%lu\n", nw);
+	// printf("%zu\n", nw);
 
 	fclose(ifp);
 	if (pclose(ofp) != 0)
@@ -341,11 +341,11 @@ usage(FILE* fp)
 	fprintf(fp, "%s: Test interrupted writes to popen()ed CMD.\n",
 	getprogname());
 	fprintf(fp, "\n");
-	fprintf(fp, "  -b SIZE   Buffer size (%lu)\n", opts.bsize);
+	fprintf(fp, "  -b SIZE   Buffer size (%zu)\n", opts.bsize);
 	fprintf(fp, "  -c CMDCommand to run on each FILE.\n");
 	fprintf(fp, "  -hThis message.\n");
 	fprintf(fp, "  -pBuffering type %s.\n", getbtype(opts.btype));
-	fprintf(fp, "  -s SIZE   stdio buffer size (%lu)\n", opts.ssize);
+	fprintf(fp, "  -s SIZE   stdio buffer size (%zu)\n", opts.ssize);
 	fprintf(fp, "  -t TMOUT  Interrupt writing to CMD every (%d) ms\n",
 	opts.tmout);
 }



CVS commit: src/tests/lib/libc/stdio

2021-07-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jul  8 15:21:40 UTC 2021

Modified Files:
src/tests/lib/libc/stdio: h_intr.c

Log Message:
fix printf format strings


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/stdio/h_intr.c

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



CVS commit: src/tests/lib/libc/stdio

2021-07-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jul  8 12:30:20 UTC 2021

Modified Files:
src/tests/lib/libc/stdio: Makefile

Log Message:
need to set BINDIR


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/tests/lib/libc/stdio/Makefile

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/libc/stdio/Makefile
diff -u src/tests/lib/libc/stdio/Makefile:1.15 src/tests/lib/libc/stdio/Makefile:1.16
--- src/tests/lib/libc/stdio/Makefile:1.15	Thu Jul  8 05:07:46 2021
+++ src/tests/lib/libc/stdio/Makefile	Thu Jul  8 08:30:20 2021
@@ -1,10 +1,12 @@
-# $NetBSD: Makefile,v 1.15 2021/07/08 09:07:46 christos Exp $
+# $NetBSD: Makefile,v 1.16 2021/07/08 12:30:20 christos Exp $
 
 NOMAN=
 .include 
 
 TESTSDIR=	${TESTSBASE}/lib/libc/stdio
 
+BINDIR= ${TESTSDIR}
+
 TESTS_C+=	t_clearerr
 TESTS_C+=	t_fflush
 TESTS_C+=	t_fmemopen



CVS commit: src/tests/lib/libc/stdio

2021-07-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jul  8 12:30:20 UTC 2021

Modified Files:
src/tests/lib/libc/stdio: Makefile

Log Message:
need to set BINDIR


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/tests/lib/libc/stdio/Makefile

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



CVS commit: [netbsd-9] src/doc

2021-07-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jul  8 11:24:41 UTC 2021

Modified Files:
src/doc [netbsd-9]: CHANGES-9.3

Log Message:
Tickets #1319 and #1320


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.14 -r1.1.2.15 src/doc/CHANGES-9.3

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



CVS commit: [netbsd-9] src/doc

2021-07-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jul  8 11:24:41 UTC 2021

Modified Files:
src/doc [netbsd-9]: CHANGES-9.3

Log Message:
Tickets #1319 and #1320


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.14 -r1.1.2.15 src/doc/CHANGES-9.3

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-9.3
diff -u src/doc/CHANGES-9.3:1.1.2.14 src/doc/CHANGES-9.3:1.1.2.15
--- src/doc/CHANGES-9.3:1.1.2.14	Tue Jul  6 04:23:55 2021
+++ src/doc/CHANGES-9.3	Thu Jul  8 11:24:41 2021
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-9.3,v 1.1.2.14 2021/07/06 04:23:55 martin Exp $
+# $NetBSD: CHANGES-9.3,v 1.1.2.15 2021/07/08 11:24:41 martin Exp $
 
 A complete list of changes from the NetBSD 9.2 release to the NetBSD 9.3
 release:
@@ -339,3 +339,13 @@ tests/rump/rumpkern/t_vm.c			1.5,1.6 (pa
 	PR 55702, PR 55945: fix uvm pageout crashes.
 	[riastradh, ticket #1317]
 
+common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S 1.4
+
+	Cosmetics (to help later additional pullups)
+	[skrll, ticket #1319]
+
+sys/external/bsd/drm2/linux/linux_reservation.c	1.12
+
+	drm: Release fence after use.
+	[riastradh, ticket #1320]
+



CVS commit: [netbsd-9] src/sys/external/bsd/drm2/linux

2021-07-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jul  8 11:23:29 UTC 2021

Modified Files:
src/sys/external/bsd/drm2/linux [netbsd-9]: linux_reservation.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1320):

sys/external/bsd/drm2/linux/linux_reservation.c: revision 1.12

drm: Release fence after use.

May plug the dreaded radeon kmem memory leak.
XXX pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.11.8.1 \
src/sys/external/bsd/drm2/linux/linux_reservation.c

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

Modified files:

Index: src/sys/external/bsd/drm2/linux/linux_reservation.c
diff -u src/sys/external/bsd/drm2/linux/linux_reservation.c:1.11 src/sys/external/bsd/drm2/linux/linux_reservation.c:1.11.8.1
--- src/sys/external/bsd/drm2/linux/linux_reservation.c:1.11	Mon Sep  3 18:02:11 2018
+++ src/sys/external/bsd/drm2/linux/linux_reservation.c	Thu Jul  8 11:23:28 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_reservation.c,v 1.11 2018/09/03 18:02:11 riastradh Exp $	*/
+/*	$NetBSD: linux_reservation.c,v 1.11.8.1 2021/07/08 11:23:28 martin Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_reservation.c,v 1.11 2018/09/03 18:02:11 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_reservation.c,v 1.11.8.1 2021/07/08 11:23:28 martin Exp $");
 
 #include 
 #include 
@@ -796,6 +796,7 @@ wait:
 	ret = fence_wait_timeout(fence, intr, timeout);
 	if (ret <= 0)
 		return ret;
+	fence_put(fence);
 	KASSERT(ret <= timeout);
 	timeout = ret;
 	goto top;



CVS commit: [netbsd-9] src/sys/external/bsd/drm2/linux

2021-07-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jul  8 11:23:29 UTC 2021

Modified Files:
src/sys/external/bsd/drm2/linux [netbsd-9]: linux_reservation.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1320):

sys/external/bsd/drm2/linux/linux_reservation.c: revision 1.12

drm: Release fence after use.

May plug the dreaded radeon kmem memory leak.
XXX pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.11.8.1 \
src/sys/external/bsd/drm2/linux/linux_reservation.c

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



CVS commit: [netbsd-9] src/common/lib/libc/arch/aarch64/atomic

2021-07-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jul  8 11:22:01 UTC 2021

Modified Files:
src/common/lib/libc/arch/aarch64/atomic [netbsd-9]: atomic_nand_16.S

Log Message:
Pull up following revision(s) (requested by skrll in ticket #1319):

common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S: revision 1.4

One more s/pte/ptr/


To generate a diff of this commit:
cvs rdiff -u -r1.1.28.1 -r1.1.28.2 \
src/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S

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

Modified files:

Index: src/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S
diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S:1.1.28.1 src/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S:1.1.28.2
--- src/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S:1.1.28.1	Tue Jul  6 04:13:50 2021
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S	Thu Jul  8 11:22:01 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_nand_16.S,v 1.1.28.1 2021/07/06 04:13:50 martin Exp $ */
+/* $NetBSD: atomic_nand_16.S,v 1.1.28.2 2021/07/08 11:22:01 martin Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@ ENTRY_NP(_atomic_nand_16)
 	mov	x4, x0
 1:	ldxrh	w0, [x4]		/* load old value (*ptr) */
 	and	w3, w0, w1		/* w3 =  (*ptr & value) */
-	mvn	w3, w3			/* w3 = ~(*pte & value) */
+	mvn	w3, w3			/* w3 = ~(*ptr & value) */
 	stxrh	w2, w3, [x4]		/* try to store */
 	cbnz	w2, 1b			/*   succeed? no, try again */
 	dmb	st
@@ -58,7 +58,7 @@ ENTRY_NP(_atomic_nand_16_nv)
 	mov	x4, x0			/* need r0 for return value */
 1:	ldxrh	w0, [x4]		/* load old value (*ptr) */
 	and	w0, w0, w1		/* w0 =  (*ptr & value) */
-	mvn	w0, w0			/* w0 = ~(*pte & value), return value */
+	mvn	w0, w0			/* w0 = ~(*ptr & value), return value */
 	stxrh	w2, w0, [x4]		/* try to store */
 	cbnz	w2, 1b			/*   succeed? no, try again? */
 	dmb	st



CVS commit: [netbsd-9] src/common/lib/libc/arch/aarch64/atomic

2021-07-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jul  8 11:22:01 UTC 2021

Modified Files:
src/common/lib/libc/arch/aarch64/atomic [netbsd-9]: atomic_nand_16.S

Log Message:
Pull up following revision(s) (requested by skrll in ticket #1319):

common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S: revision 1.4

One more s/pte/ptr/


To generate a diff of this commit:
cvs rdiff -u -r1.1.28.1 -r1.1.28.2 \
src/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S

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



CVS commit: src/distrib/sets/lists

2021-07-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jul  8 09:16:25 UTC 2021

Modified Files:
src/distrib/sets/lists/debug: mi
src/distrib/sets/lists/tests: mi

Log Message:
Add new interrupted stdio tests


To generate a diff of this commit:
cvs rdiff -u -r1.353 -r1.354 src/distrib/sets/lists/debug/mi
cvs rdiff -u -r1.1078 -r1.1079 src/distrib/sets/lists/tests/mi

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

Modified files:

Index: src/distrib/sets/lists/debug/mi
diff -u src/distrib/sets/lists/debug/mi:1.353 src/distrib/sets/lists/debug/mi:1.354
--- src/distrib/sets/lists/debug/mi:1.353	Mon May 17 00:07:41 2021
+++ src/distrib/sets/lists/debug/mi	Thu Jul  8 05:16:24 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.353 2021/05/17 04:07:41 yamaguchi Exp $
+# $NetBSD: mi,v 1.354 2021/07/08 09:16:24 christos Exp $
 ./etc/mtree/set.debug   comp-sys-root
 ./usr/lib	comp-sys-usr		compatdir
 ./usr/lib/i18n/libBIG5_g.a			comp-c-debuglib		debuglib,compatfile
@@ -2088,6 +2088,9 @@
 ./usr/libdata/debug/usr/tests/lib/libc/ssp/h_strncpy.debug		tests-lib-debug		debug,atf,ssp,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/ssp/h_vsnprintf.debug		tests-lib-debug		debug,atf,ssp,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/ssp/h_vsprintf.debug		tests-lib-debug		debug,atf,ssp,compattestfile
+./usr/libdata/debug/usr/tests/lib/libc/stdio/h_intr.debug		tests-lib-debug		debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/lib/libc/stdio/h_makenumbers.debug	tests-lib-debug		debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/lib/libc/stdio/h_testnumbers.debug	tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/stdio/t_clearerr.debug		tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/stdio/t_fflush.debug		tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/stdio/t_fmemopen.debug		tests-lib-debug		debug,atf,compattestfile

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1078 src/distrib/sets/lists/tests/mi:1.1079
--- src/distrib/sets/lists/tests/mi:1.1078	Thu Jul  8 01:18:49 2021
+++ src/distrib/sets/lists/tests/mi	Thu Jul  8 05:16:24 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1078 2021/07/08 05:18:49 rillig Exp $
+# $NetBSD: mi,v 1.1079 2021/07/08 09:16:24 christos Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -3063,12 +3063,16 @@
 ./usr/tests/lib/libc/stdiotests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/stdio/Atffile			tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/stdio/Kyuafile			tests-lib-tests		compattestfile,atf,kyua
+./usr/tests/lib/libc/stdio/h_intr			tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libc/stdio/h_makenumbers		tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libc/stdio/h_testnumbers		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/stdio/t_clearerr			tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/stdio/t_fflush			tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/stdio/t_fmemopen			tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/stdio/t_fopen			tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/stdio/t_format			tests-obsolete		obsolete
 ./usr/tests/lib/libc/stdio/t_fputc			tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libc/stdio/t_intr			tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/stdio/t_mktemp			tests-obsolete		obsolete
 ./usr/tests/lib/libc/stdio/t_open_memstream		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/stdio/t_popen			tests-lib-tests		compattestfile,atf



CVS commit: src/distrib/sets/lists

2021-07-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jul  8 09:16:25 UTC 2021

Modified Files:
src/distrib/sets/lists/debug: mi
src/distrib/sets/lists/tests: mi

Log Message:
Add new interrupted stdio tests


To generate a diff of this commit:
cvs rdiff -u -r1.353 -r1.354 src/distrib/sets/lists/debug/mi
cvs rdiff -u -r1.1078 -r1.1079 src/distrib/sets/lists/tests/mi

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



CVS commit: src/tests/lib/libc/stdio

2021-07-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jul  8 09:07:46 UTC 2021

Modified Files:
src/tests/lib/libc/stdio: Makefile
Added Files:
src/tests/lib/libc/stdio: h_intr.c h_makenumbers.c h_testnumbers.c
t_intr.sh

Log Message:
Add interrupted I/O tests (from RVP)


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/tests/lib/libc/stdio/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/stdio/h_intr.c \
src/tests/lib/libc/stdio/h_makenumbers.c \
src/tests/lib/libc/stdio/h_testnumbers.c \
src/tests/lib/libc/stdio/t_intr.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/lib/libc/stdio/Makefile
diff -u src/tests/lib/libc/stdio/Makefile:1.14 src/tests/lib/libc/stdio/Makefile:1.15
--- src/tests/lib/libc/stdio/Makefile:1.14	Mon Jun 29 10:22:11 2020
+++ src/tests/lib/libc/stdio/Makefile	Thu Jul  8 05:07:46 2021
@@ -1,5 +1,6 @@
-# $NetBSD: Makefile,v 1.14 2020/06/29 14:22:11 jruoho Exp $
+# $NetBSD: Makefile,v 1.15 2021/07/08 09:07:46 christos Exp $
 
+NOMAN=
 .include 
 
 TESTSDIR=	${TESTSBASE}/lib/libc/stdio
@@ -13,6 +14,11 @@ TESTS_C+=	t_fputc
 TESTS_C+=	t_popen
 TESTS_C+=	t_printf
 TESTS_C+=	t_scanf
+
+TESTS_SH+=	t_intr
+
 COPTS.t_printf.c += -Wno-format-nonliteral
 
+PROGS+=		h_intr h_makenumbers h_testnumbers
+
 .include 

Added files:

Index: src/tests/lib/libc/stdio/h_intr.c
diff -u /dev/null src/tests/lib/libc/stdio/h_intr.c:1.1
--- /dev/null	Thu Jul  8 05:07:46 2021
+++ src/tests/lib/libc/stdio/h_intr.c	Thu Jul  8 05:07:46 2021
@@ -0,0 +1,421 @@
+/*	$NetBSD: h_intr.c,v 1.1 2021/07/08 09:07:46 christos Exp $	*/
+
+/**
+ * Test of interrupted writes to popen()'ed commands.
+ *
+ * Example 1:
+ * ./h_fwrite -c "gzip -t" *.gz
+ *
+ * Example 2:
+ * while :; do ./h_fwrite -b $((12*1024)) -t 10 -c "bzip2 -t" *.bz2; sleep 2; done
+ *
+ * Example 3:
+ * Create checksum file:
+ * find /mnt -type f -exec sha512 -n {} + >SHA512
+ *
+ * Check program:
+ * find /mnt -type f -exec ./h_fwrite -b 512 -c run.sh {} +
+ * 
+ * ./run.sh:
+	#!/bin/sh
+	set -eu
+	grep -q "^$(sha512 -q)" SHA512
+ *
+ * Author: RVP at sdf.org
+ */
+
+#include 
+__RCSID("$NetBSD: h_intr.c,v 1.1 2021/07/08 09:07:46 christos Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int process(const char *fn);
+ssize_t maxread(FILE *fp, void *buf, size_t size);
+ssize_t smaxread(FILE *fp, void *buf, size_t size);
+ssize_t maxwrite(FILE *fp, const void *buf, size_t size);
+ssize_t smaxwrite(FILE *fp, const void *buf, size_t size);
+static sig_t xsignal(int signo, sig_t handler);
+static void alarmtimer(int wait);
+static void pr_star(int signo);
+static bool isvalid(const char *s);
+static int do_opts(int argc, char* argv[]);
+static void usage(FILE* fp);
+
+/* Globals */
+static struct options {
+	size_t bsize;
+	size_t ssize;
+	int btype;
+	int tmout;
+	const char *cmd;
+} opts;
+
+static const struct {
+	const char *name;
+	int value;
+} btypes[] = {
+	{ "IONBF", _IONBF },
+	{ "IOLBF", _IOLBF },
+	{ "IOFBF", _IOFBF },
+};
+
+enum {
+	MB = 1024 * 1024,
+	BSIZE = 16 * 1024,
+	DEF_MS = 100,
+	MS = 1000,
+};
+
+
+
+int
+main(int argc, char* argv[])
+{
+	int i, rc = EXIT_SUCCESS;
+
+	i = do_opts(argc, argv);
+	argc -= i;
+	argv += i;
+
+	if (argc == 0) {
+		usage(stderr);
+		return rc;
+	}
+
+	xsignal(SIGPIPE, SIG_IGN);
+	for (i = 0; i < argc; i++) {
+		char *s = strdup(argv[i]);
+		printf("%s...", basename(s));
+		fflush(stdout);
+		free(s);
+
+		sig_t osig = xsignal(SIGALRM, pr_star);
+
+		if (process(argv[i]) == 0)
+			printf("ok\n");
+		else
+			rc = EXIT_FAILURE;
+
+		xsignal(SIGALRM, osig);
+	}
+
+	return rc;
+}
+
+static int
+process(const char *fn)
+{
+	FILE *ifp, *ofp;
+	char *buf;
+	size_t nw = 0;
+	int rc = EXIT_FAILURE;
+	ssize_t n;
+
+	if ((buf = malloc(opts.bsize)) == NULL)
+		err(rc, "buffer alloc failed");
+
+	if ((ifp = fopen(fn, "r")) == NULL) {
+		warn("fopen failed: %s", fn);
+		return rc;
+	}
+
+	if ((ofp = popen(opts.cmd, "w")) == NULL)
+		err(rc, "popen failed `%s'", opts.cmd);
+
+	setvbuf(ofp, NULL, opts.btype, opts.ssize);
+	setvbuf(ifp, NULL, opts.btype, opts.ssize);
+
+	alarmtimer(opts.tmout);
+	while ((n = maxread(ifp, buf, opts.bsize)) > 0) {
+		ssize_t i;
+		if ((i = maxwrite(ofp, buf, n)) == -1) {
+			warn("write failed");
+			break;
+		}
+		nw += i;
+	}
+	alarmtimer(0);
+	// printf("%lu\n", nw);
+
+	fclose(ifp);
+	if (pclose(ofp) != 0)
+		warn("command failed `%s'", opts.cmd);
+	else
+		rc = EXIT_SUCCESS;
+
+	return rc;
+}
+
+/**
+ * maxread - syscall version
+ */
+ssize_t
+smaxread(FILE* fp, void* buf, size_t size)
+{
+	char* p = buf;
+	ssize_t nrd = 0;
+	ssize_t n;
+
+	while (size > 0) {
+		n = read(fileno(fp), p, size);
+		if (n < 0) {
+			if (errno == EINTR)
+continue;
+			else
+return -1;
+		} else if (n == 0)
+			break;
+		p += n;
+		nrd += n;
+		size -= n;
+	}
+	

CVS commit: src/tests/lib/libc/stdio

2021-07-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jul  8 09:07:46 UTC 2021

Modified Files:
src/tests/lib/libc/stdio: Makefile
Added Files:
src/tests/lib/libc/stdio: h_intr.c h_makenumbers.c h_testnumbers.c
t_intr.sh

Log Message:
Add interrupted I/O tests (from RVP)


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/tests/lib/libc/stdio/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/stdio/h_intr.c \
src/tests/lib/libc/stdio/h_makenumbers.c \
src/tests/lib/libc/stdio/h_testnumbers.c \
src/tests/lib/libc/stdio/t_intr.sh

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



CVS commit: src/lib/libc/stdio

2021-07-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jul  8 09:06:51 UTC 2021

Modified Files:
src/lib/libc/stdio: fflush.c fvwrite.c

Log Message:
Obey EINTR and return immediately adjusting for unwritten. From RVP


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/lib/libc/stdio/fflush.c
cvs rdiff -u -r1.26 -r1.27 src/lib/libc/stdio/fvwrite.c

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



CVS commit: src/lib/libc/stdio

2021-07-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jul  8 09:06:51 UTC 2021

Modified Files:
src/lib/libc/stdio: fflush.c fvwrite.c

Log Message:
Obey EINTR and return immediately adjusting for unwritten. From RVP


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/lib/libc/stdio/fflush.c
cvs rdiff -u -r1.26 -r1.27 src/lib/libc/stdio/fvwrite.c

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

Modified files:

Index: src/lib/libc/stdio/fflush.c
diff -u src/lib/libc/stdio/fflush.c:1.20 src/lib/libc/stdio/fflush.c:1.21
--- src/lib/libc/stdio/fflush.c:1.20	Tue Jul  6 10:22:16 2021
+++ src/lib/libc/stdio/fflush.c	Thu Jul  8 05:06:51 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: fflush.c,v 1.20 2021/07/06 14:22:16 christos Exp $	*/
+/*	$NetBSD: fflush.c,v 1.21 2021/07/08 09:06:51 christos Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)fflush.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: fflush.c,v 1.20 2021/07/06 14:22:16 christos Exp $");
+__RCSID("$NetBSD: fflush.c,v 1.21 2021/07/08 09:06:51 christos Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -108,18 +108,14 @@ __sflush(FILE *fp)
 	for (; n > 0; n -= t, p += t) {
 		t = (*fp->_write)(fp->_cookie, (char *)p, n);
 		if (t < 0) {
-			if (errno == EINTR) {
-t = 0;
-continue;
-			}
 			/* Reset _p and _w. */
 			if (p > fp->_p) {
 /* Some was written. */
 memmove(fp->_p, p, n);
-fp->_p += n;
-if ((fp->_flags & (__SLBF | __SNBF)) == 0)
-	fp->_w -= n;
 			}
+			fp->_p += n;
+			if ((fp->_flags & (__SLBF | __SNBF)) == 0)
+fp->_w -= n;
 			fp->_flags |= __SERR;
 			return EOF;
 		}

Index: src/lib/libc/stdio/fvwrite.c
diff -u src/lib/libc/stdio/fvwrite.c:1.26 src/lib/libc/stdio/fvwrite.c:1.27
--- src/lib/libc/stdio/fvwrite.c:1.26	Tue Jul  6 10:22:16 2021
+++ src/lib/libc/stdio/fvwrite.c	Thu Jul  8 05:06:51 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: fvwrite.c,v 1.26 2021/07/06 14:22:16 christos Exp $	*/
+/*	$NetBSD: fvwrite.c,v 1.27 2021/07/08 09:06:51 christos Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)fvwrite.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: fvwrite.c,v 1.26 2021/07/06 14:22:16 christos Exp $");
+__RCSID("$NetBSD: fvwrite.c,v 1.27 2021/07/08 09:06:51 christos Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -99,12 +99,14 @@ __sfvwrite(FILE *fp, struct __suio *uio)
 	}
 #define WRITE(nw) \
 	w = (*fp->_write)(fp->_cookie, p, nw); \
-	if (w < 0) { \
-		if (errno != EINTR) \
-			goto err; \
-		w = 0; \
-	} else \
-		w = w
+	if (w <= 0) \
+		goto err
+#define FLUSH(nw) \
+	if (fflush(fp)) { \
+		fp->_p -= nw;	/* rewind unwritten */ \
+		goto err; \
+	}
+
 	if (fp->_flags & __SNBF) {
 		/*
 		 * Unbuffered: write up to BUFSIZ bytes at a time.
@@ -162,8 +164,7 @@ __sfvwrite(FILE *fp, struct __suio *uio)
 COPY(w);
 /* fp->_w -= w; */ /* unneeded */
 fp->_p += w;
-if (fflush(fp))
-	goto err;
+FLUSH(w);
 			} else if (len >= (size_t)(w = fp->_bf._size)) {
 /* write directly */
 WRITE((size_t)w);
@@ -200,8 +201,7 @@ __sfvwrite(FILE *fp, struct __suio *uio)
 COPY(w);
 /* fp->_w -= w; */
 fp->_p += w;
-if (fflush(fp))
-	goto err;
+FLUSH(w);
 			} else if (s >= (w = fp->_bf._size)) {
 WRITE((size_t)w);
 			} else {
@@ -212,8 +212,7 @@ __sfvwrite(FILE *fp, struct __suio *uio)
 			}
 			if ((nldist -= w) == 0) {
 /* copied the newline: flush and forget */
-if (fflush(fp))
-	goto err;
+FLUSH(w);
 nlknown = 0;
 			}
 			p += w;