CVS commit: src/sys/dev/pci/ixgbe

2021-01-19 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Jan 20 06:53:17 UTC 2021

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe_vf.c

Log Message:
 The max number of queue(pair) is not 7 but 8. Inspired by DPDK.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/dev/pci/ixgbe/ixgbe_vf.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/ixgbe/ixgbe_vf.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_vf.c:1.25 src/sys/dev/pci/ixgbe/ixgbe_vf.c:1.26
--- src/sys/dev/pci/ixgbe/ixgbe_vf.c:1.25	Mon Nov 30 05:30:56 2020
+++ src/sys/dev/pci/ixgbe/ixgbe_vf.c	Wed Jan 20 06:53:17 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_vf.c,v 1.25 2020/11/30 05:30:56 msaitoh Exp $ */
+/* $NetBSD: ixgbe_vf.c,v 1.26 2021/01/20 06:53:17 msaitoh Exp $ */
 
 /**
   SPDX-License-Identifier: BSD-3-Clause
@@ -121,7 +121,8 @@ static void ixgbe_virt_clr_reg(struct ix
 
 	IXGBE_WRITE_REG(hw, IXGBE_VFPSRTYPE, 0);
 
-	for (i = 0; i < 7; i++) {
+	KASSERT(IXGBE_VF_MAX_TX_QUEUES == IXGBE_VF_MAX_RX_QUEUES);
+	for (i = 0; i < IXGBE_VF_MAX_TX_QUEUES; i++) {
 		IXGBE_WRITE_REG(hw, IXGBE_VFRDH(i), 0);
 		IXGBE_WRITE_REG(hw, IXGBE_VFRDT(i), 0);
 		IXGBE_WRITE_REG(hw, IXGBE_VFRXDCTL(i), 0);



CVS commit: src/sys/arch

2021-01-19 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Wed Jan 20 01:20:26 UTC 2021

Modified Files:
src/sys/arch/evbarm/conf: ARMADILLO9 CUBOX DUOVERO GUMSTIX HDL_G
HPT5325 OPENBLOCKS_A6 PEPPER SHEEVAPLUG
src/sys/arch/riscv/conf: GENERIC

Log Message:
do not enable kernel OSS compat in configs without compat_linux

perhaps kernel OSS compat can be merged into compat_linux to avoid
further confusion


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/sys/arch/evbarm/conf/ARMADILLO9
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/evbarm/conf/CUBOX
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/evbarm/conf/DUOVERO
cvs rdiff -u -r1.107 -r1.108 src/sys/arch/evbarm/conf/GUMSTIX
cvs rdiff -u -r1.64 -r1.65 src/sys/arch/evbarm/conf/HDL_G
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/evbarm/conf/HPT5325
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/evbarm/conf/OPENBLOCKS_A6
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/evbarm/conf/PEPPER
cvs rdiff -u -r1.72 -r1.73 src/sys/arch/evbarm/conf/SHEEVAPLUG
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/riscv/conf/GENERIC

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/ARMADILLO9
diff -u src/sys/arch/evbarm/conf/ARMADILLO9:1.65 src/sys/arch/evbarm/conf/ARMADILLO9:1.66
--- src/sys/arch/evbarm/conf/ARMADILLO9:1.65	Sun Sep 27 13:48:50 2020
+++ src/sys/arch/evbarm/conf/ARMADILLO9	Wed Jan 20 01:20:26 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: ARMADILLO9,v 1.65 2020/09/27 13:48:50 roy Exp $
+#	$NetBSD: ARMADILLO9,v 1.66 2021/01/20 01:20:26 nia Exp $
 #
 #	ARMADILLO9 -- Atmark Techno, Armadillo-9
 #
@@ -72,8 +72,6 @@ options 	NFS_BOOT_DHCP
 include 	"conf/compat_netbsd20.config"
 options 	COMPAT_NETBSD32	# allow running arm (e.g. non-earm) binaries
 
-options 	COMPAT_OSSAUDIO	# OSS (Voxware) audio driver compatibility
-
 # Shared memory options
 options 	SYSVMSG		# System V-like message queues
 options 	SYSVSEM		# System V-like semaphores

Index: src/sys/arch/evbarm/conf/CUBOX
diff -u src/sys/arch/evbarm/conf/CUBOX:1.19 src/sys/arch/evbarm/conf/CUBOX:1.20
--- src/sys/arch/evbarm/conf/CUBOX:1.19	Sun Sep 27 13:48:50 2020
+++ src/sys/arch/evbarm/conf/CUBOX	Wed Jan 20 01:20:26 2021
@@ -1,4 +1,4 @@
-# $NetBSD: CUBOX,v 1.19 2020/09/27 13:48:50 roy Exp $
+# $NetBSD: CUBOX,v 1.20 2021/01/20 01:20:26 nia Exp $
 #
 #	CUBOX -- SolidRun Ltd. Cubox kernel
 #
@@ -77,8 +77,6 @@ makeoptions	COPY_SYMTAB=1
 include 	"conf/compat_netbsd60.config"
 options 	COMPAT_NETBSD32	# allow running arm (e.g. non-earm) binaries
 
-options 	COMPAT_OSSAUDIO	# OSS (Voxware) audio driver compatibility
-
 # Wedge support
 options 	DKWEDGE_AUTODISCOVER	# Automatically add dk(4) instances
 options 	DKWEDGE_METHOD_GPT	# Supports GPT partitions as wedges

Index: src/sys/arch/evbarm/conf/DUOVERO
diff -u src/sys/arch/evbarm/conf/DUOVERO:1.22 src/sys/arch/evbarm/conf/DUOVERO:1.23
--- src/sys/arch/evbarm/conf/DUOVERO:1.22	Tue Sep 29 19:58:50 2020
+++ src/sys/arch/evbarm/conf/DUOVERO	Wed Jan 20 01:20:26 2021
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: DUOVERO,v 1.22 2020/09/29 19:58:50 jmcneill Exp $
+#	$NetBSD: DUOVERO,v 1.23 2021/01/20 01:20:26 nia Exp $
 #
 #	DUOOVERO -- Gumstix. Inc. DuoVero COMS platforms kernel
 #
@@ -100,8 +100,6 @@ options 	NFS_BOOT_DHCP
 include 	"conf/compat_netbsd30.config"
 options 	COMPAT_NETBSD32	# allow running arm (e.g. non-earm) binaries
 
-options 	COMPAT_OSSAUDIO	# OSS (Voxware) audio driver compatibility
-
 # Shared memory options
 
 #options 	SYSVMSG		# System V-like message queues

Index: src/sys/arch/evbarm/conf/GUMSTIX
diff -u src/sys/arch/evbarm/conf/GUMSTIX:1.107 src/sys/arch/evbarm/conf/GUMSTIX:1.108
--- src/sys/arch/evbarm/conf/GUMSTIX:1.107	Sun Sep 27 13:48:50 2020
+++ src/sys/arch/evbarm/conf/GUMSTIX	Wed Jan 20 01:20:26 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: GUMSTIX,v 1.107 2020/09/27 13:48:50 roy Exp $
+#	$NetBSD: GUMSTIX,v 1.108 2021/01/20 01:20:26 nia Exp $
 #
 #	GUMSTIX -- Gumstix. Inc. gumstix platforms kernel
 #
@@ -96,8 +96,6 @@ options 	NFS_BOOT_DHCP
 include 	"conf/compat_netbsd16.config"
 options 	COMPAT_NETBSD32	# allow running arm (e.g. non-earm) binaries
 
-options 	COMPAT_OSSAUDIO	# OSS (Voxware) audio driver compatibility
-
 # Shared memory options
 
 #options 	SYSVMSG		# System V-like message queues

Index: src/sys/arch/evbarm/conf/HDL_G
diff -u src/sys/arch/evbarm/conf/HDL_G:1.64 src/sys/arch/evbarm/conf/HDL_G:1.65
--- src/sys/arch/evbarm/conf/HDL_G:1.64	Sun Sep 27 13:48:50 2020
+++ src/sys/arch/evbarm/conf/HDL_G	Wed Jan 20 01:20:26 2021
@@ -1,4 +1,4 @@
-# $NetBSD: HDL_G,v 1.64 2020/09/27 13:48:50 roy Exp $
+# $NetBSD: HDL_G,v 1.65 2021/01/20 01:20:26 nia Exp $
 #
 #   HDL_G -- I-O DATA HDL-G Kernel
 #
@@ -84,8 +84,6 @@ options 	NFS_BOOT_BOOTPARAM
 include 	"conf/compat_netbsd09.config"
 options 	COMPAT_NETBSD32	# allow running arm (e.g. non-earm) binaries
 
-options 	COMPAT_OSSAUDIO	# OSS (Voxware) audio driver compatibility
-
 # Shared memory options
 
 options 	

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

2021-01-19 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jan 20 00:48:49 UTC 2021

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

Log Message:
Fix previous; of_search_compatible returns the sentinel when there is no
match, so we need to test ->data for NULL, not the return value.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sunxi/sunxi_sramc.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.6 src/sys/arch/arm/sunxi/sunxi_sramc.c:1.7
--- src/sys/arch/arm/sunxi/sunxi_sramc.c:1.6	Tue Jan 19 00:35:10 2021
+++ src/sys/arch/arm/sunxi/sunxi_sramc.c	Wed Jan 20 00:48:49 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_sramc.c,v 1.6 2021/01/19 00:35:10 thorpej Exp $ */
+/* $NetBSD: sunxi_sramc.c,v 1.7 2021/01/20 00:48:49 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_sramc.c,v 1.6 2021/01/19 00:35:10 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_sramc.c,v 1.7 2021/01/20 00:48:49 jmcneill 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 != NULL) {
+		if (dce->data != NULL) {
 			node = kmem_alloc(sizeof(*node), KM_SLEEP);
 			node->phandle = child;
 			node->area = dce->data;



CVS commit: src/sys/dev/ofw

2021-01-19 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jan 20 00:41:15 UTC 2021

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

Log Message:
update comment to match new reality


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 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.42 src/sys/dev/ofw/ofw_subr.c:1.43
--- src/sys/dev/ofw/ofw_subr.c:1.42	Mon Jan 18 02:35:49 2021
+++ src/sys/dev/ofw/ofw_subr.c	Wed Jan 20 00:41:15 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofw_subr.c,v 1.42 2021/01/18 02:35:49 thorpej Exp $	*/
+/*	$NetBSD: ofw_subr.c,v 1.43 2021/01/20 00:41:15 jmcneill Exp $	*/
 
 /*
  * Copyright 1998
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.42 2021/01/18 02:35:49 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.43 2021/01/20 00:41:15 jmcneill Exp $");
 
 #include 
 #include 
@@ -225,7 +225,8 @@ of_match_compat_data(int phandle,
 }
 
 /*
- * const struct of_compat_data *of_search_compatible(phandle, compat_data)
+ * const struct device_compatible_entry *of_search_compatible(phandle,
+ *			  compat_data)
  *
  * This routine searches an array of compat_data structures for a
  * matching "compatible" entry matching the supplied OFW node.



CVS commit: src/usr.bin/make

2021-01-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jan 19 22:12:44 UTC 2021

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

Log Message:
make(1): extract DetermineKindOfConditional from Cond_EvalLine


To generate a diff of this commit:
cvs rdiff -u -r1.243 -r1.244 src/usr.bin/make/cond.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/cond.c
diff -u src/usr.bin/make/cond.c:1.243 src/usr.bin/make/cond.c:1.244
--- src/usr.bin/make/cond.c:1.243	Tue Jan 19 21:55:20 2021
+++ src/usr.bin/make/cond.c	Tue Jan 19 22:12:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.243 2021/01/19 21:55:20 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.244 2021/01/19 22:12:44 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.243 2021/01/19 21:55:20 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.244 2021/01/19 22:12:44 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -1061,6 +1061,43 @@ IsEndif(const char *p)
 	   p[3] == 'i' && p[4] == 'f' && !ch_isalpha(p[5]);
 }
 
+static Boolean
+DetermineKindOfConditional(const char **pp, Boolean *out_plain,
+			   Boolean (**out_evalBare)(size_t, const char *),
+			   Boolean *out_negate)
+{
+	const char *p = *pp;
+
+	p += 2;
+	*out_plain = FALSE;
+	*out_evalBare = FuncDefined;
+	*out_negate = FALSE;
+	if (*p == 'n') {
+		p++;
+		*out_negate = TRUE;
+	}
+	if (is_token(p, "def", 3)) {		/* .ifdef and .ifndef */
+		p += 3;
+	} else if (is_token(p, "make", 4)) {	/* .ifmake and .ifnmake */
+		p += 4;
+		*out_evalBare = FuncMake;
+	} else if (is_token(p, "", 0) && !*out_negate) { /* plain .if */
+		*out_plain = TRUE;
+	} else {
+		/*
+		 * TODO: Add error message about unknown directive,
+		 * since there is no other known directive that starts
+		 * with 'el' or 'if'.
+		 *
+		 * Example: .elifx 123
+		 */
+		return FALSE;
+	}
+
+	*pp = p;
+	return TRUE;
+}
+
 /*
  * Evaluate the conditional directive in the line, which is one of:
  *
@@ -1199,36 +1236,8 @@ Cond_EvalLine(const char *line)
 		return COND_INVALID;	/* Not an ifxxx or elifxxx line */
 	}
 
-	/*
-	 * Figure out what sort of conditional it is.
-	 */
-	p += 2;
-	plain = FALSE;
-	evalBare = FuncDefined;
-	negate = FALSE;
-	if (*p == 'n') {
-		p++;
-		negate = TRUE;
-	}
-	if (is_token(p, "def", 3)) {		/* .ifdef and .ifndef */
-		p += 3;
-	} else if (is_token(p, "make", 4)) {	/* .ifmake and .ifnmake */
-		p += 4;
-		evalBare = FuncMake;
-	} else if (is_token(p, "", 0) && !negate) {	/* plain .if */
-		plain = TRUE;
-	} else {
-		/*
-		 * TODO: Add error message about unknown directive,
-		 * since there is no other known directive that starts
-		 * with 'el' or 'if'.
-		 *
-		 * Example: .elifx 123
-		 */
+	if (!DetermineKindOfConditional(, , , ))
 		return COND_INVALID;
-	}
-
-	/* Now we know what sort of 'if' it is... */
 
 	if (isElif) {
 		if (cond_depth == cond_min_depth) {



CVS commit: src/usr.bin/make

2021-01-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jan 19 21:55:20 UTC 2021

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

Log Message:
make(1): remove struct If from evaluation of conditionals

The variant of the .if directive can be stored in the CondParser
directly, instead of pointing to a struct If.

The type CondParser may have to be renamed since the condition is not
only parsed, it is evaluated as well.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.242 -r1.243 src/usr.bin/make/cond.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/cond.c
diff -u src/usr.bin/make/cond.c:1.242 src/usr.bin/make/cond.c:1.243
--- src/usr.bin/make/cond.c:1.242	Tue Jan 19 20:51:46 2021
+++ src/usr.bin/make/cond.c	Tue Jan 19 21:55:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.242 2021/01/19 20:51:46 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.243 2021/01/19 21:55:20 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.242 2021/01/19 20:51:46 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.243 2021/01/19 21:55:20 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -138,7 +138,18 @@ typedef enum CondResult {
 } CondResult;
 
 typedef struct CondParser {
-	const struct If *if_info; /* Info for current statement */
+
+	/*
+	 * The plain '.if ${VAR}' evaluates to true if the value of the
+	 * expression has length > 0.  The other '.if' variants delegate
+	 * to evalBare instead.
+	 */
+	Boolean plain;
+
+	/* The function to apply on unquoted bare words. */
+	Boolean (*evalBare)(size_t, const char *);
+	Boolean negateEvalBare;
+
 	const char *p;		/* The remaining condition to parse */
 	Token curr;		/* Single push-back token used in parsing */
 
@@ -511,32 +522,11 @@ cleanup:
 	*out_str = str;
 }
 
-struct If {
-	const char *form;	/* Form of if */
-	size_t formlen;		/* Length of form */
-	Boolean doNot;		/* TRUE if default function should be negated */
-	/* The default function to apply on unquoted bare words. */
-	Boolean (*defProc)(size_t, const char *);
-};
-
-/* The different forms of .if directives. */
-static const struct If ifs[] = {
-{ "def",   3, FALSE, FuncDefined },
-{ "ndef",  4, TRUE,  FuncDefined },
-{ "make",  4, FALSE, FuncMake },
-{ "nmake", 5, TRUE,  FuncMake },
-{ "",  0, FALSE, FuncDefined },
-{ NULL,0, FALSE, NULL }
-};
-enum {
-	PLAIN_IF_INDEX = 4
-};
-
 static Boolean
-If_Eval(const struct If *if_info, const char *arg, size_t arglen)
+If_Eval(const CondParser *par, const char *arg, size_t arglen)
 {
-	Boolean res = if_info->defProc(arglen, arg);
-	return if_info->doNot ? !res : res;
+	Boolean res = par->evalBare(arglen, arg);
+	return par->negateEvalBare ? !res : res;
 }
 
 /*
@@ -560,11 +550,10 @@ EvalNotEmpty(CondParser *par, const char
 	 * the evaluation function from that .if variant, which would test
 	 * whether a variable of the given name were defined. */
 	/* XXX: Whitespace should count as empty, just as in ParseEmptyArg. */
-	if (par->if_info->form[0] == '\0')
+	if (par->plain)
 		return value[0] != '\0';
 
-	/* For the other variants of .ifxxx ${...}, use its default function. */
-	return If_Eval(par->if_info, value, strlen(value));
+	return If_Eval(par, value, strlen(value));
 }
 
 /* Evaluate a numerical comparison, such as in ".if ${VAR} >= 9". */
@@ -835,7 +824,7 @@ CondParser_LeafToken(CondParser *par, Bo
 	 * after .if must have been taken literally, so the argument cannot
 	 * be empty - even if it contained a variable expansion.
 	 */
-	t = ToToken(!doEval || If_Eval(par->if_info, arg, arglen));
+	t = ToToken(!doEval || If_Eval(par, arg, arglen));
 	free(arg);
 	return t;
 }
@@ -999,7 +988,7 @@ CondParser_Or(CondParser *par, Boolean d
 }
 
 static CondEvalResult
-CondParser_Eval(CondParser *par, Boolean *value)
+CondParser_Eval(CondParser *par, Boolean *out_value)
 {
 	CondResult res;
 
@@ -1012,7 +1001,7 @@ CondParser_Eval(CondParser *par, Boolean
 	if (CondParser_Token(par, FALSE) != TOK_EOF)
 		return COND_INVALID;
 
-	*value = res == CR_TRUE;
+	*out_value = res == CR_TRUE;
 	return COND_PARSE;
 }
 
@@ -1028,7 +1017,8 @@ CondParser_Eval(CondParser *par, Boolean
  *	(*value) is set to the boolean value of the condition
  */
 static CondEvalResult
-CondEvalExpression(const struct If *info, const char *cond, Boolean *value,
+CondEvalExpression(const char *cond, Boolean *out_value, Boolean plain,
+		   Boolean (*evalBare)(size_t, const char *), Boolean negate,
 		   Boolean eprint, Boolean strictLHS)
 {
 	CondParser par;
@@ -1038,12 +1028,14 @@ CondEvalExpression(const struct If *info
 
 	cpp_skip_hspace();
 
-	par.if_info = info != NULL ? info : ifs + PLAIN_IF_INDEX;
+	par.plain = plain;
+	par.evalBare = 

CVS commit: src/usr.bin/make

2021-01-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jan 19 20:51:46 UTC 2021

Modified Files:
src/usr.bin/make: compat.c cond.c for.c job.c main.c make.h
make_malloc.c make_malloc.h metachar.c metachar.h nonints.h str.c
trace.c trace.h
src/usr.bin/make/filemon: filemon.h filemon_dev.c filemon_ktrace.c

Log Message:
make(1): remove do-not-format markers from comments

These markers had been used inconsistently.  Furthermore the source code
had not been formatted automatically before 2020 at all, otherwise there
wouldn't have been any trailing whitespace left.


To generate a diff of this commit:
cvs rdiff -u -r1.219 -r1.220 src/usr.bin/make/compat.c
cvs rdiff -u -r1.241 -r1.242 src/usr.bin/make/cond.c
cvs rdiff -u -r1.134 -r1.135 src/usr.bin/make/for.c
cvs rdiff -u -r1.397 -r1.398 src/usr.bin/make/job.c
cvs rdiff -u -r1.513 -r1.514 src/usr.bin/make/main.c
cvs rdiff -u -r1.243 -r1.244 src/usr.bin/make/make.h
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/make/make_malloc.c
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/make_malloc.h
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/metachar.c
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/metachar.h
cvs rdiff -u -r1.186 -r1.187 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.78 -r1.79 src/usr.bin/make/str.c
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/make/trace.c
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/trace.h
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/filemon/filemon.h
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/filemon/filemon_dev.c
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/filemon/filemon_ktrace.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/compat.c
diff -u src/usr.bin/make/compat.c:1.219 src/usr.bin/make/compat.c:1.220
--- src/usr.bin/make/compat.c:1.219	Sun Jan 10 21:20:46 2021
+++ src/usr.bin/make/compat.c	Tue Jan 19 20:51:46 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.219 2021/01/10 21:20:46 rillig Exp $	*/
+/*	$NetBSD: compat.c,v 1.220 2021/01/19 20:51:46 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -69,7 +69,7 @@
  * SUCH DAMAGE.
  */
 
-/*-
+/*
  * compat.c --
  *	The routines in this file implement the full-compatibility
  *	mode of PMake. Most of the special functionality of PMake
@@ -96,7 +96,7 @@
 #include "pathnames.h"
 
 /*	"@(#)compat.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: compat.c,v 1.219 2021/01/10 21:20:46 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.220 2021/01/19 20:51:46 rillig Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;

Index: src/usr.bin/make/cond.c
diff -u src/usr.bin/make/cond.c:1.241 src/usr.bin/make/cond.c:1.242
--- src/usr.bin/make/cond.c:1.241	Tue Jan 19 19:29:35 2021
+++ src/usr.bin/make/cond.c	Tue Jan 19 20:51:46 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.241 2021/01/19 19:29:35 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.242 2021/01/19 20:51:46 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.241 2021/01/19 19:29:35 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.242 2021/01/19 20:51:46 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -387,7 +387,7 @@ is_separator(char ch)
 	return ch == '\0' || ch_isspace(ch) || strchr("!=><)", ch) != NULL;
 }
 
-/*-
+/*
  * Parse a string from a variable reference or an optionally quoted
  * string.  This is called for the lhs and rhs of string comparisons.
  *

Index: src/usr.bin/make/for.c
diff -u src/usr.bin/make/for.c:1.134 src/usr.bin/make/for.c:1.135
--- src/usr.bin/make/for.c:1.134	Sun Jan 10 21:20:46 2021
+++ src/usr.bin/make/for.c	Tue Jan 19 20:51:46 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: for.c,v 1.134 2021/01/10 21:20:46 rillig Exp $	*/
+/*	$NetBSD: for.c,v 1.135 2021/01/19 20:51:46 rillig Exp $	*/
 
 /*
  * Copyright (c) 1992, The Regents of the University of California.
@@ -29,7 +29,7 @@
  * SUCH DAMAGE.
  */
 
-/*-
+/*
  * Handling of .for/.endfor loops in a makefile.
  *
  * For loops have the form:
@@ -58,7 +58,7 @@
 #include "make.h"
 
 /*	"@(#)for.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: for.c,v 1.134 2021/01/10 21:20:46 rillig Exp $");
+MAKE_RCSID("$NetBSD: for.c,v 1.135 2021/01/19 20:51:46 rillig Exp $");
 
 static int forLevel = 0;	/* Nesting level */
 

Index: src/usr.bin/make/job.c
diff -u src/usr.bin/make/job.c:1.397 src/usr.bin/make/job.c:1.398
--- src/usr.bin/make/job.c:1.397	Sun Jan 10 23:59:53 2021
+++ src/usr.bin/make/job.c	Tue Jan 19 20:51:46 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.397 2021/01/10 23:59:53 rillig Exp $	*/
+/*	$NetBSD: job.c,v 1.398 2021/01/19 20:51:46 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -69,7 +69,7 @@
  * SUCH DAMAGE.
  */
 
-/*-

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

2021-01-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jan 19 19:54:57 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: cond-cmp-string.exp cond-cmp-string.mk

Log Message:
make(1): add test for unsupported relational string comparisons


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/cond-cmp-string.exp
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/cond-cmp-string.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/cond-cmp-string.exp
diff -u src/usr.bin/make/unit-tests/cond-cmp-string.exp:1.8 src/usr.bin/make/unit-tests/cond-cmp-string.exp:1.9
--- src/usr.bin/make/unit-tests/cond-cmp-string.exp:1.8	Sun Nov 15 14:07:53 2020
+++ src/usr.bin/make/unit-tests/cond-cmp-string.exp	Tue Jan 19 19:54:57 2021
@@ -3,6 +3,14 @@ make: "cond-cmp-string.mk" line 42: Malf
 make: "cond-cmp-string.mk" line 49: warning: String comparison operator must be either == or !=
 make: "cond-cmp-string.mk" line 49: Malformed conditional (!("value" = "value"))
 make: "cond-cmp-string.mk" line 56: Malformed conditional (!("value" === "value"))
+make: "cond-cmp-string.mk" line 113: warning: String comparison operator must be either == or !=
+make: "cond-cmp-string.mk" line 113: Malformed conditional ("string" < "string")
+make: "cond-cmp-string.mk" line 120: warning: String comparison operator must be either == or !=
+make: "cond-cmp-string.mk" line 120: Malformed conditional ("string" <= "string")
+make: "cond-cmp-string.mk" line 127: warning: String comparison operator must be either == or !=
+make: "cond-cmp-string.mk" line 127: Malformed conditional ("string" > "string")
+make: "cond-cmp-string.mk" line 134: warning: String comparison operator must be either == or !=
+make: "cond-cmp-string.mk" line 134: Malformed conditional ("string" >= "string")
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/cond-cmp-string.mk
diff -u src/usr.bin/make/unit-tests/cond-cmp-string.mk:1.13 src/usr.bin/make/unit-tests/cond-cmp-string.mk:1.14
--- src/usr.bin/make/unit-tests/cond-cmp-string.mk:1.13	Sun Nov 15 14:07:53 2020
+++ src/usr.bin/make/unit-tests/cond-cmp-string.mk	Tue Jan 19 19:54:57 2021
@@ -1,4 +1,4 @@
-# $NetBSD: cond-cmp-string.mk,v 1.13 2020/11/15 14:07:53 rillig Exp $
+# $NetBSD: cond-cmp-string.mk,v 1.14 2021/01/19 19:54:57 rillig Exp $
 #
 # Tests for string comparisons in .if conditions.
 
@@ -108,3 +108,31 @@
 .if 12345.0 == "12345"
 .  error
 .endif
+
+# Strings cannot be compared relationally, only for equality.
+.if "string" < "string"
+.  error
+.else
+.  error
+.endif
+
+# Strings cannot be compared relationally, only for equality.
+.if "string" <= "string"
+.  error
+.else
+.  error
+.endif
+
+# Strings cannot be compared relationally, only for equality.
+.if "string" > "string"
+.  error
+.else
+.  error
+.endif
+
+# Strings cannot be compared relationally, only for equality.
+.if "string" >= "string"
+.  error
+.else
+.  error
+.endif



CVS commit: src/usr.bin/make

2021-01-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jan 19 19:29:35 UTC 2021

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

Log Message:
make(1): distinguish between tokens and results in conditionals

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.240 -r1.241 src/usr.bin/make/cond.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/cond.c
diff -u src/usr.bin/make/cond.c:1.240 src/usr.bin/make/cond.c:1.241
--- src/usr.bin/make/cond.c:1.240	Tue Jan 19 18:20:30 2021
+++ src/usr.bin/make/cond.c	Tue Jan 19 19:29:35 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.240 2021/01/19 18:20:30 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.241 2021/01/19 19:29:35 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.240 2021/01/19 18:20:30 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.241 2021/01/19 19:29:35 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -127,15 +127,16 @@ MAKE_RCSID("$NetBSD: cond.c,v 1.240 2021
  * Other terminal symbols are evaluated using either the default function or
  * the function given in the terminal, they return either TOK_TRUE or
  * TOK_FALSE.
- *
- * All non-terminal functions (CondParser_Or, CondParser_And and
- * CondParser_Term) return either TOK_FALSE, TOK_TRUE, or TOK_ERROR on error.
  */
 typedef enum Token {
-	TOK_FALSE = 0, TOK_TRUE = 1, TOK_AND, TOK_OR, TOK_NOT,
+	TOK_FALSE, TOK_TRUE, TOK_AND, TOK_OR, TOK_NOT,
 	TOK_LPAREN, TOK_RPAREN, TOK_EOF, TOK_NONE, TOK_ERROR
 } Token;
 
+typedef enum CondResult {
+	CR_FALSE, CR_TRUE, CR_ERROR
+} CondResult;
+
 typedef struct CondParser {
 	const struct If *if_info; /* Info for current statement */
 	const char *p;		/* The remaining condition to parse */
@@ -150,7 +151,7 @@ typedef struct CondParser {
 	Boolean printedError;
 } CondParser;
 
-static Token CondParser_Or(CondParser *par, Boolean);
+static CondResult CondParser_Or(CondParser *par, Boolean);
 
 static unsigned int cond_depth = 0;	/* current .if nesting level */
 static unsigned int cond_min_depth = 0;	/* depth at makefile open */
@@ -909,62 +910,60 @@ CondParser_Token(CondParser *par, Boolea
  * Term -> '!' Term
  * Term -> Leaf Operator Leaf
  * Term -> Leaf
- *
- * Results:
- *	TOK_TRUE, TOK_FALSE or TOK_ERROR.
  */
-static Token
+static CondResult
 CondParser_Term(CondParser *par, Boolean doEval)
 {
+	CondResult res;
 	Token t;
 
 	t = CondParser_Token(par, doEval);
-	if (t == TOK_TRUE || t == TOK_FALSE)
-		return t;
+	if (t == TOK_TRUE)
+		return CR_TRUE;
+	if (t == TOK_FALSE)
+		return CR_FALSE;
 
 	if (t == TOK_LPAREN) {
-		t = CondParser_Or(par, doEval);
-		if (t == TOK_ERROR)
-			return TOK_ERROR;
+		res = CondParser_Or(par, doEval);
+		if (res == CR_ERROR)
+			return CR_ERROR;
 		if (CondParser_Token(par, doEval) != TOK_RPAREN)
-			return TOK_ERROR;
-		return t;
+			return CR_ERROR;
+		return res;
 	}
 
 	if (t == TOK_NOT) {
-		t = CondParser_Term(par, doEval);
-		if (t == TOK_TRUE)
-			t = TOK_FALSE;
-		else if (t == TOK_FALSE)
-			t = TOK_TRUE;
-		return t;
+		res = CondParser_Term(par, doEval);
+		if (res == CR_TRUE)
+			res = CR_FALSE;
+		else if (res == CR_FALSE)
+			res = CR_TRUE;
+		return res;
 	}
 
-	return TOK_ERROR;
+	return CR_ERROR;
 }
 
 /*
  * And -> Term '&&' And
  * And -> Term
- *
- * Results:
- *	TOK_TRUE, TOK_FALSE or TOK_ERROR
  */
-static Token
+static CondResult
 CondParser_And(CondParser *par, Boolean doEval)
 {
-	Token res, op;
+	CondResult res;
+	Token op;
 
 	res = CondParser_Term(par, doEval);
-	if (res == TOK_ERROR)
-		return TOK_ERROR;
+	if (res == CR_ERROR)
+		return CR_ERROR;
 
 	op = CondParser_Token(par, doEval);
 	if (op == TOK_AND) {
-		if (res == TOK_TRUE)
+		if (res == CR_TRUE)
 			return CondParser_And(par, doEval);
-		if (CondParser_And(par, FALSE) == TOK_ERROR)
-			return TOK_ERROR;
+		if (CondParser_And(par, FALSE) == CR_ERROR)
+			return CR_ERROR;
 		return res;
 	}
 
@@ -975,25 +974,23 @@ CondParser_And(CondParser *par, Boolean 
 /*
  * Or -> And '||' Or
  * Or -> And
- *
- * Results:
- *	TOK_TRUE, TOK_FALSE or TOK_ERROR.
  */
-static Token
+static CondResult
 CondParser_Or(CondParser *par, Boolean doEval)
 {
-	Token res, op;
+	CondResult res;
+	Token op;
 
 	res = CondParser_And(par, doEval);
-	if (res == TOK_ERROR)
-		return TOK_ERROR;
+	if (res == CR_ERROR)
+		return CR_ERROR;
 
 	op = CondParser_Token(par, doEval);
 	if (op == TOK_OR) {
-		if (res == TOK_FALSE)
+		if (res == CR_FALSE)
 			return CondParser_Or(par, doEval);
-		if (CondParser_Or(par, FALSE) == TOK_ERROR)
-			return TOK_ERROR;
+		if (CondParser_Or(par, FALSE) == CR_ERROR)
+			return CR_ERROR;
 		return res;
 	}
 
@@ -1004,18 +1001,18 @@ CondParser_Or(CondParser *par, Boolean d
 static CondEvalResult
 

CVS commit: src/usr.bin/make

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

Modified Files:
src/usr.bin/make: cond.c
src/usr.bin/make/unit-tests: cond-op.mk

Log Message:
make(1): update references to the renamed CondParser functions


To generate a diff of this commit:
cvs rdiff -u -r1.239 -r1.240 src/usr.bin/make/cond.c
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/cond-op.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/cond.c
diff -u src/usr.bin/make/cond.c:1.239 src/usr.bin/make/cond.c:1.240
--- src/usr.bin/make/cond.c:1.239	Tue Jan 19 18:18:43 2021
+++ src/usr.bin/make/cond.c	Tue Jan 19 18:20:30 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.239 2021/01/19 18:18:43 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.240 2021/01/19 18:20:30 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.239 2021/01/19 18:18:43 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.240 2021/01/19 18:20:30 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -128,7 +128,7 @@ MAKE_RCSID("$NetBSD: cond.c,v 1.239 2021
  * the function given in the terminal, they return either TOK_TRUE or
  * TOK_FALSE.
  *
- * All non-terminal functions (CondParser_Expr, CondParser_Factor and
+ * All non-terminal functions (CondParser_Or, CondParser_And and
  * CondParser_Term) return either TOK_FALSE, TOK_TRUE, or TOK_ERROR on error.
  */
 typedef enum Token {

Index: src/usr.bin/make/unit-tests/cond-op.mk
diff -u src/usr.bin/make/unit-tests/cond-op.mk:1.12 src/usr.bin/make/unit-tests/cond-op.mk:1.13
--- src/usr.bin/make/unit-tests/cond-op.mk:1.12	Tue Jan 19 18:13:37 2021
+++ src/usr.bin/make/unit-tests/cond-op.mk	Tue Jan 19 18:20:30 2021
@@ -1,4 +1,4 @@
-# $NetBSD: cond-op.mk,v 1.12 2021/01/19 18:13:37 rillig Exp $
+# $NetBSD: cond-op.mk,v 1.13 2021/01/19 18:20:30 rillig Exp $
 #
 # Tests for operators like &&, ||, ! in .if conditions.
 #
@@ -61,8 +61,8 @@
 # As soon as the parser sees the '$', it knows that the condition will
 # be malformed.  Therefore there is no point in evaluating it.
 #
-# As of 2020-09-11, that part of the condition is evaluated nevertheless,
-# since CondParser_Expr just requests the next token, without restricting
+# As of 2021-01-20, that part of the condition is evaluated nevertheless,
+# since CondParser_Or just requests the next token, without restricting
 # the token to the expected tokens.  If the parser were to restrict the
 # valid follow tokens for the token "0" to those that can actually produce
 # a correct condition (which in this case would be comparison operators,



CVS commit: src/usr.bin/make

2021-01-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jan 19 18:18:43 UTC 2021

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

Log Message:
make(1): condense code for parsing and evaluating conditionals


To generate a diff of this commit:
cvs rdiff -u -r1.238 -r1.239 src/usr.bin/make/cond.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/cond.c
diff -u src/usr.bin/make/cond.c:1.238 src/usr.bin/make/cond.c:1.239
--- src/usr.bin/make/cond.c:1.238	Tue Jan 19 18:13:37 2021
+++ src/usr.bin/make/cond.c	Tue Jan 19 18:18:43 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.238 2021/01/19 18:13:37 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.239 2021/01/19 18:18:43 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,43 +95,39 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.238 2021/01/19 18:13:37 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.239 2021/01/19 18:18:43 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
- *	E -> F || E
- *	E -> F
- *	F -> T && F
- *	F -> T
- *	T -> defined(variable)
- *	T -> make(target)
- *	T -> exists(file)
- *	T -> empty(varspec)
- *	T -> target(name)
- *	T -> commands(name)
- *	T -> symbol
- *	T -> $(varspec) op value
- *	T -> $(varspec) == "string"
- *	T -> $(varspec) != "string"
- *	T -> "string"
- *	T -> ( E )
- *	T -> ! T
- *	op -> == | != | > | < | >= | <=
+ *	Or -> And '||' Or
+ *	Or -> And
+ *	And -> Term '&&' And
+ *	And -> Term
+ *	Term -> Function '(' Argument ')'
+ *	Term -> Leaf Operator Leaf
+ *	Term -> Leaf
+ *	Term -> '(' Or ')'
+ *	Term -> '!' Term
+ *	Leaf -> "string"
+ *	Leaf -> Number
+ *	Leaf -> VariableExpression
+ *	Leaf -> Symbol
+ *	Operator -> '==' | '!=' | '>' | '<' | '>=' | '<='
  *
- * 'symbol' is some other symbol to which the default function is applied.
+ * 'Symbol' is an unquoted string literal to which the default function is
+ * applied.
  *
  * The tokens are scanned by CondToken, which returns:
- *	TOK_AND		for '&' or '&&'
- *	TOK_OR		for '|' or '||'
+ *	TOK_AND		for '&&'
+ *	TOK_OR		for '||'
  *	TOK_NOT		for '!'
  *	TOK_LPAREN	for '('
  *	TOK_RPAREN	for ')'
+ *
  * Other terminal symbols are evaluated using either the default function or
  * the function given in the terminal, they return either TOK_TRUE or
  * TOK_FALSE.
  *
- * TOK_FALSE is 0 and TOK_TRUE 1 so we can directly assign C comparisons.
- *
  * All non-terminal functions (CondParser_Expr, CondParser_Factor and
  * CondParser_Term) return either TOK_FALSE, TOK_TRUE, or TOK_ERROR on error.
  */
@@ -154,7 +150,7 @@ typedef struct CondParser {
 	Boolean printedError;
 } CondParser;
 
-static Token CondParser_Expr(CondParser *par, Boolean);
+static Token CondParser_Or(CondParser *par, Boolean);
 
 static unsigned int cond_depth = 0;	/* current .if nesting level */
 static unsigned int cond_min_depth = 0;	/* depth at makefile open */
@@ -909,11 +905,10 @@ CondParser_Token(CondParser *par, Boolea
 }
 
 /*
- * Parse a single term in the expression. This consists of a terminal symbol
- * or TOK_NOT and a term (not including the binary operators):
- *
- *	T -> defined(variable) | make(target) | exists(file) | symbol
- *	T -> ! T | ( E )
+ * Term -> '(' Or ')'
+ * Term -> '!' Term
+ * Term -> Leaf Operator Leaf
+ * Term -> Leaf
  *
  * Results:
  *	TOK_TRUE, TOK_FALSE or TOK_ERROR.
@@ -928,113 +923,82 @@ CondParser_Term(CondParser *par, Boolean
 		return t;
 
 	if (t == TOK_LPAREN) {
-		/*
-		 * T -> ( E )
-		 */
-		t = CondParser_Expr(par, doEval);
-		if (t != TOK_ERROR) {
-			if (CondParser_Token(par, doEval) != TOK_RPAREN) {
-t = TOK_ERROR;
-			}
-		}
-	} else if (t == TOK_NOT) {
+		t = CondParser_Or(par, doEval);
+		if (t == TOK_ERROR)
+			return TOK_ERROR;
+		if (CondParser_Token(par, doEval) != TOK_RPAREN)
+			return TOK_ERROR;
+		return t;
+	}
+
+	if (t == TOK_NOT) {
 		t = CondParser_Term(par, doEval);
-		if (t == TOK_TRUE) {
+		if (t == TOK_TRUE)
 			t = TOK_FALSE;
-		} else if (t == TOK_FALSE) {
+		else if (t == TOK_FALSE)
 			t = TOK_TRUE;
-		}
-	} else
-		return TOK_ERROR;
+		return t;
+	}
 
-	assert(t == TOK_TRUE || t == TOK_FALSE || t == TOK_ERROR);
-	return t;
+	return TOK_ERROR;
 }
 
 /*
- * Parse a conjunctive factor (nice name, wot?)
- *
- *	F -> T && F | T
+ * And -> Term '&&' And
+ * And -> Term
  *
  * Results:
  *	TOK_TRUE, TOK_FALSE or TOK_ERROR
  */
 static Token
-CondParser_Factor(CondParser *par, Boolean doEval)
+CondParser_And(CondParser *par, Boolean doEval)
 {
-	Token l, o;
+	Token res, op;
 
-	l = CondParser_Term(par, doEval);
-	if (l != TOK_ERROR) {
-		o = CondParser_Token(par, doEval);
+	res = CondParser_Term(par, doEval);
+	if (res == TOK_ERROR)
+		return TOK_ERROR;
 
-		if (o == TOK_AND) {
-			/*
-			 * F -> T && F
-			 *
-			 * If T is TOK_FALSE, the whole thing will be
-			 * TOK_FALSE, but we have 

CVS commit: src/usr.bin/make

2021-01-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jan 19 18:13:37 UTC 2021

Modified Files:
src/usr.bin/make: cond.c
src/usr.bin/make/unit-tests: cond-op.exp cond-op.mk

Log Message:
make(1): add error handling for edge case in malformed conditions


To generate a diff of this commit:
cvs rdiff -u -r1.237 -r1.238 src/usr.bin/make/cond.c
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/cond-op.exp
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/cond-op.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/cond.c
diff -u src/usr.bin/make/cond.c:1.237 src/usr.bin/make/cond.c:1.238
--- src/usr.bin/make/cond.c:1.237	Tue Jan 19 17:57:07 2021
+++ src/usr.bin/make/cond.c	Tue Jan 19 18:13:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.237 2021/01/19 17:57:07 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.238 2021/01/19 18:13:37 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.237 2021/01/19 17:57:07 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.238 2021/01/19 18:13:37 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -980,7 +980,8 @@ CondParser_Factor(CondParser *par, Boole
 			if (l == TOK_TRUE) {
 l = CondParser_Factor(par, doEval);
 			} else {
-(void)CondParser_Factor(par, FALSE);
+if (CondParser_Factor(par, FALSE) == TOK_ERROR)
+	return TOK_ERROR;
 			}
 		} else {
 			/*
@@ -1023,7 +1024,8 @@ CondParser_Expr(CondParser *par, Boolean
 			if (l == TOK_FALSE) {
 l = CondParser_Expr(par, doEval);
 			} else {
-(void)CondParser_Expr(par, FALSE);
+if (CondParser_Expr(par, FALSE) == TOK_ERROR)
+	return TOK_ERROR;
 			}
 		} else {
 			/*

Index: src/usr.bin/make/unit-tests/cond-op.exp
diff -u src/usr.bin/make/unit-tests/cond-op.exp:1.8 src/usr.bin/make/unit-tests/cond-op.exp:1.9
--- src/usr.bin/make/unit-tests/cond-op.exp:1.8	Tue Jan 19 18:09:12 2021
+++ src/usr.bin/make/unit-tests/cond-op.exp	Tue Jan 19 18:13:37 2021
@@ -12,8 +12,8 @@ make: "cond-op.mk" line 93: 1 0 1   =>  
 make: "cond-op.mk" line 93: 1 1 0   =>   0   1 1
 make: "cond-op.mk" line 93: 1 1 1   =>   1   1 1
 make: "cond-op.mk" line 104: Malformed conditional (1 &&)
-make: "cond-op.mk" line 115: Missing argument for ".error"
-make: "cond-op.mk" line 121: Missing argument for ".error"
+make: "cond-op.mk" line 112: Malformed conditional (0 &&)
+make: "cond-op.mk" line 120: Malformed conditional (1 ||)
 make: "cond-op.mk" line 129: Malformed conditional (0 ||)
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests

Index: src/usr.bin/make/unit-tests/cond-op.mk
diff -u src/usr.bin/make/unit-tests/cond-op.mk:1.11 src/usr.bin/make/unit-tests/cond-op.mk:1.12
--- src/usr.bin/make/unit-tests/cond-op.mk:1.11	Tue Jan 19 18:09:12 2021
+++ src/usr.bin/make/unit-tests/cond-op.mk	Tue Jan 19 18:13:37 2021
@@ -1,4 +1,4 @@
-# $NetBSD: cond-op.mk,v 1.11 2021/01/19 18:09:12 rillig Exp $
+# $NetBSD: cond-op.mk,v 1.12 2021/01/19 18:13:37 rillig Exp $
 #
 # Tests for operators like &&, ||, ! in .if conditions.
 #
@@ -107,16 +107,16 @@
 .  error
 .endif
 
-# FIXME: Don't accept this condition as syntactically valid.
-# FIXME: CondParser_Factor, (void).
+# This obviously malformed condition was not detected as such before cond.c
+# 1.238 from 2021-01-19.
 .if 0 &&
 .  error
 .else
 .  error
 .endif
 
-# FIXME: Don't accept this condition as syntactically valid.
-# FIXME: CondParser_Expr, (void).
+# This obviously malformed condition was not detected as such before cond.c
+# 1.238 from 2021-01-19.
 .if 1 ||
 .  error
 .else



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

2021-01-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jan 19 18:09:12 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: cond-op.exp cond-op.mk

Log Message:
make(1): demonstrate missing error handling for malformed conditions


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/cond-op.exp
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/cond-op.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/cond-op.exp
diff -u src/usr.bin/make/unit-tests/cond-op.exp:1.7 src/usr.bin/make/unit-tests/cond-op.exp:1.8
--- src/usr.bin/make/unit-tests/cond-op.exp:1.7	Sun Nov 15 14:58:14 2020
+++ src/usr.bin/make/unit-tests/cond-op.exp	Tue Jan 19 18:09:12 2021
@@ -11,6 +11,10 @@ make: "cond-op.mk" line 93: 1 0 0   =>  
 make: "cond-op.mk" line 93: 1 0 1   =>   1   1 1
 make: "cond-op.mk" line 93: 1 1 0   =>   0   1 1
 make: "cond-op.mk" line 93: 1 1 1   =>   1   1 1
+make: "cond-op.mk" line 104: Malformed conditional (1 &&)
+make: "cond-op.mk" line 115: Missing argument for ".error"
+make: "cond-op.mk" line 121: Missing argument for ".error"
+make: "cond-op.mk" line 129: Malformed conditional (0 ||)
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/cond-op.mk
diff -u src/usr.bin/make/unit-tests/cond-op.mk:1.10 src/usr.bin/make/unit-tests/cond-op.mk:1.11
--- src/usr.bin/make/unit-tests/cond-op.mk:1.10	Sun Nov 15 14:58:14 2020
+++ src/usr.bin/make/unit-tests/cond-op.mk	Tue Jan 19 18:09:12 2021
@@ -1,4 +1,4 @@
-# $NetBSD: cond-op.mk,v 1.10 2020/11/15 14:58:14 rillig Exp $
+# $NetBSD: cond-op.mk,v 1.11 2021/01/19 18:09:12 rillig Exp $
 #
 # Tests for operators like &&, ||, ! in .if conditions.
 #
@@ -98,5 +98,39 @@
 .  endfor
 .endfor
 
+# This condition is obviously malformed.  It is properly detected and also
+# was properly detected before 2021-01-19, but only because the left hand
+# side of the '&&' evaluated to true.
+.if 1 &&
+.  error
+.else
+.  error
+.endif
+
+# FIXME: Don't accept this condition as syntactically valid.
+# FIXME: CondParser_Factor, (void).
+.if 0 &&
+.  error
+.else
+.  error
+.endif
+
+# FIXME: Don't accept this condition as syntactically valid.
+# FIXME: CondParser_Expr, (void).
+.if 1 ||
+.  error
+.else
+.  error
+.endif
+
+# This condition is obviously malformed.  It is properly detected and also
+# was properly detected before 2021-01-19, but only because the left hand
+# side of the '||' evaluated to false.
+.if 0 ||
+.  error
+.else
+.  error
+.endif
+
 all:
 	@:;



CVS commit: src/usr.bin/make

2021-01-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jan 19 17:57:07 UTC 2021

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

Log Message:
make(1): fix possible return values for CondParser_Term

The invalid return values didn't do any harm since CondParser_Factor and
CondParser_Expr passed them through, and CondParser_Eval carefully
checks for TOK_TRUE or TOK_FALSE and treats everything else as an error.

No change in observable behavior since there is no debug logging in that
part of the code.


To generate a diff of this commit:
cvs rdiff -u -r1.236 -r1.237 src/usr.bin/make/cond.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/cond.c
diff -u src/usr.bin/make/cond.c:1.236 src/usr.bin/make/cond.c:1.237
--- src/usr.bin/make/cond.c:1.236	Tue Jan 19 17:49:13 2021
+++ src/usr.bin/make/cond.c	Tue Jan 19 17:57:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.236 2021/01/19 17:49:13 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.237 2021/01/19 17:57:07 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.236 2021/01/19 17:49:13 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.237 2021/01/19 17:57:07 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -924,14 +924,10 @@ CondParser_Term(CondParser *par, Boolean
 	Token t;
 
 	t = CondParser_Token(par, doEval);
+	if (t == TOK_TRUE || t == TOK_FALSE)
+		return t;
 
-	if (t == TOK_EOF) {
-		/*
-		 * If we reached the end of the expression, the expression
-		 * is malformed...
-		 */
-		t = TOK_ERROR;
-	} else if (t == TOK_LPAREN) {
+	if (t == TOK_LPAREN) {
 		/*
 		 * T -> ( E )
 		 */
@@ -948,13 +944,10 @@ CondParser_Term(CondParser *par, Boolean
 		} else if (t == TOK_FALSE) {
 			t = TOK_TRUE;
 		}
-	}
+	} else
+		return TOK_ERROR;
 
-	/*
-	 * FIXME: Can at least return TOK_AND, TOK_OR, TOK_RPAREN, maybe
-	 *  others as well.
-	 */
-	/* TODO: assert(t == TOK_ERROR); */
+	assert(t == TOK_TRUE || t == TOK_FALSE || t == TOK_ERROR);
 	return t;
 }
 



CVS commit: src/usr.bin/make

2021-01-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jan 19 17:49:13 UTC 2021

Modified Files:
src/usr.bin/make: cond.c
src/usr.bin/make/unit-tests: cond-op-not.exp cond-op-not.mk
cond-op-parentheses.exp cond-op-parentheses.mk

Log Message:
make(1): demonstrate wrong return value in CondParser_Term


To generate a diff of this commit:
cvs rdiff -u -r1.235 -r1.236 src/usr.bin/make/cond.c
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/cond-op-not.exp \
src/usr.bin/make/unit-tests/cond-op-parentheses.mk
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cond-op-not.mk
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/cond-op-parentheses.exp

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

Modified files:

Index: src/usr.bin/make/cond.c
diff -u src/usr.bin/make/cond.c:1.235 src/usr.bin/make/cond.c:1.236
--- src/usr.bin/make/cond.c:1.235	Sun Jan 10 21:20:46 2021
+++ src/usr.bin/make/cond.c	Tue Jan 19 17:49:13 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.235 2021/01/10 21:20:46 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.236 2021/01/19 17:49:13 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.235 2021/01/10 21:20:46 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.236 2021/01/19 17:49:13 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -949,6 +949,12 @@ CondParser_Term(CondParser *par, Boolean
 			t = TOK_TRUE;
 		}
 	}
+
+	/*
+	 * FIXME: Can at least return TOK_AND, TOK_OR, TOK_RPAREN, maybe
+	 *  others as well.
+	 */
+	/* TODO: assert(t == TOK_ERROR); */
 	return t;
 }
 

Index: src/usr.bin/make/unit-tests/cond-op-not.exp
diff -u src/usr.bin/make/unit-tests/cond-op-not.exp:1.3 src/usr.bin/make/unit-tests/cond-op-not.exp:1.4
--- src/usr.bin/make/unit-tests/cond-op-not.exp:1.3	Sun Nov 15 14:58:14 2020
+++ src/usr.bin/make/unit-tests/cond-op-not.exp	Tue Jan 19 17:49:13 2021
@@ -3,4 +3,7 @@ make: "cond-op-not.mk" line 37: Not spac
 make: "cond-op-not.mk" line 41: Not 0 evaluates to true.
 make: "cond-op-not.mk" line 49: Not 1 evaluates to false.
 make: "cond-op-not.mk" line 55: Not word evaluates to false.
-exit status 0
+make: "cond-op-not.mk" line 59: Malformed conditional (!)
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1
Index: src/usr.bin/make/unit-tests/cond-op-parentheses.mk
diff -u src/usr.bin/make/unit-tests/cond-op-parentheses.mk:1.3 src/usr.bin/make/unit-tests/cond-op-parentheses.mk:1.4
--- src/usr.bin/make/unit-tests/cond-op-parentheses.mk:1.3	Sun Nov 15 14:58:14 2020
+++ src/usr.bin/make/unit-tests/cond-op-parentheses.mk	Tue Jan 19 17:49:13 2021
@@ -1,4 +1,4 @@
-# $NetBSD: cond-op-parentheses.mk,v 1.3 2020/11/15 14:58:14 rillig Exp $
+# $NetBSD: cond-op-parentheses.mk,v 1.4 2021/01/19 17:49:13 rillig Exp $
 #
 # Tests for parentheses in .if conditions.
 
@@ -15,5 +15,22 @@
 .  error
 .endif
 
+# An unbalanced opening parenthesis is a parse error.
+.if (
+.  error
+.else
+.  error
+.endif
+
+# An unbalanced closing parenthesis is a parse error.
+#
+# As of 2021-01-19, CondParser_Term returned TOK_RPAREN even though this
+# function promised to only ever return TOK_TRUE, TOK_FALSE or TOK_ERROR.
+.if )
+.  error
+.else
+.  error
+.endif
+
 all:
 	@:;

Index: src/usr.bin/make/unit-tests/cond-op-not.mk
diff -u src/usr.bin/make/unit-tests/cond-op-not.mk:1.6 src/usr.bin/make/unit-tests/cond-op-not.mk:1.7
--- src/usr.bin/make/unit-tests/cond-op-not.mk:1.6	Sun Nov 15 14:58:14 2020
+++ src/usr.bin/make/unit-tests/cond-op-not.mk	Tue Jan 19 17:49:13 2021
@@ -1,4 +1,4 @@
-# $NetBSD: cond-op-not.mk,v 1.6 2020/11/15 14:58:14 rillig Exp $
+# $NetBSD: cond-op-not.mk,v 1.7 2021/01/19 17:49:13 rillig Exp $
 #
 # Tests for the ! operator in .if conditions, which negates its argument.
 
@@ -55,5 +55,12 @@
 .  info Not word evaluates to false.
 .endif
 
+# A single exclamation mark is a parse error.
+.if !
+.  error
+.else
+.  error
+.endif
+
 all:
 	@:;

Index: src/usr.bin/make/unit-tests/cond-op-parentheses.exp
diff -u src/usr.bin/make/unit-tests/cond-op-parentheses.exp:1.2 src/usr.bin/make/unit-tests/cond-op-parentheses.exp:1.3
--- src/usr.bin/make/unit-tests/cond-op-parentheses.exp:1.2	Sun Nov 15 14:58:14 2020
+++ src/usr.bin/make/unit-tests/cond-op-parentheses.exp	Tue Jan 19 17:49:13 2021
@@ -1,2 +1,6 @@
 make: "cond-op-parentheses.mk" line 13: Parentheses can be nested at least to depth 112.
-exit status 0
+make: "cond-op-parentheses.mk" line 19: Malformed conditional (()
+make: "cond-op-parentheses.mk" line 29: Malformed conditional ())
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1



CVS commit: src/sys/dev/ofisa

2021-01-19 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Jan 19 14:39:20 UTC 2021

Modified Files:
src/sys/dev/ofisa: atppc_ofisa.c com_ofisa.c ess_ofisa.c if_cs_ofisa.c
joy_ofisa.c lpt_ofisa.c ofisa.c sb_ofisa.c wdc_ofisa.c

Log Message:
of_compatible() is a hokey API (returning -1 for no match) and nothing
here relies on its reverse-index return value semantics, so just use
of_match_compat_data() instead.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/ofisa/atppc_ofisa.c
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/ofisa/com_ofisa.c \
src/sys/dev/ofisa/joy_ofisa.c
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/ofisa/ess_ofisa.c
cvs rdiff -u -r1.27 -r1.28 src/sys/dev/ofisa/if_cs_ofisa.c
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/ofisa/lpt_ofisa.c
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/ofisa/ofisa.c
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/ofisa/sb_ofisa.c
cvs rdiff -u -r1.36 -r1.37 src/sys/dev/ofisa/wdc_ofisa.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/ofisa/atppc_ofisa.c
diff -u src/sys/dev/ofisa/atppc_ofisa.c:1.10 src/sys/dev/ofisa/atppc_ofisa.c:1.11
--- src/sys/dev/ofisa/atppc_ofisa.c:1.10	Mon Apr 28 20:23:54 2008
+++ src/sys/dev/ofisa/atppc_ofisa.c	Tue Jan 19 14:39:20 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: atppc_ofisa.c,v 1.10 2008/04/28 20:23:54 martin Exp $ */
+/* $NetBSD: atppc_ofisa.c,v 1.11 2021/01/19 14:39:20 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: atppc_ofisa.c,v 1.10 2008/04/28 20:23:54 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: atppc_ofisa.c,v 1.11 2021/01/19 14:39:20 thorpej Exp $");
 
 #include "opt_atppc.h"
 
@@ -73,6 +73,12 @@ static int atppc_ofisa_dma_malloc(device
 	bus_size_t);
 static void atppc_ofisa_dma_free(device_t, void **, bus_addr_t *,
 	bus_size_t);
+
+static const struct device_compatible_entry compat_data[] = {
+	{ .compat = "pnpPNP,401" },
+	{ 0 }
+};
+
 /*
  * atppc_ofisa_match: autoconf(9) match routine
  */
@@ -80,11 +86,9 @@ static int
 atppc_ofisa_match(device_t parent, cfdata_t match, void *aux)
 {
 	struct ofisa_attach_args *aa = aux;
-	static const char *const compatible_strings[] = { "pnpPNP,401", NULL };
-	int rv = 0;
+	int rv;
 
-	if (of_compatible(aa->oba.oba_phandle, compatible_strings) != -1)
-		rv = 5;
+	rv = of_match_compat_data(aa->oba.oba_phandle, compat_data) ? 5 : 0;
 #ifdef _LPT_OFISA_MD_MATCH
 	if (!rv)
 		rv = lpt_ofisa_md_match(parent, match, aux);

Index: src/sys/dev/ofisa/com_ofisa.c
diff -u src/sys/dev/ofisa/com_ofisa.c:1.16 src/sys/dev/ofisa/com_ofisa.c:1.17
--- src/sys/dev/ofisa/com_ofisa.c:1.16	Sat Dec  8 17:46:14 2018
+++ src/sys/dev/ofisa/com_ofisa.c	Tue Jan 19 14:39:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: com_ofisa.c,v 1.16 2018/12/08 17:46:14 thorpej Exp $	*/
+/*	$NetBSD: com_ofisa.c,v 1.17 2021/01/19 14:39:20 thorpej Exp $	*/
 
 /*
  * Copyright 1997, 1998
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: com_ofisa.c,v 1.16 2018/12/08 17:46:14 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: com_ofisa.c,v 1.17 2021/01/19 14:39:20 thorpej Exp $");
 
 #include 
 #include 
@@ -68,15 +68,18 @@ void com_ofisa_attach(device_t, device_t
 CFATTACH_DECL_NEW(com_ofisa, sizeof(struct com_ofisa_softc),
 com_ofisa_probe, com_ofisa_attach, NULL, NULL);
 
+static const struct device_compatible_entry compat_data[] = {
+	{ .compat = "pnpPNP,501" },
+	{ 0 }
+};
+
 int
 com_ofisa_probe(device_t parent, cfdata_t cf, void *aux)
 {
 	struct ofisa_attach_args *aa = aux;
-	static const char *const compatible_strings[] = { "pnpPNP,501", NULL };
-	int rv = 0;
+	int rv;
 
-	if (of_compatible(aa->oba.oba_phandle, compatible_strings) != -1)
-		rv = 5;
+	rv = of_match_compat_data(aa->oba.oba_phandle, compat_data) ? 5 : 0;
 #ifdef _COM_OFISA_MD_MATCH
 	if (!rv)
 		rv = com_ofisa_md_match(parent, cf, aux);
Index: src/sys/dev/ofisa/joy_ofisa.c
diff -u src/sys/dev/ofisa/joy_ofisa.c:1.16 src/sys/dev/ofisa/joy_ofisa.c:1.17
--- src/sys/dev/ofisa/joy_ofisa.c:1.16	Fri Dec  9 17:18:35 2016
+++ src/sys/dev/ofisa/joy_ofisa.c	Tue Jan 19 14:39:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: joy_ofisa.c,v 1.16 2016/12/09 17:18:35 christos Exp $	*/
+/*	$NetBSD: joy_ofisa.c,v 1.17 2021/01/19 14:39:20 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1998, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: joy_ofisa.c,v 1.16 2016/12/09 17:18:35 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: joy_ofisa.c,v 1.17 2021/01/19 14:39:20 thorpej Exp $");
 
 #include 
 #include 
@@ -58,19 +58,17 @@ static void	joy_ofisa_attach(device_t, d
 CFATTACH_DECL_NEW(joy_ofisa, sizeof(struct joy_ofisa_softc),
 joy_ofisa_match, joy_ofisa_attach, NULL, NULL);
 
+static const struct device_compatible_entry compat_data[] = {
+	{ .compat = "pnpPNP,b02f" },	/* generic joystick */
+	{ 0 }
+};
+
 static int
 

CVS commit: src/sys/dev/ofisa

2021-01-19 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Jan 19 14:35:30 UTC 2021

Modified Files:
src/sys/dev/ofisa: pckbc_ofisa.c

Log Message:
Use device_compatible_entry / of_search_compatible() for the child
nodes rather than using of_compatible() to match against different
sets of compatible strings.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/ofisa/pckbc_ofisa.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/ofisa/pckbc_ofisa.c
diff -u src/sys/dev/ofisa/pckbc_ofisa.c:1.15 src/sys/dev/ofisa/pckbc_ofisa.c:1.16
--- src/sys/dev/ofisa/pckbc_ofisa.c:1.15	Sat Mar 15 13:23:25 2008
+++ src/sys/dev/ofisa/pckbc_ofisa.c	Tue Jan 19 14:35:30 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pckbc_ofisa.c,v 1.15 2008/03/15 13:23:25 cube Exp $ */
+/* $NetBSD: pckbc_ofisa.c,v 1.16 2021/01/19 14:35:30 thorpej Exp $ */
 
 /*
  * Copyright (c) 1998
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pckbc_ofisa.c,v 1.15 2008/03/15 13:23:25 cube Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pckbc_ofisa.c,v 1.16 2021/01/19 14:35:30 thorpej Exp $");
 
 #include 
 #include 
@@ -64,20 +64,23 @@ CFATTACH_DECL_NEW(pckbc_ofisa, sizeof(st
 
 static void pckbc_ofisa_intr_establish (struct pckbc_softc *, pckbc_slot_t);
 
-static const char *const kb_compatible_strings[] = { "pnpPNP,303", NULL };
-static const char *const ms_compatible_strings[] = { "pnpPNP,f03", NULL };
+static const struct device_compatible_entry compat_data[] = {
+	{ .compat = "INTC,80c42" },
+	{ 0 }
+};
+
+static const struct device_compatible_entry port_compat_data[] = {
+	{ .compat = "pnpPNP,303",	.value = PCKBC_KBD_SLOT },
+	{ .compat = "pnpPNP,f03",	.value = PCKBC_AUX_SLOT },
+	{ 0 }
+};
 
 static int
 pckbc_ofisa_match(device_t parent, cfdata_t match, void *aux)
 {
 	struct ofisa_attach_args *aa = aux;
-	static const char *const compatible_strings[] = { "INTC,80c42", NULL };
-	int rv = 0;
-
-	if (of_compatible(aa->oba.oba_phandle, compatible_strings) != -1)
-		rv = 5;
 
-	return (rv);
+	return of_match_compat_data(aa->oba.oba_phandle, compat_data) ? 5 : 0;
 }
 
 static void
@@ -86,6 +89,7 @@ pckbc_ofisa_attach(device_t parent, devi
 	struct pckbc_ofisa_softc *osc = device_private(self);
 	struct pckbc_softc *sc = >sc_pckbc;
 	struct ofisa_attach_args *aa = aux;
+	const struct device_compatible_entry *dce;
 	struct pckbc_internal *t;
 	bus_space_tag_t iot;
 	bus_space_handle_t ioh_d, ioh_c;
@@ -99,10 +103,9 @@ pckbc_ofisa_attach(device_t parent, devi
 
 	phandle = OF_child(aa->oba.oba_phandle);
 	while (phandle != 0) {
-		if (of_compatible(phandle, kb_compatible_strings) != -1) {
-			ofisa_intr_get(phandle, >sc_intr[PCKBC_KBD_SLOT], 1);
-		} else if (of_compatible(phandle, ms_compatible_strings) != -1) {
-			ofisa_intr_get(phandle, >sc_intr[PCKBC_AUX_SLOT], 1);
+		dce = of_search_compatible(phandle, port_compat_data);
+		if (dce != NULL) {
+			ofisa_intr_get(phandle, >sc_intr[dce->value], 1);
 		}
 		phandle = OF_peer(phandle);
 	}



CVS commit: src/sys/compat/netbsd32

2021-01-19 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Jan 19 08:10:17 UTC 2021

Modified Files:
src/sys/compat/netbsd32: netbsd32_compat_20.c

Log Message:
Fix syntax error


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/compat/netbsd32/netbsd32_compat_20.c

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

Modified files:

Index: src/sys/compat/netbsd32/netbsd32_compat_20.c
diff -u src/sys/compat/netbsd32/netbsd32_compat_20.c:1.40 src/sys/compat/netbsd32/netbsd32_compat_20.c:1.41
--- src/sys/compat/netbsd32/netbsd32_compat_20.c:1.40	Tue Jan 19 03:20:13 2021
+++ src/sys/compat/netbsd32/netbsd32_compat_20.c	Tue Jan 19 08:10:17 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_compat_20.c,v 1.40 2021/01/19 03:20:13 simonb Exp $	*/
+/*	$NetBSD: netbsd32_compat_20.c,v 1.41 2021/01/19 08:10:17 wiz Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_20.c,v 1.40 2021/01/19 03:20:13 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_20.c,v 1.41 2021/01/19 08:10:17 wiz Exp $");
 
 #include 
 #include 
@@ -201,7 +201,7 @@ compat_20_netbsd32_fstatfs(struct lwp *l
  out:
 	STATVFSBUF_PUT(sb);
 	fd_putfile(SCARG(uap, fd));
-	return error)
+	return error;
 }
 
 int