CVS commit: src/sys/net80211

2020-10-06 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Oct  6 23:51:06 UTC 2020

Modified Files:
src/sys/net80211: ieee80211.c

Log Message:
net80211: Initialise the interface with a decent link state.

Link state transitions to UP when a node is joined and DOWN when left.
This means that with the interface UP, the link state could be UNKNOWN
for a while, implying it can be used in BSS mode.
Which is of course false.

Add a function to set an initial link state based on the operating mode.
Also call this when the operating mode changes.

Basically in BSS and MONITOR it starts off down.
BSS will transition UP and DOWN as before, MONITOR will stay down.
IBSS, AHDEMO and HOSTAP will remain as link unknown because the state is
. unknown.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/net80211/ieee80211.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/net80211/ieee80211.c
diff -u src/sys/net80211/ieee80211.c:1.59 src/sys/net80211/ieee80211.c:1.60
--- src/sys/net80211/ieee80211.c:1.59	Sun Mar 15 23:04:51 2020
+++ src/sys/net80211/ieee80211.c	Tue Oct  6 23:51:05 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211.c,v 1.59 2020/03/15 23:04:51 thorpej Exp $	*/
+/*	$NetBSD: ieee80211.c,v 1.60 2020/10/06 23:51:05 roy Exp $	*/
 /*-
  * Copyright (c) 2001 Atsushi Onoe
  * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
@@ -36,7 +36,7 @@
 __FBSDID("$FreeBSD: src/sys/net80211/ieee80211.c,v 1.22 2005/08/10 16:22:29 sam Exp $");
 #endif
 #ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ieee80211.c,v 1.59 2020/03/15 23:04:51 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211.c,v 1.60 2020/10/06 23:51:05 roy Exp $");
 #endif
 
 /*
@@ -150,6 +150,30 @@ ieee80211_default_reset(struct ifnet *if
 	return ENETRESET;
 }
 
+static void
+ieee80211_init_link_state(struct ieee80211com *ic)
+{
+	struct ifnet *ifp = ic->ic_ifp;
+
+	/*
+	 * Link state does not make sense in IBSS or HOSTAP modes.
+	 * We know that the link in MONITOR mode is DOWN as we cannot
+	 * transmit, only monitor.
+	 * That leaves BSS mode, which starts off DOWN and will
+	 * transition to UP when it joins a node.
+	 */
+	switch (ic->ic_opmode) {
+	case IEEE80211_M_AHDEMO:
+	case IEEE80211_M_HOSTAP:
+	case IEEE80211_M_IBSS:
+		if_link_state_change(ifp, LINK_STATE_UNKNOWN);
+		break;
+	default:
+		if_link_state_change(ifp, LINK_STATE_DOWN);
+		break;
+	}
+}
+
 void
 ieee80211_ifattach(struct ieee80211com *ic)
 {
@@ -246,6 +270,8 @@ ieee80211_ifattach(struct ieee80211com *
 	 */
 	if (ic->ic_reset == NULL)
 		ic->ic_reset = ieee80211_default_reset;
+
+	ieee80211_init_link_state(ic);
 }
 
 void
@@ -703,6 +729,7 @@ ieee80211_media_change(struct ifnet *ifp
 		 */
 		ieee80211_reset_erp(ic);
 		ieee80211_wme_initparams(ic);	/* after opmode change */
+		ieee80211_init_link_state(ic);	/* after opmode change */
 		error = ENETRESET;
 	}
 #ifdef notdef



CVS commit: src/external/gpl3/gdb/dist/bfd

2020-10-06 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Oct  6 23:28:13 UTC 2020

Modified Files:
src/external/gpl3/gdb/dist/bfd: config.bfd

Log Message:
Replace local patches adding NetBSD/aarch64 support with the upstream one

Cherry-pick:

>From c0b313441717b65569edb01bf9984d2066d899de Mon Sep 17 00:00:00 2001
From: Nick Clifton 
Date: Mon, 5 Oct 2020 14:56:42 +0100
Subject: [PATCH] Add NetBSD AArch64 Little Endian and Big Endian BFD support.

bfd  * config.bfd (aarch64-*-netbsd*, aarch64_be-*-netbsd*): Add target.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/external/gpl3/gdb/dist/bfd/config.bfd

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

Modified files:

Index: src/external/gpl3/gdb/dist/bfd/config.bfd
diff -u src/external/gpl3/gdb/dist/bfd/config.bfd:1.22 src/external/gpl3/gdb/dist/bfd/config.bfd:1.23
--- src/external/gpl3/gdb/dist/bfd/config.bfd:1.22	Tue Sep 15 02:05:16 2020
+++ src/external/gpl3/gdb/dist/bfd/config.bfd	Tue Oct  6 23:28:13 2020
@@ -247,11 +247,6 @@ case "${targ}" in
 targ_selvecs="aarch64_elf64_be_vec arm_elf32_le_vec arm_elf32_be_vec"
 want64=true
 ;;
-  aarch64-*-netbsd*)
-targ_defvec=aarch64_elf64_le_vec
-targ_selvecs="aarch64_elf64_be_vec arm_elf32_le_vec arm_elf32_be_vec"
-want64=true
-;;
   aarch64-*-fuchsia*)
 targ_defvec=aarch64_elf64_le_vec
 targ_selvecs="aarch64_elf64_be_vec arm_elf32_le_vec arm_elf32_be_vec"
@@ -262,22 +257,12 @@ case "${targ}" in
 targ_selvecs=aarch64_elf64_be_cloudabi_vec
 want64=true
 ;;
-  aarch64-*-linux*)
-targ_defvec=aarch64_elf64_le_vec
-targ_selvecs="aarch64_elf64_be_vec aarch64_elf32_le_vec aarch64_elf32_be_vec arm_elf32_le_vec arm_elf32_be_vec"
-want64=true
-;;
-  aarch64_be-*-linux*)
-targ_defvec=aarch64_elf64_be_vec
-targ_selvecs="aarch64_elf64_le_vec aarch64_elf32_le_vec aarch64_elf32_be_vec arm_elf32_be_vec arm_elf32_le_vec"
-want64=true
-;;
-  aarch64-*-netbsd*)
+  aarch64-*-linux* | aarch64-*-netbsd*)
 targ_defvec=aarch64_elf64_le_vec
 targ_selvecs="aarch64_elf64_be_vec aarch64_elf32_le_vec aarch64_elf32_be_vec arm_elf32_le_vec arm_elf32_be_vec"
 want64=true
 ;;
-  aarch64_be-*-netbsd*)
+  aarch64_be-*-linux* | aarch64_be-*-netbsd*)
 targ_defvec=aarch64_elf64_be_vec
 targ_selvecs="aarch64_elf64_le_vec aarch64_elf32_le_vec aarch64_elf32_be_vec arm_elf32_be_vec arm_elf32_le_vec"
 want64=true



CVS commit: src/external/gpl3/gdb/dist/gdb

2020-10-06 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Oct  6 23:14:47 UTC 2020

Modified Files:
src/external/gpl3/gdb/dist/gdb: inf-ptrace.c nbsd-nat.c

Log Message:
Undo local patches

They are no longer needed (and are wrong).


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/external/gpl3/gdb/dist/gdb/inf-ptrace.c
cvs rdiff -u -r1.17 -r1.18 src/external/gpl3/gdb/dist/gdb/nbsd-nat.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/gpl3/gdb/dist/gdb/inf-ptrace.c
diff -u src/external/gpl3/gdb/dist/gdb/inf-ptrace.c:1.21 src/external/gpl3/gdb/dist/gdb/inf-ptrace.c:1.22
--- src/external/gpl3/gdb/dist/gdb/inf-ptrace.c:1.21	Tue Sep 15 02:05:18 2020
+++ src/external/gpl3/gdb/dist/gdb/inf-ptrace.c	Tue Oct  6 23:14:47 2020
@@ -263,12 +263,10 @@ get_ptrace_pid (ptid_t ptid)
 {
   pid_t pid;
 
-#ifndef __NetBSD__
   /* If we have an LWPID to work with, use it.  Otherwise, we're
  dealing with a non-threaded program/target.  */
   pid = ptid.lwp ();
   if (pid == 0)
-#endif
 pid = ptid.pid ();
   return pid;
 }
@@ -293,7 +291,6 @@ inf_ptrace_target::resume (ptid_t ptid, 
   else
 request = PT_CONTINUE;
 
-  int sig;
   if (step)
 {
   /* If this system does not support PT_STEP, a higher level
@@ -302,23 +299,13 @@ inf_ptrace_target::resume (ptid_t ptid, 
 	 all possible successor instructions), so we don't have to
 	 worry about that here.  */
   request = PT_STEP;
-#if __NetBSD__
-  /*
-   * On NetBSD the data field of PT_STEP contains the thread
-   * to be stepped; all other threads are continued if this value is > 0
-   */
-  sig = ptid.lwp ();
-#else
-  sig = 0;
-#endif
-} else
-  sig = gdb_signal_to_host (signal);
+}
 
   /* An address of (PTRACE_TYPE_ARG3)1 tells ptrace to continue from
  where it was.  If GDB wanted it to start some other way, we have
  already written a new program counter value to the child.  */
   errno = 0;
-  gdb_ptrace (request, ptid, (PTRACE_TYPE_ARG3)1, sig);
+  gdb_ptrace (request, ptid, (PTRACE_TYPE_ARG3)1, gdb_signal_to_host (signal));
   if (errno != 0)
 perror_with_name (("ptrace"));
 }
@@ -476,15 +463,6 @@ inf_ptrace_target::xfer_partial (enum ta
 	/* If the PT_IO request is somehow not supported, fallback on
 	   using PT_WRITE_D/PT_READ_D.  Otherwise we will return zero
 	   to indicate failure.  */
-	if (errno == EACCES)
-	  {
-	fprintf_unfiltered (gdb_stderr, "Cannot %s process at %p (%s). "
-"Is PaX MPROTECT active? See security(7), "
-"sysctl(7), paxctl(8)\n", writebuf ? "write to" :
-"read from", piod.piod_offs,
-strerror(errno));
-	return TARGET_XFER_E_IO;	/* Some other error perhaps? */
-	  }
 	if (errno != EINVAL)
 	  return TARGET_XFER_EOF;
   }

Index: src/external/gpl3/gdb/dist/gdb/nbsd-nat.c
diff -u src/external/gpl3/gdb/dist/gdb/nbsd-nat.c:1.17 src/external/gpl3/gdb/dist/gdb/nbsd-nat.c:1.18
--- src/external/gpl3/gdb/dist/gdb/nbsd-nat.c:1.17	Sat Sep 19 21:45:45 2020
+++ src/external/gpl3/gdb/dist/gdb/nbsd-nat.c	Tue Oct  6 23:14:47 2020
@@ -587,9 +587,6 @@ nbsd_nat_target::wait (ptid_t ptid, stru
   siginfo_t *si = _siginfo;
 
   int lwp = psi.psi_lwpid;
-  // XXX: should the kernel return this?
-  if (lwp == 0)
-lwp = pid;
 
   int signo = si->si_signo;
   const int code = si->si_code;



CVS commit: src/external/gpl3/gdb/dist/gdb

2020-10-06 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Oct  6 22:17:42 UTC 2020

Modified Files:
src/external/gpl3/gdb/dist/gdb: nbsd-tdep.c

Log Message:
Remove NFC local delta


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/external/gpl3/gdb/dist/gdb/nbsd-tdep.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/gpl3/gdb/dist/gdb/nbsd-tdep.c
diff -u src/external/gpl3/gdb/dist/gdb/nbsd-tdep.c:1.5 src/external/gpl3/gdb/dist/gdb/nbsd-tdep.c:1.6
--- src/external/gpl3/gdb/dist/gdb/nbsd-tdep.c:1.5	Tue Sep 15 02:05:18 2020
+++ src/external/gpl3/gdb/dist/gdb/nbsd-tdep.c	Tue Oct  6 22:17:42 2020
@@ -3,9 +3,9 @@
Copyright (C) 2002-2020 Free Software Foundation, Inc.
 
Contributed by Wasabi Systems, Inc.
-
+  
This file is part of GDB.
-
+  
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or



CVS commit: src/external/gpl3/gdb/dist/gdb

2020-10-06 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Oct  6 22:14:41 UTC 2020

Modified Files:
src/external/gpl3/gdb/dist/gdb: ppc-nbsd-tdep.c

Log Message:
Fix typo

Remove delta with upstream.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/external/gpl3/gdb/dist/gdb/ppc-nbsd-tdep.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/gpl3/gdb/dist/gdb/ppc-nbsd-tdep.c
diff -u src/external/gpl3/gdb/dist/gdb/ppc-nbsd-tdep.c:1.5 src/external/gpl3/gdb/dist/gdb/ppc-nbsd-tdep.c:1.6
--- src/external/gpl3/gdb/dist/gdb/ppc-nbsd-tdep.c:1.5	Tue Sep 15 02:05:18 2020
+++ src/external/gpl3/gdb/dist/gdb/ppc-nbsd-tdep.c	Tue Oct  6 22:14:41 2020
@@ -199,7 +199,7 @@ _initialize_ppcnbsd_tdep ()
 			  ppcnbsd_init_abi);
 
   /* Avoid initializing the register offsets again if they were
- already initailized by ppcnbsd-nat.c.  */
+ already initialized by ppcnbsd-nat.c.  */
   if (ppcnbsd_reg_offsets.pc_offset == 0)
 {
   /* General-purpose registers.  */



CVS commit: src/external/gpl3/gdb/dist/gdbsupport

2020-10-06 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Oct  6 22:04:09 UTC 2020

Modified Files:
src/external/gpl3/gdb/dist/gdbsupport: agent.cc

Log Message:
Replace local patch with fix from upstream

Cherry-pick:

>From e2a2a24a8e78427ff8667d625f5befbe88c328bb Mon Sep 17 00:00:00 2001
From: Kamil Rytarowski 
Date: Wed, 23 Sep 2020 04:20:05 +0200
Subject: [PATCH] Preinitialize the sockaddr_un variable to zero

Don't pass random sun_len for the BSD's,
zero the whole structure as recommended for portability.

Reported by Coverity.

gdbsupport/ChangeLog:

* agent.cc (gdb_connect_sync_socket): Preinitialize addr with zeros.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/gpl3/gdb/dist/gdbsupport/agent.cc

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

Modified files:

Index: src/external/gpl3/gdb/dist/gdbsupport/agent.cc
diff -u src/external/gpl3/gdb/dist/gdbsupport/agent.cc:1.2 src/external/gpl3/gdb/dist/gdbsupport/agent.cc:1.3
--- src/external/gpl3/gdb/dist/gdbsupport/agent.cc:1.2	Sun Sep 20 21:18:45 2020
+++ src/external/gpl3/gdb/dist/gdbsupport/agent.cc	Tue Oct  6 22:04:09 2020
@@ -138,7 +138,7 @@ static int
 gdb_connect_sync_socket (int pid)
 {
 #ifdef HAVE_SYS_UN_H
-  struct sockaddr_un addr;
+  struct sockaddr_un addr = {};
   int res, fd;
   char path[UNIX_PATH_MAX];
 
@@ -153,7 +153,6 @@ gdb_connect_sync_socket (int pid)
   return -1;
 }
 
-  memset(, 0, sizeof(addr));
   addr.sun_family = AF_UNIX;
 
   res = xsnprintf (addr.sun_path, UNIX_PATH_MAX, "%s", path);



CVS commit: src/external/gpl3/gdb/dist/gnulib/import/m4

2020-10-06 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Oct  6 21:54:01 UTC 2020

Modified Files:
src/external/gpl3/gdb/dist/gnulib/import/m4: mbrtowc.m4

Log Message:
Undo local NFC patch


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/external/gpl3/gdb/dist/gnulib/import/m4/mbrtowc.m4

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

Modified files:

Index: src/external/gpl3/gdb/dist/gnulib/import/m4/mbrtowc.m4
diff -u src/external/gpl3/gdb/dist/gnulib/import/m4/mbrtowc.m4:1.3 src/external/gpl3/gdb/dist/gnulib/import/m4/mbrtowc.m4:1.4
--- src/external/gpl3/gdb/dist/gnulib/import/m4/mbrtowc.m4:1.3	Sun Sep 20 16:00:56 2020
+++ src/external/gpl3/gdb/dist/gnulib/import/m4/mbrtowc.m4	Tue Oct  6 21:54:01 2020
@@ -754,6 +754,7 @@ changequote(,)dnl
   case "$host_os" in
   # Guess no on AIX and glibc systems.
 aix* | *-gnu* | gnu*) gl_cv_func_mbrtowc_empty_input="guessing no" ;;
+  # Guess yes on native Windows.
 mingw*)   gl_cv_func_mbrtowc_empty_input="guessing yes" ;;
 *)gl_cv_func_mbrtowc_empty_input="guessing yes" ;;
   esac



CVS commit: src/usr.bin/make

2020-10-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Oct  6 21:51:33 UTC 2020

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

Log Message:
make(1): remove incomplete fallback implementation of strftime

The function strftime is available since C89.  Any environments older
than that are not supported anymore.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/usr.bin/make/util.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/util.c
diff -u src/usr.bin/make/util.c:1.63 src/usr.bin/make/util.c:1.64
--- src/usr.bin/make/util.c:1.63	Mon Oct  5 19:27:47 2020
+++ src/usr.bin/make/util.c	Tue Oct  6 21:51:33 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: util.c,v 1.63 2020/10/05 19:27:47 rillig Exp $	*/
+/*	$NetBSD: util.c,v 1.64 2020/10/06 21:51:33 rillig Exp $	*/
 
 /*
  * Missing stuff from OS's
@@ -15,7 +15,7 @@
 
 #include "make.h"
 
-MAKE_RCSID("$NetBSD: util.c,v 1.63 2020/10/05 19:27:47 rillig Exp $");
+MAKE_RCSID("$NetBSD: util.c,v 1.64 2020/10/06 21:51:33 rillig Exp $");
 
 #if !defined(MAKE_NATIVE) && !defined(HAVE_STRERROR)
 extern int errno, sys_nerr;
@@ -397,65 +397,4 @@ snprintf(char *s, size_t n, const char *
 	return rv;
 }
 
-#if !defined(MAKE_NATIVE) && !defined(HAVE_STRFTIME)
-size_t
-strftime(char *buf, size_t len, const char *fmt, const struct tm *tm)
-{
-	static char months[][4] = {
-		"Jan", "Feb", "Mar", "Apr", "May", "Jun",
-		"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
-	};
-
-	size_t s;
-	char *b = buf;
-
-	while (*fmt) {
-		if (len == 0)
-			return buf - b;
-		if (*fmt != '%') {
-			*buf++ = *fmt++;
-			len--;
-			continue;
-		}
-		switch (*fmt++) {
-		case '%':
-			*buf++ = '%';
-			len--;
-			if (len == 0) return buf - b;
-			/*FALLTHROUGH*/
-		case '\0':
-			*buf = '%';
-			s = 1;
-			break;
-		case 'k':
-			s = snprintf(buf, len, "%d", tm->tm_hour);
-			break;
-		case 'M':
-			s = snprintf(buf, len, "%02d", tm->tm_min);
-			break;
-		case 'S':
-			s = snprintf(buf, len, "%02d", tm->tm_sec);
-			break;
-		case 'b':
-			if (tm->tm_mon >= 12)
-return buf - b;
-			s = snprintf(buf, len, "%s", months[tm->tm_mon]);
-			break;
-		case 'd':
-			s = snprintf(buf, len, "%02d", tm->tm_mday);
-			break;
-		case 'Y':
-			s = snprintf(buf, len, "%d", 1900 + tm->tm_year);
-			break;
-		default:
-			s = snprintf(buf, len, "Unsupported format %c",
-			fmt[-1]);
-			break;
-		}
-		buf += s;
-		len -= s;
-	}
-	return buf - b;
-}
-#endif
 #endif



CVS commit: src/external/gpl3/gdb/dist/libiberty

2020-10-06 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Oct  6 21:49:22 UTC 2020

Modified Files:
src/external/gpl3/gdb/dist/libiberty: make-temp-file.c

Log Message:
Undo local patch having no impact

/tmp is picked from P_tmpdir earlier.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/external/gpl3/gdb/dist/libiberty/make-temp-file.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/gpl3/gdb/dist/libiberty/make-temp-file.c
diff -u src/external/gpl3/gdb/dist/libiberty/make-temp-file.c:1.6 src/external/gpl3/gdb/dist/libiberty/make-temp-file.c:1.7
--- src/external/gpl3/gdb/dist/libiberty/make-temp-file.c:1.6	Tue Sep 15 02:05:28 2020
+++ src/external/gpl3/gdb/dist/libiberty/make-temp-file.c	Tue Oct  6 21:49:22 2020
@@ -129,10 +129,10 @@ choose_tmpdir (void)
 	base = try_dir (P_tmpdir, base);
 #endif
 
-  /* Try /tmp, /var/tmp, then /usr/tmp.  */
-  base = try_dir (tmp, base);
+  /* Try /var/tmp, /usr/tmp, then /tmp.  */
   base = try_dir (vartmp, base);
   base = try_dir (usrtmp, base);
+  base = try_dir (tmp, base);
   
   /* If all else fails, use the current directory!  */
   if (base == 0)



CVS commit: src/external/gpl3/gdb/dist/bfd

2020-10-06 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Oct  6 21:39:53 UTC 2020

Modified Files:
src/external/gpl3/gdb/dist/bfd: netbsd-core.c

Log Message:
Undo local NFC patch


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/external/gpl3/gdb/dist/bfd/netbsd-core.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/gpl3/gdb/dist/bfd/netbsd-core.c
diff -u src/external/gpl3/gdb/dist/bfd/netbsd-core.c:1.8 src/external/gpl3/gdb/dist/bfd/netbsd-core.c:1.9
--- src/external/gpl3/gdb/dist/bfd/netbsd-core.c:1.8	Tue Sep 15 02:05:16 2020
+++ src/external/gpl3/gdb/dist/bfd/netbsd-core.c	Tue Oct  6 21:39:53 2020
@@ -275,7 +275,7 @@ const bfd_target core_netbsd_vec =
 0,/* Symbol prefix.  */
 ' ',			/* ar_pad_char.  */
 16,/* ar_max_namelen.  */
-0,/* match priority.  */
+0,/* Match priority.  */
 NO_GET64, NO_GETS64, NO_PUT64,	/* 64 bit data.  */
 NO_GET, NO_GETS, NO_PUT,		/* 32 bit data.  */
 NO_GET, NO_GETS, NO_PUT,		/* 16 bit data.  */



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

2020-10-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Oct  6 21:19:17 UTC 2020

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

Log Message:
make(1): add test for double expansion in SySV modifier


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-sysv.mk

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

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-sysv.mk
diff -u src/usr.bin/make/unit-tests/varmod-sysv.mk:1.4 src/usr.bin/make/unit-tests/varmod-sysv.mk:1.5
--- src/usr.bin/make/unit-tests/varmod-sysv.mk:1.4	Tue Oct  6 21:05:21 2020
+++ src/usr.bin/make/unit-tests/varmod-sysv.mk	Tue Oct  6 21:19:17 2020
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-sysv.mk,v 1.4 2020/10/06 21:05:21 rillig Exp $
+# $NetBSD: varmod-sysv.mk,v 1.5 2020/10/06 21:19:17 rillig Exp $
 #
 # Tests for the ${VAR:from=to} variable modifier, which replaces the suffix
 # "from" with "to".  It can also use '%' as a wildcard.
@@ -88,3 +88,15 @@ LIST=	one two
 .if ${LIST:%nes=%xxx} != "one two" # lhs is longer than the word "one"
 .  error
 .endif
+
+# As of 2020-10-06, the right-hand side of the SysV modifier is expanded
+# twice.  The first expansion happens in ApplyModifier_SysV, where the
+# modifier is split into its two parts.  The second expansion happens
+# when each word is replaced in ModifyWord_SYSVSubst.
+# XXX: This is unexpected.  Add more test case to demonstrate the effects
+# of removing one of the expansions.
+VALUE=		value
+INDIRECT=	1:${VALUE} 2:$${VALUE} 4:{VALUE}
+.if ${x:L:x=${INDIRECT}} != "1:value 2:value 4:\${VALUE}"
+.  error
+.endif



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

2020-10-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Oct  6 21:05:21 UTC 2020

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

Log Message:
make(1): migrate SysV modifier test to use the preprocessor

When both the expected and the actual expression are written in the same
line of the same file, it is easier to compare them and to document
anything interesting.  The exp file doesn't provide any space for
comments or explanations.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varmod-sysv.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-sysv.mk

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

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-sysv.exp
diff -u src/usr.bin/make/unit-tests/varmod-sysv.exp:1.2 src/usr.bin/make/unit-tests/varmod-sysv.exp:1.3
--- src/usr.bin/make/unit-tests/varmod-sysv.exp:1.2	Sun Aug 23 14:52:06 2020
+++ src/usr.bin/make/unit-tests/varmod-sysv.exp	Tue Oct  6 21:05:21 2020
@@ -1,8 +1 @@
-ax:Q b c d eb
-bcd.e
-&
-anchor-dollar: value
-anchor-dollar: valux
-mismatch: file.cpp file.h
-mismatch: renamed.c other.c
 exit status 0

Index: src/usr.bin/make/unit-tests/varmod-sysv.mk
diff -u src/usr.bin/make/unit-tests/varmod-sysv.mk:1.3 src/usr.bin/make/unit-tests/varmod-sysv.mk:1.4
--- src/usr.bin/make/unit-tests/varmod-sysv.mk:1.3	Sun Aug 23 14:52:06 2020
+++ src/usr.bin/make/unit-tests/varmod-sysv.mk	Tue Oct  6 21:05:21 2020
@@ -1,61 +1,90 @@
-# $NetBSD: varmod-sysv.mk,v 1.3 2020/08/23 14:52:06 rillig Exp $
+# $NetBSD: varmod-sysv.mk,v 1.4 2020/10/06 21:05:21 rillig Exp $
 #
 # Tests for the ${VAR:from=to} variable modifier, which replaces the suffix
 # "from" with "to".  It can also use '%' as a wildcard.
 #
 # This modifier is applied when the other modifiers don't match exactly.
 
-all: words ampersand anchor-dollar mismatch
+all:
 
 # The :Q looks like a modifier but isn't.
 # It is part of the replacement string.
-words:
-	@echo a${a b c d e:L:%a=x:Q}b
+.if ${a b c d e:L:%a=x:Q} != "x:Q b c d e"
+.  error
+.endif
 
 # Before 2020-07-19, an ampersand could be used in the replacement part
-# of a SysV substitution modifier.  This was probably a copy-and-paste
-# mistake since the SysV modifier code looked a lot like the code for the
-# :S and :C modifiers.  The ampersand is not mentioned in the manual page.
-ampersand:
-	@echo ${:U${a.bcd.e:L:a.%=%}:Q}
-	@echo ${:U${a.bcd.e:L:a.%=&}:Q}
+# of a SysV substitution modifier, and it was replaced with the whole match,
+# just like in the :S modifier.
+#
+# This was probably a copy-and-paste mistake since the code for the SysV
+# modifier looked a lot like the code for the :S and :C modifiers.
+# The ampersand is not mentioned in the manual page.
+.if ${a.bcd.e:L:a.%=%} != "bcd.e"
+.  error
+.endif
+# Before 2020-07-19, the result of the expression was "a.bcd.e".
+.if ${a.bcd.e:L:a.%=&} != "&"
+.  error
+.endif
 
 # Before 2020-07-20, when a SysV modifier was parsed, a single dollar
-# before the '=' was interpreted as an anchor, which doesn't make sense
-# since the anchor was discarded immediately.
-anchor-dollar:
-	@echo $@: ${:U${value:L:e$=x}:Q}
-	@echo $@: ${:U${value:L:e=x}:Q}
+# before the '=' was parsed (but not interpreted) as an anchor.
+# Parsing something without then evaluating it accordingly doesn't make
+# sense.
+.if ${value:L:e$=x} != "value"
+.  error
+.endif
+# Before 2020-07-20, the modifier ":e$=x" was parsed as having a left-hand
+# side "e" and a right-hand side "x".  The dollar was parsed (but not
+# interpreted) as 'anchor at the end'.  Therefore the modifier was equivalent
+# to ":e=x", which doesn't match the string "value$".  Therefore the whole
+# expression evaluated to "value$".
+.if ${${:Uvalue\$}:L:e$=x} != "valux"
+.  error
+.endif
+.if ${value:L:e=x} != "valux"
+.  error
+.endif
 
 # Words that don't match are copied unmodified.
-# The % placeholder can be anywhere in the string.
-mismatch:
-	@echo $@: ${:Ufile.c file.h:%.c=%.cpp}
-	@echo $@: ${:Ufile.c other.c:file.%=renamed.%}
+.if ${:Ufile.c file.h:%.c=%.cpp} != "file.cpp file.h"
+.  error
+.endif
+
+# The % placeholder can be anywhere in the string, it doesn't have to be at
+# the beginning of the pattern.
+.if ${:Ufile.c other.c:file.%=renamed.%} != "renamed.c other.c"
+.  error
+.endif
 
 # Trying to cover all possible variants of the SysV modifier.
 LIST=	one two
-EXPR.1=	${LIST:o=X}
-EXP.1=	one twX
-EXPR.2=	${LIST:o=}
-EXP.2=	one tw
-EXPR.3=	${LIST:o=%}
-EXP.3=	one tw%
-EXPR.4=	${LIST:%o=X}
-EXP.4=	one X
-EXPR.5=	${LIST:o%=X}
-EXP.5=	X two
-EXPR.6=	${LIST:o%e=X}
-EXP.6=	X two
-EXPR.7=	${LIST:o%%e=X}		# Only the first '%' is the wildcard.
-EXP.7=	one two			# None of the words contains a literal '%'.
-EXPR.8=	${LIST:%=%%}
-EXP.8=	one% two%
-EXPR.9=	${LIST:%nes=%xxx}	# lhs is longer than the word "one"
-EXP.9=	one two
-
-.for i in ${:U:range=9}
-.if ${EXPR.$i} != ${EXP.$i}

CVS commit: src/sbin/ccdconfig

2020-10-06 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Oct  6 18:47:08 UTC 2020

Modified Files:
src/sbin/ccdconfig: ccdconfig.c

Log Message:
Use raw device for configuring units. This is necessary as
having a block device opened prevents autodiscovery of wedges.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sbin/ccdconfig/ccdconfig.c

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

Modified files:

Index: src/sbin/ccdconfig/ccdconfig.c
diff -u src/sbin/ccdconfig/ccdconfig.c:1.57 src/sbin/ccdconfig/ccdconfig.c:1.58
--- src/sbin/ccdconfig/ccdconfig.c:1.57	Sun Sep  6 02:34:30 2020
+++ src/sbin/ccdconfig/ccdconfig.c	Tue Oct  6 18:47:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ccdconfig.c,v 1.57 2020/09/06 02:34:30 mrg Exp $	*/
+/*	$NetBSD: ccdconfig.c,v 1.58 2020/10/06 18:47:07 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 1996, 1997\
  The NetBSD Foundation, Inc.  All rights reserved.");
-__RCSID("$NetBSD: ccdconfig.c,v 1.57 2020/09/06 02:34:30 mrg Exp $");
+__RCSID("$NetBSD: ccdconfig.c,v 1.58 2020/10/06 18:47:07 mlelstv Exp $");
 #endif
 
 #include 
@@ -391,24 +391,38 @@ pathtounit(char *path, int *unitp)
 static char *
 resolve_ccdname(char *name)
 {
-	char c, *path;
+	char *path, *buf;
+	const char *p;
+	char c;
 	size_t len;
 	int rawpart;
 
 	if (name[0] == '/' || name[0] == '.') {
 		/* Assume they gave the correct pathname. */
-		return estrdup(name);
-	}
+		path = estrdup(name);
+	} else {
 
-	len = strlen(name);
-	c = name[len - 1];
+		len = strlen(name);
+		c = name[len - 1];
 
-	if (isdigit((unsigned char)c)) {
-		if ((rawpart = getrawpartition()) < 0)
-			return NULL;
-		easprintf(, "/dev/%s%c", name, 'a' + rawpart);
-	} else
-		easprintf(, "/dev/%s", name);
+		if (isdigit((unsigned char)c)) {
+			if ((rawpart = getrawpartition()) < 0)
+return NULL;
+			easprintf(, "/dev/%s%c", name, 'a' + rawpart);
+		} else
+			easprintf(, "/dev/%s", name);
+	}
+
+	/*
+	 * Convert to raw device if possible.
+	 */
+	buf = emalloc(MAXPATHLEN);
+	p = getdiskrawname(buf, MAXPATHLEN, path);
+	if (p) {
+		free(path);
+		path = estrdup(p);
+	}
+	free(buf);
 
 	return path;
 }
@@ -562,6 +576,7 @@ dump_ccd(int argc, char **argv, int acti
 			continue;
 		}
 		errs += printccdinfo(i);
+		free(ccd);
 	}
 	return errs;
 }



CVS commit: src/sys/dev

2020-10-06 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Oct  6 18:45:24 UTC 2020

Modified Files:
src/sys/dev: ccd.c

Log Message:
Fix ioctl locking. Add dkdriver.


To generate a diff of this commit:
cvs rdiff -u -r1.184 -r1.185 src/sys/dev/ccd.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/ccd.c
diff -u src/sys/dev/ccd.c:1.184 src/sys/dev/ccd.c:1.185
--- src/sys/dev/ccd.c:1.184	Thu Jun 11 19:20:46 2020
+++ src/sys/dev/ccd.c	Tue Oct  6 18:45:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ccd.c,v 1.184 2020/06/11 19:20:46 ad Exp $	*/
+/*	$NetBSD: ccd.c,v 1.185 2020/10/06 18:45:23 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc.
@@ -88,7 +88,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.184 2020/06/11 19:20:46 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.185 2020/10/06 18:45:23 mlelstv Exp $");
 
 #include 
 #include 
@@ -209,6 +209,11 @@ const struct cdevsw ccd_cdevsw = {
 	.d_flag = D_DISK | D_MPSAFE
 };
 
+static const struct dkdriver ccddkdriver = {
+	.d_strategy = ccdstrategy,
+	.d_minphys = minphys
+}; 
+
 #ifdef DEBUG
 static	void printiinfo(struct ccdiinfo *);
 #endif
@@ -229,7 +234,7 @@ ccdcreate(int unit) {
 	sc->sc_iolock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NONE);
 	cv_init(>sc_stop, "ccdstop");
 	cv_init(>sc_push, "ccdthr");
-	disk_init(>sc_dkdev, sc->sc_xname, NULL); /* XXX */
+	disk_init(>sc_dkdev, sc->sc_xname, );
 	return sc;
 }
 
@@ -1134,8 +1139,6 @@ ccdioctl(dev_t dev, u_long cmd, void *da
 			return (EBADF);
 	}
 
-	mutex_enter(>sc_dvlock);
-
 	/* Must be initialized for these... */
 	switch (cmd) {
 	case CCDIOCCLR:
@@ -1159,15 +1162,102 @@ ccdioctl(dev_t dev, u_long cmd, void *da
 	case ODIOCWDINFO:
 	case ODIOCGDEFLABEL:
 #endif
-		if ((cs->sc_flags & CCDF_INITED) == 0) {
-			error = ENXIO;
-			goto out;
-		}
+		if ((cs->sc_flags & CCDF_INITED) == 0)
+			return ENXIO;
 	}
 
 	error = disk_ioctl(>sc_dkdev, dev, cmd, data, flag, l);
 	if (error != EPASSTHROUGH)
-		goto out;
+		return error;
+
+	switch (cmd) {
+	case DIOCGSTRATEGY:
+	{
+		struct disk_strategy *dks = (void *)data;
+
+		mutex_enter(cs->sc_iolock);
+		if (cs->sc_bufq != NULL)
+			strlcpy(dks->dks_name,
+			bufq_getstrategyname(cs->sc_bufq),
+			sizeof(dks->dks_name));
+		else
+			error = EINVAL;
+		mutex_exit(cs->sc_iolock);
+		dks->dks_paramlen = 0;
+		break;
+	}
+
+	case DIOCWDINFO:
+	case DIOCSDINFO:
+#ifdef __HAVE_OLD_DISKLABEL
+	case ODIOCWDINFO:
+	case ODIOCSDINFO:
+#endif
+	{
+		struct disklabel *lp;
+#ifdef __HAVE_OLD_DISKLABEL
+		if (cmd == ODIOCSDINFO || cmd == ODIOCWDINFO) {
+			memset(, 0, sizeof newlabel);
+			memcpy(, data, sizeof (struct olddisklabel));
+			lp = 
+		} else
+#endif
+		lp = (struct disklabel *)data;
+
+		cs->sc_flags |= CCDF_LABELLING;
+
+		error = setdisklabel(cs->sc_dkdev.dk_label,
+		lp, 0, cs->sc_dkdev.dk_cpulabel);
+		if (error == 0) {
+			if (cmd == DIOCWDINFO
+#ifdef __HAVE_OLD_DISKLABEL
+			|| cmd == ODIOCWDINFO
+#endif
+			   )
+error = writedisklabel(CCDLABELDEV(dev),
+ccdstrategy, cs->sc_dkdev.dk_label,
+cs->sc_dkdev.dk_cpulabel);
+		}
+
+		cs->sc_flags &= ~CCDF_LABELLING;
+		break;
+	}
+
+	case DIOCKLABEL:
+		if (*(int *)data != 0)
+			cs->sc_flags |= CCDF_KLABEL;
+		else
+			cs->sc_flags &= ~CCDF_KLABEL;
+		break;
+
+	case DIOCWLABEL:
+		if (*(int *)data != 0)
+			cs->sc_flags |= CCDF_WLABEL;
+		else
+			cs->sc_flags &= ~CCDF_WLABEL;
+		break;
+
+	case DIOCGDEFLABEL:
+		ccdgetdefaultlabel(cs, (struct disklabel *)data);
+		break;
+
+#ifdef __HAVE_OLD_DISKLABEL
+	case ODIOCGDEFLABEL:
+		ccdgetdefaultlabel(cs, );
+		if (newlabel.d_npartitions > OLDMAXPARTITIONS)
+			return ENOTTY;
+		memcpy(data, , sizeof (struct olddisklabel));
+		break;
+#endif
+	default:
+		error = ENOTTY;
+			break;
+	}
+
+	if (error != ENOTTY)
+		return error;
+
+	mutex_enter(>sc_dvlock);
 
 	error = 0;
 	switch (cmd) {
@@ -1233,6 +1323,12 @@ ccdioctl(dev_t dev, u_long cmd, void *da
 sizeof(*vpp));
 kmem_free(cpp, ccio->ccio_ndisks *
 sizeof(*cpp));
+
+/*
+ * No component data is allocated,
+ * nothing is to be freed.
+*/
+cs->sc_nccdisks = 0;
 goto out;
 			}
 			++lookedup;
@@ -1332,43 +1428,31 @@ ccdioctl(dev_t dev, u_long cmd, void *da
 			cs->sc_cinfo[i].ci_pathlen);
 		}
 
-		/* Free interleave index. */
-		for (i = 0; cs->sc_itable[i].ii_ndisk; ++i) {
-			kmem_free(cs->sc_itable[i].ii_index,
-			cs->sc_itable[i].ii_indexsz);
+		if (cs->sc_nccdisks != 0) {
+			/* Free interleave index. */
+			for (i = 0; cs->sc_itable[i].ii_ndisk; ++i) {
+kmem_free(cs->sc_itable[i].ii_index,
+cs->sc_itable[i].ii_indexsz);
+			}
+			/* Free component info and interleave table. */
+			kmem_free(cs->sc_cinfo, cs->sc_nccdisks *
+			sizeof(struct ccdcinfo));
+			kmem_free(cs->sc_itable, (cs->sc_nccdisks + 1) *
+			sizeof(struct 

CVS commit: src/usr.bin/make

2020-10-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Oct  6 16:39:23 UTC 2020

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

Log Message:
make(1): remove macro FILENO

This macro was obviously wrong since it would have converted file
numbers above 127 to very large numbers, close to 2^32.

The fact that it didn't blow up at all is that this macro was only ever
given the file descriptor 4 as an argument, which can well be
represented as a char, be it signed or unsigned.  And this is how the
story goes:

In Job_Init, two jobs are started.  The server job allocates file
descriptors 15 and above.  The childExitJob is created next, and the
pipe that it creates is [3, 4].  Using F_DUPFD, fd 3 is mapped to fd 5,
and fd 3 is closed.  After that, fd 4 is mapped to fd 3 (which had just
been closed), and fd 4 is closed.

After this initialization, file descriptors 0, 1, 2, 3 and 5 are taken.
This leaves a gap at file descriptor 4, and this gap is filled whenever
cmdFILE is created.

Because of this particular order of events, the macro is not necessary.
If it should ever become necessary on platforms like the old SunOS, the
parameter minfd for JobCreatePipe should be increased to 5, which would
leave the file descriptors 3 and 4 to be used by stdio streams.

On 1995-11-03, when the macro was added, SunOS must have been in its
very early development.  In Solaris 8 (released in January 2000),
FILE._file is already an unsigned char, therefore the seeming need for
this macro must have been due to an older version, probably from the 2.x
series of SunOS.


To generate a diff of this commit:
cvs rdiff -u -r1.261 -r1.262 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.261 src/usr.bin/make/job.c:1.262
--- src/usr.bin/make/job.c:1.261	Mon Oct  5 21:37:07 2020
+++ src/usr.bin/make/job.c	Tue Oct  6 16:39:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.261 2020/10/05 21:37:07 rillig Exp $	*/
+/*	$NetBSD: job.c,v 1.262 2020/10/06 16:39:23 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -143,7 +143,7 @@
 #include "trace.h"
 
 /*	"@(#)job.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: job.c,v 1.261 2020/10/05 21:37:07 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.262 2020/10/06 16:39:23 rillig Exp $");
 
 # define STATIC static
 
@@ -162,16 +162,6 @@ static int aborting = 0;	/* why is the m
  */
 int jobTokensRunning = 0;
 
-/*
- * XXX: Avoid SunOS bug... FILENO() is fp->_file, and file
- * is a char! So when we go above 127 we turn negative!
- *
- * XXX: This cannot have ever worked. Converting a signed char directly to
- * unsigned creates very large numbers. It should have been converted to
- * unsigned char first, in the same way as for the  functions.
- */
-#define FILENO(a) ((unsigned) fileno(a))
-
 /* The number of commands actually printed for a target.
  * XXX: Why printed? Shouldn't that be run/printed instead, depending on the
  * command line options?
@@ -1213,7 +1203,7 @@ JobExec(Job *job, char **argv)
 	 * reset it to the beginning (again). Since the stream was marked
 	 * close-on-exec, we must clear that bit in the new input.
 	 */
-	if (dup2(FILENO(job->cmdFILE), 0) == -1) {
+	if (dup2(fileno(job->cmdFILE), 0) == -1) {
 	execError("dup2", "job->cmdFILE");
 	_exit(1);
 	}
@@ -1466,7 +1456,7 @@ JobStart(GNode *gn, int flags)
 	if (job->cmdFILE == NULL) {
 	Punt("Could not fdopen %s", tfile);
 	}
-	(void)fcntl(FILENO(job->cmdFILE), F_SETFD, FD_CLOEXEC);
+	(void)fcntl(fileno(job->cmdFILE), F_SETFD, FD_CLOEXEC);
 	/*
 	 * Send the commands to the command file, flush all its buffers then
 	 * rewind and remove the thing.



CVS commit: src/sys/dev/dkwedge

2020-10-06 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Oct  6 15:05:54 UTC 2020

Modified Files:
src/sys/dev/dkwedge: dk.c

Log Message:
Check dkdriver before calling a driver function.


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/sys/dev/dkwedge/dk.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/dkwedge/dk.c
diff -u src/sys/dev/dkwedge/dk.c:1.101 src/sys/dev/dkwedge/dk.c:1.102
--- src/sys/dev/dkwedge/dk.c:1.101	Sun May 24 14:40:21 2020
+++ src/sys/dev/dkwedge/dk.c	Tue Oct  6 15:05:54 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dk.c,v 1.101 2020/05/24 14:40:21 jmcneill Exp $	*/
+/*	$NetBSD: dk.c,v 1.102 2020/10/06 15:05:54 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2004, 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.101 2020/05/24 14:40:21 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.102 2020/10/06 15:05:54 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_dkwedge.h"
@@ -1441,7 +1441,10 @@ dkminphys(struct buf *bp)
 
 	dev = bp->b_dev;
 	bp->b_dev = sc->sc_pdev;
-	(*sc->sc_parent->dk_driver->d_minphys)(bp);
+	if (sc->sc_parent->dk_driver && sc->sc_parent->dk_driver->d_minphys)
+		(*sc->sc_parent->dk_driver->d_minphys)(bp);
+	else
+		minphys(bp);
 	bp->b_dev = dev;
 }
 



CVS commit: src/sys/arch

2020-10-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Oct  6 13:42:03 UTC 2020

Modified Files:
src/sys/arch/aarch64/include: vmparam.h
src/sys/arch/amd64/include: vmparam.h
src/sys/arch/mips/include: vmparam.h
src/sys/arch/riscv/include: vmparam.h
src/sys/arch/sparc64/include: vmparam.h

Log Message:
GC unused MAXTSIZ32


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/aarch64/include/vmparam.h
cvs rdiff -u -r1.52 -r1.53 src/sys/arch/amd64/include/vmparam.h
cvs rdiff -u -r1.63 -r1.64 src/sys/arch/mips/include/vmparam.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/riscv/include/vmparam.h
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/sparc64/include/vmparam.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/aarch64/include/vmparam.h
diff -u src/sys/arch/aarch64/include/vmparam.h:1.15 src/sys/arch/aarch64/include/vmparam.h:1.16
--- src/sys/arch/aarch64/include/vmparam.h:1.15	Wed Sep 23 01:02:27 2020
+++ src/sys/arch/aarch64/include/vmparam.h	Tue Oct  6 09:42:03 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: vmparam.h,v 1.15 2020/09/23 05:02:27 skrll Exp $ */
+/* $NetBSD: vmparam.h,v 1.16 2020/10/06 13:42:03 christos Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -103,10 +103,6 @@
 
 #define USRSTACK32	VM_MAXUSER_ADDRESS32
 
-#ifndef MAXTSIZ32
-#define	MAXTSIZ32	(1L << 26)	/* 32bit max text size (64MB) */
-#endif
-
 #ifndef	MAXDSIZ32
 #define	MAXDSIZ32	(3U*1024*1024*1024)	/* max data size */
 #endif

Index: src/sys/arch/amd64/include/vmparam.h
diff -u src/sys/arch/amd64/include/vmparam.h:1.52 src/sys/arch/amd64/include/vmparam.h:1.53
--- src/sys/arch/amd64/include/vmparam.h:1.52	Wed Jan 22 11:52:46 2020
+++ src/sys/arch/amd64/include/vmparam.h	Tue Oct  6 09:42:03 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmparam.h,v 1.52 2020/01/22 16:52:46 ad Exp $	*/
+/*	$NetBSD: vmparam.h,v 1.53 2020/10/06 13:42:03 christos Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -106,7 +106,6 @@
  * 32bit memory related constants.
  */
 
-#define MAXTSIZ32	(256*1024*1024)
 #ifndef DFLDSIZ32
 #define	DFLDSIZ32	(256*1024*1024)		/* initial data size limit */
 #endif

Index: src/sys/arch/mips/include/vmparam.h
diff -u src/sys/arch/mips/include/vmparam.h:1.63 src/sys/arch/mips/include/vmparam.h:1.64
--- src/sys/arch/mips/include/vmparam.h:1.63	Sun Jul 26 04:08:41 2020
+++ src/sys/arch/mips/include/vmparam.h	Tue Oct  6 09:42:03 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmparam.h,v 1.63 2020/07/26 08:08:41 simonb Exp $	*/
+/*	$NetBSD: vmparam.h,v 1.64 2020/10/06 13:42:03 christos Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -126,9 +126,6 @@
 /*
  * Virtual memory related constants, all in bytes
  */
-#ifndef MAXTSIZ32
-#define	MAXTSIZ32	MAXTSIZ			/* max text size */
-#endif
 #ifndef DFLDSIZ32
 #define	DFLDSIZ32	DFLDSIZ			/* initial data size limit */
 #endif

Index: src/sys/arch/riscv/include/vmparam.h
diff -u src/sys/arch/riscv/include/vmparam.h:1.5 src/sys/arch/riscv/include/vmparam.h:1.6
--- src/sys/arch/riscv/include/vmparam.h:1.5	Sat Jun  1 08:42:28 2019
+++ src/sys/arch/riscv/include/vmparam.h	Tue Oct  6 09:42:03 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmparam.h,v 1.5 2019/06/01 12:42:28 maxv Exp $	*/
+/*	$NetBSD: vmparam.h,v 1.6 2020/10/06 13:42:03 christos Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -79,9 +79,6 @@
 /*
  * Virtual memory related constants, all in bytes
  */
-#ifndef MAXTSIZ32
-#define	MAXTSIZ32	MAXTSIZ			/* max text size */
-#endif
 #ifndef DFLDSIZ32
 #define	DFLDSIZ32	DFLDSIZ			/* initial data size limit */
 #endif

Index: src/sys/arch/sparc64/include/vmparam.h
diff -u src/sys/arch/sparc64/include/vmparam.h:1.40 src/sys/arch/sparc64/include/vmparam.h:1.41
--- src/sys/arch/sparc64/include/vmparam.h:1.40	Wed Jan 22 11:59:37 2020
+++ src/sys/arch/sparc64/include/vmparam.h	Tue Oct  6 09:42:03 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmparam.h,v 1.40 2020/01/22 16:59:37 ad Exp $ */
+/*	$NetBSD: vmparam.h,v 1.41 2020/10/06 13:42:03 christos Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -155,9 +155,6 @@
 /*
  * 32-bit emulation limits (same as sparc - we could go bigger)
  */
-#ifndef MAXTSIZ32
-#define	MAXTSIZ32	(64*1024*1024)		/* max text size */
-#endif
 #ifndef DFLDSIZ32
 #define	DFLDSIZ32	(64*1024*1024)		/* initial data size limit */
 #endif



CVS commit: src/sys/compat/linux/arch/alpha

2020-10-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Oct  6 13:38:50 UTC 2020

Modified Files:
src/sys/compat/linux/arch/alpha: linux_osf1.c

Log Message:
make MAXTSIZ optional


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/compat/linux/arch/alpha/linux_osf1.c

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

Modified files:

Index: src/sys/compat/linux/arch/alpha/linux_osf1.c
diff -u src/sys/compat/linux/arch/alpha/linux_osf1.c:1.3 src/sys/compat/linux/arch/alpha/linux_osf1.c:1.4
--- src/sys/compat/linux/arch/alpha/linux_osf1.c:1.3	Fri Apr  5 23:06:28 2019
+++ src/sys/compat/linux/arch/alpha/linux_osf1.c	Tue Oct  6 09:38:49 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_osf1.c,v 1.3 2019/04/06 03:06:28 thorpej Exp $	*/
+/*	$NetBSD: linux_osf1.c,v 1.4 2020/10/06 13:38:49 christos Exp $	*/
 
 /*
  * Copyright (c) 1999 Christopher G. Demetriou.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_osf1.c,v 1.3 2019/04/06 03:06:28 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_osf1.c,v 1.4 2020/10/06 13:38:49 christos Exp $");
 
 #include 
 #include 
@@ -314,8 +314,10 @@ linux_sys_osf1_set_program_attributes(st
 
 	if (dsize > p->p_rlimit[RLIMIT_DATA].rlim_cur)
 		return (ENOMEM);
+#ifdef MAXTSIZ
 	if (tsize > MAXTSIZ)
 		return (ENOMEM);
+#endif
 
 	/* XXXSMP unlocked */
 	p->p_vmspace->vm_taddr = SCARG(uap, taddr);



CVS commit: src/sys/kern

2020-10-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Oct  6 13:38:00 UTC 2020

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

Log Message:
Make MAXTSIZ optional.


To generate a diff of this commit:
cvs rdiff -u -r1.501 -r1.502 src/sys/kern/kern_exec.c

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

Modified files:

Index: src/sys/kern/kern_exec.c
diff -u src/sys/kern/kern_exec.c:1.501 src/sys/kern/kern_exec.c:1.502
--- src/sys/kern/kern_exec.c:1.501	Sat May 23 19:42:43 2020
+++ src/sys/kern/kern_exec.c	Tue Oct  6 09:38:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_exec.c,v 1.501 2020/05/23 23:42:43 ad Exp $	*/
+/*	$NetBSD: kern_exec.c,v 1.502 2020/10/06 13:38:00 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2019, 2020 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.501 2020/05/23 23:42:43 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.502 2020/10/06 13:38:00 christos Exp $");
 
 #include "opt_exec.h"
 #include "opt_execfmt.h"
@@ -498,18 +498,25 @@ check_exec(struct lwp *l, struct exec_pa
 			}
 
 			/* check limits */
-			if ((epp->ep_tsize > MAXTSIZ) ||
-			(epp->ep_dsize > (u_quad_t)l->l_proc->p_rlimit
-		[RLIMIT_DATA].rlim_cur)) {
+#ifdef MAXTSIZ
+			if (epp->ep_tsize > MAXTSIZ) {
 #ifdef DIAGNOSTIC
-printf("%s: rejecting due to "
-"limits (t=%llu > %llu || d=%llu > %llu)\n",
-__func__,
-(unsigned long long)epp->ep_tsize,
-(unsigned long long)MAXTSIZ,
-(unsigned long long)epp->ep_dsize,
-(unsigned long long)
-l->l_proc->p_rlimit[RLIMIT_DATA].rlim_cur);
+#define LMSG "%s: rejecting due to %s limit (%ju > %ju)\n"
+printf(LMSG, __func__, "text",
+(uintmax_t)epp->ep_tsize,
+(uintmax_t)MAXTSIZ);
+#endif
+error = ENOMEM;
+break;
+			}
+#endif
+			vsize_t dlimit =
+			(vsize_t)l->l_proc->p_rlimit[RLIMIT_DATA].rlim_cur;
+			if (epp->ep_dsize > dlimit) {
+#ifdef DIAGNOSTIC
+printf(LMSG, __func__, "data",
+(uintmax_t)epp->ep_dsize,
+(uintmax_t)dlimit);
 #endif
 error = ENOMEM;
 break;



CVS commit: src/distrib/sun2/miniroot

2020-10-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Oct  6 13:32:42 UTC 2020

Modified Files:
src/distrib/sun2/miniroot: list

Log Message:
Revert the previous again; miniroot overflows this time...

- switch to x_disklabel (drop non-native label support)
- switch to x_fsck_ffs and x_newfs (drop byte-swapped and Apple UFS support)
- switch to more


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/distrib/sun2/miniroot/list

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

Modified files:

Index: src/distrib/sun2/miniroot/list
diff -u src/distrib/sun2/miniroot/list:1.22 src/distrib/sun2/miniroot/list:1.23
--- src/distrib/sun2/miniroot/list:1.22	Sun Oct  4 23:42:43 2020
+++ src/distrib/sun2/miniroot/list	Tue Oct  6 13:32:41 2020
@@ -1,5 +1,5 @@
 #
-# $NetBSD: list,v 1.22 2020/10/04 23:42:43 rin Exp $
+# $NetBSD: list,v 1.23 2020/10/06 13:32:41 rin Exp $
 #
 
 # The PROM provides a default kernel name of "vmunix"
@@ -127,7 +127,7 @@ PROG	usr/bin/chflags
 PROG	usr/bin/cksum
 PROG	usr/bin/cmp
 PROG	usr/bin/ftp
-PROG	usr/bin/less	usr/bin/more
+PROG	usr/bin/more	usr/bin/less
 PROG	usr/bin/rsh
 PROG	usr/bin/sed
 PROG	usr/bin/tip
@@ -138,14 +138,18 @@ PROG	usr/bin/gzip	usr/bin/gzcat usr/bin/
 # install.md still uses sort
 PROG	usr/bin/sort
 
-SPECIAL	less		srcdir	external/bsd/less/bin/less
 SPECIAL	vi		srcdir	external/bsd/nvi/usr.bin/nvi
 
+SPECIAL	disklabel	srcdir	distrib/utils/x_disklabel
 SPECIAL	ed		srcdir	distrib/utils/x_ed
+SPECIAL	fsck_ffs	srcdir	distrib/utils/x_fsck_ffs
 SPECIAL	gzip		srcdir	distrib/utils/x_gzip
 SPECIAL	ifconfig	srcdir	distrib/utils/x_ifconfig
+SPECIAL	newfs		srcdir	distrib/utils/x_newfs
 SPECIAL	ping		srcdir	distrib/utils/x_ping
 SPECIAL	route		srcdir	distrib/utils/x_route
+
+SPECIAL	more		srcdir	distrib/utils/more
 SPECIAL	edlabel		srcdir	distrib/utils/edlabel
 
 ARGVLN	sh -sh



CVS commit: src/usr.bin/make

2020-10-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Oct  6 08:13:28 UTC 2020

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

Log Message:
make(1): rework memory allocation for the name of variables

There's more to know about variable names than fits in a one-liner.
While here, enforce that the name is not modified by splitting it into
the established (var + var_freeIt) pattern.

Since the name is not modified and not freed in the middle of evaluating
an expression, there is no need to make a backup copy of it.  That code
had been necessary more than 12 years ago, but not anymore since the
code got a lot cleaner since then.


To generate a diff of this commit:
cvs rdiff -u -r1.569 -r1.570 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.569 src/usr.bin/make/var.c:1.570
--- src/usr.bin/make/var.c:1.569	Tue Oct  6 07:52:47 2020
+++ src/usr.bin/make/var.c	Tue Oct  6 08:13:27 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.569 2020/10/06 07:52:47 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.570 2020/10/06 08:13:27 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.569 2020/10/06 07:52:47 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.570 2020/10/06 08:13:27 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -213,11 +213,31 @@ ENUM_FLAGS_RTTI_6(VarFlags,
 		  VAR_IN_USE, VAR_FROM_ENV,
 		  VAR_EXPORTED, VAR_REEXPORT, VAR_FROM_CMD, VAR_READONLY);
 
+/* Variables are defined using one of the VAR=value assignments.  Their
+ * value can be queried by expressions such as $V, ${VAR}, or with modifiers
+ * such as ${VAR:S,from,to,g:Q}.
+ *
+ * There are 3 kinds of variables: context variables, environment variables,
+ * undefined variables.
+ *
+ * Context variables are stored in a GNode.context.  The only way to undefine
+ * a context variable is using the .undef directive.  In particular, it must
+ * not be possible to undefine a variable during the evaluation of an
+ * expression, or Var.name might point nowhere.
+ *
+ * Environment variables are temporary.  They are returned by VarFind, and
+ * after using them, they must be freed using VarFreeEnv.
+ *
+ * Undefined variables occur during evaluation of variable expressions such
+ * as ${UNDEF:Ufallback} in Var_Parse and ApplyModifiers.
+ */
 typedef struct Var {
-char  *name;	/* the variable's name; it is allocated for
- * environment variables and aliased to the
- * Hash_Entry name for all other variables,
- * and thus must not be modified */
+/* The name of the variable, once set, doesn't change anymore.
+ * For context variables, it aliases the corresponding Hash_Entry name.
+ * For environment and undefined variables, it is allocated. */
+const char *name;
+void *name_freeIt;
+
 Buffer	  val;		/* its value */
 VarFlags	  flags;	/* miscellaneous status flags */
 } Var;
@@ -254,11 +274,12 @@ typedef enum {
 } VarPatternFlags;
 
 static Var *
-VarNew(char *name, const char *value, VarFlags flags)
+VarNew(const char *name, void *name_freeIt, const char *value, VarFlags flags)
 {
 size_t value_len = strlen(value);
 Var *var = bmake_malloc(sizeof *var);
 var->name = name;
+var->name_freeIt = name_freeIt;
 Buf_Init(>val, value_len + 1);
 Buf_AddBytes(>val, value, value_len);
 var->flags = flags;
@@ -360,8 +381,10 @@ VarFind(const char *name, GNode *ctxt, V
 if (var == NULL && (flags & FIND_ENV)) {
 	char *env;
 
-	if ((env = getenv(name)) != NULL)
-	return VarNew(bmake_strdup(name), env, VAR_FROM_ENV);
+	if ((env = getenv(name)) != NULL) {
+	char *varname = bmake_strdup(name);
+	return VarNew(varname, varname, env, VAR_FROM_ENV);
+	}
 
 	if (checkEnvFirst && (flags & FIND_GLOBAL) && ctxt != VAR_GLOBAL) {
 	var = Hash_FindValue(_GLOBAL->context, name);
@@ -394,7 +417,7 @@ VarFreeEnv(Var *v, Boolean destroy)
 {
 if (!(v->flags & VAR_FROM_ENV))
 	return FALSE;
-free(v->name);
+free(v->name_freeIt);
 Buf_Destroy(>val, destroy);
 free(v);
 return TRUE;
@@ -406,7 +429,8 @@ static void
 VarAdd(const char *name, const char *val, GNode *ctxt, VarSet_Flags flags)
 {
 Hash_Entry *he = Hash_CreateEntry(>context, name, NULL);
-Var *v = VarNew(he->name, val, flags & VAR_SET_READONLY ? VAR_READONLY : 0);
+Var *v = VarNew(he->name, NULL, val,
+		  flags & VAR_SET_READONLY ? VAR_READONLY : 0);
 Hash_SetValue(he, v);
 if (!(ctxt->flags & INTERNAL)) {
 	VAR_DEBUG3("%s:%s = %s\n", ctxt->name, name, val);
@@ -436,8 +460,7 @@ Var_Delete(const char *name, GNode *ctxt
 	unsetenv(v->name);
 	if (strcmp(v->name, MAKE_EXPORTED) == 0)
 	var_exportedVars 

CVS commit: src/usr.bin/make

2020-10-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Oct  6 07:52:47 UTC 2020

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

Log Message:
make(1): remove duplicate code for creating variables


To generate a diff of this commit:
cvs rdiff -u -r1.568 -r1.569 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.568 src/usr.bin/make/var.c:1.569
--- src/usr.bin/make/var.c:1.568	Mon Oct  5 19:39:30 2020
+++ src/usr.bin/make/var.c	Tue Oct  6 07:52:47 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.568 2020/10/05 19:39:30 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.569 2020/10/06 07:52:47 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.568 2020/10/05 19:39:30 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.569 2020/10/06 07:52:47 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -253,6 +253,18 @@ typedef enum {
 VARP_ANCHOR_END	= 0x08	/* Match at end of word */
 } VarPatternFlags;
 
+static Var *
+VarNew(char *name, const char *value, VarFlags flags)
+{
+size_t value_len = strlen(value);
+Var *var = bmake_malloc(sizeof *var);
+var->name = name;
+Buf_Init(>val, value_len + 1);
+Buf_AddBytes(>val, value, value_len);
+var->flags = flags;
+return var;
+}
+
 /*-
  *---
  * VarFind --
@@ -348,18 +360,8 @@ VarFind(const char *name, GNode *ctxt, V
 if (var == NULL && (flags & FIND_ENV)) {
 	char *env;
 
-	if ((env = getenv(name)) != NULL) {
-	Var *v = bmake_malloc(sizeof(Var));
-	size_t len;
-	v->name = bmake_strdup(name);
-
-	len = strlen(env);
-	Buf_Init(>val, len + 1);
-	Buf_AddBytes(>val, env, len);
-
-	v->flags = VAR_FROM_ENV;
-	return v;
-	}
+	if ((env = getenv(name)) != NULL)
+	return VarNew(bmake_strdup(name), env, VAR_FROM_ENV);
 
 	if (checkEnvFirst && (flags & FIND_GLOBAL) && ctxt != VAR_GLOBAL) {
 	var = Hash_FindValue(_GLOBAL->context, name);
@@ -403,20 +405,9 @@ VarFreeEnv(Var *v, Boolean destroy)
 static void
 VarAdd(const char *name, const char *val, GNode *ctxt, VarSet_Flags flags)
 {
-Var *v = bmake_malloc(sizeof(Var));
-size_t len = strlen(val);
-Hash_Entry *he;
-
-Buf_Init(>val, len + 1);
-Buf_AddBytes(>val, val, len);
-
-v->flags = 0;
-if (flags & VAR_SET_READONLY)
-	v->flags |= VAR_READONLY;
-
-he = Hash_CreateEntry(>context, name, NULL);
+Hash_Entry *he = Hash_CreateEntry(>context, name, NULL);
+Var *v = VarNew(he->name, val, flags & VAR_SET_READONLY ? VAR_READONLY : 0);
 Hash_SetValue(he, v);
-v->name = he->name;
 if (!(ctxt->flags & INTERNAL)) {
 	VAR_DEBUG3("%s:%s = %s\n", ctxt->name, name, val);
 }
@@ -3639,10 +3630,7 @@ Var_Parse(const char **pp, GNode *ctxt, 
 	 * At the end, after applying all modifiers, if the expression
 	 * is still undefined, Var_Parse will return an empty string
 	 * instead of the actually computed value. */
-	v = bmake_malloc(sizeof(Var));
-	v->name = varname;
-	Buf_Init(>val, 1);
-	v->flags = 0;
+	v = VarNew(varname, "", 0);
 	exprFlags = VEF_UNDEF;
 	} else
 	free(varname);



CVS commit: src/sys/arch/aarch64/aarch64

2020-10-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Oct  6 06:26:46 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: cpuswitch.S vectors.S

Log Message:
move #include "opt_compat_netbsd32.h" to where it's required


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/aarch64/aarch64/cpuswitch.S
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/aarch64/aarch64/vectors.S

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

Modified files:

Index: src/sys/arch/aarch64/aarch64/cpuswitch.S
diff -u src/sys/arch/aarch64/aarch64/cpuswitch.S:1.28 src/sys/arch/aarch64/aarch64/cpuswitch.S:1.29
--- src/sys/arch/aarch64/aarch64/cpuswitch.S:1.28	Wed Sep 30 16:35:49 2020
+++ src/sys/arch/aarch64/aarch64/cpuswitch.S	Tue Oct  6 06:26:46 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cpuswitch.S,v 1.28 2020/09/30 16:35:49 skrll Exp $ */
+/* $NetBSD: cpuswitch.S,v 1.29 2020/10/06 06:26:46 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014, 2020 The NetBSD Foundation, Inc.
@@ -34,12 +34,11 @@
 
 #include "assym.h"
 
-#include "opt_compat_netbsd32.h"
 #include "opt_cpuoptions.h"
 #include "opt_ddb.h"
 #include "opt_kasan.h"
 
-RCSID("$NetBSD: cpuswitch.S,v 1.28 2020/09/30 16:35:49 skrll Exp $")
+RCSID("$NetBSD: cpuswitch.S,v 1.29 2020/10/06 06:26:46 skrll Exp $")
 
 	ARMV8_DEFINE_OPTIONS
 

Index: src/sys/arch/aarch64/aarch64/vectors.S
diff -u src/sys/arch/aarch64/aarch64/vectors.S:1.19 src/sys/arch/aarch64/aarch64/vectors.S:1.20
--- src/sys/arch/aarch64/aarch64/vectors.S:1.19	Wed Sep 30 16:35:49 2020
+++ src/sys/arch/aarch64/aarch64/vectors.S	Tue Oct  6 06:26:46 2020
@@ -1,15 +1,16 @@
-/*	$NetBSD: vectors.S,v 1.19 2020/09/30 16:35:49 skrll Exp $	*/
+/*	$NetBSD: vectors.S,v 1.20 2020/10/06 06:26:46 skrll Exp $	*/
 
 #include 
 #include 
 
 #include "assym.h"
 
+#include "opt_compat_netbsd32.h"
 #include "opt_cpuoptions.h"
 #include "opt_ddb.h"
 #include "opt_dtrace.h"
 
-RCSID("$NetBSD: vectors.S,v 1.19 2020/09/30 16:35:49 skrll Exp $")
+RCSID("$NetBSD: vectors.S,v 1.20 2020/10/06 06:26:46 skrll Exp $")
 
 	ARMV8_DEFINE_OPTIONS