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

2024-01-07 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Jan  8 05:11:54 UTC 2024

Modified Files:
src/sys/arch/virt68k/conf: GENERIC

Log Message:
Add PROCFS and MSDOSFS.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/virt68k/conf/GENERIC

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



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

2024-01-07 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Jan  8 05:11:54 UTC 2024

Modified Files:
src/sys/arch/virt68k/conf: GENERIC

Log Message:
Add PROCFS and MSDOSFS.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/virt68k/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/virt68k/conf/GENERIC
diff -u src/sys/arch/virt68k/conf/GENERIC:1.3 src/sys/arch/virt68k/conf/GENERIC:1.4
--- src/sys/arch/virt68k/conf/GENERIC:1.3	Tue Jan  2 18:11:44 2024
+++ src/sys/arch/virt68k/conf/GENERIC	Mon Jan  8 05:11:54 2024
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.3 2024/01/02 18:11:44 thorpej Exp $
+# $NetBSD: GENERIC,v 1.4 2024/01/08 05:11:54 thorpej Exp $
 #
 # GENERIC machine description file
 # 
@@ -22,7 +22,7 @@ include 	"arch/virt68k/conf/std.virt68k"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.3 $"
+#ident 		"GENERIC-$Revision: 1.4 $"
 
 makeoptions	COPTS="-O2 -fno-reorder-blocks"	# see share/mk/sys.mk
 
@@ -60,9 +60,10 @@ options 	SYSCTL_INCLUDE_DESCR	# Include 
 file-system 	FFS
 file-system 	NFS
 file-system 	KERNFS
+file-system 	PROCFS
 #file-system 	MFS
 file-system 	CD9660
-#file-system	MSDOSFS
+file-system	MSDOSFS
 #file-system	UNION
 file-system	PTYFS		# /dev/pts/N support
 file-system	TMPFS		# Efficient memory file-system



CVS commit: src/sys/arch/virt68k/virt68k

2024-01-07 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Jan  8 05:11:33 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: clock.c

Log Message:
Use aprint_error() rather than a bare printf() in a few spots, and
an aprint_normal() in some others.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/virt68k/virt68k/clock.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/virt68k/virt68k/clock.c
diff -u src/sys/arch/virt68k/virt68k/clock.c:1.1 src/sys/arch/virt68k/virt68k/clock.c:1.2
--- src/sys/arch/virt68k/virt68k/clock.c:1.1	Tue Jan  2 07:41:02 2024
+++ src/sys/arch/virt68k/virt68k/clock.c	Mon Jan  8 05:11:32 2024
@@ -1,4 +1,4 @@
-/*  $NetBSD: clock.c,v 1.1 2024/01/02 07:41:02 thorpej Exp $	*/
+/*  $NetBSD: clock.c,v 1.2 2024/01/08 05:11:32 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.1 2024/01/02 07:41:02 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.2 2024/01/08 05:11:32 thorpej Exp $");
 
 #include 
 #include 
@@ -174,20 +174,20 @@ cpu_initclocks(void)
 	}
 
 	if (100 % hz) {
-		printf("Cannot get %d Hz clock; using 100 Hz\n", hz);
+		aprint_error("Cannot get %d Hz clock; using 100 Hz\n", hz);
 		hz = 100;
 		tick = 100 / hz;
 	}
 
 	if (virt68k_clocks[CLOCK_STATCLOCK].args == NULL) {
-		printf("No statclock; using hardclock.\n");
+		aprint_normal("No statclock; using hardclock.\n");
 		stathz = 0;
 		statint = 0;
 	} else if (stathz == 0) {
 		stathz = hz;
 		if (100 % stathz) {
-			printf("Cannot get %d Hz statclock; using 100 Hz\n",
-			stathz);
+			aprint_error("Cannot get %d Hz statclock; "
+ "using 100 Hz\n", stathz);
 			stathz = 100;
 		}
 		profhz = stathz;	/* always */



CVS commit: src/sys/arch/virt68k/virt68k

2024-01-07 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Jan  8 05:11:33 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: clock.c

Log Message:
Use aprint_error() rather than a bare printf() in a few spots, and
an aprint_normal() in some others.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/virt68k/virt68k/clock.c

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



CVS commit: src/sys/arch/virt68k/virt68k

2024-01-07 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Jan  8 05:10:51 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: autoconf.c machdep.c

Log Message:
Accept "root=xxx" for the root device and "flags=xxx" as the boothowto
flags from the kernel command line arguments.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/virt68k/virt68k/autoconf.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/virt68k/virt68k/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/virt68k/virt68k/autoconf.c
diff -u src/sys/arch/virt68k/virt68k/autoconf.c:1.4 src/sys/arch/virt68k/virt68k/autoconf.c:1.5
--- src/sys/arch/virt68k/virt68k/autoconf.c:1.4	Sun Jan  7 16:41:24 2024
+++ src/sys/arch/virt68k/virt68k/autoconf.c	Mon Jan  8 05:10:51 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.4 2024/01/07 16:41:24 thorpej Exp $	*/
+/*	$NetBSD: autoconf.c,v 1.5 2024/01/08 05:10:51 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -45,7 +45,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.4 2024/01/07 16:41:24 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.5 2024/01/08 05:10:51 thorpej Exp $");
 
 #include 
 #include 
@@ -96,6 +96,26 @@ void
 device_register(device_t dev, void *aux)
 {
 	device_t parent = device_parent(dev);
+	char rootname[DEVICE_XNAME_SIZE];
+	bool rootname_valid = false;
+
+	if (booted_device == NULL) {
+		rootname_valid = bootinfo_getarg("root",
+		rootname, sizeof(rootname));
+		if (rootname_valid) {
+			size_t len = strlen(rootname);
+			while (len) {
+len--;
+if (isdigit(rootname[len])) {
+	break;
+}
+rootname[len] = '\0';
+			}
+			if (strcmp(device_xname(dev), rootname) == 0) {
+booted_device = dev;
+			}
+		}
+	}
 
 	if (device_is_a(parent, "mainbus")) {
 		struct mainbus_attach_args *ma = aux;

Index: src/sys/arch/virt68k/virt68k/machdep.c
diff -u src/sys/arch/virt68k/virt68k/machdep.c:1.5 src/sys/arch/virt68k/virt68k/machdep.c:1.6
--- src/sys/arch/virt68k/virt68k/machdep.c:1.5	Sat Jan  6 21:43:37 2024
+++ src/sys/arch/virt68k/virt68k/machdep.c	Mon Jan  8 05:10:51 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.5 2024/01/06 21:43:37 thorpej Exp $	*/
+/*	$NetBSD: machdep.c,v 1.6 2024/01/08 05:10:51 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.5 2024/01/06 21:43:37 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.6 2024/01/08 05:10:51 thorpej Exp $");
 
 #include "opt_ddb.h"
 #include "opt_m060sp.h"
@@ -70,6 +70,7 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 
 #include 
 #include 
 #include 
+#include 
 
 #include "ksyms.h"
 
@@ -100,8 +101,6 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 
 #include 
 #endif
 
-#define	MAXMEM	64*1024	/* XXX - from cmap.h */
-
 /* the following is used externally (sysctl_hw) */
 char	machine[] = MACHINE;	/* from  */
 
@@ -207,6 +206,17 @@ virt68k_init(void)
 
 	/* Check for RND seed from the loader. */
 	bootinfo_setup_rndseed();
+
+	char flags[32];
+	if (bootinfo_getarg("flags", flags, sizeof(flags))) {
+		for (const char *cp = flags; *cp != '\0'; cp++) {
+			/* Consume 'm' in favor of BI_RAMDISK. */
+			if (*cp == 'm') {
+continue;
+			}
+			BOOT_FLAG(*cp, boothowto);
+		}
+	}
 }
 
 /*



CVS commit: src/sys/arch/virt68k/virt68k

2024-01-07 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Jan  8 05:10:51 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: autoconf.c machdep.c

Log Message:
Accept "root=xxx" for the root device and "flags=xxx" as the boothowto
flags from the kernel command line arguments.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/virt68k/virt68k/autoconf.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/virt68k/virt68k/machdep.c

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



CVS commit: src/sys/arch/virt68k

2024-01-07 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Jan  8 05:09:41 UTC 2024

Modified Files:
src/sys/arch/virt68k/include: bootinfo.h
src/sys/arch/virt68k/virt68k: bootinfo.c

Log Message:
Add bootinfo_getarg(), which gets the name kernel command line argument
and returns its value (sort of like getenv()).


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/virt68k/include/bootinfo.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/virt68k/virt68k/bootinfo.c

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



CVS commit: src/sys/arch/virt68k

2024-01-07 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Jan  8 05:09:41 UTC 2024

Modified Files:
src/sys/arch/virt68k/include: bootinfo.h
src/sys/arch/virt68k/virt68k: bootinfo.c

Log Message:
Add bootinfo_getarg(), which gets the name kernel command line argument
and returns its value (sort of like getenv()).


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/virt68k/include/bootinfo.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/virt68k/virt68k/bootinfo.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/virt68k/include/bootinfo.h
diff -u src/sys/arch/virt68k/include/bootinfo.h:1.4 src/sys/arch/virt68k/include/bootinfo.h:1.5
--- src/sys/arch/virt68k/include/bootinfo.h:1.4	Sat Jan  6 17:32:40 2024
+++ src/sys/arch/virt68k/include/bootinfo.h	Mon Jan  8 05:09:41 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: bootinfo.h,v 1.4 2024/01/06 17:32:40 thorpej Exp $	*/
+/*	$NetBSD: bootinfo.h,v 1.5 2024/01/08 05:09:41 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -156,6 +156,7 @@ bool			bootinfo_addr_is_console(paddr_t)
 
 void			bootinfo_setup_initrd(void);
 void			bootinfo_setup_rndseed(void);
+bool			bootinfo_getarg(const char *, char *, size_t);
 
 void			bootinfo_md_cnattach(void (*)(bus_space_tag_t,
 		  bus_space_handle_t),

Index: src/sys/arch/virt68k/virt68k/bootinfo.c
diff -u src/sys/arch/virt68k/virt68k/bootinfo.c:1.5 src/sys/arch/virt68k/virt68k/bootinfo.c:1.6
--- src/sys/arch/virt68k/virt68k/bootinfo.c:1.5	Sat Jan  6 21:40:41 2024
+++ src/sys/arch/virt68k/virt68k/bootinfo.c	Mon Jan  8 05:09:41 2024
@@ -1,4 +1,4 @@
-/*  $NetBSD: bootinfo.c,v 1.5 2024/01/06 21:40:41 thorpej Exp $*/  
+/*  $NetBSD: bootinfo.c,v 1.6 2024/01/08 05:09:41 thorpej Exp $*/  
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bootinfo.c,v 1.5 2024/01/06 21:40:41 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bootinfo.c,v 1.6 2024/01/08 05:09:41 thorpej Exp $");
 
 #include "opt_md.h"
 
@@ -426,3 +426,49 @@ bootinfo_setup_rndseed(void)
 		explicit_memset(rnd->data_bytes, 0, rnd->data_length);
 	}
 }
+
+/*
+ * bootinfo_getarg --
+ *	Get an argument from the BI_COMMAND_LINE bootinfo record.
+ */
+bool
+bootinfo_getarg(const char *var, char *buf, size_t buflen)
+{
+	const size_t varlen = strlen(var);
+	struct bi_record *bi = bootinfo_find(BI_COMMAND_LINE);
+
+	if (bi == NULL) {
+		return false;
+	}
+
+	const char *sp = bootinfo_dataptr(bi);
+	const char *osp = sp;
+	for (;;) {
+		sp = strstr(sp, var);
+		if (sp == NULL) {
+			return false;
+		}
+
+		if (sp != osp &&
+		sp[-1] != ' ' && sp[-1] != '\t' && sp[-1] != '-') {
+			continue;
+		}
+		sp += varlen;
+		char ch = *sp++;
+		if (ch != '=' && ch != ' ' && ch != '\t' && ch != '\0') {
+			continue;
+		}
+		/* Found it. */
+		break;
+	}
+
+	while (--buflen) {
+		if (*sp == ' ' || *sp == '\t' || *sp == '\0') {
+			break;
+		}
+		*buf++ = *sp++;
+	}
+	*buf = '\0';
+
+	return true;
+}



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

2024-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan  7 21:19:42 UTC 2024

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_107.c msg_141.c msg_305.c

Log Message:
tests/lint: test operators, integer overflow, conversions


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/msg_107.c
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/xlint/lint1/msg_141.c
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_305.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_107.c
diff -u src/tests/usr.bin/xlint/lint1/msg_107.c:1.6 src/tests/usr.bin/xlint/lint1/msg_107.c:1.7
--- src/tests/usr.bin/xlint/lint1/msg_107.c:1.6	Fri Jul  7 19:45:22 2023
+++ src/tests/usr.bin/xlint/lint1/msg_107.c	Sun Jan  7 21:19:42 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_107.c,v 1.6 2023/07/07 19:45:22 rillig Exp $	*/
+/*	$NetBSD: msg_107.c,v 1.7 2024/01/07 21:19:42 rillig Exp $	*/
 # 3 "msg_107.c"
 
 // Test for message: operands of '%s' have incompatible types '%s' and '%s' [107]
@@ -12,3 +12,12 @@ compare(double d, void *ptr)
 	/* expect+1: error: operands of '==' have incompatible types 'double' and 'pointer to void' [107] */
 	return d == ptr;
 }
+
+static inline void
+typeok_minus(const char *p, int i, double d)
+{
+	if (p[i] != p[(int)d])
+		return;
+	/* expect+1: error: operands of '-' have incompatible types 'pointer to const char' and 'double' [107] */
+	return (p - i) - (p - d);
+}

Index: src/tests/usr.bin/xlint/lint1/msg_141.c
diff -u src/tests/usr.bin/xlint/lint1/msg_141.c:1.7 src/tests/usr.bin/xlint/lint1/msg_141.c:1.8
--- src/tests/usr.bin/xlint/lint1/msg_141.c:1.7	Sun Jul  9 11:01:27 2023
+++ src/tests/usr.bin/xlint/lint1/msg_141.c	Sun Jan  7 21:19:42 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_141.c,v 1.7 2023/07/09 11:01:27 rillig Exp $	*/
+/*	$NetBSD: msg_141.c,v 1.8 2024/01/07 21:19:42 rillig Exp $	*/
 # 3 "msg_141.c"
 
 // Test for message: operator '%s' produces integer overflow [141]
@@ -9,13 +9,13 @@
  * Before tree.c 1.347 from 2021-08-23, lint wrongly warned about integer
  * overflow in '-'.
  */
-int signed_int_max = (1u << 31) - 1;
+int signed_int_max = (1U << 31) - 1;
 
 /*
  * Before tree.c 1.347 from 2021-08-23, lint wrongly warned about integer
  * overflow in '-'.
  */
-unsigned int unsigned_int_max = (1u << 31) - 1;
+unsigned int unsigned_int_max = (1U << 31) - 1;
 
 /* expect+1: warning: operator '+' produces integer overflow [141] */
 int int_overflow = (1 << 30) + (1 << 30);
@@ -27,7 +27,184 @@ unsigned int intermediate_overflow = (1 
 unsigned int no_overflow = (1U << 30) + (1 << 30);
 
 /* expect+1: warning: operator '-' produces integer overflow [141] */
-unsigned int unsigned_int_min = 0u - (1u << 31);
+unsigned int unsigned_int_min = 0U - (1U << 31);
 
 /* expect+1: warning: operator '-' produces integer overflow [141] */
-unsigned int unsigned_int_min_unary = -(1u << 31);
+unsigned int unsigned_int_min_unary = -(1U << 31);
+
+enum {
+	INT_MAX = 2147483647,
+	INT_MIN = -INT_MAX - 1,
+};
+
+unsigned long long overflow_unsigned[] = {
+
+	// unary '+'
+
+	+0U,
+	+~0U,
+	+~0ULL,
+
+	// unary '-'
+
+	-0U,
+	-~0U,
+	/* expect+1: warning: operator '-' produces integer overflow [141] */
+	-(1ULL << 63),
+	/* expect+1: warning: operator '-' produces integer overflow [141] */
+	-(1U << 31),
+
+	// '~'
+
+	~0U,
+	~~0U,
+	~0ULL,
+	~~0ULL,
+
+	// '*'
+
+	0x10001U * 0xU,
+	/* expect+1: warning: operator '*' produces integer overflow [141] */
+	0x1U * 0x1U,
+	0x1ULL * 0x1U,
+	/* expect+1: warning: operator '*' produces integer overflow [141] */
+	0x1U * 0x1U,
+
+	// '/'
+
+	0xU / ~0U,
+	/* expect+1: error: division by 0 [139] */
+	0xU / 0U,
+
+	// '%'
+
+	0xU % ~0U,
+	/* expect+1: error: modulus by 0 [140] */
+	0xU % 0U,
+
+	// '+'
+
+	0U + 0U,
+	~0U + 0U,
+	0U + ~0U,
+	/* expect+1: warning: operator '+' produces integer overflow [141] */
+	~0U + 1U,
+	/* expect+1: warning: operator '+' produces integer overflow [141] */
+	1U + ~0U,
+	/* expect+1: warning: operator '+' produces integer overflow [141] */
+	~0U + ~0U,
+
+	// '-'
+
+	0U - 0U,
+	0U - 1U,
+	0U - ~0U,
+
+	// '<<'
+
+	256U << 23,
+	/* expect+1: warning: operator '<<' produces integer overflow [141] */
+	256U << 24,
+
+	// '>>'
+
+	10U >> 1,
+	-10U >> 1,
+
+	// bitwise operators
+
+	1U & -1U,
+	1U ^ -1U,
+	1U | -1U,
+};
+
+long long overflow_signed[] = {
+
+	// unary '+'
+
+	+(unsigned char)255,
+	+0x7fff,
+
+	// unary '-'
+
+	-(unsigned char)255,
+	-0x7fff,
+
+	// '~'
+
+	~0,
+	~1,
+	~1,
+	~-1,
+
+	// '*'
+
+	/* expect+1: warning: operator '*' produces integer overflow [141] */
+	0x1 * 0x8000,
+	/* expect+1: warning: operator '*' produces integer overflow [141] */
+	0x1 * 0x1,
+	0x1LL * 0x1,
+	/* TODO: expect+1: warning: operator '*' produces integer overflow [141] */
+	

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

2024-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan  7 21:19:42 UTC 2024

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_107.c msg_141.c msg_305.c

Log Message:
tests/lint: test operators, integer overflow, conversions


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/msg_107.c
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/xlint/lint1/msg_141.c
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_305.c

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



CVS commit: src

2024-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan  7 18:42:37 UTC 2024

Modified Files:
src/tests/usr.bin/xlint/lint1: queries.c t_usage.sh
src/usr.bin/xlint/lint1: err.c lex.c

Log Message:
lint: allow querying for invisible characters in literals and constants


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/tests/usr.bin/xlint/lint1/queries.c
cvs rdiff -u -r1.12 -r1.13 src/tests/usr.bin/xlint/lint1/t_usage.sh
cvs rdiff -u -r1.221 -r1.222 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.196 -r1.197 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/tests/usr.bin/xlint/lint1/queries.c
diff -u src/tests/usr.bin/xlint/lint1/queries.c:1.20 src/tests/usr.bin/xlint/lint1/queries.c:1.21
--- src/tests/usr.bin/xlint/lint1/queries.c:1.20	Sun Dec 10 15:29:38 2023
+++ src/tests/usr.bin/xlint/lint1/queries.c	Sun Jan  7 18:42:37 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: queries.c,v 1.20 2023/12/10 15:29:38 rillig Exp $	*/
+/*	$NetBSD: queries.c,v 1.21 2024/01/07 18:42:37 rillig Exp $	*/
 # 3 "queries.c"
 
 /*
@@ -11,11 +11,11 @@
  *	Understanding how C works internally, by making the usual arithmetic
  *	conversions visible.
  *
- * 	Finding code that intentionally suppresses a regular lint warning,
- * 	such as casts between arithmetic types.
+ *	Finding code that intentionally suppresses a regular lint warning,
+ *	such as casts between arithmetic types.
  */
 
-/* lint1-extra-flags: -q 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 -X 351 */
+/* lint1-extra-flags: -q 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 -X 351 */
 
 typedef unsigned char u8_t;
 typedef unsigned short u16_t;
@@ -458,6 +458,11 @@ void Q16(void)
 {
 }
 
+/* expect+1: invisible character U+0009 in character constant [Q17] */
+char Q17_char[] = { ' ', '\0', '	' };
+/* expect+1: invisible character U+0009 in string literal [Q17] */
+char Q17_string[] = " \0	";
+
 /*
  * Since queries do not affect the exit status, force a warning to make this
  * test conform to the general expectation that a test that produces output

Index: src/tests/usr.bin/xlint/lint1/t_usage.sh
diff -u src/tests/usr.bin/xlint/lint1/t_usage.sh:1.12 src/tests/usr.bin/xlint/lint1/t_usage.sh:1.13
--- src/tests/usr.bin/xlint/lint1/t_usage.sh:1.12	Sun Dec 10 15:29:38 2023
+++ src/tests/usr.bin/xlint/lint1/t_usage.sh	Sun Jan  7 18:42:37 2024
@@ -1,4 +1,4 @@
-# $NetBSD: t_usage.sh,v 1.12 2023/12/10 15:29:38 rillig Exp $
+# $NetBSD: t_usage.sh,v 1.13 2024/01/07 18:42:37 rillig Exp $
 #
 # Copyright (c) 2023 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -89,13 +89,13 @@ enable_queries_body()
 
 	# The largest known query.
 	atf_check \
-	"$lint1" -q 16 code.c /dev/null
+	"$lint1" -q 17 code.c /dev/null
 
 	# Larger than the largest known query.
 	atf_check \
 	-s 'exit:1' \
-	-e "inline:lint1: invalid query ID '17'\n" \
-	"$lint1" -q 17 code.c /dev/null
+	-e "inline:lint1: invalid query ID '18'\n" \
+	"$lint1" -q 18 code.c /dev/null
 
 	# Whitespace is not allowed before a query ID.
 	atf_check \

Index: src/usr.bin/xlint/lint1/err.c
diff -u src/usr.bin/xlint/lint1/err.c:1.221 src/usr.bin/xlint/lint1/err.c:1.222
--- src/usr.bin/xlint/lint1/err.c:1.221	Sun Dec 10 15:29:38 2023
+++ src/usr.bin/xlint/lint1/err.c	Sun Jan  7 18:42:37 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: err.c,v 1.221 2023/12/10 15:29:38 rillig Exp $	*/
+/*	$NetBSD: err.c,v 1.222 2024/01/07 18:42:37 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID)
-__RCSID("$NetBSD: err.c,v 1.221 2023/12/10 15:29:38 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.222 2024/01/07 18:42:37 rillig Exp $");
 #endif
 
 #include 
@@ -715,6 +715,7 @@ static const char *queries[] = {
 	"comparison '%s' of 'char' with plain integer %d",	  /* Q14 */
 	"implicit conversion from integer 0 to pointer '%s'",	  /* Q15 */
 	"'%s' was declared 'static', now non-'static'",		  /* Q16 */
+	"invisible character U+%04X in %s",			  /* Q17 */
 };
 
 bool any_query_enabled;		/* for optimizing non-query scenarios */

Index: src/usr.bin/xlint/lint1/lex.c
diff -u src/usr.bin/xlint/lint1/lex.c:1.196 src/usr.bin/xlint/lint1/lex.c:1.197
--- src/usr.bin/xlint/lint1/lex.c:1.196	Sun Dec  3 18:17:41 2023
+++ src/usr.bin/xlint/lint1/lex.c	Sun Jan  7 18:42:37 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.196 2023/12/03 18:17:41 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.197 2024/01/07 18:42:37 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID)
-__RCSID("$NetBSD: lex.c,v 1.196 2023/12/03 18:17:41 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.197 2024/01/07 18:42:37 rillig Exp $");
 #endif
 
 #include 
@@ -868,6 +868,13 @@ get_escaped_char(int delim)
 		c = read_escaped_backslash(delim);
 		if (c == -3)
 			return 

CVS commit: src

2024-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan  7 18:42:37 UTC 2024

Modified Files:
src/tests/usr.bin/xlint/lint1: queries.c t_usage.sh
src/usr.bin/xlint/lint1: err.c lex.c

Log Message:
lint: allow querying for invisible characters in literals and constants


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/tests/usr.bin/xlint/lint1/queries.c
cvs rdiff -u -r1.12 -r1.13 src/tests/usr.bin/xlint/lint1/t_usage.sh
cvs rdiff -u -r1.221 -r1.222 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.196 -r1.197 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.



CVS commit: src/sys/arch/virt68k/virt68k

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

Modified Files:
src/sys/arch/virt68k/virt68k: autoconf.c locore.s

Log Message:
Don't to go IPL0 right before calling main(), instead call spl0() at the
end of cpu_configure().  It seems that Qemu doesn't reset pending interrupts
correctly after a RESET request, which was causing an explosion when an
interrupt was delivered to the new kernel instance.  This change makes
reboot work.

Thx to mlelstv@ for figuring out what the problem was.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/virt68k/virt68k/autoconf.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/virt68k/virt68k/locore.s

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



CVS commit: src/sys/arch/virt68k/virt68k

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

Modified Files:
src/sys/arch/virt68k/virt68k: autoconf.c locore.s

Log Message:
Don't to go IPL0 right before calling main(), instead call spl0() at the
end of cpu_configure().  It seems that Qemu doesn't reset pending interrupts
correctly after a RESET request, which was causing an explosion when an
interrupt was delivered to the new kernel instance.  This change makes
reboot work.

Thx to mlelstv@ for figuring out what the problem was.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/virt68k/virt68k/autoconf.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/virt68k/virt68k/locore.s

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/virt68k/virt68k/autoconf.c
diff -u src/sys/arch/virt68k/virt68k/autoconf.c:1.3 src/sys/arch/virt68k/virt68k/autoconf.c:1.4
--- src/sys/arch/virt68k/virt68k/autoconf.c:1.3	Tue Jan  2 16:59:14 2024
+++ src/sys/arch/virt68k/virt68k/autoconf.c	Sun Jan  7 16:41:24 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.3 2024/01/02 16:59:14 thorpej Exp $	*/
+/*	$NetBSD: autoconf.c,v 1.4 2024/01/07 16:41:24 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -45,7 +45,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.3 2024/01/02 16:59:14 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.4 2024/01/07 16:41:24 thorpej Exp $");
 
 #include 
 #include 
@@ -73,6 +73,14 @@ cpu_configure(void)
 
 	if (config_rootfound("mainbus", NULL) == NULL)
 		panic("autoconfig failed, no root");
+
+	/*
+	 * XXX Go ahead and enable interrupts now that we've configured
+	 * XXX everything.
+	 * XXX
+	 * XXX See locore.s, right before main() is called.
+	 */
+	spl0();
 }
 
 void

Index: src/sys/arch/virt68k/virt68k/locore.s
diff -u src/sys/arch/virt68k/virt68k/locore.s:1.2 src/sys/arch/virt68k/virt68k/locore.s:1.3
--- src/sys/arch/virt68k/virt68k/locore.s:1.2	Tue Jan  2 18:10:36 2024
+++ src/sys/arch/virt68k/virt68k/locore.s	Sun Jan  7 16:41:24 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.2 2024/01/02 18:10:36 thorpej Exp $	*/
+/*	$NetBSD: locore.s,v 1.3 2024/01/07 16:41:24 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -278,7 +278,14 @@ Lenab3:
  * later on.
  */
 	jbsr	_C_LABEL(virt68k_init)	| additional pre-main initialization
+#if 0
+	/*
+	 * XXX Don't do the spl0() here; when Qemu performs a reboot request,
+	 * XXX it seems to not clear pending interrupts, and so we blow up
+	 * XXX early when the new kernel starts up.
+	 */
 	movw	#PSL_LOWIPL,%sr		| lower SPL
+#endif
 	clrw	%sp@-			| vector offset/frame type
 	clrl	%sp@-			| PC - filled in by "execve"
 	movw	#PSL_USER,%sp@-		| in user mode



CVS commit: src

2024-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan  7 12:43:16 UTC 2024

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

Log Message:
lint: fix crash for invalid __func__ (since 2023-01-29)


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/d_c99_func.c
cvs rdiff -u -r1.590 -r1.591 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/d_c99_func.c
diff -u src/tests/usr.bin/xlint/lint1/d_c99_func.c:1.6 src/tests/usr.bin/xlint/lint1/d_c99_func.c:1.7
--- src/tests/usr.bin/xlint/lint1/d_c99_func.c:1.6	Tue Mar 28 14:44:34 2023
+++ src/tests/usr.bin/xlint/lint1/d_c99_func.c	Sun Jan  7 12:43:16 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: d_c99_func.c,v 1.6 2023/03/28 14:44:34 rillig Exp $	*/
+/*	$NetBSD: d_c99_func.c,v 1.7 2024/01/07 12:43:16 rillig Exp $	*/
 # 3 "d_c99_func.c"
 
 /* C99 __func__ */
@@ -14,3 +14,10 @@ function_name(void)
 	typedef int reveal_size[-(int)sizeof(__func__)];
 	return __func__;
 }
+
+
+// Since tree.c 1.504 from 2023-01-29 and before tree.c 1.591 from 2024-01-07,
+// lint crashed because there was no "current function", even though the "block
+// level" was not 0.
+/* expect+1: error: '__func__' undefined [99] */
+typedef int f(int[sizeof(__func__)]);

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.590 src/usr.bin/xlint/lint1/tree.c:1.591
--- src/usr.bin/xlint/lint1/tree.c:1.590	Sun Jan  7 12:20:42 2024
+++ src/usr.bin/xlint/lint1/tree.c	Sun Jan  7 12:43:16 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.590 2024/01/07 12:20:42 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.591 2024/01/07 12:43:16 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID)
-__RCSID("$NetBSD: tree.c,v 1.590 2024/01/07 12:20:42 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.591 2024/01/07 12:43:16 rillig Exp $");
 #endif
 
 #include 
@@ -409,7 +409,7 @@ fallback_symbol(sym_t *sym)
 		return;
 	}
 
-	if (block_level > 0 && strcmp(sym->s_name, "__func__") == 0) {
+	if (funcsym != NULL && strcmp(sym->s_name, "__func__") == 0) {
 		if (!allow_c99)
 			/* __func__ is a C99 feature */
 			warning(317);



CVS commit: src

2024-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan  7 12:43:16 UTC 2024

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

Log Message:
lint: fix crash for invalid __func__ (since 2023-01-29)


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/d_c99_func.c
cvs rdiff -u -r1.590 -r1.591 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.



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

2024-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan  7 12:20:42 UTC 2024

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

Log Message:
lint: fix memory allocation names, eliminate double negation


To generate a diff of this commit:
cvs rdiff -u -r1.589 -r1.590 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.589 src/usr.bin/xlint/lint1/tree.c:1.590
--- src/usr.bin/xlint/lint1/tree.c:1.589	Sat Jan  6 15:05:24 2024
+++ src/usr.bin/xlint/lint1/tree.c	Sun Jan  7 12:20:42 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.589 2024/01/06 15:05:24 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.590 2024/01/07 12:20:42 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID)
-__RCSID("$NetBSD: tree.c,v 1.589 2024/01/06 15:05:24 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.590 2024/01/07 12:20:42 rillig Exp $");
 #endif
 
 #include 
@@ -536,13 +536,13 @@ build_string(strg_t *strg)
 	n->tn_type = tp;
 	n->tn_lvalue = true;
 
-	n->tn_string = expr_zero_alloc(sizeof(*n->tn_string), "type.string");
+	n->tn_string = expr_zero_alloc(sizeof(*n->tn_string), "tnode.string");
 	n->tn_string->st_char = strg->st_char;
 	n->tn_string->st_len = len;
 
 	size_t chsize = strg->st_char ? sizeof(char) : sizeof(wchar_t);
 	size_t size = (len + 1) * chsize;
-	n->tn_string->st_mem = expr_zero_alloc(size, "type.string.data");
+	n->tn_string->st_mem = expr_zero_alloc(size, "tnode.string.data");
 	(void)memcpy(n->tn_string->st_mem, strg->st_mem, size);
 	free(strg->st_mem);
 	free(strg);
@@ -759,18 +759,18 @@ balance(op_t op, tnode_t **lnp, tnode_t 
 }
 
 static tnode_t *
-build_address(bool sys, tnode_t *tn, bool noign)
+build_address(bool sys, tnode_t *tn, bool force)
 {
 	tspec_t t;
 
-	if (!noign && ((t = tn->tn_type->t_tspec) == ARRAY || t == FUNC)) {
+	if (!force && ((t = tn->tn_type->t_tspec) == ARRAY || t == FUNC)) {
 		if (!allow_c90)
 			/* '&' before array or function: ignored */
 			warning(127);
 		return tn;
 	}
 
-	/* eliminate &* */
+	/* eliminate '&*' */
 	if (tn->tn_op == INDIR &&
 	tn->tn_left->tn_type->t_tspec == PTR &&
 	tn->tn_left->tn_type->t_subt == tn->tn_type) {



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

2024-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan  7 12:20:42 UTC 2024

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

Log Message:
lint: fix memory allocation names, eliminate double negation


To generate a diff of this commit:
cvs rdiff -u -r1.589 -r1.590 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.



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

2024-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan  7 11:42:22 UTC 2024

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

Log Message:
tests/make: test the '::=' modifier in target scope


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/make/unit-tests/varmod-assign.exp \
src/usr.bin/make/unit-tests/varmod-assign.mk

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

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-assign.exp
diff -u src/usr.bin/make/unit-tests/varmod-assign.exp:1.18 src/usr.bin/make/unit-tests/varmod-assign.exp:1.19
--- src/usr.bin/make/unit-tests/varmod-assign.exp:1.18	Fri Dec 29 15:47:03 2023
+++ src/usr.bin/make/unit-tests/varmod-assign.exp	Sun Jan  7 11:42:22 2024
@@ -50,4 +50,11 @@ make: Unfinished modifier for "ASSIGN" (
 ok=word
 make: " echo word; false " returned non-zero status
 err=previous
+Command: TARGET_CMD_VAR = cmd-value
+Global: TARGET_GLOBAL_VAR = global-value
+target: TARGET_TARGET_VAR = target-value
+target: TARGET_TARGET_VAR = new-value
+Global: TARGET_GLOBAL_VAR = new-value
+Global: TARGET_ENV_VAR = new-value
+target: TARGET_NEW_VAR = new-value
 exit status 0
Index: src/usr.bin/make/unit-tests/varmod-assign.mk
diff -u src/usr.bin/make/unit-tests/varmod-assign.mk:1.18 src/usr.bin/make/unit-tests/varmod-assign.mk:1.19
--- src/usr.bin/make/unit-tests/varmod-assign.mk:1.18	Sun Dec 31 10:09:01 2023
+++ src/usr.bin/make/unit-tests/varmod-assign.mk	Sun Jan  7 11:42:22 2024
@@ -1,8 +1,10 @@
-# $NetBSD: varmod-assign.mk,v 1.18 2023/12/31 10:09:01 rillig Exp $
+# $NetBSD: varmod-assign.mk,v 1.19 2024/01/07 11:42:22 rillig Exp $
 #
 # Tests for the obscure ::= variable modifiers, which perform variable
 # assignments during evaluation, just like the = operator in C.
 
+.if !make(target)
+
 all:	mod-assign-empty
 all:	mod-assign-parse
 all:	mod-assign-shell-error
@@ -162,7 +164,6 @@ ${VARNAME}=	initial-value	# Sets 'VAR.${
 .MAKEFLAGS: CMD_CMD_VAR=cmd-value
 CMD_GLOBAL_VAR=global-value
 export CMD_ENV_VAR=env-value
-
 .MAKEFLAGS: -dv
 # expect-reset
 # expect: Command: CMD_CMD_VAR = new-value
@@ -178,23 +179,30 @@ export CMD_ENV_VAR=env-value
 .endif
 .MAKEFLAGS: -d0
 
+# Run the 'target' test in a separate sub-make, with reduced debug logging.
+all: run-target
+run-target: .PHONY
+	@${MAKE} -r -f ${MAKEFILE} -dv target 2>&1 | grep ': TARGET_'
 
-# In target scope, assignments only happen in a few cases.  To extract the
-# debug log for this test, the debug log would have to be enabled for the
-# other targets as well, thus producing lots of irrelevant output.
+.else # make(target)
+
+# The commands of a target are evaluated in target scope.  An assignment
+# modifier that creates a new variable creates it in the target scope.
+# Existing variables are updated in their previous scope, and environment
+# variables are created in the global scope, as in other situations.
 #
-# Running './make -r -f varmod-assign.mk target | grep ": TARGET"' results in:
-#	target: TARGET_TARGET_VAR = new-value
-#	Global: TARGET_GLOBAL_VAR = new-value
-#	Global: TARGET_ENV_VAR = new-value
-#	target: TARGET_NEW_VAR = new-value
+# expect: target: TARGET_TARGET_VAR = new-value
+# expect: Global: TARGET_GLOBAL_VAR = new-value
+# expect: Global: TARGET_ENV_VAR = new-value
+# expect: target: TARGET_NEW_VAR = new-value
 .MAKEFLAGS: TARGET_CMD_VAR=cmd-value
 TARGET_GLOBAL_VAR=global-value
 export TARGET_ENV_VAR=env-value
-.MAKEFLAGS: ${make(target):?-dv:}
 target: .PHONY TARGET_TARGET_VAR=target-value
 	: ${TARGET_TARGET_VAR::=new-value}
 	: ${TARGET_CMD_VAR::=new-value}
 	: ${TARGET_GLOBAL_VAR::=new-value}
 	: ${TARGET_ENV_VAR::=new-value}
 	: ${TARGET_NEW_VAR::=new-value}
+
+.endif



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

2024-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan  7 11:42:22 UTC 2024

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

Log Message:
tests/make: test the '::=' modifier in target scope


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/make/unit-tests/varmod-assign.exp \
src/usr.bin/make/unit-tests/varmod-assign.mk

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



CVS commit: src/usr.bin/make

2024-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan  7 11:39:04 UTC 2024

Modified Files:
src/usr.bin/make: job.c parse.c var.c
src/usr.bin/make/unit-tests: varparse-undef-partial.mk

Log Message:
make: clean up comments, constify shell name


To generate a diff of this commit:
cvs rdiff -u -r1.464 -r1.465 src/usr.bin/make/job.c
cvs rdiff -u -r1.715 -r1.716 src/usr.bin/make/parse.c
cvs rdiff -u -r1.1093 -r1.1094 src/usr.bin/make/var.c
cvs rdiff -u -r1.4 -r1.5 \
src/usr.bin/make/unit-tests/varparse-undef-partial.mk

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



CVS commit: src/usr.bin/make

2024-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan  7 11:39:04 UTC 2024

Modified Files:
src/usr.bin/make: job.c parse.c var.c
src/usr.bin/make/unit-tests: varparse-undef-partial.mk

Log Message:
make: clean up comments, constify shell name


To generate a diff of this commit:
cvs rdiff -u -r1.464 -r1.465 src/usr.bin/make/job.c
cvs rdiff -u -r1.715 -r1.716 src/usr.bin/make/parse.c
cvs rdiff -u -r1.1093 -r1.1094 src/usr.bin/make/var.c
cvs rdiff -u -r1.4 -r1.5 \
src/usr.bin/make/unit-tests/varparse-undef-partial.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/job.c
diff -u src/usr.bin/make/job.c:1.464 src/usr.bin/make/job.c:1.465
--- src/usr.bin/make/job.c:1.464	Sun Jan  7 01:33:57 2024
+++ src/usr.bin/make/job.c	Sun Jan  7 11:39:04 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.464 2024/01/07 01:33:57 sjg Exp $	*/
+/*	$NetBSD: job.c,v 1.465 2024/01/07 11:39:04 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -141,7 +141,7 @@
 #include "trace.h"
 
 /*	"@(#)job.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: job.c,v 1.464 2024/01/07 01:33:57 sjg Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.465 2024/01/07 11:39:04 rillig Exp $");
 
 /*
  * A shell defines how the commands are run.  All commands for a target are
@@ -2474,16 +2474,9 @@ Job_ParseShell(char *line)
 			}
 		}
 	} else {
-		/*
-		 * The user provided a path. If s/he gave nothing else
-		 * (fullSpec is false), try and find a matching shell in the
-		 * ones we know of. Else we just take the specification at
-		 * its word and copy it to a new location. In either case,
-		 * we need to record the path the user gave for the shell.
-		 */
-		char *name = path + (str_basename(path) - path);
 		shellPath = path;
-		shellName = newShell.name != NULL ? newShell.name : name;
+		shellName = newShell.name != NULL ? newShell.name
+		: str_basename(path);
 		if (!fullSpec) {
 			if ((sh = FindShellByName(shellName)) == NULL) {
 Parse_Error(PARSE_WARNING,

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.715 src/usr.bin/make/parse.c:1.716
--- src/usr.bin/make/parse.c:1.715	Fri Jan  5 23:22:06 2024
+++ src/usr.bin/make/parse.c	Sun Jan  7 11:39:04 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.715 2024/01/05 23:22:06 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.716 2024/01/07 11:39:04 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -105,7 +105,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.715 2024/01/05 23:22:06 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.716 2024/01/07 11:39:04 rillig Exp $");
 
 /* Detects a multiple-inclusion guard in a makefile. */
 typedef enum {
@@ -115,9 +115,7 @@ typedef enum {
 	GS_NO			/* the file is not guarded */
 } GuardState;
 
-/*
- * A file being read.
- */
+/* A file being parsed. */
 typedef struct IncludedFile {
 	FStr name;		/* absolute or relative to the cwd */
 	unsigned lineno;	/* 1-based */
@@ -2901,13 +2899,6 @@ ParseDependencyLine(char *line)
 static void
 ParseLine(char *line)
 {
-	/*
-	 * Lines that begin with '.' can be pretty much anything:
-	 *	- directives like '.include' or '.if',
-	 *	- suffix rules like '.c.o:',
-	 *	- dependencies for filenames that start with '.',
-	 *	- variable assignments like '.tmp=value'.
-	 */
 	if (line[0] == '.' && ParseDirective(line))
 		return;
 

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.1093 src/usr.bin/make/var.c:1.1094
--- src/usr.bin/make/var.c:1.1093	Fri Jan  5 23:22:06 2024
+++ src/usr.bin/make/var.c	Sun Jan  7 11:39:04 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.1093 2024/01/05 23:22:06 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.1094 2024/01/07 11:39:04 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -139,7 +139,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.1093 2024/01/05 23:22:06 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1094 2024/01/07 11:39:04 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -1859,15 +1859,15 @@ FormatTime(const char *fmt, time_t t, bo
  * Some modifiers such as ':sh' or '::=' have noticeable side effects though.
  *
  * Evaluating the modifier usually takes the current value of the
- * expression from ch->expr->value, or the variable name from ch->var->name
+ * expression from ch->expr->value, or the variable name from ch->var->name,
  * and stores the result back in ch->expr->value via Expr_SetValueOwn or
  * Expr_SetValueRefer.
  *
- * If evaluating fails (as of 2020-08-23), an error message is printed using
- * Error.  This function has no side effects, it really just prints the error
- * message.  Processing the expression continues as if everything were ok.
- * TODO: This should be fixed by adding proper