CVS commit: src/sys/dev/wscons

2021-01-24 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Mon Jan 25 02:11:41 UTC 2021

Modified Files:
src/sys/dev/wscons: wsdisplay_vcons.c

Log Message:
clear the RI_CURSOR flag when we overwrite the cursor so we can skip clearing
it when asked to do it later on
saves a bunch of framebuffer writes


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/dev/wscons/wsdisplay_vcons.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/wscons/wsdisplay_vcons.c
diff -u src/sys/dev/wscons/wsdisplay_vcons.c:1.48 src/sys/dev/wscons/wsdisplay_vcons.c:1.49
--- src/sys/dev/wscons/wsdisplay_vcons.c:1.48	Thu Jan 21 21:45:42 2021
+++ src/sys/dev/wscons/wsdisplay_vcons.c	Mon Jan 25 02:11:41 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: wsdisplay_vcons.c,v 1.48 2021/01/21 21:45:42 macallan Exp $ */
+/*	$NetBSD: wsdisplay_vcons.c,v 1.49 2021/01/25 02:11:41 macallan Exp $ */
 
 /*-
  * Copyright (c) 2005, 2006 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wsdisplay_vcons.c,v 1.48 2021/01/21 21:45:42 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsdisplay_vcons.c,v 1.49 2021/01/25 02:11:41 macallan Exp $");
 
 #include 
 #include 
@@ -1273,6 +1273,9 @@ vcons_putchar(void *cookie, int row, int
 #ifdef VCONS_DRAW_INTR
 		vcons_putchar_cached(cookie, row, col, c, attr);
 #else
+		if (row == ri->ri_crow && col == ri->ri_ccol) {
+			ri->ri_flg &= ~RI_CURSOR;
+		}
 		scr->putchar(cookie, row, col, c, attr);
 #endif
 	}
@@ -1337,7 +1340,7 @@ vcons_cursor_noread(void *cookie, int on
 #endif
 	if (SCREEN_IS_VISIBLE(scr) && SCREEN_CAN_DRAW(scr)) {
 		int ofs = offset + ri->ri_crow * ri->ri_cols + ri->ri_ccol;
-		if (ri->ri_flg & RI_CURSOR) {
+		if (on && (ri->ri_flg & RI_CURSOR)) {
 			scr->putchar(cookie, ri->ri_crow, ri->ri_ccol,
 			scr->scr_chars[ofs], scr->scr_attrs[ofs]);
 			ri->ri_flg &= ~RI_CURSOR;



CVS commit: src/doc

2021-01-24 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sun Jan 24 22:08:37 UTC 2021

Modified Files:
src/doc: CHANGES

Log Message:
Correct date for previous (tzdata 2021a update) - seems I cannot read
the output of the date(1) command any more...


To generate a diff of this commit:
cvs rdiff -u -r1.2776 -r1.2777 src/doc/CHANGES

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
diff -u src/doc/CHANGES:1.2776 src/doc/CHANGES:1.2777
--- src/doc/CHANGES:1.2776	Sun Jan 24 22:02:47 2021
+++ src/doc/CHANGES	Sun Jan 24 22:08:37 2021
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2776 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2777 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -328,4 +328,4 @@ Changes from NetBSD 9.0 to NetBSD 10.0:
 	tzdata updated to 2020f (includes update to 2020e)  [kre 20201231] 
 	evbarm: Add support for Amlogic G12 family SoCs. [ryo 20210101]
 	pppd(8): updated to version 2.4.9. [christos 20210109]
-	tzdata updated to 2021a [kre 20210122] 
+	tzdata updated to 2021a [kre 20210124] 



CVS commit: src/doc

2021-01-24 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sun Jan 24 22:02:47 UTC 2021

Modified Files:
src/doc: 3RDPARTY CHANGES

Log Message:
Note update of tzdata to 2021a


To generate a diff of this commit:
cvs rdiff -u -r1.1773 -r1.1774 src/doc/3RDPARTY
cvs rdiff -u -r1.2775 -r1.2776 src/doc/CHANGES

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

Modified files:

Index: src/doc/3RDPARTY
diff -u src/doc/3RDPARTY:1.1773 src/doc/3RDPARTY:1.1774
--- src/doc/3RDPARTY:1.1773	Sat Jan  9 16:44:35 2021
+++ src/doc/3RDPARTY	Sun Jan 24 22:02:47 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: 3RDPARTY,v 1.1773 2021/01/09 16:44:35 christos Exp $
+#	$NetBSD: 3RDPARTY,v 1.1774 2021/01/24 22:02:47 kre Exp $
 #
 # This file contains a list of the software that has been integrated into
 # NetBSD where we are not the primary maintainer.
@@ -1410,8 +1410,8 @@ Notes:
 Added changes from a5 -> a12 manually.
 
 Package:	tz
-Version:	tzcode2020c / tzdata2020f
-Current Vers:	tzcode2020f / tzdata2020f
+Version:	tzcode2020c / tzdata2021a
+Current Vers:	tzcode2021a / tzdata2021a
 Maintainer:	Paul Eggert 
 Archive Site:	ftp://ftp.iana.org/tz/releases/
 Archive Site:	ftp://munnari.oz.au/pub/oldtz/

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.2775 src/doc/CHANGES:1.2776
--- src/doc/CHANGES:1.2775	Sat Jan  9 16:44:35 2021
+++ src/doc/CHANGES	Sun Jan 24 22:02:47 2021
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2775 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2776 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -328,3 +328,4 @@ Changes from NetBSD 9.0 to NetBSD 10.0:
 	tzdata updated to 2020f (includes update to 2020e)  [kre 20201231] 
 	evbarm: Add support for Amlogic G12 family SoCs. [ryo 20210101]
 	pppd(8): updated to version 2.4.9. [christos 20210109]
+	tzdata updated to 2021a [kre 20210122] 



CVS commit: src/external/public-domain/tz/dist

2021-01-24 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sun Jan 24 21:59:37 UTC 2021

Modified Files:
src/external/public-domain/tz/dist: TZDATA_VERSION

Log Message:
Merge tzdata2021a


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/external/public-domain/tz/dist/TZDATA_VERSION

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

Modified files:

Index: src/external/public-domain/tz/dist/TZDATA_VERSION
diff -u src/external/public-domain/tz/dist/TZDATA_VERSION:1.23 src/external/public-domain/tz/dist/TZDATA_VERSION:1.24
--- src/external/public-domain/tz/dist/TZDATA_VERSION:1.23	Thu Dec 31 07:50:43 2020
+++ src/external/public-domain/tz/dist/TZDATA_VERSION	Sun Jan 24 21:59:37 2021
@@ -1 +1 @@
-tzdata-2020f
+tzdata-2021a



CVS import: src/external/public-domain/tz/dist

2021-01-24 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sun Jan 24 21:59:15 UTC 2021

Update of /cvsroot/src/external/public-domain/tz/dist
In directory ivanova.netbsd.org:/tmp/cvs-serv19196

Log Message:
Import tzdata2021a from ftp://ftp.iana.org/tz/releases/tzdata2021a.tar.gz

Summary of changes in tzdata2021a (2021-01-24 10:54:57 -0800):

South Sudan changes from +03 to +02 on 2021-02-01 at 00:00.

Status:

Vendor Tag: TZDATA
Release Tags:   TZDATA2021A

U src/external/public-domain/tz/dist/leap-seconds.list
U src/external/public-domain/tz/dist/calendars
U src/external/public-domain/tz/dist/CONTRIBUTING
U src/external/public-domain/tz/dist/LICENSE
U src/external/public-domain/tz/dist/Makefile
U src/external/public-domain/tz/dist/NEWS
U src/external/public-domain/tz/dist/README
U src/external/public-domain/tz/dist/theory.html
U src/external/public-domain/tz/dist/version
U src/external/public-domain/tz/dist/africa
U src/external/public-domain/tz/dist/antarctica
U src/external/public-domain/tz/dist/asia
U src/external/public-domain/tz/dist/australasia
U src/external/public-domain/tz/dist/europe
U src/external/public-domain/tz/dist/northamerica
U src/external/public-domain/tz/dist/southamerica
U src/external/public-domain/tz/dist/etcetera
U src/external/public-domain/tz/dist/factory
U src/external/public-domain/tz/dist/backward
U src/external/public-domain/tz/dist/backzone
U src/external/public-domain/tz/dist/iso3166.tab
U src/external/public-domain/tz/dist/checklinks.awk
U src/external/public-domain/tz/dist/leapseconds
U src/external/public-domain/tz/dist/zone1970.tab
U src/external/public-domain/tz/dist/zone.tab
U src/external/public-domain/tz/dist/leapseconds.awk
U src/external/public-domain/tz/dist/checktab.awk
U src/external/public-domain/tz/dist/zoneinfo2tdf.pl
U src/external/public-domain/tz/dist/ziguard.awk
U src/external/public-domain/tz/dist/zishrink.awk

No conflicts created by this import



CVS commit: src/sys/dev/ofw

2021-01-24 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Jan 24 21:48:38 UTC 2021

Modified Files:
src/sys/dev/ofw: ofw_subr.c

Log Message:
malloc(9) -> kmem(9)


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/dev/ofw/ofw_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/ofw/ofw_subr.c
diff -u src/sys/dev/ofw/ofw_subr.c:1.47 src/sys/dev/ofw/ofw_subr.c:1.48
--- src/sys/dev/ofw/ofw_subr.c:1.47	Sun Jan 24 19:38:37 2021
+++ src/sys/dev/ofw/ofw_subr.c	Sun Jan 24 21:48:38 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofw_subr.c,v 1.47 2021/01/24 19:38:37 thorpej Exp $	*/
+/*	$NetBSD: ofw_subr.c,v 1.48 2021/01/24 21:48:38 thorpej Exp $	*/
 
 /*
  * Copyright 1998
@@ -34,13 +34,12 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.47 2021/01/24 19:38:37 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.48 2021/01/24 21:48:38 thorpej Exp $");
 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #define	OFW_MAX_STACK_BUF_SIZE	256
@@ -293,7 +292,7 @@ of_packagename(int phandle, char *buf, i
 	const char *lastslash;
 	int l, rv;
 
-	pbuf = malloc(OFW_PATH_BUF_SIZE, M_TEMP, M_WAITOK);
+	pbuf = kmem_alloc(OFW_PATH_BUF_SIZE, KM_SLEEP);
 	l = OF_package_to_path(phandle, pbuf, OFW_PATH_BUF_SIZE);
 
 	/* check that we could get the name, and that it's not too long. */
@@ -315,7 +314,7 @@ of_packagename(int phandle, char *buf, i
 		rv = 0;
 	}
 
-	free(pbuf, M_TEMP);
+	kmem_free(pbuf, OFW_PATH_BUF_SIZE);
 	return (rv);
 }
 



CVS commit: src/usr.bin/make

2021-01-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 24 20:11:55 UTC 2021

Modified Files:
src/usr.bin/make: dir.c main.c make.h nonints.h parse.c suff.c

Log Message:
make(1): convert SearchPath to struct

This prepares for making dotLast a simple struct member instead of a
fake CachedDir, which is easier to understand.


To generate a diff of this commit:
cvs rdiff -u -r1.263 -r1.264 src/usr.bin/make/dir.c
cvs rdiff -u -r1.516 -r1.517 src/usr.bin/make/main.c
cvs rdiff -u -r1.245 -r1.246 src/usr.bin/make/make.h
cvs rdiff -u -r1.187 -r1.188 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.530 -r1.531 src/usr.bin/make/parse.c
cvs rdiff -u -r1.339 -r1.340 src/usr.bin/make/suff.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/dir.c
diff -u src/usr.bin/make/dir.c:1.263 src/usr.bin/make/dir.c:1.264
--- src/usr.bin/make/dir.c:1.263	Sat Jan 23 12:36:02 2021
+++ src/usr.bin/make/dir.c	Sun Jan 24 20:11:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.263 2021/01/23 12:36:02 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.264 2021/01/24 20:11:55 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -138,7 +138,7 @@
 #include "job.h"
 
 /*	"@(#)dir.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: dir.c,v 1.263 2021/01/23 12:36:02 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.264 2021/01/24 20:11:55 rillig Exp $");
 
 /*
  * A search path is a list of CachedDir structures. A CachedDir has in it the
@@ -253,7 +253,7 @@ typedef enum CachedStatsFlags {
 } CachedStatsFlags;
 
 
-SearchPath dirSearchPath = LST_INIT;	/* main search path */
+SearchPath dirSearchPath = { LST_INIT }; /* main search path */
 
 static OpenDirs openDirs;	/* all cached directories */
 
@@ -551,7 +551,7 @@ Dir_SetPATH(void)
 
 	Var_Delete(".PATH", VAR_GLOBAL);
 
-	if ((ln = dirSearchPath.first) != NULL) {
+	if ((ln = dirSearchPath.dirs.first) != NULL) {
 		CachedDir *dir = ln->datum;
 		if (dir == dotLast) {
 			seenDotLast = TRUE;
@@ -566,7 +566,7 @@ Dir_SetPATH(void)
 			Var_Append(".PATH", cur->name, VAR_GLOBAL);
 	}
 
-	for (ln = dirSearchPath.first; ln != NULL; ln = ln->next) {
+	for (ln = dirSearchPath.dirs.first; ln != NULL; ln = ln->next) {
 		CachedDir *dir = ln->datum;
 		if (dir == dotLast)
 			continue;
@@ -818,7 +818,7 @@ static void
 DirExpandPath(const char *word, SearchPath *path, StringList *expansions)
 {
 	SearchPathNode *ln;
-	for (ln = path->first; ln != NULL; ln = ln->next) {
+	for (ln = path->dirs.first; ln != NULL; ln = ln->next) {
 		CachedDir *dir = ln->datum;
 		DirMatchFiles(word, dir, expansions);
 	}
@@ -1085,7 +1085,7 @@ FindFileRelative(SearchPath *path, Boole
 			goto found;
 	}
 
-	for (ln = path->first; ln != NULL; ln = ln->next) {
+	for (ln = path->dirs.first; ln != NULL; ln = ln->next) {
 		CachedDir *dir = ln->datum;
 		if (dir == dotLast)
 			continue;
@@ -1150,7 +1150,7 @@ FindFileAbsolute(SearchPath *path, Boole
 	((file = DirLookupAbs(cur, name, base)) != NULL))
 		goto found;
 
-	for (ln = path->first; ln != NULL; ln = ln->next) {
+	for (ln = path->dirs.first; ln != NULL; ln = ln->next) {
 		CachedDir *dir = ln->datum;
 		if (dir == dotLast)
 			continue;
@@ -1207,8 +1207,8 @@ Dir_FindFile(const char *name, SearchPat
 		return NULL;
 	}
 
-	if (path->first != NULL) {
-		CachedDir *dir = path->first->datum;
+	if (path->dirs.first != NULL) {
+		CachedDir *dir = path->dirs.first->datum;
 		if (dir == dotLast) {
 			seenDotLast = TRUE;
 			DEBUG0(DIR, "[dot last]...");
@@ -1241,7 +1241,7 @@ Dir_FindFile(const char *name, SearchPat
 		if (!seenDotLast && (file = DirFindDot(name, base)) != NULL)
 			return file;
 
-		for (ln = path->first; ln != NULL; ln = ln->next) {
+		for (ln = path->dirs.first; ln != NULL; ln = ln->next) {
 			CachedDir *dir = ln->datum;
 			if (dir == dotLast)
 continue;
@@ -1544,7 +1544,7 @@ CacheNewDir(const char *name, SearchPath
 
 	OpenDirs_Add(, dir);
 	if (path != NULL)
-		Lst_Append(path, CachedDir_Ref(dir));
+		Lst_Append(>dirs, CachedDir_Ref(dir));
 
 	DEBUG1(DIR, "Caching %s done\n", name);
 	return dir;
@@ -1576,21 +1576,21 @@ SearchPath_Add(SearchPath *path, const c
 		SearchPathNode *ln;
 
 		/* XXX: Linear search gets slow with thousands of entries. */
-		for (ln = path->first; ln != NULL; ln = ln->next) {
+		for (ln = path->dirs.first; ln != NULL; ln = ln->next) {
 			CachedDir *pathDir = ln->datum;
 			if (strcmp(pathDir->name, name) == 0)
 return pathDir;
 		}
 
-		Lst_Prepend(path, CachedDir_Ref(dotLast));
+		Lst_Prepend(>dirs, CachedDir_Ref(dotLast));
 	}
 
 	if (path != NULL) {
 		/* XXX: Why is OpenDirs only checked if path != NULL? */
 		CachedDir *dir = OpenDirs_Find(, name);
 		if (dir != NULL) {
-			if (Lst_FindDatum(path, dir) == NULL)
-Lst_Append(path, CachedDir_Ref(dir));
+			if (Lst_FindDatum(>dirs, dir) == NULL)
+Lst_Append(>dirs, CachedDir_Ref(dir));
 			return dir;
 		}
 	}

CVS commit: src/sys/dev/ofw

2021-01-24 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Jan 24 20:09:03 UTC 2021

Modified Files:
src/sys/dev/ofw: ofw_network_subr.c

Log Message:
Rewrite of_network_decode_media() to use strlist_next() and
device_compatible_lookup().


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/ofw/ofw_network_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/ofw/ofw_network_subr.c
diff -u src/sys/dev/ofw/ofw_network_subr.c:1.8 src/sys/dev/ofw/ofw_network_subr.c:1.9
--- src/sys/dev/ofw/ofw_network_subr.c:1.8	Wed May 29 06:21:57 2019
+++ src/sys/dev/ofw/ofw_network_subr.c	Sun Jan 24 20:09:03 2021
@@ -1,7 +1,7 @@
-/*	$NetBSD: ofw_network_subr.c,v 1.8 2019/05/29 06:21:57 msaitoh Exp $	*/
+/*	$NetBSD: ofw_network_subr.c,v 1.9 2021/01/24 20:09:03 thorpej Exp $	*/
 
 /*-
- * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * Copyright (c) 1998, 2021 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -31,27 +31,40 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ofw_network_subr.c,v 1.8 2019/05/29 06:21:57 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_network_subr.c,v 1.9 2021/01/24 20:09:03 thorpej Exp $");
 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
 
 #include 
 
-#define	OFW_MAX_STACK_BUF_SIZE	256
-#define	OFW_PATH_BUF_SIZE	512
+static const struct device_compatible_entry media_compat[] = {
+	{ .compat = "ethernet,10,rj45,half",
+	  .value = IFM_ETHER | IFM_10_T },
 
-struct table_entry {
-	const char *t_string;
-	int t_value;
-};
+	{ .compat = "ethernet,10,rj45,full",
+	  .value = IFM_ETHER | IFM_10_T | IFM_FDX },
+
+	{ .compat = "ethernet,10,aui,half",
+	  .value = IFM_ETHER | IFM_10_5 },
+
+	{ .compat = "ethernet,10,bnc,half",
+	  .value = IFM_ETHER | IFM_10_2 },
 
-int	of_network_parse_network_type(const char *);
+	{ .compat = "ethernet,100,rj45,half",
+	  .value = IFM_ETHER | IFM_100_TX },
+
+	{ .compat = "ethernet,100,rj45,full",
+	  .value = IFM_ETHER | IFM_100_TX | IFM_FDX },
+
+	{ 0 }
+};
 
 /*
  * int of_network_decode_media(phandle, nmediap, defmediap)
@@ -80,73 +93,52 @@ int	of_network_parse_network_type(const 
 int *
 of_network_decode_media(int phandle, int *nmediap, int *defmediap)
 {
-	int i, len, count, med, *rv = NULL;
-	char *buf = NULL, *cp, *ncp;
+	const struct device_compatible_entry *dce;
+	int nmedia, len, *rv = NULL;
+	char *sl = NULL;
+	const char *cp;
+	size_t cursor;
+	unsigned int count;
 
 	len = OF_getproplen(phandle, "supported-network-types");
 	if (len <= 0)
 		return (NULL);
 
-	buf = malloc(len, M_TEMP, M_WAITOK);
+	sl = malloc(len, M_TEMP, M_WAITOK);
 
 	/* `supported-network-types' should not change. */
-	if (OF_getprop(phandle, "supported-network-types", buf, len) != len)
+	if (OF_getprop(phandle, "supported-network-types", sl, len) != len)
 		goto bad;
 
-	/*
-	 * Count the number of entries in the array.  This is kind of tricky,
-	 * because they're variable-length strings, yuck.
-	 */
-	for (count = 0, cp = buf; cp <= (buf + len); cp++) {
-		/*
-		 * If we encounter nul, that marks the end of a string,
-		 * and thus one complete media description.
-		 */
-		if (*cp == '\0')
-			count++;
-	}
+	count = strlist_count(sl, len);
 
-	/* Sanity. */
 	if (count == 0)
 		goto bad;
 
 	/* Allocate the return value array. */
 	rv = malloc(count * sizeof(int), M_DEVBUF, M_WAITOK);
 
-	/*
-	 * Parse each media string.  If we get -1 back from the parser,
-	 * back off the count by one, to skip the bad entry.
-	 */
-	for (i = 0, cp = buf; cp <= (buf + len) && i < count; ) {
-		/*
-		 * Find the next string now, as we may chop
-		 * the current one up in the parser.
-		 */
-		for (ncp = cp; *ncp != '\0'; ncp++)
-			/* ...skip to the nul... */ ;
-		ncp++;	/* ...and now past it. */
-
-		med = of_network_parse_network_type(cp);
-		if (med == -1)
-			count--;
-		else {
-			rv[i] = med;
-			i++;
+	/* Parse each media string. */
+	for (nmedia = 0, cursor = 0;
+	 (cp = strlist_next(sl, len, )) != NULL; ) {
+		dce = device_compatible_lookup(, 1, media_compat);
+		if (dce != NULL) {
+			rv[nmedia++] = (int)dce->value;
 		}
-		cp = ncp;
 	}
-
 	/* Sanity... */
-	if (count == 0)
+	if (nmedia == 0)
 		goto bad;
 
+	free(sl, M_TEMP);
+	sl = NULL;
+
 	/*
 	 * We now have the `supported-media-types' property decoded.
 	 * Next step is to decode the `chosen-media-type' property,
 	 * if it exists.
 	 */
-	free(buf, M_TEMP);
-	buf = NULL;
+	*defmediap = -1;
 	len = OF_getproplen(phandle, "chosen-network-type");
 	if (len <= 0) {
 		/* Property does not exist. */
@@ -154,63 +146,28 @@ of_network_decode_media(int phandle, int
 		goto done;
 	}
 
-	buf = malloc(len, M_TEMP, M_WAITOK);
-	if (OF_getprop(phandle, "chosen-network-type", buf, len) != len) {
+	sl = malloc(len, M_TEMP, M_WAITOK);
+	if (OF_getprop(phandle, "chosen-network-type", 

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

2021-01-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 24 19:48:11 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: directive-for-escape.exp
directive-for-escape.mk

Log Message:
make(1): describe expansion of nested variables in .for values

These edge cases are not documented anywhere, and their behavior is
non-intuitive.  For now, just describe them, don't try to fix them.
There may be people out there relying on exactly this behavior.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/directive-for-escape.exp \
src/usr.bin/make/unit-tests/directive-for-escape.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-for-escape.exp
diff -u src/usr.bin/make/unit-tests/directive-for-escape.exp:1.4 src/usr.bin/make/unit-tests/directive-for-escape.exp:1.5
--- src/usr.bin/make/unit-tests/directive-for-escape.exp:1.4	Sun Jan 24 19:30:18 2021
+++ src/usr.bin/make/unit-tests/directive-for-escape.exp	Sun Jan 24 19:48:11 2021
@@ -27,25 +27,29 @@ make: "directive-for-escape.mk" line 41:
 For: end for 1
 For: loop body:
 .  info ${:U\${UNDEF\:U\\$\\$}
-make: "directive-for-escape.mk" line 52: ${UNDEF:U\$
+make: "directive-for-escape.mk" line 55: ${UNDEF:U\$
 For: loop body:
 .  info ${:U{{\}\}}
-make: "directive-for-escape.mk" line 52: {{}}
+make: "directive-for-escape.mk" line 55: {{}}
 For: loop body:
 .  info ${:Uend\}}
-make: "directive-for-escape.mk" line 52: end}
+make: "directive-for-escape.mk" line 55: end}
+For: end for 1
+For: loop body:
+.  info ${:Ubegin<${UNDEF:Ufallback:N{{{>end}
+make: "directive-for-escape.mk" line 66: beginend
 For: end for 1
 For: loop body:
 .  info ${:U\$}
-make: "directive-for-escape.mk" line 60: $
+make: "directive-for-escape.mk" line 74: $
 For: end for 1
 For: loop body:
 .  info ${NUMBERS} ${:Ureplaced}
-make: "directive-for-escape.mk" line 68: one two three replaced
+make: "directive-for-escape.mk" line 82: one two three replaced
 For: end for 1
 For: loop body:
 .  info ${:Ureplaced}
-make: "directive-for-escape.mk" line 78: replaced
+make: "directive-for-escape.mk" line 92: replaced
 For: end for 1
 For: loop body:
 .  info .$$i: ${:Uinner}
@@ -58,14 +62,14 @@ For: loop body:
 .  info . $${i2}: ${i2}
 .  info . $${i,}: ${i,}
 .  info .  adjacent: ${:Uinner}${:Uinner}${:Uinner:M*}${:Uinner}
-make: "directive-for-escape.mk" line 86: .$i: inner
-make: "directive-for-escape.mk" line 87: .  ${i}: inner
-make: "directive-for-escape.mk" line 88: .   ${i:M*}: inner
-make: "directive-for-escape.mk" line 89: .  $(i): inner
-make: "directive-for-escape.mk" line 90: .   $(i:M*): inner
-make: "directive-for-escape.mk" line 91: . ${i${:U}}: outer
-make: "directive-for-escape.mk" line 92: .${i\}}: inner}
-make: "directive-for-escape.mk" line 93: . ${i2}: two
-make: "directive-for-escape.mk" line 94: . ${i,}: comma
-make: "directive-for-escape.mk" line 95: .  adjacent: innerinnerinnerinner
+make: "directive-for-escape.mk" line 100: .$i: inner
+make: "directive-for-escape.mk" line 101: .  ${i}: inner
+make: "directive-for-escape.mk" line 102: .   ${i:M*}: inner
+make: "directive-for-escape.mk" line 103: .  $(i): inner
+make: "directive-for-escape.mk" line 104: .   $(i:M*): inner
+make: "directive-for-escape.mk" line 105: . ${i${:U}}: outer
+make: "directive-for-escape.mk" line 106: .${i\}}: inner}
+make: "directive-for-escape.mk" line 107: . ${i2}: two
+make: "directive-for-escape.mk" line 108: . ${i,}: comma
+make: "directive-for-escape.mk" line 109: .  adjacent: innerinnerinnerinner
 exit status 0
Index: src/usr.bin/make/unit-tests/directive-for-escape.mk
diff -u src/usr.bin/make/unit-tests/directive-for-escape.mk:1.4 src/usr.bin/make/unit-tests/directive-for-escape.mk:1.5
--- src/usr.bin/make/unit-tests/directive-for-escape.mk:1.4	Sun Jan 24 19:30:18 2021
+++ src/usr.bin/make/unit-tests/directive-for-escape.mk	Sun Jan 24 19:48:11 2021
@@ -1,4 +1,4 @@
-# $NetBSD: directive-for-escape.mk,v 1.4 2021/01/24 19:30:18 rillig Exp $
+# $NetBSD: directive-for-escape.mk,v 1.5 2021/01/24 19:48:11 rillig Exp $
 #
 # Test escaping of special characters in the iteration values of a .for loop.
 # These values get expanded later using the :U variable modifier, and this
@@ -41,17 +41,31 @@ VALUES=		$$ $${V} $${V:=-with-modifier} 
 .  info $i
 .endfor
 
-# Cover the code for nested '{}' in for_var_len.
+# Try to cover the code for nested '{}' in for_var_len, without success.
 #
-# The value of VALUES is not a variable expression.  Instead, it is meant to
-# represent dollar, lbrace, "UNDEF:U", backslash, dollar, backslash, dollar,
-# space, nested braces, space, "end}".
+# The value of VALUES is not meant to be a variable expression.  Instead, it
+# is meant to represent dollar, lbrace, "UNDEF:U", backslash, dollar,
+# backslash, 

CVS commit: src/sys/dev/i2c

2021-01-24 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Jan 24 19:38:49 UTC 2021

Modified Files:
src/sys/dev/i2c: pcai2cmux.c

Log Message:
remove part of previous that was committed by mistake


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/i2c/pcai2cmux.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/i2c/pcai2cmux.c
diff -u src/sys/dev/i2c/pcai2cmux.c:1.4 src/sys/dev/i2c/pcai2cmux.c:1.5
--- src/sys/dev/i2c/pcai2cmux.c:1.4	Sun Jan 24 19:37:45 2021
+++ src/sys/dev/i2c/pcai2cmux.c	Sun Jan 24 19:38:49 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcai2cmux.c,v 1.4 2021/01/24 19:37:45 jmcneill Exp $	*/
+/*	$NetBSD: pcai2cmux.c,v 1.5 2021/01/24 19:38:49 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcai2cmux.c,v 1.4 2021/01/24 19:37:45 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcai2cmux.c,v 1.5 2021/01/24 19:38:49 jmcneill Exp $");
 
 /*
  * Driver for NXP PCA954x / PCA984x I2C switches and multiplexers.
@@ -126,10 +126,6 @@ static const struct device_compatible_en
 	{ .compat = "nxp,pca9547",
 	  .data = _type },
 
-	/* PCA9547 - 8 channel i2c mux (NXP Layerscape ACPI) */
-	{ .compat = "NXP0002",
-	  .data = _type },
-
 	/* PCA9548 - 8 channel i2c switch */
 	{ .compat = "nxp,pca9548",
 	  .data = _type },



CVS commit: src/sys/dev/ofw

2021-01-24 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Jan 24 19:38:37 UTC 2021

Modified Files:
src/sys/dev/ofw: ofw_subr.c

Log Message:
Rewrite of_compatible() using strlist_match().


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/dev/ofw/ofw_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/ofw/ofw_subr.c
diff -u src/sys/dev/ofw/ofw_subr.c:1.46 src/sys/dev/ofw/ofw_subr.c:1.47
--- src/sys/dev/ofw/ofw_subr.c:1.46	Sun Jan 24 17:44:16 2021
+++ src/sys/dev/ofw/ofw_subr.c	Sun Jan 24 19:38:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofw_subr.c,v 1.46 2021/01/24 17:44:16 thorpej Exp $	*/
+/*	$NetBSD: ofw_subr.c,v 1.47 2021/01/24 19:38:37 thorpej Exp $	*/
 
 /*
  * Copyright 1998
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.46 2021/01/24 17:44:16 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.47 2021/01/24 19:38:37 thorpej Exp $");
 
 #include 
 #include 
@@ -101,60 +101,31 @@ of_decode_int(const unsigned char *p)
 int
 of_compatible(int phandle, const char * const *strings)
 {
+	char *prop, propbuf[OFW_MAX_STACK_BUF_SIZE];
+	const char *cp;
+	int proplen, match, rv = -1;
 
-	int len, olen, allocated, nstr, cstr, rv;
-	char *buf, sbuf[OFW_MAX_STACK_BUF_SIZE];
-	const char *sp, *nsp;
-
-	len = OF_getproplen(phandle, "compatible");
-	if (len <= 0)
-		return (-1);
-
-	if (len > sizeof(sbuf)) {
-		buf = malloc(len, M_TEMP, M_WAITOK);
-		allocated = 1;
-	} else {
-		buf = sbuf;
-		allocated = 0;
+	proplen = OF_getproplen(phandle, "compatible");
+	if (proplen <= 0) {
+		return -1;
 	}
 
-	/* 'compatible' size should not change. */
-	if (OF_getprop(phandle, "compatible", buf, len) != len) {
-		rv = -1;
+	prop = kmem_tmpbuf_alloc(proplen, propbuf, sizeof(propbuf), KM_SLEEP);
+
+	if (OF_getprop(phandle, "compatible", prop, proplen) != proplen) {
 		goto out;
 	}
 
-	/* count 'compatible' strings */
-	sp = buf;
-	nstr = 0;
-	olen = len;
-	while (len && (nsp = memchr(sp, 0, len)) != NULL) {
-		nsp++;			/* skip over NUL char */
-		len -= (nsp - sp);
-		sp = nsp;
-		nstr++;
-	}
-	len = olen;
-
-	sp = buf;
-	rv = nstr;
-	while (len && (nsp = memchr(sp, 0, len)) != NULL) {
-		rv--;
-		/* look for a match among the strings provided */
-		for (cstr = 0; strings[cstr] != NULL; cstr++)
-			if (strcmp(sp, strings[cstr]) == 0)
-goto out;
-
-		nsp++;			/* skip over NUL char */
-		len -= (nsp - sp);
-		sp = nsp;
-	}
-	rv = -1;
-
-out:
-	if (allocated)
-		free(buf, M_TEMP);
-	return (rv);
+	for (; (cp = *strings) != NULL; strings++) {
+		if ((match = strlist_match(prop, proplen, cp)) != 0) {
+			rv = match - 1;
+			break;
+		}
+	}
+
+ out:
+	kmem_tmpbuf_free(prop, proplen, propbuf);
+	return rv;
 }
 
 /*



CVS commit: src/sys/dev/i2c

2021-01-24 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Jan 24 19:37:45 UTC 2021

Modified Files:
src/sys/dev/i2c: pcai2cmux.c

Log Message:
trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/i2c/pcai2cmux.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/i2c/pcai2cmux.c
diff -u src/sys/dev/i2c/pcai2cmux.c:1.3 src/sys/dev/i2c/pcai2cmux.c:1.4
--- src/sys/dev/i2c/pcai2cmux.c:1.3	Mon Jan 18 15:28:21 2021
+++ src/sys/dev/i2c/pcai2cmux.c	Sun Jan 24 19:37:45 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcai2cmux.c,v 1.3 2021/01/18 15:28:21 thorpej Exp $	*/
+/*	$NetBSD: pcai2cmux.c,v 1.4 2021/01/24 19:37:45 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcai2cmux.c,v 1.3 2021/01/18 15:28:21 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcai2cmux.c,v 1.4 2021/01/24 19:37:45 jmcneill Exp $");
 
 /*
  * Driver for NXP PCA954x / PCA984x I2C switches and multiplexers.
@@ -126,6 +126,10 @@ static const struct device_compatible_en
 	{ .compat = "nxp,pca9547",
 	  .data = _type },
 
+	/* PCA9547 - 8 channel i2c mux (NXP Layerscape ACPI) */
+	{ .compat = "NXP0002",
+	  .data = _type },
+
 	/* PCA9548 - 8 channel i2c switch */
 	{ .compat = "nxp,pca9548",
 	  .data = _type },
@@ -291,7 +295,7 @@ pcaiicmux_match(device_t parent, cfdata_
 	if (iic_use_direct_match(ia, cf, compat_data, _result)) {
 		return match_result;
 	}
-	
+
 	/* This device is direct-config only. */
 
 	return 0;



CVS commit: src/sys/dev/i2c

2021-01-24 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Jan 24 19:35:45 UTC 2021

Modified Files:
src/sys/dev/i2c: i2cmuxvar.h

Log Message:
trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/i2c/i2cmuxvar.h

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

Modified files:

Index: src/sys/dev/i2c/i2cmuxvar.h
diff -u src/sys/dev/i2c/i2cmuxvar.h:1.1 src/sys/dev/i2c/i2cmuxvar.h:1.2
--- src/sys/dev/i2c/i2cmuxvar.h:1.1	Mon Dec 28 20:29:57 2020
+++ src/sys/dev/i2c/i2cmuxvar.h	Sun Jan 24 19:35:45 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: i2cmuxvar.h,v 1.1 2020/12/28 20:29:57 thorpej Exp $	*/
+/*	$NetBSD: i2cmuxvar.h,v 1.2 2021/01/24 19:35:45 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -15,7 +15,7 @@
  * 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
@@ -26,15 +26,15 @@
  * 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. 
- */ 
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
 
 #ifndef _DEV_I2C_I2CMUXVAR_H_
 #define	_DEV_I2C_I2CMUXVAR_H_
 
 #include 
 
-struct iicmux_softc;  
+struct iicmux_softc;
 struct iicmux_bus;
 
 struct iicmux_config {



CVS commit: src/sys/dev/i2c

2021-01-24 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Jan 24 19:35:21 UTC 2021

Modified Files:
src/sys/dev/i2c: i2cmux.c

Log Message:
trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/i2c/i2cmux.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/i2c/i2cmux.c
diff -u src/sys/dev/i2c/i2cmux.c:1.1 src/sys/dev/i2c/i2cmux.c:1.2
--- src/sys/dev/i2c/i2cmux.c:1.1	Mon Dec 28 20:29:57 2020
+++ src/sys/dev/i2c/i2cmux.c	Sun Jan 24 19:35:21 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: i2cmux.c,v 1.1 2020/12/28 20:29:57 thorpej Exp $	*/
+/*	$NetBSD: i2cmux.c,v 1.2 2021/01/24 19:35:21 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -15,7 +15,7 @@
  * 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
@@ -26,44 +26,44 @@
  * 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. 
- */ 
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i2cmux.c,v 1.1 2020/12/28 20:29:57 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i2cmux.c,v 1.2 2021/01/24 19:35:21 jmcneill Exp $");
 
 #include 
 #include 
 #include 
-#include  
+#include 
 
 #include 
 #include 
 #include 
 
-/* 
- * i2c mux 
- * 
+/*
+ * i2c mux
+ *
  * This works by interposing a set of virtual controllers behind the real
  * i2c controller.  We provide our own acquire and release functions that
  * perform the following tasks:
- *
+ *
  *	acquire -> acquire parent controller, program mux
- * 
+ *
  *	release -> idle mux, release parent controller
- * 
+ *
  * All of the actual I/O operations are transparently passed through.
- * 
- * N.B. the locking order; the generic I2C layer has already acquired  
+ *
+ * N.B. the locking order; the generic I2C layer has already acquired
  * our virtual controller's mutex before calling our acquire function,
- * and we will then acquire the real controller's mutex when we acquire 
+ * and we will then acquire the real controller's mutex when we acquire
  * the bus, so the order is:
- * 
+ *
  *	mux virtual controller -> parent controller
  *
  * These are common routines used by various i2c mux controller
  * implementations (gpio, pin mux, i2c device, etc.).
- */ 
+ */
 
 /*/
 
@@ -141,7 +141,7 @@ iicmux_count_children(struct iicmux_soft
 /* XXX iicbus_print() should be able to do this. */
 static int
 iicmux_print(void * const aux, const char * const pnp)
-{ 
+{
 	i2c_tag_t const tag = aux;
 	struct iicmux_bus * const bus = tag->ic_cookie;
 	int rv;
@@ -152,7 +152,7 @@ iicmux_print(void * const aux, const cha
 	return rv;
 }
 
-static void 
+static void
 iicmux_attach_bus(struct iicmux_softc * const sc,
 int const phandle, int const busidx)
 {



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

2021-01-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 24 19:30:18 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: directive-for-escape.exp
directive-for-escape.mk

Log Message:
make(1): let the test directive-for-escape exit successfully

There is no reason for a non-zero exit status here.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/directive-for-escape.exp \
src/usr.bin/make/unit-tests/directive-for-escape.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-for-escape.exp
diff -u src/usr.bin/make/unit-tests/directive-for-escape.exp:1.3 src/usr.bin/make/unit-tests/directive-for-escape.exp:1.4
--- src/usr.bin/make/unit-tests/directive-for-escape.exp:1.3	Thu Dec 31 14:26:37 2020
+++ src/usr.bin/make/unit-tests/directive-for-escape.exp	Sun Jan 24 19:30:18 2021
@@ -68,7 +68,4 @@ make: "directive-for-escape.mk" line 92:
 make: "directive-for-escape.mk" line 93: . ${i2}: two
 make: "directive-for-escape.mk" line 94: . ${i,}: comma
 make: "directive-for-escape.mk" line 95: .  adjacent: innerinnerinnerinner
-make: no target to make.
-
-make: stopped in unit-tests
-exit status 2
+exit status 0
Index: src/usr.bin/make/unit-tests/directive-for-escape.mk
diff -u src/usr.bin/make/unit-tests/directive-for-escape.mk:1.3 src/usr.bin/make/unit-tests/directive-for-escape.mk:1.4
--- src/usr.bin/make/unit-tests/directive-for-escape.mk:1.3	Thu Dec 31 14:26:37 2020
+++ src/usr.bin/make/unit-tests/directive-for-escape.mk	Sun Jan 24 19:30:18 2021
@@ -1,4 +1,4 @@
-# $NetBSD: directive-for-escape.mk,v 1.3 2020/12/31 14:26:37 rillig Exp $
+# $NetBSD: directive-for-escape.mk,v 1.4 2021/01/24 19:30:18 rillig Exp $
 #
 # Test escaping of special characters in the iteration values of a .for loop.
 # These values get expanded later using the :U variable modifier, and this
@@ -94,3 +94,5 @@ i,=		comma
 .  info . $${i,}: ${i,}
 .  info .  adjacent: $i${i}${i:M*}$i
 .endfor
+
+all:



CVS commit: src/sys

2021-01-24 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Jan 24 18:02:51 UTC 2021

Modified Files:
src/sys/arch/evbarm/conf: GENERIC64
src/sys/dev/acpi: files.acpi
Added Files:
src/sys/dev/acpi: nxpiic_acpi.c

Log Message:
Add support for NXP Layerscape I2C controllers.


To generate a diff of this commit:
cvs rdiff -u -r1.174 -r1.175 src/sys/arch/evbarm/conf/GENERIC64
cvs rdiff -u -r1.119 -r1.120 src/sys/dev/acpi/files.acpi
cvs rdiff -u -r0 -r1.1 src/sys/dev/acpi/nxpiic_acpi.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/evbarm/conf/GENERIC64
diff -u src/sys/arch/evbarm/conf/GENERIC64:1.174 src/sys/arch/evbarm/conf/GENERIC64:1.175
--- src/sys/arch/evbarm/conf/GENERIC64:1.174	Thu Jan 21 17:46:28 2021
+++ src/sys/arch/evbarm/conf/GENERIC64	Sun Jan 24 18:02:51 2021
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC64,v 1.174 2021/01/21 17:46:28 nia Exp $
+#	$NetBSD: GENERIC64,v 1.175 2021/01/24 18:02:51 jmcneill Exp $
 #
 #	GENERIC ARM (aarch64) kernel
 #
@@ -301,6 +301,7 @@ bsciic*		at acpi?
 dwiic*		at fdt?			# Designware I2C
 dwiic*		at acpi?
 imxi2c*		at fdt? pass 4		# IMX I2C
+nxpiic*		at acpi?		# NXP Layerscape I2C
 rkiic*		at fdt? pass 4		# Rockchip I2C
 sunxirsb*	at fdt?	pass 4		# Allwinner RSB
 sunxitwi*	at fdt?			# Allwinner TWI

Index: src/sys/dev/acpi/files.acpi
diff -u src/sys/dev/acpi/files.acpi:1.119 src/sys/dev/acpi/files.acpi:1.120
--- src/sys/dev/acpi/files.acpi:1.119	Sun Dec 13 20:39:20 2020
+++ src/sys/dev/acpi/files.acpi	Sun Jan 24 18:02:51 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: files.acpi,v 1.119 2020/12/13 20:39:20 jmcneill Exp $
+#	$NetBSD: files.acpi,v 1.120 2021/01/24 18:02:51 jmcneill Exp $
 
 include "dev/acpi/acpica/files.acpica"
 
@@ -264,6 +264,11 @@ file	dev/acpi/plgpio_acpi.c		plgpio_acpi
 attach	dwiic at acpinodebus with dwiic_acpi
 file	dev/acpi/dwiic_acpi.c		dwiic_acpi
 
+# NXP Layerscape I2C controller
+device	nxpiic: motoi2c, i2cbus, i2cexec
+attach	nxpiic at acpinodebus with nxpiic_acpi
+file	dev/acpi/nxpiic_acpi.c		nxpiic_acpi
+
 # AMD Cryptographic Coprocessor
 attach	amdccp at acpinodebus with amdccp_acpi
 file	dev/acpi/amdccp_acpi.c		amdccp_acpi

Added files:

Index: src/sys/dev/acpi/nxpiic_acpi.c
diff -u /dev/null src/sys/dev/acpi/nxpiic_acpi.c:1.1
--- /dev/null	Sun Jan 24 18:02:51 2021
+++ src/sys/dev/acpi/nxpiic_acpi.c	Sun Jan 24 18:02:51 2021
@@ -0,0 +1,149 @@
+/* $NetBSD: nxpiic_acpi.c,v 1.1 2021/01/24 18:02:51 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2021 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jared McNeill .
+ *
+ * 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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: nxpiic_acpi.c,v 1.1 2021/01/24 18:02:51 jmcneill Exp $");
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+struct nxpiic_softc {
+	device_t		sc_dev;
+	struct motoi2c_softc	sc_motoi2c;
+};
+
+static int	nxpiic_acpi_match(device_t, cfdata_t, void *);
+static void	nxpiic_acpi_attach(device_t, device_t, void *);
+
+static uint8_t	nxpiic_acpi_iord(struct motoi2c_softc *, bus_size_t);
+static void	nxpiic_acpi_iowr(struct motoi2c_softc *, bus_size_t, uint8_t);
+
+CFATTACH_DECL_NEW(nxpiic_acpi, sizeof(struct nxpiic_softc),
+nxpiic_acpi_match, nxpiic_acpi_attach, NULL, NULL);
+
+static const char * const compatible[] = {
+	"NXP0001",
+	NULL
+};
+
+static int
+nxpiic_acpi_match(device_t parent, cfdata_t cf, void *aux)
+{
+	struct acpi_attach_args *aa = aux;
+
+	if (aa->aa_node->ad_type != ACPI_TYPE_DEVICE)
+		return 0;
+
+	

CVS commit: src/sys/dev/i2c

2021-01-24 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Jan 24 18:01:14 UTC 2021

Modified Files:
src/sys/dev/i2c: motoi2c.c motoi2cvar.h

Log Message:
Support non-FDT attachment.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/i2c/motoi2c.c
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/i2c/motoi2cvar.h

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

Modified files:

Index: src/sys/dev/i2c/motoi2c.c
diff -u src/sys/dev/i2c/motoi2c.c:1.8 src/sys/dev/i2c/motoi2c.c:1.9
--- src/sys/dev/i2c/motoi2c.c:1.8	Wed Dec 23 16:02:11 2020
+++ src/sys/dev/i2c/motoi2c.c	Sun Jan 24 18:01:13 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: motoi2c.c,v 1.8 2020/12/23 16:02:11 thorpej Exp $ */
+/* $NetBSD: motoi2c.c,v 1.9 2021/01/24 18:01:13 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2007, 2010 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: motoi2c.c,v 1.8 2020/12/23 16:02:11 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: motoi2c.c,v 1.9 2021/01/24 18:01:13 jmcneill Exp $");
 
 #if defined(__arm__) || defined(__aarch64__)
 #include "opt_fdt.h"
@@ -107,6 +107,7 @@ motoi2c_attach_common(device_t self, str
 		sc->sc_iowr = motoi2c_iowr1;
 	memset(, 0, sizeof(iba));
 	iba.iba_tag = >sc_i2c;
+	iba.iba_child_devices = sc->sc_child_devices;
 
 	I2C_WRITE(I2CCR, 0);		/* reset before changing anything */
 	I2C_WRITE(I2CDFSRR, i2c->i2c_dfsrr);	/* sampling units */
@@ -115,13 +116,13 @@ motoi2c_attach_common(device_t self, str
 	I2C_WRITE(I2CSR, 0);		/* clear status flags */
 
 #ifdef FDT
-	KASSERT(sc->sc_phandle != 0);
-	fdtbus_register_i2c_controller(>sc_i2c, sc->sc_phandle);
-
-	fdtbus_attach_i2cbus(self, sc->sc_phandle, >sc_i2c, iicbus_print);
-#else
-	config_found_ia(self, "i2cbus", , iicbus_print);
+	if (sc->sc_phandle != 0) {
+		fdtbus_register_i2c_controller(>sc_i2c, sc->sc_phandle);
+		fdtbus_attach_i2cbus(self, sc->sc_phandle, >sc_i2c,
+		iicbus_print);
+	} else
 #endif
+	config_found_ia(self, "i2cbus", , iicbus_print);
 }
 
 static int

Index: src/sys/dev/i2c/motoi2cvar.h
diff -u src/sys/dev/i2c/motoi2cvar.h:1.6 src/sys/dev/i2c/motoi2cvar.h:1.7
--- src/sys/dev/i2c/motoi2cvar.h:1.6	Sun Dec 22 23:23:32 2019
+++ src/sys/dev/i2c/motoi2cvar.h	Sun Jan 24 18:01:13 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: motoi2cvar.h,v 1.6 2019/12/22 23:23:32 thorpej Exp $ */
+/* $NetBSD: motoi2cvar.h,v 1.7 2021/01/24 18:01:13 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2007, 2010 The NetBSD Foundation, Inc.
@@ -51,6 +51,7 @@ struct motoi2c_softc {
 	motoi2c_iord_t		sc_iord;
 	motoi2c_iowr_t		sc_iowr;
 	int			sc_phandle;
+	prop_array_t		sc_child_devices;
 };
 
 #define	MOTOI2C_ADR_DEFAULT	(0x7e << 1)



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

2021-01-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 24 17:55:41 UTC 2021

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

Log Message:
lint: add test for message 325, undefined static function


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_225.c \
src/tests/usr.bin/xlint/lint1/msg_225.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_225.c
diff -u src/tests/usr.bin/xlint/lint1/msg_225.c:1.1 src/tests/usr.bin/xlint/lint1/msg_225.c:1.2
--- src/tests/usr.bin/xlint/lint1/msg_225.c:1.1	Sat Jan  2 10:22:44 2021
+++ src/tests/usr.bin/xlint/lint1/msg_225.c	Sun Jan 24 17:55:41 2021
@@ -1,7 +1,20 @@
-/*	$NetBSD: msg_225.c,v 1.1 2021/01/02 10:22:44 rillig Exp $	*/
+/*	$NetBSD: msg_225.c,v 1.2 2021/01/24 17:55:41 rillig Exp $	*/
 # 3 "msg_225.c"
 
 // Test for message: static function called but not defined: %s() [225]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+static void undefined(void);
+
+static void defined_later(void);
+
+void
+caller(void)
+{
+	undefined();		/* expect: 225 */
+	defined_later();
+}
+
+static void
+defined_later(void)
+{
+}
Index: src/tests/usr.bin/xlint/lint1/msg_225.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_225.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_225.exp:1.2
--- src/tests/usr.bin/xlint/lint1/msg_225.exp:1.1	Sat Jan  2 10:22:44 2021
+++ src/tests/usr.bin/xlint/lint1/msg_225.exp	Sun Jan 24 17:55:41 2021
@@ -1 +1 @@
-msg_225.c(6): syntax error ':' [249]
+msg_225.c(13): static function called but not defined: undefined() [225]



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

2021-01-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 24 17:44:37 UTC 2021

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

Log Message:
lint: add test for message 329, union cast with incompatible type


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_329.c \
src/tests/usr.bin/xlint/lint1/msg_329.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_329.c
diff -u src/tests/usr.bin/xlint/lint1/msg_329.c:1.1 src/tests/usr.bin/xlint/lint1/msg_329.c:1.2
--- src/tests/usr.bin/xlint/lint1/msg_329.c:1.1	Sat Jan  2 10:22:44 2021
+++ src/tests/usr.bin/xlint/lint1/msg_329.c	Sun Jan 24 17:44:37 2021
@@ -1,7 +1,40 @@
-/*	$NetBSD: msg_329.c,v 1.1 2021/01/02 10:22:44 rillig Exp $	*/
+/*	$NetBSD: msg_329.c,v 1.2 2021/01/24 17:44:37 rillig Exp $	*/
 # 3 "msg_329.c"
 
 // Test for message: type '%s' is not a member of '%s' [329]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+union u {
+	int i1;
+	int i2;
+	void *vp;
+};
+
+void
+example(void)
+{
+	/*
+	 * A type cast to a union type is valid if the source type is any
+	 * member type of the union.  Since all union members with the same
+	 * type have the same representation, the name of the union member
+	 * doesn't matter.
+	 *
+	 * XXX: could there be padding bits or other tricky details that are
+	 * settable per-member?  These could make the type alone insufficient
+	 * for determining the exact representation.
+	 *
+	 * C99 6.5.4 "Cast operators" does not mention a union cast.  On the
+	 * contrary, it says that the type name shall specify a scalar type.
+	 *
+	 * C11 6.5.4 "Cast operators" differs from C99 but still requires
+	 * scalar types for both the target type and the source value.
+	 *
+	 * This is a GCC extension.
+	 * See https://gcc.gnu.org/onlinedocs/gcc/Cast-to-Union.html.
+	 *
+	 * FIXME: lint says in message 328 that "union cast is a C9X feature",
+	 *  but that is wrong.  It is a GCC feature.
+	 */
+	union u u_i1 = (union u)3;
+	union u u_vp = (union u)(void *)0;
+	union u u_cp = (union u)(char *)0;	/* expect: 329 */
+}
Index: src/tests/usr.bin/xlint/lint1/msg_329.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_329.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_329.exp:1.2
--- src/tests/usr.bin/xlint/lint1/msg_329.exp:1.1	Sat Jan  2 10:22:44 2021
+++ src/tests/usr.bin/xlint/lint1/msg_329.exp	Sun Jan 24 17:44:37 2021
@@ -1 +1 @@
-msg_329.c(6): syntax error ':' [249]
+msg_329.c(39): type 'pointer to char' is not a member of 'union u' [329]



CVS commit: src/sys/dev/ofw

2021-01-24 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Jan 24 17:44:16 UTC 2021

Modified Files:
src/sys/dev/ofw: ofw_subr.c

Log Message:
Implement of_match_compat_data() using device_compatible_match_strlist().
Implement of_search_compatible() using device_compatible_lookup_strlist().


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/dev/ofw/ofw_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/ofw/ofw_subr.c
diff -u src/sys/dev/ofw/ofw_subr.c:1.45 src/sys/dev/ofw/ofw_subr.c:1.46
--- src/sys/dev/ofw/ofw_subr.c:1.45	Sun Jan 24 16:45:41 2021
+++ src/sys/dev/ofw/ofw_subr.c	Sun Jan 24 17:44:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofw_subr.c,v 1.45 2021/01/24 16:45:41 thorpej Exp $	*/
+/*	$NetBSD: ofw_subr.c,v 1.46 2021/01/24 17:44:16 thorpej Exp $	*/
 
 /*
  * Copyright 1998
@@ -34,10 +34,11 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.45 2021/01/24 16:45:41 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.46 2021/01/24 17:44:16 thorpej Exp $");
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -215,13 +216,25 @@ int
 of_match_compat_data(int phandle,
 const struct device_compatible_entry *compat_data)
 {
-	for (; compat_data->compat != NULL; compat_data++) {
-		const char *compat[] = { compat_data->compat, NULL };
-		const int match = of_match_compatible(phandle, compat);
-		if (match)
-			return match;
+	char *prop, propbuf[OFW_MAX_STACK_BUF_SIZE];
+	int proplen, match = 0;
+
+	proplen = OF_getproplen(phandle, "compatible");
+	if (proplen <= 0) {
+		return 0;
 	}
-	return 0;
+
+	prop = kmem_tmpbuf_alloc(proplen, propbuf, sizeof(propbuf), KM_SLEEP);
+
+	if (OF_getprop(phandle, "compatible", prop, proplen) != proplen) {
+		goto out;
+	}
+
+	match = device_compatible_match_strlist(prop, proplen, compat_data);
+
+ out:
+	kmem_tmpbuf_free(prop, proplen, propbuf);
+	return match;
 }
 
 /*
@@ -241,7 +254,7 @@ of_match_compat_data(int phandle,
  *
  * Return Value:
  *	The first matching compat_data entry in the array. If no matches
- *	are found, the NULL is returned.
+ *	are found, NULL is returned.
  *
  * Side Effects:
  *	None.
@@ -250,12 +263,26 @@ const struct device_compatible_entry *
 of_search_compatible(int phandle,
 const struct device_compatible_entry *compat_data)
 {
-	for (; compat_data->compat != NULL; compat_data++) {
-		const char *compat[] = { compat_data->compat, NULL };
-		if (of_match_compatible(phandle, compat))
-			return compat_data;
+	char *prop, propbuf[OFW_MAX_STACK_BUF_SIZE];
+	const struct device_compatible_entry *match = NULL;
+	int proplen;
+
+	proplen = OF_getproplen(phandle, "compatible");
+	if (proplen <= 0) {
+		return 0;
 	}
-	return NULL;
+
+	prop = kmem_tmpbuf_alloc(proplen, propbuf, sizeof(propbuf), KM_SLEEP);
+
+	if (OF_getprop(phandle, "compatible", prop, proplen) != proplen) {
+		goto out;
+	}
+
+	match = device_compatible_lookup_strlist(prop, proplen, compat_data);
+
+ out:
+	kmem_tmpbuf_free(prop, proplen, propbuf);
+	return match;
 }
 
 /*



CVS commit: src/sys

2021-01-24 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Jan 24 17:42:37 UTC 2021

Modified Files:
src/sys/kern: subr_autoconf.c
src/sys/sys: device.h

Log Message:
Refactor and simplify device_compatible_match(), and also provide
device_compatible_p{match,lookup}() which treats the strings in the
driver compatible data as pmatch(9) patterns.

Add device_compatible_{,p}{match,lookup}_strlist(), which are the same, but
take an OpenFirmware-style string list rather than an array of strings
for the device data.


To generate a diff of this commit:
cvs rdiff -u -r1.275 -r1.276 src/sys/kern/subr_autoconf.c
cvs rdiff -u -r1.161 -r1.162 src/sys/sys/device.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/kern/subr_autoconf.c
diff -u src/sys/kern/subr_autoconf.c:1.275 src/sys/kern/subr_autoconf.c:1.276
--- src/sys/kern/subr_autoconf.c:1.275	Mon Jan 18 15:28:21 2021
+++ src/sys/kern/subr_autoconf.c	Sun Jan 24 17:42:36 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_autoconf.c,v 1.275 2021/01/18 15:28:21 thorpej Exp $ */
+/* $NetBSD: subr_autoconf.c,v 1.276 2021/01/24 17:42:36 thorpej Exp $ */
 
 /*
  * Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.275 2021/01/18 15:28:21 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.276 2021/01/24 17:42:36 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -2324,52 +2324,179 @@ device_find_by_driver_unit(const char *n
 	return device_lookup(cd, unit);
 }
 
+static bool
+match_strcmp(const char * const s1, const char * const s2)
+{
+	return strcmp(s1, s2) == 0;
+}
+
+static bool
+match_pmatch(const char * const s1, const char * const s2)
+{
+	return pmatch(s1, s2, NULL) == 2;
+}
+
+static bool
+strarray_match_internal(const char ** const strings,
+unsigned int const nstrings, const char * const str,
+unsigned int * const indexp,
+bool (*match_fn)(const char *, const char *))
+{
+	unsigned int i;
+
+	if (strings == NULL || nstrings == 0) {
+		return 0;
+	}
+
+	for (i = 0; i < nstrings; i++) {
+		if ((*match_fn)(strings[i], str)) {
+			*indexp = i;
+			return true;
+		}
+	}
+
+	return false;
+}
+
+static int
+strarray_match(const char ** const strings, unsigned int const nstrings,
+const char * const str)
+{
+	unsigned int idx;
+
+	if (strarray_match_internal(strings, nstrings, str, ,
+match_strcmp)) {
+		return (int)(nstrings - idx);
+	}
+	return 0;
+}
+
+static int
+strarray_pmatch(const char ** const strings, unsigned int const nstrings,
+const char * const pattern)
+{
+	unsigned int idx;
+
+	if (strarray_match_internal(strings, nstrings, pattern, ,
+match_pmatch)) {
+		return (int)(nstrings - idx);
+	}
+	return 0;
+}
+
+static int
+device_compatible_match_strarray_internal(
+const char **device_compats, int ndevice_compats,
+const struct device_compatible_entry *driver_compats,
+const struct device_compatible_entry **matching_entryp,
+int (*match_fn)(const char **, unsigned int, const char *))
+{
+	const struct device_compatible_entry *dce = NULL;
+	int rv;
+
+	if (ndevice_compats == 0 || device_compats == NULL ||
+	driver_compats == NULL)
+		return 0;
+
+	for (dce = driver_compats; dce->compat != NULL; dce++) {
+		rv = (*match_fn)(device_compats, ndevice_compats, dce->compat);
+		if (rv != 0) {
+			if (matching_entryp != NULL) {
+*matching_entryp = dce;
+			}
+			return rv;
+		}
+	}
+	return 0;
+}
+
 /*
  * device_compatible_match:
  *
  *	Match a driver's "compatible" data against a device's
- *	"compatible" strings.  If a match is found, we return
- *	a weighted match result, and optionally the matching
- *	entry.
+ *	"compatible" strings.  Returns resulted weighted by
+ *	which device "compatible" string was matched.
+ */
+int
+device_compatible_match(const char **device_compats, int ndevice_compats,
+const struct device_compatible_entry *driver_compats)
+{
+	return device_compatible_match_strarray_internal(device_compats,
+	ndevice_compats, driver_compats, NULL, strarray_match);
+}
+
+/*
+ * device_compatible_pmatch:
+ *
+ *	Like device_compatible_match(), but uses pmatch(9) to compare
+ *	the device "compatible" strings against patterns in the
+ *	driver's "compatible" data.
  */
+int
+device_compatible_pmatch(const char **device_compats, int ndevice_compats,
+const struct device_compatible_entry *driver_compats)
+{
+	return device_compatible_match_strarray_internal(device_compats,
+	ndevice_compats, driver_compats, NULL, strarray_pmatch);
+}
+
 static int
-device_compatible_match_internal(const char **device_compats,
-int ndevice_compats,
+device_compatible_match_strlist_internal(
+const char * const device_compats, size_t const device_compatsize,
 const struct device_compatible_entry *driver_compats,
-const struct device_compatible_entry 

CVS commit: src

2021-01-24 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Jan 24 17:29:11 UTC 2021

Modified Files:
src/distrib/sets/lists/comp: mi
src/share/man/man9: Makefile kmem.9
src/sys/kern: subr_kmem.c
src/sys/sys: kmem.h

Log Message:
Add kmem_tmpbuf_alloc(), a utility function for allocating memory for
temporary use where allocation on the stack is desirable, but only up to
a certain size.  If the requested size fits within the specified stack
buffer, the stack buffer is returned.  Otherwise, memory is allocated with
kmem_alloc().  Add a corresponding kmem_tmpbuf_free() function that frees
the memory using kmem_free() if it is not the tempory stack buffer location.


To generate a diff of this commit:
cvs rdiff -u -r1.2372 -r1.2373 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.454 -r1.455 src/share/man/man9/Makefile
cvs rdiff -u -r1.26 -r1.27 src/share/man/man9/kmem.9
cvs rdiff -u -r1.80 -r1.81 src/sys/kern/subr_kmem.c
cvs rdiff -u -r1.11 -r1.12 src/sys/sys/kmem.h

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/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.2372 src/distrib/sets/lists/comp/mi:1.2373
--- src/distrib/sets/lists/comp/mi:1.2372	Thu Jan 21 15:53:15 2021
+++ src/distrib/sets/lists/comp/mi	Sun Jan 24 17:29:11 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.2372 2021/01/21 15:53:15 thorpej Exp $
+#	$NetBSD: mi,v 1.2373 2021/01/24 17:29:11 thorpej Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 ./etc/mtree/set.compcomp-sys-root
@@ -11650,6 +11650,8 @@
 ./usr/share/man/cat9/kmem_intr_zalloc.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/kmem_strdupsize.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/kmem_strfree.0		comp-sys-catman		.cat
+./usr/share/man/cat9/kmem_tmpbuf_alloc.0	comp-sys-catman		.cat
+./usr/share/man/cat9/kmem_tmpbuf_free.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/kmem_zalloc.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/knote.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/kpause.0			comp-sys-catman		.cat
@@ -19815,6 +19817,8 @@
 ./usr/share/man/html9/kmem_intr_zalloc.html	comp-sys-htmlman	html
 ./usr/share/man/html9/kmem_strdupsize.html	comp-sys-htmlman	html
 ./usr/share/man/html9/kmem_strfree.html		comp-sys-htmlman	html
+./usr/share/man/html9/kmem_tmpbuf_alloc.html	comp-sys-htmlman	html
+./usr/share/man/html9/kmem_tmpbuf_free.html	comp-sys-htmlman	html
 ./usr/share/man/html9/kmem_zalloc.html		comp-sys-htmlman	html
 ./usr/share/man/html9/knote.html		comp-sys-htmlman	html
 ./usr/share/man/html9/kpause.html		comp-sys-htmlman	html
@@ -28132,6 +28136,8 @@
 ./usr/share/man/man9/kmem_intr_zalloc.9		comp-sys-man		.man
 ./usr/share/man/man9/kmem_strdupsize.9		comp-sys-man		.man
 ./usr/share/man/man9/kmem_strfree.9		comp-sys-man		.man
+./usr/share/man/man9/kmem_tmpbuf_alloc.9	comp-sys-man		.man
+./usr/share/man/man9/kmem_tmpbuf_free.9		comp-sys-man		.man
 ./usr/share/man/man9/kmem_zalloc.9		comp-sys-man		.man
 ./usr/share/man/man9/knote.9			comp-sys-man		.man
 ./usr/share/man/man9/kpause.9			comp-sys-man		.man

Index: src/share/man/man9/Makefile
diff -u src/share/man/man9/Makefile:1.454 src/share/man/man9/Makefile:1.455
--- src/share/man/man9/Makefile:1.454	Thu Jan 21 15:53:16 2021
+++ src/share/man/man9/Makefile	Sun Jan 24 17:29:11 2021
@@ -1,4 +1,4 @@
-#   $NetBSD: Makefile,v 1.454 2021/01/21 15:53:16 thorpej Exp $
+#   $NetBSD: Makefile,v 1.455 2021/01/24 17:29:11 thorpej Exp $
 
 #	Makefile for section 9 (kernel function and variable) manual pages.
 
@@ -456,7 +456,9 @@ MLINKS+=kmem.9 kmem_alloc.9 \
 	kmem.9 kmem_intr_zalloc.9 \
 	kmem.9 kmem_asprintf.9 \
 	kmem.9 kmem_strdupsize.9 \
-	kmem.9 kmem_strfree.9
+	kmem.9 kmem_strfree.9 \
+	kmem.9 kmem_tmpbuf_alloc.9 \
+	kmem.9 kmem_tmpbuf_free.9
 MAN+=	kpreempt.9
 MLINKS+=kpreempt.9 kpreempt_disable.9 \
 	kpreempt.9 kpreempt_disabled.9 \

Index: src/share/man/man9/kmem.9
diff -u src/share/man/man9/kmem.9:1.26 src/share/man/man9/kmem.9:1.27
--- src/share/man/man9/kmem.9:1.26	Fri Jun 19 07:25:20 2020
+++ src/share/man/man9/kmem.9	Sun Jan 24 17:29:11 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: kmem.9,v 1.26 2020/06/19 07:25:20 wiz Exp $
+.\"	$NetBSD: kmem.9,v 1.27 2021/01/24 17:29:11 thorpej Exp $
 .\"
 .\" Copyright (c)2006 YAMAMOTO Takashi,
 .\" All rights reserved.
@@ -25,7 +25,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\" 
-.Dd June 19, 2020
+.Dd January 24, 2021
 .Dt KMEM 9
 .Os
 .\" 
@@ -73,6 +73,13 @@
 .Fn kmem_strfree \
 "char *str"
 .\" 
+.Ft void *
+.Fn kmem_tmpbuf_alloc \
+"size_t size" "void *stackbuf" "size_t stackbufsize" "km_flag_t kmflags"
+.Ft void
+.Fn kmem_tmpbuf_free \
+"void *p" "size_t size" "void *stsackbuf"
+.\" 
 

CVS commit: src

2021-01-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 24 16:55:10 UTC 2021

Modified Files:
src/tools/lint: Makefile
src/usr.bin/xlint/xlint: pathnames.h

Log Message:
lint: make path to lint data configurable

This is needed for strict bool mode, to make the custom header stdbool.h
available when lint is run as part of build.sh.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tools/lint/Makefile
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/xlint/xlint/pathnames.h

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

Modified files:

Index: src/tools/lint/Makefile
diff -u src/tools/lint/Makefile:1.6 src/tools/lint/Makefile:1.7
--- src/tools/lint/Makefile:1.6	Sun Jan 24 16:22:55 2021
+++ src/tools/lint/Makefile	Sun Jan 24 16:55:09 2021
@@ -1,9 +1,9 @@
-#	$NetBSD: Makefile,v 1.6 2021/01/24 16:22:55 rillig Exp $
+#	$NetBSD: Makefile,v 1.7 2021/01/24 16:55:09 rillig Exp $
 
 HOSTPROGNAME=	${MACHINE_GNU_PLATFORM}-lint
 HOST_SRCDIR=	usr.bin/xlint/xlint
 HOST_CPPFLAGS=	-DPATH_LIBEXEC=\"${TOOLDIR}/libexec\" \
-		-DPATH_LIBLINT=\"${TOOLDIR}/libdata/lint\" \
+		-DPATH_LINTLIB=\"${TOOLDIR}/libdata/lint\" \
 		-DTARGET_PREFIX=\"${MACHINE_GNU_PLATFORM}-\"
 
 

Index: src/usr.bin/xlint/xlint/pathnames.h
diff -u src/usr.bin/xlint/xlint/pathnames.h:1.5 src/usr.bin/xlint/xlint/pathnames.h:1.6
--- src/usr.bin/xlint/xlint/pathnames.h:1.5	Sat Jan 16 16:03:46 2021
+++ src/usr.bin/xlint/xlint/pathnames.h	Sun Jan 24 16:55:09 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pathnames.h,v 1.5 2021/01/16 16:03:46 rillig Exp $	*/
+/*	$NetBSD: pathnames.h,v 1.6 2021/01/24 16:55:09 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -40,7 +40,9 @@
 #define	PATH_USRBIN		"/usr/bin"
 
 /* default library search path */
+#ifndef PATH_LINTLIB
 #define PATH_LINTLIB		"/usr/libdata/lint"
+#endif
 
 /* overridden system headers */
 #define PATH_STRICT_BOOL_INCLUDE PATH_LINTLIB "/strict-bool"



CVS commit: src/sys/dev/ofw

2021-01-24 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Jan 24 16:45:41 UTC 2021

Modified Files:
src/sys/dev/ofw: ofw_subr.c

Log Message:
Update a comment.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/dev/ofw/ofw_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/ofw/ofw_subr.c
diff -u src/sys/dev/ofw/ofw_subr.c:1.44 src/sys/dev/ofw/ofw_subr.c:1.45
--- src/sys/dev/ofw/ofw_subr.c:1.44	Sun Jan 24 16:23:05 2021
+++ src/sys/dev/ofw/ofw_subr.c	Sun Jan 24 16:45:41 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofw_subr.c,v 1.44 2021/01/24 16:23:05 thorpej Exp $	*/
+/*	$NetBSD: ofw_subr.c,v 1.45 2021/01/24 16:45:41 thorpej Exp $	*/
 
 /*
  * Copyright 1998
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.44 2021/01/24 16:23:05 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.45 2021/01/24 16:45:41 thorpej Exp $");
 
 #include 
 #include 
@@ -241,7 +241,7 @@ of_match_compat_data(int phandle,
  *
  * Return Value:
  *	The first matching compat_data entry in the array. If no matches
- *	are found, the terminating ("compat" of NULL) record is returned.
+ *	are found, the NULL is returned.
  *
  * Side Effects:
  *	None.



CVS commit: src/sys

2021-01-24 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Jan 24 16:33:48 UTC 2021

Modified Files:
src/sys/arch/amd64/conf: GENERIC
src/sys/dev/acpi: dwiic_acpi.c

Log Message:
Attach dwiic(4) to AMD FCH I2C controllers. These busses are separate
from the SMBus that we attach to piixpm(4) today, and support direct
config via ACPI.


To generate a diff of this commit:
cvs rdiff -u -r1.582 -r1.583 src/sys/arch/amd64/conf/GENERIC
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/acpi/dwiic_acpi.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/amd64/conf/GENERIC
diff -u src/sys/arch/amd64/conf/GENERIC:1.582 src/sys/arch/amd64/conf/GENERIC:1.583
--- src/sys/arch/amd64/conf/GENERIC:1.582	Wed Jan 20 13:22:08 2021
+++ src/sys/arch/amd64/conf/GENERIC	Sun Jan 24 16:33:48 2021
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.582 2021/01/20 13:22:08 nia Exp $
+# $NetBSD: GENERIC,v 1.583 2021/01/24 16:33:48 jmcneill Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.582 $"
+#ident		"GENERIC-$Revision: 1.583 $"
 
 maxusers	64		# estimated number of users
 
@@ -545,8 +545,9 @@ iic*	at ichsmb?
 ismt* at pci? dev ? function ?
 iic*	at ismt?
 
-# I2C controller as found in some Intel PCH devices.
-dwiic*		at pci?			# I2C controller
+# DesignWare I2C controller as found in some Intel PCH and AMD FCH devices.
+dwiic*		at acpi?		# DesignWare I2C controller
+dwiic*		at pci?			# DesignWare I2C controller
 iic*		at dwiic?
 
 # Thermal monitor and fan controller

Index: src/sys/dev/acpi/dwiic_acpi.c
diff -u src/sys/dev/acpi/dwiic_acpi.c:1.4 src/sys/dev/acpi/dwiic_acpi.c:1.5
--- src/sys/dev/acpi/dwiic_acpi.c:1.4	Mon Dec  7 10:02:51 2020
+++ src/sys/dev/acpi/dwiic_acpi.c	Sun Jan 24 16:33:48 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: dwiic_acpi.c,v 1.4 2020/12/07 10:02:51 jmcneill Exp $ */
+/* $NetBSD: dwiic_acpi.c,v 1.5 2021/01/24 16:33:48 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dwiic_acpi.c,v 1.4 2020/12/07 10:02:51 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwiic_acpi.c,v 1.5 2021/01/24 16:33:48 jmcneill Exp $");
 
 #include 
 #include 
@@ -60,6 +60,8 @@ static void	dwiic_acpi_configure(struct 
 CFATTACH_DECL_NEW(dwiic_acpi, sizeof(struct dwiic_softc), dwiic_acpi_match, dwiic_acpi_attach, NULL, NULL);
 
 static const char * const compatible[] = {
+	"AMD0010",	/* AMD FCH */
+	"AMDI0010",	/* AMD FCH */
 	"AMDI0510",	/* AMD Seattle */
 	"APMC0D0F",	/* Ampere eMAG */
 	NULL



CVS commit: src/sys

2021-01-24 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Jan 24 16:23:06 UTC 2021

Modified Files:
src/sys/arch/arm/sunxi: sunxi_sramc.c
src/sys/dev/ofw: ofw_subr.c

Log Message:
Change of_search_compable() to return NULL on no-match, which is much more
sensible than the previous behavior.  As such, back out rev 1.7 of
sunxi_sramc.c.  All other of_search_compable() call sites have been audited.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/sunxi/sunxi_sramc.c
cvs rdiff -u -r1.43 -r1.44 src/sys/dev/ofw/ofw_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/arch/arm/sunxi/sunxi_sramc.c
diff -u src/sys/arch/arm/sunxi/sunxi_sramc.c:1.7 src/sys/arch/arm/sunxi/sunxi_sramc.c:1.8
--- src/sys/arch/arm/sunxi/sunxi_sramc.c:1.7	Wed Jan 20 00:48:49 2021
+++ src/sys/arch/arm/sunxi/sunxi_sramc.c	Sun Jan 24 16:23:06 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_sramc.c,v 1.7 2021/01/20 00:48:49 jmcneill Exp $ */
+/* $NetBSD: sunxi_sramc.c,v 1.8 2021/01/24 16:23:06 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_sramc.c,v 1.7 2021/01/20 00:48:49 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_sramc.c,v 1.8 2021/01/24 16:23:06 thorpej Exp $");
 
 #include 
 #include 
@@ -127,7 +127,7 @@ sunxi_sramc_init_mmio(struct sunxi_sramc
 
 	for (child = OF_child(phandle); child; child = OF_peer(child)) {
 		dce = of_search_compatible(child, sunxi_sramc_areas);
-		if (dce->data != NULL) {
+		if (dce != NULL) {
 			node = kmem_alloc(sizeof(*node), KM_SLEEP);
 			node->phandle = child;
 			node->area = dce->data;

Index: src/sys/dev/ofw/ofw_subr.c
diff -u src/sys/dev/ofw/ofw_subr.c:1.43 src/sys/dev/ofw/ofw_subr.c:1.44
--- src/sys/dev/ofw/ofw_subr.c:1.43	Wed Jan 20 00:41:15 2021
+++ src/sys/dev/ofw/ofw_subr.c	Sun Jan 24 16:23:05 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofw_subr.c,v 1.43 2021/01/20 00:41:15 jmcneill Exp $	*/
+/*	$NetBSD: ofw_subr.c,v 1.44 2021/01/24 16:23:05 thorpej Exp $	*/
 
 /*
  * Copyright 1998
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.43 2021/01/20 00:41:15 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.44 2021/01/24 16:23:05 thorpej Exp $");
 
 #include 
 #include 
@@ -253,9 +253,9 @@ of_search_compatible(int phandle,
 	for (; compat_data->compat != NULL; compat_data++) {
 		const char *compat[] = { compat_data->compat, NULL };
 		if (of_match_compatible(phandle, compat))
-			break;
+			return compat_data;
 	}
-	return compat_data;
+	return NULL;
 }
 
 /*



CVS commit: src/tools/lint

2021-01-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 24 16:22:55 UTC 2021

Modified Files:
src/tools/lint: Makefile

Log Message:
lint: fix path to installed stdbool.h for strict bool mode


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tools/lint/Makefile

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

Modified files:

Index: src/tools/lint/Makefile
diff -u src/tools/lint/Makefile:1.5 src/tools/lint/Makefile:1.6
--- src/tools/lint/Makefile:1.5	Sun Jan 24 15:43:09 2021
+++ src/tools/lint/Makefile	Sun Jan 24 16:22:55 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.5 2021/01/24 15:43:09 christos Exp $
+#	$NetBSD: Makefile,v 1.6 2021/01/24 16:22:55 rillig Exp $
 
 HOSTPROGNAME=	${MACHINE_GNU_PLATFORM}-lint
 HOST_SRCDIR=	usr.bin/xlint/xlint
@@ -11,9 +11,9 @@ HOST_CPPFLAGS=	-DPATH_LIBEXEC=\"${TOOLDI
 
 STDBOOL_H=${NETBSDSRCDIR}/${HOST_SRCDIR}/strict-bool-stdbool.h
 
-install: ${TOOLDIR}/libdata/lint/stdbool.h
+install: ${TOOLDIR}/libdata/lint/strict-bool/stdbool.h
 
-${TOOLDIR}/libdata/lint/stdbool.h:: ${STDBOOL_H}
+${TOOLDIR}/libdata/lint/strict-bool/stdbool.h:: ${STDBOOL_H}
 	${_MKTARGET_INSTALL}
-	mkdir -p ${TOOLDIR}/libdata/lint
+	mkdir -p ${.TARGET:H}
 	${HOST_INSTALL_FILE} -m ${NONBINMODE} ${STDBOOL_H} ${.TARGET}



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

2021-01-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 24 16:12:45 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_168.c msg_168.exp msg_171.c
msg_171.exp msg_175.c msg_175.exp msg_177.c msg_177.exp msg_178.c
msg_178.exp

Log Message:
lint: add tests for a few messages


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_168.c \
src/tests/usr.bin/xlint/lint1/msg_168.exp \
src/tests/usr.bin/xlint/lint1/msg_171.c \
src/tests/usr.bin/xlint/lint1/msg_171.exp \
src/tests/usr.bin/xlint/lint1/msg_175.c \
src/tests/usr.bin/xlint/lint1/msg_175.exp \
src/tests/usr.bin/xlint/lint1/msg_177.c \
src/tests/usr.bin/xlint/lint1/msg_177.exp \
src/tests/usr.bin/xlint/lint1/msg_178.c \
src/tests/usr.bin/xlint/lint1/msg_178.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_168.c
diff -u src/tests/usr.bin/xlint/lint1/msg_168.c:1.1 src/tests/usr.bin/xlint/lint1/msg_168.c:1.2
--- src/tests/usr.bin/xlint/lint1/msg_168.c:1.1	Sat Jan  2 10:22:43 2021
+++ src/tests/usr.bin/xlint/lint1/msg_168.c	Sun Jan 24 16:12:45 2021
@@ -1,7 +1,29 @@
-/*	$NetBSD: msg_168.c,v 1.1 2021/01/02 10:22:43 rillig Exp $	*/
+/*	$NetBSD: msg_168.c,v 1.2 2021/01/24 16:12:45 rillig Exp $	*/
 # 3 "msg_168.c"
 
 // Test for message: array subscript cannot be > %d: %ld [168]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+void print_string(const char *);
+void print_char(char);
+
+void
+example(void)
+{
+	char buf[20] = {};
+
+	print_string(buf + 19);	/* inside the array */
+
+	/*
+	 * It is valid to point at the end of the array, but reading a
+	 * character from there invokes undefined behavior.
+	 *
+	 * The pointer to the end of the array is typically used in (begin,
+	 * end) tuples.  These are more common in C++ than in C though.
+	 */
+	print_string(buf + 20);
+
+	print_string(buf + 21);	/* undefined behavior, not detected */
+
+	print_char(buf[19]);
+	print_char(buf[20]);	/* expect: 168 */
+}
Index: src/tests/usr.bin/xlint/lint1/msg_168.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_168.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_168.exp:1.2
--- src/tests/usr.bin/xlint/lint1/msg_168.exp:1.1	Sat Jan  2 10:22:43 2021
+++ src/tests/usr.bin/xlint/lint1/msg_168.exp	Sun Jan 24 16:12:45 2021
@@ -1 +1 @@
-msg_168.c(6): syntax error ':' [249]
+msg_168.c(28): warning: array subscript cannot be > 19: 20 [168]
Index: src/tests/usr.bin/xlint/lint1/msg_171.c
diff -u src/tests/usr.bin/xlint/lint1/msg_171.c:1.1 src/tests/usr.bin/xlint/lint1/msg_171.c:1.2
--- src/tests/usr.bin/xlint/lint1/msg_171.c:1.1	Sat Jan  2 10:22:43 2021
+++ src/tests/usr.bin/xlint/lint1/msg_171.c	Sun Jan 24 16:12:45 2021
@@ -1,7 +1,19 @@
-/*	$NetBSD: msg_171.c,v 1.1 2021/01/02 10:22:43 rillig Exp $	*/
+/*	$NetBSD: msg_171.c,v 1.2 2021/01/24 16:12:45 rillig Exp $	*/
 # 3 "msg_171.c"
 
 // Test for message: assignment type mismatch (%s != %s) [171]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+struct s {
+	int member;
+};
+
+/*ARGSUSED*/
+void
+example(int i, void *vp, struct s *s)
+{
+	i = *s;			/* expect: 171 */
+	*s = i;			/* expect: 171 */
+
+	vp = *s;		/* expect: 171 */
+	*s = vp;		/* expect: 171 */
+}
Index: src/tests/usr.bin/xlint/lint1/msg_171.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_171.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_171.exp:1.2
--- src/tests/usr.bin/xlint/lint1/msg_171.exp:1.1	Sat Jan  2 10:22:43 2021
+++ src/tests/usr.bin/xlint/lint1/msg_171.exp	Sun Jan 24 16:12:45 2021
@@ -1 +1,4 @@
-msg_171.c(6): syntax error ':' [249]
+msg_171.c(14): assignment type mismatch (int != struct) [171]
+msg_171.c(15): assignment type mismatch (struct != int) [171]
+msg_171.c(17): assignment type mismatch (pointer != struct) [171]
+msg_171.c(18): assignment type mismatch (struct != pointer) [171]
Index: src/tests/usr.bin/xlint/lint1/msg_175.c
diff -u src/tests/usr.bin/xlint/lint1/msg_175.c:1.1 src/tests/usr.bin/xlint/lint1/msg_175.c:1.2
--- src/tests/usr.bin/xlint/lint1/msg_175.c:1.1	Sat Jan  2 10:22:43 2021
+++ src/tests/usr.bin/xlint/lint1/msg_175.c	Sun Jan 24 16:12:45 2021
@@ -1,7 +1,10 @@
-/*	$NetBSD: msg_175.c,v 1.1 2021/01/02 10:22:43 rillig Exp $	*/
+/*	$NetBSD: msg_175.c,v 1.2 2021/01/24 16:12:45 rillig Exp $	*/
 # 3 "msg_175.c"
 
 // Test for message: initialisation of an incomplete type [175]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+struct incomplete;			/* expect: 233 */
+
+struct incomplete incomplete = {	/* expect: 175 */
+	"invalid"
+};	/* expect: 31 */
Index: src/tests/usr.bin/xlint/lint1/msg_175.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_175.exp:1.1 

CVS commit: src/sys/dev/pci

2021-01-24 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Sun Jan 24 15:59:35 UTC 2021

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

Log Message:
Remove incorrect comment. It would violate the specs.

VirtIO PCI v1.0 attachments can only happen on revision 1 devices as they have
a radical different register layout. Transitional devices have to use revision
0 and have to use the VirtIO PCI v0.9 attachment method but can allow for
features to be negotiated normally found in later versions.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/dev/pci/virtio_pci.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/virtio_pci.c
diff -u src/sys/dev/pci/virtio_pci.c:1.24 src/sys/dev/pci/virtio_pci.c:1.25
--- src/sys/dev/pci/virtio_pci.c:1.24	Sun Jan 24 15:34:07 2021
+++ src/sys/dev/pci/virtio_pci.c	Sun Jan 24 15:59:35 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: virtio_pci.c,v 1.24 2021/01/24 15:34:07 thorpej Exp $ */
+/* $NetBSD: virtio_pci.c,v 1.25 2021/01/24 15:59:35 reinoud Exp $ */
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.24 2021/01/24 15:34:07 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.25 2021/01/24 15:59:35 reinoud Exp $");
 
 #include 
 #include 
@@ -461,12 +461,6 @@ virtio_pci_attach_10(device_t self, void
 	else
 		have_device_cfg = 1;
 
-	/*
-	 * XXX Maybe there are devices that offer the pci caps but not the
-	 * XXX VERSION_1 feature bit? Then we should check the feature bit
-	 * XXX here and fall back to 0.9 out if not present.
-	 */
-
 	/* Figure out which bars we need to map */
 	for (i = 0; i < __arraycount(caps); i++) {
 		int bar = caps[i]->bar;



CVS commit: src/tools/lint

2021-01-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan 24 15:43:09 UTC 2021

Modified Files:
src/tools/lint: Makefile

Log Message:
Install lint's custom stdbool.h and make lint search for it in the right place.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tools/lint/Makefile

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

Modified files:

Index: src/tools/lint/Makefile
diff -u src/tools/lint/Makefile:1.4 src/tools/lint/Makefile:1.5
--- src/tools/lint/Makefile:1.4	Mon Nov 12 18:16:28 2001
+++ src/tools/lint/Makefile	Sun Jan 24 10:43:09 2021
@@ -1,8 +1,19 @@
-#	$NetBSD: Makefile,v 1.4 2001/11/12 23:16:28 tv Exp $
+#	$NetBSD: Makefile,v 1.5 2021/01/24 15:43:09 christos Exp $
 
 HOSTPROGNAME=	${MACHINE_GNU_PLATFORM}-lint
 HOST_SRCDIR=	usr.bin/xlint/xlint
 HOST_CPPFLAGS=	-DPATH_LIBEXEC=\"${TOOLDIR}/libexec\" \
+		-DPATH_LIBLINT=\"${TOOLDIR}/libdata/lint\" \
 		-DTARGET_PREFIX=\"${MACHINE_GNU_PLATFORM}-\"
 
+
 .include "${.CURDIR}/../Makefile.host"
+
+STDBOOL_H=${NETBSDSRCDIR}/${HOST_SRCDIR}/strict-bool-stdbool.h
+
+install: ${TOOLDIR}/libdata/lint/stdbool.h
+
+${TOOLDIR}/libdata/lint/stdbool.h:: ${STDBOOL_H}
+	${_MKTARGET_INSTALL}
+	mkdir -p ${TOOLDIR}/libdata/lint
+	${HOST_INSTALL_FILE} -m ${NONBINMODE} ${STDBOOL_H} ${.TARGET}



CVS commit: src/sys/dev/fdt

2021-01-24 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Jan 24 15:43:23 UTC 2021

Modified Files:
src/sys/dev/fdt: fdt_subr.c

Log Message:
Use strlist(9).


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/dev/fdt/fdt_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/fdt/fdt_subr.c
diff -u src/sys/dev/fdt/fdt_subr.c:1.38 src/sys/dev/fdt/fdt_subr.c:1.39
--- src/sys/dev/fdt/fdt_subr.c:1.38	Thu Jul 16 16:39:18 2020
+++ src/sys/dev/fdt/fdt_subr.c	Sun Jan 24 15:43:22 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_subr.c,v 1.38 2020/07/16 16:39:18 jmcneill Exp $ */
+/* $NetBSD: fdt_subr.c,v 1.39 2021/01/24 15:43:22 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdt_subr.c,v 1.38 2020/07/16 16:39:18 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_subr.c,v 1.39 2021/01/24 15:43:22 thorpej Exp $");
 
 #include "opt_fdt.h"
 
@@ -502,42 +502,31 @@ fdtbus_get_string(int phandle, const cha
 const char *
 fdtbus_get_string_index(int phandle, const char *prop, u_int index)
 {
-	const char *names, *name;
-	int len, cur;
+	const char *names;
+	int len;
 
 	if ((len = OF_getproplen(phandle, prop)) < 0)
 		return NULL;
 
 	names = fdtbus_get_string(phandle, prop);
 
-	for (name = names, cur = 0; len > 0;
-	 len -= strlen(name) + 1, name += strlen(name) + 1, cur++) {
-		if (index == cur)
-			return name;
-	}
-
-	return NULL;
+	return strlist_string(names, len, index);
 }
 
 int
 fdtbus_get_index(int phandle, const char *prop, const char *name, u_int *idx)
 {
 	const char *p;
-	size_t pl;
-	u_int index;
-	int len;
+	int len, index;
 
 	p = fdtbus_get_prop(phandle, prop, );
 	if (p == NULL || len <= 0)
 		return -1;
 
-	for (index = 0; len > 0;
-	pl = strlen(p) + 1, len -= pl, p += pl, index++) {
-		if (strcmp(p, name) == 0) {
-			*idx = index;
-			return 0;
-		}
-	}
+	index = strlist_index(p, len, name);
+	if (index == -1)
+		return -1;
 
-	return -1;
+	*idx = index;
+	return 0;
 }



CVS commit: src/sys/dev/pci

2021-01-24 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Jan 24 15:34:08 UTC 2021

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

Log Message:
Redefining bus_space functions in drivers is a bad idea, and we just
should't be in the habit of doing so.  Besides, the previous "solutions"
still did not compile correctly, and this does, so let's be done with
this nonsense, shall we?


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/dev/pci/virtio_pci.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/virtio_pci.c
diff -u src/sys/dev/pci/virtio_pci.c:1.23 src/sys/dev/pci/virtio_pci.c:1.24
--- src/sys/dev/pci/virtio_pci.c:1.23	Sun Jan 24 15:33:02 2021
+++ src/sys/dev/pci/virtio_pci.c	Sun Jan 24 15:34:07 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: virtio_pci.c,v 1.23 2021/01/24 15:33:02 reinoud Exp $ */
+/* $NetBSD: virtio_pci.c,v 1.24 2021/01/24 15:34:07 thorpej Exp $ */
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.23 2021/01/24 15:33:02 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.24 2021/01/24 15:34:07 thorpej Exp $");
 
 #include 
 #include 
@@ -738,19 +738,19 @@ virtio_pci_read_queue_size_10(struct vir
 /*
  * By definition little endian only in v1.0 and 8 byters are allowed to be
  * written as two 4 byters
- */
-#ifndef __HAVE_BUS_SPACE_8
-/*
+ *
  * This is not a general purpose function that can be used in any
  * driver. Virtio specifically allows the 8 byte bus transaction
  * to be split into two 4 byte transactions. Do not copy/use it
  * in other device drivers unless you know that the device accepts it.
  */
 static __inline void
-bus_space_write_8(bus_space_tag_t iot, bus_space_handle_t ioh,
+virtio_pci_bus_space_write_8(bus_space_tag_t iot, bus_space_handle_t ioh,
  bus_size_t offset, uint64_t value)
 {
-#if _QUAD_HIGHWORD
+#if defined(__HAVE_BUS_SPACE_8)
+	bus_space_write_8(iot, ioh, offset, value);
+#elif _QUAD_HIGHWORD
 	bus_space_write_4(iot, ioh, offset, BUS_ADDR_LO32(value));
 	bus_space_write_4(iot, ioh, offset + 4, BUS_ADDR_HI32(value));
 #else
@@ -758,7 +758,6 @@ bus_space_write_8(bus_space_tag_t iot, b
 	bus_space_write_4(iot, ioh, offset + 4, BUS_ADDR_LO32(value));
 #endif
 }
-#endif
 
 static void
 virtio_pci_setup_queue_10(struct virtio_softc *sc, uint16_t idx, uint64_t addr)
@@ -772,15 +771,18 @@ virtio_pci_setup_queue_10(struct virtio_
 	bus_space_write_2(iot, ioh, VIRTIO_CONFIG1_QUEUE_SELECT, vq->vq_index);
 	if (addr == 0) {
 		bus_space_write_2(iot, ioh, VIRTIO_CONFIG1_QUEUE_ENABLE, 0);
-		bus_space_write_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_DESC,   0);
-		bus_space_write_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_AVAIL,  0);
-		bus_space_write_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_USED,   0);
+		virtio_pci_bus_space_write_8(iot, ioh,
+		VIRTIO_CONFIG1_QUEUE_DESC,   0);
+		virtio_pci_bus_space_write_8(iot, ioh,
+		VIRTIO_CONFIG1_QUEUE_AVAIL,  0);
+		virtio_pci_bus_space_write_8(iot, ioh,
+		VIRTIO_CONFIG1_QUEUE_USED,   0);
 	} else {
-		bus_space_write_8(iot, ioh,
+		virtio_pci_bus_space_write_8(iot, ioh,
 			VIRTIO_CONFIG1_QUEUE_DESC, addr);
-		bus_space_write_8(iot, ioh,
+		virtio_pci_bus_space_write_8(iot, ioh,
 			VIRTIO_CONFIG1_QUEUE_AVAIL, addr + vq->vq_availoffset);
-		bus_space_write_8(iot, ioh,
+		virtio_pci_bus_space_write_8(iot, ioh,
 			VIRTIO_CONFIG1_QUEUE_USED, addr + vq->vq_usedoffset);
 		bus_space_write_2(iot, ioh,
 			VIRTIO_CONFIG1_QUEUE_ENABLE, 1);



CVS commit: src/sys/dev/pci

2021-01-24 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Sun Jan 24 15:33:02 UTC 2021

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

Log Message:
On error unmap the pci_mapreg_map()d regions using bus_space_unmap() as
suggested by jak@


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/pci/virtio_pci.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/virtio_pci.c
diff -u src/sys/dev/pci/virtio_pci.c:1.22 src/sys/dev/pci/virtio_pci.c:1.23
--- src/sys/dev/pci/virtio_pci.c:1.22	Sun Jan 24 14:33:49 2021
+++ src/sys/dev/pci/virtio_pci.c	Sun Jan 24 15:33:02 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: virtio_pci.c,v 1.22 2021/01/24 14:33:49 reinoud Exp $ */
+/* $NetBSD: virtio_pci.c,v 1.23 2021/01/24 15:33:02 reinoud Exp $ */
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.22 2021/01/24 14:33:49 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.23 2021/01/24 15:33:02 reinoud Exp $");
 
 #include 
 #include 
@@ -555,7 +555,13 @@ virtio_pci_attach_10(device_t self, void
 	return 0;
 
 err:
-	/* there is no pci_mapreg_unmap() */
+	/* undo our pci_mapreg_map()s */ 
+	for (i = 0; i < __arraycount(bars); i++) {
+		if (bars[i] == 0)
+			continue;
+		bus_space_unmap(psc->sc_bars_iot[j], psc->sc_bars_ioh[j],
+psc->sc_bars_iosize[j]);
+	}
 	return ret;
 }
 



CVS commit: src/sys/arch/arm/arm32

2021-01-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Jan 24 14:51:01 UTC 2021

Modified Files:
src/sys/arch/arm/arm32: pmap.c

Log Message:
More debug


To generate a diff of this commit:
cvs rdiff -u -r1.422 -r1.423 src/sys/arch/arm/arm32/pmap.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/arm/arm32/pmap.c
diff -u src/sys/arch/arm/arm32/pmap.c:1.422 src/sys/arch/arm/arm32/pmap.c:1.423
--- src/sys/arch/arm/arm32/pmap.c:1.422	Fri Oct 30 18:54:36 2020
+++ src/sys/arch/arm/arm32/pmap.c	Sun Jan 24 14:51:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.422 2020/10/30 18:54:36 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.423 2021/01/24 14:51:01 skrll Exp $	*/
 
 /*
  * Copyright 2003 Wasabi Systems, Inc.
@@ -192,7 +192,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.422 2020/10/30 18:54:36 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.423 2021/01/24 14:51:01 skrll Exp $");
 
 #include 
 #include 
@@ -3154,6 +3154,10 @@ pmap_enter(pmap_t pm, vaddr_t va, paddr_
 		struct vm_page_md *md = (pg != NULL) ? VM_PAGE_TO_MD(pg) :
 		PMAP_PAGE_TO_MD(pp);
 
+		UVMHIST_LOG(maphist, "  pg %#jx pp %#jx pvh_attrs %#jx "
+		"nflags %#jx", (uintptr_t)pg, (uintptr_t)pp,
+		md->pvh_attrs, nflags);
+
 		/*
 		 * This is to be a managed mapping.
 		 */



CVS commit: src/usr.bin/xlint

2021-01-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 24 14:47:43 UTC 2021

Modified Files:
src/usr.bin/xlint/arch/aarch64: targparam.h
src/usr.bin/xlint/arch/alpha: targparam.h
src/usr.bin/xlint/arch/arm: targparam.h
src/usr.bin/xlint/arch/coldfire: targparam.h
src/usr.bin/xlint/arch/hppa: targparam.h
src/usr.bin/xlint/arch/i386: targparam.h
src/usr.bin/xlint/arch/ia64: targparam.h
src/usr.bin/xlint/arch/m68000: targparam.h
src/usr.bin/xlint/arch/m68k: targparam.h
src/usr.bin/xlint/arch/mips: targparam.h
src/usr.bin/xlint/arch/mips64: targparam.h
src/usr.bin/xlint/arch/or1k: targparam.h
src/usr.bin/xlint/arch/powerpc: targparam.h
src/usr.bin/xlint/arch/powerpc64: targparam.h
src/usr.bin/xlint/arch/riscv32: targparam.h
src/usr.bin/xlint/arch/riscv64: targparam.h
src/usr.bin/xlint/arch/sh3: targparam.h
src/usr.bin/xlint/arch/sparc: targparam.h
src/usr.bin/xlint/arch/sparc64: targparam.h
src/usr.bin/xlint/arch/vax: targparam.h
src/usr.bin/xlint/arch/x86_64: targparam.h
src/usr.bin/xlint/common: inittyp.c
src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: reduce preprocessor magic for platform target types


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/xlint/arch/aarch64/targparam.h
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/xlint/arch/alpha/targparam.h
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/xlint/arch/arm/targparam.h
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/xlint/arch/coldfire/targparam.h
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/xlint/arch/hppa/targparam.h
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/xlint/arch/i386/targparam.h
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/xlint/arch/ia64/targparam.h
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/xlint/arch/m68000/targparam.h
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/xlint/arch/m68k/targparam.h
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/xlint/arch/mips/targparam.h
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/xlint/arch/mips64/targparam.h
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/xlint/arch/or1k/targparam.h
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/xlint/arch/powerpc/targparam.h
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/xlint/arch/powerpc64/targparam.h
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/xlint/arch/riscv32/targparam.h
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/xlint/arch/riscv64/targparam.h
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/xlint/arch/sh3/targparam.h
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/xlint/arch/sparc/targparam.h
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/xlint/arch/sparc64/targparam.h
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/xlint/arch/vax/targparam.h
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/xlint/arch/x86_64/targparam.h
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/xlint/common/inittyp.c
cvs rdiff -u -r1.190 -r1.191 src/usr.bin/xlint/lint1/tree.c

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

Modified files:

Index: src/usr.bin/xlint/arch/aarch64/targparam.h
diff -u src/usr.bin/xlint/arch/aarch64/targparam.h:1.3 src/usr.bin/xlint/arch/aarch64/targparam.h:1.4
--- src/usr.bin/xlint/arch/aarch64/targparam.h:1.3	Sat Jan  9 14:10:12 2021
+++ src/usr.bin/xlint/arch/aarch64/targparam.h	Sun Jan 24 14:47:40 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: targparam.h,v 1.3 2021/01/09 14:10:12 rillig Exp $ */
+/* $NetBSD: targparam.h,v 1.4 2021/01/24 14:47:40 rillig Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -41,9 +41,9 @@
  * kept in sync with the compiler!
  */
 
-#define	PTRDIFF_IS_LONG		1
-#define	SIZEOF_IS_ULONG		1
-#define INTPTR_IS_LONG		1
+#define	PTRDIFF_TSPEC		LONG
+#define	SIZEOF_TSPEC		ULONG
+#define INTPTR_TSPEC		LONG
 
 #define	FLOAT_SIZE		32
 #define	DOUBLE_SIZE		64

Index: src/usr.bin/xlint/arch/alpha/targparam.h
diff -u src/usr.bin/xlint/arch/alpha/targparam.h:1.6 src/usr.bin/xlint/arch/alpha/targparam.h:1.7
--- src/usr.bin/xlint/arch/alpha/targparam.h:1.6	Sat Jan  9 14:10:12 2021
+++ src/usr.bin/xlint/arch/alpha/targparam.h	Sun Jan 24 14:47:40 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: targparam.h,v 1.6 2021/01/09 14:10:12 rillig Exp $	*/
+/*	$NetBSD: targparam.h,v 1.7 2021/01/24 14:47:40 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -43,9 +43,9 @@
  * kept in sync with the compiler!
  */
 
-#define	PTRDIFF_IS_LONG		1
-#define	SIZEOF_IS_ULONG		1
-#define INTPTR_IS_LONG		1
+#define	PTRDIFF_TSPEC		LONG
+#define	SIZEOF_TSPEC		ULONG
+#define INTPTR_TSPEC		LONG
 
 #define	FLOAT_SIZE		32
 #define	DOUBLE_SIZE		64

Index: src/usr.bin/xlint/arch/arm/targparam.h
diff -u src/usr.bin/xlint/arch/arm/targparam.h:1.7 src/usr.bin/xlint/arch/arm/targparam.h:1.8
--- src/usr.bin/xlint/arch/arm/targparam.h:1.7	Sat Jan  9 14:10:12 2021
+++ src/usr.bin/xlint/arch/arm/targparam.h	Sun Jan 24 14:47:41 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: targparam.h,v 1.7 2021/01/09 14:10:12 rillig Exp $	*/
+/*	$NetBSD: targparam.h,v 1.8 2021/01/24 14:47:41 rillig Exp $	*/
 
 /*
  

CVS commit: src/usr.sbin/fstyp

2021-01-24 Thread Tomohiro Kusumi
Module Name:src
Committed By:   tkusumi
Date:   Sun Jan 24 14:37:32 UTC 2021

Modified Files:
src/usr.sbin/fstyp: exfat.c

Log Message:
fstyp: Fix exfat detection

taken-from FreeBSD ddf61156132b610915325769cbb93ea11be0d433


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/fstyp/exfat.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.sbin/fstyp/exfat.c
diff -u src/usr.sbin/fstyp/exfat.c:1.3 src/usr.sbin/fstyp/exfat.c:1.4
--- src/usr.sbin/fstyp/exfat.c:1.3	Sat Feb  8 12:56:56 2020
+++ src/usr.sbin/fstyp/exfat.c	Sun Jan 24 14:37:32 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: exfat.c,v 1.3 2020/02/08 12:56:56 fox Exp $	*/
+/*	$NetBSD: exfat.c,v 1.4 2021/01/24 14:37:32 tkusumi Exp $	*/
 
 /*
  * Copyright (c) 2017 Conrad Meyer 
@@ -26,7 +26,7 @@
  * SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: exfat.c,v 1.3 2020/02/08 12:56:56 fox Exp $");
+__RCSID("$NetBSD: exfat.c,v 1.4 2021/01/24 14:37:32 tkusumi Exp $");
 
 #include 
 #include 
@@ -327,15 +327,15 @@ fstyp_exfat(FILE *fp, char *label, size_
 	uint32_t chksum;
 	int error;
 
+	error = 1;
 	cksect = NULL;
-
 	ev = (struct exfat_vbr *)read_buf(fp, 0, 512);
 	if (ev == NULL || strncmp(ev->ev_fsname, "EXFAT   ", 8) != 0)
-		goto fail;
+		goto out;
 
 	if (ev->ev_log_bytes_per_sect < 9 || ev->ev_log_bytes_per_sect > 12) {
 		warnx("exfat: Invalid BytesPerSectorShift");
-		goto done;
+		goto out;
 	}
 
 	bytespersec = (1u << ev->ev_log_bytes_per_sect);
@@ -343,7 +343,7 @@ fstyp_exfat(FILE *fp, char *label, size_
 	error = exfat_compute_boot_chksum(fp, MAIN_BOOT_REGION_SECT,
 	bytespersec, );
 	if (error != 0)
-		goto done;
+		goto out;
 
 	cksect = read_sect(fp, MAIN_BOOT_REGION_SECT + SUBREGION_CHKSUM_SECT,
 	bytespersec);
@@ -355,18 +355,15 @@ fstyp_exfat(FILE *fp, char *label, size_
 	if (chksum != le32toh(cksect[0])) {
 		warnx("exfat: Found checksum 0x%08x != computed 0x%08x",
 		le32toh(cksect[0]), chksum);
-		goto done;
+		error = 1;
+		goto out;
 	}
 
 	if (show_label)
 		exfat_find_label(fp, ev, bytespersec, label, size);
 
-done:
+out:
 	free(cksect);
 	free(ev);
-	return (0);
-
-fail:
-	free(ev);
-	return (1);
+	return (error != 0);
 }



CVS commit: src/sys/dev/pci

2021-01-24 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Sun Jan 24 14:33:49 UTC 2021

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

Log Message:
Move definition of NMAPREG to the start


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/pci/virtio_pci.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/virtio_pci.c
diff -u src/sys/dev/pci/virtio_pci.c:1.21 src/sys/dev/pci/virtio_pci.c:1.22
--- src/sys/dev/pci/virtio_pci.c:1.21	Sun Jan 24 14:12:36 2021
+++ src/sys/dev/pci/virtio_pci.c	Sun Jan 24 14:33:49 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: virtio_pci.c,v 1.21 2021/01/24 14:12:36 reinoud Exp $ */
+/* $NetBSD: virtio_pci.c,v 1.22 2021/01/24 14:33:49 reinoud Exp $ */
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.21 2021/01/24 14:12:36 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.22 2021/01/24 14:33:49 reinoud Exp $");
 
 #include 
 #include 
@@ -55,6 +55,9 @@ static void	virtio_pci_attach(device_t, 
 static int	virtio_pci_rescan(device_t, const char *, const int *);
 static int	virtio_pci_detach(device_t, int);
 
+
+#define NMAPREG		((PCI_MAPREG_END - PCI_MAPREG_START) / \
+sizeof(pcireg_t))
 struct virtio_pci_softc {
 	struct virtio_softc	sc_sc;
 
@@ -426,8 +429,6 @@ virtio_pci_attach_09(device_t self, void
 }
 
 
-#define NMAPREG		((PCI_MAPREG_END - PCI_MAPREG_START) / \
-sizeof(pcireg_t))
 static int
 virtio_pci_attach_10(device_t self, void *aux)
 {



CVS commit: src/sys/arch/amd64/amd64

2021-01-24 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sun Jan 24 14:17:11 UTC 2021

Modified Files:
src/sys/arch/amd64/amd64: machdep.c

Log Message:
Fix a tyop in a comment.


To generate a diff of this commit:
cvs rdiff -u -r1.357 -r1.358 src/sys/arch/amd64/amd64/machdep.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/amd64/amd64/machdep.c
diff -u src/sys/arch/amd64/amd64/machdep.c:1.357 src/sys/arch/amd64/amd64/machdep.c:1.358
--- src/sys/arch/amd64/amd64/machdep.c:1.357	Mon Sep  7 00:47:27 2020
+++ src/sys/arch/amd64/amd64/machdep.c	Sun Jan 24 14:17:10 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.357 2020/09/07 00:47:27 mrg Exp $	*/
+/*	$NetBSD: machdep.c,v 1.358 2021/01/24 14:17:10 simonb Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -110,7 +110,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.357 2020/09/07 00:47:27 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.358 2021/01/24 14:17:10 simonb Exp $");
 
 #include "opt_modular.h"
 #include "opt_user_ldt.h"
@@ -344,7 +344,7 @@ cpu_startup(void)
 	consinit();
 
 	/*
-	 * Initialize error message buffer (et end of core).
+	 * Initialize error message buffer (at end of core).
 	 */
 	if (msgbuf_p_cnt == 0)
 		panic("msgbuf paddr map has not been set up");



CVS commit: src/sys/dev/pci

2021-01-24 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Sun Jan 24 14:12:36 UTC 2021

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

Log Message:
Prevent potential buffer over runs in number of BARS


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/pci/virtio_pci.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/virtio_pci.c
diff -u src/sys/dev/pci/virtio_pci.c:1.20 src/sys/dev/pci/virtio_pci.c:1.21
--- src/sys/dev/pci/virtio_pci.c:1.20	Sun Jan 24 01:44:11 2021
+++ src/sys/dev/pci/virtio_pci.c	Sun Jan 24 14:12:36 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: virtio_pci.c,v 1.20 2021/01/24 01:44:11 christos Exp $ */
+/* $NetBSD: virtio_pci.c,v 1.21 2021/01/24 14:12:36 reinoud Exp $ */
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.20 2021/01/24 01:44:11 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.21 2021/01/24 14:12:36 reinoud Exp $");
 
 #include 
 #include 
@@ -65,9 +65,9 @@ struct virtio_pci_softc {
 	bus_size_t		sc_mapped_iosize;
 
 	/* BARs */
-	bus_space_tag_t		sc_bars_iot[4];
-	bus_space_handle_t	sc_bars_ioh[4];
-	bus_size_t		sc_bars_iosize[4];
+	bus_space_tag_t		sc_bars_iot[NMAPREG];
+	bus_space_handle_t	sc_bars_ioh[NMAPREG];
+	bus_size_t		sc_bars_iosize[NMAPREG];
 
 	/* notify space */
 	bus_space_tag_t		sc_notify_iot;



CVS commit: src/sys

2021-01-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Jan 24 13:33:56 UTC 2021

Modified Files:
src/sys/arch/arm/include: bus_funcs.h
src/sys/sys: bus_proto.h

Log Message:
Obey __HAVE_BUS_SPACE_8


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/include/bus_funcs.h
cvs rdiff -u -r1.12 -r1.13 src/sys/sys/bus_proto.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/arch/arm/include/bus_funcs.h
diff -u src/sys/arch/arm/include/bus_funcs.h:1.10 src/sys/arch/arm/include/bus_funcs.h:1.11
--- src/sys/arch/arm/include/bus_funcs.h:1.10	Sat Sep  5 16:04:31 2020
+++ src/sys/arch/arm/include/bus_funcs.h	Sun Jan 24 13:33:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus_funcs.h,v 1.10 2020/09/05 16:04:31 jakllsch Exp $	*/
+/*	$NetBSD: bus_funcs.h,v 1.11 2021/01/24 13:33:56 martin Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
@@ -150,13 +150,17 @@
 #define	bus_space_read_1(t, h, o)	__bs_rs(1,(t),(h),(o))
 #define	bus_space_read_2(t, h, o)	__bs_rs(2,(t),(h),(o))
 #define	bus_space_read_4(t, h, o)	__bs_rs(4,(t),(h),(o))
+#ifdef __HAVE_BUS_SPACE_8
 #define	bus_space_read_8(t, h, o)	__bs_rs(8,(t),(h),(o))
+#endif
 #ifdef __BUS_SPACE_HAS_STREAM_METHODS
 #define	bus_space_read_stream_1(t, h, o)	__bs_rs_s(1,(t),(h),(o))
 #define	bus_space_read_stream_2(t, h, o)	__bs_rs_s(2,(t),(h),(o))
 #define	bus_space_read_stream_4(t, h, o)	__bs_rs_s(4,(t),(h),(o))
+#ifdef __HAVE_BUS_SPACE_8
 #define	bus_space_read_stream_8(t, h, o)	__bs_rs_s(8,(t),(h),(o))
 #endif
+#endif
 
 
 /*
@@ -168,8 +172,10 @@
 	__bs_nonsingle(rm,2,(t),(h),(o),(a),(c))
 #define	bus_space_read_multi_4(t, h, o, a, c)\
 	__bs_nonsingle(rm,4,(t),(h),(o),(a),(c))
+#ifdef __HAVE_BUS_SPACE_8
 #define	bus_space_read_multi_8(t, h, o, a, c)\
 	__bs_nonsingle(rm,8,(t),(h),(o),(a),(c))
+#endif
 #ifdef __BUS_SPACE_HAS_STREAM_METHODS
 #define	bus_space_read_multi_stream_1(t, h, o, a, c)			\
 	__bs_nonsingle_s(rm,1,(t),(h),(o),(a),(c))
@@ -177,9 +183,11 @@
 	__bs_nonsingle_s(rm,2,(t),(h),(o),(a),(c))
 #define	bus_space_read_multi_stream_4(t, h, o, a, c)			\
 	__bs_nonsingle_s(rm,4,(t),(h),(o),(a),(c))
+#ifdef __HAVE_BUS_SPACE_8
 #define	bus_space_read_multi_stream_8(t, h, o, a, c)			\
 	__bs_nonsingle_s(rm,8,(t),(h),(o),(a),(c))
 #endif
+#endif
 
 
 /*
@@ -191,8 +199,10 @@
 	__bs_nonsingle(rr,2,(t),(h),(o),(a),(c))
 #define	bus_space_read_region_4(t, h, o, a, c)\
 	__bs_nonsingle(rr,4,(t),(h),(o),(a),(c))
+#ifdef __HAVE_BUS_SPACE_8
 #define	bus_space_read_region_8(t, h, o, a, c)\
 	__bs_nonsingle(rr,8,(t),(h),(o),(a),(c))
+#endif
 #ifdef __BUS_SPACE_HAS_STREAM_METHODS
 #define	bus_space_read_region_stream_1(t, h, o, a, c)			\
 	__bs_nonsingle_s(rr,1,(t),(h),(o),(a),(c))
@@ -200,9 +210,11 @@
 	__bs_nonsingle_s(rr,2,(t),(h),(o),(a),(c))
 #define	bus_space_read_region_stream_4(t, h, o, a, c)			\
 	__bs_nonsingle_s(rr,4,(t),(h),(o),(a),(c))
+#ifdef __HAVE_BUS_SPACE_8
 #define	bus_space_read_region_stream_8(t, h, o, a, c)			\
 	__bs_nonsingle_s(rr,8,(t),(h),(o),(a),(c))
 #endif
+#endif
 
 
 /*
@@ -211,13 +223,17 @@
 #define	bus_space_write_1(t, h, o, v)	__bs_ws(1,(t),(h),(o),(v))
 #define	bus_space_write_2(t, h, o, v)	__bs_ws(2,(t),(h),(o),(v))
 #define	bus_space_write_4(t, h, o, v)	__bs_ws(4,(t),(h),(o),(v))
+#ifdef __HAVE_BUS_SPACE_8
 #define	bus_space_write_8(t, h, o, v)	__bs_ws(8,(t),(h),(o),(v))
+#endif
 #ifdef __BUS_SPACE_HAS_STREAM_METHODS
 #define	bus_space_write_stream_1(t, h, o, v)	__bs_ws_s(1,(t),(h),(o),(v))
 #define	bus_space_write_stream_2(t, h, o, v)	__bs_ws_s(2,(t),(h),(o),(v))
 #define	bus_space_write_stream_4(t, h, o, v)	__bs_ws_s(4,(t),(h),(o),(v))
+#ifdef __HAVE_BUS_SPACE_8
 #define	bus_space_write_stream_8(t, h, o, v)	__bs_ws_s(8,(t),(h),(o),(v))
 #endif
+#endif
 
 
 /*
@@ -229,8 +245,10 @@
 	__bs_nonsingle(wm,2,(t),(h),(o),(a),(c))
 #define	bus_space_write_multi_4(t, h, o, a, c)\
 	__bs_nonsingle(wm,4,(t),(h),(o),(a),(c))
+#ifdef __HAVE_BUS_SPACE_8
 #define	bus_space_write_multi_8(t, h, o, a, c)\
 	__bs_nonsingle(wm,8,(t),(h),(o),(a),(c))
+#endif
 #ifdef __BUS_SPACE_HAS_STREAM_METHODS
 #define	bus_space_write_multi_stream_1(t, h, o, a, c)			\
 	__bs_nonsingle_s(wm,1,(t),(h),(o),(a),(c))
@@ -238,9 +256,11 @@
 	__bs_nonsingle_s(wm,2,(t),(h),(o),(a),(c))
 #define	bus_space_write_multi_stream_4(t, h, o, a, c)			\
 	__bs_nonsingle_s(wm,4,(t),(h),(o),(a),(c))
+#ifdef __HAVE_BUS_SPACE_8
 #define	bus_space_write_multi_stream_8(t, h, o, a, c)			\
 	__bs_nonsingle_s(wm,8,(t),(h),(o),(a),(c))
 #endif
+#endif
 
 
 /*
@@ -252,8 +272,10 @@
 	__bs_nonsingle(wr,2,(t),(h),(o),(a),(c))
 #define	bus_space_write_region_4(t, h, o, a, c)\
 	__bs_nonsingle(wr,4,(t),(h),(o),(a),(c))
+#ifdef __HAVE_BUS_SPACE_8
 #define	bus_space_write_region_8(t, h, o, a, c)\
 	__bs_nonsingle(wr,8,(t),(h),(o),(a),(c))
+#endif
 #ifdef __BUS_SPACE_HAS_STREAM_METHODS
 #define	

CVS commit: src

2021-01-24 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Jan 24 12:51:32 UTC 2021

Modified Files:
src/sbin/mount_nfs: mount_nfs.8
src/sys/arch/aarch64/include: param.h

Log Message:
Use 32K as the default NFSv3 read and write data sizes on aarch64, matching
i386 and amd64.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sbin/mount_nfs/mount_nfs.8
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/aarch64/include/param.h

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

Modified files:

Index: src/sbin/mount_nfs/mount_nfs.8
diff -u src/sbin/mount_nfs/mount_nfs.8:1.50 src/sbin/mount_nfs/mount_nfs.8:1.51
--- src/sbin/mount_nfs/mount_nfs.8:1.50	Sat Oct  3 18:29:02 2020
+++ src/sbin/mount_nfs/mount_nfs.8	Sun Jan 24 12:51:32 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: mount_nfs.8,v 1.50 2020/10/03 18:29:02 wiz Exp $
+.\"	$NetBSD: mount_nfs.8,v 1.51 2021/01/24 12:51:32 jmcneill Exp $
 .\"
 .\" Copyright (c) 1992, 1993, 1994, 1995
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"	@(#)mount_nfs.8	8.3 (Berkeley) 3/29/95
 .\"
-.Dd October 3, 2020
+.Dd January 24, 2021
 .Dt MOUNT_NFS 8
 .Os
 .Sh NAME
@@ -356,7 +356,8 @@ The default size for NFS version 2 is 8K
 .Pp
 The default size for NFS version 3 is platform dependent:
 on
-.Nx Ns /amd64
+.Nx Ns /aarch64 ,
+.Nx Ns /amd64 ,
 and
 .Nx Ns /i386 ,
 the default is 32K, for other platforms it is 8K.

Index: src/sys/arch/aarch64/include/param.h
diff -u src/sys/arch/aarch64/include/param.h:1.14 src/sys/arch/aarch64/include/param.h:1.15
--- src/sys/arch/aarch64/include/param.h:1.14	Sat Feb  1 09:21:49 2020
+++ src/sys/arch/aarch64/include/param.h	Sun Jan 24 12:51:32 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: param.h,v 1.14 2020/02/01 09:21:49 skrll Exp $ */
+/* $NetBSD: param.h,v 1.15 2021/01/24 12:51:32 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -131,6 +131,12 @@
 
 #define MCLBYTES		(1 << MCLSHIFT)	/* size of a m_buf cluster */
 
+#ifndef NFS_RSIZE
+#define NFS_RSIZE		32768	/* Default NFS read data size */
+#endif
+#ifndef NFS_WSIZE
+#define NFS_WSIZE		32768	/* Default NFS write data size */
+#endif
 
 #ifndef MSGBUFSIZE
 #define MSGBUFSIZE		65536	/* default message buffer size */



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

2021-01-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 24 11:55:57 UTC 2021

Modified Files:
src/usr.bin/xlint/common: tyname.c

Log Message:
lint: merge duplicate code for interning type names


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/xlint/common/tyname.c

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

Modified files:

Index: src/usr.bin/xlint/common/tyname.c
diff -u src/usr.bin/xlint/common/tyname.c:1.24 src/usr.bin/xlint/common/tyname.c:1.25
--- src/usr.bin/xlint/common/tyname.c:1.24	Sat Jan 16 16:53:23 2021
+++ src/usr.bin/xlint/common/tyname.c	Sun Jan 24 11:55:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tyname.c,v 1.24 2021/01/16 16:53:23 rillig Exp $	*/
+/*	$NetBSD: tyname.c,v 1.25 2021/01/24 11:55:57 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tyname.c,v 1.24 2021/01/16 16:53:23 rillig Exp $");
+__RCSID("$NetBSD: tyname.c,v 1.25 2021/01/24 11:55:57 rillig Exp $");
 #endif
 
 #include 
@@ -82,10 +82,10 @@ new_name_tree_node(const char *name)
 }
 
 /* Return the canonical instance of the string, with unlimited life time. */
-static const char *
+static const char * __noinline
 intern(const char *name)
 {
-	name_tree_node *n = type_names;
+	name_tree_node *n = type_names, **next;
 	int cmp;
 
 	if (n == NULL) {
@@ -95,19 +95,12 @@ intern(const char *name)
 	}
 
 	while ((cmp = strcmp(name, n->ntn_name)) != 0) {
-		if (cmp < 0) {
-			if (n->ntn_less == NULL) {
-n->ntn_less = new_name_tree_node(name);
-return n->ntn_less->ntn_name;
-			}
-			n = n->ntn_less;
-		} else {
-			if (n->ntn_greater == NULL) {
-n->ntn_greater = new_name_tree_node(name);
-return n->ntn_greater->ntn_name;
-			}
-			n = n->ntn_greater;
+		next = cmp < 0 ? >ntn_less : >ntn_greater;
+		if (*next == NULL) {
+			*next = new_name_tree_node(name);
+			return (*next)->ntn_name;
 		}
+		n = *next;
 	}
 	return n->ntn_name;
 }



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

2021-01-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 24 11:34:01 UTC 2021

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

Log Message:
lint: extract duplicate code into is_null_pointer

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.189 -r1.190 src/usr.bin/xlint/lint1/tree.c

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

Modified files:

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.189 src/usr.bin/xlint/lint1/tree.c:1.190
--- src/usr.bin/xlint/lint1/tree.c:1.189	Sun Jan 24 11:21:58 2021
+++ src/usr.bin/xlint/lint1/tree.c	Sun Jan 24 11:34:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.189 2021/01/24 11:21:58 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.190 2021/01/24 11:34:01 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.189 2021/01/24 11:21:58 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.190 2021/01/24 11:34:01 rillig Exp $");
 #endif
 
 #include 
@@ -722,6 +722,16 @@ before_conversion(const tnode_t *tn)
 	return tn;
 }
 
+static bool
+is_null_pointer(const tnode_t *tn)
+{
+	tspec_t t = tn->tn_type->t_tspec;
+
+	return ((t == PTR && tn->tn_type->t_subt->t_tspec == VOID) ||
+		is_integer(t))
+	   && (tn->tn_op == CON && tn->tn_val->v_quad == 0);
+}
+
 /*
  * See if the node is valid as operand of an operator that compares its
  * argument with 0.
@@ -952,16 +962,10 @@ typeok_shift(tspec_t lt, const tnode_t *
 static bool
 is_typeok_eq(const tnode_t *ln, tspec_t lt, const tnode_t *rn, tspec_t rt)
 {
-	if (lt == PTR && ((rt == PTR && rn->tn_type->t_subt->t_tspec == VOID) ||
-			  is_integer(rt))) {
-		if (rn->tn_op == CON && rn->tn_val->v_quad == 0)
-			return true;
-	}
-	if (rt == PTR && ((lt == PTR && ln->tn_type->t_subt->t_tspec == VOID) ||
-			  is_integer(lt))) {
-		if (ln->tn_op == CON && ln->tn_val->v_quad == 0)
-			return true;
-	}
+	if (lt == PTR && is_null_pointer(rn))
+		return true;
+	if (rt == PTR && is_null_pointer(ln))
+		return true;
 	return false;
 }
 
@@ -1027,15 +1031,11 @@ typeok_colon(const mod_t *mp,
 	lst = lstp != NULL ? lstp->t_tspec : NOTSPEC;
 	rst = rstp != NULL ? rstp->t_tspec : NOTSPEC;
 
-	/* combination of any pointer and 0, 0L or (void *)0 is ok */
-	if (lt == PTR && ((rt == PTR && rst == VOID) || is_integer(rt))) {
-		if (rn->tn_op == CON && rn->tn_val->v_quad == 0)
-			return true;
-	}
-	if (rt == PTR && ((lt == PTR && lst == VOID) || is_integer(lt))) {
-		if (ln->tn_op == CON && ln->tn_val->v_quad == 0)
-			return true;
-	}
+	/* combination of any pointer and null pointer is ok */
+	if (lt == PTR && is_null_pointer(rn))
+		return true;
+	if (rt == PTR && is_null_pointer(ln))
+		return true;
 
 	if ((lt == PTR && is_integer(rt)) || (is_integer(lt) && rt == PTR)) {
 		const char *lx = lt == PTR ?  "pointer" : "integer";
@@ -1559,11 +1559,9 @@ check_assign_types_compatible(op_t op, i
 		/* both are struct or union */
 		return ltp->t_str == rtp->t_str;
 
-	/* 0, 0L and (void *)0 may be assigned to any pointer */
-	if (lt == PTR && ((rt == PTR && rst == VOID) || is_integer(rt))) {
-		if (rn->tn_op == CON && rn->tn_val->v_quad == 0)
-			return true;
-	}
+	/* a null pointer may be assigned to any pointer */
+	if (lt == PTR && is_null_pointer(rn))
+		return true;
 
 	if (lt == PTR && rt == PTR && (lst == VOID || rst == VOID)) {
 		/* two pointers, at least one pointer to void */
@@ -2030,20 +2028,17 @@ tnode_t *
 convert(op_t op, int arg, type_t *tp, tnode_t *tn)
 {
 	tnode_t	*ntn;
-	tspec_t	nt, ot, ost = NOTSPEC;
+	tspec_t	nt, ot;
 
 	nt = tp->t_tspec;
-	if ((ot = tn->tn_type->t_tspec) == PTR)
-		ost = tn->tn_type->t_subt->t_tspec;
+	ot = tn->tn_type->t_tspec;
 
 	if (!tflag && !sflag && op == FARG)
 		check_prototype_conversion(arg, nt, ot, tp, tn);
 	if (is_integer(nt) && is_integer(ot)) {
 		check_integer_conversion(op, arg, nt, ot, tp, tn);
-	} else if (nt == PTR && ((ot == PTR && ost == VOID) ||
- is_integer(ot)) && tn->tn_op == CON &&
-		   tn->tn_val->v_quad == 0) {
-		/* 0, 0L and (void *)0 may be assigned to any pointer. */
+	} else if (nt == PTR && is_null_pointer(tn)) {
+		/* a null pointer may be assigned to any pointer. */
 	} else if (is_integer(nt) && nt != BOOL && ot == PTR) {
 		check_pointer_integer_conversion(op, nt, tp, tn);
 	} else if (nt == PTR && ot == PTR) {



CVS commit: src/sys/kern

2021-01-24 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sun Jan 24 11:31:47 UTC 2021

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

Log Message:
don't check signals while waiting for other kqueue scans to finish

reportedly somewhat improves behaviour for PR kern/55946

part of PR kern/50094 fix


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 src/sys/kern/kern_event.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/kern_event.c
diff -u src/sys/kern/kern_event.c:1.113 src/sys/kern/kern_event.c:1.114
--- src/sys/kern/kern_event.c:1.113	Thu Jan 21 19:37:23 2021
+++ src/sys/kern/kern_event.c	Sun Jan 24 11:31:47 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_event.c,v 1.113 2021/01/21 19:37:23 jdolecek Exp $	*/
+/*	$NetBSD: kern_event.c,v 1.114 2021/01/24 11:31:47 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.113 2021/01/21 19:37:23 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.114 2021/01/24 11:31:47 jdolecek Exp $");
 
 #include 
 #include 
@@ -1470,7 +1470,7 @@ relock:
 KQ_FLUX_WAKEUP(kq);
 			}
 			mutex_exit(>fd_lock);
-			(void)cv_wait_sig(>kq_cv, >kq_lock);
+			(void)cv_wait(>kq_cv, >kq_lock);
 			goto relock;
 		}
 



CVS commit: src

2021-01-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 24 11:21:58 UTC 2021

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

Log Message:
lint: fix wrong warning about null pointer comparison


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_124.c
cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/xlint/lint1/msg_124.exp
cvs rdiff -u -r1.188 -r1.189 src/usr.bin/xlint/lint1/tree.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_124.c
diff -u src/tests/usr.bin/xlint/lint1/msg_124.c:1.5 src/tests/usr.bin/xlint/lint1/msg_124.c:1.6
--- src/tests/usr.bin/xlint/lint1/msg_124.c:1.5	Sun Jan 24 11:17:44 2021
+++ src/tests/usr.bin/xlint/lint1/msg_124.c	Sun Jan 24 11:21:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_124.c,v 1.5 2021/01/24 11:17:44 rillig Exp $	*/
+/*	$NetBSD: msg_124.c,v 1.6 2021/01/24 11:21:58 rillig Exp $	*/
 # 3 "msg_124.c"
 
 // Test for message: illegal pointer combination, op %s [124]
@@ -35,11 +35,11 @@ compare_pointers(const void *vp, const c
 	ok(vp == (void *)0);
 	ok(cp == (void *)0);
 	ok(ip == (void *)0);
-	ok(fp == (void *)0);	/*FIXME*//* expect: 274 */
+	ok(fp == (void *)0);	/* wrong 124 before 2021-01-25 */
 	ok((void *)0 == vp);
 	ok((void *)0 == cp);
 	ok((void *)0 == ip);
-	ok((void *)0 == fp);	/*FIXME*//* expect: 274 */
+	ok((void *)0 == fp);	/* wrong 124 before 2021-01-25 */
 	ok(vp == 0);
 	ok(cp == 0);
 	ok(ip == 0);

Index: src/tests/usr.bin/xlint/lint1/msg_124.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_124.exp:1.8 src/tests/usr.bin/xlint/lint1/msg_124.exp:1.9
--- src/tests/usr.bin/xlint/lint1/msg_124.exp:1.8	Sun Jan 24 11:17:44 2021
+++ src/tests/usr.bin/xlint/lint1/msg_124.exp	Sun Jan 24 11:21:58 2021
@@ -4,5 +4,3 @@ msg_124.c(20): warning: illegal pointer 
 msg_124.c(32): warning: ANSI C forbids comparison of 'void *' with function pointer [274]
 msg_124.c(33): warning: illegal pointer combination (pointer to const char) and (pointer to const int), op == [124]
 msg_124.c(34): warning: illegal pointer combination (pointer to const char) and (pointer to function(int) returning void), op == [124]
-msg_124.c(38): warning: ANSI C forbids comparison of function pointer with 'void *' [274]
-msg_124.c(42): warning: ANSI C forbids comparison of 'void *' with function pointer [274]

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.188 src/usr.bin/xlint/lint1/tree.c:1.189
--- src/usr.bin/xlint/lint1/tree.c:1.188	Sun Jan 24 10:57:17 2021
+++ src/usr.bin/xlint/lint1/tree.c	Sun Jan 24 11:21:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.188 2021/01/24 10:57:17 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.189 2021/01/24 11:21:58 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.188 2021/01/24 10:57:17 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.189 2021/01/24 11:21:58 rillig Exp $");
 #endif
 
 #include 
@@ -952,14 +952,12 @@ typeok_shift(tspec_t lt, const tnode_t *
 static bool
 is_typeok_eq(const tnode_t *ln, tspec_t lt, const tnode_t *rn, tspec_t rt)
 {
-	/* FIXME: missing tn_subt */
-	if (lt == PTR && ((rt == PTR && rn->tn_type->t_tspec == VOID) ||
+	if (lt == PTR && ((rt == PTR && rn->tn_type->t_subt->t_tspec == VOID) ||
 			  is_integer(rt))) {
 		if (rn->tn_op == CON && rn->tn_val->v_quad == 0)
 			return true;
 	}
-	/* FIXME: missing tn_subt */
-	if (rt == PTR && ((lt == PTR && ln->tn_type->t_tspec == VOID) ||
+	if (rt == PTR && ((lt == PTR && ln->tn_type->t_subt->t_tspec == VOID) ||
 			  is_integer(lt))) {
 		if (ln->tn_op == CON && ln->tn_val->v_quad == 0)
 			return true;



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

2021-01-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 24 11:17:44 UTC 2021

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

Log Message:
lint: demonstrate wrong 124 for flipped == as well

Since the fix in the next commit changes two places in the code, there
must be two wrong error messages that disappear then.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_124.c
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/xlint/lint1/msg_124.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_124.c
diff -u src/tests/usr.bin/xlint/lint1/msg_124.c:1.4 src/tests/usr.bin/xlint/lint1/msg_124.c:1.5
--- src/tests/usr.bin/xlint/lint1/msg_124.c:1.4	Sun Jan 24 11:13:22 2021
+++ src/tests/usr.bin/xlint/lint1/msg_124.c	Sun Jan 24 11:17:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_124.c,v 1.4 2021/01/24 11:13:22 rillig Exp $	*/
+/*	$NetBSD: msg_124.c,v 1.5 2021/01/24 11:17:44 rillig Exp $	*/
 # 3 "msg_124.c"
 
 // Test for message: illegal pointer combination, op %s [124]
@@ -36,6 +36,10 @@ compare_pointers(const void *vp, const c
 	ok(cp == (void *)0);
 	ok(ip == (void *)0);
 	ok(fp == (void *)0);	/*FIXME*//* expect: 274 */
+	ok((void *)0 == vp);
+	ok((void *)0 == cp);
+	ok((void *)0 == ip);
+	ok((void *)0 == fp);	/*FIXME*//* expect: 274 */
 	ok(vp == 0);
 	ok(cp == 0);
 	ok(ip == 0);

Index: src/tests/usr.bin/xlint/lint1/msg_124.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_124.exp:1.7 src/tests/usr.bin/xlint/lint1/msg_124.exp:1.8
--- src/tests/usr.bin/xlint/lint1/msg_124.exp:1.7	Sun Jan 24 11:13:22 2021
+++ src/tests/usr.bin/xlint/lint1/msg_124.exp	Sun Jan 24 11:17:44 2021
@@ -5,3 +5,4 @@ msg_124.c(32): warning: ANSI C forbids c
 msg_124.c(33): warning: illegal pointer combination (pointer to const char) and (pointer to const int), op == [124]
 msg_124.c(34): warning: illegal pointer combination (pointer to const char) and (pointer to function(int) returning void), op == [124]
 msg_124.c(38): warning: ANSI C forbids comparison of function pointer with 'void *' [274]
+msg_124.c(42): warning: ANSI C forbids comparison of 'void *' with function pointer [274]



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

2021-01-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 24 11:13:22 UTC 2021

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

Log Message:
lint: demonstrate wrong 124 due to bug in is_typeok_eq


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_124.c
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/msg_124.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_124.c
diff -u src/tests/usr.bin/xlint/lint1/msg_124.c:1.3 src/tests/usr.bin/xlint/lint1/msg_124.c:1.4
--- src/tests/usr.bin/xlint/lint1/msg_124.c:1.3	Sun Jan 24 10:50:42 2021
+++ src/tests/usr.bin/xlint/lint1/msg_124.c	Sun Jan 24 11:13:22 2021
@@ -1,8 +1,10 @@
-/*	$NetBSD: msg_124.c,v 1.3 2021/01/24 10:50:42 rillig Exp $	*/
+/*	$NetBSD: msg_124.c,v 1.4 2021/01/24 11:13:22 rillig Exp $	*/
 # 3 "msg_124.c"
 
 // Test for message: illegal pointer combination, op %s [124]
 
+/* lint1-extra-flags: -s */
+
 typedef void(*signal_handler)(int);
 
 typedef signal_handler(*sys_signal)(signal_handler);
@@ -27,13 +29,13 @@ compare_pointers(const void *vp, const c
 {
 	ok(vp == cp);
 	ok(vp == ip);
-	ok(vp == fp);
+	ok(vp == fp);		/* expect: 274 */
 	not_ok(cp == ip);	/* expect: 124 */
 	not_ok(cp == fp);	/* expect: 124 */
 	ok(vp == (void *)0);
 	ok(cp == (void *)0);
 	ok(ip == (void *)0);
-	ok(fp == (void *)0);
+	ok(fp == (void *)0);	/*FIXME*//* expect: 274 */
 	ok(vp == 0);
 	ok(cp == 0);
 	ok(ip == 0);

Index: src/tests/usr.bin/xlint/lint1/msg_124.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_124.exp:1.6 src/tests/usr.bin/xlint/lint1/msg_124.exp:1.7
--- src/tests/usr.bin/xlint/lint1/msg_124.exp:1.6	Sun Jan 24 10:50:42 2021
+++ src/tests/usr.bin/xlint/lint1/msg_124.exp	Sun Jan 24 11:13:22 2021
@@ -1,5 +1,7 @@
-msg_124.c(16): warning: illegal pointer combination (pointer to function(int) returning void) and (pointer to int), op = [124]
-msg_124.c(17): warning: illegal pointer combination (pointer to function(pointer to function(int) returning void) returning pointer to function(int) returning void) and (pointer to int), op = [124]
-msg_124.c(18): warning: illegal pointer combination (pointer to function(pointer to const char, ...) returning int) and (pointer to int), op = [124]
-msg_124.c(31): warning: illegal pointer combination (pointer to const char) and (pointer to const int), op == [124]
-msg_124.c(32): warning: illegal pointer combination (pointer to const char) and (pointer to function(int) returning void), op == [124]
+msg_124.c(18): warning: illegal pointer combination (pointer to function(int) returning void) and (pointer to int), op = [124]
+msg_124.c(19): warning: illegal pointer combination (pointer to function(pointer to function(int) returning void) returning pointer to function(int) returning void) and (pointer to int), op = [124]
+msg_124.c(20): warning: illegal pointer combination (pointer to function(pointer to const char, ...) returning int) and (pointer to int), op = [124]
+msg_124.c(32): warning: ANSI C forbids comparison of 'void *' with function pointer [274]
+msg_124.c(33): warning: illegal pointer combination (pointer to const char) and (pointer to const int), op == [124]
+msg_124.c(34): warning: illegal pointer combination (pointer to const char) and (pointer to function(int) returning void), op == [124]
+msg_124.c(38): warning: ANSI C forbids comparison of function pointer with 'void *' [274]



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

2021-01-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 24 10:57:17 UTC 2021

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

Log Message:
lint: fix local variable names in check_pointer_comparison


To generate a diff of this commit:
cvs rdiff -u -r1.187 -r1.188 src/usr.bin/xlint/lint1/tree.c

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

Modified files:

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.187 src/usr.bin/xlint/lint1/tree.c:1.188
--- src/usr.bin/xlint/lint1/tree.c:1.187	Sun Jan 24 10:55:11 2021
+++ src/usr.bin/xlint/lint1/tree.c	Sun Jan 24 10:57:17 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.187 2021/01/24 10:55:11 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.188 2021/01/24 10:57:17 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.187 2021/01/24 10:55:11 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.188 2021/01/24 10:57:17 rillig Exp $");
 #endif
 
 #include 
@@ -1503,7 +1503,7 @@ check_pointer_comparison(op_t op, const 
 {
 	type_t	*ltp, *rtp;
 	tspec_t	lst, rst;
-	const	char *lts, *rts;
+	const	char *lsts, *rsts;
 
 	lst = (ltp = ln->tn_type)->t_subt->t_tspec;
 	rst = (rtp = rn->tn_type)->t_subt->t_tspec;
@@ -1511,10 +1511,10 @@ check_pointer_comparison(op_t op, const 
 	if (lst == VOID || rst == VOID) {
 		if (sflag && (lst == FUNC || rst == FUNC)) {
 			/* (void *)0 already handled in typeok() */
-			*(lst == FUNC ?  : ) = "function pointer";
-			*(lst == VOID ?  : ) = "'void *'";
+			*(lst == FUNC ?  : ) = "function pointer";
+			*(lst == VOID ?  : ) = "'void *'";
 			/* ANSI C forbids comparison of %s with %s */
-			warning(274, lts, rts);
+			warning(274, lsts, rsts);
 		}
 		return;
 	}



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

2021-01-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 24 10:55:11 UTC 2021

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

Log Message:
lint: clean up typeok_eq and check_pointer_comparison

Since typeok_eq does not issue any diagnostics, prefix it with "is_".

By convention, the variable rt aliases rn->tn_type->t_tspec.  Make it
obvious that in check_pointer_comparison, rt corresponds to the subtype
of the pointer.


To generate a diff of this commit:
cvs rdiff -u -r1.186 -r1.187 src/usr.bin/xlint/lint1/tree.c

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

Modified files:

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.186 src/usr.bin/xlint/lint1/tree.c:1.187
--- src/usr.bin/xlint/lint1/tree.c:1.186	Sun Jan 24 10:50:42 2021
+++ src/usr.bin/xlint/lint1/tree.c	Sun Jan 24 10:55:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.186 2021/01/24 10:50:42 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.187 2021/01/24 10:55:11 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.186 2021/01/24 10:50:42 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.187 2021/01/24 10:55:11 rillig Exp $");
 #endif
 
 #include 
@@ -950,7 +950,7 @@ typeok_shift(tspec_t lt, const tnode_t *
 }
 
 static bool
-typeok_eq(const tnode_t *ln, tspec_t lt, const tnode_t *rn, tspec_t rt)
+is_typeok_eq(const tnode_t *ln, tspec_t lt, const tnode_t *rn, tspec_t rt)
 {
 	/* FIXME: missing tn_subt */
 	if (lt == PTR && ((rt == PTR && rn->tn_type->t_tspec == VOID) ||
@@ -1358,7 +1358,7 @@ typeok_op(op_t op, const mod_t *mp, int 
 		 * Accept some things which are allowed with EQ and NE,
 		 * but not with ordered comparisons.
 		 */
-		if (typeok_eq(ln, lt, rn, rt))
+		if (is_typeok_eq(ln, lt, rn, rt))
 			break;
 		/* FALLTHROUGH */
 	case LT:
@@ -1502,17 +1502,17 @@ static void
 check_pointer_comparison(op_t op, const tnode_t *ln, const tnode_t *rn)
 {
 	type_t	*ltp, *rtp;
-	tspec_t	lt, rt;
+	tspec_t	lst, rst;
 	const	char *lts, *rts;
 
-	lt = (ltp = ln->tn_type)->t_subt->t_tspec;
-	rt = (rtp = rn->tn_type)->t_subt->t_tspec;
+	lst = (ltp = ln->tn_type)->t_subt->t_tspec;
+	rst = (rtp = rn->tn_type)->t_subt->t_tspec;
 
-	if (lt == VOID || rt == VOID) {
-		if (sflag && (lt == FUNC || rt == FUNC)) {
+	if (lst == VOID || rst == VOID) {
+		if (sflag && (lst == FUNC || rst == FUNC)) {
 			/* (void *)0 already handled in typeok() */
-			*(lt == FUNC ?  : ) = "function pointer";
-			*(lt == VOID ?  : ) = "'void *'";
+			*(lst == FUNC ?  : ) = "function pointer";
+			*(lst == VOID ?  : ) = "'void *'";
 			/* ANSI C forbids comparison of %s with %s */
 			warning(274, lts, rts);
 		}
@@ -1524,7 +1524,7 @@ check_pointer_comparison(op_t op, const 
 		return;
 	}
 
-	if (lt == FUNC && rt == FUNC) {
+	if (lst == FUNC && rst == FUNC) {
 		if (sflag && op != EQ && op != NE)
 			/* ANSI C forbids ordered comparisons of ... */
 			warning(125);



CVS commit: src

2021-01-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 24 10:50:42 UTC 2021

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

Log Message:
lint: document bug in typeok_eq

Since rt is an alias for rn->tn_type->t_tspec, it cannot be PTR and VOID
at the same time.  This makes the condition unsatisfiable.  Removing
that part of the code didn't show any change in behavior, as expected.

It may even be that fixing this obvious bug doesn't show any change in
behavior since that function is only used in a single place and
check_pointer_comparison performs its own checks before issuing any
warning.

At least the test cases added to msg_124.c all run as expected.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_124.c
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_124.exp
cvs rdiff -u -r1.185 -r1.186 src/usr.bin/xlint/lint1/tree.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_124.c
diff -u src/tests/usr.bin/xlint/lint1/msg_124.c:1.2 src/tests/usr.bin/xlint/lint1/msg_124.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_124.c:1.2	Sun Jan  3 15:44:35 2021
+++ src/tests/usr.bin/xlint/lint1/msg_124.c	Sun Jan 24 10:50:42 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_124.c,v 1.2 2021/01/03 15:44:35 rillig Exp $	*/
+/*	$NetBSD: msg_124.c,v 1.3 2021/01/24 10:50:42 rillig Exp $	*/
 # 3 "msg_124.c"
 
 // Test for message: illegal pointer combination, op %s [124]
@@ -13,7 +13,33 @@ typedef int(*printflike)(const char *, .
 void
 example(int *ptr)
 {
-	signal_handler handler = ptr;
-	sys_signal signal = ptr;
-	printflike printf = ptr;
+	signal_handler handler = ptr;	/* expect: 124 */
+	sys_signal signal = ptr;	/* expect: 124 */
+	printflike printf = ptr;	/* expect: 124 */
+}
+
+void ok(_Bool);
+void not_ok(_Bool);
+
+void
+compare_pointers(const void *vp, const char *cp, const int *ip,
+		 signal_handler fp)
+{
+	ok(vp == cp);
+	ok(vp == ip);
+	ok(vp == fp);
+	not_ok(cp == ip);	/* expect: 124 */
+	not_ok(cp == fp);	/* expect: 124 */
+	ok(vp == (void *)0);
+	ok(cp == (void *)0);
+	ok(ip == (void *)0);
+	ok(fp == (void *)0);
+	ok(vp == 0);
+	ok(cp == 0);
+	ok(ip == 0);
+	ok(fp == 0);
+	ok(vp == 0L);
+	ok(cp == 0L);
+	ok(ip == 0L);
+	ok(fp == 0L);
 }

Index: src/tests/usr.bin/xlint/lint1/msg_124.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_124.exp:1.5 src/tests/usr.bin/xlint/lint1/msg_124.exp:1.6
--- src/tests/usr.bin/xlint/lint1/msg_124.exp:1.5	Tue Jan  5 23:07:49 2021
+++ src/tests/usr.bin/xlint/lint1/msg_124.exp	Sun Jan 24 10:50:42 2021
@@ -1,3 +1,5 @@
 msg_124.c(16): warning: illegal pointer combination (pointer to function(int) returning void) and (pointer to int), op = [124]
 msg_124.c(17): warning: illegal pointer combination (pointer to function(pointer to function(int) returning void) returning pointer to function(int) returning void) and (pointer to int), op = [124]
 msg_124.c(18): warning: illegal pointer combination (pointer to function(pointer to const char, ...) returning int) and (pointer to int), op = [124]
+msg_124.c(31): warning: illegal pointer combination (pointer to const char) and (pointer to const int), op == [124]
+msg_124.c(32): warning: illegal pointer combination (pointer to const char) and (pointer to function(int) returning void), op == [124]

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.185 src/usr.bin/xlint/lint1/tree.c:1.186
--- src/usr.bin/xlint/lint1/tree.c:1.185	Sun Jan 24 00:15:20 2021
+++ src/usr.bin/xlint/lint1/tree.c	Sun Jan 24 10:50:42 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.185 2021/01/24 00:15:20 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.186 2021/01/24 10:50:42 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.185 2021/01/24 00:15:20 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.186 2021/01/24 10:50:42 rillig Exp $");
 #endif
 
 #include 
@@ -952,11 +952,13 @@ typeok_shift(tspec_t lt, const tnode_t *
 static bool
 typeok_eq(const tnode_t *ln, tspec_t lt, const tnode_t *rn, tspec_t rt)
 {
+	/* FIXME: missing tn_subt */
 	if (lt == PTR && ((rt == PTR && rn->tn_type->t_tspec == VOID) ||
 			  is_integer(rt))) {
 		if (rn->tn_op == CON && rn->tn_val->v_quad == 0)
 			return true;
 	}
+	/* FIXME: missing tn_subt */
 	if (rt == PTR && ((lt == PTR && ln->tn_type->t_tspec == VOID) ||
 			  is_integer(lt))) {
 		if (ln->tn_op == CON && ln->tn_val->v_quad == 0)



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

2021-01-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 24 09:44:35 UTC 2021

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

Log Message:
lint: fix build on Cygwin

Cygwin does not conform to C99, which says that MB_CUR_MAX has type
size_t.

Instead, Cygwin defines it as type int.  This leads to compile errors
because comparing signed with unsigned expressions is surprising in C.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/xlint/lint1/lex.c

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

Modified files:

Index: src/usr.bin/xlint/lint1/lex.c
diff -u src/usr.bin/xlint/lint1/lex.c:1.6 src/usr.bin/xlint/lint1/lex.c:1.7
--- src/usr.bin/xlint/lint1/lex.c:1.6	Sun Jan 24 09:25:16 2021
+++ src/usr.bin/xlint/lint1/lex.c	Sun Jan 24 09:44:35 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.6 2021/01/24 09:25:16 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.7 2021/01/24 09:44:35 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: lex.c,v 1.6 2021/01/24 09:25:16 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.7 2021/01/24 09:44:35 rillig Exp $");
 #endif
 
 #include 
@@ -845,13 +845,15 @@ int
 lex_wide_character_constant(void)
 {
 	static	char buf[MB_LEN_MAX + 1];
-	size_t	i;
+	size_t	i, imax;
 	int c;
 	wchar_t	wc;
 
+	imax = MB_CUR_MAX;
+
 	i = 0;
 	while ((c = get_escaped_char('\'')) >= 0) {
-		if (i < MB_CUR_MAX)
+		if (i < imax)
 			buf[i] = (char)c;
 		i++;
 	}
@@ -865,14 +867,14 @@ lex_wide_character_constant(void)
 		/* empty character constant */
 		error(73);
 	} else {
-		if (i > MB_CUR_MAX) {
-			i = MB_CUR_MAX;
+		if (i > imax) {
+			i = imax;
 			/* too many characters in character constant */
 			error(71);
 		} else {
 			buf[i] = '\0';
 			(void)mbtowc(NULL, NULL, 0);
-			if (mbtowc(, buf, MB_CUR_MAX) < 0)
+			if (mbtowc(, buf, imax) < 0)
 /* invalid multibyte character */
 error(291);
 		}



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

2021-01-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 24 09:25:17 UTC 2021

Modified Files:
src/usr.bin/xlint/lint1: externs1.h lex.c scan.l

Log Message:
lint: expand abbreviations in lexer function names

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/usr.bin/xlint/lint1/externs1.h
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/xlint/lint1/lex.c
cvs rdiff -u -r1.130 -r1.131 src/usr.bin/xlint/lint1/scan.l

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/externs1.h
diff -u src/usr.bin/xlint/lint1/externs1.h:1.62 src/usr.bin/xlint/lint1/externs1.h:1.63
--- src/usr.bin/xlint/lint1/externs1.h:1.62	Sat Jan 23 23:11:40 2021
+++ src/usr.bin/xlint/lint1/externs1.h	Sun Jan 24 09:25:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: externs1.h,v 1.62 2021/01/23 23:11:40 rillig Exp $	*/
+/*	$NetBSD: externs1.h,v 1.63 2021/01/24 09:25:16 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -310,18 +310,18 @@ extern	void	outusg(const sym_t *);
  * lex.c
  */
 extern	int	lex_name(const char *, size_t);
-extern	int	lex_icon(const char *, size_t, int);
-extern	int	lex_fcon(const char *, size_t);
+extern	int	lex_integer_constant(const char *, size_t, int);
+extern	int	lex_floating_constant(const char *, size_t);
 extern	int	lex_operator(int, op_t);
 extern	int	lex_string(void);
-extern	int	lex_wcstrg(void);
-extern	int	lex_ccon(void);
-extern	int	lex_wccon(void);
+extern	int	lex_wide_string(void);
+extern	int	lex_character_constant(void);
+extern	int	lex_wide_character_constant(void);
 extern	void	lex_directive(const char *);
-extern	void	lex_incline(void);
+extern	void	lex_next_line(void);
 extern	void	lex_comment(void);
-extern	void	lex_slashslashcomment(void);
-extern	void	lex_badchar(int);
+extern	void	lex_slash_slash_comment(void);
+extern	void	lex_unknown_character(int);
 extern	int	lex_input(void);
 
 /*

Index: src/usr.bin/xlint/lint1/lex.c
diff -u src/usr.bin/xlint/lint1/lex.c:1.5 src/usr.bin/xlint/lint1/lex.c:1.6
--- src/usr.bin/xlint/lint1/lex.c:1.5	Sun Jan 24 07:58:48 2021
+++ src/usr.bin/xlint/lint1/lex.c	Sun Jan 24 09:25:16 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.5 2021/01/24 07:58:48 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.6 2021/01/24 09:25:16 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: lex.c,v 1.5 2021/01/24 07:58:48 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.6 2021/01/24 09:25:16 rillig Exp $");
 #endif
 
 #include 
@@ -75,10 +75,10 @@ static	int	inpc(void);
 static	int	hash(const char *);
 static	sym_t *	search(sbuf_t *);
 static	int	keyw(sym_t *);
-static	int	getescc(int);
+static	int	get_escaped_char(int);
 
 void
-lex_incline(void)
+lex_next_line(void)
 {
 	curr_pos.p_line++;
 	curr_pos.p_uniq = 0;
@@ -92,7 +92,7 @@ lex_incline(void)
 }
 
 void
-lex_badchar(int c)
+lex_unknown_character(int c)
 {
 
 	/* unknown character \%o */
@@ -362,7 +362,7 @@ inpc(void)
 	int	c;
 
 	if ((c = lex_input()) != EOF && (c &= CHAR_MASK) == '\n')
-		lex_incline();
+		lex_next_line();
 	return c;
 }
 
@@ -470,7 +470,7 @@ keyw(sym_t *sym)
  * The value is returned in yylval. icon() (and yylex()) returns T_CON.
  */
 int
-lex_icon(const char *yytext, size_t yyleng, int base)
+lex_integer_constant(const char *yytext, size_t yyleng, int base)
 {
 	int	l_suffix, u_suffix;
 	int	len;
@@ -711,7 +711,7 @@ xsign(int64_t q, tspec_t t, int len)
  * long double which are greater than DBL_MAX.
  */
 int
-lex_fcon(const char *yytext, size_t yyleng)
+lex_floating_constant(const char *yytext, size_t yyleng)
 {
 	const	char *cp;
 	int	len;
@@ -799,7 +799,7 @@ lex_operator(int t, op_t o)
  * Called if lex found a leading \'.
  */
 int
-lex_ccon(void)
+lex_character_constant(void)
 {
 	size_t	n;
 	int val, c;
@@ -807,7 +807,7 @@ lex_ccon(void)
 
 	n = 0;
 	val = 0;
-	while ((c = getescc('\'')) >= 0) {
+	while ((c = get_escaped_char('\'')) >= 0) {
 		val = (val << CHAR_SIZE) + c;
 		n++;
 	}
@@ -842,7 +842,7 @@ lex_ccon(void)
  * Called if lex found a leading L\'
  */
 int
-lex_wccon(void)
+lex_wide_character_constant(void)
 {
 	static	char buf[MB_LEN_MAX + 1];
 	size_t	i;
@@ -850,7 +850,7 @@ lex_wccon(void)
 	wchar_t	wc;
 
 	i = 0;
-	while ((c = getescc('\'')) >= 0) {
+	while ((c = get_escaped_char('\'')) >= 0) {
 		if (i < MB_CUR_MAX)
 			buf[i] = (char)c;
 		i++;
@@ -896,7 +896,7 @@ lex_wccon(void)
  * -2 if the EOF is reached, and the character otherwise.
  */
 static int
-getescc(int delim)
+get_escaped_char(int delim)
 {
 	static	int pbc = -1;
 	int	n, c, v;
@@ -1006,7 +1006,7 @@ getescc(int delim)
 			}
 			return v;
 		case '\n':
-			return getescc(delim);
+			return get_escaped_char(delim);
 		case EOF:
 			return -2;
 		default:
@@ -1228,7 +1228,7 @@ skip_rest:
  * Handle // style comments
  */
 void

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

2021-01-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 24 09:18:42 UTC 2021

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

Log Message:
lint: improve introduction of test d_c99_bool_strict_syshdr


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 \
src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c \
src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.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/d_c99_bool_strict_syshdr.c
diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c:1.7 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c:1.8
--- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c:1.7	Sun Jan 24 07:58:48 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c	Sun Jan 24 09:18:42 2021
@@ -1,11 +1,22 @@
-/*	$NetBSD: d_c99_bool_strict_syshdr.c,v 1.7 2021/01/24 07:58:48 rillig Exp $	*/
+/*	$NetBSD: d_c99_bool_strict_syshdr.c,v 1.8 2021/01/24 09:18:42 rillig Exp $	*/
 # 3 "d_c99_bool_strict_syshdr.c"
 
 /*
- * Macros from system headers may use int expressions where bool expressions
- * are expected.  These headers are not allowed to include 
- * themselves, and even if they could, lint must accept other scalar types
- * as well, since system headers are not changed lightheartedly.
+ * In strict bool mode, lint treats bool as incompatible with any other scalar
+ * types.  This mode helps in migrating code from pre-C99 to C99.
+ *
+ * System headers, on the other hand, cannot be migrated if they need to stay
+ * compatible with pre-C99 code.  Therefore, the checks for system headers are
+ * loosened.  In contexts where a scalar expression is compared to 0, macros
+ * and functions from system headers may use int expressions as well.
+ *
+ * These headers are not allowed to include [references needed].
+ * Doing so would inject lint's own , which defines the macros
+ * false and true to other identifiers instead of the plain 0 and 1, thereby
+ * allowing to see whether the code really uses true and false as identifiers.
+ *
+ * Since the system headers cannot include , they need to use the
+ * traditional bool constants 0 and 1.
  */
 
 /* lint1-extra-flags: -T */
@@ -31,12 +42,12 @@ strict_bool_system_header_statement_macr
 		println("nothing");
 	} while (/*CONSTCOND*/0);	/* expect: 333 */
 
-# 35 "d_c99_bool_strict_syshdr.c" 3 4
+# 46 "d_c99_bool_strict_syshdr.c" 3 4
 	do {
 		println("nothing");
 	} while (/*CONSTCOND*/0);	/* ok */
 
-# 40 "d_c99_bool_strict_syshdr.c"
+# 51 "d_c99_bool_strict_syshdr.c"
 	do {
 		println("nothing");
 	} while (/*CONSTCOND*/0);	/* expect: 333 */
@@ -70,28 +81,28 @@ strict_bool_system_header_ctype(int c)
 	 * All other combinations of type are safe from truncation.
 	 */
 	_Bool system_int_assigned_to_bool =
-# 74 "d_c99_bool_strict_syshdr.c" 3 4
+# 85 "d_c99_bool_strict_syshdr.c" 3 4
 	(int)((ctype_table + 1)[c] & 0x0040)	/* INT */
-# 76 "d_c99_bool_strict_syshdr.c"
+# 87 "d_c99_bool_strict_syshdr.c"
 	;			/* expect: 107 */
 
 	int system_bool_assigned_to_int =
-# 80 "d_c99_bool_strict_syshdr.c" 3 4
+# 91 "d_c99_bool_strict_syshdr.c" 3 4
 	(int)((ctype_table + 1)[c] & 0x0040) != 0	/* BOOL */
-# 82 "d_c99_bool_strict_syshdr.c"
+# 93 "d_c99_bool_strict_syshdr.c"
 	;
 
 	if (
-# 86 "d_c99_bool_strict_syshdr.c" 3 4
+# 97 "d_c99_bool_strict_syshdr.c" 3 4
 	(int)((ctype_table + 1)[c] & 0x0040)	/* INT */
-# 88 "d_c99_bool_strict_syshdr.c"
+# 99 "d_c99_bool_strict_syshdr.c"
 	)
 		println("system macro returning INT");
 
 	if (
-# 93 "d_c99_bool_strict_syshdr.c" 3 4
+# 104 "d_c99_bool_strict_syshdr.c" 3 4
 	((ctype_table + 1)[c] & 0x0040) != 0	/* BOOL */
-# 95 "d_c99_bool_strict_syshdr.c"
+# 106 "d_c99_bool_strict_syshdr.c"
 	)
 		println("system macro returning BOOL");
 }
@@ -100,9 +111,9 @@ static inline _Bool
 ch_isspace_sys_int(char c)
 {
 	return
-# 104 "d_c99_bool_strict_syshdr.c" 3 4
+# 115 "d_c99_bool_strict_syshdr.c" 3 4
 	((ctype_table + 1)[c] & 0x0040)
-# 106 "d_c99_bool_strict_syshdr.c"
+# 117 "d_c99_bool_strict_syshdr.c"
 	!= 0;
 }
 
@@ -115,9 +126,9 @@ static inline _Bool
 ch_isspace_sys_bool(char c)
 {
 	return
-# 119 "d_c99_bool_strict_syshdr.c" 3 4
+# 130 "d_c99_bool_strict_syshdr.c" 3 4
 	((ctype_table + 1)[(unsigned char)c] & 0x0040) != 0
-# 121 "d_c99_bool_strict_syshdr.c"
+# 132 "d_c99_bool_strict_syshdr.c"
 	!= 0;
 }
 
@@ -142,7 +153,7 @@ ch_isspace_sys_bool(char c)
 extern int finite(double);
 # 1 "string.h" 3 4
 extern int strcmp(const char *, const char *);
-# 146 "d_c99_bool_strict_syshdr.c"
+# 157 "d_c99_bool_strict_syshdr.c"
 
 /*ARGSUSED*/
 _Bool
Index: src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp
diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp:1.7 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp:1.8
---