Re: CVS commit: src/lib/libc/time

2022-03-25 Thread Roland Illig

Am 26.03.2022 um 00:50 schrieb Tobias Nygren:

On Sat, 26 Mar 2022 00:31:45 +0100
Roland Illig  wrote:


localtime.c: add back storage class 'register'

This reduces the differences to the upstream code.


I don't know why you did that. It is as simple to sed -e 's/register //g'
in upstream when you diff. Adding register is useless; these days it is
mostly ignored by compilers, except you can't &...


I thought that having a small diff to the upstream code was more
important than a few saved keywords.  If I was wrong, I can of course
revert it.


Can we keep it as-is, but #define register to empty at the top of the file?


I don't think the compiler's view on the code is the main point of this
discussion.  At least, GCC generates the same code on x86_64, with or
without 'register', so it doesn't seem to care.

To me, the more interesting question is how human readers should deal
with the code.

If this piece of code had originated in the NetBSD tree, I wouldn't have
added the 'register' keywords, I would have just indented the code
according to KNF.

But, most of this code is copied from the tz project, therefore our goal
should be to make the diff minimal, in order to benefit from the testing
of other projects using the same code.  In this case, it means to keep
the indentation exactly as inconsistent as upstream and also to keep the
keyword 'register'.  The remaining diff is still large enough to consume
some developer time, containing a few fixes for WARNS=6 and for the lint
checks.

Roland


Re: CVS commit: src/lib/libc/time

2022-03-25 Thread Tobias Nygren
On Sat, 26 Mar 2022 00:31:45 +0100
Roland Illig  wrote:

> >> localtime.c: add back storage class 'register'
> >>
> >> This reduces the differences to the upstream code.
> >
> > I don't know why you did that. It is as simple to sed -e 's/register //g'
> > in upstream when you diff. Adding register is useless; these days it is
> > mostly ignored by compilers, except you can't &...
> 
> I thought that having a small diff to the upstream code was more
> important than a few saved keywords.  If I was wrong, I can of course
> revert it.

Can we keep it as-is, but #define register to empty at the top of the file?



Re: CVS commit: src/lib/libc/time

2022-03-25 Thread Roland Illig

Am 25.03.2022 um 22:25 schrieb Christos Zoulas:

In article <20220325183551.0f039f...@cvs.netbsd.org>,
Roland Illig  wrote:

-=-=-=-=-=-

Module Name:src
Committed By:   rillig
Date:   Fri Mar 25 18:35:50 UTC 2022

Modified Files:
src/lib/libc/time: localtime.c

Log Message:
localtime.c: add back storage class 'register'

This reduces the differences to the upstream code.


I don't know why you did that. It is as simple to sed -e 's/register //g'
in upstream when you diff. Adding register is useless; these days it is
mostly ignored by compilers, except you can't &...


I thought that having a small diff to the upstream code was more
important than a few saved keywords.  If I was wrong, I can of course
revert it.

Roland


CVS commit: src/sys/dev/ic

2022-03-25 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Fri Mar 25 23:16:04 UTC 2022

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

Log Message:
dwhdmi: properly initialize connector atomic helper funcs (PR port-evbarm/56766)


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/ic/dw_hdmi.c

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

Modified files:

Index: src/sys/dev/ic/dw_hdmi.c
diff -u src/sys/dev/ic/dw_hdmi.c:1.9 src/sys/dev/ic/dw_hdmi.c:1.10
--- src/sys/dev/ic/dw_hdmi.c:1.9	Sun Dec 19 11:01:11 2021
+++ src/sys/dev/ic/dw_hdmi.c	Fri Mar 25 23:16:04 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: dw_hdmi.c,v 1.9 2021/12/19 11:01:11 riastradh Exp $ */
+/* $NetBSD: dw_hdmi.c,v 1.10 2022/03/25 23:16:04 tnn Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dw_hdmi.c,v 1.9 2021/12/19 11:01:11 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dw_hdmi.c,v 1.10 2022/03/25 23:16:04 tnn Exp $");
 
 #include 
 #include 
@@ -47,6 +47,7 @@ __KERNEL_RCSID(0, "$NetBSD: dw_hdmi.c,v 
 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -570,6 +571,9 @@ static const struct drm_connector_funcs 
 	.detect = dwhdmi_connector_detect,
 	.fill_modes = drm_helper_probe_single_connector_modes,
 	.destroy = dwhdmi_connector_destroy,
+	.reset = drm_atomic_helper_connector_reset,
+	.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
+	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
 };
 
 static int



CVS commit: src/sys/dev/ic

2022-03-25 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Fri Mar 25 23:16:04 UTC 2022

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

Log Message:
dwhdmi: properly initialize connector atomic helper funcs (PR port-evbarm/56766)


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/ic/dw_hdmi.c

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



Re: CVS commit: src/lib/libc/time

2022-03-25 Thread Christos Zoulas
In article ,
Roland Illig   wrote:
>
>The mess with the indentation comes from upstream.  In our copy it's a
>bit worth than upstream, but not much.

I've asked upstream to indent consistently in the past. It has not happened.
I try to minimize the diffs with upstream so that we can keep patching in
our changes. I've also submitted our changes for inclusion to upstream.
Some have been accepted, others have not.

Best,

christos



Re: CVS commit: src/lib/libc/time

2022-03-25 Thread Christos Zoulas
In article <20220325183551.0f039f...@cvs.netbsd.org>,
Roland Illig  wrote:
>-=-=-=-=-=-
>
>Module Name:   src
>Committed By:  rillig
>Date:  Fri Mar 25 18:35:50 UTC 2022
>
>Modified Files:
>   src/lib/libc/time: localtime.c
>
>Log Message:
>localtime.c: add back storage class 'register'
>
>This reduces the differences to the upstream code.

I don't know why you did that. It is as simple to sed -e 's/register //g'
in upstream when you diff. Adding register is useless; these days it is
mostly ignored by compilers, except you can't &...

christos



Re: CVS commit: src/lib/libc/time

2022-03-25 Thread Christos Zoulas
In article <20220325190016.15114f...@cvs.netbsd.org>,
Roland Illig  wrote:
>-=-=-=-=-=-
>
>Module Name:   src
>Committed By:  rillig
>Date:  Fri Mar 25 19:00:16 UTC 2022
>
>Modified Files:
>   src/lib/libc/time: localtime.c
>
>Log Message:
>localtime.c: take indentation style from upstream

That I am fine with, but remember that some of the indentation changes
in upstream were gratuitus (no code changes).

christos



CVS commit: src/usr.bin/make/unit-tests

2022-03-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Mar 25 23:03:47 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: directive-undef.mk

Log Message:
tests/make: test .undef for exported global variables


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/directive-undef.mk

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/make/unit-tests/directive-undef.mk
diff -u src/usr.bin/make/unit-tests/directive-undef.mk:1.10 src/usr.bin/make/unit-tests/directive-undef.mk:1.11
--- src/usr.bin/make/unit-tests/directive-undef.mk:1.10	Tue Feb 16 18:02:19 2021
+++ src/usr.bin/make/unit-tests/directive-undef.mk	Fri Mar 25 23:03:47 2022
@@ -1,4 +1,4 @@
-# $NetBSD: directive-undef.mk,v 1.10 2021/02/16 18:02:19 rillig Exp $
+# $NetBSD: directive-undef.mk,v 1.11 2022/03/25 23:03:47 rillig Exp $
 #
 # Tests for the .undef directive.
 #
@@ -43,11 +43,11 @@
 3=		3
 ${:U1 2 3}=	one two three
 VARNAMES=	1 2 3
-.undef ${VARNAMES}		# undefines the variable "1 2 3"
-.if !defined(${:U1 2 3})
+.undef ${VARNAMES}		# undefines the variables "1", "2" and "3"
+.if ${${:U1 2 3}} != "one two three"	# still there
 .  error
 .endif
-.if ${1:U_}${2:U_}${3:U_} != "___"	# these are still defined
+.if ${1:U_}${2:U_}${3:U_} != "___"	# these have been undefined
 .  error
 .endif
 
@@ -104,4 +104,30 @@ UT_EXPORTED=	exported-value
 .endif
 
 
+# When an exported variable is undefined, the variable is removed both from
+# the global scope as well as from the environment.
+DIRECT=		direct
+INDIRECT=	in-${DIRECT}
+.export DIRECT INDIRECT
+.if ${DIRECT} != "direct"
+.  error
+.endif
+.if ${INDIRECT} != "in-direct"
+.  error
+.endif
+
+# Deletes the variables from the global scope and also from the environment.
+# This applies to both variables, even though 'INDIRECT' is not actually
+# exported yet since it refers to another variable.
+.undef DIRECT			# Separate '.undef' directives,
+.undef INDIRECT			# for backwards compatibility.
+
+.if ${DIRECT:Uundefined} != "undefined"
+.  error
+.endif
+.if ${INDIRECT:Uundefined} != "undefined"
+.  error
+.endif
+
+
 all:



CVS commit: src/usr.bin/make/unit-tests

2022-03-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Mar 25 23:03:47 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: directive-undef.mk

Log Message:
tests/make: test .undef for exported global variables


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/directive-undef.mk

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



CVS commit: src/usr.bin/make/unit-tests

2022-03-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Mar 25 22:38:39 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: Makefile

Log Message:
tests/make: suppress -DCLEANUP output in test deptgt-phony


To generate a diff of this commit:
cvs rdiff -u -r1.309 -r1.310 src/usr.bin/make/unit-tests/Makefile

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

Modified files:

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.309 src/usr.bin/make/unit-tests/Makefile:1.310
--- src/usr.bin/make/unit-tests/Makefile:1.309	Sat Feb 12 13:17:57 2022
+++ src/usr.bin/make/unit-tests/Makefile	Fri Mar 25 22:38:39 2022
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.309 2022/02/12 13:17:57 rillig Exp $
+# $NetBSD: Makefile,v 1.310 2022/03/25 22:38:39 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -485,9 +485,8 @@ FLAGS.jobs-error-nested-make=	# none, es
 FLAGS.varname-empty=		-dv '$${:U}=cmdline-u' '=cmdline-plain'
 
 # Some tests need extra postprocessing.
-SED_CMDS.dir=		${:D remove output from -DCLEANUP mode }
-SED_CMDS.dir+=		-e '/^OpenDirs_Done:/d'
-SED_CMDS.dir+=		-e '/^CachedDir /d'
+SED_CMDS.deptgt-phony=	${STD_SED_CMDS.dd}
+SED_CMDS.dir=		${STD_SED_CMDS.dd}
 SED_CMDS.export=	-e '/^[^=_A-Za-z0-9]*=/d'
 SED_CMDS.export-all=	${SED_CMDS.export}
 SED_CMDS.export-env=	${SED_CMDS.export}
@@ -552,6 +551,11 @@ unexport-env.rawout: export.mk
 
 # Some standard sed commands, to be used in the SED_CMDS above.
 
+# In tests that use the debugging option -dd, ignore debugging output that is
+# only logged in -DCLEANUP mode.
+STD_SED_CMDS.dd=		-e '/^OpenDirs_Done:/d'
+STD_SED_CMDS.dd+=		-e '/^CachedDir /d'
+
 # Omit details such as process IDs from the output of the -dg1 option.
 STD_SED_CMDS.dg1=	-e 's,${.CURDIR}$$,,'
 STD_SED_CMDS.dg1+=	-e 's,  ${DEFSYSPATH:U/usr/share/mk}$$,  ,'



CVS commit: src/usr.bin/make/unit-tests

2022-03-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Mar 25 22:38:39 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: Makefile

Log Message:
tests/make: suppress -DCLEANUP output in test deptgt-phony


To generate a diff of this commit:
cvs rdiff -u -r1.309 -r1.310 src/usr.bin/make/unit-tests/Makefile

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



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

2022-03-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Mar 25 21:24:20 UTC 2022

Modified Files:
src/sys/arch/evbarm/conf: GENERIC.common

Log Message:
evbarm: Enable USERCONF option


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/evbarm/conf/GENERIC.common

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

Modified files:

Index: src/sys/arch/evbarm/conf/GENERIC.common
diff -u src/sys/arch/evbarm/conf/GENERIC.common:1.47 src/sys/arch/evbarm/conf/GENERIC.common:1.48
--- src/sys/arch/evbarm/conf/GENERIC.common:1.47	Sat Jun 26 09:29:14 2021
+++ src/sys/arch/evbarm/conf/GENERIC.common	Fri Mar 25 21:24:20 2022
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC.common,v 1.47 2021/06/26 09:29:14 nia Exp $
+#	$NetBSD: GENERIC.common,v 1.48 2022/03/25 21:24:20 jmcneill Exp $
 #
 #	GENERIC evbarm kernel config (template)
 #
@@ -95,7 +95,7 @@ options 	SYSVSHM		# System V-like memory
 options 	KTRACE			# system call tracing, a la ktrace(1)
 #options 	SCSIVERBOSE		# Verbose SCSI errors
 #options 	MIIVERBOSE		# Verbose MII autoconfuration messages
-#options 	USERCONF		# userconf(4) support
+options 	USERCONF		# userconf(4) support
 #options 	PIPE_SOCKETPAIR		# smaller, but slower pipe(2)
 
 # Wedge support



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

2022-03-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Mar 25 21:24:20 UTC 2022

Modified Files:
src/sys/arch/evbarm/conf: GENERIC.common

Log Message:
evbarm: Enable USERCONF option


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/evbarm/conf/GENERIC.common

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



CVS commit: src/sys/dev/fdt

2022-03-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Mar 25 21:23:51 UTC 2022

Modified Files:
src/sys/dev/fdt: files.fdt
Added Files:
src/sys/dev/fdt: fdt_userconf.c

Log Message:
fdt: add support for USERCONF option


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/dev/fdt/fdt_userconf.c
cvs rdiff -u -r1.63 -r1.64 src/sys/dev/fdt/files.fdt

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/fdt/files.fdt
diff -u src/sys/dev/fdt/files.fdt:1.63 src/sys/dev/fdt/files.fdt:1.64
--- src/sys/dev/fdt/files.fdt:1.63	Fri Mar  4 08:19:06 2022
+++ src/sys/dev/fdt/files.fdt	Fri Mar 25 21:23:51 2022
@@ -1,4 +1,4 @@
-# $NetBSD: files.fdt,v 1.63 2022/03/04 08:19:06 skrll Exp $
+# $NetBSD: files.fdt,v 1.64 2022/03/25 21:23:51 jmcneill Exp $
 
 include	"external/bsd/libfdt/conf/files.libfdt"
 
@@ -13,6 +13,8 @@ device	simplebus: fdt
 attach	simplebus at fdt
 file	dev/fdt/fdtbus.c			fdt
 
+file	dev/fdt/fdt_userconf.c			fdt & userconf
+
 device	fregulator
 attach	fregulator at fdt
 file	dev/fdt/fixedregulator.c		fregulator

Added files:

Index: src/sys/dev/fdt/fdt_userconf.c
diff -u /dev/null src/sys/dev/fdt/fdt_userconf.c:1.1
--- /dev/null	Fri Mar 25 21:23:51 2022
+++ src/sys/dev/fdt/fdt_userconf.c	Fri Mar 25 21:23:51 2022
@@ -0,0 +1,67 @@
+/* $NetBSD: fdt_userconf.c,v 1.1 2022/03/25 21:23:51 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2022 Jared McNeill 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: fdt_userconf.c,v 1.1 2022/03/25 21:23:51 jmcneill Exp $");
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#define	FDT_CHOSEN_PATH			"/chosen"
+#define	FDT_CHOSEN_USERCONF_PROP	"netbsd,userconf"
+
+void
+userconf_bootinfo(void)
+{
+	const void *fdt = fdtbus_get_data();
+	const char *cmd;
+	int chosen, index;
+
+	if (fdt == NULL) {
+		return;
+	}
+
+	chosen = fdt_path_offset(fdt, FDT_CHOSEN_PATH);
+	if (chosen < 0) {
+		return;
+	}
+
+	index = 0;
+	do {
+		cmd = fdt_stringlist_get(fdt, chosen, FDT_CHOSEN_USERCONF_PROP,
+		index++, NULL);
+		if (cmd != NULL) {
+			aprint_debug("Processing userconf command: %s\n", cmd);
+			userconf_parse(__UNCONST(cmd));
+		}
+	} while (cmd != NULL);
+}



CVS commit: src/sys/dev/fdt

2022-03-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Mar 25 21:23:51 UTC 2022

Modified Files:
src/sys/dev/fdt: files.fdt
Added Files:
src/sys/dev/fdt: fdt_userconf.c

Log Message:
fdt: add support for USERCONF option


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/dev/fdt/fdt_userconf.c
cvs rdiff -u -r1.63 -r1.64 src/sys/dev/fdt/files.fdt

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



CVS commit: src/sys/stand/efiboot

2022-03-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Mar 25 21:23:00 UTC 2022

Modified Files:
src/sys/stand/efiboot: Makefile.efiboot boot.c bootmenu.c efiboot.h
efifdt.c efifdt.h version
Added Files:
src/sys/stand/efiboot: userconf.c

Log Message:
efiboot: Add support for 'userconf' command.

Add support for the 'userconf' command at the boot prompt and in boot.cfg,
and for FDT based booting, pass the commands as a string list property
named "netbsd,userconf" on the /chosen node.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/stand/efiboot/Makefile.efiboot
cvs rdiff -u -r1.42 -r1.43 src/sys/stand/efiboot/boot.c
cvs rdiff -u -r1.3 -r1.4 src/sys/stand/efiboot/bootmenu.c
cvs rdiff -u -r1.18 -r1.19 src/sys/stand/efiboot/efiboot.h
cvs rdiff -u -r1.33 -r1.34 src/sys/stand/efiboot/efifdt.c
cvs rdiff -u -r1.11 -r1.12 src/sys/stand/efiboot/efifdt.h
cvs rdiff -u -r0 -r1.1 src/sys/stand/efiboot/userconf.c
cvs rdiff -u -r1.29 -r1.30 src/sys/stand/efiboot/version

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

Modified files:

Index: src/sys/stand/efiboot/Makefile.efiboot
diff -u src/sys/stand/efiboot/Makefile.efiboot:1.25 src/sys/stand/efiboot/Makefile.efiboot:1.26
--- src/sys/stand/efiboot/Makefile.efiboot:1.25	Sun Oct 17 14:12:54 2021
+++ src/sys/stand/efiboot/Makefile.efiboot	Fri Mar 25 21:23:00 2022
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.25 2021/10/17 14:12:54 jmcneill Exp $
+# $NetBSD: Makefile.efiboot,v 1.26 2022/03/25 21:23:00 jmcneill Exp $
 
 S=		${.CURDIR}/../../..
 
@@ -22,7 +22,7 @@ AFLAGS.start.S= ${${ACTIVE_CC} == "clang
 .PATH: ${EFIDIR}/gnuefi
 SOURCES=	crt0-efi-${GNUEFIARCH}.S reloc_${GNUEFIARCH}.c
 SOURCES+=	boot.c bootmenu.c conf.c console.c dev_net.c devopen.c exec.c \
-		module.c panic.c prompt.c
+		module.c panic.c prompt.c userconf.c
 SOURCES+=	efiboot.c efichar.c efidev.c efigetsecs.c \
 		efifile.c efiblock.c efinet.c efipxe.c efirng.c \
 		efiwatchdog.c efigop.c smbios.c

Index: src/sys/stand/efiboot/boot.c
diff -u src/sys/stand/efiboot/boot.c:1.42 src/sys/stand/efiboot/boot.c:1.43
--- src/sys/stand/efiboot/boot.c:1.42	Thu Nov  4 07:28:34 2021
+++ src/sys/stand/efiboot/boot.c	Fri Mar 25 21:23:00 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.42 2021/11/04 07:28:34 skrll Exp $	*/
+/*	$NetBSD: boot.c,v 1.43 2022/03/25 21:23:00 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -114,6 +114,7 @@ void	command_mem(char *);
 void	command_menu(char *);
 void	command_reset(char *);
 void	command_setup(char *);
+void	command_userconf(char *);
 void	command_version(char *);
 void	command_quit(char *);
 
@@ -141,6 +142,7 @@ const struct boot_command commands[] = {
 	{ "reboot",	command_reset,		"reboot|reset" },
 	{ "reset",	command_reset,		NULL },
 	{ "setup",	command_setup,		"setup" },
+	{ "userconf",	command_userconf,	"userconf " },
 	{ "version",	command_version,	"version" },
 	{ "ver",	command_version,	NULL },
 	{ "help",	command_help,		"help|?" },
@@ -450,6 +452,12 @@ command_setup(char *arg)
 	efi_reboot();
 }
 
+void
+command_userconf(char *arg)
+{
+	userconf_add(arg);
+}
+
 int
 set_default_device(const char *arg)
 {

Index: src/sys/stand/efiboot/bootmenu.c
diff -u src/sys/stand/efiboot/bootmenu.c:1.3 src/sys/stand/efiboot/bootmenu.c:1.4
--- src/sys/stand/efiboot/bootmenu.c:1.3	Wed Oct  6 10:13:19 2021
+++ src/sys/stand/efiboot/bootmenu.c	Fri Mar 25 21:23:00 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: bootmenu.c,v 1.3 2021/10/06 10:13:19 jmcneill Exp $	*/
+/*	$NetBSD: bootmenu.c,v 1.4 2022/03/25 21:23:00 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -60,10 +60,8 @@ do_bootcfg_command(const char *cmd, char
 {
 	if (strcmp(cmd, BOOTCFG_CMD_LOAD) == 0)
 		module_add(arg);
-#if notyet
 	else if (strcmp(cmd, BOOTCFG_CMD_USERCONF) == 0)
 		userconf_add(arg);
-#endif
 #ifdef EFIBOOT_FDT
 	else if (strcmp(cmd, "dtoverlay") == 0)
 		dtoverlay_add(arg);

Index: src/sys/stand/efiboot/efiboot.h
diff -u src/sys/stand/efiboot/efiboot.h:1.18 src/sys/stand/efiboot/efiboot.h:1.19
--- src/sys/stand/efiboot/efiboot.h:1.18	Wed Oct  6 10:13:19 2021
+++ src/sys/stand/efiboot/efiboot.h	Fri Mar 25 21:23:00 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: efiboot.h,v 1.18 2021/10/06 10:13:19 jmcneill Exp $	*/
+/*	$NetBSD: efiboot.h,v 1.19 2022/03/25 21:23:00 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -131,3 +131,7 @@ char *gettrailer(char *);
 void docommand(char *);
 char awaitkey(int, int);
 __dead void bootprompt(void);
+
+/* userconf.c */
+void userconf_add(const char *);
+void userconf_foreach(void (*)(const char *));

Index: src/sys/stand/efiboot/efifdt.c
diff -u src/sys/stand/efiboot/efifdt.c:1.33 src/sys/stand/efiboot/efifdt.c:1.34
--- src/sys/stand/efiboot/efifdt.c:1.33	Sat Nov  6 19:44:22 2021
+++ src/sys/stand/efiboot/efifdt.c	Fri Mar 25 21:23:00 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: efifdt.c,v 1.33 2021/11/06 19:44:22 

CVS commit: src/sys/stand/efiboot

2022-03-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Mar 25 21:23:00 UTC 2022

Modified Files:
src/sys/stand/efiboot: Makefile.efiboot boot.c bootmenu.c efiboot.h
efifdt.c efifdt.h version
Added Files:
src/sys/stand/efiboot: userconf.c

Log Message:
efiboot: Add support for 'userconf' command.

Add support for the 'userconf' command at the boot prompt and in boot.cfg,
and for FDT based booting, pass the commands as a string list property
named "netbsd,userconf" on the /chosen node.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/stand/efiboot/Makefile.efiboot
cvs rdiff -u -r1.42 -r1.43 src/sys/stand/efiboot/boot.c
cvs rdiff -u -r1.3 -r1.4 src/sys/stand/efiboot/bootmenu.c
cvs rdiff -u -r1.18 -r1.19 src/sys/stand/efiboot/efiboot.h
cvs rdiff -u -r1.33 -r1.34 src/sys/stand/efiboot/efifdt.c
cvs rdiff -u -r1.11 -r1.12 src/sys/stand/efiboot/efifdt.h
cvs rdiff -u -r0 -r1.1 src/sys/stand/efiboot/userconf.c
cvs rdiff -u -r1.29 -r1.30 src/sys/stand/efiboot/version

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



CVS commit: src/usr.bin/make

2022-03-25 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Fri Mar 25 21:16:04 UTC 2022

Modified Files:
src/usr.bin/make: make.1 parse.c

Log Message:
Include posix.mk when .POSIX: first encountered

Since .POSIX: is required to be the first non-comment line
in a Makefile, including ${MAKE_POSIX_MK} or whatever _PATH_POSIX_MK is
set to at this point is equivalent to an extension of sys.mk

This is a minimal change that can allow a better approximation of
POSIX compliance

Reviewed by: rillig


To generate a diff of this commit:
cvs rdiff -u -r1.305 -r1.306 src/usr.bin/make/make.1
cvs rdiff -u -r1.667 -r1.668 src/usr.bin/make/parse.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/make/make.1
diff -u src/usr.bin/make/make.1:1.305 src/usr.bin/make/make.1:1.306
--- src/usr.bin/make/make.1:1.305	Wed Feb  9 21:09:24 2022
+++ src/usr.bin/make/make.1	Fri Mar 25 21:16:04 2022
@@ -1,4 +1,4 @@
-.\"	$NetBSD: make.1,v 1.305 2022/02/09 21:09:24 rillig Exp $
+.\"	$NetBSD: make.1,v 1.306 2022/03/25 21:16:04 sjg Exp $
 .\"
 .\" Copyright (c) 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"	from: @(#)make.1	8.4 (Berkeley) 3/19/94
 .\"
-.Dd January 28, 2022
+.Dd March 24, 2022
 .Dt MAKE 1
 .Os
 .Sh NAME
@@ -2289,6 +2289,18 @@ The suffix must have been previously dec
 Apply the
 .Ic .PHONY
 attribute to any specified sources.
+.It Ic .POSIX
+This should be the first non-comment line in a Makefile.
+It results in the variable
+.Va %POSIX
+being defined with the value
+.Ql 1003.2 .
+The first time
+.Ic .POSIX
+is encountered, the makefile
+.Ql posix.mk
+will be included if possible,
+to provide POSIX compatible default rules.
 .It Ic .PRECIOUS
 Apply the
 .Ic .PRECIOUS

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.667 src/usr.bin/make/parse.c:1.668
--- src/usr.bin/make/parse.c:1.667	Thu Mar  3 19:55:27 2022
+++ src/usr.bin/make/parse.c	Fri Mar 25 21:16:04 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.667 2022/03/03 19:55:27 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.668 2022/03/25 21:16:04 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -106,7 +106,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.667 2022/03/03 19:55:27 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.668 2022/03/25 21:16:04 sjg Exp $");
 
 /*
  * A file being read.
@@ -1115,6 +1115,121 @@ ClearPaths(SearchPathList *paths)
 	Dir_SetPATH();
 }
 
+/*
+ * Handle one of the .[-ds]include directives by remembering the current file
+ * and pushing the included file on the stack.  After the included file has
+ * finished, parsing continues with the including file; see Parse_PushInput
+ * and ParseEOF.
+ *
+ * System includes are looked up in sysIncPath, any other includes are looked
+ * up in the parsedir and then in the directories specified by the -I command
+ * line options.
+ */
+static void
+IncludeFile(const char *file, bool isSystem, bool depinc, bool silent)
+{
+	Buffer buf;
+	char *fullname;		/* full pathname of file */
+	char *newName;
+	char *slash, *incdir;
+	int fd;
+	int i;
+
+	fullname = file[0] == '/' ? bmake_strdup(file) : NULL;
+
+	if (fullname == NULL && !isSystem) {
+		/*
+		 * Include files contained in double-quotes are first searched
+		 * relative to the including file's location. We don't want to
+		 * cd there, of course, so we just tack on the old file's
+		 * leading path components and call Dir_FindFile to see if
+		 * we can locate the file.
+		 */
+
+		incdir = bmake_strdup(CurFile()->name.str);
+		slash = strrchr(incdir, '/');
+		if (slash != NULL) {
+			*slash = '\0';
+			/*
+			 * Now do lexical processing of leading "../" on the
+			 * filename.
+			 */
+			for (i = 0; strncmp(file + i, "../", 3) == 0; i += 3) {
+slash = strrchr(incdir + 1, '/');
+if (slash == NULL || strcmp(slash, "/..") == 0)
+	break;
+*slash = '\0';
+			}
+			newName = str_concat3(incdir, "/", file + i);
+			fullname = Dir_FindFile(newName, parseIncPath);
+			if (fullname == NULL)
+fullname = Dir_FindFile(newName,
+);
+			free(newName);
+		}
+		free(incdir);
+
+		if (fullname == NULL) {
+			/*
+			 * Makefile wasn't found in same directory as included
+			 * makefile.
+			 *
+			 * Search for it first on the -I search path, then on
+			 * the .PATH search path, if not found in a -I
+			 * directory. If we have a suffix-specific path, we
+			 * should use that.
+			 */
+			const char *suff;
+			SearchPath *suffPath = NULL;
+
+			if ((suff = strrchr(file, '.')) != NULL) {
+suffPath = Suff_GetPath(suff);
+if (suffPath != NULL)
+	fullname = Dir_FindFile(file, suffPath);
+			}
+			if (fullname == NULL) {
+fullname = Dir_FindFile(file, parseIncPath);
+if (fullname == NULL)
+	fullname = Dir_FindFile(file,
+	);
+			}
+		}
+	}
+
+	/* Looking for a 

CVS commit: src/usr.bin/make

2022-03-25 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Fri Mar 25 21:16:04 UTC 2022

Modified Files:
src/usr.bin/make: make.1 parse.c

Log Message:
Include posix.mk when .POSIX: first encountered

Since .POSIX: is required to be the first non-comment line
in a Makefile, including ${MAKE_POSIX_MK} or whatever _PATH_POSIX_MK is
set to at this point is equivalent to an extension of sys.mk

This is a minimal change that can allow a better approximation of
POSIX compliance

Reviewed by: rillig


To generate a diff of this commit:
cvs rdiff -u -r1.305 -r1.306 src/usr.bin/make/make.1
cvs rdiff -u -r1.667 -r1.668 src/usr.bin/make/parse.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/time

2022-03-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Mar 25 19:34:04 UTC 2022

Modified Files:
src/lib/libc/time: localtime.c

Log Message:
localtime.c: fix theoretical syntax error

If NetBSD were built with -DHAVE_MALLOC_ERRNO=0, the previous code would
have resulted in a compile error due to the extra '}'.  Fix this by
copying the upstream code.

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.132 -r1.133 src/lib/libc/time/localtime.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/time

2022-03-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Mar 25 19:34:04 UTC 2022

Modified Files:
src/lib/libc/time: localtime.c

Log Message:
localtime.c: fix theoretical syntax error

If NetBSD were built with -DHAVE_MALLOC_ERRNO=0, the previous code would
have resulted in a compile error due to the extra '}'.  Fix this by
copying the upstream code.

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.132 -r1.133 src/lib/libc/time/localtime.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/time/localtime.c
diff -u src/lib/libc/time/localtime.c:1.132 src/lib/libc/time/localtime.c:1.133
--- src/lib/libc/time/localtime.c:1.132	Fri Mar 25 19:25:23 2022
+++ src/lib/libc/time/localtime.c	Fri Mar 25 19:34:04 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: localtime.c,v 1.132 2022/03/25 19:25:23 rillig Exp $	*/
+/*	$NetBSD: localtime.c,v 1.133 2022/03/25 19:34:04 rillig Exp $	*/
 
 /* Convert timestamp from time_t to struct tm.  */
 
@@ -12,7 +12,7 @@
 #if 0
 static char	elsieid[] = "@(#)localtime.c	8.17";
 #else
-__RCSID("$NetBSD: localtime.c,v 1.132 2022/03/25 19:25:23 rillig Exp $");
+__RCSID("$NetBSD: localtime.c,v 1.133 2022/03/25 19:34:04 rillig Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -1555,11 +1555,8 @@ tzalloc(char const *name)
   errno = err;
   return NULL;
 }
-  }
-#if !HAVE_MALLOC_ERRNO
-  } else
+  } else if (!HAVE_MALLOC_ERRNO)
 errno = ENOMEM;
-#endif
   return sp;
 }
 



CVS commit: src/lib/libc/time

2022-03-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Mar 25 19:25:23 UTC 2022

Modified Files:
src/lib/libc/time: localtime.c

Log Message:
localtime.c: reduce unnecessary diff to upstream

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 src/lib/libc/time/localtime.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/time/localtime.c
diff -u src/lib/libc/time/localtime.c:1.131 src/lib/libc/time/localtime.c:1.132
--- src/lib/libc/time/localtime.c:1.131	Fri Mar 25 19:00:15 2022
+++ src/lib/libc/time/localtime.c	Fri Mar 25 19:25:23 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: localtime.c,v 1.131 2022/03/25 19:00:15 rillig Exp $	*/
+/*	$NetBSD: localtime.c,v 1.132 2022/03/25 19:25:23 rillig Exp $	*/
 
 /* Convert timestamp from time_t to struct tm.  */
 
@@ -12,7 +12,7 @@
 #if 0
 static char	elsieid[] = "@(#)localtime.c	8.17";
 #else
-__RCSID("$NetBSD: localtime.c,v 1.131 2022/03/25 19:00:15 rillig Exp $");
+__RCSID("$NetBSD: localtime.c,v 1.132 2022/03/25 19:25:23 rillig Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -336,7 +336,7 @@ tzgetgmtoff(const timezone_t sp, int isd
 }
 
 static void
-update_tzname_etc(const struct state *sp, const struct ttinfo *ttisp)
+update_tzname_etc(struct state const *sp, struct ttinfo const *ttisp)
 {
 #if HAVE_TZNAME
   tzname[ttisp->tt_isdst] = __UNCONST(>chars[ttisp->tt_desigidx]);
@@ -348,7 +348,7 @@ update_tzname_etc(const struct state *sp
 #if ALTZONE
   if (ttisp->tt_isdst)
 altzone = - ttisp->tt_utoff;
-#endif /* ALTZONE */
+#endif
 }
 
 static void
@@ -488,7 +488,7 @@ tzloadbody(char const *name, struct stat
 		/* Set doaccess if NAME contains a ".." file name
 		   component, as such a name could read a file outside
 		   the TZDIR virtual subtree.  */
-		for (dot = name; (dot = strchr(dot, '.')) != NULL; dot++)
+		for (dot = name; (dot = strchr(dot, '.')); dot++)
 		  if ((dot == name || dot[-1] == '/') && dot[1] == '.'
 		  && (dot[2] == '/' || !dot[2])) {
 		doaccess = true;
@@ -1280,7 +1280,7 @@ tzparse(const char *name, struct state *
 			} while (atlo < janfirst
  && EPOCH_YEAR - YEARSPERREPEAT / 2 < yearbeg);
 
-			for (;;) {
+			while (true) {
 			  int_fast32_t yearsecs
 			= year_lengths[isleap(yearbeg)] * SECSPERDAY;
 			  int yearbeg1 = yearbeg;
@@ -1487,7 +1487,8 @@ tzsetlcl(char const *name)
 {
   struct state *sp = __lclptr;
   int lcl = name ? strlen(name) < sizeof lcl_TZname : -1;
-  if (lcl < 0 ? lcl_is_set < 0
+  if (lcl < 0
+  ? lcl_is_set < 0
   : 0 < lcl_is_set && strcmp(lcl_TZname, name) == 0)
 return;
 
@@ -1544,7 +1545,7 @@ gmtcheck(void)
 #if NETBSD_INSPIRED
 
 timezone_t
-tzalloc(const char *name)
+tzalloc(char const *name)
 {
   timezone_t sp = malloc(sizeof *sp);
   if (sp) {
@@ -1723,7 +1724,7 @@ localtime_r(const time_t * __restrict ti
 */
 
 static struct tm *
-gmtsub(struct state const *sp, const time_t *timep, int_fast32_t offset,
+gmtsub(struct state const *sp, time_t const *timep, int_fast32_t offset,
struct tm *tmp)
 {
 	register struct tm *	result;
@@ -1820,6 +1821,7 @@ time(time_t *p)
 ** Return the number of leap years through the end of the given year
 ** where, to make the math easy, the answer for year zero is defined as zero.
 */
+
 static time_t
 leaps_thru_end_of_nonneg(time_t y)
 {
@@ -1827,7 +1829,7 @@ leaps_thru_end_of_nonneg(time_t y)
 }
 
 static time_t
-leaps_thru_end_of(const time_t y)
+leaps_thru_end_of(time_t y)
 {
   return (y < 0
 	  ? -1 - leaps_thru_end_of_nonneg(-1 - y)
@@ -2091,7 +2093,7 @@ time2sub(struct tm *const tmp,
 	register time_t			lo;
 	register time_t			hi;
 #ifdef NO_ERROR_IN_DST_GAP
-	time_t			ilo;
+	time_tilo;
 #endif
 	int_fast32_t			y;
 	time_tnewt;
@@ -2495,12 +2497,19 @@ leapcorr(struct state const *sp, time_t 
 
 /* NETBSD_INSPIRED_EXTERN functions are exported to callers if
NETBSD_INSPIRED is defined, and are private otherwise.  */
-#if NETBSD_INSPIRED
-# define NETBSD_INSPIRED_EXTERN
-#else
-# define NETBSD_INSPIRED_EXTERN static
-#endif
+# if NETBSD_INSPIRED
+#  define NETBSD_INSPIRED_EXTERN
+# else
+#  define NETBSD_INSPIRED_EXTERN static
+# endif
 
+/*
+** IEEE Std 1003.1 (POSIX) says that 536457599
+** shall correspond to "Wed Dec 31 23:59:59 UTC 1986", which
+** is not the case if we are accounting for leap seconds.
+** So, we provide the following conversion routines for use
+** when exchanging timestamps with POSIX conforming systems.
+*/
 
 NETBSD_INSPIRED_EXTERN time_t
 time2posix_z(timezone_t sp, time_t t)
@@ -2526,14 +2535,6 @@ time2posix(time_t t)
 
 #ifdef STD_INSPIRED
 
-/*
-** IEEE Std 1003.1 (POSIX) says that 536457599
-** shall correspond to "Wed Dec 31 23:59:59 UTC 1986", which
-** is not the case if we are accounting for leap seconds.
-** So, we provide the following conversion routines for use
-** when exchanging timestamps with POSIX conforming systems.
-*/
-
 

CVS commit: src/lib/libc/time

2022-03-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Mar 25 19:25:23 UTC 2022

Modified Files:
src/lib/libc/time: localtime.c

Log Message:
localtime.c: reduce unnecessary diff to upstream

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 src/lib/libc/time/localtime.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/time

2022-03-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Mar 25 19:00:16 UTC 2022

Modified Files:
src/lib/libc/time: localtime.c

Log Message:
localtime.c: take indentation style from upstream

This reduces the diff to upstream.

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.131 src/lib/libc/time/localtime.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/time/localtime.c
diff -u src/lib/libc/time/localtime.c:1.130 src/lib/libc/time/localtime.c:1.131
--- src/lib/libc/time/localtime.c:1.130	Fri Mar 25 18:35:50 2022
+++ src/lib/libc/time/localtime.c	Fri Mar 25 19:00:15 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: localtime.c,v 1.130 2022/03/25 18:35:50 rillig Exp $	*/
+/*	$NetBSD: localtime.c,v 1.131 2022/03/25 19:00:15 rillig Exp $	*/
 
 /* Convert timestamp from time_t to struct tm.  */
 
@@ -12,7 +12,7 @@
 #if 0
 static char	elsieid[] = "@(#)localtime.c	8.17";
 #else
-__RCSID("$NetBSD: localtime.c,v 1.130 2022/03/25 18:35:50 rillig Exp $");
+__RCSID("$NetBSD: localtime.c,v 1.131 2022/03/25 19:00:15 rillig Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -238,11 +238,11 @@ long			altzone = 0;
 static void
 init_ttinfo(struct ttinfo *s, int_fast32_t utoff, bool isdst, int desigidx)
 {
-	s->tt_utoff = utoff;
-	s->tt_isdst = isdst;
-	s->tt_desigidx = desigidx;
-	s->tt_ttisstd = false;
-	s->tt_ttisut = false;
+  s->tt_utoff = utoff;
+  s->tt_isdst = isdst;
+  s->tt_desigidx = desigidx;
+  s->tt_ttisstd = false;
+  s->tt_ttisut = false;
 }
 
 /* Return true if SP's time type I does not specify local time.  */
@@ -271,10 +271,10 @@ detzcode(const char *const codep)
 	if (codep[0] & 0x80) {
 	  /* Do two's-complement negation even on non-two's-complement machines.
 	 If the result would be minval - 1, return minval.  */
-	result -= !TWOS_COMPLEMENT(int_fast32_t) && result != 0;
-	result += minval;
+	  result -= !TWOS_COMPLEMENT(int_fast32_t) && result != 0;
+	  result += minval;
 	}
- 	return result;
+	return result;
 }
 
 static int_fast64_t
@@ -297,7 +297,7 @@ detzcode64(const char *const codep)
 	  result -= !TWOS_COMPLEMENT(int_fast64_t) && result != 0;
 	  result += minval;
 	}
- 	return result;
+	return result;
 }
 
 #include 
@@ -339,15 +339,15 @@ static void
 update_tzname_etc(const struct state *sp, const struct ttinfo *ttisp)
 {
 #if HAVE_TZNAME
-	tzname[ttisp->tt_isdst] = __UNCONST(>chars[ttisp->tt_desigidx]);
+  tzname[ttisp->tt_isdst] = __UNCONST(>chars[ttisp->tt_desigidx]);
 #endif
 #if USG_COMPAT
-	if (!ttisp->tt_isdst)
-		timezone = - ttisp->tt_utoff;
+  if (!ttisp->tt_isdst)
+timezone = - ttisp->tt_utoff;
 #endif
 #if ALTZONE
-	if (ttisp->tt_isdst)
-	altzone = - ttisp->tt_utoff;
+  if (ttisp->tt_isdst)
+altzone = - ttisp->tt_utoff;
 #endif /* ALTZONE */
 }
 
@@ -414,12 +414,12 @@ scrub_abbrs(struct state *sp)
 
 /* Input buffer for data read from a compiled tz file.  */
 union input_buffer {
-	/* The first part of the buffer, interpreted as a header.  */
-	struct tzhead tzhead;
+  /* The first part of the buffer, interpreted as a header.  */
+  struct tzhead tzhead;
 
-	/* The entire buffer.  */
-	char buf[2 * sizeof(struct tzhead) + 2 * sizeof(struct state)
-	  + 4 * TZ_MAX_TIMES];
+  /* The entire buffer.  */
+  char buf[2 * sizeof(struct tzhead) + 2 * sizeof(struct state)
+	   + 4 * TZ_MAX_TIMES];
 };
 
 /* TZDIR with a trailing '/' rather than a trailing '\0'.  */
@@ -427,18 +427,18 @@ static char const tzdirslash[sizeof TZDI
 
 /* Local storage needed for 'tzloadbody'.  */
 union local_storage {
-	/* The results of analyzing the file's contents after it is opened.  */
-	struct file_analysis {
-		/* The input buffer.  */
-		union input_buffer u;
-
-		/* A temporary state used for parsing a TZ string in the file.  */
-		struct state st;
-	} u;
-
-	/* The file name to be opened.  */
-	char fullname[/*CONSTCOND*/BIGGEST(sizeof(struct file_analysis),
-	sizeof tzdirslash + 1024)];
+  /* The results of analyzing the file's contents after it is opened.  */
+  struct file_analysis {
+/* The input buffer.  */
+union input_buffer u;
+
+/* A temporary state used for parsing a TZ string in the file.  */
+struct state st;
+  } u;
+
+  /* The file name to be opened.  */
+  char fullname[/*CONSTCOND*/BIGGEST(sizeof(struct file_analysis),
+			sizeof tzdirslash + 1024)];
 };
 
 /* Load tz data from the file named NAME into *SP.  Read extended
@@ -446,7 +446,7 @@ union local_storage {
success, an errno value on failure.  */
 static int
 tzloadbody(char const *name, struct state *sp, bool doextend,
-  union local_storage *lsp)
+	   union local_storage *lsp)
 {
 	register int			i;
 	register int			fid;
@@ -461,7 +461,7 @@ tzloadbody(char const *name, struct stat
 	if (! name) {
 		name = TZDEFAULT;
 		if (! name)
-			return EINVAL;
+		  return EINVAL;
 	}
 
 	if (name[0] == ':')
@@ -477,7 +477,7 @@ tzloadbody(char 

CVS commit: src/lib/libc/time

2022-03-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Mar 25 19:00:16 UTC 2022

Modified Files:
src/lib/libc/time: localtime.c

Log Message:
localtime.c: take indentation style from upstream

This reduces the diff to upstream.

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.131 src/lib/libc/time/localtime.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/time

2022-03-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Mar 25 18:35:50 UTC 2022

Modified Files:
src/lib/libc/time: localtime.c

Log Message:
localtime.c: add back storage class 'register'

This reduces the differences to the upstream code.

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/lib/libc/time/localtime.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/time/localtime.c
diff -u src/lib/libc/time/localtime.c:1.129 src/lib/libc/time/localtime.c:1.130
--- src/lib/libc/time/localtime.c:1.129	Thu Mar 24 16:15:05 2022
+++ src/lib/libc/time/localtime.c	Fri Mar 25 18:35:50 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: localtime.c,v 1.129 2022/03/24 16:15:05 christos Exp $	*/
+/*	$NetBSD: localtime.c,v 1.130 2022/03/25 18:35:50 rillig Exp $	*/
 
 /* Convert timestamp from time_t to struct tm.  */
 
@@ -12,7 +12,7 @@
 #if 0
 static char	elsieid[] = "@(#)localtime.c	8.17";
 #else
-__RCSID("$NetBSD: localtime.c,v 1.129 2022/03/24 16:15:05 christos Exp $");
+__RCSID("$NetBSD: localtime.c,v 1.130 2022/03/25 18:35:50 rillig Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -257,8 +257,8 @@ ttunspecified(struct state const *sp, in
 static int_fast32_t
 detzcode(const char *const codep)
 {
-	int_fast32_t result;
-	int	i;
+	register int_fast32_t	result;
+	register int		i;
 	int_fast32_t one = 1;
 	int_fast32_t halfmaxval = one << (32 - 2);
 	int_fast32_t maxval = halfmaxval - 1 + halfmaxval;
@@ -280,8 +280,8 @@ detzcode(const char *const codep)
 static int_fast64_t
 detzcode64(const char *const codep)
 {
-	int_fast64_t result;
-	int	i;
+	register int_fast64_t result;
+	register int	i;
 	int_fast64_t one = 1;
 	int_fast64_t halfmaxval = one << (64 - 2);
 	int_fast64_t maxval = halfmaxval - 1 + halfmaxval;
@@ -354,8 +354,8 @@ update_tzname_etc(const struct state *sp
 static void
 settzname(void)
 {
-	timezone_t const	sp = __lclptr;
-	int			i;
+	register timezone_t const	sp = __lclptr;
+	register int			i;
 
 #if HAVE_TZNAME
 	tzname[0] = tzname[1] =
@@ -378,7 +378,9 @@ settzname(void)
 		update_tzname_etc(sp, >ttis[i]);
 
 	for (i = 0; i < sp->timecnt; ++i) {
-		const struct ttinfo * const ttisp = >ttis[sp->types[i]];
+		register const struct ttinfo * const	ttisp =
+			>ttis[
+sp->types[i]];
 		update_tzname_etc(sp, ttisp);
 #if USG_COMPAT
 		if (ttisp->tt_isdst)
@@ -401,7 +403,7 @@ scrub_abbrs(struct state *sp)
 	** Second, truncate long abbreviations.
 	*/
 	for (i = 0; i < sp->typecnt; ++i) {
-		const struct ttinfo * const	ttisp = >ttis[i];
+		register const struct ttinfo * const	ttisp = >ttis[i];
 		char *cp = >chars[ttisp->tt_desigidx];
 
 		if (strlen(cp) > TZ_ABBR_MAX_LEN &&
@@ -446,13 +448,13 @@ static int
 tzloadbody(char const *name, struct state *sp, bool doextend,
   union local_storage *lsp)
 {
-	int			i;
-	int			fid;
-	int			stored;
-	ssize_t			nread;
-	bool			doaccess;
-	union input_buffer	*up = >u.u;
-	size_t			tzheadsize = sizeof(struct tzhead);
+	register int			i;
+	register int			fid;
+	register int			stored;
+	register ssize_t		nread;
+	register bool doaccess;
+	register union input_buffer *up = >u.u;
+	register size_t tzheadsize = sizeof(struct tzhead);
 
 	sp->goback = sp->goahead = false;
 
@@ -588,7 +590,7 @@ tzloadbody(char const *name, struct stat
 		}
 		sp->timecnt = timecnt;
 		for (i = 0; i < sp->typecnt; ++i) {
-			struct ttinfo *	ttisp;
+			register struct ttinfo *	ttisp;
 			unsigned char isdst, desigidx;
 
 			ttisp = >ttis[i];
@@ -645,7 +647,7 @@ tzloadbody(char const *name, struct stat
 		sp->leapcnt = leapcnt;
 
 		for (i = 0; i < sp->typecnt; ++i) {
-			struct ttinfo *	ttisp;
+			register struct ttinfo *	ttisp;
 
 			ttisp = >ttis[i];
 			if (ttisstdcnt == 0)
@@ -657,7 +659,7 @@ tzloadbody(char const *name, struct stat
 			}
 		}
 		for (i = 0; i < sp->typecnt; ++i) {
-			struct ttinfo *	ttisp;
+			register struct ttinfo *	ttisp;
 
 			ttisp = >ttis[i];
 			if (ttisutcnt == 0)
@@ -841,15 +843,15 @@ tzload(char const *name, struct state *s
 static bool
 typesequiv(const struct state *sp, int a, int b)
 {
-	bool result;
+	register bool result;
 
 	if (sp == NULL ||
 		a < 0 || a >= sp->typecnt ||
 		b < 0 || b >= sp->typecnt)
 			result = false;
 	else {
-		const struct ttinfo *	ap = >ttis[a];
-		const struct ttinfo *	bp = >ttis[b];
+		register const struct ttinfo *	ap = >ttis[a];
+		register const struct ttinfo *	bp = >ttis[b];
 		result = (ap->tt_utoff == bp->tt_utoff
 			  && ap->tt_isdst == bp->tt_isdst
 			  && ap->tt_ttisstd == bp->tt_ttisstd
@@ -884,9 +886,9 @@ is_digit(char c)
 */
 
 static ATTRIBUTE_PURE const char *
-getzname(const char *strp)
+getzname(register const char *strp)
 {
-	char	c;
+	register char	c;
 
 	while ((c = *strp) != '\0' && !is_digit(c) && c != ',' && c != '-' &&
 		c != '+')
@@ -905,9 +907,9 @@ getzname(const char *strp)
 */
 
 static ATTRIBUTE_PURE const char *
-getqzname(const char 

CVS commit: src/lib/libc/time

2022-03-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Mar 25 18:35:50 UTC 2022

Modified Files:
src/lib/libc/time: localtime.c

Log Message:
localtime.c: add back storage class 'register'

This reduces the differences to the upstream code.

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/lib/libc/time/localtime.c

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



Re: CVS commit: src/lib/libc/time

2022-03-25 Thread Roland Illig

Am 25.03.2022 um 13:59 schrieb Robert Elz:

 Date:Thu, 24 Mar 2022 23:32:30 +0100
 From:Roland Illig 
 Message-ID:  <6bb00924-edaf-a4c8-348e-ba1304d57...@gmx.de>

   | Someone should clean up this mess.

No, they probabky shouldn't, in general.

That source comes from the tz project (currently from
tzcode2022a) with local modifications.


When I said "somebody" above, I really meant "somebody at the
appropriate position".  I already suspected that this would not be
NetBSD.  Sorry for the brevity.


I think upstream mostly uses ts=4 (or more likely
the emacs equivalent).   we mostky use tab, and view
with ts=8 and yes, that can mead to ugly results.


The mess with the indentation comes from upstream.  In our copy it's a
bit worth than upstream, but not much.

Roland


Re: CVS commit: src/lib/libc/time

2022-03-25 Thread Robert Elz
Date:Thu, 24 Mar 2022 23:32:30 +0100
From:Roland Illig 
Message-ID:  <6bb00924-edaf-a4c8-348e-ba1304d57...@gmx.de>

  | Someone should clean up this mess.

No, they probabky shouldn't, in general.

That source comes from the tz project (currently from
tzcode2022a) with local modifications.

I think upstream mostly uses ts=4 (or more likely
the emacs equivalent).   we mostky use tab, and view
with ts=8 and yes, that can mead to ugly results.

But to ease merging of future versions, this should be
touched as little as possible.

kre

ps: one way and another we have plenty of localtime
testing, not all in tests/libc.  At least for general
correctness.  I don't know if all the various hard casez
are as well tested locally, but changes that would
affect thise generally come from upstream.   Lots of
people do lots of tests on the upstream code.


CVS commit: src/sys/dev/ic

2022-03-25 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Fri Mar 25 12:24:44 UTC 2022

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

Log Message:
pcdisplay_getwschar: on error return error code, not -1.

This value ends up being returned from vga_ioctl to sys_ioctl which
expects an errno and spams kernel log otherwise.

Ditto for pcdisplay_putwschar.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/dev/ic/pcdisplay_subr.c

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

Modified files:

Index: src/sys/dev/ic/pcdisplay_subr.c
diff -u src/sys/dev/ic/pcdisplay_subr.c:1.35 src/sys/dev/ic/pcdisplay_subr.c:1.36
--- src/sys/dev/ic/pcdisplay_subr.c:1.35	Tue Oct 19 22:27:19 2010
+++ src/sys/dev/ic/pcdisplay_subr.c	Fri Mar 25 12:24:44 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: pcdisplay_subr.c,v 1.35 2010/10/19 22:27:19 jmcneill Exp $ */
+/* $NetBSD: pcdisplay_subr.c,v 1.36 2022/03/25 12:24:44 uwe Exp $ */
 
 /*
  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcdisplay_subr.c,v 1.35 2010/10/19 22:27:19 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcdisplay_subr.c,v 1.36 2022/03/25 12:24:44 uwe Exp $");
 
 #include "opt_wsmsgattrs.h" /* for WSDISPLAY_CUSTOM_OUTPUT */
 
@@ -306,7 +306,7 @@ pcdisplay_getwschar(struct pcdisplayscre
 
 	off = wschar->row * scr->type->ncols + wschar->col;
 	if (off >= scr->type->ncols * scr->type->nrows)
-		return -1;
+		return EINVAL;
 
 	if (scr->active)
 		chardata = bus_space_read_2(scr->hdl->ph_memt,
@@ -336,7 +336,7 @@ pcdisplay_putwschar(struct pcdisplayscre
 
 	off = wschar->row * scr->type->ncols + wschar->col;
 	if (off >= (scr->type->ncols * scr->type->nrows))
-		return -1;
+		return EINVAL;
 
 	attrbyte = wschar->background & 0x07;
 	if (wschar->flags & WSDISPLAY_CHAR_BLINK) attrbyte |= 0x08;



CVS commit: src/sys/dev/ic

2022-03-25 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Fri Mar 25 12:24:44 UTC 2022

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

Log Message:
pcdisplay_getwschar: on error return error code, not -1.

This value ends up being returned from vga_ioctl to sys_ioctl which
expects an errno and spams kernel log otherwise.

Ditto for pcdisplay_putwschar.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/dev/ic/pcdisplay_subr.c

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



CVS commit: src/sys/net

2022-03-25 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Mar 25 08:57:51 UTC 2022

Modified Files:
src/sys/net: if_wg.c

Log Message:
Prevent memory corruption from wg_send_handshake_msg_init() on
LP64 machines with "MSIZE == 256", sparc64 for example.

wg_send_handshake_msg_init() tries to put 148 bytes into a buffer
of 144 bytes and overwrites 4 bytes following the mbuf.  Check
for "sizeof() > MHLEN" and use a cluster in this case.

With help from Taylor R Campbell 


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/sys/net/if_wg.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/net/if_wg.c
diff -u src/sys/net/if_wg.c:1.68 src/sys/net/if_wg.c:1.69
--- src/sys/net/if_wg.c:1.68	Sun Jan 16 20:43:20 2022
+++ src/sys/net/if_wg.c	Fri Mar 25 08:57:50 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wg.c,v 1.68 2022/01/16 20:43:20 riastradh Exp $	*/
+/*	$NetBSD: if_wg.c,v 1.69 2022/03/25 08:57:50 hannken Exp $	*/
 
 /*
  * Copyright (C) Ryota Ozaki 
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.68 2022/01/16 20:43:20 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.69 2022/03/25 08:57:50 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_altq_enabled.h"
@@ -1707,6 +1707,10 @@ wg_send_handshake_msg_init(struct wg_sof
 	wgs->wgs_state = WGS_STATE_INIT_ACTIVE;
 
 	m = m_gethdr(M_WAIT, MT_DATA);
+	if (sizeof(*wgmi) > MHLEN) {
+		m_clget(m, M_WAIT);
+		CTASSERT(sizeof(*wgmi) <= MCLBYTES);
+	}
 	m->m_pkthdr.len = m->m_len = sizeof(*wgmi);
 	wgmi = mtod(m, struct wg_msg_init *);
 	wg_fill_msg_init(wg, wgp, wgs, wgmi);
@@ -2056,6 +2060,10 @@ wg_send_handshake_msg_resp(struct wg_sof
 	KASSERT(wgs->wgs_state == WGS_STATE_INIT_PASSIVE);
 
 	m = m_gethdr(M_WAIT, MT_DATA);
+	if (sizeof(*wgmr) > MHLEN) {
+		m_clget(m, M_WAIT);
+		CTASSERT(sizeof(*wgmr) <= MCLBYTES);
+	}
 	m->m_pkthdr.len = m->m_len = sizeof(*wgmr);
 	wgmr = mtod(m, struct wg_msg_resp *);
 	wg_fill_msg_resp(wg, wgp, wgs, wgmr, wgmi);
@@ -2154,6 +2162,10 @@ wg_send_cookie_msg(struct wg_softc *wg, 
 	KASSERT(mutex_owned(wgp->wgp_lock));
 
 	m = m_gethdr(M_WAIT, MT_DATA);
+	if (sizeof(*wgmc) > MHLEN) {
+		m_clget(m, M_WAIT);
+		CTASSERT(sizeof(*wgmc) <= MCLBYTES);
+	}
 	m->m_pkthdr.len = m->m_len = sizeof(*wgmc);
 	wgmc = mtod(m, struct wg_msg_cookie *);
 	wg_fill_msg_cookie(wg, wgp, wgmc, sender, mac1, src);



CVS commit: src/sys/net

2022-03-25 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Mar 25 08:57:51 UTC 2022

Modified Files:
src/sys/net: if_wg.c

Log Message:
Prevent memory corruption from wg_send_handshake_msg_init() on
LP64 machines with "MSIZE == 256", sparc64 for example.

wg_send_handshake_msg_init() tries to put 148 bytes into a buffer
of 144 bytes and overwrites 4 bytes following the mbuf.  Check
for "sizeof() > MHLEN" and use a cluster in this case.

With help from Taylor R Campbell 


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/sys/net/if_wg.c

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



CVS commit: src/sys/kern

2022-03-25 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Mar 25 08:57:15 UTC 2022

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

Log Message:
It is impossible for VOP_LOCK() to return ENOENT with LK_RETRY flag.
Remove the second call to VOP_LOCK().

Enable assertion "vrefcnt(vp) > 0" and assert all possible errors
for all LK_RETRY/LK_NOWAIT combinations.


To generate a diff of this commit:
cvs rdiff -u -r1.226 -r1.227 src/sys/kern/vfs_vnops.c

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

Modified files:

Index: src/sys/kern/vfs_vnops.c
diff -u src/sys/kern/vfs_vnops.c:1.226 src/sys/kern/vfs_vnops.c:1.227
--- src/sys/kern/vfs_vnops.c:1.226	Sat Mar 19 13:50:02 2022
+++ src/sys/kern/vfs_vnops.c	Fri Mar 25 08:57:15 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_vnops.c,v 1.226 2022/03/19 13:50:02 hannken Exp $	*/
+/*	$NetBSD: vfs_vnops.c,v 1.227 2022/03/25 08:57:15 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.226 2022/03/19 13:50:02 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.227 2022/03/25 08:57:15 hannken Exp $");
 
 #include "veriexec.h"
 
@@ -1192,9 +1192,7 @@ vn_lock(struct vnode *vp, int flags)
 	struct lwp *l;
 	int error;
 
-#if 0
-	KASSERT(vrefcnt(vp) > 0 || (vp->v_iflag & VI_ONWORKLST) != 0);
-#endif
+	KASSERT(vrefcnt(vp) > 0);
 	KASSERT((flags & ~(LK_SHARED|LK_EXCLUSIVE|LK_NOWAIT|LK_RETRY|
 	LK_UPGRADE|LK_DOWNGRADE)) == 0);
 	KASSERT((flags & LK_NOWAIT) != 0 || !mutex_owned(vp->v_interlock));
@@ -1210,13 +1208,23 @@ vn_lock(struct vnode *vp, int flags)
 	l->l_rwcallsite = (uintptr_t)__builtin_return_address(0);	
 
 	error = VOP_LOCK(vp, flags);
-	if ((flags & LK_RETRY) != 0 && error == ENOENT)
-		error = VOP_LOCK(vp, flags);
 
 	l->l_rwcallsite = 0;
 
-	KASSERT((flags & LK_RETRY) == 0 || (flags & LK_NOWAIT) != 0 ||
-	error == 0);
+	switch (flags & (LK_RETRY | LK_NOWAIT)) {
+	case 0:
+		KASSERT(error == 0 || error == ENOENT);
+		break;
+	case LK_RETRY:
+		KASSERT(error == 0);
+		break;
+	case LK_NOWAIT:
+		KASSERT(error == 0 || error == EBUSY || error == ENOENT);
+		break;
+	case LK_RETRY | LK_NOWAIT:
+		KASSERT(error == 0 || error == EBUSY);
+		break;
+	}
 
 	return error;
 }



CVS commit: src/sys/kern

2022-03-25 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Mar 25 08:57:15 UTC 2022

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

Log Message:
It is impossible for VOP_LOCK() to return ENOENT with LK_RETRY flag.
Remove the second call to VOP_LOCK().

Enable assertion "vrefcnt(vp) > 0" and assert all possible errors
for all LK_RETRY/LK_NOWAIT combinations.


To generate a diff of this commit:
cvs rdiff -u -r1.226 -r1.227 src/sys/kern/vfs_vnops.c

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



CVS commit: src/sys/sys

2022-03-25 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Mar 25 08:56:36 UTC 2022

Modified Files:
src/sys/sys: vnode.h

Log Message:
As VV_LOCKSWORK is gone remove LOCKSWORK from VNODE_FLAGBITS string.
Also convert illegal octal number 18 to 20.


To generate a diff of this commit:
cvs rdiff -u -r1.300 -r1.301 src/sys/sys/vnode.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/sys/vnode.h
diff -u src/sys/sys/vnode.h:1.300 src/sys/sys/vnode.h:1.301
--- src/sys/sys/vnode.h:1.300	Sat Mar 19 13:53:32 2022
+++ src/sys/sys/vnode.h	Fri Mar 25 08:56:36 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vnode.h,v 1.300 2022/03/19 13:53:32 hannken Exp $	*/
+/*	$NetBSD: vnode.h,v 1.301 2022/03/25 08:56:36 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2020 The NetBSD Foundation, Inc.
@@ -221,8 +221,8 @@ typedef struct vnode vnode_t;
 #define	VU_DIROP	0x0100	/* LFS: involved in a directory op */
 
 #define	VNODE_FLAGBITS \
-"\20\1ROOT\2SYSTEM\3ISTTY\4MAPPED\5MPSAFE\6LOCKSWORK\11TEXT\12EXECMAP" \
-"\13WRMAP\14PAGES\17ONWORKLST\18DEADCHECK\31DIROP"
+"\20\1ROOT\2SYSTEM\3ISTTY\4MAPPED\5MPSAFE\11TEXT\12EXECMAP" \
+"\13WRMAP\14PAGES\17ONWORKLST\20DEADCHECK\31DIROP"
 
 #define	VSIZENOTSET	((voff_t)-1)
 



CVS commit: src/sys/sys

2022-03-25 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Mar 25 08:56:36 UTC 2022

Modified Files:
src/sys/sys: vnode.h

Log Message:
As VV_LOCKSWORK is gone remove LOCKSWORK from VNODE_FLAGBITS string.
Also convert illegal octal number 18 to 20.


To generate a diff of this commit:
cvs rdiff -u -r1.300 -r1.301 src/sys/sys/vnode.h

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