CVS commit: src/sys/dev/audio

2021-02-13 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun Feb 14 03:41:13 UTC 2021

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

Log Message:
Add missing curlwp_bindx() corresponding to curlwp_bind().
Pointed out by riastradh@.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/dev/audio/audio.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/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.90 src/sys/dev/audio/audio.c:1.91
--- src/sys/dev/audio/audio.c:1.90	Tue Feb  9 12:36:34 2021
+++ src/sys/dev/audio/audio.c	Sun Feb 14 03:41:13 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.90 2021/02/09 12:36:34 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.91 2021/02/14 03:41:13 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -138,7 +138,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.90 2021/02/09 12:36:34 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.91 2021/02/14 03:41:13 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -1544,9 +1544,6 @@ audio_sc_acquire_foropen(struct audio_so
 {
 	int s;
 
-	/* psref(9) forbids to migrate CPUs */
-	curlwp_bind();
-
 	/* Block audiodetach while we acquire a reference */
 	s = pserialize_read_enter();
 
@@ -1574,9 +1571,6 @@ audio_sc_acquire_fromfile(audio_file_t *
 	int s;
 	bool dying;
 
-	/* psref(9) forbids to migrate CPUs */
-	curlwp_bind();
-
 	/* Block audiodetach while we acquire a reference */
 	s = pserialize_read_enter();
 
@@ -1679,6 +1673,7 @@ audioopen(dev_t dev, int flags, int ifmt
 {
 	struct audio_softc *sc;
 	struct psref sc_ref;
+	int bound;
 	int error;
 
 	/* Find the device */
@@ -1686,6 +1681,7 @@ audioopen(dev_t dev, int flags, int ifmt
 	if (sc == NULL || sc->hw_if == NULL)
 		return ENXIO;
 
+	bound = curlwp_bind();
 	audio_sc_acquire_foropen(sc, _ref);
 
 	error = audio_exlock_enter(sc);
@@ -1712,6 +1708,7 @@ audioopen(dev_t dev, int flags, int ifmt
 
 done:
 	audio_sc_release(sc, _ref);
+	curlwp_bindx(bound);
 	return error;
 }
 
@@ -1721,6 +1718,7 @@ audioclose(struct file *fp)
 	struct audio_softc *sc;
 	struct psref sc_ref;
 	audio_file_t *file;
+	int bound;
 	int error;
 	dev_t dev;
 
@@ -1736,6 +1734,7 @@ audioclose(struct file *fp)
 	 * - free all memory objects, regardless of sc.
 	 */
 
+	bound = curlwp_bind();
 	sc = audio_sc_acquire_fromfile(file, _ref);
 	if (sc) {
 		switch (AUDIODEV(dev)) {
@@ -1756,6 +1755,7 @@ audioclose(struct file *fp)
 
 		audio_sc_release(sc, _ref);
 	}
+	curlwp_bindx(bound);
 
 	/* Free memory objects anyway */
 	TRACEF(2, file, "free memory");
@@ -1776,6 +1776,7 @@ audioread(struct file *fp, off_t *offp, 
 	struct audio_softc *sc;
 	struct psref sc_ref;
 	audio_file_t *file;
+	int bound;
 	int error;
 	dev_t dev;
 
@@ -1783,9 +1784,12 @@ audioread(struct file *fp, off_t *offp, 
 	file = fp->f_audioctx;
 	dev = file->dev;
 
+	bound = curlwp_bind();
 	sc = audio_sc_acquire_fromfile(file, _ref);
-	if (sc == NULL)
-		return EIO;
+	if (sc == NULL) {
+		error = EIO;
+		goto done;
+	}
 
 	if (fp->f_flag & O_NONBLOCK)
 		ioflag |= IO_NDELAY;
@@ -1805,6 +1809,8 @@ audioread(struct file *fp, off_t *offp, 
 	}
 
 	audio_sc_release(sc, _ref);
+done:
+	curlwp_bindx(bound);
 	return error;
 }
 
@@ -1815,6 +1821,7 @@ audiowrite(struct file *fp, off_t *offp,
 	struct audio_softc *sc;
 	struct psref sc_ref;
 	audio_file_t *file;
+	int bound;
 	int error;
 	dev_t dev;
 
@@ -1822,9 +1829,12 @@ audiowrite(struct file *fp, off_t *offp,
 	file = fp->f_audioctx;
 	dev = file->dev;
 
+	bound = curlwp_bind();
 	sc = audio_sc_acquire_fromfile(file, _ref);
-	if (sc == NULL)
-		return EIO;
+	if (sc == NULL) {
+		error = EIO;
+		goto done;
+	}
 
 	if (fp->f_flag & O_NONBLOCK)
 		ioflag |= IO_NDELAY;
@@ -1844,6 +1854,8 @@ audiowrite(struct file *fp, off_t *offp,
 	}
 
 	audio_sc_release(sc, _ref);
+done:
+	curlwp_bindx(bound);
 	return error;
 }
 
@@ -1854,6 +1866,7 @@ audioioctl(struct file *fp, u_long cmd, 
 	struct psref sc_ref;
 	audio_file_t *file;
 	struct lwp *l = curlwp;
+	int bound;
 	int error;
 	dev_t dev;
 
@@ -1861,9 +1874,12 @@ audioioctl(struct file *fp, u_long cmd, 
 	file = fp->f_audioctx;
 	dev = file->dev;
 
+	bound = curlwp_bind();
 	sc = audio_sc_acquire_fromfile(file, _ref);
-	if (sc == NULL)
-		return EIO;
+	if (sc == NULL) {
+		error = EIO;
+		goto done;
+	}
 
 	switch (AUDIODEV(dev)) {
 	case SOUND_DEVICE:
@@ -1887,6 +1903,8 @@ audioioctl(struct file *fp, u_long cmd, 
 	}
 
 	audio_sc_release(sc, _ref);
+done:
+	curlwp_bindx(bound);
 	return error;
 }
 
@@ -1896,14 +1914,20 @@ audiostat(struct file *fp, struct stat *
 	struct audio_softc *sc;
 	struct psref sc_ref;
 	audio_file_t *file;
+	int bound;
+	int error;
 
 	KASSERT(fp->f_audioctx);
 	file = fp->f_audioctx;
 
+	bound = curlwp_bind();
 	sc = audio_sc_acquire_fromfile(file, _ref);
-	if (sc == NULL)
-		return EIO;
+	if (sc == NULL) {
+		error = EIO;
+		goto done;
+	}
 
+	

CVS commit: src/tests/usr.bin/nbperf

2021-02-13 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sun Feb 14 01:27:33 UTC 2021

Modified Files:
src/tests/usr.bin/nbperf: t_nbperf.sh

Log Message:
Adjust test cases to hit the fudge case after the changes in nbperf
itself.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/nbperf/t_nbperf.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/usr.bin/nbperf/t_nbperf.sh
diff -u src/tests/usr.bin/nbperf/t_nbperf.sh:1.4 src/tests/usr.bin/nbperf/t_nbperf.sh:1.5
--- src/tests/usr.bin/nbperf/t_nbperf.sh:1.4	Thu Jan  7 16:03:08 2021
+++ src/tests/usr.bin/nbperf/t_nbperf.sh	Sun Feb 14 01:27:33 2021
@@ -1,4 +1,4 @@
-# $NetBSD: t_nbperf.sh,v 1.4 2021/01/07 16:03:08 joerg Exp $
+# $NetBSD: t_nbperf.sh,v 1.5 2021/02/14 01:27:33 joerg Exp $
 #
 # Copyright (c) 2012 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -62,17 +62,17 @@ chm_fudged_head()
 }
 chm_fudged_body()
 {
-	seq 0 9 > reference.txt
-	seq 1 10 > input.txt
+	seq 0 11 > reference.txt
+	seq 1 12 > input.txt
 
 	atf_check -o file:reference.txt \
 	$(atf_get_srcdir)/h_nbperf input.txt "chm -p" cat \
-	10 $(atf_get_srcdir)/hash_driver.c
+	12 $(atf_get_srcdir)/hash_driver.c
 	atf_check -s exit:1 fgrep -q '^=' hash.c
 
 	atf_check -o file:reference.txt \
 	$(atf_get_srcdir)/h_nbperf input.txt "chm -f -p" cat \
-	10 $(atf_get_srcdir)/hash_driver.c
+	12 $(atf_get_srcdir)/hash_driver.c
 	atf_check -s exit:0 fgrep -q '^=' hash.c
 }
 chm_fudged_clean()
@@ -163,17 +163,17 @@ bpz_fudged_head()
 }
 bpz_fudged_body()
 {
-	seq 0 9 > reference.txt
-	seq 1 10 > input.txt
+	seq 0 11 > reference.txt
+	seq 1 12 > input.txt
 
 	atf_check -o file:reference.txt \
 	$(atf_get_srcdir)/h_nbperf input.txt "bpz -p" "sort -n" \
-	10 $(atf_get_srcdir)/hash_driver.c
+	12 $(atf_get_srcdir)/hash_driver.c
 	atf_check -s exit:1 fgrep -q '^=' hash.c
 
 	atf_check -o file:reference.txt \
 	$(atf_get_srcdir)/h_nbperf input.txt "bpz -f -p" "sort -n" \
-	10 $(atf_get_srcdir)/hash_driver.c
+	12 $(atf_get_srcdir)/hash_driver.c
 	atf_check -s exit:0 fgrep -q '^= (' hash.c
 	atf_check -s exit:0 fgrep -q '^= 2' hash.c
 }



CVS commit: src/tests/lib/libcurses/tests

2021-02-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 13 22:19:47 UTC 2021

Modified Files:
src/tests/lib/libcurses/tests: addbytes

Log Message:
tests/libcurses: note that addbytes is not part of the API

https://mail-index.netbsd.org/source-changes-d/2021/02/13/msg013199.html


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libcurses/tests/addbytes

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

Modified files:

Index: src/tests/lib/libcurses/tests/addbytes
diff -u src/tests/lib/libcurses/tests/addbytes:1.1 src/tests/lib/libcurses/tests/addbytes:1.2
--- src/tests/lib/libcurses/tests/addbytes:1.1	Sat Feb 13 06:29:45 2021
+++ src/tests/lib/libcurses/tests/addbytes	Sat Feb 13 22:19:47 2021
@@ -1,6 +1,9 @@
-# $NetBSD: addbytes,v 1.1 2021/02/13 06:29:45 rillig Exp $
+# $NetBSD: addbytes,v 1.2 2021/02/13 22:19:47 rillig Exp $
 #
 # Tests adding bytes to stdscr.
+#
+# Note that addbytes is not part of the official curses API, it is merely
+# an internal helper function.
 
 include start
 



CVS commit: src/tests/lib/libcurses/slave

2021-02-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 13 19:23:11 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: commands.c

Log Message:
tests/libcurses: protect against short writes

The previous code only errored out if a write failed completely.  If it
was partially written, the program continued without writing the rest of
it.

Extract the common code into a few functions that write raw data to the
parent process.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/tests/lib/libcurses/slave/commands.c

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

Modified files:

Index: src/tests/lib/libcurses/slave/commands.c
diff -u src/tests/lib/libcurses/slave/commands.c:1.12 src/tests/lib/libcurses/slave/commands.c:1.13
--- src/tests/lib/libcurses/slave/commands.c:1.12	Sat Feb 13 08:14:46 2021
+++ src/tests/lib/libcurses/slave/commands.c	Sat Feb 13 19:23:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: commands.c,v 1.12 2021/02/13 08:14:46 rillig Exp $	*/
+/*	$NetBSD: commands.c,v 1.13 2021/02/13 19:23:11 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -42,8 +42,7 @@
 
 extern int initdone;
 
-static void report_type(data_enum_t);
-static void report_message(int, const char *);
+static void report_message(data_enum_t, const char *);
 
 /*
  * Match the passed command string and execute the associated test
@@ -85,6 +84,29 @@ command_execute(char *func, int nargs, c
 	report_status("UNKNOWN_FUNCTION");
 }
 
+static void
+write_to_director(const void *mem, size_t size)
+{
+	ssize_t nwritten = write(to_director, mem, size);
+	if (nwritten == -1)
+		err(1, "writing to director failed");
+	if ((size_t)nwritten != size)
+		err(1, "short write to director, expected %zu, got %zd",
+		size, nwritten);
+}
+
+static void
+write_to_director_int(int i)
+{
+	write_to_director(, sizeof i);
+}
+
+static void
+write_to_director_type(data_enum_t return_type)
+{
+	write_to_director_int(return_type);
+}
+
 /*
  * Report an pointer value back to the director
  */
@@ -121,9 +143,9 @@ void
 report_return(int status)
 {
 	if (status == ERR)
-		report_type(data_err);
+		write_to_director_type(data_err);
 	else if (status == OK)
-		report_type(data_ok);
+		write_to_director_type(data_ok);
 	else if (status == KEY_CODE_YES)
 		report_int(status);
 	else
@@ -131,33 +153,13 @@ report_return(int status)
 }
 
 /*
- * Report the type back to the director via the command pipe
- */
-static void
-report_type(data_enum_t return_type)
-{
-	int type;
-
-	type = return_type;
-	if (write(to_director, , sizeof(int)) < 0)
-		err(1, "command pipe write for status type failed");
-
-}
-
-/*
  * Report the number of returns back to the director via the command pipe
  */
 void
 report_count(int count)
 {
-	int type;
-
-	type = data_count;
-	if (write(to_director, , sizeof(int)) < 0)
-		err(1, "command pipe write for count type failed");
-
-	if (write(to_director, , sizeof(int)) < 0)
-		err(1, "command pipe write for count");
+	write_to_director_type(data_count);
+	write_to_director_int(count);
 }
 
 /*
@@ -183,20 +185,12 @@ report_error(const char *status)
  * command pipe.
  */
 static void
-report_message(int type, const char *status)
+report_message(data_enum_t type, const char *status)
 {
-	int len;
-
-	len = strlen(status);
-
-	if (write(to_director, , sizeof(int)) < 0)
-		err(1, "command pipe write for message type failed");
-
-	if (write(to_director, , sizeof(int)) < 0)
-		err(1, "command pipe write for message length failed");
-
-	if (write(to_director, status, len) < 0)
-		err(1, "command pipe write of message data failed");
+	size_t len = strlen(status);
+	write_to_director_type(type);
+	write_to_director_int(len);
+	write_to_director(status, len);
 }
 
 /*
@@ -218,31 +212,17 @@ report_byte(chtype c)
 void
 report_nstr(chtype *string)
 {
-	int len, type;
+	size_t size;
 	chtype *p;
 
-	len = 0;
-	p = string;
+	for (p = string; (*p & __CHARTEXT) != 0; p++)
+		continue;
 
-	while ((*p++ & __CHARTEXT) != 0) {
-		len++;
-	}
+	size = (size_t)(p + 1 - string) * sizeof *p;
 
-	len++; /* add in the termination chtype */
-	len *= sizeof(chtype);
-
-	type = data_byte;
-	if (write(to_director, , sizeof(int)) < 0)
-		err(1, "%s: command pipe write for status type failed",
-		__func__);
-
-	if (write(to_director, , sizeof(int)) < 0)
-		err(1, "%s: command pipe write for status length failed",
-		__func__);
-
-	if (write(to_director, string, len) < 0)
-		err(1, "%s: command pipe write of status data failed",
-		__func__);
+	write_to_director_type(data_byte);
+	write_to_director_int(size);
+	write_to_director(string, size);
 }
 
 /*
@@ -251,21 +231,10 @@ report_nstr(chtype *string)
 void
 report_cchar(cchar_t c)
 {
-	int len, type;
-	len = sizeof(cchar_t);
-	type = data_cchar;
-
-	if (write(to_director, , sizeof(int)) < 0)
-		err(1, "%s: command pipe write for status type failed",
-		__func__);
-
-	if (write(to_director, , sizeof(int)) 

CVS commit: src/tests/lib/libcurses/slave

2021-02-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 13 18:24:11 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: lint.lua

Log Message:
tests/libcurses: remove unused code in linter


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libcurses/slave/lint.lua

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

Modified files:

Index: src/tests/lib/libcurses/slave/lint.lua
diff -u src/tests/lib/libcurses/slave/lint.lua:1.1 src/tests/lib/libcurses/slave/lint.lua:1.2
--- src/tests/lib/libcurses/slave/lint.lua:1.1	Fri Feb 12 20:41:37 2021
+++ src/tests/lib/libcurses/slave/lint.lua	Sat Feb 13 18:24:11 2021
@@ -1,5 +1,5 @@
 #! /usr/bin/lua
--- $NetBSD: lint.lua,v 1.1 2021/02/12 20:41:37 rillig Exp $
+-- $NetBSD: lint.lua,v 1.2 2021/02/13 18:24:11 rillig Exp $
 
 --[[
 
@@ -83,15 +83,6 @@ local function check_args(errors)
 end
 
 
-local function check_file(fname, msgs)
-  local errors = collect_errors(fname, msgs)
-  for _, err in ipairs(errors) do
-print(err)
-  end
-  return #errors == 0
-end
-
-
 local function main(arg)
   local errors = new_errors()
   check_args(errors)



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

2021-02-13 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Sat Feb 13 18:13:54 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64: pmap.c

Log Message:
No assignment is needed here.

the loop in pmap_page_remove() always removes the first pv,
and since the list is managed by _pmap_remove_pv(), pp->pp_pv.pv_next always 
points to the first.


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/sys/arch/aarch64/aarch64/pmap.c

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

Modified files:

Index: src/sys/arch/aarch64/aarch64/pmap.c
diff -u src/sys/arch/aarch64/aarch64/pmap.c:1.101 src/sys/arch/aarch64/aarch64/pmap.c:1.102
--- src/sys/arch/aarch64/aarch64/pmap.c:1.101	Mon Feb  1 18:12:11 2021
+++ src/sys/arch/aarch64/aarch64/pmap.c	Sat Feb 13 18:13:53 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.101 2021/02/01 18:12:11 ryo Exp $	*/
+/*	$NetBSD: pmap.c,v 1.102 2021/02/13 18:13:53 ryo Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.101 2021/02/01 18:12:11 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.102 2021/02/13 18:13:53 ryo Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -2237,7 +2237,7 @@ pmap_page_remove(struct pmap_page *pp, v
 			KASSERT(pv == >pp_pv);
 		} else {
 			KASSERT(pv == pvtmp);
-			pp->pp_pv.pv_next = pv->pv_next;
+			KASSERT(pp->pp_pv.pv_next == pv->pv_next);
 			pv->pv_next = pvtofree;
 			pvtofree = pv;
 		}



CVS commit: src/tests/lib/libcurses

2021-02-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 13 16:43:12 UTC 2021

Modified Files:
src/tests/lib/libcurses: atf.terminfo

Log Message:
tests/libcurses: use ASCII only in terminfo description


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libcurses/atf.terminfo

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

Modified files:

Index: src/tests/lib/libcurses/atf.terminfo
diff -u src/tests/lib/libcurses/atf.terminfo:1.2 src/tests/lib/libcurses/atf.terminfo:1.3
--- src/tests/lib/libcurses/atf.terminfo:1.2	Sat Feb 13 16:38:02 2021
+++ src/tests/lib/libcurses/atf.terminfo	Sat Feb 13 16:43:12 2021
@@ -1,4 +1,4 @@
-# $NetBSD: atf.terminfo,v 1.2 2021/02/13 16:38:02 rillig Exp $
+# $NetBSD: atf.terminfo,v 1.3 2021/02/13 16:43:12 rillig Exp $
 #
 # Based on xterm capabilities
 #
@@ -29,12 +29,12 @@ atf|Automated Test Framework pseudo term
 	csr=csr%i%p1%d;%p2%dX,
 	cub=cub%p1%dX,		cub1=^H,
 	cud=cud%p1%dX,		cud1=^J,
-	cuf=cuf%p1%dX,		cuf1=,
+	cuf=cuf%p1%dX,		cuf1=^F,
 	cup=cup%i%p1%d;%p2%dX,
-	cuu=cuu%p1%dX,		cuu1=,
+	cuu=cuu%p1%dX,		cuu1=^U,
 	cvvis=cvvis,
-	dch=dch%p1%dX,		dch1=,
-	dl=dl%p1%dX,		dl1=,
+	dch=dch%p1%dX,		dch1=^D,
+	dl=dl%p1%dX,		dl1=^K,
 	dim=dim,
 	ech=ech%p1%dX,
 	ed=ed,



CVS commit: src/tests/lib/libcurses

2021-02-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 13 16:38:02 UTC 2021

Modified Files:
src/tests/lib/libcurses: atf.terminfo

Log Message:
tests/libcurses: split terminfo entry over more lines

This provides space to see each capability on its own, instead of having
to search them in the blob of text.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libcurses/atf.terminfo

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

Modified files:

Index: src/tests/lib/libcurses/atf.terminfo
diff -u src/tests/lib/libcurses/atf.terminfo:1.1 src/tests/lib/libcurses/atf.terminfo:1.2
--- src/tests/lib/libcurses/atf.terminfo:1.1	Sun Apr 10 09:55:08 2011
+++ src/tests/lib/libcurses/atf.terminfo	Sat Feb 13 16:38:02 2021
@@ -1,44 +1,134 @@
+# $NetBSD: atf.terminfo,v 1.2 2021/02/13 16:38:02 rillig Exp $
+#
 # Based on xterm capabilities
-atf|atf automatic test frame pseudo terminal,
-	am, bce, ccc, km, mc5i, mir, msgr, npc, xenl,
-	colors#8, cols#80, it#8, lines#24, pairs#64,
+#
+atf|Automated Test Framework pseudo terminal,
+	am,
+	bce,
+	ccc,
+	km,
+	mc5i,
+	mir,
+	msgr,
+	npc,
+	xenl,
+	colors#8,
+	cols#80,
+	it#8,
+	lines#24,
+	pairs#64,
 	acsc=++\,\,--..00``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=bel, blink=blink, bold=bold, cbt=cbt, civis=civis, clear=clear,
-	cnorm=cnorm, cr=^M, csr=csr%i%p1%d;%p2%dX, cub=cub%p1%dX,
-	cub1=^H, cud=cud%p1%dX, cud1=^J, cuf=cuf%p1%dX, cuf1=,
-	cup=cup%i%p1%d;%p2%dX, cuu=cuu%p1%dX, cuu1=, cvvis=cvvis,
-	dch=dch%p1%dX, dch1=, dl=dl%p1%dX, dl1=, dim=dim, ech=ech%p1%dX,
-	ed=ed, el=el, el1=el1, enacs=enacs, flash=flash, home=home,
-	hpa=hpa%i%p1%dX, ht=^I, hts=hts, ich=ich%p1%dX, il=il%p1%dX,
-	il1=il1, ind=^M, indn=indn%p1%dX, invis=invis,
-	is2=is2, kDC=\E[3;2~, kEND=\E[1;2F, kHOM=\E[1;2H,
-	kIC=\E[2;2~, kLFT=\E[1;2D, kNXT=\E[6;2~, kPRV=\E[5;2~,
-	kRIT=\E[1;2C, kb2=\EOE, kbs=^H, kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB,
-	kcuf1=\EOC, kcuu1=\EOA, kdch1=\E[3~, kend=\EOF, kent=\EOM,
-	kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[1;2P,
-	kf14=\E[1;2Q, kf15=\E[1;2R, kf16=\E[1;2S, kf17=\E[15;2~,
-	kf18=\E[17;2~, kf19=\E[18;2~, kf2=\EOQ, kf20=\E[19;2~,
-	kf21=\E[20;2~, kf22=\E[21;2~, kf23=\E[23;2~, kf24=\E[24;2~,
-	kf25=\E[1;5P, kf26=\E[1;5Q, kf27=\E[1;5R, kf28=\E[1;5S,
-	kf29=\E[15;5~, kf3=\EOR, kf30=\E[17;5~, kf31=\E[18;5~,
-	kf32=\E[19;5~, kf33=\E[20;5~, kf34=\E[21;5~, kf35=\E[23;5~,
-	kf36=\E[24;5~, kf37=\E[1;6P, kf38=\E[1;6Q, kf39=\E[1;6R, kf4=\EOS,
-	kf40=\E[1;6S, kf41=\E[15;6~, kf42=\E[17;6~, kf43=\E[18;6~,
-	kf44=\E[19;6~, kf45=\E[20;6~, kf46=\E[21;6~, kf47=\E[23;6~,
-	kf48=\E[24;6~, kf49=\E[1;3P, kf5=\E[15~, kf50=\E[1;3Q,
-	kf51=\E[1;3R, kf52=\E[1;3S, kf53=\E[15;3~, kf54=\E[17;3~,
-	kf55=\E[18;3~, kf56=\E[19;3~, kf57=\E[20;3~, kf58=\E[21;3~,
-	kf59=\E[23;3~, kf6=\E[17~, kf60=\E[24;3~, kf61=\E[1;4P,
-	kf62=\E[1;4Q, kf63=\E[1;4R, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
-	khome=\EOH, kich1=\E[2~, kind=\E[1;2B, kmous=\E[M, knp=\E[6~,
-	kpp=\E[5~, kri=\E[1;2A, mc0=mc0, mc4=mc4, mc5=mc5,
-	op=op, rc=rc, rev=rev, ri=ri, rin=rin%p1%dX, rmacs=rmacs,
-	rmam=rmam, rmcup=rmcup, rmir=rmir, rmkx=rmkx,
-	rmm=rmm, rmso=rmso, rmul=rmul, rs1=rs1,
-	rs2=rs2, sc=sc, setab=setab%p1%dX,
-	setaf=setaf%p1%dX, setb=setb%p1%dX, setf=setf%p1%dX,
+	bel=bel,
+	blink=blink,
+	bold=bold,
+	cbt=cbt,
+	civis=civis,
+	clear=clear,
+	cnorm=cnorm,
+	cr=^M,
+	csr=csr%i%p1%d;%p2%dX,
+	cub=cub%p1%dX,		cub1=^H,
+	cud=cud%p1%dX,		cud1=^J,
+	cuf=cuf%p1%dX,		cuf1=,
+	cup=cup%i%p1%d;%p2%dX,
+	cuu=cuu%p1%dX,		cuu1=,
+	cvvis=cvvis,
+	dch=dch%p1%dX,		dch1=,
+	dl=dl%p1%dX,		dl1=,
+	dim=dim,
+	ech=ech%p1%dX,
+	ed=ed,
+	el=el,
+	el1=el1,
+	enacs=enacs,
+	flash=flash,
+	home=home,
+	hpa=hpa%i%p1%dX,
+	ht=^I,
+	hts=hts,
+	ich=ich%p1%dX,
+	il=il%p1%dX, il1=il1,
+	ind=^M,
+	indn=indn%p1%dX,
+	invis=invis,
+	is2=is2,
+	kDC=\E[3;2~,
+	kEND=\E[1;2F,
+	kHOM=\E[1;2H,
+	kIC=\E[2;2~,
+	kLFT=\E[1;2D,
+	kNXT=\E[6;2~,
+	kPRV=\E[5;2~,
+	kRIT=\E[1;2C,
+	kb2=\EOE,
+	kbs=^H,
+	kcbt=\E[Z,
+	kcub1=\EOD,
+	kcud1=\EOB,
+	kcuf1=\EOC,
+	kcuu1=\EOA,
+	kdch1=\E[3~,
+	kend=\EOF,
+	kent=\EOM,
+	kf1=\EOP,	kf2=\EOQ,	kf3=\EOR,	kf4=\EOS,
+	kf5=\E[15~,	kf6=\E[17~,	kf7=\E[18~,	kf8=\E[19~,
+	kf9=\E[20~,	kf10=\E[21~,	kf11=\E[23~,	kf12=\E[24~,
+	kf13=\E[1;2P,	kf14=\E[1;2Q,	kf15=\E[1;2R,	kf16=\E[1;2S,
+	kf17=\E[15;2~,	kf18=\E[17;2~,	kf19=\E[18;2~,	kf20=\E[19;2~,
+	kf21=\E[20;2~,	kf22=\E[21;2~,	kf23=\E[23;2~,	kf24=\E[24;2~,
+	kf25=\E[1;5P,	kf26=\E[1;5Q,	kf27=\E[1;5R,	kf28=\E[1;5S,
+	kf29=\E[15;5~,	kf30=\E[17;5~,	kf31=\E[18;5~,	kf32=\E[19;5~,
+	kf33=\E[20;5~,	kf34=\E[21;5~,	kf35=\E[23;5~,	kf36=\E[24;5~,
+	kf37=\E[1;6P,	kf38=\E[1;6Q,	kf39=\E[1;6R,	kf40=\E[1;6S,
+	kf41=\E[15;6~,	kf42=\E[17;6~,	kf43=\E[18;6~,	kf44=\E[19;6~,
+	kf45=\E[20;6~,	kf46=\E[21;6~,	kf47=\E[23;6~,	kf48=\E[24;6~,
+	kf49=\E[1;3P,	kf50=\E[1;3Q,	kf51=\E[1;3R,	kf52=\E[1;3S,
+	kf53=\E[15;3~,	kf54=\E[17;3~,	kf55=\E[18;3~,	kf56=\E[19;3~,
+	kf57=\E[20;3~,	kf58=\E[21;3~,	

CVS commit: src/sys/dev/pci

2021-02-13 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sat Feb 13 16:33:30 UTC 2021

Modified Files:
src/sys/dev/pci: if_bnx.c if_bnxreg.h

Log Message:
Curb aprint_*() abuse in bnx(4)


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/sys/dev/pci/if_bnx.c
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/pci/if_bnxreg.h

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

Modified files:

Index: src/sys/dev/pci/if_bnx.c
diff -u src/sys/dev/pci/if_bnx.c:1.106 src/sys/dev/pci/if_bnx.c:1.107
--- src/sys/dev/pci/if_bnx.c:1.106	Sat Feb 13 01:51:24 2021
+++ src/sys/dev/pci/if_bnx.c	Sat Feb 13 16:33:30 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bnx.c,v 1.106 2021/02/13 01:51:24 jakllsch Exp $	*/
+/*	$NetBSD: if_bnx.c,v 1.107 2021/02/13 16:33:30 jakllsch Exp $	*/
 /*	$OpenBSD: if_bnx.c,v 1.101 2013/03/28 17:21:44 brad Exp $	*/
 
 /*-
@@ -35,7 +35,7 @@
 #if 0
 __FBSDID("$FreeBSD: src/sys/dev/bce/if_bce.c,v 1.3 2006/04/13 14:12:26 ru Exp $");
 #endif
-__KERNEL_RCSID(0, "$NetBSD: if_bnx.c,v 1.106 2021/02/13 01:51:24 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bnx.c,v 1.107 2021/02/13 16:33:30 jakllsch Exp $");
 
 /*
  * The following controllers are supported by this driver:
@@ -923,10 +923,8 @@ bnx_attach(device_t parent, device_t sel
 	sc->bnx_intrhand = pci_intr_establish_xname(pc, sc->bnx_ih[0], IPL_NET,
 	bnx_intr, sc, device_xname(self));
 	if (sc->bnx_intrhand == NULL) {
-		aprint_error_dev(self, "couldn't establish interrupt");
-		if (intrstr != NULL)
-			aprint_error(" at %s", intrstr);
-		aprint_error("\n");
+		aprint_error_dev(self, "couldn't establish interrupt%s%s\n",
+		intrstr ? " at " : "", intrstr ? intrstr : "");
 		goto bnx_attach_fail;
 	}
 	aprint_normal_dev(sc->bnx_dev, "interrupting at %s\n", intrstr);
@@ -3991,7 +3989,7 @@ bnx_get_buf(struct bnx_softc *sc, uint16
 
 	/* Make sure the inputs are valid. */
 	DBRUNIF((*chain_prod > MAX_RX_BD),
-	aprint_error_dev(sc->bnx_dev,
+	device_printf(sc->bnx_dev,
 		"RX producer out of range: 0x%04X > 0x%04X\n",
 		*chain_prod, (uint16_t)MAX_RX_BD));
 
@@ -4007,7 +4005,7 @@ bnx_get_buf(struct bnx_softc *sc, uint16
 	while (sc->free_rx_bd >= min_free_bd) {
 		/* Simulate an mbuf allocation failure. */
 		DBRUNIF(DB_RANDOMTRUE(bnx_debug_mbuf_allocation_failure),
-		aprint_error_dev(sc->bnx_dev,
+		device_printf(sc->bnx_dev,
 		"Simulating mbuf allocation failure.\n");
 			sc->mbuf_sim_alloc_failed++;
 			rc = ENOBUFS;
@@ -4260,7 +4258,7 @@ bnx_free_tx_chain(struct bnx_softc *sc)
 
 	/* Check if we lost any mbufs in the process. */
 	DBRUNIF((sc->tx_mbuf_alloc),
-	aprint_error_dev(sc->bnx_dev,
+	device_printf(sc->bnx_dev,
 		"Memory leak! Lost %d mbufs from tx chain!\n",
 		sc->tx_mbuf_alloc));
 
@@ -4415,7 +4413,7 @@ bnx_free_rx_chain(struct bnx_softc *sc)
 
 	/* Check if we lost any mbufs in the process. */
 	DBRUNIF((sc->rx_mbuf_alloc),
-	aprint_error_dev(sc->bnx_dev,
+	device_printf(sc->bnx_dev,
 		"Memory leak! Lost %d mbufs from rx chain!\n",
 		sc->rx_mbuf_alloc));
 
@@ -4589,7 +4587,7 @@ bnx_rx_intr(struct bnx_softc *sc)
 		rxbd = >rx_bd_chain[RX_PAGE(sw_chain_cons)][RX_IDX(sw_chain_cons)];
 		sc->free_rx_bd++;
 
-		DBRUN(BNX_VERBOSE_RECV, aprint_error("%s(): ", __func__);
+		DBRUN(BNX_VERBOSE_RECV, printf("%s(): ", __func__);
 		bnx_dump_rxbd(sc, sw_chain_cons, rxbd));
 
 		/* The mbuf is stored with the last rx_bd entry of a packet. */
@@ -4650,13 +4648,13 @@ bnx_rx_intr(struct bnx_softc *sc)
 			status = l2fhdr->l2_fhdr_status;
 
 			DBRUNIF(DB_RANDOMTRUE(bnx_debug_l2fhdr_status_check),
-			aprint_error("Simulating l2_fhdr status error.\n");
+			printf("Simulating l2_fhdr status error.\n");
 			status = status | L2_FHDR_ERRORS_PHY_DECODE);
 
 			/* Watch for unusual sized frames. */
 			DBRUNIF(((len < BNX_MIN_MTU) ||
 			(len > BNX_MAX_JUMBO_ETHER_MTU_VLAN)),
-			aprint_error_dev(sc->bnx_dev,
+			device_printf(sc->bnx_dev,
 "Unusual frame size found. "
 "Min(%d), Actual(%d), Max(%d)\n",
 (int)BNX_MIN_MTU, len,
@@ -4697,7 +4695,7 @@ bnx_rx_intr(struct bnx_softc *sc)
 			 */
 			if (bnx_get_buf(sc, _prod, _chain_prod,
 			_prod_bseq)) {
-DBRUN(BNX_WARN, aprint_debug_dev(sc->bnx_dev,
+DBRUN(BNX_WARN, device_printf(sc->bnx_dev,
 "Failed to allocate "
 "new mbuf, incoming frame dropped!\n"));
 
@@ -4728,7 +4726,7 @@ bnx_rx_intr(struct bnx_softc *sc)
 			DBRUN(BNX_VERBOSE_RECV,
 			struct ether_header *eh;
 			eh = mtod(m, struct ether_header *);
-			aprint_error("%s: to: %s, from: %s, type: 0x%04X\n",
+			printf("%s: to: %s, from: %s, type: 0x%04X\n",
 			__func__, ether_sprintf(eh->ether_dhost),
 			ether_sprintf(eh->ether_shost),
 			htons(eh->ether_type)));
@@ -4868,7 +4866,7 @@ bnx_tx_intr(struct bnx_softc *sc)
 		__func__, hw_tx_cons, sw_tx_cons, sw_tx_chain_cons);
 
 		DBRUNIF((sw_tx_chain_cons > MAX_TX_BD),
-		

CVS commit: src/sys/external/bsd/drm2/via

2021-02-13 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sat Feb 13 15:42:15 UTC 2021

Modified Files:
src/sys/external/bsd/drm2/via: via_pci.c

Log Message:
Add aprint_*() newlines for viadrmums(4) attach

>From Andrius V in kern/55884


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/external/bsd/drm2/via/via_pci.c

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

Modified files:

Index: src/sys/external/bsd/drm2/via/via_pci.c
diff -u src/sys/external/bsd/drm2/via/via_pci.c:1.4 src/sys/external/bsd/drm2/via/via_pci.c:1.5
--- src/sys/external/bsd/drm2/via/via_pci.c:1.4	Mon Jul 20 21:29:38 2020
+++ src/sys/external/bsd/drm2/via/via_pci.c	Sat Feb 13 15:42:15 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: via_pci.c,v 1.4 2020/07/20 21:29:38 riastradh Exp $	*/
+/*	$NetBSD: via_pci.c,v 1.5 2021/02/13 15:42:15 jakllsch Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: via_pci.c,v 1.4 2020/07/20 21:29:38 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: via_pci.c,v 1.5 2021/02/13 15:42:15 jakllsch Exp $");
 
 #include 
 #include 
@@ -116,6 +116,9 @@ viadrm_attach(device_t parent, device_t 
 
 	KASSERT(cookiep != NULL);
 
+	aprint_naive("\n");
+	aprint_normal("\n");
+
 	if (!pmf_device_register(self, NULL, NULL))
 		aprint_error_dev(self, "couldn't establish power handler\n");
 



CVS commit: src/usr.sbin/sysinst

2021-02-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Feb 13 15:31:36 UTC 2021

Modified Files:
src/usr.sbin/sysinst: bsddisklabel.c

Log Message:
PR 55991: when extending the marked partition (typically: the NetBSD root
partition) round the new size up to current alignment.

This may lead to a slightly smaller than initialy planned last partition
(depending on order added) if the disk size is odd or the partitioning
scheme needs some internal space (like GPT) - but it avoids gaps elsewhere
due to alignement.

Ideally we would pin all other partitions in a first pass and then let
the partitioning backend pick the full available size for the extended
partition, but this should be good enough.


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

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

Modified files:

Index: src/usr.sbin/sysinst/bsddisklabel.c
diff -u src/usr.sbin/sysinst/bsddisklabel.c:1.57 src/usr.sbin/sysinst/bsddisklabel.c:1.58
--- src/usr.sbin/sysinst/bsddisklabel.c:1.57	Sun Jan 31 22:45:46 2021
+++ src/usr.sbin/sysinst/bsddisklabel.c	Sat Feb 13 15:31:35 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: bsddisklabel.c,v 1.57 2021/01/31 22:45:46 rillig Exp $	*/
+/*	$NetBSD: bsddisklabel.c,v 1.58 2021/02/13 15:31:35 martin Exp $	*/
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -1387,6 +1387,8 @@ apply_settings_to_partitions(struct disk
 	 * Pass one: calculate space available for expanding
 	 * the marked partition.
 	 */
+	if (parts->free_space != parts->disk_size)
+		planned_space = align;	/* align first part */
 	for (i = 0; i < wanted->num; i++) {
 		if ((wanted->infos[i].flags & PUIFLAG_EXTEND) &&
 		exp_ndx == ~0U)
@@ -1403,8 +1405,9 @@ apply_settings_to_partitions(struct disk
 			if (!(wanted->infos[i].flags & PUIFLG_IS_OUTER))
 nsp -= infos[i].size;
 		}
-		if (nsp > 0)
-			planned_space += roundup(nsp, align);
+		if (nsp <= 0)
+			continue;
+		planned_space += roundup(nsp, align);
 	}
 
 	/*
@@ -1412,12 +1415,10 @@ apply_settings_to_partitions(struct disk
 	 * but check size limits.
 	 */
 	if (exp_ndx < wanted->num) {
-		daddr_t free_space =
-		parts->free_space - roundup(wanted->reserved_space, align);
-		free_space -= planned_space;
+		daddr_t free_space = parts->free_space - planned_space;
 		daddr_t new_size = wanted->infos[exp_ndx].size;
 		if (free_space > 0)
-			new_size += free_space;
+			new_size += roundup(free_space,align);
 
 		if (wanted->infos[exp_ndx].limit > 0 &&
 		(new_size + wanted->infos[exp_ndx].cur_start)



CVS commit: src

2021-02-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 13 14:30:37 UTC 2021

Modified Files:
src/lib/libcurses: addbytes.c
src/tests/lib/libcurses/check_files: addch.chk
src/tests/lib/libcurses/tests: addch

Log Message:
libcurses: fix wrong tab width for addch

In sysinst, the installation screen is indented with tabs.  Sysinst uses
msgc, which brings its own text layout engine.  This engine does not use
addbytes but addch.  In addch, the x position for each tab was advanced
twice as much as needed.  The menu items were thus not indented by 8
spaces but by 16, which caused an ugly line break in the German
translation.

This bug largely went unnoticed because most other applications use
addbytes instead, which worked fine all the time.  It had been
introduced somewhere between NetBSD 8.0 and NetBSD 9.0.

The code around this bug used aliased variables for win->curx and
win->cury a lot.  Getting this right is difficult and needs a thorough
test suite.  Even though libcurses has 201 tests, that is not nearly
enough to cover all the relations between the various functions in
libcurses that call each other, crossing API boundaries from internal
to external, doing character conversions on the way and juggling around
4 different types of characters (char, wchar_t, chtype, cchar_t).

The simplest fix was to remove all this aliasing, while keeping the
API the same.  If _cursesi_waddbytes is not considered part of the API,
it would be possible to replace px with win->curx in all places, same
for py and win->cury.

The complicated code with the aliasing may have been meant for
performance reasons, but it's hard to see any advantage if both points
of truth need to be synchronized all the time.

Libcurses can be built in 2 modes: with wide character support or
without (-DDISABLE_WCHAR).  The test suite only covers the variant with
wide characters.  The single-byte variant has to be tested manually.
Running sysinst with the single-byte libcurses produces the correct
layout.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/lib/libcurses/addbytes.c
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libcurses/check_files/addch.chk
cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libcurses/tests/addch

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

Modified files:

Index: src/lib/libcurses/addbytes.c
diff -u src/lib/libcurses/addbytes.c:1.53 src/lib/libcurses/addbytes.c:1.54
--- src/lib/libcurses/addbytes.c:1.53	Sat Feb  6 19:41:14 2021
+++ src/lib/libcurses/addbytes.c	Sat Feb 13 14:30:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: addbytes.c,v 1.53 2021/02/06 19:41:14 rillig Exp $	*/
+/*	$NetBSD: addbytes.c,v 1.54 2021/02/13 14:30:37 rillig Exp $	*/
 
 /*
  * Copyright (c) 1987, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)addbytes.c	8.4 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: addbytes.c,v 1.53 2021/02/06 19:41:14 rillig Exp $");
+__RCSID("$NetBSD: addbytes.c,v 1.54 2021/02/13 14:30:37 rillig Exp $");
 #endif
 #endif/* not lint */
 
@@ -46,16 +46,11 @@ __RCSID("$NetBSD: addbytes.c,v 1.53 2021
 #include 
 #endif
 
-#define	SYNCH_IN	{y = win->cury; x = win->curx;}
-#define	SYNCH_OUT	{win->cury = y; win->curx = x;}
-#define	PSYNCH_IN	{*y = win->cury; *x = win->curx;}
-#define	PSYNCH_OUT	{win->cury = *y; win->curx = *x;}
-
 #ifndef _CURSES_USE_MACROS
 
 /*
  * addbytes --
- *  Add the character to the current position in stdscr.
+ *  Add the characters to the current position in stdscr.
  */
 int
 addbytes(const char *bytes, int count)
@@ -66,7 +61,7 @@ addbytes(const char *bytes, int count)
 
 /*
  * waddbytes --
- *  Add the character to the current position in the given window.
+ *  Add the characters to the current position in the given window.
  */
 int
 waddbytes(WINDOW *win, const char *bytes, int count)
@@ -111,7 +106,7 @@ __waddbytes(WINDOW *win, const char *byt
 
 /*
  * _cursesi_waddbytes --
- *	Add the character to the current position in the given window.
+ *	Add the characters to the current position in the given window.
  * if char_interp is non-zero then character interpretation is done on
  * the byte (i.e. \n to newline, \r to carriage return, \b to backspace
  * and so on).
@@ -120,7 +115,7 @@ int
 _cursesi_waddbytes(WINDOW *win, const char *bytes, int count, attr_t attr,
 	int char_interp)
 {
-	int		x, y, err;
+	int		*py = >cury, *px = >curx, err;
 	__LINE		*lp;
 #ifdef HAVE_WCHAR
 	int		n;
@@ -141,8 +136,7 @@ _cursesi_waddbytes(WINDOW *win, const ch
 #endif
 
 	err = OK;
-	SYNCH_IN;
-	lp = win->alines[y];
+	lp = win->alines[*py];
 
 #ifdef HAVE_WCHAR
 	(void)memset(, 0, sizeof(st));
@@ -152,13 +146,13 @@ _cursesi_waddbytes(WINDOW *win, const ch
 		c = *bytes++;
 #ifdef DEBUG
 		__CTRACE(__CTRACE_INPUT, "ADDBYTES('%c', %x) at (%d, %d)\n",
-		c, attr, y, x);
+		c, attr, *py, *px);
 #endif
-		err = _cursesi_addbyte(win, , , , c, attr, char_interp);
+		err = 

CVS commit: src/sys

2021-02-13 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sat Feb 13 13:00:16 UTC 2021

Modified Files:
src/sys/net: if_ethersubr.c if_gre.c
src/sys/netinet: if_arp.c

Log Message:
Prior alignment fixes should not use an offset


To generate a diff of this commit:
cvs rdiff -u -r1.290 -r1.291 src/sys/net/if_ethersubr.c
cvs rdiff -u -r1.178 -r1.179 src/sys/net/if_gre.c
cvs rdiff -u -r1.299 -r1.300 src/sys/netinet/if_arp.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_ethersubr.c
diff -u src/sys/net/if_ethersubr.c:1.290 src/sys/net/if_ethersubr.c:1.291
--- src/sys/net/if_ethersubr.c:1.290	Sat Feb 13 07:28:04 2021
+++ src/sys/net/if_ethersubr.c	Sat Feb 13 13:00:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ethersubr.c,v 1.290 2021/02/13 07:28:04 roy Exp $	*/
+/*	$NetBSD: if_ethersubr.c,v 1.291 2021/02/13 13:00:16 roy Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.290 2021/02/13 07:28:04 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.291 2021/02/13 13:00:16 roy Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -649,23 +649,19 @@ ether_input(struct ifnet *ifp, struct mb
 	if ((ifp->if_flags & IFF_UP) == 0)
 		goto drop;
 
-	/* If the Ethernet header is not aligned, slurp it up into a new
-	 * mbuf with space for link headers, in the event we forward
-	 * it.  Otherwise, if it is aligned, make sure the entire
-	 * base Ethernet header is in the first mbuf of the chain.
-	 */
+#ifdef MBUFTRACE
+	m_claimm(m, >ec_rx_mowner);
+#endif
+
+	/* Enforce alignement */
 	if (ETHER_HDR_ALIGNED_P(mtod(m, void *)) == 0) {
-		if ((m = m_copyup(m, sizeof(*eh),
-		(max_linkhdr + 3) & ~3)) == NULL)
+		if ((m = m_copyup(m, sizeof(*eh), 0)) == NULL)
 			goto dropped;
 	} else if (__predict_false(m->m_len < sizeof(*eh))) {
 		if ((m = m_pullup(m, sizeof(*eh))) == NULL)
 			goto dropped;
 	}
 
-#ifdef MBUFTRACE
-	m_claimm(m, >ec_rx_mowner);
-#endif
 	eh = mtod(m, struct ether_header *);
 	etype = ntohs(eh->ether_type);
 	ehlen = sizeof(*eh);

Index: src/sys/net/if_gre.c
diff -u src/sys/net/if_gre.c:1.178 src/sys/net/if_gre.c:1.179
--- src/sys/net/if_gre.c:1.178	Fri Feb 12 19:57:49 2021
+++ src/sys/net/if_gre.c	Sat Feb 13 13:00:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_gre.c,v 1.178 2021/02/12 19:57:49 roy Exp $ */
+/*	$NetBSD: if_gre.c,v 1.179 2021/02/13 13:00:16 roy Exp $ */
 
 /*
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -45,7 +45,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.178 2021/02/12 19:57:49 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.179 2021/02/13 13:00:16 roy Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_atalk.h"
@@ -396,14 +396,9 @@ gre_receive(struct socket *so, void *arg
 		return;
 	}
 
-	/* If the GRE header is not aligned, slurp it up into a new
-	 * mbuf with space for link headers, in the event we forward
-	 * it.  Otherwise, if it is aligned, make sure the entire
-	 * base GRE header is in the first mbuf of the chain.
-	 */
+	/* Enforce alignment */
 	if (GRE_HDR_ALIGNED_P(mtod(m, void *)) == 0) {
-		if ((m = m_copyup(m, sizeof(struct gre_h),
-		(max_linkhdr + 3) & ~3)) == NULL) {
+		if ((m = m_copyup(m, sizeof(struct gre_h), 0)) == NULL) {
 			/* XXXJRT new stat, please */
 			GRE_DPRINTF(sc, "m_copyup failed\n");
 			sc->sc_pullup_ev.ev_count++;

Index: src/sys/netinet/if_arp.c
diff -u src/sys/netinet/if_arp.c:1.299 src/sys/netinet/if_arp.c:1.300
--- src/sys/netinet/if_arp.c:1.299	Sat Feb 13 07:57:09 2021
+++ src/sys/netinet/if_arp.c	Sat Feb 13 13:00:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_arp.c,v 1.299 2021/02/13 07:57:09 roy Exp $	*/
+/*	$NetBSD: if_arp.c,v 1.300 2021/02/13 13:00:16 roy Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.299 2021/02/13 07:57:09 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.300 2021/02/13 13:00:16 roy Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -700,14 +700,9 @@ arpintr(void)
 		MCLAIM(m, _mowner);
 		ARP_STATINC(ARP_STAT_RCVTOTAL);
 
-		/* If the ARP header is not aligned, slurp it up into a new
-		 * mbuf with space for link headers, in the event we forward
-		 * it.  Otherwise, if it is aligned, make sure the entire
-		 * base ARP header is in the first mbuf of the chain.
-		 */
+		/* Enforce alignment */
 		if (ARP_HDR_ALIGNED_P(mtod(m, void *)) == 0) {
-			if ((m = m_copyup(m, sizeof(*ar),
-			(max_linkhdr + 3) & ~3)) == NULL)
+			if ((m = m_copyup(m, sizeof(*ar), 0)) == NULL)
 goto badlen;
 		} else if (__predict_false(m->m_len < sizeof(*ar))) {
 			if ((m = m_pullup(m, sizeof(*ar))) == NULL)
@@ -732,9 +727,6 @@ arpintr(void)
 ARP_STATINC(ARP_STAT_RCVBADPROTO);
 goto free;
 			}
-
-			arplen = sizeof(struct arphdr) +
-			ar->ar_hln 

CVS commit: src/lib/libcurses

2021-02-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 13 10:37:00 UTC 2021

Modified Files:
src/lib/libcurses: curses.h

Log Message:
curses.h: proofread, indent a bit more consistently


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/lib/libcurses/curses.h

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

Modified files:

Index: src/lib/libcurses/curses.h
diff -u src/lib/libcurses/curses.h:1.129 src/lib/libcurses/curses.h:1.130
--- src/lib/libcurses/curses.h:1.129	Mon Mar 23 13:37:36 2020
+++ src/lib/libcurses/curses.h	Sat Feb 13 10:37:00 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses.h,v 1.129 2020/03/23 13:37:36 roy Exp $	*/
+/*	$NetBSD: curses.h,v 1.130 2021/02/13 10:37:00 rillig Exp $	*/
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -61,14 +61,14 @@ typedef wchar_t	attr_t;
 #ifdef HAVE_WCHAR
 /*
  * The complex character structure required by the X/Open reference and used
- * in * functions such as in_wchstr(). It includes a string of up to 8 wide
+ * in functions such as in_wchstr(). It includes a string of up to 8 wide
  * characters and its length, an attribute, and a color-pair.
  */
 #define CURSES_CCHAR_MAX 8
 #define CCHARW_MAX   5
 typedef struct {
 	attr_t		attributes;		/* character attributes */
-	unsigned	elements;		/* number of wide char in
+	unsigned	elements;		/* number of wide chars in
 		   vals[] */
 	wchar_t		vals[CURSES_CCHAR_MAX]; /* wide chars including
 		   non-spacing */
@@ -86,12 +86,12 @@ typedef chtype cchar_t;
 
 #ifndef _CURSES_PRIVATE
 
-#define _puts(s)tputs(s, 0, __cputchar)
-#define _putchar(c) __cputchar(c)
+#define _puts(s)	tputs(s, 0, __cputchar)
+#define _putchar(c)	__cputchar(c)
 
 /* Old-style terminal modes access. */
-#define crmode()cbreak()
-#define nocrmode()  nocbreak()
+#define crmode()	cbreak()
+#define nocrmode()	nocbreak()
 #endif /* _CURSES_PRIVATE */
 
 
@@ -107,7 +107,7 @@ typedef chtype cchar_t;
 
 /* First function key (block of 64 follow) */
 #defineKEY_F0 0x108
-/* Function defining other function key values*/
+/* Function defining other function key values */
 #defineKEY_F(n)   (KEY_F0+(n))
 
 #defineKEY_DL 0x148/* Delete Line */
@@ -132,7 +132,7 @@ typedef chtype cchar_t;
 #defineKEY_LL 0x15B/* Home Down */
 
 /*
- * "Keypad" keys arranged like this:
+ * "Keypad" keys are arranged like this:
  *
  *  A1   up  A3
  * left  B2 right
@@ -170,7 +170,7 @@ typedef chtype cchar_t;
 #defineKEY_RESTART0x177/* Restart key */
 #defineKEY_RESUME 0x178/* Resume key */
 #defineKEY_SAVE   0x179/* Save key */
-#defineKEY_SBEG   0x17A/* Shift begin key */
+#defineKEY_SBEG   0x17A/* Shift Begin key */
 #defineKEY_SCANCEL0x17B/* Shift Cancel key */
 #defineKEY_SCOMMAND   0x17C/* Shift Command key */
 #defineKEY_SCOPY  0x17D/* Shift Copy key */
@@ -204,12 +204,12 @@ typedef chtype cchar_t;
 #defineKEY_MOUSE  0x199/* Mouse event has occurred */
 #defineKEY_RESIZE 0x200/* Resize event has occurred */
 #defineKEY_MAX0x240/* maximum extended key value */
-#defineKEY_CODE_YES   0x241/* A function key pressed */
+#defineKEY_CODE_YES   0x241/* A function key was pressed */
 
 #include 
 
 /*
- * A window an array of __LINE structures pointed to by the 'lines' pointer.
+ * A window is an array of __LINE structures pointed to by the 'lines' pointer.
  * A line is an array of __LDATA structures pointed to by the 'line' pointer.
  */
 
@@ -638,7 +638,7 @@ __END_DECLS
 	} while(0 /* CONSTCOND */)
 
 
-/* Public function prototypes. */
+/* Public functions. */
 __BEGIN_DECLS
 int	 assume_default_colors(short, short);
 int	 baudrate(void);
@@ -1034,9 +1034,9 @@ bool is_pad(const WINDOW *);
 
 typedef unsigned long mmask_t;
 typedef struct {
-	short id;	/* ID to distinguish multiple devices */
-	int x, y, z;	/* event coordinates */
-	mmask_t bstate;   /* button state bits */
+	short id;		/* ID to distinguish multiple devices */
+	int x, y, z;		/* event coordinates */
+	mmask_t bstate;		/* button state bits */
 } MEVENT;
 
 bool has_mouse(void);
@@ -1052,10 +1052,10 @@ int mouseinterval(int);
 const char *curses_version(void);
 
 /* Private functions that are needed for user programs prototypes. */
-int	 __cputchar(int);
-int	 __waddbytes(WINDOW *, const char *, int, attr_t);
+int	__cputchar(int);
+int	__waddbytes(WINDOW *, const char *, int, attr_t);
 #ifdef HAVE_WCHAR
-int __cputwchar( wchar_t );
+int	__cputwchar(wchar_t);
 #endif /* HAVE_WCHAR */
 __END_DECLS
 



CVS commit: src/tests/lib/libcurses/slave

2021-02-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 13 10:03:49 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: slave.c

Log Message:
tests/libcurses: extract read_command_argument from process_commands

Having code indented so far to the right that each word gets its own
line is ridiculous.  Fix that.

While here, remove the cargo-cult realloc pattern, which is not needed
if the process exits immediately on error.

While here, reduce the indentation of the code by returning early.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/tests/lib/libcurses/slave/slave.c

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

Modified files:

Index: src/tests/lib/libcurses/slave/slave.c
diff -u src/tests/lib/libcurses/slave/slave.c:1.15 src/tests/lib/libcurses/slave/slave.c:1.16
--- src/tests/lib/libcurses/slave/slave.c:1.15	Sat Feb 13 09:28:27 2021
+++ src/tests/lib/libcurses/slave/slave.c	Sat Feb 13 10:03:49 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: slave.c,v 1.15 2021/02/13 09:28:27 rillig Exp $	*/
+/*	$NetBSD: slave.c,v 1.16 2021/02/13 10:03:49 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -76,6 +76,50 @@ read_from_director(void *data, size_t n)
 		n, (size_t)nread);
 }
 
+static bool
+read_command_argument(char ***pargs, int argslen)
+{
+	int type, len;
+	char **args = *pargs;
+
+	read_from_director(, sizeof type);
+	read_from_director(, sizeof len);
+	if (len < 0)
+		return false;
+
+	args = realloc(args, (argslen + 1) * sizeof args[0]);
+	if (args == NULL)
+		err(1, "slave realloc of args array failed");
+	*pargs = args;
+
+	if (type != data_null) {
+		args[argslen] = malloc(len + 1);
+
+		if (args[argslen] == NULL)
+			err(1, "slave alloc of %d bytes for args failed", len);
+	}
+
+	if (len == 0) {
+		if (type == data_null)
+			args[argslen] = NULL;
+		else
+			args[argslen][0] = '\0';
+	} else {
+		read_from_director(args[argslen], len);
+		if (type != data_byte)
+			args[argslen][len] = '\0';
+
+		if (len == 6 && strcmp(args[argslen], "STDSCR") == 0) {
+			char *stdscr_buf;
+			if (asprintf(_buf, "%p", stdscr) < 0)
+err(2, "asprintf of stdscr failed");
+			free(args[argslen]);
+			args[argslen] = stdscr_buf;
+		}
+	}
+	return true;
+}
+
 /*
  * Read the command pipe for the function to execute, gather the args
  * and then process the command.
@@ -83,8 +127,8 @@ read_from_director(void *data, size_t n)
 static void
 process_commands(void)
 {
-	int len, maxlen, argslen, i, ret, type;
-	char *cmdbuf, *tmpbuf, **args, **tmpargs;
+	int len, maxlen, argslen, i, type;
+	char *cmdbuf, *tmpbuf, **args;
 
 	len = maxlen = 30;
 	if ((cmdbuf = malloc(maxlen)) == NULL)
@@ -109,54 +153,8 @@ process_commands(void)
 		argslen = 0;
 		args = NULL;
 
-		do {
-			read_from_director(, sizeof type);
-			read_from_director(, sizeof len);
-
-			if (len >= 0) {
-tmpargs = realloc(args,
-(argslen + 1) * sizeof(char *));
-if (tmpargs == NULL)
-	err(1, "slave realloc of args array "
-	"failed");
-
-args = tmpargs;
-if (type != data_null) {
-	args[argslen] = malloc(len + 1);
-
-	if (args[argslen] == NULL)
-		err(1, "slave alloc of %d bytes"
-		" for args failed", len);
-}
-
-if (len == 0) {
-	if (type == data_null)
-		args[argslen] = NULL;
-	else
-		args[argslen][0] = '\0';
-} else {
-	read_from_director(args[argslen], len);
-	if (type != data_byte)
-		args[argslen][len] = '\0';
-
-	if (len == 6) {
-		if (strcmp(args[argslen],
-			   "STDSCR") == 0) {
-			ret = asprintf(,
- "%p",
- stdscr);
-			if (ret < 0)
-err(2,
-"asprintf of stdscr failed");
-			free(args[argslen]);
-			args[argslen] = tmpbuf;
-		}
-	}
-}
-
-argslen++;
-			}
-		} while (len >= 0);
+		while (read_command_argument(, argslen))
+			argslen++;
 
 		command_execute(cmdbuf, argslen, args);
 



CVS commit: src/tests/lib/libcurses/slave

2021-02-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 13 09:28:27 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: slave.c

Log Message:
tests/libcurses: fix reading from the parent process

In case of a short read, processing the incomplete data invoked
undefined behavior.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/tests/lib/libcurses/slave/slave.c

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

Modified files:

Index: src/tests/lib/libcurses/slave/slave.c
diff -u src/tests/lib/libcurses/slave/slave.c:1.14 src/tests/lib/libcurses/slave/slave.c:1.15
--- src/tests/lib/libcurses/slave/slave.c:1.14	Sat Feb 13 09:18:12 2021
+++ src/tests/lib/libcurses/slave/slave.c	Sat Feb 13 09:28:27 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: slave.c,v 1.14 2021/02/13 09:18:12 rillig Exp $	*/
+/*	$NetBSD: slave.c,v 1.15 2021/02/13 09:28:27 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -32,6 +32,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -50,6 +51,31 @@ static const char *returns_enum_names[] 
 };
 #endif
 
+static bool
+try_read_from_director(void *data, size_t n)
+{
+	ssize_t nread = read(from_director, data, n);
+	if (nread < 0)
+		err(2, "error reading from command pipe");
+	if (nread == 0)
+		return false;
+	if ((size_t)nread != n)
+		errx(2, "short read from command pipe: expected %zu, got %zu",
+		n, (size_t)nread);
+	return true;
+}
+
+static void
+read_from_director(void *data, size_t n)
+{
+	ssize_t nread = read(from_director, data, n);
+	if (nread < 0)
+		err(2, "error reading from command pipe");
+	if ((size_t)nread != n)
+		errx(2, "short read from command pipe: expected %zu, got %zu",
+		n, (size_t)nread);
+}
+
 /*
  * Read the command pipe for the function to execute, gather the args
  * and then process the command.
@@ -59,23 +85,16 @@ process_commands(void)
 {
 	int len, maxlen, argslen, i, ret, type;
 	char *cmdbuf, *tmpbuf, **args, **tmpargs;
-	ssize_t nread;
 
 	len = maxlen = 30;
 	if ((cmdbuf = malloc(maxlen)) == NULL)
 		err(1, "slave cmdbuf malloc failed");
 
-	for (;;) {
-		if ((nread = read(from_director, , sizeof(int))) < 0)
-			err(1, "slave command type read failed");
-		if (nread == 0)
-			break;
-
+	while (try_read_from_director(, sizeof type)) {
 		if (type != data_string)
 			errx(1, "Unexpected type for command, got %d", type);
 
-		if (read(from_director, , sizeof(int)) < 0)
-			err(1, "slave command len read failed");
+		read_from_director(, sizeof len);
 
 		if ((len + 1) > maxlen) {
 			maxlen = len + 1;
@@ -85,18 +104,14 @@ process_commands(void)
 			cmdbuf = tmpbuf;
 		}
 
-		if (read(from_director, cmdbuf, len) < 0)
-			err(1, "slave command read failed");
+		read_from_director(cmdbuf, len);
 		cmdbuf[len] = '\0';
 		argslen = 0;
 		args = NULL;
 
 		do {
-			if (read(from_director, , sizeof(int)) < 0)
-err(1, "slave arg type read failed");
-
-			if (read(from_director, , sizeof(int)) < 0)
-err(1, "slave arg len read failed");
+			read_from_director(, sizeof type);
+			read_from_director(, sizeof len);
 
 			if (len >= 0) {
 tmpargs = realloc(args,
@@ -120,8 +135,7 @@ process_commands(void)
 	else
 		args[argslen][0] = '\0';
 } else {
-	read(from_director, args[argslen],
-	 len);
+	read_from_director(args[argslen], len);
 	if (type != data_byte)
 		args[argslen][len] = '\0';
 



CVS commit: src/tests/lib/libcurses

2021-02-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 13 09:18:12 UTC 2021

Modified Files:
src/tests/lib/libcurses/director: director.c
src/tests/lib/libcurses/slave: slave.c

Log Message:
tests/libcurses: fix child process handling

The child process needs to be properly controlled by the parent process.
Otherwise it is not possible to get code coverage data from it using
gcov since that requires the child process to exit normally.  Previously
the child process had been killed because its parent had exited.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/tests/lib/libcurses/director/director.c
cvs rdiff -u -r1.13 -r1.14 src/tests/lib/libcurses/slave/slave.c

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

Modified files:

Index: src/tests/lib/libcurses/director/director.c
diff -u src/tests/lib/libcurses/director/director.c:1.27 src/tests/lib/libcurses/director/director.c:1.28
--- src/tests/lib/libcurses/director/director.c:1.27	Sat Feb 13 08:26:12 2021
+++ src/tests/lib/libcurses/director/director.c	Sat Feb 13 09:18:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: director.c,v 1.27 2021/02/13 08:26:12 rillig Exp $	*/
+/*	$NetBSD: director.c,v 1.28 2021/02/13 09:18:12 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -72,7 +73,7 @@ void init_parse_variables(int);	/* in te
  * output in verbose mode, truncating the useful part of the error message.
  */
 static void
-slave_died(int param)
+slave_died(int signo)
 {
 	char last_words[256];
 	size_t count;
@@ -276,5 +277,12 @@ main(int argc, char *argv[])
 	yyparse();
 	fclose(yyin);
 
+	signal(SIGCHLD, SIG_DFL);
+	(void)close(to_slave);
+	(void)close(from_slave);
+
+	int status;
+	(void)waitpid(slave_pid, , 0);
+
 	exit(0);
 }

Index: src/tests/lib/libcurses/slave/slave.c
diff -u src/tests/lib/libcurses/slave/slave.c:1.13 src/tests/lib/libcurses/slave/slave.c:1.14
--- src/tests/lib/libcurses/slave/slave.c:1.13	Sat Feb 13 08:17:15 2021
+++ src/tests/lib/libcurses/slave/slave.c	Sat Feb 13 09:18:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: slave.c,v 1.13 2021/02/13 08:17:15 rillig Exp $	*/
+/*	$NetBSD: slave.c,v 1.14 2021/02/13 09:18:12 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -59,14 +59,17 @@ process_commands(void)
 {
 	int len, maxlen, argslen, i, ret, type;
 	char *cmdbuf, *tmpbuf, **args, **tmpargs;
+	ssize_t nread;
 
 	len = maxlen = 30;
 	if ((cmdbuf = malloc(maxlen)) == NULL)
 		err(1, "slave cmdbuf malloc failed");
 
 	for (;;) {
-		if (read(from_director, , sizeof(int)) < 0)
+		if ((nread = read(from_director, , sizeof(int))) < 0)
 			err(1, "slave command type read failed");
+		if (nread == 0)
+			break;
 
 		if (type != data_string)
 			errx(1, "Unexpected type for command, got %d", type);



CVS commit: src/tests/lib/libcurses/director

2021-02-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 13 08:43:03 UTC 2021

Modified Files:
src/tests/lib/libcurses/director: testlang_parse.y

Log Message:
tests/libcurses: fix error messages


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/tests/lib/libcurses/director/testlang_parse.y

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

Modified files:

Index: src/tests/lib/libcurses/director/testlang_parse.y
diff -u src/tests/lib/libcurses/director/testlang_parse.y:1.46 src/tests/lib/libcurses/director/testlang_parse.y:1.47
--- src/tests/lib/libcurses/director/testlang_parse.y:1.46	Sat Feb 13 08:14:46 2021
+++ src/tests/lib/libcurses/director/testlang_parse.y	Sat Feb 13 08:43:03 2021
@@ -1,5 +1,5 @@
 %{
-/*	$NetBSD: testlang_parse.y,v 1.46 2021/02/13 08:14:46 rillig Exp $	*/
+/*	$NetBSD: testlang_parse.y,v 1.47 2021/02/13 08:43:03 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -767,7 +767,7 @@ assign_arg(data_enum_t arg_type, void *a
 	if (cur.arg_type == data_var) {
 		cur.var_index = find_var_index(arg);
 		if (cur.var_index < 0)
-			err(1, "%s:%zu: Invalid variable %s",
+			errx(1, "%s:%zu: Invalid variable %s",
 			cur_file, line, str);
 	} else if (cur.arg_type == data_byte) {
 		ret = arg;
@@ -1085,7 +1085,7 @@ do_function_call(size_t nresults)
 	 */
 	read_cmd_pipe(_count);
 	if (returns_count.data_type != data_count)
-		err(2, "expected return type of data_count but received %s",
+		errx(2, "expected return type of data_count but received %s",
 		enum_names[returns_count.data_type]);
 
 	perform_delay(_post_call); /* let slave catch up */



CVS commit: src/tests/lib/libcurses/tests

2021-02-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 13 08:37:21 UTC 2021

Modified Files:
src/tests/lib/libcurses/tests: mvwin

Log Message:
tests/libcurses: "fix" test mvwin

The test mvwin previously expected an endless stream of bytes, by
comparing the actual output with /dev/zero.  This didn't make sense as
the curses output does not contain '\0' in any of the test cases.

Compare with /dev/null instead.  This is as wrong as before, but the
curses test framework currently ignores this situation, as for many
other test cases.  See the numerous "Excess" messages in atf-run.log.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libcurses/tests/mvwin

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

Modified files:

Index: src/tests/lib/libcurses/tests/mvwin
diff -u src/tests/lib/libcurses/tests/mvwin:1.1 src/tests/lib/libcurses/tests/mvwin:1.2
--- src/tests/lib/libcurses/tests/mvwin:1.1	Sun Apr 10 09:55:10 2011
+++ src/tests/lib/libcurses/tests/mvwin	Sat Feb 13 08:37:21 2021
@@ -2,11 +2,11 @@ include window
 call OK wmove $win1 1 1
 call OK wprintw $win1 "%s" ""
 call OK wrefresh $win1
-compare /dev/zero
+compare /dev/null
 call OK refresh
-compare /dev/zero
+compare /dev/null
 call OK mvwin $win1 4 7
 call OK wrefresh $win1
-compare /dev/zero
+compare /dev/null
 call OK refresh
-compare /dev/zero
+compare /dev/null



CVS commit: src/tests/lib/libcurses/director

2021-02-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 13 08:26:12 UTC 2021

Modified Files:
src/tests/lib/libcurses/director: director.c

Log Message:
tests/libcurses: remove undocumented, unused command line option

The option -T has the same effect as the removed option -p.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/tests/lib/libcurses/director/director.c

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

Modified files:

Index: src/tests/lib/libcurses/director/director.c
diff -u src/tests/lib/libcurses/director/director.c:1.26 src/tests/lib/libcurses/director/director.c:1.27
--- src/tests/lib/libcurses/director/director.c:1.26	Sat Feb 13 08:22:34 2021
+++ src/tests/lib/libcurses/director/director.c	Sat Feb 13 08:26:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: director.c,v 1.26 2021/02/13 08:22:34 rillig Exp $	*/
+/*	$NetBSD: director.c,v 1.27 2021/02/13 08:26:12 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -138,7 +138,7 @@ main(int argc, char *argv[])
 	verbose = 0;
 	check_file_flag = 0;
 
-	while ((ch = getopt(argc, argv, "vgfC:p:s:t:T:")) != -1) {
+	while ((ch = getopt(argc, argv, "vgfC:s:t:T:")) != -1) {
 		switch (ch) {
 		case 'C':
 			check_path = optarg;
@@ -146,9 +146,6 @@ main(int argc, char *argv[])
 		case 'T':
 			termpath = optarg;
 			break;
-		case 'p':
-			termpath = optarg;
-			break;
 		case 's':
 			slave = optarg;
 			break;



CVS commit: src/tests/lib/libcurses/director

2021-02-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 13 08:22:34 UTC 2021

Modified Files:
src/tests/lib/libcurses/director: director.c

Log Message:
tests/libcurses: remove include path from usage message

The option has been removed a few minutes ago.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/tests/lib/libcurses/director/director.c

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

Modified files:

Index: src/tests/lib/libcurses/director/director.c
diff -u src/tests/lib/libcurses/director/director.c:1.25 src/tests/lib/libcurses/director/director.c:1.26
--- src/tests/lib/libcurses/director/director.c:1.25	Sat Feb 13 08:14:46 2021
+++ src/tests/lib/libcurses/director/director.c	Sat Feb 13 08:22:34 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: director.c,v 1.25 2021/02/13 08:14:46 rillig Exp $	*/
+/*	$NetBSD: director.c,v 1.26 2021/02/13 08:22:34 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -114,7 +114,6 @@ usage(void)
 	"file, or a file holding the terminfo description\n");
 	fprintf(stderr, "-s is the path to the slave executable\n");
 	fprintf(stderr, "-t is value to set TERM to for the test\n");
-	fprintf(stderr, "-I is the directory to include files\n");
 	fprintf(stderr, "-C is the directory for check-files\n");
 	fprintf(stderr, "commandfile is a file of test directives\n");
 	exit(1);



CVS commit: src/tests/lib/libcurses/slave

2021-02-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 13 08:17:15 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: slave.c slave.h

Log Message:
tests/libcurses: clean up remaining include guard, comments

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/tests/lib/libcurses/slave/slave.c
cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libcurses/slave/slave.h

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

Modified files:

Index: src/tests/lib/libcurses/slave/slave.c
diff -u src/tests/lib/libcurses/slave/slave.c:1.12 src/tests/lib/libcurses/slave/slave.c:1.13
--- src/tests/lib/libcurses/slave/slave.c:1.12	Sat Feb 13 06:45:42 2021
+++ src/tests/lib/libcurses/slave/slave.c	Sat Feb 13 08:17:15 2021
@@ -1,7 +1,8 @@
-/*	$NetBSD: slave.c,v 1.12 2021/02/13 06:45:42 rillig Exp $	*/
+/*	$NetBSD: slave.c,v 1.13 2021/02/13 08:17:15 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
+ * Copyright 2021 Roland Illig 
  *
  * All rights reserved.
  *
@@ -25,9 +26,8 @@
  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *
  */
+
 #include 
 #include 
 #include 

Index: src/tests/lib/libcurses/slave/slave.h
diff -u src/tests/lib/libcurses/slave/slave.h:1.6 src/tests/lib/libcurses/slave/slave.h:1.7
--- src/tests/lib/libcurses/slave/slave.h:1.6	Sat Feb 13 06:45:42 2021
+++ src/tests/lib/libcurses/slave/slave.h	Sat Feb 13 08:17:15 2021
@@ -1,7 +1,8 @@
-/*	$NetBSD: slave.h,v 1.6 2021/02/13 06:45:42 rillig Exp $	*/
+/*	$NetBSD: slave.h,v 1.7 2021/02/13 08:17:15 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
+ * Copyright 2021 Roland Illig 
  *
  * All rights reserved.
  *
@@ -25,11 +26,10 @@
  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *
  */
-#ifndef CURTEST_SLAVE_H
-#define CURTEST_SLAVE_H
+
+#ifndef CTF_SLAVE_H
+#define CTF_SLAVE_H
 
 #include 
 



CVS commit: src/tests/lib/libcurses

2021-02-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 13 08:14:46 UTC 2021

Modified Files:
src/tests/lib/libcurses/director: director.c director.h returns.h
testlang_conf.l testlang_parse.y
src/tests/lib/libcurses/slave: command_table.h commands.c
curses_commands.c curses_commands.h

Log Message:
tests/libcurses: clean up inclusion guards, function declarations

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/tests/lib/libcurses/director/director.c
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libcurses/director/director.h
cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libcurses/director/returns.h
cvs rdiff -u -r1.19 -r1.20 src/tests/lib/libcurses/director/testlang_conf.l
cvs rdiff -u -r1.45 -r1.46 src/tests/lib/libcurses/director/testlang_parse.y
cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libcurses/slave/command_table.h \
src/tests/lib/libcurses/slave/curses_commands.h
cvs rdiff -u -r1.11 -r1.12 src/tests/lib/libcurses/slave/commands.c
cvs rdiff -u -r1.21 -r1.22 src/tests/lib/libcurses/slave/curses_commands.c

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

Modified files:

Index: src/tests/lib/libcurses/director/director.c
diff -u src/tests/lib/libcurses/director/director.c:1.24 src/tests/lib/libcurses/director/director.c:1.25
--- src/tests/lib/libcurses/director/director.c:1.24	Sat Feb 13 08:00:07 2021
+++ src/tests/lib/libcurses/director/director.c	Sat Feb 13 08:14:46 2021
@@ -1,7 +1,8 @@
-/*	$NetBSD: director.c,v 1.24 2021/02/13 08:00:07 rillig Exp $	*/
+/*	$NetBSD: director.c,v 1.25 2021/02/13 08:14:46 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
+ * Copyright 2021 Roland Illig 
  *
  * All rights reserved.
  *
@@ -25,8 +26,6 @@
  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *
  */
 
 #include 

Index: src/tests/lib/libcurses/director/director.h
diff -u src/tests/lib/libcurses/director/director.h:1.3 src/tests/lib/libcurses/director/director.h:1.4
--- src/tests/lib/libcurses/director/director.h:1.3	Sat Feb 13 07:08:45 2021
+++ src/tests/lib/libcurses/director/director.h	Sat Feb 13 08:14:46 2021
@@ -1,8 +1,9 @@
-/*	$NetBSD: director.h,v 1.3 2021/02/13 07:08:45 rillig Exp $	*/
+/*	$NetBSD: director.h,v 1.4 2021/02/13 08:14:46 rillig Exp $	*/
 
 /*-
  * Copyright 2020 Naman Jain , this code was
  * created as part of the Google Summer of Code 2020.
+ * Copyright 2021 Roland Illig 
  *
  * All rights reserved.
  *
@@ -26,11 +27,10 @@
  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *
  */
-#ifndef DIRECTOR_H
-#define DIRECTOR_H
+
+#ifndef CTF_DIRECTOR_H
+#define CTF_DIRECTOR_H
 
 #define GEN_CHECK_FILE 1
 #define FORCE_GEN 2
@@ -38,4 +38,4 @@
 extern int to_slave;
 extern int from_slave;
 
-#endif /* DIRECTOR_H */
+#endif

Index: src/tests/lib/libcurses/director/returns.h
diff -u src/tests/lib/libcurses/director/returns.h:1.5 src/tests/lib/libcurses/director/returns.h:1.6
--- src/tests/lib/libcurses/director/returns.h:1.5	Mon Feb  8 19:15:20 2021
+++ src/tests/lib/libcurses/director/returns.h	Sat Feb 13 08:14:46 2021
@@ -1,7 +1,8 @@
-/*	$NetBSD: returns.h,v 1.5 2021/02/08 19:15:20 rillig Exp $	*/
+/*	$NetBSD: returns.h,v 1.6 2021/02/13 08:14:46 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
+ * Copyright 2021 Roland Illig 
  *
  * All rights reserved.
  *
@@ -25,12 +26,10 @@
  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *
  */
-#ifndef CTF_RETURNS_H
-#define CTF_RETURNS_H 1
 
+#ifndef CTF_RETURNS_H
+#define CTF_RETURNS_H
 
 typedef enum {
 	data_number = 1,
@@ -66,4 +65,4 @@ typedef struct {
 	char	*data;
 } saved_data_t;
 
-#endif /* CTF_RETURNS_H */
+#endif

Index: src/tests/lib/libcurses/director/testlang_conf.l
diff -u src/tests/lib/libcurses/director/testlang_conf.l:1.19 src/tests/lib/libcurses/director/testlang_conf.l:1.20
--- src/tests/lib/libcurses/director/testlang_conf.l:1.19	Sat Feb 13 08:00:07 2021
+++ src/tests/lib/libcurses/director/testlang_conf.l	Sat Feb 13 08:14:46 2021
@@ -1,8 +1,9 @@
 %{
-/*	$NetBSD: testlang_conf.l,v 1.19 2021/02/13 08:00:07 rillig Exp $ 	*/
+/*	$NetBSD: testlang_conf.l,v 1.20 2021/02/13 08:14:46 rillig Exp $ 	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
+ * Copyright 2021 Roland Illig 
  *
  * All rights reserved.
  *
@@ -26,8 +27,6 @@
  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * 

CVS commit: src/tests/lib/libcurses

2021-02-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 13 08:00:07 UTC 2021

Modified Files:
src/tests/lib/libcurses: t_curses.sh
src/tests/lib/libcurses/director: director.c testlang_conf.l

Log Message:
tests/libcurses: remove include path handling

All include commands in the current test suite use relative paths.
Instead of a fixed include path, interpret the included filename
relative to the including file.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/tests/lib/libcurses/t_curses.sh
cvs rdiff -u -r1.23 -r1.24 src/tests/lib/libcurses/director/director.c
cvs rdiff -u -r1.18 -r1.19 src/tests/lib/libcurses/director/testlang_conf.l

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

Modified files:

Index: src/tests/lib/libcurses/t_curses.sh
diff -u src/tests/lib/libcurses/t_curses.sh:1.22 src/tests/lib/libcurses/t_curses.sh:1.23
--- src/tests/lib/libcurses/t_curses.sh:1.22	Sat Feb 13 06:29:45 2021
+++ src/tests/lib/libcurses/t_curses.sh	Sat Feb 13 08:00:07 2021
@@ -25,7 +25,6 @@ r_run()
 	$(atf_get_srcdir)/director $2 \
 		-T $(atf_get_srcdir) \
 		-t atf \
-		-I $(atf_get_srcdir)/tests \
 		-C $(atf_get_srcdir)/check_files \
 		-s $(atf_get_srcdir)/slave $file || atf_fail "test ${file} failed"
 }

Index: src/tests/lib/libcurses/director/director.c
diff -u src/tests/lib/libcurses/director/director.c:1.23 src/tests/lib/libcurses/director/director.c:1.24
--- src/tests/lib/libcurses/director/director.c:1.23	Sat Feb 13 07:32:19 2021
+++ src/tests/lib/libcurses/director/director.c	Sat Feb 13 08:00:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: director.c,v 1.23 2021/02/13 07:32:19 rillig Exp $	*/
+/*	$NetBSD: director.c,v 1.24 2021/02/13 08:00:07 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -51,7 +51,6 @@ void yyparse(void);
 #define DEF_SLAVE "./slave"
 
 const char *def_check_path = "./"; /* default check path */
-const char *def_include_path = "./"; /* default include path */
 
 extern size_t nvars;		/* In testlang_conf.y */
 saved_data_t  saved_output;	/* In testlang_conf.y */
@@ -62,7 +61,6 @@ int verbose;			/* control verbosity of t
 int check_file_flag;		/* control check-file generation */
 const char *check_path;		/* path to prepend to check files for output
    validation */
-const char *include_path;	/* path to prepend to include files */
 char *cur_file;			/* name of file currently being read */
 
 void init_parse_variables(int);	/* in testlang_parse.y */
@@ -142,11 +140,8 @@ main(int argc, char *argv[])
 	verbose = 0;
 	check_file_flag = 0;
 
-	while ((ch = getopt(argc, argv, "vgfC:I:p:s:t:T:")) != -1) {
+	while ((ch = getopt(argc, argv, "vgfC:p:s:t:T:")) != -1) {
 		switch (ch) {
-		case 'I':
-			include_path = optarg;
-			break;
 		case 'C':
 			check_path = optarg;
 			break;
@@ -199,14 +194,6 @@ main(int argc, char *argv[])
 		check_path = def_check_path;
 	}
 
-	if (include_path == NULL)
-		include_path = getenv("INCLUDE_PATH");
-	if ((include_path == NULL) || (include_path[0] == '\0')) {
-		warnx("$INCLUDE_PATH not set, defaulting to %s",
-			def_include_path);
-		include_path = def_include_path;
-	}
-
 	signal(SIGCHLD, slave_died);
 
 	if (setenv("TERM", term, 1) != 0)

Index: src/tests/lib/libcurses/director/testlang_conf.l
diff -u src/tests/lib/libcurses/director/testlang_conf.l:1.18 src/tests/lib/libcurses/director/testlang_conf.l:1.19
--- src/tests/lib/libcurses/director/testlang_conf.l:1.18	Mon Feb  8 23:54:03 2021
+++ src/tests/lib/libcurses/director/testlang_conf.l	Sat Feb 13 08:00:07 2021
@@ -1,5 +1,5 @@
 %{
-/*	$NetBSD: testlang_conf.l,v 1.18 2021/02/08 23:54:03 rillig Exp $ 	*/
+/*	$NetBSD: testlang_conf.l,v 1.19 2021/02/13 08:00:07 rillig Exp $ 	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -45,7 +45,6 @@
 int yylex(void);
 
 extern size_t line;
-extern char *include_path; 	/* from director.c */
 extern char *cur_file;		/* from director.c */
 
 static int include_stack[MAX_INCLUDES];
@@ -175,7 +174,7 @@ include		BEGIN(incl);
 
 [ \t]*	/* eat the whitespace */
 [^ \t\n]+ { /* got the include file name */
-		char inc_file[MAXPATHLEN];
+		char *inc_file;
 
 		if (include_ptr > MAX_INCLUDES) {
 			fprintf(stderr,
@@ -184,23 +183,27 @@ include		BEGIN(incl);
 exit(2);
 		}
 
-		if (yytext[0] != '/') {
-			if (strlcpy(inc_file, include_path, sizeof(inc_file))
-			>= sizeof(inc_file))
-err(2, "CHECK_PATH too long");
-			if ((include_path[strlen(include_path) - 1] != '/') &&
-			((strlcat(inc_file, "/", sizeof(inc_file))
-			>= sizeof(inc_file
-err(2, "Could not append / to include file path");
+		const char *dir_begin;
+		int dir_len;
+		if (yytext[0] == '/') {
+			dir_begin = "";
+			dir_len = 0;
 		} else {
-			inc_file[0] = '\0';
+			dir_begin = cur_file;
+			const char *dir_end = strrchr(cur_file, '/');
+			if (dir_end != NULL) {
+dir_len = (int)(dir_end + 1 - dir_begin);
+			} else {
+dir_begin = ".";
+dir_len = 1;
+			}
 		}
 
-