CVS commit: src/sys/arch/mips/include

2020-09-25 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sat Sep 26 04:31:53 UTC 2020

Modified Files:
src/sys/arch/mips/include: pcb.h

Log Message:
Whitespace consistency nit.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/mips/include/pcb.h

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

Modified files:

Index: src/sys/arch/mips/include/pcb.h
diff -u src/sys/arch/mips/include/pcb.h:1.26 src/sys/arch/mips/include/pcb.h:1.27
--- src/sys/arch/mips/include/pcb.h:1.26	Mon Aug 17 04:15:33 2020
+++ src/sys/arch/mips/include/pcb.h	Sat Sep 26 04:31:53 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcb.h,v 1.26 2020/08/17 04:15:33 mrg Exp $	*/
+/*	$NetBSD: pcb.h,v 1.27 2020/09/26 04:31:53 simonb Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -57,7 +57,7 @@ struct pcb_faultinfo {
  */
 struct pcb {
 	mips_label_t pcb_context;	/* kernel context for resume */
-	void *	pcb_onfault;		/* for copyin/copyout faults */
+	void *pcb_onfault;		/* for copyin/copyout faults */
 	uint32_t pcb_ppl;		/* previous priority level */
 	struct fpreg pcb_fpregs;	/* saved floating point registers */
 	struct dspreg pcb_dspregs;	/* saved DSP registers */



CVS commit: src/sys/arch/mips/include

2020-09-25 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sat Sep 26 04:31:53 UTC 2020

Modified Files:
src/sys/arch/mips/include: pcb.h

Log Message:
Whitespace consistency nit.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/mips/include/pcb.h

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



CVS commit: src/sys/arch/mips/mips

2020-09-25 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sat Sep 26 04:11:48 UTC 2020

Modified Files:
src/sys/arch/mips/mips: db_trace.c

Log Message:
Including  once should be sufficient.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/mips/mips/db_trace.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/mips/mips/db_trace.c
diff -u src/sys/arch/mips/mips/db_trace.c:1.45 src/sys/arch/mips/mips/db_trace.c:1.46
--- src/sys/arch/mips/mips/db_trace.c:1.45	Mon Aug 17 04:15:34 2020
+++ src/sys/arch/mips/mips/db_trace.c	Sat Sep 26 04:11:48 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_trace.c,v 1.45 2020/08/17 04:15:34 mrg Exp $	*/
+/*	$NetBSD: db_trace.c,v 1.46 2020/09/26 04:11:48 simonb Exp $	*/
 
 /*
  * Mach Operating System
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.45 2020/08/17 04:15:34 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.46 2020/09/26 04:11:48 simonb Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -46,7 +46,6 @@ __KERNEL_RCSID(0, "$NetBSD: db_trace.c,v
 #include 
 
 #include 
-#include 
 #include 
 #include 
 #include 



CVS commit: src/sys/arch/mips/mips

2020-09-25 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sat Sep 26 04:11:48 UTC 2020

Modified Files:
src/sys/arch/mips/mips: db_trace.c

Log Message:
Including  once should be sufficient.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/mips/mips/db_trace.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/alpha/pci

2020-09-25 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Sep 26 02:50:42 UTC 2020

Modified Files:
src/sys/arch/alpha/pci: pci_6600.c

Log Message:
Support CPU interrupt affinity on Tsunami systems.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/alpha/pci/pci_6600.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/alpha/pci/pci_6600.c
diff -u src/sys/arch/alpha/pci/pci_6600.c:1.27 src/sys/arch/alpha/pci/pci_6600.c:1.28
--- src/sys/arch/alpha/pci/pci_6600.c:1.27	Wed Sep 23 18:48:50 2020
+++ src/sys/arch/alpha/pci/pci_6600.c	Sat Sep 26 02:50:41 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_6600.c,v 1.27 2020/09/23 18:48:50 thorpej Exp $ */
+/* $NetBSD: pci_6600.c,v 1.28 2020/09/26 02:50:41 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1999 by Ross Harvey.  All rights reserved.
@@ -33,13 +33,14 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pci_6600.c,v 1.27 2020/09/23 18:48:50 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_6600.c,v 1.28 2020/09/26 02:50:41 thorpej Exp $");
 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #define _ALPHA_BUS_DMA_PRIVATE
@@ -94,9 +95,15 @@ static void	 *dec_6600_pciide_compat_int
 
 static void	dec_6600_intr_enable(pci_chipset_tag_t, int irq);
 static void	dec_6600_intr_disable(pci_chipset_tag_t, int irq);
+static void	dec_6600_intr_set_affinity(pci_chipset_tag_t, int,
+		struct cpu_info *);
 
-/* Software copy of enabled interrupt bits. */
+/*
+ * We keep 2 software copies of the interrupt enables: one global one,
+ * and one per-CPU for setting the interrupt affinity.
+ */
 static uint64_t	dec_6600_intr_enables __read_mostly;
+static uint64_t dec_6600_cpu_intr_enables[4] __read_mostly;
 
 void
 pci_6600_pickintr(struct tsp_config *pcp)
@@ -105,6 +112,8 @@ pci_6600_pickintr(struct tsp_config *pcp
 	pci_chipset_tag_t pc = >pc_pc;
 	char *cp;
 	int i;
+	struct cpu_info *ci;
+	CPU_INFO_ITERATOR cii;
 
 	pc->pc_intr_v = pcp;
 	pc->pc_intr_map = dec_6600_intr_map;
@@ -121,12 +130,25 @@ pci_6600_pickintr(struct tsp_config *pcp
 
 	pc->pc_intr_enable = dec_6600_intr_enable;
 	pc->pc_intr_disable = dec_6600_intr_disable;
+	pc->pc_intr_set_affinity = dec_6600_intr_set_affinity;
+
+	/* Note eligible CPUs for interrupt routing purposes. */
+	for (CPU_INFO_FOREACH(cii, ci)) {
+		KASSERT(ci->ci_cpuid < 4);
+		pc->pc_eligible_cpus |= __BIT(ci->ci_cpuid);
+	}
 
 	/*
 	 * System-wide and Pchip-0-only logic...
 	 */
 	if (sioprimary == NULL) {
 		sioprimary = pcp;
+		/*
+		 * Unless explicitly routed, all interrupts go to the
+		 * primary CPU.
+		 */
+		dec_6600_cpu_intr_enables[cpu_info_primary.ci_cpuid] =
+		__BITS(0,63);
 		pc->pc_pciide_compat_intr_establish =
 		dec_6600_pciide_compat_intr_establish;
 #define PCI_6600_IRQ_STR	8
@@ -146,7 +168,10 @@ pci_6600_pickintr(struct tsp_config *pcp
 		}
 #if NSIO
 		sio_intr_setup(pc, iot);
-		dec_6600_intr_enable(pc, PCI_SIO_IRQ);	/* irq line for sio */
+
+		mutex_enter(_lock);
+		dec_6600_intr_enable(pc, PCI_SIO_IRQ);
+		mutex_exit(_lock);
 #endif
 	} else {
 		pc->pc_shared_intrs = sioprimary->pc_pc.pc_shared_intrs;
@@ -266,21 +291,109 @@ dec_6600_intr_disestablish(pci_chipset_t
 }
 
 static void
-dec_6600_intr_enable(pci_chipset_tag_t const pc __unused, int const irq)
+dec_6600_intr_program(pci_chipset_tag_t const pc)
 {
-	dec_6600_intr_enables |= 1UL << irq;
+	unsigned int irq, cpuno, cnt;
+
+	/*
+	 * Validate the configuration before we program it: each enabled
+	 * IRQ must be routed to exactly one CPU.
+	 */
+	for (irq = 0; irq < PCI_NIRQ; irq++) {
+		if ((dec_6600_intr_enables & __BIT(irq)) == 0)
+			continue;
+		for (cpuno = 0, cnt = 0; cpuno < 4; cpuno++) {
+			if (dec_6600_cpu_intr_enables[cpuno] != 0 &&
+			(pc->pc_eligible_cpus & __BIT(cpuno)) == 0)
+panic("%s: interrupts enabled on non-existent CPU %u",
+__func__, cpuno);
+			if (dec_6600_cpu_intr_enables[cpuno] & __BIT(irq))
+cnt++;
+		}
+		if (cnt != 1) {
+			panic("%s: irq %u enabled on %u CPUs", __func__,
+			irq, cnt);
+		}
+	}
+
+	const uint64_t enab0 =
+	dec_6600_intr_enables & dec_6600_cpu_intr_enables[0];
+	const uint64_t enab1 =
+	dec_6600_intr_enables & dec_6600_cpu_intr_enables[1];
+	const uint64_t enab2 =
+	dec_6600_intr_enables & dec_6600_cpu_intr_enables[2];
+	const uint64_t enab3 =
+	dec_6600_intr_enables & dec_6600_cpu_intr_enables[3];
+
+	/* Don't touch DIMx registers for non-existent CPUs. */
+	uint64_t black_hole;
+	volatile uint64_t * const dim0 = (pc->pc_eligible_cpus & __BIT(0)) ?
+	(void *)ALPHA_PHYS_TO_K0SEG(TS_C_DIM0) : _hole;
+	volatile uint64_t * const dim1 = (pc->pc_eligible_cpus & __BIT(1)) ?
+	(void *)ALPHA_PHYS_TO_K0SEG(TS_C_DIM1) : _hole;
+	volatile uint64_t * const dim2 = (pc->pc_eligible_cpus & __BIT(2)) ?
+	(void *)ALPHA_PHYS_TO_K0SEG(TS_C_DIM2) : _hole;
+	volatile uint64_t * const dim3 = (pc->pc_eligible_cpus & 

CVS commit: src/sys/arch/alpha/pci

2020-09-25 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Sep 26 02:50:42 UTC 2020

Modified Files:
src/sys/arch/alpha/pci: pci_6600.c

Log Message:
Support CPU interrupt affinity on Tsunami systems.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/alpha/pci/pci_6600.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/alpha

2020-09-25 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Sep 26 02:46:28 UTC 2020

Modified Files:
src/sys/arch/alpha/include: pci_machdep.h
src/sys/arch/alpha/pci: pci_machdep.c

Log Message:
Add support for CPU interrupt affinity for PCI interrupts:
- Keep a bitmap of eligible interrupt-handling CPUs in the pci_chipset_tag_t.
  If this bitmap is 0, then we assume that all PCI interrupts should be
  routed to the primary CPU.
- Add an optional PCI chipset callback for setting the CPU affinity of
  an interrupt.
- When an establishing an interrupt handler, select the CPU that will
  handle this irq using the following algorithm:
  ==> If the irq already has a CPU assignment, keep it.
  ==> Otherwise, find the CPU with the fewest registered handlers that
  is eligible from both a hardware (based on the pci_chipset_tag_t)
  and software (based on cpu_info::ci_schedstate.spc_flags) perspectives.
  ==> Fall back to the primary CPU failing all else.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/alpha/include/pci_machdep.h
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/alpha/pci/pci_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/alpha/include/pci_machdep.h
diff -u src/sys/arch/alpha/include/pci_machdep.h:1.19 src/sys/arch/alpha/include/pci_machdep.h:1.20
--- src/sys/arch/alpha/include/pci_machdep.h:1.19	Tue Sep 22 15:24:01 2020
+++ src/sys/arch/alpha/include/pci_machdep.h	Sat Sep 26 02:46:27 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_machdep.h,v 1.19 2020/09/22 15:24:01 thorpej Exp $ */
+/* $NetBSD: pci_machdep.h,v 1.20 2020/09/26 02:46:27 thorpej Exp $ */
 
 /*
  * Copyright (c) 1996 Carnegie-Mellon University.
@@ -87,8 +87,12 @@ struct alpha_pci_chipset {
 	u_long		pc_vecbase;
 	u_int		pc_nirq;
 
+	u_long		pc_eligible_cpus;
+
 	void		(*pc_intr_enable)(pci_chipset_tag_t, int);
 	void		(*pc_intr_disable)(pci_chipset_tag_t, int);
+	void		(*pc_intr_set_affinity)(pci_chipset_tag_t, int,
+			struct cpu_info *);
 };
 
 /*

Index: src/sys/arch/alpha/pci/pci_machdep.c
diff -u src/sys/arch/alpha/pci/pci_machdep.c:1.26 src/sys/arch/alpha/pci/pci_machdep.c:1.27
--- src/sys/arch/alpha/pci/pci_machdep.c:1.26	Fri Sep 25 03:40:11 2020
+++ src/sys/arch/alpha/pci/pci_machdep.c	Sat Sep 26 02:46:28 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_machdep.c,v 1.26 2020/09/25 03:40:11 thorpej Exp $ */
+/* $NetBSD: pci_machdep.c,v 1.27 2020/09/26 02:46:28 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.26 2020/09/25 03:40:11 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.27 2020/09/26 02:46:28 thorpej Exp $");
 
 #include 
 #include 
@@ -224,6 +224,63 @@ alpha_pci_generic_intr_evcnt(pci_chipset
 	return alpha_shared_intr_evcnt(pc->pc_shared_intrs, irq);
 }
 
+static struct cpu_info *
+alpha_pci_generic_intr_select_cpu(pci_chipset_tag_t const pc, u_int const irq,
+u_int const flags)
+{
+	struct cpu_info *ci, *best_ci;
+	CPU_INFO_ITERATOR cii;
+
+	KASSERT(mutex_owned(_lock));
+
+	/*
+	 * If the back-end didn't tell us where we can route, then
+	 * they all go to the primry CPU.
+	 */
+	if (pc->pc_eligible_cpus == 0) {
+		return _info_primary;
+	}
+
+	/*
+	 * If the interrupt already has a CPU assigned, keep on using it,
+	 * unless the CPU has become ineligible.
+	 */
+	ci = alpha_shared_intr_get_cpu(pc->pc_shared_intrs, irq);
+	if (ci != NULL) {
+		if ((ci->ci_schedstate.spc_flags & SPCF_NOINTR) == 0 ||
+		CPU_IS_PRIMARY(ci)) {
+			return ci;
+		}
+	}
+
+	/*
+	 * Pick the CPU with the fewest handlers.
+	 */
+	best_ci = NULL;
+	for (CPU_INFO_FOREACH(cii, ci)) {
+		if ((pc->pc_eligible_cpus & __BIT(ci->ci_cpuid)) == 0) {
+			/* This CPU is not eligible in hardware. */
+			continue;
+		}
+		if (ci->ci_schedstate.spc_flags & SPCF_NOINTR) {
+			/* This CPU is not eligible in software. */
+			continue;
+		}
+		if (best_ci == NULL ||
+		ci->ci_nintrhand < best_ci->ci_nintrhand) {
+			best_ci = ci;
+		}
+	}
+
+	/* If we found one, cool... */
+	if (best_ci != NULL) {
+		return best_ci;
+	}
+
+	/* ...if not, well I guess we'll just fall back on the primary. */
+	return _info_primary;
+}
+
 void *
 alpha_pci_generic_intr_establish(pci_chipset_tag_t const pc,
 pci_intr_handle_t const ih, int const level,
@@ -243,6 +300,26 @@ alpha_pci_generic_intr_establish(pci_chi
 
 	mutex_enter(_lock);
 
+	struct cpu_info *target_ci =
+	alpha_pci_generic_intr_select_cpu(pc, irq, flags);
+	struct cpu_info *current_ci =
+	alpha_shared_intr_get_cpu(pc->pc_shared_intrs, irq);
+
+	const bool first_handler =
+	! alpha_shared_intr_isactive(pc->pc_shared_intrs, irq);
+
+	/*
+	 * If this is the first handler on this interrupt, or if the
+	 * target CPU has changed, then program the route if the
+	 * hardware supports it.
+	 */

CVS commit: src/sys/arch/alpha

2020-09-25 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Sep 26 02:46:28 UTC 2020

Modified Files:
src/sys/arch/alpha/include: pci_machdep.h
src/sys/arch/alpha/pci: pci_machdep.c

Log Message:
Add support for CPU interrupt affinity for PCI interrupts:
- Keep a bitmap of eligible interrupt-handling CPUs in the pci_chipset_tag_t.
  If this bitmap is 0, then we assume that all PCI interrupts should be
  routed to the primary CPU.
- Add an optional PCI chipset callback for setting the CPU affinity of
  an interrupt.
- When an establishing an interrupt handler, select the CPU that will
  handle this irq using the following algorithm:
  ==> If the irq already has a CPU assignment, keep it.
  ==> Otherwise, find the CPU with the fewest registered handlers that
  is eligible from both a hardware (based on the pci_chipset_tag_t)
  and software (based on cpu_info::ci_schedstate.spc_flags) perspectives.
  ==> Fall back to the primary CPU failing all else.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/alpha/include/pci_machdep.h
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/alpha/pci/pci_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/alpha/common

2020-09-25 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Sep 26 02:35:31 UTC 2020

Modified Files:
src/sys/arch/alpha/common: shared_intr.c

Log Message:
- Fix some bugs in previous, mainly related to indexing the correct
  interrupt queue.
- Make sure to update cpu_info::ci_nintrhand if an irq moves from
  one CPU to another.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/alpha/common/shared_intr.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/alpha/common/shared_intr.c
diff -u src/sys/arch/alpha/common/shared_intr.c:1.25 src/sys/arch/alpha/common/shared_intr.c:1.26
--- src/sys/arch/alpha/common/shared_intr.c:1.25	Fri Sep 25 03:40:11 2020
+++ src/sys/arch/alpha/common/shared_intr.c	Sat Sep 26 02:35:31 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: shared_intr.c,v 1.25 2020/09/25 03:40:11 thorpej Exp $ */
+/* $NetBSD: shared_intr.c,v 1.26 2020/09/26 02:35:31 thorpej Exp $ */
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: shared_intr.c,v 1.25 2020/09/25 03:40:11 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: shared_intr.c,v 1.26 2020/09/26 02:35:31 thorpej Exp $");
 
 #include 
 #include 
@@ -212,9 +212,11 @@ alpha_shared_intr_link_unlink_xcall(void
 {
 	struct alpha_shared_intrhand *ih = arg1;
 	struct alpha_shared_intr *intr = ih->ih_intrhead;
-	struct cpu_info *ci = intr->intr_cpu;
 	unsigned int num = ih->ih_num;
 
+	struct cpu_info *ci = intr[num].intr_cpu;
+
+	KASSERT(ci != NULL);
 	KASSERT(ci == curcpu() || !mp_online);
 	KASSERT(!cpu_intr_p());
 
@@ -273,17 +275,17 @@ alpha_shared_intr_link(struct alpha_shar
 	 * If a CPU hasn't been assigned yet, just give it to the
 	 * primary.
 	 */
-	if (intr->intr_cpu == NULL) {
-		intr->intr_cpu = _info_primary;
+	if (intr[num].intr_cpu == NULL) {
+		intr[num].intr_cpu = _info_primary;
 	}
 
 	kpreempt_disable();
-	if (intr->intr_cpu == curcpu() || !mp_online) {
-		alpha_shared_intr_link_unlink_xcall(ih, intr);
+	if (intr[num].intr_cpu == curcpu() || !mp_online) {
+		alpha_shared_intr_link_unlink_xcall(ih, ih);
 	} else {
 		uint64_t where = xc_unicast(XC_HIGHPRI,
-		alpha_shared_intr_link_unlink_xcall, ih, intr,
-		intr->intr_cpu);
+		alpha_shared_intr_link_unlink_xcall, ih, ih,
+		intr->intr_cpu);
 		xc_wait(where);
 	}
 	kpreempt_enable();
@@ -295,16 +297,17 @@ void
 alpha_shared_intr_unlink(struct alpha_shared_intr *intr,
 struct alpha_shared_intrhand *ih, const char *basename)
 {
+	unsigned int num = ih->ih_num;
 
 	KASSERT(mutex_owned(_lock));
 
 	kpreempt_disable();
-	if (intr->intr_cpu == curcpu() || !mp_online) {
+	if (intr[num].intr_cpu == curcpu() || !mp_online) {
 		alpha_shared_intr_link_unlink_xcall(ih, NULL);
 	} else {
 		uint64_t where = xc_unicast(XC_HIGHPRI,
 		alpha_shared_intr_link_unlink_xcall, ih, NULL,
-		intr->intr_cpu);
+		intr->intr_cpu);
 		xc_wait(where);
 	}
 	kpreempt_enable();
@@ -401,12 +404,79 @@ alpha_shared_intr_get_private(struct alp
 	return (intr[num].intr_private);
 }
 
+static unsigned int
+alpha_shared_intr_q_count_handlers(struct alpha_shared_intr *intr_q)
+{
+	unsigned int cnt = 0;
+	struct alpha_shared_intrhand *ih;
+
+	TAILQ_FOREACH(ih, _q->intr_q, ih_q) {
+		cnt++;
+	}
+
+	return cnt;
+}
+
+static void
+alpha_shared_intr_set_cpu_xcall(void *arg1, void *arg2)
+{
+	struct alpha_shared_intr *intr_q = arg1;
+	struct cpu_info *ci = arg2;
+	unsigned int cnt = alpha_shared_intr_q_count_handlers(intr_q);
+
+	KASSERT(ci == curcpu() || !mp_online);
+
+	ci->ci_nintrhand += cnt;
+	KASSERT(cnt <= ci->ci_nintrhand);
+}
+
+static void
+alpha_shared_intr_unset_cpu_xcall(void *arg1, void *arg2)
+{
+	struct alpha_shared_intr *intr_q = arg1;
+	struct cpu_info *ci = arg2;
+	unsigned int cnt = alpha_shared_intr_q_count_handlers(intr_q);
+
+	KASSERT(ci == curcpu() || !mp_online);
+
+	KASSERT(cnt <= ci->ci_nintrhand);
+	ci->ci_nintrhand -= cnt;
+}
+
 void
 alpha_shared_intr_set_cpu(struct alpha_shared_intr *intr, unsigned int num,
 struct cpu_info *ci)
 {
+	struct cpu_info *old_ci;
+
+	KASSERT(mutex_owned(_lock));
 
+	old_ci = intr[num].intr_cpu;
 	intr[num].intr_cpu = ci;
+
+	if (old_ci != NULL && old_ci != ci) {
+		kpreempt_disable();
+
+		if (ci == curcpu() || !mp_online) {
+			alpha_shared_intr_set_cpu_xcall([num], ci);
+		} else {
+			uint64_t where = xc_unicast(XC_HIGHPRI,
+			alpha_shared_intr_set_cpu_xcall, [num],
+			ci, ci);
+			xc_wait(where);
+		}
+
+		if (old_ci == curcpu() || !mp_online) {
+			alpha_shared_intr_unset_cpu_xcall([num], old_ci);
+		} else {
+			uint64_t where = xc_unicast(XC_HIGHPRI,
+			alpha_shared_intr_unset_cpu_xcall, [num],
+			old_ci, old_ci);
+			xc_wait(where);
+		}
+
+		kpreempt_enable();
+	}
 }
 
 struct cpu_info *



CVS commit: src/sys/arch/alpha/common

2020-09-25 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Sep 26 02:35:31 UTC 2020

Modified Files:
src/sys/arch/alpha/common: shared_intr.c

Log Message:
- Fix some bugs in previous, mainly related to indexing the correct
  interrupt queue.
- Make sure to update cpu_info::ci_nintrhand if an irq moves from
  one CPU to another.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/alpha/common/shared_intr.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

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Sep 26 00:03:29 UTC 2020

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

Log Message:
make(1): replace a few Lst_ForEachUntil with simpler Lst_ForEach


To generate a diff of this commit:
cvs rdiff -u -r1.330 -r1.331 src/usr.bin/make/parse.c

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

Modified files:

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.330 src/usr.bin/make/parse.c:1.331
--- src/usr.bin/make/parse.c:1.330	Fri Sep 25 23:39:51 2020
+++ src/usr.bin/make/parse.c	Sat Sep 26 00:03:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.330 2020/09/25 23:39:51 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.331 2020/09/26 00:03:29 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.330 2020/09/25 23:39:51 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.331 2020/09/26 00:03:29 rillig Exp $");
 
 /* types and constants */
 
@@ -793,7 +793,7 @@ struct ParseLinkSrcArgs {
  * Add the parent to the child's parents, but only if the target is not
  * special.  An example for such a special target is .END, which does not
  * need to be informed once the child target has been made. */
-static int
+static void
 ParseLinkSrc(void *pgnp, void *data)
 {
 const struct ParseLinkSrcArgs *args = data;
@@ -815,8 +815,6 @@ ParseLinkSrc(void *pgnp, void *data)
 	Targ_PrintNode(pgn, 0);
 	Targ_PrintNode(cgn, 0);
 }
-
-return 0;
 }
 
 /*-
@@ -954,7 +952,7 @@ ParseDoSrc(int tOp, const char *src, Par
 		gn->type = OP_WAIT | OP_PHONY | OP_DEPENDS | OP_NOTMAIN;
 		if (targets != NULL) {
 		struct ParseLinkSrcArgs args = { gn, specType };
-		Lst_ForEachUntil(targets, ParseLinkSrc, );
+		Lst_ForEach(targets, ParseLinkSrc, );
 		}
 		return;
 	}
@@ -1025,7 +1023,7 @@ ParseDoSrc(int tOp, const char *src, Par
 	} else {
 	if (targets != NULL) {
 	struct ParseLinkSrcArgs args = { gn, specType };
-		Lst_ForEachUntil(targets, ParseLinkSrc, );
+		Lst_ForEach(targets, ParseLinkSrc, );
 	}
 	}
 	break;
@@ -1063,44 +1061,16 @@ ParseFindMain(void *gnp, void *dummy MAK
 }
 }
 
-/*-
- *---
- * ParseAddDir --
- *	Front-end for Dir_AddDir to make sure Lst_ForEachUntil keeps going
- *
- * Results:
- *	=== 0
- *
- * Side Effects:
- *	See Dir_AddDir.
- *
- *---
- */
-static int
+static void
 ParseAddDir(void *path, void *name)
 {
 (void)Dir_AddDir(path, name);
-return 0;
 }
 
-/*-
- *---
- * ParseClearPath --
- *	Front-end for Dir_ClearPath to make sure Lst_ForEachUntil keeps going
- *
- * Results:
- *	=== 0
- *
- * Side Effects:
- *	See Dir_ClearPath
- *
- *---
- */
-static int
-ParseClearPath(void *path, void *dummy MAKE_ATTR_UNUSED)
+static void
+ParseClearPath(void *path, void *unused MAKE_ATTR_UNUSED)
 {
 Dir_ClearPath(path);
-return 0;
 }
 
 /*
@@ -1561,7 +1531,7 @@ ParseDoDependency(char *line)
 		break;
 	case ExPath:
 		if (paths != NULL)
-		Lst_ForEachUntil(paths, ParseClearPath, NULL);
+		Lst_ForEach(paths, ParseClearPath, NULL);
 		Dir_SetPATH();
 		break;
 #ifdef POSIX
@@ -1637,7 +1607,7 @@ ParseDoDependency(char *line)
 		break;
 		case ExPath:
 		if (paths != NULL)
-			Lst_ForEachUntil(paths, ParseAddDir, line);
+			Lst_ForEach(paths, ParseAddDir, line);
 		break;
 		case Includes:
 		Suff_AddInclude(line);
@@ -2836,18 +2806,17 @@ ParseReadLine(void)
 }
 }
 
-static int
+static void
 SuffEndTransform(void *target, void *unused MAKE_ATTR_UNUSED)
 {
 Suff_EndTransform(target);
-return 0;
 }
 
 static void
 FinishDependencyGroup(void)
 {
 if (targets != NULL) {
-	Lst_ForEachUntil(targets, SuffEndTransform, NULL);
+	Lst_ForEach(targets, SuffEndTransform, NULL);
 	Lst_Destroy(targets, ParseHasCommands);
 }
 targets = NULL;



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Sep 26 00:03:29 UTC 2020

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

Log Message:
make(1): replace a few Lst_ForEachUntil with simpler Lst_ForEach


To generate a diff of this commit:
cvs rdiff -u -r1.330 -r1.331 src/usr.bin/make/parse.c

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



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

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 23:42:43 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: dep-colon-bug-cross-file.mk

Log Message:
make(1): fix grammar and style in test dep-colon-bug-cross-file


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.mk

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



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

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 23:42:43 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: dep-colon-bug-cross-file.mk

Log Message:
make(1): fix grammar and style in test dep-colon-bug-cross-file


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.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/dep-colon-bug-cross-file.mk
diff -u src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.mk:1.2 src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.mk:1.3
--- src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.mk:1.2	Fri Sep 25 23:30:16 2020
+++ src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.mk	Fri Sep 25 23:42:43 2020
@@ -1,4 +1,4 @@
-# $NetBSD: dep-colon-bug-cross-file.mk,v 1.2 2020/09/25 23:30:16 rillig Exp $
+# $NetBSD: dep-colon-bug-cross-file.mk,v 1.3 2020/09/25 23:42:43 rillig Exp $
 #
 # Until 2020-09-25, the very last dependency group of a top-level makefile
 # was not finished properly.  This made it possible to add further commands
@@ -11,8 +11,8 @@
 #
 # After the file has been parsed completely, it is parsed again in pass 2.
 # In this pass, another command is added to the "current dependency group",
-# which is still the one from pass 1, which means it is possible to even
-# cross file boundaries.
+# which was still the one from pass 1, which means it was possible to later
+# add commands to an existing target, even across file boundaries.
 #
 # Oops, even worse.  Running this test in a make from 2020-09-25 or earlier
 # on NetBSD 8.0 x86_64 with MALLOC_OPTIONS=JA produces this or a similar
@@ -22,7 +22,7 @@
 #
 # The 'Z' means access to already freed memory; see jemalloc(3).  The cause
 # for this is that in MainParseArgs, the command line arguments were not
-# properly copied before storing them with global variables.
+# properly copied before storing them in global variables.
 
 PASS?=	1
 



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 23:39:51 UTC 2020

Modified Files:
src/usr.bin/make: parse.c
src/usr.bin/make/unit-tests: deptgt.mk

Log Message:
make(1): remove redundant variable inLine from parse.c

This variable has served at least 27 years bringing unnecessary
redundancy to the code.  It was already redundant at 1993-03-21, when
the code was imported to NetBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.329 -r1.330 src/usr.bin/make/parse.c
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/deptgt.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/parse.c
diff -u src/usr.bin/make/parse.c:1.329 src/usr.bin/make/parse.c:1.330
--- src/usr.bin/make/parse.c:1.329	Fri Sep 25 23:35:25 2020
+++ src/usr.bin/make/parse.c	Fri Sep 25 23:39:51 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.329 2020/09/25 23:35:25 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.330 2020/09/25 23:39:51 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.329 2020/09/25 23:35:25 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.330 2020/09/25 23:39:51 rillig Exp $");
 
 /* types and constants */
 
@@ -232,9 +232,6 @@ static GNode	*predecessor;
 
 /* parser state */
 
-/* true if currently in a dependency line or its commands */
-static Boolean inLine;
-
 /* number of fatal errors */
 static int fatals = 0;
 
@@ -2849,14 +2846,11 @@ SuffEndTransform(void *target, void *unu
 static void
 FinishDependencyGroup(void)
 {
-if (inLine) {
-	if (targets != NULL) {
-	Lst_ForEachUntil(targets, SuffEndTransform, NULL);
-	Lst_Destroy(targets, ParseHasCommands);
-	}
-	targets = NULL;
-	inLine = FALSE;
+if (targets != NULL) {
+	Lst_ForEachUntil(targets, SuffEndTransform, NULL);
+	Lst_Destroy(targets, ParseHasCommands);
 }
+targets = NULL;
 }
 
 /* Add the command to each target from the current dependency spec. */
@@ -2869,10 +2863,10 @@ ParseLine_ShellCommand(char *cp)
 if (*cp == '\0')
 	return;			/* skip empty commands */
 
-if (!inLine)
+if (targets == NULL) {
 	Parse_Error(PARSE_FATAL, "Unassociated shell command \"%s\"", cp);
-if (targets == NULL)
 	return;
+}
 
 {
 	char *cmd = bmake_strdup(cp);
@@ -2904,7 +2898,7 @@ Parse_File(const char *name, int fd)
 
 lf = loadfile(name, fd);
 
-inLine = FALSE;
+assert(targets == NULL);
 fatals = 0;
 
 if (name == NULL)
@@ -3012,7 +3006,7 @@ Parse_File(const char *name, int fd)
 		cp++;
 		}
 		if (*cp == '\0') {
-		if (inLine) {
+		if (targets == NULL) {
 			Parse_Error(PARSE_WARNING,
  "Shell command needs a leading tab");
 			goto shellCommand;
@@ -3094,14 +3088,10 @@ Parse_File(const char *name, int fd)
 		/* TODO: handle errors */
 	}
 
-	/*
-	 * Need a list for the target nodes
-	 */
+	/* Need a fresh list for the target nodes */
 	if (targets != NULL)
 		Lst_Free(targets);
-
 	targets = Lst_Init();
-	inLine = TRUE;
 
 	ParseDoDependency(line);
 	free(line);

Index: src/usr.bin/make/unit-tests/deptgt.mk
diff -u src/usr.bin/make/unit-tests/deptgt.mk:1.6 src/usr.bin/make/unit-tests/deptgt.mk:1.7
--- src/usr.bin/make/unit-tests/deptgt.mk:1.6	Fri Sep 25 23:35:25 2020
+++ src/usr.bin/make/unit-tests/deptgt.mk	Fri Sep 25 23:39:51 2020
@@ -1,4 +1,4 @@
-# $NetBSD: deptgt.mk,v 1.6 2020/09/25 23:35:25 rillig Exp $
+# $NetBSD: deptgt.mk,v 1.7 2020/09/25 23:39:51 rillig Exp $
 #
 # Tests for special targets like .BEGIN or .SUFFIXES in dependency
 # declarations.
@@ -16,7 +16,7 @@
 #	FinishDependencyGroup	at "targets = NULL"
 #	Parse_File		at "Lst_Free(targets)"
 #	Parse_File		at "targets = Lst_Init()"
-#	Parse_File		at "!inLine"
+#	ParseLine_ShellCommand	at "targets == NULL"
 #
 # Keywords:
 #	parse.c:targets



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 23:39:51 UTC 2020

Modified Files:
src/usr.bin/make: parse.c
src/usr.bin/make/unit-tests: deptgt.mk

Log Message:
make(1): remove redundant variable inLine from parse.c

This variable has served at least 27 years bringing unnecessary
redundancy to the code.  It was already redundant at 1993-03-21, when
the code was imported to NetBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.329 -r1.330 src/usr.bin/make/parse.c
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/deptgt.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

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 23:35:25 UTC 2020

Modified Files:
src/usr.bin/make: parse.c
src/usr.bin/make/unit-tests: deptgt.mk

Log Message:
make(1): rename ParseFinishLine to FinishDependencyGroup

Even after 27 or more years, it's not too late to fix bad function
names.  This one for example does not finish a line but a dependency
group.


To generate a diff of this commit:
cvs rdiff -u -r1.328 -r1.329 src/usr.bin/make/parse.c
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/deptgt.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/parse.c
diff -u src/usr.bin/make/parse.c:1.328 src/usr.bin/make/parse.c:1.329
--- src/usr.bin/make/parse.c:1.328	Fri Sep 25 23:30:16 2020
+++ src/usr.bin/make/parse.c	Fri Sep 25 23:35:25 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.328 2020/09/25 23:30:16 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.329 2020/09/25 23:35:25 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.328 2020/09/25 23:30:16 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.329 2020/09/25 23:35:25 rillig Exp $");
 
 /* types and constants */
 
@@ -2846,21 +2846,8 @@ SuffEndTransform(void *target, void *unu
 return 0;
 }
 
-/*-
- *---
- * ParseFinishLine --
- *	Handle the end of a dependency group.
- *
- * Results:
- *	Nothing.
- *
- * Side Effects:
- *	inLine set FALSE. 'targets' list destroyed.
- *
- *---
- */
 static void
-ParseFinishLine(void)
+FinishDependencyGroup(void)
 {
 if (inLine) {
 	if (targets != NULL) {
@@ -3003,7 +2990,7 @@ Parse_File(const char *name, int fd)
 	}
 #endif
 	if (Parse_IsVar(line)) {
-		ParseFinishLine();
+		FinishDependencyGroup();
 		Parse_DoVar(line, VAR_GLOBAL);
 		continue;
 	}
@@ -3033,7 +3020,7 @@ Parse_File(const char *name, int fd)
 		}
 	}
 #endif
-	ParseFinishLine();
+	FinishDependencyGroup();
 
 	/*
 	 * For some reason - probably to make the parser impossible -
@@ -3129,7 +3116,7 @@ Parse_File(const char *name, int fd)
 	 */
 } while (ParseEOF() == CONTINUE);
 
-ParseFinishLine();
+FinishDependencyGroup();
 
 if (fatals) {
 	(void)fflush(stdout);

Index: src/usr.bin/make/unit-tests/deptgt.mk
diff -u src/usr.bin/make/unit-tests/deptgt.mk:1.5 src/usr.bin/make/unit-tests/deptgt.mk:1.6
--- src/usr.bin/make/unit-tests/deptgt.mk:1.5	Mon Sep 14 18:27:15 2020
+++ src/usr.bin/make/unit-tests/deptgt.mk	Fri Sep 25 23:35:25 2020
@@ -1,4 +1,4 @@
-# $NetBSD: deptgt.mk,v 1.5 2020/09/14 18:27:15 rillig Exp $
+# $NetBSD: deptgt.mk,v 1.6 2020/09/25 23:35:25 rillig Exp $
 #
 # Tests for special targets like .BEGIN or .SUFFIXES in dependency
 # declarations.
@@ -13,7 +13,7 @@
 # parsing of dependencies.  To see it in action, set breakpoints in:
 #
 #	ParseDoDependency	at the beginning
-#	ParseFinishLine		at "targets = NULL"
+#	FinishDependencyGroup	at "targets = NULL"
 #	Parse_File		at "Lst_Free(targets)"
 #	Parse_File		at "targets = Lst_Init()"
 #	Parse_File		at "!inLine"



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 23:35:25 UTC 2020

Modified Files:
src/usr.bin/make: parse.c
src/usr.bin/make/unit-tests: deptgt.mk

Log Message:
make(1): rename ParseFinishLine to FinishDependencyGroup

Even after 27 or more years, it's not too late to fix bad function
names.  This one for example does not finish a line but a dependency
group.


To generate a diff of this commit:
cvs rdiff -u -r1.328 -r1.329 src/usr.bin/make/parse.c
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/deptgt.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

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 23:30:16 UTC 2020

Modified Files:
src/usr.bin/make: parse.c
src/usr.bin/make/unit-tests: dep-colon-bug-cross-file.exp
dep-colon-bug-cross-file.mk opt-debug-graph1.exp

Log Message:
make(1): fix missing check for duplicate commands in Parse_File


To generate a diff of this commit:
cvs rdiff -u -r1.327 -r1.328 src/usr.bin/make/parse.c
cvs rdiff -u -r1.1 -r1.2 \
src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.exp \
src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.mk
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/opt-debug-graph1.exp

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



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 23:30:16 UTC 2020

Modified Files:
src/usr.bin/make: parse.c
src/usr.bin/make/unit-tests: dep-colon-bug-cross-file.exp
dep-colon-bug-cross-file.mk opt-debug-graph1.exp

Log Message:
make(1): fix missing check for duplicate commands in Parse_File


To generate a diff of this commit:
cvs rdiff -u -r1.327 -r1.328 src/usr.bin/make/parse.c
cvs rdiff -u -r1.1 -r1.2 \
src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.exp \
src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.mk
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/opt-debug-graph1.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/parse.c
diff -u src/usr.bin/make/parse.c:1.327 src/usr.bin/make/parse.c:1.328
--- src/usr.bin/make/parse.c:1.327	Fri Sep 25 21:13:44 2020
+++ src/usr.bin/make/parse.c	Fri Sep 25 23:30:16 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.327 2020/09/25 21:13:44 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.328 2020/09/25 23:30:16 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.327 2020/09/25 21:13:44 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.328 2020/09/25 23:30:16 rillig Exp $");
 
 /* types and constants */
 
@@ -3129,6 +3129,8 @@ Parse_File(const char *name, int fd)
 	 */
 } while (ParseEOF() == CONTINUE);
 
+ParseFinishLine();
+
 if (fatals) {
 	(void)fflush(stdout);
 	(void)fprintf(stderr,

Index: src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.exp
diff -u src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.exp:1.1 src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.exp:1.2
--- src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.exp:1.1	Fri Sep 25 23:24:49 2020
+++ src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.exp	Fri Sep 25 23:30:16 2020
@@ -1,3 +1,4 @@
+make: "dep-colon-bug-cross-file.mk" line 31: warning: duplicate script for target "all" ignored
+make: "dep-colon-bug-cross-file.mk" line 40: warning: using previous script for "all" defined here
 : pass 1
-: pass 2
 exit status 0
Index: src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.mk
diff -u src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.mk:1.1 src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.mk:1.2
--- src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.mk:1.1	Fri Sep 25 23:24:49 2020
+++ src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.mk	Fri Sep 25 23:30:16 2020
@@ -1,4 +1,4 @@
-# $NetBSD: dep-colon-bug-cross-file.mk,v 1.1 2020/09/25 23:24:49 rillig Exp $
+# $NetBSD: dep-colon-bug-cross-file.mk,v 1.2 2020/09/25 23:30:16 rillig Exp $
 #
 # Until 2020-09-25, the very last dependency group of a top-level makefile
 # was not finished properly.  This made it possible to add further commands
@@ -14,8 +14,6 @@
 # which is still the one from pass 1, which means it is possible to even
 # cross file boundaries.
 #
-# TODO: Finish the file properly in Parse_File.
-#
 # Oops, even worse.  Running this test in a make from 2020-09-25 or earlier
 # on NetBSD 8.0 x86_64 with MALLOC_OPTIONS=JA produces this or a similar
 # output:

Index: src/usr.bin/make/unit-tests/opt-debug-graph1.exp
diff -u src/usr.bin/make/unit-tests/opt-debug-graph1.exp:1.3 src/usr.bin/make/unit-tests/opt-debug-graph1.exp:1.4
--- src/usr.bin/make/unit-tests/opt-debug-graph1.exp:1.3	Sat Sep  5 06:46:12 2020
+++ src/usr.bin/make/unit-tests/opt-debug-graph1.exp	Fri Sep 25 23:30:16 2020
@@ -1,5 +1,5 @@
 #*** Input graph:
-# all, made UNMADE, type OP_DEPENDS, flags none
+# all, made UNMADE, type OP_DEPENDS|OP_HAS_COMMANDS, flags none
 # made-target, made UNMADE, type OP_DEPENDS, flags none
 # made-target-no-sources, made UNMADE, type OP_DEPENDS, flags none
 # made-source, made UNMADE, type OP_DEPENDS, flags none



CVS commit: src

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 23:24:49 UTC 2020

Modified Files:
src/distrib/sets/lists/tests: mi
src/usr.bin/make/unit-tests: Makefile dep-wildcards.exp
Added Files:
src/usr.bin/make/unit-tests: dep-colon-bug-cross-file.exp
dep-colon-bug-cross-file.mk

Log Message:
make(1): add test for harmless bug in Parse_File

When there is a dependency group at the end of a top-level makefile,
this dependency group is not finished properly.  This allows to add
further commands to the targets of this dependency group, which was not
intended.


To generate a diff of this commit:
cvs rdiff -u -r1.929 -r1.930 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.151 -r1.152 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 \
src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.exp \
src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.mk
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/dep-wildcards.exp

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.929 src/distrib/sets/lists/tests/mi:1.930
--- src/distrib/sets/lists/tests/mi:1.929	Fri Sep 25 18:18:25 2020
+++ src/distrib/sets/lists/tests/mi	Fri Sep 25 23:24:49 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.929 2020/09/25 18:18:25 rillig Exp $
+# $NetBSD: mi,v 1.930 2020/09/25 23:24:49 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4614,6 +4614,8 @@
 ./usr/tests/usr.bin/make/unit-tests/counter-append.mktests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/counter.exp	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/counter.mk	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/dep-colon-bug-cross-file.exp		tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/dep-colon-bug-cross-file.mk			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/dep-colon.exptests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/dep-colon.mktests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/dep-double-colon.exp			tests-usr.bin-tests	compattestfile,atf

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.151 src/usr.bin/make/unit-tests/Makefile:1.152
--- src/usr.bin/make/unit-tests/Makefile:1.151	Fri Sep 25 20:11:06 2020
+++ src/usr.bin/make/unit-tests/Makefile	Fri Sep 25 23:24:49 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.151 2020/09/25 20:11:06 rillig Exp $
+# $NetBSD: Makefile,v 1.152 2020/09/25 23:24:49 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -74,6 +74,7 @@ TESTS+=		counter
 TESTS+=		counter-append
 TESTS+=		dep
 TESTS+=		dep-colon
+TESTS+=		dep-colon-bug-cross-file
 TESTS+=		dep-double-colon
 TESTS+=		dep-exclam
 TESTS+=		dep-none

Index: src/usr.bin/make/unit-tests/dep-wildcards.exp
diff -u src/usr.bin/make/unit-tests/dep-wildcards.exp:1.2 src/usr.bin/make/unit-tests/dep-wildcards.exp:1.3
--- src/usr.bin/make/unit-tests/dep-wildcards.exp:1.2	Tue Sep  8 05:33:05 2020
+++ src/usr.bin/make/unit-tests/dep-wildcards.exp	Fri Sep 25 23:24:49 2020
@@ -1,3 +1,4 @@
+dep-colon-bug-cross-file.mk
 dep-colon.mk
 dep-double-colon.mk
 dep-exclam.mk

Added files:

Index: src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.exp
diff -u /dev/null src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.exp:1.1
--- /dev/null	Fri Sep 25 23:24:49 2020
+++ src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.exp	Fri Sep 25 23:24:49 2020
@@ -0,0 +1,3 @@
+: pass 1
+: pass 2
+exit status 0
Index: src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.mk
diff -u /dev/null src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.mk:1.1
--- /dev/null	Fri Sep 25 23:24:49 2020
+++ src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.mk	Fri Sep 25 23:24:49 2020
@@ -0,0 +1,43 @@
+# $NetBSD: dep-colon-bug-cross-file.mk,v 1.1 2020/09/25 23:24:49 rillig Exp $
+#
+# Until 2020-09-25, the very last dependency group of a top-level makefile
+# was not finished properly.  This made it possible to add further commands
+# to that target.
+#
+# In pass 1, there is a dependency group at the bottom of the file.
+# This dependency group is not finished properly.  Finishing the dependency
+# group would add the OP_HAS_COMMANDS flag to the "all" target, thereby
+# preventing any commands from being added later.
+#
+# After the file has been parsed completely, it is parsed again in pass 2.
+# In this pass, another command is added to the "current dependency group",
+# which is still the one from pass 1, which means it is possible to even
+# cross file boundaries.
+#
+# TODO: Finish the file properly in Parse_File.
+#
+# Oops, even worse.  Running this test in a make from 2020-09-25 or earlier
+# on NetBSD 8.0 x86_64 with 

CVS commit: src

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 23:24:49 UTC 2020

Modified Files:
src/distrib/sets/lists/tests: mi
src/usr.bin/make/unit-tests: Makefile dep-wildcards.exp
Added Files:
src/usr.bin/make/unit-tests: dep-colon-bug-cross-file.exp
dep-colon-bug-cross-file.mk

Log Message:
make(1): add test for harmless bug in Parse_File

When there is a dependency group at the end of a top-level makefile,
this dependency group is not finished properly.  This allows to add
further commands to the targets of this dependency group, which was not
intended.


To generate a diff of this commit:
cvs rdiff -u -r1.929 -r1.930 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.151 -r1.152 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 \
src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.exp \
src/usr.bin/make/unit-tests/dep-colon-bug-cross-file.mk
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/dep-wildcards.exp

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



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 23:18:59 UTC 2020

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

Log Message:
make(1): fix undefined behavior for .MAKEFLAGS: -f file

Since at least 1993-03-21, adding other makefiles in a .MAKEFILES
dependency has invoked undefined behavior because the command line
arguments were copied directly into the global makefiles variable,
without a proper strdup.  Shortly after that, the word list created by
Str_Words (formerly brk_string) was freed.

This applies to both the -f and the -v and -V options.  Luckily it is an
edge case to use these options in .MAKEFLAGS at all.

The -T option had already been fixed at 2000-12-30, but not the other
options.


To generate a diff of this commit:
cvs rdiff -u -r1.344 -r1.345 src/usr.bin/make/main.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

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 23:18:59 UTC 2020

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

Log Message:
make(1): fix undefined behavior for .MAKEFLAGS: -f file

Since at least 1993-03-21, adding other makefiles in a .MAKEFILES
dependency has invoked undefined behavior because the command line
arguments were copied directly into the global makefiles variable,
without a proper strdup.  Shortly after that, the word list created by
Str_Words (formerly brk_string) was freed.

This applies to both the -f and the -v and -V options.  Luckily it is an
edge case to use these options in .MAKEFLAGS at all.

The -T option had already been fixed at 2000-12-30, but not the other
options.


To generate a diff of this commit:
cvs rdiff -u -r1.344 -r1.345 src/usr.bin/make/main.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/main.c
diff -u src/usr.bin/make/main.c:1.344 src/usr.bin/make/main.c:1.345
--- src/usr.bin/make/main.c:1.344	Fri Sep 25 19:40:23 2020
+++ src/usr.bin/make/main.c	Fri Sep 25 23:18:59 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.344 2020/09/25 19:40:23 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.345 2020/09/25 23:18:59 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -126,7 +126,7 @@
 #endif
 
 /*	"@(#)main.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: main.c,v 1.344 2020/09/25 19:40:23 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.345 2020/09/25 23:18:59 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\
  The Regents of the University of California.  All rights reserved.");
@@ -389,20 +389,13 @@ is_relpath(const char *path)
 	return FALSE;
 }
 
-/*-
- * MainParseArgs --
- *	Parse a given argument vector. Called from main() and from
- *	Main_ParseArgLine() when the .MAKEFLAGS target is used.
- *
- *	XXX: Deal with command line overriding .MAKEFLAGS in makefile
+/* Parse the given arguments.  Called from main() and from
+ * Main_ParseArgLine() when the .MAKEFLAGS target is used.
  *
- * Results:
- *	None
+ * The arguments must be treated as read-only and will be freed after the
+ * call.
  *
- * Side Effects:
- *	Various global and local flags will be set depending on the flags
- *	given
- */
+ * XXX: Deal with command line overriding .MAKEFLAGS in makefile */
 static void
 MainParseArgs(int argc, char **argv)
 {
@@ -543,7 +536,7 @@ rearg:
 		case 'v':
 			if (argvalue == NULL) goto noarg;
 			printVars = c == 'v' ? EXPAND_VARS : COMPAT_VARS;
-			Lst_Append(variables, argvalue);
+			Lst_Append(variables, bmake_strdup(argvalue));
 			Var_Append(MAKEFLAGS, "-V", VAR_GLOBAL);
 			Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL);
 			break;
@@ -571,7 +564,7 @@ rearg:
 			break;
 		case 'f':
 			if (argvalue == NULL) goto noarg;
-			Lst_Append(makefiles, argvalue);
+			Lst_Append(makefiles, bmake_strdup(argvalue));
 			break;
 		case 'i':
 			ignoreErrors = TRUE;



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 21:13:44 UTC 2020

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

Log Message:
make(1): inline Lst_ForEachUntil in ParseLine_ShellCommand


To generate a diff of this commit:
cvs rdiff -u -r1.326 -r1.327 src/usr.bin/make/parse.c

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

Modified files:

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.326 src/usr.bin/make/parse.c:1.327
--- src/usr.bin/make/parse.c:1.326	Fri Sep 25 20:57:22 2020
+++ src/usr.bin/make/parse.c	Fri Sep 25 21:13:44 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.326 2020/09/25 20:57:22 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.327 2020/09/25 21:13:44 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.326 2020/09/25 20:57:22 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.327 2020/09/25 21:13:44 rillig Exp $");
 
 /* types and constants */
 
@@ -2043,30 +2043,16 @@ ParseMaybeSubMake(const char *cmd)
 return FALSE;
 }
 
-/*-
- * ParseAddCmd  --
- *	Lst_ForEachUntil function to add a command line to all targets
- *
- * Input:
- *	gnp		the node to which the command is to be added
- *	cmd		the command to add
- *
- * Results:
- *	Always 0
+/* Append the command to the target node.
  *
- * Side Effects:
- *	A new element is added to the commands list of the node,
- *	and the node can be marked as a submake node if the command is
- *	determined to be that.
- */
-static int
-ParseAddCmd(void *gnp, void *cmd)
+ * The node may be marked as a submake node if the command is determined to
+ * be that. */
+static void
+ParseAddCmd(GNode *gn, char *cmd)
 {
-GNode *gn = (GNode *)gnp;
-
 /* Add to last (ie current) cohort for :: targets */
-if ((gn->type & OP_DOUBLEDEP) && !Lst_IsEmpty(gn->cohorts))
-	gn = LstNode_Datum(Lst_Last(gn->cohorts));
+if ((gn->type & OP_DOUBLEDEP) && gn->cohorts->last != NULL)
+	gn = gn->cohorts->last->datum;
 
 /* if target already supplied, ignore commands */
 if (!(gn->type & OP_HAS_COMMANDS)) {
@@ -2075,7 +2061,7 @@ ParseAddCmd(void *gnp, void *cmd)
 	gn->type |= OP_SUBMAKE;
 	ParseMark(gn);
 } else {
-#ifdef notyet
+#if 0
 	/* XXX: We cannot do this until we fix the tree */
 	Lst_Append(gn->commands, cmd);
 	Parse_Error(PARSE_WARNING,
@@ -2091,7 +2077,6 @@ ParseAddCmd(void *gnp, void *cmd)
 			gn->name);
 #endif
 }
-return 0;
 }
 
 /* Callback procedure for Parse_File when destroying the list of targets on
@@ -2887,27 +2872,32 @@ ParseFinishLine(void)
 }
 }
 
+/* Add the command to each target from the current dependency spec. */
 static void
 ParseLine_ShellCommand(char *cp)
 {
 for (; ch_isspace(*cp); cp++)
 	continue;
 
-if (*cp != '\0') {
-	if (!inLine)
-	Parse_Error(PARSE_FATAL, "Unassociated shell command \"%s\"", cp);
-	/*
-	 * So long as it's not a blank line and we're actually
-	 * in a dependency spec, add the command to the list of
-	 * commands of all targets in the dependency spec
-	 */
-	if (targets) {
-	cp = bmake_strdup(cp);
-	Lst_ForEachUntil(targets, ParseAddCmd, cp);
+if (*cp == '\0')
+	return;			/* skip empty commands */
+
+if (!inLine)
+	Parse_Error(PARSE_FATAL, "Unassociated shell command \"%s\"", cp);
+if (targets == NULL)
+	return;
+
+{
+	char *cmd = bmake_strdup(cp);
+	GNodeListNode *ln;
+
+	for (ln = targets->first; ln != NULL; ln = ln->next) {
+	GNode *gn = ln->datum;
+	ParseAddCmd(gn, cmd);
+	}
 #ifdef CLEANUP
-	Lst_Append(targCmds, cp);
+	Lst_Append(targCmds, cmd);
 #endif
-	}
 }
 }
 



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 21:13:44 UTC 2020

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

Log Message:
make(1): inline Lst_ForEachUntil in ParseLine_ShellCommand


To generate a diff of this commit:
cvs rdiff -u -r1.326 -r1.327 src/usr.bin/make/parse.c

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



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 20:57:22 UTC 2020

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

Log Message:
make(1): extract ParseLine_ShellCommand from Parse_File

Parsing a single shell command from a line does not belong in
Parse_File, its proper place is in Parse_Line.  Having the whole
detailed code inline in Parse_File is even more confusing.


To generate a diff of this commit:
cvs rdiff -u -r1.325 -r1.326 src/usr.bin/make/parse.c

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

Modified files:

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.325 src/usr.bin/make/parse.c:1.326
--- src/usr.bin/make/parse.c:1.325	Fri Sep 25 20:48:23 2020
+++ src/usr.bin/make/parse.c	Fri Sep 25 20:57:22 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.325 2020/09/25 20:48:23 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.326 2020/09/25 20:57:22 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.325 2020/09/25 20:48:23 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.326 2020/09/25 20:57:22 rillig Exp $");
 
 /* types and constants */
 
@@ -2887,6 +2887,29 @@ ParseFinishLine(void)
 }
 }
 
+static void
+ParseLine_ShellCommand(char *cp)
+{
+for (; ch_isspace(*cp); cp++)
+	continue;
+
+if (*cp != '\0') {
+	if (!inLine)
+	Parse_Error(PARSE_FATAL, "Unassociated shell command \"%s\"", cp);
+	/*
+	 * So long as it's not a blank line and we're actually
+	 * in a dependency spec, add the command to the list of
+	 * commands of all targets in the dependency spec
+	 */
+	if (targets) {
+	cp = bmake_strdup(cp);
+	Lst_ForEachUntil(targets, ParseAddCmd, cp);
+#ifdef CLEANUP
+	Lst_Append(targCmds, cp);
+#endif
+	}
+}
+}
 
 /* Parse a top-level makefile into its component parts, incorporating them
  * into the global dependency graph.
@@ -2966,27 +2989,7 @@ Parse_File(const char *name, int fd)
 		 */
 		cp = line + 1;
 	  shellCommand:
-		for (; ch_isspace(*cp); cp++) {
-		continue;
-		}
-		if (*cp) {
-		if (!inLine)
-			Parse_Error(PARSE_FATAL,
- "Unassociated shell command \"%s\"",
- cp);
-		/*
-		 * So long as it's not a blank line and we're actually
-		 * in a dependency spec, add the command to the list of
-		 * commands of all targets in the dependency spec
-		 */
-		if (targets) {
-			cp = bmake_strdup(cp);
-			Lst_ForEachUntil(targets, ParseAddCmd, cp);
-#ifdef CLEANUP
-			Lst_Append(targCmds, cp);
-#endif
-		}
-		}
+	ParseLine_ShellCommand(cp);
 		continue;
 	}
 



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 20:57:22 UTC 2020

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

Log Message:
make(1): extract ParseLine_ShellCommand from Parse_File

Parsing a single shell command from a line does not belong in
Parse_File, its proper place is in Parse_Line.  Having the whole
detailed code inline in Parse_File is even more confusing.


To generate a diff of this commit:
cvs rdiff -u -r1.325 -r1.326 src/usr.bin/make/parse.c

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



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 20:48:23 UTC 2020

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

Log Message:
make(1): rename variables cp2 to be more expressive


To generate a diff of this commit:
cvs rdiff -u -r1.150 -r1.151 src/usr.bin/make/cond.c
cvs rdiff -u -r1.324 -r1.325 src/usr.bin/make/parse.c

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

Modified files:

Index: src/usr.bin/make/cond.c
diff -u src/usr.bin/make/cond.c:1.150 src/usr.bin/make/cond.c:1.151
--- src/usr.bin/make/cond.c:1.150	Fri Sep 25 15:54:50 2020
+++ src/usr.bin/make/cond.c	Fri Sep 25 20:48:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.150 2020/09/25 15:54:50 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.151 2020/09/25 20:48:23 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -93,7 +93,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.150 2020/09/25 15:54:50 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.151 2020/09/25 20:48:23 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -245,13 +245,13 @@ ParseFuncArg(const char **pp, Boolean do
 	 * variable, so we don't need to do it. Nor do we return an error,
 	 * though perhaps we should...
 	 */
-	void *freeIt;
+	void *nestedVal_freeIt;
 	VarEvalFlags eflags = VARE_UNDEFERR | (doEval ? VARE_WANTRES : 0);
-	const char *cp2;
-	(void)Var_Parse(, VAR_CMD, eflags, , );
+	const char *nestedVal;
+	(void)Var_Parse(, VAR_CMD, eflags, , _freeIt);
 	/* TODO: handle errors */
-	Buf_AddStr(, cp2);
-	free(freeIt);
+	Buf_AddStr(, nestedVal);
+	free(nestedVal_freeIt);
 	continue;
 	}
 	if (ch == '(')

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.324 src/usr.bin/make/parse.c:1.325
--- src/usr.bin/make/parse.c:1.324	Thu Sep 24 07:11:29 2020
+++ src/usr.bin/make/parse.c	Fri Sep 25 20:48:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.324 2020/09/24 07:11:29 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.325 2020/09/25 20:48:23 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.324 2020/09/24 07:11:29 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.325 2020/09/25 20:48:23 rillig Exp $");
 
 /* types and constants */
 
@@ -1923,11 +1923,11 @@ Parse_DoVar(char *line, GNode *ctxt)
 if (DEBUG(LINT)) {
 	if (type != VAR_SUBST && strchr(cp, '$') != NULL) {
 	/* sanity check now */
-	char *cp2;
+	char *expandedValue;
 
-	(void)Var_Subst(cp, ctxt, VARE_ASSIGN, );
+	(void)Var_Subst(cp, ctxt, VARE_ASSIGN, );
 	/* TODO: handle errors */
-	free(cp2);
+	free(expandedValue);
 	}
 }
 
@@ -2925,21 +2925,23 @@ Parse_File(const char *name, int fd)
 		 * On the other hand they can be suffix rules (.c.o: ...)
 		 * or just dependencies for filenames that start '.'.
 		 */
-		for (cp = line + 1; ch_isspace(*cp); cp++) {
+		for (cp = line + 1; ch_isspace(*cp); cp++)
 		continue;
-		}
 		if (IsInclude(cp, FALSE)) {
 		ParseDoInclude(cp);
 		continue;
 		}
 		if (strncmp(cp, "undef", 5) == 0) {
-		char *cp2;
+		const char *varname;
 		for (cp += 5; ch_isspace(*cp); cp++)
 			continue;
-		for (cp2 = cp; !ch_isspace(*cp2) && *cp2 != '\0'; cp2++)
+		varname = cp;
+		for (; !ch_isspace(*cp) && *cp != '\0'; cp++)
 			continue;
-		*cp2 = '\0';
-		Var_Delete(cp, VAR_GLOBAL);
+		*cp = '\0';
+		Var_Delete(varname, VAR_GLOBAL);
+		/* TODO: undefine all variables, not only the first */
+		/* TODO: use Str_Words, like everywhere else */
 		continue;
 		} else if (strncmp(cp, "export", 6) == 0) {
 		for (cp += 6; ch_isspace(*cp); cp++)



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 20:48:23 UTC 2020

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

Log Message:
make(1): rename variables cp2 to be more expressive


To generate a diff of this commit:
cvs rdiff -u -r1.150 -r1.151 src/usr.bin/make/cond.c
cvs rdiff -u -r1.324 -r1.325 src/usr.bin/make/parse.c

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



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

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 20:11:06 UTC 2020

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

Log Message:
make(1): add test for make() function in conditions


To generate a diff of this commit:
cvs rdiff -u -r1.150 -r1.151 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/cond-func-make.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/cond-func-make.mk

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



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

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 20:11:06 UTC 2020

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

Log Message:
make(1): add test for make() function in conditions


To generate a diff of this commit:
cvs rdiff -u -r1.150 -r1.151 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/cond-func-make.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/cond-func-make.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/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.150 src/usr.bin/make/unit-tests/Makefile:1.151
--- src/usr.bin/make/unit-tests/Makefile:1.150	Fri Sep 25 18:18:25 2020
+++ src/usr.bin/make/unit-tests/Makefile	Fri Sep 25 20:11:06 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.150 2020/09/25 18:18:25 rillig Exp $
+# $NetBSD: Makefile,v 1.151 2020/09/25 20:11:06 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -362,6 +362,7 @@ ENV.varmisc+=		FROM_ENV_AFTER=env
 # Override make flags for some of the tests; default is -k.
 # If possible, write ".MAKEFLAGS: -dv" in the test .mk file instead of
 # settings FLAGS.test=-dv here, since that is closer to the test code.
+FLAGS.cond-func-make=	via-cmdline
 FLAGS.directive-ifmake=	first second
 FLAGS.doterror=		# none
 FLAGS.envfirst=		-e

Index: src/usr.bin/make/unit-tests/cond-func-make.exp
diff -u src/usr.bin/make/unit-tests/cond-func-make.exp:1.1 src/usr.bin/make/unit-tests/cond-func-make.exp:1.2
--- src/usr.bin/make/unit-tests/cond-func-make.exp:1.1	Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/cond-func-make.exp	Fri Sep 25 20:11:06 2020
@@ -1 +1,3 @@
+: via-cmdline
+: via-dot-makeflags
 exit status 0

Index: src/usr.bin/make/unit-tests/cond-func-make.mk
diff -u src/usr.bin/make/unit-tests/cond-func-make.mk:1.2 src/usr.bin/make/unit-tests/cond-func-make.mk:1.3
--- src/usr.bin/make/unit-tests/cond-func-make.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/cond-func-make.mk	Fri Sep 25 20:11:06 2020
@@ -1,8 +1,24 @@
-# $NetBSD: cond-func-make.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: cond-func-make.mk,v 1.3 2020/09/25 20:11:06 rillig Exp $
 #
-# Tests for the make() function in .if conditions.
+# Tests for the make() function in .if conditions, which tests whether
+# the argument has been passed as a target via the command line or later
+# via the .MAKEFLAGS special dependency target.
 
-# TODO: Implementation
+.if !make(via-cmdline)
+.  error
+.endif
+.if make(via-dot-makeflags)
+.  error
+.endif
 
-all:
-	@:;
+.MAKEFLAGS: via-dot-makeflags
+
+.if !make(via-cmdline)
+.  error
+.endif
+.if !make(via-dot-makeflags)
+.  error
+.endif
+
+via-cmdline via-dot-makeflags:
+	: $@



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 19:50:04 UTC 2020

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

Log Message:
make(1): declare strings for suff.c constant


To generate a diff of this commit:
cvs rdiff -u -r1.128 -r1.129 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.166 -r1.167 src/usr.bin/make/suff.c

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

Modified files:

Index: src/usr.bin/make/nonints.h
diff -u src/usr.bin/make/nonints.h:1.128 src/usr.bin/make/nonints.h:1.129
--- src/usr.bin/make/nonints.h:1.128	Fri Sep 25 15:54:50 2020
+++ src/usr.bin/make/nonints.h	Fri Sep 25 19:50:04 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nonints.h,v 1.128 2020/09/25 15:54:50 rillig Exp $	*/
+/*	$NetBSD: nonints.h,v 1.129 2020/09/25 19:50:04 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -152,17 +152,17 @@ Boolean Str_Match(const char *, const ch
 
 /* suff.c */
 void Suff_ClearSuffixes(void);
-Boolean Suff_IsTransform(char *);
-GNode *Suff_AddTransform(char *);
+Boolean Suff_IsTransform(const char *);
+GNode *Suff_AddTransform(const char *);
 void Suff_EndTransform(GNode *);
 void Suff_AddSuffix(const char *, GNode **);
-SearchPath *Suff_GetPath(char *);
+SearchPath *Suff_GetPath(const char *);
 void Suff_DoPaths(void);
-void Suff_AddInclude(char *);
+void Suff_AddInclude(const char *);
 void Suff_AddLib(const char *);
 void Suff_FindDeps(GNode *);
 SearchPath *Suff_FindPath(GNode *);
-void Suff_SetNull(char *);
+void Suff_SetNull(const char *);
 void Suff_Init(void);
 void Suff_End(void);
 void Suff_PrintAll(void);

Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.166 src/usr.bin/make/suff.c:1.167
--- src/usr.bin/make/suff.c:1.166	Fri Sep 25 18:58:12 2020
+++ src/usr.bin/make/suff.c	Fri Sep 25 19:50:04 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.166 2020/09/25 18:58:12 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.167 2020/09/25 19:50:04 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -126,7 +126,7 @@
 #include	  "dir.h"
 
 /*	"@(#)suff.c	8.4 (Berkeley) 3/21/94"	*/
-MAKE_RCSID("$NetBSD: suff.c,v 1.166 2020/09/25 18:58:12 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.167 2020/09/25 19:50:04 rillig Exp $");
 
 #define SUFF_DEBUG0(fmt) \
 if (!DEBUG(SUFF)) (void) 0; else fprintf(debug_file, fmt)
@@ -464,11 +464,11 @@ Suff_ClearSuffixes(void)
  *	TRUE if the string is a valid transformation, FALSE otherwise.
  */
 static Boolean
-SuffParseTransform(char *str, Suff **out_src, Suff **out_targ)
+SuffParseTransform(const char *str, Suff **out_src, Suff **out_targ)
 {
 SuffListNode *srcLn;	/* element in suffix list of trans source*/
 Suff *src;			/* Source of transformation */
-char *str2;			/* Extra pointer (maybe target suffix) */
+const char *str2;		/* Extra pointer (maybe target suffix) */
 SuffListNode *singleLn;	/* element in suffix list of any suffix
  * that exactly matches str */
 Suff *single = NULL;	/* Source of possible transformation to
@@ -529,7 +529,7 @@ SuffParseTransform(char *str, Suff **out
 /* Return TRUE if the given string is a transformation rule, that is, a
  * concatenation of two known suffixes. */
 Boolean
-Suff_IsTransform(char *str)
+Suff_IsTransform(const char *str)
 {
 Suff	  *src, *targ;
 
@@ -549,7 +549,7 @@ Suff_IsTransform(char *str)
  *	The node created for the transformation in the transforms list
  */
 GNode *
-Suff_AddTransform(char *line)
+Suff_AddTransform(const char *line)
 {
 GNode *gn;		/* GNode of transformation rule */
 Suff  *s,		/* source suffix */
@@ -803,7 +803,7 @@ Suff_AddSuffix(const char *name, GNode *
 
 /* Return the search path for the given suffix, or NULL. */
 SearchPath *
-Suff_GetPath(char *sname)
+Suff_GetPath(const char *sname)
 {
 Suff *s = FindSuffByName(sname);
 return s != NULL ? s->searchPath : NULL;
@@ -871,7 +871,7 @@ Suff_DoPaths(void)
  *	sname		Name of the suffix to mark
  */
 void
-Suff_AddInclude(char *sname)
+Suff_AddInclude(const char *sname)
 {
 Suff *suff = FindSuffByName(sname);
 if (suff != NULL)
@@ -2095,7 +2095,7 @@ SuffFindDeps(GNode *gn, SrcList *slst)
  *	name		Name of null suffix
  */
 void
-Suff_SetNull(char *name)
+Suff_SetNull(const char *name)
 {
 Suff *s = FindSuffByName(name);
 if (s == NULL) {



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 19:50:04 UTC 2020

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

Log Message:
make(1): declare strings for suff.c constant


To generate a diff of this commit:
cvs rdiff -u -r1.128 -r1.129 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.166 -r1.167 src/usr.bin/make/suff.c

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



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 19:40:23 UTC 2020

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

Log Message:
make(1): extract parsing of the -dF option into separate function


To generate a diff of this commit:
cvs rdiff -u -r1.343 -r1.344 src/usr.bin/make/main.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

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 19:40:23 UTC 2020

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

Log Message:
make(1): extract parsing of the -dF option into separate function


To generate a diff of this commit:
cvs rdiff -u -r1.343 -r1.344 src/usr.bin/make/main.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/main.c
diff -u src/usr.bin/make/main.c:1.343 src/usr.bin/make/main.c:1.344
--- src/usr.bin/make/main.c:1.343	Fri Sep 25 19:24:56 2020
+++ src/usr.bin/make/main.c	Fri Sep 25 19:40:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.343 2020/09/25 19:24:56 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.344 2020/09/25 19:40:23 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -126,7 +126,7 @@
 #endif
 
 /*	"@(#)main.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: main.c,v 1.343 2020/09/25 19:24:56 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.344 2020/09/25 19:40:23 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\
  The Regents of the University of California.  All rights reserved.");
@@ -223,12 +223,51 @@ explode(const char *flags)
 }
 
 static void
+parse_debug_option_F(const char *modules)
+{
+const char *mode;
+size_t len;
+char *fname;
+
+if (debug_file != stdout && debug_file != stderr)
+	fclose(debug_file);
+
+if (*modules == '+') {
+	modules++;
+	mode = "a";
+} else
+	mode = "w";
+
+if (strcmp(modules, "stdout") == 0) {
+	debug_file = stdout;
+	return;
+}
+if (strcmp(modules, "stderr") == 0) {
+	debug_file = stderr;
+	return;
+}
+
+len = strlen(modules);
+fname = bmake_malloc(len + 20);
+memcpy(fname, modules, len + 1);
+
+/* Let the filename be modified by the pid */
+if (strcmp(fname + len - 3, ".%d") == 0)
+	snprintf(fname + len - 2, 20, "%d", getpid());
+
+debug_file = fopen(fname, mode);
+if (!debug_file) {
+	fprintf(stderr, "Cannot open debug file %s\n",
+		fname);
+	usage();
+}
+free(fname);
+}
+
+static void
 parse_debug_options(const char *argvalue)
 {
 	const char *modules;
-	const char *mode;
-	char *fname;
-	int len;
 
 	for (modules = argvalue; *modules; ++modules) {
 		switch (*modules) {
@@ -307,34 +346,7 @@ parse_debug_options(const char *argvalue
 			debug |= DEBUG_SHELL;
 			break;
 		case 'F':
-			if (debug_file != stdout && debug_file != stderr)
-fclose(debug_file);
-			if (*++modules == '+') {
-modules++;
-mode = "a";
-			} else
-mode = "w";
-			if (strcmp(modules, "stdout") == 0) {
-debug_file = stdout;
-goto debug_setbuf;
-			}
-			if (strcmp(modules, "stderr") == 0) {
-debug_file = stderr;
-goto debug_setbuf;
-			}
-			len = strlen(modules);
-			fname = bmake_malloc(len + 20);
-			memcpy(fname, modules, len + 1);
-			/* Let the filename be modified by the pid */
-			if (strcmp(fname + len - 3, ".%d") == 0)
-snprintf(fname + len - 2, 20, "%d", getpid());
-			debug_file = fopen(fname, mode);
-			if (!debug_file) {
-fprintf(stderr, "Cannot open debug file %s\n",
-fname);
-usage();
-			}
-			free(fname);
+			parse_debug_option_F(modules + 1);
 			goto debug_setbuf;
 		default:
 			(void)fprintf(stderr,



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 19:24:56 UTC 2020

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

Log Message:
make(1): extract InitVarTarget from main


To generate a diff of this commit:
cvs rdiff -u -r1.342 -r1.343 src/usr.bin/make/main.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/main.c
diff -u src/usr.bin/make/main.c:1.342 src/usr.bin/make/main.c:1.343
--- src/usr.bin/make/main.c:1.342	Thu Sep 24 07:11:29 2020
+++ src/usr.bin/make/main.c	Fri Sep 25 19:24:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.342 2020/09/24 07:11:29 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.343 2020/09/25 19:24:56 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -126,7 +126,7 @@
 #endif
 
 /*	"@(#)main.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: main.c,v 1.342 2020/09/24 07:11:29 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.343 2020/09/25 19:24:56 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\
  The Regents of the University of California.  All rights reserved.");
@@ -931,6 +931,27 @@ runTargets(void)
 	return outOfDate;
 }
 
+/*
+ * Set up the .TARGETS variable to contain the list of targets to be
+ * created. If none specified, make the variable empty -- the parser
+ * will fill the thing in with the default or .MAIN target.
+ */
+static void
+InitVarTargets(void)
+{
+	StringListNode *ln;
+
+	if (Lst_IsEmpty(create)) {
+		Var_Set(".TARGETS", "", VAR_GLOBAL);
+		return;
+	}
+
+	for (ln = create->first; ln != NULL; ln = ln->next) {
+		char *name = ln->datum;
+		Var_Append(".TARGETS", name, VAR_GLOBAL);
+	}
+}
+
 /*-
  * main --
  *	The main function, for obvious reasons. Initializes variables
@@ -1265,21 +1286,7 @@ main(int argc, char **argv)
 
 	Trace_Log(MAKESTART, NULL);
 
-	/*
-	 * Set up the .TARGETS variable to contain the list of targets to be
-	 * created. If none specified, make the variable empty -- the parser
-	 * will fill the thing in with the default or .MAIN target.
-	 */
-	if (!Lst_IsEmpty(create)) {
-		StringListNode *ln;
-
-		for (ln = Lst_First(create); ln != NULL; ln = LstNode_Next(ln)) {
-			char *name = LstNode_Datum(ln);
-			Var_Append(".TARGETS", name, VAR_GLOBAL);
-		}
-	} else
-		Var_Set(".TARGETS", "", VAR_GLOBAL);
-
+	InitVarTargets();
 
 	/*
 	 * If no user-supplied system path was given (through the -m option)



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 19:24:56 UTC 2020

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

Log Message:
make(1): extract InitVarTarget from main


To generate a diff of this commit:
cvs rdiff -u -r1.342 -r1.343 src/usr.bin/make/main.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

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 18:58:12 UTC 2020

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

Log Message:
make(1): in FindSuffByName, return the suffix instead of a list node

None of the callers was interested in the list node.


To generate a diff of this commit:
cvs rdiff -u -r1.165 -r1.166 src/usr.bin/make/suff.c

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



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 18:58:12 UTC 2020

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

Log Message:
make(1): in FindSuffByName, return the suffix instead of a list node

None of the callers was interested in the list node.


To generate a diff of this commit:
cvs rdiff -u -r1.165 -r1.166 src/usr.bin/make/suff.c

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

Modified files:

Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.165 src/usr.bin/make/suff.c:1.166
--- src/usr.bin/make/suff.c:1.165	Fri Sep 25 17:55:19 2020
+++ src/usr.bin/make/suff.c	Fri Sep 25 18:58:12 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.165 2020/09/25 17:55:19 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.166 2020/09/25 18:58:12 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -126,7 +126,7 @@
 #include	  "dir.h"
 
 /*	"@(#)suff.c	8.4 (Berkeley) 3/21/94"	*/
-MAKE_RCSID("$NetBSD: suff.c,v 1.165 2020/09/25 17:55:19 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.166 2020/09/25 18:58:12 rillig Exp $");
 
 #define SUFF_DEBUG0(fmt) \
 if (!DEBUG(SUFF)) (void) 0; else fprintf(debug_file, fmt)
@@ -294,15 +294,15 @@ SuffSuffIsSuffix(const void *s, const vo
 return SuffSuffGetSuffix(s, sd) != NULL;
 }
 
-static SuffListNode *
+static Suff *
 FindSuffByName(const char *name)
 {
 SuffListNode *ln;
 
 for (ln = sufflist->first; ln != NULL; ln = ln->next) {
-const Suff *suff = ln->datum;
+Suff *suff = ln->datum;
 if (strcmp(suff->name, name) == 0)
-return ln;
+return suff;
 }
 return NULL;
 }
@@ -468,7 +468,6 @@ SuffParseTransform(char *str, Suff **out
 {
 SuffListNode *srcLn;	/* element in suffix list of trans source*/
 Suff *src;			/* Source of transformation */
-SuffListNode *targLn;	/* element in suffix list of trans target*/
 char *str2;			/* Extra pointer (maybe target suffix) */
 SuffListNode *singleLn;	/* element in suffix list of any suffix
  * that exactly matches str */
@@ -517,10 +516,10 @@ SuffParseTransform(char *str, Suff **out
 	single = src;
 	singleLn = srcLn;
 	} else {
-	targLn = FindSuffByName(str2);
-	if (targLn != NULL) {
+	Suff *targ = FindSuffByName(str2);
+	if (targ != NULL) {
 		*out_src = src;
-		*out_targ = LstNode_Datum(targLn);
+		*out_targ = targ;
 		return TRUE;
 	}
 	}
@@ -670,7 +669,6 @@ SuffRebuildGraph(void *transformp, void 
 GNode   	*transform = (GNode *)transformp;
 Suff	*s = (Suff *)sp;
 char 	*cp;
-Suff  	*s2;
 struct SuffSuffGetSuffixArgs sd;
 
 /*
@@ -678,13 +676,9 @@ SuffRebuildGraph(void *transformp, void 
  */
 cp = UNCONST(SuffStrIsPrefix(s->name, transform->name));
 if (cp != NULL) {
-	SuffListNode *ln = FindSuffByName(cp);
-	if (ln != NULL) {
-	/*
-	 * Found target. Link in and return, since it can't be anything
-	 * else.
-	 */
-	s2 = LstNode_Datum(ln);
+	Suff *s2 = FindSuffByName(cp);
+	if (s2 != NULL) {
+	/* Link in and return, since it can't be anything else. */
 	SuffInsert(s2->children, s);
 	SuffInsert(s->parents, s2);
 	return;
@@ -698,22 +692,16 @@ SuffRebuildGraph(void *transformp, void 
 sd.name_end = transform->name + sd.name_len;
 cp = SuffSuffGetSuffix(s, );
 if (cp != NULL) {
-	SuffListNode *ln;
+	Suff *s2;
 
-	/*
-	 * Null-terminate the source suffix in order to find it.
-	 */
+	/* Null-terminate the source suffix in order to find it. */
+	/* XXX: don't modify strings, not even temporarily */
 	cp[1] = '\0';
-	ln = FindSuffByName(transform->name);
-	/*
-	 * Replace the start of the target suffix
-	 */
-	cp[1] = s->name[0];
-	if (ln != NULL) {
-	/*
-	 * Found it -- establish the proper relationship
-	 */
-	s2 = LstNode_Datum(ln);
+	s2 = FindSuffByName(transform->name);
+	cp[1] = s->name[0];		/* restore */
+
+	if (s2 != NULL) {
+	/* establish the proper relationship */
 	SuffInsert(s->children, s2);
 	SuffInsert(s2->parents, s);
 	}
@@ -786,47 +774,39 @@ SuffScanTargets(void *targetp, void *gsp
 void
 Suff_AddSuffix(const char *name, GNode **gnp)
 {
-Suff  *s;	/* new suffix descriptor */
-SuffListNode *ln;
-GNodeSuff	  gs;
+GNodeSuff gs;
 
-ln = FindSuffByName(name);
-if (ln == NULL) {
-	s = SuffNew(name);
+Suff *s = FindSuffByName(name);
+if (s != NULL)
+	return;
 
-	Lst_Append(sufflist, s);
-	/*
-	 * We also look at our existing targets list to see if adding
-	 * this suffix will make one of our current targets mutate into
-	 * a suffix rule. This is ugly, but other makes treat all targets
-	 * that start with a . as suffix rules.
-	 */
-	gs.gnp = gnp;
-	gs.s  = s;
-	gs.r  = FALSE;
-	Lst_ForEachUntil(Targ_List(), SuffScanTargets, );
-	/*
-	 * Look for any existing transformations from or to this suffix.
-	 * XXX: Only do this after a Suff_ClearSuffixes?
-	 */
-	

CVS commit: src

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 18:18:25 UTC 2020

Modified Files:
src/distrib/sets/lists/tests: mi
src/usr.bin/make/unit-tests: Makefile
Added Files:
src/usr.bin/make/unit-tests: suff-rebuild.exp suff-rebuild.mk

Log Message:
make(1): add test for deleting the suffixes during parsing


To generate a diff of this commit:
cvs rdiff -u -r1.928 -r1.929 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.149 -r1.150 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/suff-rebuild.exp \
src/usr.bin/make/unit-tests/suff-rebuild.mk

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.928 src/distrib/sets/lists/tests/mi:1.929
--- src/distrib/sets/lists/tests/mi:1.928	Fri Sep 25 05:56:59 2020
+++ src/distrib/sets/lists/tests/mi	Fri Sep 25 18:18:25 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.928 2020/09/25 05:56:59 rillig Exp $
+# $NetBSD: mi,v 1.929 2020/09/25 18:18:25 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4960,6 +4960,8 @@
 ./usr/tests/usr.bin/make/unit-tests/sh-single-line.mktests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/sh.exp	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/sh.mk	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/suff-rebuild.exptests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/suff-rebuild.mktests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/suffixes.exptests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/suffixes.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/sunshcmd.exptests-usr.bin-tests	compattestfile,atf

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.149 src/usr.bin/make/unit-tests/Makefile:1.150
--- src/usr.bin/make/unit-tests/Makefile:1.149	Fri Sep 25 05:56:59 2020
+++ src/usr.bin/make/unit-tests/Makefile	Fri Sep 25 18:18:25 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.149 2020/09/25 05:56:59 rillig Exp $
+# $NetBSD: Makefile,v 1.150 2020/09/25 18:18:25 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -242,6 +242,7 @@ TESTS+=		sh-meta-chars
 TESTS+=		sh-multi-line
 TESTS+=		sh-single-line
 TESTS+=		# suffixes	# runs into an endless loop (try -dA)
+TESTS+=		suff-rebuild
 TESTS+=		sunshcmd
 TESTS+=		sysv
 TESTS+=		ternary

Added files:

Index: src/usr.bin/make/unit-tests/suff-rebuild.exp
diff -u /dev/null src/usr.bin/make/unit-tests/suff-rebuild.exp:1.1
--- /dev/null	Fri Sep 25 18:18:26 2020
+++ src/usr.bin/make/unit-tests/suff-rebuild.exp	Fri Sep 25 18:18:25 2020
@@ -0,0 +1,5 @@
+: from nothing to a
+: from a to b
+: from b to c
+: from c to nothing
+exit status 0
Index: src/usr.bin/make/unit-tests/suff-rebuild.mk
diff -u /dev/null src/usr.bin/make/unit-tests/suff-rebuild.mk:1.1
--- /dev/null	Fri Sep 25 18:18:26 2020
+++ src/usr.bin/make/unit-tests/suff-rebuild.mk	Fri Sep 25 18:18:25 2020
@@ -0,0 +1,33 @@
+# $NetBSD: suff-rebuild.mk,v 1.1 2020/09/25 18:18:25 rillig Exp $
+#
+# Demonstrates what happens to transformation rules (called inference rules
+# by POSIX) when all suffixes are deleted.
+
+all: suff-rebuild-example
+
+.SUFFIXES:
+
+.SUFFIXES: .a .b .c
+
+suff-rebuild-example.a:
+	: from nothing to a
+
+.a.b:
+	: from a to b
+.b.c:
+	: from b to c
+.c:
+	: from c to nothing
+
+# XXX: At a quick glance, the code in SuffScanTargets looks at if it were
+# possible to delete the suffixes in the middle of the makefile, add back
+# the suffixes from before, and have the transformation rules preserved.
+#
+# As of 2020-09-25, uncommenting the following line results in the error
+# message "don't know how to make suff-rebuild-example" though.
+#
+#.SUFFIXES:
+
+# Add the suffixes back.  It should not matter that the order of the suffixes
+# is different from before.
+.SUFFIXES: .c .b .a



CVS commit: src

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 18:18:25 UTC 2020

Modified Files:
src/distrib/sets/lists/tests: mi
src/usr.bin/make/unit-tests: Makefile
Added Files:
src/usr.bin/make/unit-tests: suff-rebuild.exp suff-rebuild.mk

Log Message:
make(1): add test for deleting the suffixes during parsing


To generate a diff of this commit:
cvs rdiff -u -r1.928 -r1.929 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.149 -r1.150 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/suff-rebuild.exp \
src/usr.bin/make/unit-tests/suff-rebuild.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

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 17:55:19 UTC 2020

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

Log Message:
make(1): migrate suff.c from Lst_ForEachUntil to Lst_ForEach


To generate a diff of this commit:
cvs rdiff -u -r1.164 -r1.165 src/usr.bin/make/suff.c

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



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 17:55:19 UTC 2020

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

Log Message:
make(1): migrate suff.c from Lst_ForEachUntil to Lst_ForEach


To generate a diff of this commit:
cvs rdiff -u -r1.164 -r1.165 src/usr.bin/make/suff.c

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

Modified files:

Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.164 src/usr.bin/make/suff.c:1.165
--- src/usr.bin/make/suff.c:1.164	Fri Sep 25 17:14:32 2020
+++ src/usr.bin/make/suff.c	Fri Sep 25 17:55:19 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.164 2020/09/25 17:14:32 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.165 2020/09/25 17:55:19 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -126,7 +126,7 @@
 #include	  "dir.h"
 
 /*	"@(#)suff.c	8.4 (Berkeley) 3/21/94"	*/
-MAKE_RCSID("$NetBSD: suff.c,v 1.164 2020/09/25 17:14:32 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.165 2020/09/25 17:55:19 rillig Exp $");
 
 #define SUFF_DEBUG0(fmt) \
 if (!DEBUG(SUFF)) (void) 0; else fprintf(debug_file, fmt)
@@ -599,7 +599,6 @@ Suff_AddTransform(char *line)
 
 /* Handle the finish of a transformation definition, removing the
  * transformation from the graph if it has neither commands nor sources.
- * This is a callback procedure for the Parse module via Lst_ForEachUntil.
  *
  * If the node has no commands or children, the children and parents lists
  * of the affected suffixes are altered.
@@ -664,11 +663,8 @@ Suff_EndTransform(GNode *gn)
  * Input:
  *	transformp	Transformation to test
  *	sp		Suffix to rebuild
- *
- * Results:
- *	0, so that Lst_ForEachUntil continues
  */
-static int
+static void
 SuffRebuildGraph(void *transformp, void *sp)
 {
 GNode   	*transform = (GNode *)transformp;
@@ -691,7 +687,7 @@ SuffRebuildGraph(void *transformp, void 
 	s2 = LstNode_Datum(ln);
 	SuffInsert(s2->children, s);
 	SuffInsert(s->parents, s2);
-	return 0;
+	return;
 	}
 }
 
@@ -722,7 +718,6 @@ SuffRebuildGraph(void *transformp, void 
 	SuffInsert(s2->parents, s);
 	}
 }
-return 0;
 }
 
 /* Called from Suff_AddSuffix via Lst_ForEachUntil to search through the list of
@@ -814,7 +809,7 @@ Suff_AddSuffix(const char *name, GNode *
 	 * Look for any existing transformations from or to this suffix.
 	 * XXX: Only do this after a Suff_ClearSuffixes?
 	 */
-	Lst_ForEachUntil(transforms, SuffRebuildGraph, s);
+	Lst_ForEach(transforms, SuffRebuildGraph, s);
 }
 }
 
@@ -926,11 +921,10 @@ Suff_AddLib(const char *sname)
 	  /** Implicit Source Search Functions */
 
 #ifdef DEBUG_SRC
-static int
+static void
 PrintAddr(void *a, void *b MAKE_ATTR_UNUSED)
 {
 printf("%lx ", (unsigned long) a);
-return 0;
 }
 #endif
 
@@ -941,11 +935,8 @@ PrintAddr(void *a, void *b MAKE_ATTR_UNU
  * Input:
  *	sp		suffix for which to create a Src structure
  *	lsp		list and parent for the new Src
- *
- * Results:
- *	0, so that Lst_ForEachUntil continues
  */
-static int
+static void
 SuffAddSrc(void *sp, void *lsp)
 {
 Suff	*s = (Suff *)sp;
@@ -975,7 +966,7 @@ SuffAddSrc(void *sp, void *lsp)
 	s2->cp = Lst_Init();
 	Lst_Append(targ->cp, s2);
 	fprintf(debug_file, "1 add %p %p to %p:", targ, s2, ls->l);
-	Lst_ForEachUntil(ls->l, PrintAddr, NULL);
+	Lst_ForEach(ls->l, PrintAddr, NULL);
 	fprintf(debug_file, "\n");
 #endif
 }
@@ -993,11 +984,9 @@ SuffAddSrc(void *sp, void *lsp)
 s2->cp = Lst_Init();
 Lst_Append(targ->cp, s2);
 fprintf(debug_file, "2 add %p %p to %p:", targ, s2, ls->l);
-Lst_ForEachUntil(ls->l, PrintAddr, NULL);
+Lst_ForEach(ls->l, PrintAddr, NULL);
 fprintf(debug_file, "\n");
 #endif
-
-return 0;
 }
 
 /* Add all the children of targ as Src structures to the given list.
@@ -1014,7 +1003,7 @@ SuffAddLevel(SrcList *l, Src *targ)
 ls.s = targ;
 ls.l = l;
 
-Lst_ForEachUntil(targ->suff->children, SuffAddSrc, );
+Lst_ForEach(targ->suff->children, SuffAddSrc, );
 }
 
 /* Free the first Src in the list that doesn't have a reference count.
@@ -1029,7 +1018,7 @@ SuffRemoveSrc(SrcList *l)
 
 #ifdef DEBUG_SRC
 fprintf(debug_file, "cleaning %lx: ", (unsigned long) l);
-Lst_ForEachUntil(l, PrintAddr, NULL);
+Lst_ForEach(l, PrintAddr, NULL);
 fprintf(debug_file, "\n");
 #endif
 
@@ -1059,7 +1048,7 @@ SuffRemoveSrc(SrcList *l)
 #ifdef DEBUG_SRC
 	else {
 	fprintf(debug_file, "keep: [l=%p] p=%p %d: ", l, s, s->children);
-	Lst_ForEachUntil(s->cp, PrintAddr, NULL);
+	Lst_ForEach(s->cp, PrintAddr, NULL);
 	fprintf(debug_file, "\n");
 	}
 #endif
@@ -2193,14 +2182,13 @@ Suff_End(void)
 
 /* DEBUGGING FUNCTIONS **/
 
-static int SuffPrintName(void *s, void *dummy MAKE_ATTR_UNUSED)
+static void
+SuffPrintName(void *s, void *dummy MAKE_ATTR_UNUSED)
 {
-
 fprintf(debug_file, "%s ", ((Suff *)s)->name);
-return 0;
 }
 
-static 

CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 17:14:32 UTC 2020

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

Log Message:
make(1): convert int to size_t for string lengths

Just for formal reasons.  There is no practical scenario in which any
filename suffix would grow larger than a few kilocharacters.


To generate a diff of this commit:
cvs rdiff -u -r1.163 -r1.164 src/usr.bin/make/suff.c

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

Modified files:

Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.163 src/usr.bin/make/suff.c:1.164
--- src/usr.bin/make/suff.c:1.163	Fri Sep 25 16:28:29 2020
+++ src/usr.bin/make/suff.c	Fri Sep 25 17:14:32 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.163 2020/09/25 16:28:29 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.164 2020/09/25 17:14:32 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -126,7 +126,7 @@
 #include	  "dir.h"
 
 /*	"@(#)suff.c	8.4 (Berkeley) 3/21/94"	*/
-MAKE_RCSID("$NetBSD: suff.c,v 1.163 2020/09/25 16:28:29 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.164 2020/09/25 17:14:32 rillig Exp $");
 
 #define SUFF_DEBUG0(fmt) \
 if (!DEBUG(SUFF)) (void) 0; else fprintf(debug_file, fmt)
@@ -172,7 +172,7 @@ typedef List SuffListList;
  */
 typedef struct Suff {
 char *name;		/* The suffix itself, such as ".c" */
-int		 nameLen;	/* Length of the name, to avoid strlen calls */
+size_t	 nameLen;	/* Length of the name, to avoid strlen calls */
 SuffFlags	 flags;  	/* Type of suffix */
 SearchPath	 *searchPath;	/* The path along which files of this suffix
  * may be found */
@@ -252,8 +252,8 @@ SuffStrIsPrefix(const char *pref, const 
 }
 
 struct SuffSuffGetSuffixArgs {
-char	*ename;		/* The end of the name */
-int		 len;		/* Length of the name */
+size_t name_len;
+char *name_end;
 };
 
 /* See if suff is a suffix of str. str->ename should point to THE END
@@ -273,11 +273,11 @@ SuffSuffGetSuffix(const Suff *s, const s
 char  *p1;		/* Pointer into suffix name */
 char  *p2;		/* Pointer into string being examined */
 
-if (str->len < s->nameLen)
+if (str->name_len < s->nameLen)
 	return NULL;		/* this string is shorter than the suffix */
 
 p1 = s->name + s->nameLen;
-p2 = str->ename;
+p2 = str->name_end;
 
 while (p1 >= s->name && *p1 == *p2) {
 	p1--;
@@ -698,8 +698,8 @@ SuffRebuildGraph(void *transformp, void 
 /*
  * Not from, maybe to?
  */
-sd.len = strlen(transform->name);
-sd.ename = transform->name + sd.len;
+sd.name_len = strlen(transform->name);
+sd.name_end = transform->name + sd.name_len;
 cp = SuffSuffGetSuffix(s, );
 if (cp != NULL) {
 	SuffListNode *ln;
@@ -1143,7 +1143,7 @@ SuffFindCmds(Src *targ, SrcList *slst)
 
 GNode		*t, 	/* Target GNode */
 			*s; 	/* Source GNode */
-int		  	prefLen;/* The length of the defined prefix */
+size_t		prefLen;/* The length of the defined prefix */
 Suff	  	*suff;	/* Suffix on matching beastie */
 Src		  	*ret;	/* Return value */
 char	  	*cp;
@@ -1452,8 +1452,8 @@ Suff_FindPath(GNode* gn)
 if (suff == NULL) {
 	struct SuffSuffGetSuffixArgs sd;   /* Search string data */
 	SuffListNode *ln;
-	sd.len = strlen(gn->name);
-	sd.ename = gn->name + sd.len;
+	sd.name_len = strlen(gn->name);
+	sd.name_end = gn->name + sd.name_len;
 	ln = Lst_Find(sufflist, SuffSuffIsSuffix, );
 
 	SUFF_DEBUG1("Wildcard expanding \"%s\"...", gn->name);
@@ -1661,8 +1661,8 @@ SuffFindArchiveDeps(GNode *gn, SrcList *
 	/*
 	 * Use first matching suffix...
 	 */
-	sd.len = eoarch - gn->name;
-	sd.ename = eoarch;
+	sd.name_len = eoarch - gn->name;
+	sd.name_end = eoarch;
 	ln = Lst_Find(ms->parents, SuffSuffIsSuffix, );
 
 	if (ln != NULL) {
@@ -1725,8 +1725,8 @@ SuffFindNormalDeps(GNode *gn, SrcList *s
 struct SuffSuffGetSuffixArgs sd; /* Search string data */
 
 
-sd.len = strlen(gn->name);
-sd.ename = eoname = gn->name + sd.len;
+sd.name_len = strlen(gn->name);
+sd.name_end = eoname = gn->name + sd.name_len;
 
 sopref = gn->name;
 
@@ -1903,7 +1903,7 @@ sfnd_abort:
 		 * Suffix known for the thing -- trim the suffix off
 		 * the path to form the proper .PREFIX variable.
 		 */
-		int savep = strlen(gn->path) - targ->suff->nameLen;
+		size_t savep = strlen(gn->path) - targ->suff->nameLen;
 		charsavec;
 
 		if (gn->suffix)



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 17:14:32 UTC 2020

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

Log Message:
make(1): convert int to size_t for string lengths

Just for formal reasons.  There is no practical scenario in which any
filename suffix would grow larger than a few kilocharacters.


To generate a diff of this commit:
cvs rdiff -u -r1.163 -r1.164 src/usr.bin/make/suff.c

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



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 16:28:29 UTC 2020

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

Log Message:
make(1): don't use reserved names in type names


To generate a diff of this commit:
cvs rdiff -u -r1.162 -r1.163 src/usr.bin/make/suff.c

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

Modified files:

Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.162 src/usr.bin/make/suff.c:1.163
--- src/usr.bin/make/suff.c:1.162	Fri Sep 25 16:27:15 2020
+++ src/usr.bin/make/suff.c	Fri Sep 25 16:28:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.162 2020/09/25 16:27:15 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.163 2020/09/25 16:28:29 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -126,7 +126,7 @@
 #include	  "dir.h"
 
 /*	"@(#)suff.c	8.4 (Berkeley) 3/21/94"	*/
-MAKE_RCSID("$NetBSD: suff.c,v 1.162 2020/09/25 16:27:15 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.163 2020/09/25 16:28:29 rillig Exp $");
 
 #define SUFF_DEBUG0(fmt) \
 if (!DEBUG(SUFF)) (void) 0; else fprintf(debug_file, fmt)
@@ -186,11 +186,11 @@ typedef struct Suff {
 /*
  * Structure used in the search for implied sources.
  */
-typedef struct _Src {
+typedef struct Src {
 char*file;	/* The file to look for */
 char	*pref;  	/* Prefix from which file was formed */
 Suff*suff;	/* The suffix on the file */
-struct _Src *parent;	/* The Src for which this is a source */
+struct Src *parent;	/* The Src for which this is a source */
 GNode   *node;	/* The node describing the file */
 int		children;	/* Count of existing children (so we don't free
  * this thing too early or never nuke it) */



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 16:28:29 UTC 2020

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

Log Message:
make(1): don't use reserved names in type names


To generate a diff of this commit:
cvs rdiff -u -r1.162 -r1.163 src/usr.bin/make/suff.c

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



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 16:27:15 UTC 2020

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

Log Message:
make(1): replace Lst_Find with FindSuffByName


To generate a diff of this commit:
cvs rdiff -u -r1.161 -r1.162 src/usr.bin/make/suff.c

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

Modified files:

Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.161 src/usr.bin/make/suff.c:1.162
--- src/usr.bin/make/suff.c:1.161	Fri Sep 25 15:54:51 2020
+++ src/usr.bin/make/suff.c	Fri Sep 25 16:27:15 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.161 2020/09/25 15:54:51 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.162 2020/09/25 16:27:15 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -126,7 +126,7 @@
 #include	  "dir.h"
 
 /*	"@(#)suff.c	8.4 (Berkeley) 3/21/94"	*/
-MAKE_RCSID("$NetBSD: suff.c,v 1.161 2020/09/25 15:54:51 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.162 2020/09/25 16:27:15 rillig Exp $");
 
 #define SUFF_DEBUG0(fmt) \
 if (!DEBUG(SUFF)) (void) 0; else fprintf(debug_file, fmt)
@@ -294,11 +294,17 @@ SuffSuffIsSuffix(const void *s, const vo
 return SuffSuffGetSuffix(s, sd) != NULL;
 }
 
-/* See if the suffix has the desired name. */
-static Boolean
-SuffSuffHasName(const void *s, const void *desiredName)
+static SuffListNode *
+FindSuffByName(const char *name)
 {
-return strcmp(((const Suff *)s)->name, desiredName) == 0;
+SuffListNode *ln;
+
+for (ln = sufflist->first; ln != NULL; ln = ln->next) {
+const Suff *suff = ln->datum;
+if (strcmp(suff->name, name) == 0)
+return ln;
+}
+return NULL;
 }
 
 /* See if the suffix name is a prefix of the string. Care must be taken when
@@ -511,7 +517,7 @@ SuffParseTransform(char *str, Suff **out
 	single = src;
 	singleLn = srcLn;
 	} else {
-	targLn = Lst_Find(sufflist, SuffSuffHasName, str2);
+	targLn = FindSuffByName(str2);
 	if (targLn != NULL) {
 		*out_src = src;
 		*out_targ = LstNode_Datum(targLn);
@@ -676,7 +682,7 @@ SuffRebuildGraph(void *transformp, void 
  */
 cp = UNCONST(SuffStrIsPrefix(s->name, transform->name));
 if (cp != NULL) {
-	SuffListNode *ln = Lst_Find(sufflist, SuffSuffHasName, cp);
+	SuffListNode *ln = FindSuffByName(cp);
 	if (ln != NULL) {
 	/*
 	 * Found target. Link in and return, since it can't be anything
@@ -702,7 +708,7 @@ SuffRebuildGraph(void *transformp, void 
 	 * Null-terminate the source suffix in order to find it.
 	 */
 	cp[1] = '\0';
-	ln = Lst_Find(sufflist, SuffSuffHasName, transform->name);
+	ln = FindSuffByName(transform->name);
 	/*
 	 * Replace the start of the target suffix
 	 */
@@ -789,7 +795,7 @@ Suff_AddSuffix(const char *name, GNode *
 SuffListNode *ln;
 GNodeSuff	  gs;
 
-ln = Lst_Find(sufflist, SuffSuffHasName, name);
+ln = FindSuffByName(name);
 if (ln == NULL) {
 	s = SuffNew(name);
 
@@ -819,7 +825,7 @@ Suff_GetPath(char *sname)
 SuffListNode *ln;
 Suff *s;
 
-ln = Lst_Find(sufflist, SuffSuffHasName, sname);
+ln = FindSuffByName(sname);
 if (ln == NULL) {
 	return NULL;
 } else {
@@ -892,7 +898,7 @@ Suff_DoPaths(void)
 void
 Suff_AddInclude(char *sname)
 {
-SuffListNode *ln = Lst_Find(sufflist, SuffSuffHasName, sname);
+SuffListNode *ln = FindSuffByName(sname);
 if (ln != NULL) {
 	Suff *s = LstNode_Datum(ln);
 	s->flags |= SUFF_INCLUDE;
@@ -910,7 +916,7 @@ Suff_AddInclude(char *sname)
 void
 Suff_AddLib(const char *sname)
 {
-SuffListNode *ln = Lst_Find(sufflist, SuffSuffHasName, sname);
+SuffListNode *ln = FindSuffByName(sname);
 if (ln != NULL) {
 	Suff *s = LstNode_Datum(ln);
 	s->flags |= SUFF_LIBRARY;
@@ -1177,7 +1183,7 @@ SuffFindCmds(Src *targ, SrcList *slst)
 	 * The node matches the prefix ok, see if it has a known
 	 * suffix.
 	 */
-	suffln = Lst_Find(sufflist, SuffSuffHasName, [prefLen]);
+	suffln = FindSuffByName(cp + prefLen);
 	if (suffln == NULL)
 	continue;
 	/*
@@ -2097,7 +2103,7 @@ SuffFindDeps(GNode *gn, SrcList *slst)
 	SuffListNode *ln;
 	Suff	*s;
 
-	ln = Lst_Find(sufflist, SuffSuffHasName, LIBSUFF);
+	ln = FindSuffByName(LIBSUFF);
 	if (gn->suffix)
 	gn->suffix->refCount--;
 	if (ln != NULL) {
@@ -2133,7 +2139,7 @@ Suff_SetNull(char *name)
 Suff*s;
 SuffListNode *ln;
 
-ln = Lst_Find(sufflist, SuffSuffHasName, name);
+ln = FindSuffByName(name);
 if (ln != NULL) {
 	s = LstNode_Datum(ln);
 	if (suffNull != NULL) {



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 16:27:15 UTC 2020

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

Log Message:
make(1): replace Lst_Find with FindSuffByName


To generate a diff of this commit:
cvs rdiff -u -r1.161 -r1.162 src/usr.bin/make/suff.c

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



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 15:54:51 UTC 2020

Modified Files:
src/usr.bin/make: cond.c enum.h for.c lst.h nonints.h suff.c var.c

Log Message:
make(1): add tags to some of the unnamed structs

The tags prevent the structs from accidentally becoming compatible
types.

While here, remove a few typedefs for structs that are single-purpose,
since there is no point in abstracting from the actual representation of
these types.


To generate a diff of this commit:
cvs rdiff -u -r1.149 -r1.150 src/usr.bin/make/cond.c
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/enum.h
cvs rdiff -u -r1.85 -r1.86 src/usr.bin/make/for.c
cvs rdiff -u -r1.67 -r1.68 src/usr.bin/make/lst.h
cvs rdiff -u -r1.127 -r1.128 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.160 -r1.161 src/usr.bin/make/suff.c
cvs rdiff -u -r1.540 -r1.541 src/usr.bin/make/var.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

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 15:54:51 UTC 2020

Modified Files:
src/usr.bin/make: cond.c enum.h for.c lst.h nonints.h suff.c var.c

Log Message:
make(1): add tags to some of the unnamed structs

The tags prevent the structs from accidentally becoming compatible
types.

While here, remove a few typedefs for structs that are single-purpose,
since there is no point in abstracting from the actual representation of
these types.


To generate a diff of this commit:
cvs rdiff -u -r1.149 -r1.150 src/usr.bin/make/cond.c
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/enum.h
cvs rdiff -u -r1.85 -r1.86 src/usr.bin/make/for.c
cvs rdiff -u -r1.67 -r1.68 src/usr.bin/make/lst.h
cvs rdiff -u -r1.127 -r1.128 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.160 -r1.161 src/usr.bin/make/suff.c
cvs rdiff -u -r1.540 -r1.541 src/usr.bin/make/var.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.149 src/usr.bin/make/cond.c:1.150
--- src/usr.bin/make/cond.c:1.149	Fri Sep 25 15:40:06 2020
+++ src/usr.bin/make/cond.c	Fri Sep 25 15:54:50 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.149 2020/09/25 15:40:06 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.150 2020/09/25 15:54:50 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -93,7 +93,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.149 2020/09/25 15:40:06 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.150 2020/09/25 15:54:50 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -138,7 +138,7 @@ typedef enum {
 TOK_LPAREN, TOK_RPAREN, TOK_EOF, TOK_NONE, TOK_ERROR
 } Token;
 
-typedef struct {
+typedef struct CondParser {
 const struct If *if_info;	/* Info for current statement */
 const char *p;		/* The remaining condition to parse */
 Token curr;			/* Single push-back token used in parsing */

Index: src/usr.bin/make/enum.h
diff -u src/usr.bin/make/enum.h:1.11 src/usr.bin/make/enum.h:1.12
--- src/usr.bin/make/enum.h:1.11	Tue Sep 22 06:13:38 2020
+++ src/usr.bin/make/enum.h	Fri Sep 25 15:54:50 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: enum.h,v 1.11 2020/09/22 06:13:38 rillig Exp $	*/
+/*	$NetBSD: enum.h,v 1.12 2020/09/25 15:54:50 rillig Exp $	*/
 
 /*
  Copyright (c) 2020 Roland Illig 
@@ -34,7 +34,7 @@
 
 #include 
 
-typedef struct {
+typedef struct EnumToStringSpec {
 	int es_value;
 	const char *es_name;
 } EnumToStringSpec;

Index: src/usr.bin/make/for.c
diff -u src/usr.bin/make/for.c:1.85 src/usr.bin/make/for.c:1.86
--- src/usr.bin/make/for.c:1.85	Tue Sep 22 20:19:46 2020
+++ src/usr.bin/make/for.c	Fri Sep 25 15:54:50 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: for.c,v 1.85 2020/09/22 20:19:46 rillig Exp $	*/
+/*	$NetBSD: for.c,v 1.86 2020/09/25 15:54:50 rillig Exp $	*/
 
 /*
  * Copyright (c) 1992, The Regents of the University of California.
@@ -60,7 +60,7 @@
 #include"strlist.h"
 
 /*	"@(#)for.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: for.c,v 1.85 2020/09/22 20:19:46 rillig Exp $");
+MAKE_RCSID("$NetBSD: for.c,v 1.86 2020/09/25 15:54:50 rillig Exp $");
 
 typedef enum {
 FOR_SUB_ESCAPE_CHAR = 0x0001,
@@ -73,7 +73,7 @@ static int forLevel = 0;	/* Nesting leve
 /*
  * State of a for loop.
  */
-typedef struct {
+typedef struct For {
 Buffer buf;			/* Body of loop */
 strlist_t vars;		/* Iteration variables */
 strlist_t items;		/* Substitution items */

Index: src/usr.bin/make/lst.h
diff -u src/usr.bin/make/lst.h:1.67 src/usr.bin/make/lst.h:1.68
--- src/usr.bin/make/lst.h:1.67	Fri Sep 25 04:18:11 2020
+++ src/usr.bin/make/lst.h	Fri Sep 25 15:54:50 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lst.h,v 1.67 2020/09/25 04:18:11 rillig Exp $	*/
+/*	$NetBSD: lst.h,v 1.68 2020/09/25 15:54:50 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -218,7 +218,7 @@ void *Lst_Dequeue(List *);
 
 /* A stack is a very simple collection of items that only allows access to the
  * top-most item. */
-typedef struct {
+typedef struct Stack {
 void **items;
 size_t len;
 size_t cap;

Index: src/usr.bin/make/nonints.h
diff -u src/usr.bin/make/nonints.h:1.127 src/usr.bin/make/nonints.h:1.128
--- src/usr.bin/make/nonints.h:1.127	Wed Sep 23 03:06:38 2020
+++ src/usr.bin/make/nonints.h	Fri Sep 25 15:54:50 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nonints.h,v 1.127 2020/09/23 03:06:38 rillig Exp $	*/
+/*	$NetBSD: nonints.h,v 1.128 2020/09/25 15:54:50 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@ void Parse_SetInput(const char *, int, i
 GNodeList *Parse_MainName(void);
 
 /* str.c */
-typedef struct {
+typedef struct Words {
 char **words;
 size_t len;
 void *freeIt;

Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.160 

CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 15:40:06 UTC 2020

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

Log Message:
make(1): rename local variables in ParseFuncArg


To generate a diff of this commit:
cvs rdiff -u -r1.148 -r1.149 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.148 src/usr.bin/make/cond.c:1.149
--- src/usr.bin/make/cond.c:1.148	Tue Sep 22 06:06:18 2020
+++ src/usr.bin/make/cond.c	Fri Sep 25 15:40:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.148 2020/09/22 06:06:18 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.149 2020/09/25 15:40:06 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -93,7 +93,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.148 2020/09/22 06:06:18 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.149 2020/09/25 15:40:06 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -194,8 +194,8 @@ CondParser_SkipWhitespace(CondParser *pa
 /* Parse the argument of a built-in function.
  *
  * Arguments:
- *	*linePtr initially points at the '(', upon successful return points
- *	right after the ')'.
+ *	*pp initially points at the '(',
+ *	upon successful return it points right after the ')'.
  *
  *	*out_arg receives the argument as string.
  *
@@ -204,20 +204,17 @@ CondParser_SkipWhitespace(CondParser *pa
  *
  * Return the length of the argument. */
 static int
-ParseFuncArg(const char **linePtr, Boolean doEval, const char *func,
+ParseFuncArg(const char **pp, Boolean doEval, const char *func,
 	 char **out_arg) {
-const char *cp;
-Buffer buf;
+const char *p = *pp;
+Buffer argBuf;
 int paren_depth;
-char ch;
 size_t argLen;
 
-cp = *linePtr;
 if (func != NULL)
-	/* Skip opening '(' - verified by caller */
-	cp++;
+	p++;			/* Skip opening '(' - verified by caller */
 
-if (*cp == '\0') {
+if (*p == '\0') {
 	/*
 	 * No arguments whatsoever. Because 'make' and 'defined' aren't really
 	 * "reserved words", we don't print a message. I think this is better
@@ -228,24 +225,20 @@ ParseFuncArg(const char **linePtr, Boole
 	return 0;
 }
 
-while (*cp == ' ' || *cp == '\t') {
-	cp++;
+while (*p == ' ' || *p == '\t') {
+	p++;
 }
 
-/*
- * Create a buffer for the argument and start it out at 16 characters
- * long. Why 16? Why not?
- */
-Buf_Init(, 16);
+Buf_Init(, 16);
 
 paren_depth = 0;
 for (;;) {
-	ch = *cp;
+	char ch = *p;
 	if (ch == 0 || ch == ' ' || ch == '\t')
 	break;
 	if ((ch == '&' || ch == '|') && paren_depth == 0)
 	break;
-	if (*cp == '$') {
+	if (*p == '$') {
 	/*
 	 * Parse the variable spec and install it as part of the argument
 	 * if it's valid. We tell Var_Parse to complain on an undefined
@@ -255,9 +248,9 @@ ParseFuncArg(const char **linePtr, Boole
 	void *freeIt;
 	VarEvalFlags eflags = VARE_UNDEFERR | (doEval ? VARE_WANTRES : 0);
 	const char *cp2;
-	(void)Var_Parse(, VAR_CMD, eflags, , );
+	(void)Var_Parse(, VAR_CMD, eflags, , );
 	/* TODO: handle errors */
-	Buf_AddStr(, cp2);
+	Buf_AddStr(, cp2);
 	free(freeIt);
 	continue;
 	}
@@ -265,25 +258,25 @@ ParseFuncArg(const char **linePtr, Boole
 	paren_depth++;
 	else if (ch == ')' && --paren_depth < 0)
 	break;
-	Buf_AddByte(, *cp);
-	cp++;
+	Buf_AddByte(, *p);
+	p++;
 }
 
-*out_arg = Buf_GetAll(, );
-Buf_Destroy(, FALSE);
+*out_arg = Buf_GetAll(, );
+Buf_Destroy(, FALSE);
 
-while (*cp == ' ' || *cp == '\t') {
-	cp++;
+while (*p == ' ' || *p == '\t') {
+	p++;
 }
 
-if (func != NULL && *cp++ != ')') {
+if (func != NULL && *p++ != ')') {
 	Parse_Error(PARSE_WARNING, "Missing closing parenthesis for %s()",
 		func);
 	/* The PARSE_FATAL is done as a follow-up by CondEvalExpression. */
 	return 0;
 }
 
-*linePtr = cp;
+*pp = p;
 return argLen;
 }
 



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 15:40:06 UTC 2020

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

Log Message:
make(1): rename local variables in ParseFuncArg


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



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 14:49:51 UTC 2020

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

Log Message:
make(1): inline ArchFindArchive into ArchStatMember

This avoids a few void pointers and unnecessary function calls.


To generate a diff of this commit:
cvs rdiff -u -r1.120 -r1.121 src/usr.bin/make/arch.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/arch.c
diff -u src/usr.bin/make/arch.c:1.120 src/usr.bin/make/arch.c:1.121
--- src/usr.bin/make/arch.c:1.120	Fri Sep 25 14:41:35 2020
+++ src/usr.bin/make/arch.c	Fri Sep 25 14:49:51 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: arch.c,v 1.120 2020/09/25 14:41:35 rillig Exp $	*/
+/*	$NetBSD: arch.c,v 1.121 2020/09/25 14:49:51 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -133,7 +133,7 @@
 #include"config.h"
 
 /*	"@(#)arch.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: arch.c,v 1.120 2020/09/25 14:41:35 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.121 2020/09/25 14:49:51 rillig Exp $");
 
 #ifdef TARGET_MACHINE
 #undef MAKE_MACHINE
@@ -437,14 +437,6 @@ Arch_ParseArchive(char **linePtr, GNodeL
 return TRUE;
 }
 
-/* See if the given archive is the one we are looking for.
- * Called via Lst_Find. */
-static Boolean
-ArchFindArchive(const void *ar, const void *desiredName)
-{
-return strcmp(((const Arch *)ar)->name, desiredName) == 0;
-}
-
 /*-
  *---
  * ArchStatMember --
@@ -490,7 +482,12 @@ ArchStatMember(const char *archive, cons
 	member = base + 1;
 }
 
-ln = Lst_Find(archives, ArchFindArchive, archive);
+for (ln = archives->first; ln != NULL; ln = ln->next) {
+	const Arch *archPtr = ln->datum;
+	if (strcmp(archPtr->name, archive) == 0)
+	break;
+}
+
 if (ln != NULL) {
 	ar = LstNode_Datum(ln);
 



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 14:49:51 UTC 2020

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

Log Message:
make(1): inline ArchFindArchive into ArchStatMember

This avoids a few void pointers and unnecessary function calls.


To generate a diff of this commit:
cvs rdiff -u -r1.120 -r1.121 src/usr.bin/make/arch.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

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 14:41:35 UTC 2020

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

Log Message:
make(1): make code in ArchSVR4Entry simpler


To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/usr.bin/make/arch.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/arch.c
diff -u src/usr.bin/make/arch.c:1.119 src/usr.bin/make/arch.c:1.120
--- src/usr.bin/make/arch.c:1.119	Fri Sep 25 06:49:13 2020
+++ src/usr.bin/make/arch.c	Fri Sep 25 14:41:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: arch.c,v 1.119 2020/09/25 06:49:13 rillig Exp $	*/
+/*	$NetBSD: arch.c,v 1.120 2020/09/25 14:41:35 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -133,7 +133,7 @@
 #include"config.h"
 
 /*	"@(#)arch.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: arch.c,v 1.119 2020/09/25 06:49:13 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.120 2020/09/25 14:41:35 rillig Exp $");
 
 #ifdef TARGET_MACHINE
 #undef MAKE_MACHINE
@@ -714,17 +714,9 @@ ArchSVR4Entry(Arch *ar, char *name, size
 	}
 	eptr = ar->fnametab + size;
 	for (entry = 0, ptr = ar->fnametab; ptr < eptr; ptr++)
-	switch (*ptr) {
-	case '/':
+	if (*ptr == '/') {
 		entry++;
 		*ptr = '\0';
-		break;
-
-	case '\n':
-		break;
-
-	default:
-		break;
 	}
 	if (DEBUG(ARCH)) {
 	fprintf(debug_file, "Found svr4 archive name table with %lu entries\n",



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 14:41:35 UTC 2020

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

Log Message:
make(1): make code in ArchSVR4Entry simpler


To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/usr.bin/make/arch.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

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 14:10:10 UTC 2020

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

Log Message:
make(1): fix type of local variable in ParseModifierPart

Thanks, Clang-Tidy.


To generate a diff of this commit:
cvs rdiff -u -r1.539 -r1.540 src/usr.bin/make/var.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

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 14:10:10 UTC 2020

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

Log Message:
make(1): fix type of local variable in ParseModifierPart

Thanks, Clang-Tidy.


To generate a diff of this commit:
cvs rdiff -u -r1.539 -r1.540 src/usr.bin/make/var.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/var.c
diff -u src/usr.bin/make/var.c:1.539 src/usr.bin/make/var.c:1.540
--- src/usr.bin/make/var.c:1.539	Fri Sep 25 14:07:12 2020
+++ src/usr.bin/make/var.c	Fri Sep 25 14:10:09 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.539 2020/09/25 14:07:12 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.540 2020/09/25 14:10:09 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -121,7 +121,7 @@
 #include"metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.539 2020/09/25 14:07:12 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.540 2020/09/25 14:10:09 rillig Exp $");
 
 #define VAR_DEBUG_IF(cond, fmt, ...)	\
 if (!(DEBUG(VAR) && (cond)))	\
@@ -1920,7 +1920,7 @@ ParseModifierPart(
 	 * and suck it in without further ado.
 	 * It will be interpreted later.
 	 */
-	int have = p[1];
+	char have = p[1];
 	int want = have == '(' ? ')' : '}';
 	int depth = 1;
 



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 14:07:12 UTC 2020

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

Log Message:
make(1): fix type of local variable in ApplyModifiers

Thanks, Clang-Tidy.


To generate a diff of this commit:
cvs rdiff -u -r1.538 -r1.539 src/usr.bin/make/var.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

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 14:07:12 UTC 2020

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

Log Message:
make(1): fix type of local variable in ApplyModifiers

Thanks, Clang-Tidy.


To generate a diff of this commit:
cvs rdiff -u -r1.538 -r1.539 src/usr.bin/make/var.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/var.c
diff -u src/usr.bin/make/var.c:1.538 src/usr.bin/make/var.c:1.539
--- src/usr.bin/make/var.c:1.538	Fri Sep 25 06:06:15 2020
+++ src/usr.bin/make/var.c	Fri Sep 25 14:07:12 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.538 2020/09/25 06:06:15 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.539 2020/09/25 14:07:12 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -121,7 +121,7 @@
 #include"metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.538 2020/09/25 06:06:15 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.539 2020/09/25 14:07:12 rillig Exp $");
 
 #define VAR_DEBUG_IF(cond, fmt, ...)	\
 if (!(DEBUG(VAR) && (cond)))	\
@@ -3012,7 +3012,7 @@ ApplyModifiers(
 	const char *nested_p = p;
 	void *freeIt;
 	const char *rval;
-	int c;
+	char c;
 
 	(void)Var_Parse(_p, st.ctxt, st.eflags, , );
 	/* TODO: handle errors */



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 14:00:17 UTC 2020

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

Log Message:
make(1): inline Lst_ForEach in MakeUnmark

By the way, the additional argument to Lst_ForEach was not used at all.


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

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

Modified files:

Index: src/usr.bin/make/make.c
diff -u src/usr.bin/make/make.c:1.143 src/usr.bin/make/make.c:1.144
--- src/usr.bin/make/make.c:1.143	Thu Sep 24 07:37:42 2020
+++ src/usr.bin/make/make.c	Fri Sep 25 14:00:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.c,v 1.143 2020/09/24 07:37:42 rillig Exp $	*/
+/*	$NetBSD: make.c,v 1.144 2020/09/25 14:00:17 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -107,7 +107,7 @@
 #include"job.h"
 
 /*	"@(#)make.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: make.c,v 1.143 2020/09/24 07:37:42 rillig Exp $");
+MAKE_RCSID("$NetBSD: make.c,v 1.144 2020/09/25 14:00:17 rillig Exp $");
 
 static unsigned int checked = 1;/* Sequence # to detect recursion */
 static GNodeList *toBeMade;	/* The current fringe of the graph. These
@@ -836,11 +836,14 @@ Make_Update(GNode *cgn)
 }
 
 static void
-MakeUnmark(void *cgnp, void *pgnp MAKE_ATTR_UNUSED)
+UnmarkChildren(GNode *gn)
 {
-GNode	*cgn = (GNode *)cgnp;
+GNodeListNode *ln;
 
-cgn->type &= ~OP_MARK;
+for (ln = gn->children->first; ln != NULL; ln = ln->next) {
+	GNode *child = ln->datum;
+	child->type &= ~OP_MARK;
+}
 }
 
 /*-
@@ -950,7 +953,7 @@ Make_DoAllVar(GNode *gn)
 if (gn->flags & DONE_ALLSRC)
 	return;
 
-Lst_ForEach(gn->children, MakeUnmark, gn);
+UnmarkChildren(gn);
 Lst_ForEach(gn->children, MakeAddAllSrc, gn);
 
 if (!Var_Exists (OODATE, gn)) {
@@ -1145,9 +1148,6 @@ MakeStartJobs(void)
  *
  * Input:
  *	gnp		Node to examine
- *	cyclep		True if gn->unmade being non-zero implies a
- *			cycle in the graph, not an error in an
- *			inferior.
  *
  * Results:
  *	Always returns 0.
@@ -1315,7 +1315,7 @@ Make_ExpandUse(GNodeList *targs)
 
 	(void)Dir_MTime(gn, 0);
 	Var_Set(TARGET, gn->path ? gn->path : gn->name, gn);
-	Lst_ForEach(gn->children, MakeUnmark, gn);
+	UnmarkChildren(gn);
 	Lst_ForEachUntil(gn->children, MakeHandleUse, gn);
 
 	if ((gn->type & OP_MADE) == 0)



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 14:00:17 UTC 2020

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

Log Message:
make(1): inline Lst_ForEach in MakeUnmark

By the way, the additional argument to Lst_ForEach was not used at all.


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

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



CVS commit: src/sys/dev/scsipi

2020-09-25 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Fri Sep 25 13:08:00 UTC 2020

Modified Files:
src/sys/dev/scsipi: sd.c

Log Message:
spelling fixes in sd.c comments


To generate a diff of this commit:
cvs rdiff -u -r1.329 -r1.330 src/sys/dev/scsipi/sd.c

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



CVS commit: src/sys/dev/scsipi

2020-09-25 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Fri Sep 25 13:08:00 UTC 2020

Modified Files:
src/sys/dev/scsipi: sd.c

Log Message:
spelling fixes in sd.c comments


To generate a diff of this commit:
cvs rdiff -u -r1.329 -r1.330 src/sys/dev/scsipi/sd.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/scsipi/sd.c
diff -u src/sys/dev/scsipi/sd.c:1.329 src/sys/dev/scsipi/sd.c:1.330
--- src/sys/dev/scsipi/sd.c:1.329	Mon Apr 13 08:05:02 2020
+++ src/sys/dev/scsipi/sd.c	Fri Sep 25 13:08:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: sd.c,v 1.329 2020/04/13 08:05:02 maxv Exp $	*/
+/*	$NetBSD: sd.c,v 1.330 2020/09/25 13:08:00 jakllsch Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2003, 2004 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.329 2020/04/13 08:05:02 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.330 2020/09/25 13:08:00 jakllsch Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_scsi.h"
@@ -444,7 +444,7 @@ sd_firstopen(device_t self, dev_t dev, i
 
 	/*
 	 * Start the pack spinning if necessary. Always allow the
-	 * raw parition to be opened, for raw IOCTLs. Data transfers
+	 * raw partition to be opened, for raw IOCTLs. Data transfers
 	 * will check for SDEV_MEDIA_LOADED.
 	 */
 	if (error == EIO) {
@@ -588,7 +588,7 @@ sd_lastclose(device_t self)
 }
 
 /*
- * close the device.. only called if we are the LAST occurence of an open
+ * close the device.. only called if we are the LAST occurrence of an open
  * device.  Convenient now but usually a pain.
  */
 static int
@@ -642,7 +642,7 @@ sdstrategy(struct buf *bp)
 /*
  * Issue single I/O command
  *
- * Called from dk_start and implicitely from dk_strategy
+ * Called from dk_start and implicitly from dk_strategy
  */
 static int
 sd_diskstart(device_t dev, struct buf *bp)
@@ -871,7 +871,7 @@ sdminphys(struct buf *bp)
 	 *
 	 * XXX Note that the SCSI-I spec says that 256-block transfers
 	 * are allowed in a 6-byte read/write, and are specified
-	 * by settng the "length" to 0.  However, we're conservative
+	 * by setting the "length" to 0.  However, we're conservative
 	 * here, allowing only 255-block transfers in case an
 	 * ancient device gets confused by length == 0.  A length of 0
 	 * in a 10-byte read/write actually means 0 blocks.



CVS commit: src/external/bsd/blocklist/diff

2020-09-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Sep 25 12:52:59 UTC 2020

Modified Files:
src/external/bsd/blocklist/diff: postfix.diff

Log Message:
Add one more place to notify blocklistd


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/bsd/blocklist/diff/postfix.diff

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



CVS commit: src/external/bsd/blocklist/diff

2020-09-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Sep 25 12:52:59 UTC 2020

Modified Files:
src/external/bsd/blocklist/diff: postfix.diff

Log Message:
Add one more place to notify blocklistd


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/bsd/blocklist/diff/postfix.diff

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

Modified files:

Index: src/external/bsd/blocklist/diff/postfix.diff
diff -u src/external/bsd/blocklist/diff/postfix.diff:1.2 src/external/bsd/blocklist/diff/postfix.diff:1.3
--- src/external/bsd/blocklist/diff/postfix.diff:1.2	Sun Jun 14 22:29:45 2020
+++ src/external/bsd/blocklist/diff/postfix.diff	Fri Sep 25 08:52:59 2020
@@ -80,3 +80,19 @@ diff -u -r1.6 Makefile
  DPADD+=	${LIBPTLS} ${LIBSSL} ${LIBCRYPTO}
  LDADD+=	${LIBPTLS} -lssl -lcrypto
  
+Index: dist/src/smtpd/smtpd.c
+===
+RCS file: /cvsroot/src/external/ibm-public/postfix/dist/src/smtpd/smtpd.c,v
+retrieving revision 1.17
+diff -u -u -r1.17 smtpd.c
+--- dist/src/smtpd/smtpd.c	18 Mar 2020 19:05:20 -	1.17
 dist/src/smtpd/smtpd.c	25 Sep 2020 12:51:52 -
+@@ -5795,6 +5795,8 @@
+ 		   || strcmp(state->reason, REASON_LOST_CONNECTION)) {
+ 	msg_info("%s after %s from %s",
+ 		 state->reason, state->where, state->namaddr);
++	if (strcmp(state->where, SMTPD_CMD_AUTH) == 0)
++		pfilter_notify(1, vstream_fileno(state->client));
+ 	}
+ }
+ 



CVS commit: src/external/ibm-public/postfix/dist/src/smtpd

2020-09-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Sep 25 12:52:13 UTC 2020

Modified Files:
src/external/ibm-public/postfix/dist/src/smtpd: smtpd.c

Log Message:
Notify blacklistd about smtp auth failures (Jeff Rizzo)


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 \
src/external/ibm-public/postfix/dist/src/smtpd/smtpd.c

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



CVS commit: src/external/ibm-public/postfix/dist/src/smtpd

2020-09-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Sep 25 12:52:13 UTC 2020

Modified Files:
src/external/ibm-public/postfix/dist/src/smtpd: smtpd.c

Log Message:
Notify blacklistd about smtp auth failures (Jeff Rizzo)


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 \
src/external/ibm-public/postfix/dist/src/smtpd/smtpd.c

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

Modified files:

Index: src/external/ibm-public/postfix/dist/src/smtpd/smtpd.c
diff -u src/external/ibm-public/postfix/dist/src/smtpd/smtpd.c:1.17 src/external/ibm-public/postfix/dist/src/smtpd/smtpd.c:1.18
--- src/external/ibm-public/postfix/dist/src/smtpd/smtpd.c:1.17	Wed Mar 18 15:05:20 2020
+++ src/external/ibm-public/postfix/dist/src/smtpd/smtpd.c	Fri Sep 25 08:52:12 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: smtpd.c,v 1.17 2020/03/18 19:05:20 christos Exp $	*/
+/*	$NetBSD: smtpd.c,v 1.18 2020/09/25 12:52:12 christos Exp $	*/
 
 /*++
 /* NAME
@@ -5795,6 +5795,8 @@ static void smtpd_proto(SMTPD_STATE *sta
 		   || strcmp(state->reason, REASON_LOST_CONNECTION)) {
 	msg_info("%s after %s from %s",
 		 state->reason, state->where, state->namaddr);
+	if (strcmp(state->where, SMTPD_CMD_AUTH) == 0)
+		pfilter_notify(1, vstream_fileno(state->client));
 	}
 }
 



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 06:49:13 UTC 2020

Modified Files:
src/usr.bin/make: arch.c dir.c

Log Message:
make(1): replace a few calls to Lst_Open with simple loops

This avoids relying on the internal iterator of the list, which is
supposed to be removed in the near future.


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/usr.bin/make/arch.c
cvs rdiff -u -r1.146 -r1.147 src/usr.bin/make/dir.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/arch.c
diff -u src/usr.bin/make/arch.c:1.118 src/usr.bin/make/arch.c:1.119
--- src/usr.bin/make/arch.c:1.118	Tue Sep 22 20:19:46 2020
+++ src/usr.bin/make/arch.c	Fri Sep 25 06:49:13 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: arch.c,v 1.118 2020/09/22 20:19:46 rillig Exp $	*/
+/*	$NetBSD: arch.c,v 1.119 2020/09/25 06:49:13 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -133,7 +133,7 @@
 #include"config.h"
 
 /*	"@(#)arch.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: arch.c,v 1.118 2020/09/22 20:19:46 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.119 2020/09/25 06:49:13 rillig Exp $");
 
 #ifdef TARGET_MACHINE
 #undef MAKE_MACHINE
@@ -1026,11 +1026,9 @@ time_t
 Arch_MemMTime(GNode *gn)
 {
 GNodeListNode *ln;
-GNode   	  *pgn;
 
-Lst_Open(gn->parents);
-while ((ln = Lst_Next(gn->parents)) != NULL) {
-	pgn = LstNode_Datum(ln);
+for (ln = gn->parents->first; ln != NULL; ln = ln->next) {
+	GNode *pgn = ln->datum;
 
 	if (pgn->type & OP_ARCHV) {
 	/*
@@ -1058,8 +1056,6 @@ Arch_MemMTime(GNode *gn)
 	}
 }
 
-Lst_Close(gn->parents);
-
 return gn->mtime;
 }
 

Index: src/usr.bin/make/dir.c
diff -u src/usr.bin/make/dir.c:1.146 src/usr.bin/make/dir.c:1.147
--- src/usr.bin/make/dir.c:1.146	Thu Sep 24 07:49:58 2020
+++ src/usr.bin/make/dir.c	Fri Sep 25 06:49:13 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.146 2020/09/24 07:49:58 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.147 2020/09/25 06:49:13 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -134,7 +134,7 @@
 #include "job.h"
 
 /*	"@(#)dir.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: dir.c,v 1.146 2020/09/24 07:49:58 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.147 2020/09/25 06:49:13 rillig Exp $");
 
 #define DIR_DEBUG0(fmt) \
 if (!DEBUG(DIR)) (void) 0; else fprintf(debug_file, fmt)
@@ -747,21 +747,18 @@ static void
 DirExpandInt(const char *word, SearchPath *path, StringList *expansions)
 {
 SearchPathNode *ln;
-
-Lst_Open(path);
-while ((ln = Lst_Next(path)) != NULL) {
-	CachedDir *dir = LstNode_Datum(ln);
+for (ln = path->first; ln != NULL; ln = ln->next) {
+	CachedDir *dir = ln->datum;
 	DirMatchFiles(word, dir, expansions);
 }
-Lst_Close(path);
 }
 
 static void
 DirPrintExpansions(StringList *words)
 {
-StringListNode *node;
-for (node = Lst_First(words); node != NULL; node = LstNode_Next(node)) {
-	const char *word = LstNode_Datum(node);
+StringListNode *ln;
+for (ln = words->first; ln != NULL; ln = ln->next) {
+	const char *word = ln->datum;
 	fprintf(debug_file, "%s ", word);
 }
 fprintf(debug_file, "\n");
@@ -1611,14 +1608,12 @@ Dir_MakeFlags(const char *flag, SearchPa
 Buf_Init(, 0);
 
 if (path != NULL) {
-	Lst_Open(path);
-	while ((ln = Lst_Next(path)) != NULL) {
-	CachedDir *dir = LstNode_Datum(ln);
+	for (ln = path->first; ln != NULL; ln = ln->next) {
+	CachedDir *dir = ln->datum;
 	Buf_AddStr(, " ");
 	Buf_AddStr(, flag);
 	Buf_AddStr(, dir->name);
 	}
-	Lst_Close(path);
 }
 
 return Buf_Destroy(, FALSE);
@@ -1740,13 +1735,11 @@ Dir_PrintDirectories(void)
 	percentage(hits, hits + bigmisses + nearmisses));
 fprintf(debug_file, "# %-20s referenced\thits\n", "directory");
 
-Lst_Open(openDirectories);
-while ((ln = Lst_Next(openDirectories)) != NULL) {
-	CachedDir *dir = LstNode_Datum(ln);
+for (ln = openDirectories->first; ln != NULL; ln = ln->next) {
+	CachedDir *dir = ln->datum;
 	fprintf(debug_file, "# %-20s %10d\t%4d\n", dir->name, dir->refCount,
 		dir->hits);
 }
-Lst_Close(openDirectories);
 }
 
 void



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 06:49:13 UTC 2020

Modified Files:
src/usr.bin/make: arch.c dir.c

Log Message:
make(1): replace a few calls to Lst_Open with simple loops

This avoids relying on the internal iterator of the list, which is
supposed to be removed in the near future.


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/usr.bin/make/arch.c
cvs rdiff -u -r1.146 -r1.147 src/usr.bin/make/dir.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/evbarm/fdt

2020-09-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Sep 25 06:47:24 UTC 2020

Modified Files:
src/sys/arch/evbarm/fdt: fdt_machdep.c

Log Message:
Add a newline


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/arch/evbarm/fdt/fdt_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/evbarm/fdt

2020-09-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Sep 25 06:47:24 UTC 2020

Modified Files:
src/sys/arch/evbarm/fdt: fdt_machdep.c

Log Message:
Add a newline


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/arch/evbarm/fdt/fdt_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/evbarm/fdt/fdt_machdep.c
diff -u src/sys/arch/evbarm/fdt/fdt_machdep.c:1.73 src/sys/arch/evbarm/fdt/fdt_machdep.c:1.74
--- src/sys/arch/evbarm/fdt/fdt_machdep.c:1.73	Sat Jun 27 18:44:02 2020
+++ src/sys/arch/evbarm/fdt/fdt_machdep.c	Fri Sep 25 06:47:24 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_machdep.c,v 1.73 2020/06/27 18:44:02 jmcneill Exp $ */
+/* $NetBSD: fdt_machdep.c,v 1.74 2020/09/25 06:47:24 skrll Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.73 2020/06/27 18:44:02 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.74 2020/09/25 06:47:24 skrll Exp $");
 
 #include "opt_machdep.h"
 #include "opt_bootconfig.h"
@@ -657,6 +657,7 @@ initarm(void *arg)
 
 	if (error)
 		return sp;
+
 	/*
 	 * Now we have APs started the pages used for stacks and L1PT can
 	 * be given to uvm



CVS commit: src/sys/net

2020-09-25 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Fri Sep 25 06:22:33 UTC 2020

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

Log Message:
Add a function to copy AC-Name and Service-Name


To generate a diff of this commit:
cvs rdiff -u -r1.152 -r1.153 src/sys/net/if_pppoe.c

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



CVS commit: src/sys/net

2020-09-25 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Fri Sep 25 06:22:33 UTC 2020

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

Log Message:
Add a function to copy AC-Name and Service-Name


To generate a diff of this commit:
cvs rdiff -u -r1.152 -r1.153 src/sys/net/if_pppoe.c

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

Modified files:

Index: src/sys/net/if_pppoe.c
diff -u src/sys/net/if_pppoe.c:1.152 src/sys/net/if_pppoe.c:1.153
--- src/sys/net/if_pppoe.c:1.152	Fri Sep 25 06:12:33 2020
+++ src/sys/net/if_pppoe.c	Fri Sep 25 06:22:33 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: if_pppoe.c,v 1.152 2020/09/25 06:12:33 yamaguchi Exp $ */
+/* $NetBSD: if_pppoe.c,v 1.153 2020/09/25 06:22:33 yamaguchi Exp $ */
 
 /*
  * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.152 2020/09/25 06:12:33 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.153 2020/09/25 06:22:33 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "pppoe.h"
@@ -1192,6 +1192,52 @@ pppoe_output(struct pppoe_softc *sc, str
 }
 
 static int
+pppoe_parm_cpyinstr(struct pppoe_softc *sc,
+char **dst, const void *src, size_t len)
+{
+	int error = 0;
+	char *next = NULL;
+	size_t bufsiz, cpysiz, strsiz;
+
+	bufsiz = len + 1;
+
+	if (src == NULL)
+		goto out;
+
+	bufsiz = len + 1;
+	next = malloc(bufsiz, M_DEVBUF, M_WAITOK);
+	if (next == NULL)
+		return ENOMEM;
+
+	error = copyinstr(src, next, bufsiz, );
+	if (error != 0)
+		goto fail;
+	if (cpysiz != bufsiz) {
+		error = EINVAL;
+		goto fail;
+	}
+
+	strsiz = strnlen(next, bufsiz);
+	if (strsiz == bufsiz) {
+		error = EINVAL;
+		goto fail;
+	}
+
+out:
+	PPPOE_LOCK(sc, RW_WRITER);
+	if (*dst != NULL)
+		free(*dst, M_DEVBUF);
+	*dst = next;
+	next = NULL;
+	PPPOE_UNLOCK(sc);
+fail:
+	if (next != NULL)
+		free(next, M_DEVBUF);
+
+	return error;
+}
+
+static int
 pppoe_ioctl(struct ifnet *ifp, unsigned long cmd, void *data)
 {
 	struct lwp *l = curlwp;	/* XXX */
@@ -1226,60 +1272,16 @@ pppoe_ioctl(struct ifnet *ifp, unsigned 
 			sc->sc_eth_if = eth_if;
 			PPPOE_UNLOCK(sc);
 		}
-		if (parms->ac_name != NULL) {
-			size_t s;
-			char *b = malloc(parms->ac_name_len + 1, M_DEVBUF,
-			M_WAITOK);
-			if (b == NULL)
-return ENOMEM;
-			error = copyinstr(parms->ac_name, b,
-			parms->ac_name_len+1, );
-			if (error != 0) {
-free(b, M_DEVBUF);
-return error;
-			}
-			if (s != parms->ac_name_len+1) {
-free(b, M_DEVBUF);
-return EINVAL;
-			}
 
-			PPPOE_LOCK(sc, RW_WRITER);
-			if (sc->sc_concentrator_name)
-free(sc->sc_concentrator_name, M_DEVBUF);
-			sc->sc_concentrator_name = b;
-			PPPOE_UNLOCK(sc);
-		} else {
-			if (sc->sc_concentrator_name)
-free(sc->sc_concentrator_name, M_DEVBUF);
-			sc->sc_concentrator_name = NULL;
-		}
-		if (parms->service_name != NULL) {
-			size_t s;
-			char *b = malloc(parms->service_name_len + 1, M_DEVBUF,
-			M_WAITOK);
-			if (b == NULL)
-return ENOMEM;
-			error = copyinstr(parms->service_name, b,
-			parms->service_name_len+1, );
-			if (error != 0) {
-free(b, M_DEVBUF);
-return error;
-			}
-			if (s != parms->service_name_len+1) {
-free(b, M_DEVBUF);
-return EINVAL;
-			}
-
-			PPPOE_LOCK(sc, RW_WRITER);
-			if (sc->sc_service_name)
-free(sc->sc_service_name, M_DEVBUF);
-			sc->sc_service_name = b;
-			PPPOE_UNLOCK(sc);
-		} else {
-			if (sc->sc_service_name)
-free(sc->sc_service_name, M_DEVBUF);
-			sc->sc_service_name = NULL;
-		}
+		error = pppoe_parm_cpyinstr(sc, >sc_concentrator_name,
+		parms->ac_name, parms->ac_name_len);
+		if (error != 0)
+			return error;
+
+		error = pppoe_parm_cpyinstr(sc, >sc_service_name,
+		parms->service_name, parms->service_name_len);
+		if (error != 0)
+			return error;
 		return 0;
 	}
 	break;



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 06:20:45 UTC 2020

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

Log Message:
make(1): document details on why JobRun runs .END in compat mode


To generate a diff of this commit:
cvs rdiff -u -r1.237 -r1.238 src/usr.bin/make/job.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/job.c
diff -u src/usr.bin/make/job.c:1.237 src/usr.bin/make/job.c:1.238
--- src/usr.bin/make/job.c:1.237	Thu Sep 24 07:11:29 2020
+++ src/usr.bin/make/job.c	Fri Sep 25 06:20:44 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.237 2020/09/24 07:11:29 rillig Exp $	*/
+/*	$NetBSD: job.c,v 1.238 2020/09/25 06:20:44 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -140,7 +140,7 @@
 #include "trace.h"
 
 /*	"@(#)job.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: job.c,v 1.237 2020/09/24 07:11:29 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.238 2020/09/25 06:20:44 rillig Exp $");
 
 # define STATIC static
 
@@ -1907,13 +1907,16 @@ end_loop:
 static void
 JobRun(GNode *targ)
 {
-#ifdef notyet
+#if 0
 /*
- * Unfortunately it is too complicated to run .BEGIN, .END,
- * and .INTERRUPT job in the parallel job module. This has
- * the nice side effect that it avoids a lot of other problems.
+ * Unfortunately it is too complicated to run .BEGIN, .END, and
+ * .INTERRUPT job in the parallel job module.  As of 2020-09-25,
+ * unit-tests/deptgt-end-jobs.mk hangs in an endless loop.
+ *
+ * Running these jobs in compat mode also guarantees that these
+ * jobs do not overlap with other unrelated jobs.
  */
-Lst lst = Lst_Init();
+List *lst = Lst_Init();
 Lst_Append(lst, targ);
 (void)Make_Run(lst);
 Lst_Destroy(lst, NULL);



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 06:20:45 UTC 2020

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

Log Message:
make(1): document details on why JobRun runs .END in compat mode


To generate a diff of this commit:
cvs rdiff -u -r1.237 -r1.238 src/usr.bin/make/job.c

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



CVS commit: src/tests/net/if_pppoe

2020-09-25 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Fri Sep 25 06:15:30 UTC 2020

Modified Files:
src/tests/net/if_pppoe: t_pppoe.sh

Log Message:
update test cases for AC-Name and Service-Name


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/tests/net/if_pppoe/t_pppoe.sh

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

Modified files:

Index: src/tests/net/if_pppoe/t_pppoe.sh
diff -u src/tests/net/if_pppoe/t_pppoe.sh:1.22 src/tests/net/if_pppoe/t_pppoe.sh:1.23
--- src/tests/net/if_pppoe/t_pppoe.sh:1.22	Fri Sep 25 06:07:31 2020
+++ src/tests/net/if_pppoe/t_pppoe.sh	Fri Sep 25 06:15:30 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: t_pppoe.sh,v 1.22 2020/09/25 06:07:31 yamaguchi Exp $
+#	$NetBSD: t_pppoe.sh,v 1.23 2020/09/25 06:15:30 yamaguchi Exp $
 #
 # Copyright (c) 2016 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -556,7 +556,7 @@ pppoe_params_body()
 	atf_check -s exit:0 rump.ifconfig pppoe0 down
 	wait_for_disconnected
 	atf_check -s exit:0 -x "$HIJACKING pppoectl -a ACNAME-TEST2 -e shmif0 pppoe0"
-	atf_check -s exit:0 -x "$HIJACKING pppoectl -a \"\" -e shmif0 pppoe0"
+	atf_check -s exit:0 -x "$HIJACKING pppoectl -e shmif0 pppoe0"
 	atf_check -s exit:0 rump.ifconfig pppoe0 up
 	$DEBUG && rump.ifconfig
 	wait_for_session_established
@@ -567,6 +567,19 @@ pppoe_params_body()
 	-x "${dumpcmd} | grep PADI"
 	atf_check -s exit:0 -o match:'\[Service-Name\]' -e ignore \
 	-x "${dumpcmd} | grep PADR"
+	atf_check -s exit:0 -o not-match:'AC-Name' -e ignore \
+	-x "${dumpcmd} | grep PADI"
+
+	# store 0 length string in AC-NAME
+	export RUMP_SERVER=$CLIENT
+	atf_check -s exit:0 rump.ifconfig pppoe0 down
+	wait_for_disconnected
+	atf_check -s exit:0 -x "$HIJACKING pppoectl -a \"\" -e shmif0 pppoe0"
+	atf_check -s exit:0 rump.ifconfig pppoe0 up
+	$DEBUG && rump.ifconfig
+	wait_for_session_established
+	unset RUMP_SERVER
+
 	atf_check -s exit:0 -o match:'\[AC-Name\]' -e ignore \
 	-x "${dumpcmd} | grep PADI"
 
@@ -629,7 +642,7 @@ pppoe_params_body()
 	atf_check -s exit:0 rump.ifconfig pppoe0 down
 	wait_for_disconnected
 	atf_check -s exit:0 -x "$HIJACKING pppoectl -s SNAME-TEST2 -e shmif0 pppoe0"
-	atf_check -s exit:0 -x "$HIJACKING pppoectl -s \"\" -e shmif0 pppoe0"
+	atf_check -s exit:0 -x "$HIJACKING pppoectl -e shmif0 pppoe0"
 	atf_check -s exit:0 rump.ifconfig pppoe0 up
 	$DEBUG && rump.ifconfig
 	wait_for_session_established
@@ -685,10 +698,10 @@ pppoe_params_body()
 
 	$DEBUG && dump_bus
 	atf_check -s exit:0 \
-	-o match:'\[Service-Name "SNAME-TEST3"\] \[AC-Name "ACNAME-TEST4"\]' \
+	-o match:'\[Service-Name\] \[AC-Name "ACNAME-TEST4"\]' \
 	-e ignore \
 	-x "${dumpcmd} | grep PADI"
-	atf_check -s exit:0 -o match:'\[Service-Name "SNAME-TEST3"\]' -e ignore \
+	atf_check -s exit:0 -o match:'\[Service-Name\]' -e ignore \
 	-x "${dumpcmd} | grep PADR"
 
 	# change Service-Name
@@ -696,7 +709,9 @@ pppoe_params_body()
 	atf_check -s exit:0 rump.ifconfig pppoe0 down
 	wait_for_disconnected
 	atf_check -s exit:0 -x \
-	"$HIJACKING pppoectl -e shmif0 -s SNAME-TEST4 pppoe0"
+	"$HIJACKING pppoectl -e shmif0 -a ACNAME-TEST5 -s SNAME-TEST5 pppoe0"
+	atf_check -s exit:0 -x \
+	"$HIJACKING pppoectl -e shmif0 -s SNAME-TEST6 pppoe0"
 	atf_check -s exit:0 rump.ifconfig pppoe0 up
 	$DEBUG && rump.ifconfig
 	wait_for_session_established
@@ -704,11 +719,13 @@ pppoe_params_body()
 
 	$DEBUG && dump_bus
 	atf_check -s exit:0 \
-	-o match:'\[Service-Name "SNAME-TEST4"\] \[AC-Name "ACNAME-TEST4"\]' \
+	-o match:'\[Service-Name "SNAME-TEST6"\]' \
 	-e ignore \
 	-x "${dumpcmd} | grep PADI"
-	atf_check -s exit:0 -o match:'\[Service-Name "SNAME-TEST3"\]' -e ignore \
+	atf_check -s exit:0 -o match:'\[Service-Name "SNAME-TEST6"\]' -e ignore \
 	-x "${dumpcmd} | grep PADR"
+	atf_check -s exit:0 -o not-match:'\[AC-Name "ACNAME-TEST5\]"' -e ignore \
+	-x "${dumpcmd} | grep PADI"
 }
 
 pppoe_params_cleanup()



CVS commit: src/tests/net/if_pppoe

2020-09-25 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Fri Sep 25 06:15:30 UTC 2020

Modified Files:
src/tests/net/if_pppoe: t_pppoe.sh

Log Message:
update test cases for AC-Name and Service-Name


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/tests/net/if_pppoe/t_pppoe.sh

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



CVS commit: src/sys/net

2020-09-25 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Fri Sep 25 06:12:33 UTC 2020

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

Log Message:
Clear AC-Name and Service-Name if params are not specified


To generate a diff of this commit:
cvs rdiff -u -r1.151 -r1.152 src/sys/net/if_pppoe.c

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

Modified files:

Index: src/sys/net/if_pppoe.c
diff -u src/sys/net/if_pppoe.c:1.151 src/sys/net/if_pppoe.c:1.152
--- src/sys/net/if_pppoe.c:1.151	Fri Sep 18 09:53:50 2020
+++ src/sys/net/if_pppoe.c	Fri Sep 25 06:12:33 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: if_pppoe.c,v 1.151 2020/09/18 09:53:50 yamaguchi Exp $ */
+/* $NetBSD: if_pppoe.c,v 1.152 2020/09/25 06:12:33 yamaguchi Exp $ */
 
 /*
  * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.151 2020/09/18 09:53:50 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.152 2020/09/25 06:12:33 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "pppoe.h"
@@ -1248,6 +1248,10 @@ pppoe_ioctl(struct ifnet *ifp, unsigned 
 free(sc->sc_concentrator_name, M_DEVBUF);
 			sc->sc_concentrator_name = b;
 			PPPOE_UNLOCK(sc);
+		} else {
+			if (sc->sc_concentrator_name)
+free(sc->sc_concentrator_name, M_DEVBUF);
+			sc->sc_concentrator_name = NULL;
 		}
 		if (parms->service_name != NULL) {
 			size_t s;
@@ -1271,6 +1275,10 @@ pppoe_ioctl(struct ifnet *ifp, unsigned 
 free(sc->sc_service_name, M_DEVBUF);
 			sc->sc_service_name = b;
 			PPPOE_UNLOCK(sc);
+		} else {
+			if (sc->sc_service_name)
+free(sc->sc_service_name, M_DEVBUF);
+			sc->sc_service_name = NULL;
 		}
 		return 0;
 	}



CVS commit: src/sys/net

2020-09-25 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Fri Sep 25 06:12:33 UTC 2020

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

Log Message:
Clear AC-Name and Service-Name if params are not specified


To generate a diff of this commit:
cvs rdiff -u -r1.151 -r1.152 src/sys/net/if_pppoe.c

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



CVS commit: src/tests/net/if_pppoe

2020-09-25 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Fri Sep 25 06:07:31 UTC 2020

Modified Files:
src/tests/net/if_pppoe: t_pppoe.sh

Log Message:
Add test cases for AC-Name and Service-Name


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/tests/net/if_pppoe/t_pppoe.sh

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

Modified files:

Index: src/tests/net/if_pppoe/t_pppoe.sh
diff -u src/tests/net/if_pppoe/t_pppoe.sh:1.21 src/tests/net/if_pppoe/t_pppoe.sh:1.22
--- src/tests/net/if_pppoe/t_pppoe.sh:1.21	Wed Sep 23 06:18:20 2020
+++ src/tests/net/if_pppoe/t_pppoe.sh	Fri Sep 25 06:07:31 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: t_pppoe.sh,v 1.21 2020/09/23 06:18:20 yamaguchi Exp $
+#	$NetBSD: t_pppoe.sh,v 1.22 2020/09/25 06:07:31 yamaguchi Exp $
 #
 # Copyright (c) 2016 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -62,41 +62,53 @@ pppoe_create_destroy_cleanup()
 	cleanup
 }
 
-setup()
+setup_ifaces()
 {
-	inet=true
-
-	if [ $# -ne 0 ]; then
-		eval $@
-	fi
-
-	rump_server_start $SERVER netinet6 pppoe
-	rump_server_start $CLIENT netinet6 pppoe
 
 	rump_server_add_iface $SERVER shmif0 $BUS
 	rump_server_add_iface $CLIENT shmif0 $BUS
+	rump_server_add_iface $SERVER pppoe0
+	rump_server_add_iface $CLIENT pppoe0
 
 	export RUMP_SERVER=$SERVER
 	atf_check -s exit:0 rump.ifconfig shmif0 up
-
-	rump_server_add_iface $SERVER pppoe0
 	$inet && atf_check -s exit:0 rump.ifconfig pppoe0 \
 	inet $SERVER_IP $CLIENT_IP down
 	atf_check -s exit:0 rump.ifconfig pppoe0 link0
 
 	$DEBUG && rump.ifconfig
 	$DEBUG && $HIJACKING pppoectl -d pppoe0
-
-	atf_check -s exit:0 -x "$HIJACKING pppoectl -e shmif0 pppoe0"
 	unset RUMP_SERVER
 
 	export RUMP_SERVER=$CLIENT
 	atf_check -s exit:0 rump.ifconfig shmif0 up
 
-	rump_server_add_iface $CLIENT pppoe0
 	$inet && atf_check -s exit:0 rump.ifconfig pppoe0 \
 	inet 0.0.0.0 0.0.0.1 down
 
+	$DEBUG && rump.ifconfig
+	$DEBUG && $HIJACKING pppoectl -d pppoe0
+	unset RUMP_SERVER
+}
+
+setup()
+{
+	inet=true
+
+	if [ $# -ne 0 ]; then
+		eval $@
+	fi
+
+	rump_server_start $SERVER netinet6 pppoe
+	rump_server_start $CLIENT netinet6 pppoe
+
+	setup_ifaces
+
+	export RUMP_SERVER=$SERVER
+	atf_check -s exit:0 -x "$HIJACKING pppoectl -e shmif0 pppoe0"
+	unset RUMP_SERVER
+
+	export RUMP_SERVER=$CLIENT
 	atf_check -s exit:0 -x "$HIJACKING pppoectl -e shmif0 pppoe0"
 	unset RUMP_SERVER
 }
@@ -426,10 +438,290 @@ pppoe6_chap_cleanup()
 	cleanup
 }
 
+atf_test_case pppoe_params cleanup
+
+dump_bus()
+{
+
+	shmif_dumpbus -p - ${BUS} | tcpdump -n -e -r -
+}
+
+setup_auth_conf()
+{
+	local auth=chap
+
+	export RUMP_SERVER=$SERVER
+	local setup_serverparam="pppoectl pppoe0 hisauthproto=$auth \
+'hisauthname=$AUTHNAME' \
+'hisauthsecret=$SECRET' \
+'myauthproto=none' \
+$server_optparam"
+
+	atf_check -s exit:0 rump.ifconfig pppoe0 link0
+	atf_check -s exit:0 -x "$HIJACKING $setup_serverparam"
+	unset RUMP_SERVER
+
+	local setup_clientparam="pppoectl pppoe0 myauthproto=$auth \
+'myauthname=$AUTHNAME' \
+'myauthsecret=$SECRET' \
+'hisauthproto=none'"
+
+	export RUMP_SERVER=$CLIENT
+	$inet && atf_check -s exit:0 rump.ifconfig pppoe0 \
+	inet 0.0.0.0 0.0.0.1 down
+	atf_check -s exit:0 -x "$HIJACKING $setup_clientparam"
+	$DEBUG && rump.ifconfig
+	unset RUMP_SERVER
+}
+
+pppoe_params_head()
+{
+	atf_set "descr" "Set and clear access concentrator name and service name"
+	atf_set "require.progs" "rump_server pppoectl"
+}
+
+pppoe_params_body()
+{
+	local dumpcmd
+
+	dumpcmd="shmif_dumpbus -p - ${BUS}"
+	dumpcmd="${dumpcmd} | tcpdump -n -e -r -"
+
+	rump_server_start $SERVER netinet6 pppoe
+	rump_server_start $CLIENT netinet6 pppoe
+
+	setup_ifaces
+	setup_auth_conf
+
+	export RUMP_SERVER=$SERVER
+	atf_check -s exit:0 -x "$HIJACKING pppoectl -e shmif0 pppoe0"
+	atf_check -s exit:0 rump.ifconfig pppoe0 up
+	unset RUMP_SERVER
+
+	export RUMP_SERVER=$CLIENT
+	atf_check -s exit:0 -x "$HIJACKING pppoectl -e shmif0 pppoe0"
+	atf_check -s exit:0 rump.ifconfig pppoe0 up
+	$DEBUG && rump.ifconfig
+	wait_for_session_established
+	unset RUMP_SERVER
+
+	$DEBUG && dump_bus
+	atf_check -s exit:0 -o match:'\[Service-Name\]' -e ignore \
+	-x "${dumpcmd} | grep PADI"
+	atf_check -s exit:0 -o match:'\[Service-Name\]' -e ignore \
+	-x "${dumpcmd} | grep PADR"
+	atf_check -s exit:0 -o not-match:'AC-Name' -e ignore \
+	-x "${dumpcmd} | grep PADI"
+
+	# set Remote access concentrator name (AC-NAME, -a option)
+	export RUMP_SERVER=$CLIENT
+	atf_check -s exit:0 rump.ifconfig pppoe0 down
+	wait_for_disconnected
+	atf_check -s exit:0 -x "$HIJACKING pppoectl -e shmif0 -a ACNAME-TEST0 pppoe0"
+	atf_check -s exit:0 rump.ifconfig pppoe0 up
+	$DEBUG && rump.ifconfig
+	wait_for_session_established
+	unset RUMP_SERVER
+
+	$DEBUG && dump_bus
+	atf_check -s exit:0 -o match:'\[AC-Name "ACNAME-TEST0"\]' -e ignore \
+	-x "${dumpcmd} | grep PADI"
+
+	# change AC-NAME
+	

CVS commit: src/tests/net/if_pppoe

2020-09-25 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Fri Sep 25 06:07:31 UTC 2020

Modified Files:
src/tests/net/if_pppoe: t_pppoe.sh

Log Message:
Add test cases for AC-Name and Service-Name


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/tests/net/if_pppoe/t_pppoe.sh

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

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 06:06:15 UTC 2020

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

Log Message:
make(1): document expansion of undefined variables in Var_Subst

>From reading the code alone, it is not obvious what effects this
innocent-looking code has.


To generate a diff of this commit:
cvs rdiff -u -r1.537 -r1.538 src/usr.bin/make/var.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/var.c
diff -u src/usr.bin/make/var.c:1.537 src/usr.bin/make/var.c:1.538
--- src/usr.bin/make/var.c:1.537	Fri Sep 25 05:04:51 2020
+++ src/usr.bin/make/var.c	Fri Sep 25 06:06:15 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.537 2020/09/25 05:04:51 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.538 2020/09/25 06:06:15 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -121,7 +121,7 @@
 #include"metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.537 2020/09/25 05:04:51 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.538 2020/09/25 06:06:15 rillig Exp $");
 
 #define VAR_DEBUG_IF(cond, fmt, ...)	\
 if (!(DEBUG(VAR) && (cond)))	\
@@ -3780,6 +3780,10 @@ Var_Subst(const char *str, GNode *ctxt, 
 		p = nested_p;
 		errorReported = TRUE;
 		} else {
+		/* Copy the initial '$' of the undefined expression,
+		 * thereby deferring expansion of the expression, but
+		 * expand nested expressions if already possible.
+		 * See unit-tests/varparse-undef-partial.mk. */
 		Buf_AddByte(, *p);
 		p++;
 		}



CVS commit: src/usr.bin/make

2020-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Sep 25 06:06:15 UTC 2020

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

Log Message:
make(1): document expansion of undefined variables in Var_Subst

>From reading the code alone, it is not obvious what effects this
innocent-looking code has.


To generate a diff of this commit:
cvs rdiff -u -r1.537 -r1.538 src/usr.bin/make/var.c

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