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

2023-12-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec 17 00:19:11 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-match.exp varmod-match.mk

Log Message:
tests/make: add basic tests for the ':M' modifier


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/varmod-match.exp
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/make/unit-tests/varmod-match.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/varmod-match.exp
diff -u src/usr.bin/make/unit-tests/varmod-match.exp:1.12 src/usr.bin/make/unit-tests/varmod-match.exp:1.13
--- src/usr.bin/make/unit-tests/varmod-match.exp:1.12	Sat Dec 16 23:40:33 2023
+++ src/usr.bin/make/unit-tests/varmod-match.exp	Sun Dec 17 00:19:11 2023
@@ -1,14 +1,14 @@
-make: "varmod-match.mk" line 238: warning: Unfinished character list in pattern 'a[' of modifier ':M'
-make: "varmod-match.mk" line 246: warning: Unfinished character list in pattern 'a[^' of modifier ':M'
-make: "varmod-match.mk" line 254: warning: Unfinished character list in pattern '[-x1-3' of modifier ':M'
-make: "varmod-match.mk" line 262: warning: Unfinished character list in pattern '*[-x1-3' of modifier ':M'
-make: "varmod-match.mk" line 271: warning: Unfinished character list in pattern '[^-x1-3' of modifier ':M'
-make: "varmod-match.mk" line 285: warning: Unfinished character list in pattern '?[\' of modifier ':M'
-make: "varmod-match.mk" line 293: warning: Unfinished character range in pattern '[x-' of modifier ':M'
-make: "varmod-match.mk" line 305: warning: Unfinished character range in pattern '[^x-' of modifier ':M'
-make: "varmod-match.mk" line 313: warning: Unfinished character list in pattern '[' of modifier ':M'
-make: "varmod-match.mk" line 313: Unknown modifier "]"
-make: "varmod-match.mk" line 313: Malformed conditional (${ ${:U\:} ${:U\:\:} :L:M[:]} != ":")
+make: "varmod-match.mk" line 268: warning: Unfinished character list in pattern 'a[' of modifier ':M'
+make: "varmod-match.mk" line 276: warning: Unfinished character list in pattern 'a[^' of modifier ':M'
+make: "varmod-match.mk" line 284: warning: Unfinished character list in pattern '[-x1-3' of modifier ':M'
+make: "varmod-match.mk" line 292: warning: Unfinished character list in pattern '*[-x1-3' of modifier ':M'
+make: "varmod-match.mk" line 301: warning: Unfinished character list in pattern '[^-x1-3' of modifier ':M'
+make: "varmod-match.mk" line 315: warning: Unfinished character list in pattern '?[\' of modifier ':M'
+make: "varmod-match.mk" line 323: warning: Unfinished character range in pattern '[x-' of modifier ':M'
+make: "varmod-match.mk" line 335: warning: Unfinished character range in pattern '[^x-' of modifier ':M'
+make: "varmod-match.mk" line 343: warning: Unfinished character list in pattern '[' of modifier ':M'
+make: "varmod-match.mk" line 343: Unknown modifier "]"
+make: "varmod-match.mk" line 343: Malformed conditional (${ ${:U\:} ${:U\:\:} :L:M[:]} != ":")
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/varmod-match.mk
diff -u src/usr.bin/make/unit-tests/varmod-match.mk:1.18 src/usr.bin/make/unit-tests/varmod-match.mk:1.19
--- src/usr.bin/make/unit-tests/varmod-match.mk:1.18	Sat Dec 16 23:38:35 2023
+++ src/usr.bin/make/unit-tests/varmod-match.mk	Sun Dec 17 00:19:11 2023
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-match.mk,v 1.18 2023/12/16 23:38:35 rillig Exp $
+# $NetBSD: varmod-match.mk,v 1.19 2023/12/17 00:19:11 rillig Exp $
 #
 # Tests for the ':M' modifier, which keeps only those words that match the
 # given pattern.
@@ -12,8 +12,10 @@
 # 5. Performance
 # 6. Error handling
 # 7. Historical bugs
+#
+# See ApplyModifier_Match, ParseModifier_Match, ModifyWord_Match and
+# Str_Match.
 
-NUMBERS=	One Two Three Four five six seven
 
 # 1. Pattern characters '*', '?' and '\'
 #
@@ -21,7 +23,35 @@ NUMBERS=	One Two Three Four five six sev
 #	?	matches 1 character
 #	\x	matches the character 'x'
 
-# TODO
+# The pattern is anchored both at the beginning and at the end of the word.
+# Since the pattern 'e' does not contain any pattern matching characters, it
+# matches exactly the word 'e', twice.
+.if ${a c e aa cc ee e f g:L:Me} != "e e"
+.  error
+.endif
+
+# The pattern character '?' matches exactly 1 character, the pattern character
+# '*' matches 0 or more characters.  The whole pattern matches all words that
+# start with 's' and have 3 or more characters.
+.if ${One Two Three Four five six seven:L:Ms??*} != "six seven"
+.  error
+.endif
+
+# Ensure that a pattern without placeholders only matches itself.
+.if ${a aa aaa b ba baa bab:L:Ma} != "a"
+.  error
+.endif
+
+# Ensure that a pattern that ends with '*' is properly anchored at the
+# beginning.
+.if ${a aa aaa b ba baa bab:L:Ma*} != "a aa aaa"
+.  error
+.endif
+
+# Ensure that a pattern that starts with 

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

2023-12-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec 17 00:19:11 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-match.exp varmod-match.mk

Log Message:
tests/make: add basic tests for the ':M' modifier


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/varmod-match.exp
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/make/unit-tests/varmod-match.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

2023-12-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Dec 16 23:40:33 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-match.exp

Log Message:
tests/make: fix line numbers in expected test output for ':M'


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/varmod-match.exp

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/varmod-match.exp
diff -u src/usr.bin/make/unit-tests/varmod-match.exp:1.11 src/usr.bin/make/unit-tests/varmod-match.exp:1.12
--- src/usr.bin/make/unit-tests/varmod-match.exp:1.11	Sat Dec 16 23:38:35 2023
+++ src/usr.bin/make/unit-tests/varmod-match.exp	Sat Dec 16 23:40:33 2023
@@ -1,14 +1,14 @@
-make: "varmod-match.mk" line 236: warning: Unfinished character list in pattern 'a[' of modifier ':M'
-make: "varmod-match.mk" line 244: warning: Unfinished character list in pattern 'a[^' of modifier ':M'
-make: "varmod-match.mk" line 252: warning: Unfinished character list in pattern '[-x1-3' of modifier ':M'
-make: "varmod-match.mk" line 260: warning: Unfinished character list in pattern '*[-x1-3' of modifier ':M'
-make: "varmod-match.mk" line 269: warning: Unfinished character list in pattern '[^-x1-3' of modifier ':M'
-make: "varmod-match.mk" line 283: warning: Unfinished character list in pattern '?[\' of modifier ':M'
-make: "varmod-match.mk" line 291: warning: Unfinished character range in pattern '[x-' of modifier ':M'
-make: "varmod-match.mk" line 303: warning: Unfinished character range in pattern '[^x-' of modifier ':M'
-make: "varmod-match.mk" line 311: warning: Unfinished character list in pattern '[' of modifier ':M'
-make: "varmod-match.mk" line 311: Unknown modifier "]"
-make: "varmod-match.mk" line 311: Malformed conditional (${ ${:U\:} ${:U\:\:} :L:M[:]} != ":")
+make: "varmod-match.mk" line 238: warning: Unfinished character list in pattern 'a[' of modifier ':M'
+make: "varmod-match.mk" line 246: warning: Unfinished character list in pattern 'a[^' of modifier ':M'
+make: "varmod-match.mk" line 254: warning: Unfinished character list in pattern '[-x1-3' of modifier ':M'
+make: "varmod-match.mk" line 262: warning: Unfinished character list in pattern '*[-x1-3' of modifier ':M'
+make: "varmod-match.mk" line 271: warning: Unfinished character list in pattern '[^-x1-3' of modifier ':M'
+make: "varmod-match.mk" line 285: warning: Unfinished character list in pattern '?[\' of modifier ':M'
+make: "varmod-match.mk" line 293: warning: Unfinished character range in pattern '[x-' of modifier ':M'
+make: "varmod-match.mk" line 305: warning: Unfinished character range in pattern '[^x-' of modifier ':M'
+make: "varmod-match.mk" line 313: warning: Unfinished character list in pattern '[' of modifier ':M'
+make: "varmod-match.mk" line 313: Unknown modifier "]"
+make: "varmod-match.mk" line 313: Malformed conditional (${ ${:U\:} ${:U\:\:} :L:M[:]} != ":")
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1



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

2023-12-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Dec 16 23:40:33 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-match.exp

Log Message:
tests/make: fix line numbers in expected test output for ':M'


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/varmod-match.exp

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

2023-12-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Dec 16 23:38:35 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-match.exp varmod-match.mk

Log Message:
tests/make: reorganize tests for the ':M' modifier

Add a table of contents.  Group the existing tests into sections.  Fix
the pattern of the test for the malformed ':M[\' modifier, now in line
283.

Note that the tests for the pattern characters '*?\' are missing.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/varmod-match.exp
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/varmod-match.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

2023-12-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Dec 16 23:38:35 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-match.exp varmod-match.mk

Log Message:
tests/make: reorganize tests for the ':M' modifier

Add a table of contents.  Group the existing tests into sections.  Fix
the pattern of the test for the malformed ':M[\' modifier, now in line
283.

Note that the tests for the pattern characters '*?\' are missing.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/varmod-match.exp
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/varmod-match.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/varmod-match.exp
diff -u src/usr.bin/make/unit-tests/varmod-match.exp:1.10 src/usr.bin/make/unit-tests/varmod-match.exp:1.11
--- src/usr.bin/make/unit-tests/varmod-match.exp:1.10	Fri Jun 23 04:56:54 2023
+++ src/usr.bin/make/unit-tests/varmod-match.exp	Sat Dec 16 23:38:35 2023
@@ -1,25 +1,14 @@
-CondParser_Eval: ${NUMBERS:M[A-Z]*} != "One Two Three Four"
-Comparing "One Two Three Four" != "One Two Three Four"
-CondParser_Eval: ${NUMBERS:M[^A-Z]*} != "five six seven"
-Comparing "five six seven" != "five six seven"
-CondParser_Eval: ${NUMBERS:M[^s]*[ex]} != "One Three five"
-Comparing "One Three five" != "One Three five"
-CondParser_Eval: ${:U:Mb}
-CondParser_Eval: ${:U..b:M*?*?*?*?*?a}
-CondParser_Eval: ${:Ua \$ sign:M*$$*} != "\$"
-Comparing "$" != "$"
-CondParser_Eval: ${:Ua \$ sign any-asterisk:M*\$*} != "any-asterisk"
-Comparing "any-asterisk" != "any-asterisk"
-make: "varmod-match.mk" line 162: warning: Unfinished character list in pattern '[' of modifier ':M'
-make: "varmod-match.mk" line 162: Unknown modifier "]"
-make: "varmod-match.mk" line 162: Malformed conditional (${ ${:U\:} ${:U\:\:} :L:M[:]} != ":")
-make: "varmod-match.mk" line 205: warning: Unfinished character list in pattern 'a[' of modifier ':M'
-make: "varmod-match.mk" line 213: warning: Unfinished character list in pattern 'a[^' of modifier ':M'
-make: "varmod-match.mk" line 221: warning: Unfinished character list in pattern '[-x1-3' of modifier ':M'
-make: "varmod-match.mk" line 229: warning: Unfinished character list in pattern '*[-x1-3' of modifier ':M'
-make: "varmod-match.mk" line 238: warning: Unfinished character list in pattern '[^-x1-3' of modifier ':M'
-make: "varmod-match.mk" line 258: warning: Unfinished character range in pattern '[x-' of modifier ':M'
-make: "varmod-match.mk" line 270: warning: Unfinished character range in pattern '[^x-' of modifier ':M'
+make: "varmod-match.mk" line 236: warning: Unfinished character list in pattern 'a[' of modifier ':M'
+make: "varmod-match.mk" line 244: warning: Unfinished character list in pattern 'a[^' of modifier ':M'
+make: "varmod-match.mk" line 252: warning: Unfinished character list in pattern '[-x1-3' of modifier ':M'
+make: "varmod-match.mk" line 260: warning: Unfinished character list in pattern '*[-x1-3' of modifier ':M'
+make: "varmod-match.mk" line 269: warning: Unfinished character list in pattern '[^-x1-3' of modifier ':M'
+make: "varmod-match.mk" line 283: warning: Unfinished character list in pattern '?[\' of modifier ':M'
+make: "varmod-match.mk" line 291: warning: Unfinished character range in pattern '[x-' of modifier ':M'
+make: "varmod-match.mk" line 303: warning: Unfinished character range in pattern '[^x-' of modifier ':M'
+make: "varmod-match.mk" line 311: warning: Unfinished character list in pattern '[' of modifier ':M'
+make: "varmod-match.mk" line 311: Unknown modifier "]"
+make: "varmod-match.mk" line 311: Malformed conditional (${ ${:U\:} ${:U\:\:} :L:M[:]} != ":")
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/varmod-match.mk
diff -u src/usr.bin/make/unit-tests/varmod-match.mk:1.17 src/usr.bin/make/unit-tests/varmod-match.mk:1.18
--- src/usr.bin/make/unit-tests/varmod-match.mk:1.17	Sun Nov 19 21:47:52 2023
+++ src/usr.bin/make/unit-tests/varmod-match.mk	Sat Dec 16 23:38:35 2023
@@ -1,97 +1,46 @@
-# $NetBSD: varmod-match.mk,v 1.17 2023/11/19 21:47:52 rillig Exp $
+# $NetBSD: varmod-match.mk,v 1.18 2023/12/16 23:38:35 rillig Exp $
 #
-# Tests for the :M variable modifier, which filters words that match the
+# Tests for the ':M' modifier, which keeps only those words that match the
 # given pattern.
 #
-# See ApplyModifier_Match, ParseModifier_Match and ModifyWord_Match.
-
-.MAKEFLAGS: -dc
+# Table of contents
+#
+# 1. Pattern characters '*', '?' and '\'
+# 2. Character lists and character ranges
+# 3. Parsing and escaping
+# 4. Interaction with other modifiers
+# 5. Performance
+# 6. Error handling
+# 7. Historical bugs
 
 NUMBERS=	One Two Three Four five six seven
 
-# Only keep words that start with an 

CVS commit: src/usr.bin/make

2023-12-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Dec 16 21:26:07 UTC 2023

Modified Files:
src/usr.bin/make: str.c

Log Message:
make: eliminate a local variable in Str_Match

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/usr.bin/make/str.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/str.c
diff -u src/usr.bin/make/str.c:1.99 src/usr.bin/make/str.c:1.100
--- src/usr.bin/make/str.c:1.99	Fri Jun 23 05:03:04 2023
+++ src/usr.bin/make/str.c	Sat Dec 16 21:26:07 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: str.c,v 1.99 2023/06/23 05:03:04 rillig Exp $	*/
+/*	$NetBSD: str.c,v 1.100 2023/12/16 21:26:07 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -71,7 +71,7 @@
 #include "make.h"
 
 /*	"@(#)str.c	5.8 (Berkeley) 6/1/90"	*/
-MAKE_RCSID("$NetBSD: str.c,v 1.99 2023/06/23 05:03:04 rillig Exp $");
+MAKE_RCSID("$NetBSD: str.c,v 1.100 2023/12/16 21:26:07 rillig Exp $");
 
 
 static HashTable interned_strings;
@@ -322,17 +322,13 @@ StrMatchResult
 Str_Match(const char *str, const char *pat)
 {
 	StrMatchResult res = { NULL, false };
-	const char *fixed_str, *fixed_pat;
-	bool asterisk, matched;
-
-	asterisk = false;
-	fixed_str = str;
-	fixed_pat = pat;
+	bool asterisk = false;
+	const char *fixed_str = str;
+	const char *fixed_pat = pat;
 
 match_fixed_length:
 	str = fixed_str;
 	pat = fixed_pat;
-	matched = false;
 	for (; *pat != '\0' && *pat != '*'; str++, pat++) {
 		if (*str == '\0')
 			return res;
@@ -350,7 +346,7 @@ match_fixed_length:
 			if (*pat == ']' || *pat == '\0') {
 if (neg)
 	goto end_of_char_list;
-goto match_done;
+goto no_match;
 			}
 			if (*pat == *str)
 goto end_of_char_list;
@@ -369,7 +365,7 @@ match_fixed_length:
 
 		end_of_char_list:
 			if (neg && *pat != ']' && *pat != '\0')
-goto match_done;
+goto no_match;
 			while (*pat != ']' && *pat != '\0')
 pat++;
 			if (*pat == '\0')
@@ -380,42 +376,32 @@ match_fixed_length:
 		if (*pat == '\\')	/* match the next character exactly */
 			pat++;
 		if (*pat != *str)
-			goto match_done;
+			goto no_match;
 	}
-	matched = true;
 
-match_done:
-	if (!asterisk) {
-		if (!matched)
-			return res;
-		if (*pat == '\0') {
-			res.matched = *str == '\0';
-			return res;
-		}
+	if (*pat == '*') {
 		asterisk = true;
-	} else {
-		if (!matched) {
-			fixed_str++;
-			goto match_fixed_length;
-		}
+		while (*pat == '*')
+			pat++;
 		if (*pat == '\0') {
-			if (*str == '\0') {
-res.matched = true;
-return res;
-			}
-			fixed_str += strlen(str);
-			goto match_fixed_length;
+			res.matched = true;
+			return res;
 		}
+		fixed_str = str;
+		fixed_pat = pat;
+		goto match_fixed_length;
+	}
+	if (asterisk && *str != '\0') {
+		fixed_str += strlen(str);
+		goto match_fixed_length;
 	}
+	res.matched = *str == '\0';
+	return res;
 
-	while (*pat == '*')
-		pat++;
-	if (*pat == '\0') {
-		res.matched = true;
+no_match:
+	if (!asterisk)
 		return res;
-	}
-	fixed_str = str;
-	fixed_pat = pat;
+	fixed_str++;
 	goto match_fixed_length;
 }
 



CVS commit: src/usr.bin/make

2023-12-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Dec 16 21:26:07 UTC 2023

Modified Files:
src/usr.bin/make: str.c

Log Message:
make: eliminate a local variable in Str_Match

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/usr.bin/make/str.c

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



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

2023-12-16 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Dec 16 18:02:02 UTC 2023

Modified Files:
src/sys/arch/riscv/dev: plic.c

Log Message:
Free memory on failure


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/riscv/dev/plic.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/riscv/dev/plic.c
diff -u src/sys/arch/riscv/dev/plic.c:1.2 src/sys/arch/riscv/dev/plic.c:1.3
--- src/sys/arch/riscv/dev/plic.c:1.2	Sat Sep  2 09:58:15 2023
+++ src/sys/arch/riscv/dev/plic.c	Sat Dec 16 18:02:02 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: plic.c,v 1.2 2023/09/02 09:58:15 skrll Exp $ */
+/* $NetBSD: plic.c,v 1.3 2023/12/16 18:02:02 skrll Exp $ */
 
 /*-
  * Copyright (c) 2022 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: plic.c,v 1.2 2023/09/02 09:58:15 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plic.c,v 1.3 2023/12/16 18:02:02 skrll Exp $");
 
 #include 
 
@@ -190,17 +190,16 @@ plic_set_threshold(struct plic_softc *sc
 int
 plic_attach_common(struct plic_softc *sc, bus_addr_t addr, bus_size_t size)
 {
-	struct cpu_info *ci;
-	CPU_INFO_ITERATOR cii;
-	u_int irq;
+	const size_t szintrs = sizeof(*sc->sc_intr) * sc->sc_ndev;
+	const size_t szintrevs = sizeof(*sc->sc_intrevs) * sc->sc_ndev;
 
-	sc->sc_intr = kmem_zalloc(sizeof(*sc->sc_intr) * sc->sc_ndev,
-	KM_SLEEP);
-	sc->sc_intrevs = kmem_zalloc(sizeof(*sc->sc_intrevs) * sc->sc_ndev,
-	KM_SLEEP);
+	sc->sc_intr = kmem_zalloc(szintrs, KM_SLEEP);
+	sc->sc_intrevs = kmem_zalloc(szintrevs, KM_SLEEP);
 
 	if (bus_space_map(sc->sc_bst, addr, size, 0, >sc_bsh) != 0) {
-		aprint_error("couldn't map registers\n");
+		aprint_error_dev(sc->sc_dev, "couldn't map registers\n");
+		kmem_free(sc->sc_intr, szintrs);
+		kmem_free(sc->sc_intrevs, szintrevs);
 		return -1;
 	}
 
@@ -210,10 +209,13 @@ plic_attach_common(struct plic_softc *sc
 	plic_sc = sc;
 
 	/* Start with all interrupts disabled. */
+	u_int irq;
 	for (irq = PLIC_FIRST_IRQ; irq < sc->sc_ndev; irq++) {
 		plic_set_priority(sc, irq, 0);
 	}
 
+	struct cpu_info *ci;
+	CPU_INFO_ITERATOR cii;
 	/* Set priority thresholds for all interrupts to 0 (not masked). */
 	for (CPU_INFO_FOREACH(cii, ci)) {
 		plic_set_threshold(sc, ci->ci_cpuid, 0);



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

2023-12-16 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Dec 16 18:02:02 UTC 2023

Modified Files:
src/sys/arch/riscv/dev: plic.c

Log Message:
Free memory on failure


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/riscv/dev/plic.c

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



CVS commit: src/sys/dev/pci

2023-12-16 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Dec 16 16:35:49 UTC 2023

Modified Files:
src/sys/dev/pci: if_rge.c

Log Message:
- handle stuck transmitter (descriptor still owned)
- restart send queue after transmit
- count output packets
- use deferred start

Should fix PR 57694


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/pci/if_rge.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/pci/if_rge.c
diff -u src/sys/dev/pci/if_rge.c:1.28 src/sys/dev/pci/if_rge.c:1.29
--- src/sys/dev/pci/if_rge.c:1.28	Thu Oct 19 23:43:40 2023
+++ src/sys/dev/pci/if_rge.c	Sat Dec 16 16:35:49 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_rge.c,v 1.28 2023/10/19 23:43:40 mrg Exp $	*/
+/*	$NetBSD: if_rge.c,v 1.29 2023/12/16 16:35:49 mlelstv Exp $	*/
 /*	$OpenBSD: if_rge.c,v 1.9 2020/12/12 11:48:53 jan Exp $	*/
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_rge.c,v 1.28 2023/10/19 23:43:40 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_rge.c,v 1.29 2023/12/16 16:35:49 mlelstv Exp $");
 
 #include 
 
@@ -351,6 +351,7 @@ rge_attach(device_t parent, device_t sel
 	sc->sc_media.ifm_media = sc->sc_media.ifm_cur->ifm_media;
 
 	if_attach(ifp);
+	if_deferred_start_init(ifp, NULL);
 	ether_ifattach(ifp, eaddr);
 
 	if (pmf_device_register(self, NULL, NULL))
@@ -1385,10 +1386,14 @@ rge_txeof(struct rge_softc *sc)
 		m_freem(txq->txq_mbuf);
 		txq->txq_mbuf = NULL;
 
+		net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
 		if (txstat & (RGE_TDCMDSTS_EXCESSCOLL | RGE_TDCMDSTS_COLL))
-			if_statinc(ifp, if_collisions);
+			if_statinc_ref(nsr, if_collisions);
 		if (txstat & RGE_TDCMDSTS_TXERR)
-			if_statinc(ifp, if_oerrors);
+			if_statinc_ref(nsr, if_oerrors);
+		else
+			if_statinc_ref(nsr, if_opackets);
+		IF_STAT_PUTREF(ifp);
 
 		bus_dmamap_sync(sc->sc_dmat, sc->rge_ldata.rge_tx_list_map,
 		idx * sizeof(struct rge_tx_desc),
@@ -1404,24 +1409,12 @@ rge_txeof(struct rge_softc *sc)
 
 	sc->rge_ldata.rge_txq_considx = cons;
 
-#if 0
-	if (ifq_is_oactive(>if_snd))
-		ifq_restart(>if_snd);
-	else if (free == 2)
-		ifq_serialize(>if_snd, >sc_task);
-	else
-		ifp->if_timer = 0;
-#else
-#if 0
-	if (!IF_IS_EMPTY(>if_snd))
-		rge_start(ifp);
-	else
 	if (free == 2)
-		if (0) { rge_txstart(>sc_task, sc); }
-	else
-#endif
-		ifp->if_timer = 0;
-#endif
+		rge_txstart(>sc_task, sc);
+
+	CLR(ifp->if_flags, IFF_OACTIVE);
+	ifp->if_timer = 0;
+	if_schedule_deferred_start(ifp);
 
 	return (1);
 }



CVS commit: src/sys/dev/pci

2023-12-16 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Dec 16 16:35:49 UTC 2023

Modified Files:
src/sys/dev/pci: if_rge.c

Log Message:
- handle stuck transmitter (descriptor still owned)
- restart send queue after transmit
- count output packets
- use deferred start

Should fix PR 57694


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/pci/if_rge.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/cvslatest

2023-12-16 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat Dec 16 14:32:33 UTC 2023

Modified Files:
src/usr.bin/cvslatest: cvslatest.1

Log Message:
cvslatest(1): remove RETURN VALUES

Pages in section one should use EXIT STATUS instead (which this one
already provides).

Closes PR 57778 by Kouichi Hashikawa


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/cvslatest/cvslatest.1

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



CVS commit: src/usr.bin/cvslatest

2023-12-16 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat Dec 16 14:32:33 UTC 2023

Modified Files:
src/usr.bin/cvslatest: cvslatest.1

Log Message:
cvslatest(1): remove RETURN VALUES

Pages in section one should use EXIT STATUS instead (which this one
already provides).

Closes PR 57778 by Kouichi Hashikawa


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/cvslatest/cvslatest.1

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

Modified files:

Index: src/usr.bin/cvslatest/cvslatest.1
diff -u src/usr.bin/cvslatest/cvslatest.1:1.1 src/usr.bin/cvslatest/cvslatest.1:1.2
--- src/usr.bin/cvslatest/cvslatest.1:1.1	Sun Jan 24 17:08:16 2016
+++ src/usr.bin/cvslatest/cvslatest.1	Sat Dec 16 14:32:33 2023
@@ -1,4 +1,4 @@
-.\" $NetBSD: cvslatest.1,v 1.1 2016/01/24 17:08:16 christos Exp $
+.\" $NetBSD: cvslatest.1,v 1.2 2023/12/16 14:32:33 wiz Exp $
 .\" Copyright (C) 2015 Thomas Klausner
 .\"
 .\" Redistribution and use in source and binary forms, with or without
@@ -23,7 +23,7 @@
 .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd January 7, 2016
+.Dd December 16, 2023
 .Dt CVSLATEST 1
 .Os
 .Sh NAME
@@ -70,7 +70,5 @@ information directory.
 .Sh SEE ALSO
 .Xr cvs 1 ,
 .Xr date 1
-.Sh RETURN VALUES
-.Ex -std
 .Sh AUTHORS
 .An Christos Zoulas Aq Mt chris...@netbsd.org