CVS commit: src/sys/dev/pci

2021-11-04 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Nov  5 05:52:49 UTC 2021

Modified Files:
src/sys/dev/pci: if_wm.c

Log Message:
Fix a bug that device timeout still happens on ICH/PCH. Fixes PR kern/56478.

 - if_wm.c rev. 1.695 for PR kern/40981 still had a problem. The workaround
   flag was unexpectedly cleared when a cable is not connected, SIOCINITIFADDR
   was called, or if_init was called. Fix it.
 - Add debug printf()s.


To generate a diff of this commit:
cvs rdiff -u -r1.717 -r1.718 src/sys/dev/pci/if_wm.c

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

Modified files:

Index: src/sys/dev/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.717 src/sys/dev/pci/if_wm.c:1.718
--- src/sys/dev/pci/if_wm.c:1.717	Fri Nov  5 01:49:14 2021
+++ src/sys/dev/pci/if_wm.c	Fri Nov  5 05:52:49 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.717 2021/11/05 01:49:14 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.718 2021/11/05 05:52:49 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.717 2021/11/05 01:49:14 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.718 2021/11/05 05:52:49 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -3154,8 +3154,12 @@ alloc_retry:
 
 	sc->sc_txrx_use_workqueue = false;
 
-	if (wm_phy_need_linkdown_discard(sc))
+	if (wm_phy_need_linkdown_discard(sc)) {
+		DPRINTF(sc, WM_DEBUG_LINK,
+		("%s: %s: Set linkdown discard flag\n",
+			device_xname(sc->sc_dev), __func__));
 		wm_set_linkdown_discard(sc);
+	}
 
 	wm_init_sysctls(sc);
 
@@ -3625,10 +3629,12 @@ wm_ioctl(struct ifnet *ifp, u_long cmd, 
 		WM_CORE_UNLOCK(sc);
 		error = ifmedia_ioctl(ifp, ifr, >sc_mii.mii_media, cmd);
 		if (error == 0 && wm_phy_need_linkdown_discard(sc)) {
-			if (IFM_SUBTYPE(ifr->ifr_media) == IFM_NONE)
+			if (IFM_SUBTYPE(ifr->ifr_media) == IFM_NONE) {
+DPRINTF(sc, WM_DEBUG_LINK,
+("%s: %s: Set linkdown discard flag\n",
+	device_xname(sc->sc_dev), __func__));
 wm_set_linkdown_discard(sc);
-			else
-wm_clear_linkdown_discard(sc);
+			}
 		}
 		break;
 	case SIOCINITIFADDR:
@@ -3644,14 +3650,14 @@ wm_ioctl(struct ifnet *ifp, u_long cmd, 
 			break;
 		}
 		WM_CORE_UNLOCK(sc);
-		if (((ifp->if_flags & IFF_UP) == 0) && wm_phy_need_linkdown_discard(sc))
-			wm_clear_linkdown_discard(sc);
 		/*FALLTHROUGH*/
 	default:
 		if (cmd == SIOCSIFFLAGS && wm_phy_need_linkdown_discard(sc)) {
-			if (((ifp->if_flags & IFF_UP) == 0) && ((ifr->ifr_flags & IFF_UP) != 0)) {
-wm_clear_linkdown_discard(sc);
-			} else if (((ifp->if_flags & IFF_UP) != 0) && ((ifr->ifr_flags & IFF_UP) == 0)) {
+			if (((ifp->if_flags & IFF_UP) != 0) &&
+			((ifr->ifr_flags & IFF_UP) == 0)) {
+DPRINTF(sc, WM_DEBUG_LINK,
+("%s: %s: Set linkdown discard flag\n",
+	device_xname(sc->sc_dev), __func__));
 wm_set_linkdown_discard(sc);
 			}
 		}
@@ -7479,7 +7485,9 @@ wm_init_tx_queue(struct wm_softc *sc, st
 	wm_init_tx_regs(sc, wmq, txq);
 	wm_init_tx_buffer(sc, txq);
 
-	txq->txq_flags = 0; /* Clear WM_TXQ_NO_SPACE */
+	/* Clear other than WM_TXQ_LINKDOWN_DISCARD */
+	txq->txq_flags &= WM_TXQ_LINKDOWN_DISCARD;
+
 	txq->txq_sending = false;
 }
 
@@ -9490,13 +9498,21 @@ wm_linkintr_gmii(struct wm_softc *sc, ui
 		DPRINTF(sc, WM_DEBUG_LINK, ("%s: LINK: LSC -> up %s\n",
 			device_xname(dev),
 			(status & STATUS_FD) ? "FDX" : "HDX"));
-		if (wm_phy_need_linkdown_discard(sc))
+		if (wm_phy_need_linkdown_discard(sc)) {
+			DPRINTF(sc, WM_DEBUG_LINK,
+			("%s: linkintr: Clear linkdown discard flag\n",
+device_xname(dev)));
 			wm_clear_linkdown_discard(sc);
+		}
 	} else {
 		DPRINTF(sc, WM_DEBUG_LINK, ("%s: LINK: LSC -> down\n",
 			device_xname(dev)));
-		if (wm_phy_need_linkdown_discard(sc))
+		if (wm_phy_need_linkdown_discard(sc)) {
+			DPRINTF(sc, WM_DEBUG_LINK,
+			("%s: linkintr: Set linkdown discard flag\n",
+device_xname(dev)));
 			wm_set_linkdown_discard(sc);
+		}
 	}
 	if ((sc->sc_type == WM_T_ICH8) && (link == false))
 		wm_gig_downshift_workaround_ich8lan(sc);



CVS commit: src/sys/dev/pci

2021-11-04 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Nov  5 05:52:49 UTC 2021

Modified Files:
src/sys/dev/pci: if_wm.c

Log Message:
Fix a bug that device timeout still happens on ICH/PCH. Fixes PR kern/56478.

 - if_wm.c rev. 1.695 for PR kern/40981 still had a problem. The workaround
   flag was unexpectedly cleared when a cable is not connected, SIOCINITIFADDR
   was called, or if_init was called. Fix it.
 - Add debug printf()s.


To generate a diff of this commit:
cvs rdiff -u -r1.717 -r1.718 src/sys/dev/pci/if_wm.c

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



CVS commit: src/sys/dev/mii

2021-11-04 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Nov  5 01:53:30 UTC 2021

Modified Files:
src/sys/dev/mii: ihphy.c

Log Message:
Don't power down the PHY when the interface goes down.

 - All of other PHY drivers don't power down the PHY. Do the same way.
 - At least, keeping the link is required for Intel AMT and WoL.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/mii/ihphy.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/mii/ihphy.c
diff -u src/sys/dev/mii/ihphy.c:1.19 src/sys/dev/mii/ihphy.c:1.20
--- src/sys/dev/mii/ihphy.c:1.19	Wed Nov  4 09:15:10 2020
+++ src/sys/dev/mii/ihphy.c	Fri Nov  5 01:53:30 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ihphy.c,v 1.19 2020/11/04 09:15:10 msaitoh Exp $	*/
+/*	$NetBSD: ihphy.c,v 1.20 2021/11/05 01:53:30 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ihphy.c,v 1.19 2020/11/04 09:15:10 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ihphy.c,v 1.20 2021/11/05 01:53:30 msaitoh Exp $");
 
 #include 
 #include 
@@ -211,7 +211,6 @@ ihphy_service(struct mii_softc *sc, stru
 
 	case MII_DOWN:
 		mii_phy_down(sc);
-		PHY_WRITE(sc, MII_BMCR, BMCR_PDOWN);
 		return 0;
 	}
 



CVS commit: src/sys/dev/mii

2021-11-04 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Nov  5 01:53:30 UTC 2021

Modified Files:
src/sys/dev/mii: ihphy.c

Log Message:
Don't power down the PHY when the interface goes down.

 - All of other PHY drivers don't power down the PHY. Do the same way.
 - At least, keeping the link is required for Intel AMT and WoL.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/mii/ihphy.c

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



CVS commit: src/sys/dev/pci

2021-11-04 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Nov  5 01:49:15 UTC 2021

Modified Files:
src/sys/dev/pci: if_wm.c

Log Message:
 Use macro. No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.716 -r1.717 src/sys/dev/pci/if_wm.c

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

Modified files:

Index: src/sys/dev/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.716 src/sys/dev/pci/if_wm.c:1.717
--- src/sys/dev/pci/if_wm.c:1.716	Thu Nov  4 12:25:05 2021
+++ src/sys/dev/pci/if_wm.c	Fri Nov  5 01:49:14 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.716 2021/11/04 12:25:05 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.717 2021/11/05 01:49:14 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.716 2021/11/04 12:25:05 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.717 2021/11/05 01:49:14 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -10502,9 +10502,9 @@ wm_gmii_setup_phytype(struct wm_softc *s
 	} else {
 		/* It's not the first call. Use PHY OUI and model */
 		switch (phy_oui) {
-		case MII_OUI_ATTANSIC: /* XXX ??? */
+		case MII_OUI_ATTANSIC: /* atphy(4) */
 			switch (phy_model) {
-			case 0x0004: /* XXX */
+			case MII_MODEL_ATTANSIC_AR8021:
 new_phytype = WMPHY_82578;
 break;
 			default:



CVS commit: src/sys/dev/pci

2021-11-04 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Nov  5 01:49:15 UTC 2021

Modified Files:
src/sys/dev/pci: if_wm.c

Log Message:
 Use macro. No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.716 -r1.717 src/sys/dev/pci/if_wm.c

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



Re: CVS commit: src

2021-11-04 Thread Joerg Sonnenberger
On Mon, Nov 01, 2021 at 03:09:59AM +, Alistair G. Crooks wrote:
> Module Name:  src
> Committed By: agc
> Date: Mon Nov  1 03:09:59 UTC 2021
> 
> Modified Files:
>   src/external/apache2/argon2/dist/phc-winner-argon2/src: argon2.c core.c
>   src/lib/libcrypt: Makefile
> 
> Log Message:
> Remove the
> 
>   COPTS.*+=   -Wno-error=.*
> 
> lines for building argon2 sources, by fixing the problems at source.
> 
> Addresses Rin Okuyama's concerns on tech-userlevel/tech-crypto in
> 
>   Message-ID: 

The +1 part seems questionable to me as it can actually introduce a wrap
around, can't it?

Joerg


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

2021-11-04 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Nov  4 21:31:30 UTC 2021

Modified Files:
src/sys/arch/arm/fdt: gic_fdt.c

Log Message:
make compilable at NPCI==0


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/fdt/gic_fdt.c

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

Modified files:

Index: src/sys/arch/arm/fdt/gic_fdt.c
diff -u src/sys/arch/arm/fdt/gic_fdt.c:1.23 src/sys/arch/arm/fdt/gic_fdt.c:1.24
--- src/sys/arch/arm/fdt/gic_fdt.c:1.23	Sat Aug  7 16:18:43 2021
+++ src/sys/arch/arm/fdt/gic_fdt.c	Thu Nov  4 21:31:30 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: gic_fdt.c,v 1.23 2021/08/07 16:18:43 thorpej Exp $ */
+/* $NetBSD: gic_fdt.c,v 1.24 2021/11/04 21:31:30 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill 
@@ -29,7 +29,7 @@
 #include "pci.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.23 2021/08/07 16:18:43 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.24 2021/11/04 21:31:30 jakllsch Exp $");
 
 #include 
 #include 
@@ -117,10 +117,12 @@ static const struct device_compatible_en
 	DEVICE_COMPAT_EOL
 };
 
+#if NPCI > 0 && defined(__HAVE_PCI_MSI_MSIX)
 static const struct device_compatible_entry v2m_compat_data[] = {
 	{ .compat = "arm,gic-v2m-frame" },
 	DEVICE_COMPAT_EOL
 };
+#endif
 
 static int
 gic_fdt_match(device_t parent, cfdata_t cf, void *aux)



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

2021-11-04 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Nov  4 21:31:30 UTC 2021

Modified Files:
src/sys/arch/arm/fdt: gic_fdt.c

Log Message:
make compilable at NPCI==0


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/fdt/gic_fdt.c

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



CVS commit: src/usr.bin/indent

2021-11-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Nov  4 20:31:05 UTC 2021

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

Log Message:
indent: split process_comment_in_code into separate functions

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.206 -r1.207 src/usr.bin/indent/indent.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/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.206 src/usr.bin/indent/indent.c:1.207
--- src/usr.bin/indent/indent.c:1.206	Thu Nov  4 17:12:12 2021
+++ src/usr.bin/indent/indent.c	Thu Nov  4 20:31:04 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.206 2021/11/04 17:12:12 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.207 2021/11/04 20:31:04 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.206 2021/11/04 17:12:12 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.207 2021/11/04 20:31:04 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -685,31 +685,31 @@ process_end_of_file(void)
 }
 
 static void
-process_comment_in_code(lexer_symbol lsym, bool *force_nl)
+maybe_break_line(lexer_symbol lsym, bool *force_nl)
 {
-if (*force_nl &&
-	lsym != lsym_semicolon &&
-	(lsym != lsym_lbrace || !opt.brace_same_line)) {
-
-	/* we should force a broken line here */
-	if (opt.verbose)
-	diag(0, "Line broken");
-	dump_line();
-	ps.want_blank = false;	/* don't insert blank at line start */
-	*force_nl = false;
-}
+if (!*force_nl)
+	return;
+if (lsym == lsym_semicolon)
+	return;
+else if (lsym == lsym_lbrace && opt.brace_same_line)
+	return;
 
-/* add an extra level of indentation; turned off again by a ';' or '}' */
-ps.in_stmt = true;
+if (opt.verbose)
+	diag(0, "Line broken");
+dump_line();
+ps.want_blank = false;
+*force_nl = false;
+}
 
-if (com.s != com.e) {	/* a comment embedded in a line */
-	buf_add_char(, ' ');
-	buf_add_buf(, );
-	buf_add_char(, ' ');
-	buf_terminate();
-	buf_reset();
-	ps.want_blank = false;
-}
+static void
+move_com_to_code(void)
+{
+buf_add_char(, ' ');
+buf_add_buf(, );
+buf_add_char(, ' ');
+buf_terminate();
+buf_reset();
+ps.want_blank = false;
 }
 
 static void
@@ -1402,8 +1402,13 @@ main_loop(void)
 	if (lsym == lsym_newline || lsym == lsym_form_feed ||
 		lsym == lsym_preprocessing)
 	force_nl = false;
-	else if (lsym != lsym_comment)
-	process_comment_in_code(lsym, _nl);
+	else if (lsym != lsym_comment) {
+	maybe_break_line(lsym, _nl);
+	ps.in_stmt = true;	/* add an extra level of indentation; turned
+ * off again by a ';' or '}' */
+	if (com.s != com.e)
+		move_com_to_code();
+	}
 
 	buf_reserve(, 3);	/* space for 2 characters plus '\0' */
 



CVS commit: src/usr.bin/indent

2021-11-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Nov  4 20:31:05 UTC 2021

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

Log Message:
indent: split process_comment_in_code into separate functions

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.206 -r1.207 src/usr.bin/indent/indent.c

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



CVS commit: src/usr.bin/indent

2021-11-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Nov  4 19:23:57 UTC 2021

Modified Files:
src/usr.bin/indent: io.c

Log Message:
indent: do not discard former error comments anymore

Since io.c 1.20 from 2019-10-19, indent has not placed error comments in
the code anymore. Since these comments are supposed to be cleaned up
immediately, there is no point in having code for handling them.


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 src/usr.bin/indent/io.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/indent/io.c
diff -u src/usr.bin/indent/io.c:1.113 src/usr.bin/indent/io.c:1.114
--- src/usr.bin/indent/io.c:1.113	Thu Nov  4 17:10:37 2021
+++ src/usr.bin/indent/io.c	Thu Nov  4 19:23:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.113 2021/11/04 17:10:37 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.114 2021/11/04 19:23:57 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)io.c	8.1 (Be
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.113 2021/11/04 17:10:37 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.114 2021/11/04 19:23:57 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -450,12 +450,8 @@ inbuf_read_line(void)
 inp.s = inp.buf;
 inp.e = p;
 
-if (p - inp.s >= 3 && p[-3] == '*' && p[-2] == '/') {
-	if (strncmp(inp.s, "/**INDENT**", 11) == 0)
-	inbuf_read_line();	/* flush indent error message */
-	else
-	parse_indent_comment();
-}
+if (p - inp.s >= 3 && p[-3] == '*' && p[-2] == '/')
+	parse_indent_comment();
 
 if (inhibit_formatting)
 	output_range(inp.s, inp.e);



CVS commit: src/usr.bin/indent

2021-11-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Nov  4 19:23:57 UTC 2021

Modified Files:
src/usr.bin/indent: io.c

Log Message:
indent: do not discard former error comments anymore

Since io.c 1.20 from 2019-10-19, indent has not placed error comments in
the code anymore. Since these comments are supposed to be cleaned up
immediately, there is no point in having code for handling them.


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 src/usr.bin/indent/io.c

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



CVS commit: src

2021-11-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Nov  4 18:38:37 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token_comment.c
src/usr.bin/indent: pr_comment.c

Log Message:
indent: fix parsing of C99 comments containing '*/'


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/tests/usr.bin/indent/token_comment.c
cvs rdiff -u -r1.95 -r1.96 src/usr.bin/indent/pr_comment.c

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



CVS commit: src

2021-11-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Nov  4 18:38:37 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token_comment.c
src/usr.bin/indent: pr_comment.c

Log Message:
indent: fix parsing of C99 comments containing '*/'


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/tests/usr.bin/indent/token_comment.c
cvs rdiff -u -r1.95 -r1.96 src/usr.bin/indent/pr_comment.c

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

Modified files:

Index: src/tests/usr.bin/indent/token_comment.c
diff -u src/tests/usr.bin/indent/token_comment.c:1.16 src/tests/usr.bin/indent/token_comment.c:1.17
--- src/tests/usr.bin/indent/token_comment.c:1.16	Thu Nov  4 18:31:22 2021
+++ src/tests/usr.bin/indent/token_comment.c	Thu Nov  4 18:38:37 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token_comment.c,v 1.16 2021/11/04 18:31:22 rillig Exp $ */
+/* $NetBSD: token_comment.c,v 1.17 2021/11/04 18:38:37 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -952,16 +952,13 @@ f(void)
 
 /*
  * Test for an edge cases in comment handling, having a block comment inside
- * a line comment.
+ * a line comment. Before NetBSD pr_comment.c 1.96 from 2021-11-04, indent
+ * wrongly assumed that the comment would end at the '*' '/', tokenizing the
+ * second word 'still' as a type_at_paren_level_0.
  */
 #indent input
 /* block comment */
 // line comment /* still a line comment */ still a line comment
 #indent end
 
-/* FIXME: The line comment must not be indented. */
-/* FIXME: The '*' '/' in the line comment must not be removed. */
-#indent run
-/* block comment */
- // line comment /* still a line comment  still a line comment
-#indent end
+#indent run-equals-input

Index: src/usr.bin/indent/pr_comment.c
diff -u src/usr.bin/indent/pr_comment.c:1.95 src/usr.bin/indent/pr_comment.c:1.96
--- src/usr.bin/indent/pr_comment.c:1.95	Thu Nov  4 17:37:03 2021
+++ src/usr.bin/indent/pr_comment.c	Thu Nov  4 18:38:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pr_comment.c,v 1.95 2021/11/04 17:37:03 rillig Exp $	*/
+/*	$NetBSD: pr_comment.c,v 1.96 2021/11/04 18:38:37 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)pr_comment.c
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: pr_comment.c,v 1.95 2021/11/04 17:37:03 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.96 2021/11/04 18:38:37 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -270,7 +270,7 @@ copy_comment(int adj_max_line_length, bo
 
 	case '*':
 	inbuf_skip();
-	if (*inp.s == '/') {
+	if (*inp.s == '/' && token.e[-1] == '*') {
 	end_of_comment:
 		inbuf_skip();
 
@@ -285,7 +285,7 @@ copy_comment(int adj_max_line_length, bo
 
 		if (!ch_isblank(com.e[-1]) && may_wrap)
 		com_add_char(' ');
-		if (token.e[-1] != '/') {
+		if (token.e[-1] == '*') {
 		com_add_char('*');
 		com_add_char('/');
 		}



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

2021-11-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Nov  4 18:31:23 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token_comment.c

Log Message:
tests/indent: demonstrate wrong edge case in C99 comments


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/tests/usr.bin/indent/token_comment.c

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

Modified files:

Index: src/tests/usr.bin/indent/token_comment.c
diff -u src/tests/usr.bin/indent/token_comment.c:1.15 src/tests/usr.bin/indent/token_comment.c:1.16
--- src/tests/usr.bin/indent/token_comment.c:1.15	Sat Oct 30 22:36:07 2021
+++ src/tests/usr.bin/indent/token_comment.c	Thu Nov  4 18:31:22 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token_comment.c,v 1.15 2021/10/30 22:36:07 rillig Exp $ */
+/* $NetBSD: token_comment.c,v 1.16 2021/11/04 18:31:22 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -948,3 +948,20 @@ f(void)
 		 /* 12 1234 123 123456 1234 1234567 123 1234.  */ ;
 }
 #indent end
+
+
+/*
+ * Test for an edge cases in comment handling, having a block comment inside
+ * a line comment.
+ */
+#indent input
+/* block comment */
+// line comment /* still a line comment */ still a line comment
+#indent end
+
+/* FIXME: The line comment must not be indented. */
+/* FIXME: The '*' '/' in the line comment must not be removed. */
+#indent run
+/* block comment */
+ // line comment /* still a line comment  still a line comment
+#indent end



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

2021-11-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Nov  4 18:31:23 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token_comment.c

Log Message:
tests/indent: demonstrate wrong edge case in C99 comments


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/tests/usr.bin/indent/token_comment.c

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



CVS commit: src/usr.bin/indent

2021-11-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Nov  4 17:37:03 UTC 2021

Modified Files:
src/usr.bin/indent: pr_comment.c

Log Message:
indent: split process_comments into separate functions

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/usr.bin/indent/pr_comment.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/indent/pr_comment.c
diff -u src/usr.bin/indent/pr_comment.c:1.94 src/usr.bin/indent/pr_comment.c:1.95
--- src/usr.bin/indent/pr_comment.c:1.94	Wed Nov  3 21:47:35 2021
+++ src/usr.bin/indent/pr_comment.c	Thu Nov  4 17:37:03 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pr_comment.c,v 1.94 2021/11/03 21:47:35 rillig Exp $	*/
+/*	$NetBSD: pr_comment.c,v 1.95 2021/11/04 17:37:03 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)pr_comment.c
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: pr_comment.c,v 1.94 2021/11/03 21:47:35 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.95 2021/11/04 17:37:03 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -99,41 +99,17 @@ fits_in_one_line(int max_line_length)
 return false;
 }
 
-/*
- * Scan, reformat and output a single comment, which is either a block comment
- * starting with '/' '*' or an end-of-line comment starting with '//'.
- *
- * Try to keep comments from going over the maximum line length.  If a line is
- * too long, move everything starting from the last blank to the next comment
- * line.  Blanks and tabs from the beginning of the input line are removed.
- *
- * ALGORITHM:
- *	1) Decide where the comment should be aligned, and if lines should
- *	   be broken.
- *	2) If lines should not be broken and filled, just copy up to end of
- *	   comment.
- *	3) If lines should be filled, then scan through the input buffer,
- *	   copying characters to com_buf.  Remember where the last blank,
- *	   tab, or newline was.  When line is filled, print up to last blank
- *	   and continue copying.
- */
-void
-process_comment(void)
+static void
+analyze_comment(int *p_adj_max_line_length, bool *p_break_delim,
+bool *p_may_wrap)
 {
 int adj_max_line_length;	/* Adjusted max_line_length for comments that
  * spill over the right margin */
-ssize_t last_blank;		/* index of the last blank in com.buf */
 bool break_delim = opt.comment_delimiter_on_blankline;
-int l_just_saw_decl = ps.just_saw_decl;
 int com_ind;
 
 adj_max_line_length = opt.max_line_length;
-ps.just_saw_decl = 0;
-last_blank = -1;		/* no blanks found so far */
 bool may_wrap = true;
-ps.stats.comments++;
-
-/* Figure where to align and how to treat the comment */
 
 if (ps.curr_col_1 && !opt.format_col1_comments) {
 	may_wrap = false;
@@ -220,7 +196,15 @@ process_comment(void)
 	com_add_delim();
 }
 
-/* Now copy the comment. */
+*p_adj_max_line_length = adj_max_line_length;
+*p_break_delim = break_delim;
+*p_may_wrap = may_wrap;
+}
+
+static void
+copy_comment(int adj_max_line_length, bool break_delim, bool may_wrap)
+{
+ssize_t last_blank = -1;	/* index of the last blank in com.buf */
 
 for (;;) {
 	switch (*inp.s) {
@@ -306,8 +290,6 @@ process_comment(void)
 		com_add_char('/');
 		}
 		com_terminate();
-
-		ps.just_saw_decl = l_just_saw_decl;
 		return;
 
 	} else		/* handle isolated '*' */
@@ -354,3 +336,39 @@ process_comment(void)
 	}
 }
 }
+
+/*
+ * Scan, reformat and output a single comment, which is either a block comment
+ * starting with '/' '*' or an end-of-line comment starting with '//'.
+ *
+ * Try to keep comments from going over the maximum line length.  If a line is
+ * too long, move everything starting from the last blank to the next comment
+ * line.  Blanks and tabs from the beginning of the input line are removed.
+ *
+ * ALGORITHM:
+ *	1) Decide where the comment should be aligned, and if lines should
+ *	   be broken.
+ *	2) If lines should not be broken and filled, just copy up to end of
+ *	   comment.
+ *	3) If lines should be filled, then scan through the input buffer,
+ *	   copying characters to com_buf.  Remember where the last blank,
+ *	   tab, or newline was.  When line is filled, print up to last blank
+ *	   and continue copying.
+ */
+void
+process_comment(void)
+{
+int adj_max_line_length;	/* Adjusted max_line_length for comments that
+ * spill over the right margin */
+bool break_delim = opt.comment_delimiter_on_blankline;
+
+adj_max_line_length = opt.max_line_length;
+ps.just_saw_decl = 0;
+bool may_wrap = true;
+ps.stats.comments++;
+
+int l_just_saw_decl = ps.just_saw_decl;
+analyze_comment(_max_line_length, _delim, _wrap);
+copy_comment(adj_max_line_length, break_delim, may_wrap);
+

CVS commit: src/usr.bin/indent

2021-11-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Nov  4 17:37:03 UTC 2021

Modified Files:
src/usr.bin/indent: pr_comment.c

Log Message:
indent: split process_comments into separate functions

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/usr.bin/indent/pr_comment.c

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



CVS commit: src

2021-11-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Nov  4 17:12:12 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token_binary_op.c token_unary_op.c
src/usr.bin/indent: indent.c

Log Message:
indent: fix joining of adjacent unary '+' operators


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/indent/token_binary_op.c
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/token_unary_op.c
cvs rdiff -u -r1.205 -r1.206 src/usr.bin/indent/indent.c

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

Modified files:

Index: src/tests/usr.bin/indent/token_binary_op.c
diff -u src/tests/usr.bin/indent/token_binary_op.c:1.6 src/tests/usr.bin/indent/token_binary_op.c:1.7
--- src/tests/usr.bin/indent/token_binary_op.c:1.6	Sat Oct 30 22:36:07 2021
+++ src/tests/usr.bin/indent/token_binary_op.c	Thu Nov  4 17:12:12 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token_binary_op.c,v 1.6 2021/10/30 22:36:07 rillig Exp $ */
+/* $NetBSD: token_binary_op.c,v 1.7 2021/11/04 17:12:12 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -214,7 +214,7 @@ peculiarities(void)
 	 *
 	 * See lexi.c, lexi, "case '+':".
 	 */
-	if (a++ ++ +++b)
+	if (a++ ++ ++ +b)
 		return;
 }
 #indent end

Index: src/tests/usr.bin/indent/token_unary_op.c
diff -u src/tests/usr.bin/indent/token_unary_op.c:1.1 src/tests/usr.bin/indent/token_unary_op.c:1.2
--- src/tests/usr.bin/indent/token_unary_op.c:1.1	Mon Oct 18 22:30:34 2021
+++ src/tests/usr.bin/indent/token_unary_op.c	Thu Nov  4 17:12:12 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token_unary_op.c,v 1.1 2021/10/18 22:30:34 rillig Exp $ */
+/* $NetBSD: token_unary_op.c,v 1.2 2021/11/04 17:12:12 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -16,7 +16,5 @@ int same = + + + + + - - - - - 3;
 int var = +3;
 int mixed = +-+-+-+-+-+-+-+-+-+-+-+-+-3;
 int count = ~-~-~-~-~-~-~-~-~-~-~-~-~-3;
-/* $ FIXME: There must be spaces between adjacent '+'. */
-/* $ FIXME: There must be spaces between adjacent '-'. */
-int same = +-3;
+int same = + + + + +- - - - -3;
 #indent end

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.205 src/usr.bin/indent/indent.c:1.206
--- src/usr.bin/indent/indent.c:1.205	Wed Nov  3 21:47:35 2021
+++ src/usr.bin/indent/indent.c	Thu Nov  4 17:12:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.205 2021/11/03 21:47:35 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.206 2021/11/04 17:12:12 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.205 2021/11/03 21:47:35 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.206 2021/11/04 17:12:12 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -834,6 +834,16 @@ process_rparen_or_rbracket(bool *spaced_
 ps.search_stmt = opt.brace_same_line;
 }
 
+static bool
+want_blank_before_unary_op(void)
+{
+if (ps.want_blank)
+	return true;
+if (token.s[0] == '+' || token.s[0] == '-')
+	return code.e[-1] == token.s[0];
+return false;
+}
+
 static void
 process_unary_op(int decl_ind, bool tabs_to_var)
 {
@@ -842,7 +852,7 @@ process_unary_op(int decl_ind, bool tabs
 	/* pointer declarations */
 	code_add_decl_indent(decl_ind - (int)buf_len(), tabs_to_var);
 	ps.decl_indent_done = true;
-} else if (ps.want_blank)
+} else if (want_blank_before_unary_op())
 	*code.e++ = ' ';
 
 buf_add_buf(, );



CVS commit: src

2021-11-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Nov  4 17:12:12 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token_binary_op.c token_unary_op.c
src/usr.bin/indent: indent.c

Log Message:
indent: fix joining of adjacent unary '+' operators


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/indent/token_binary_op.c
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/token_unary_op.c
cvs rdiff -u -r1.205 -r1.206 src/usr.bin/indent/indent.c

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



CVS commit: src/usr.bin/indent

2021-11-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Nov  4 17:10:37 UTC 2021

Modified Files:
src/usr.bin/indent: io.c

Log Message:
indent: extract compute_code_indent_lineup into separate function

Having 9 different paths in a single function made it more complicated
to understand than necessary.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.112 -r1.113 src/usr.bin/indent/io.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/indent/io.c
diff -u src/usr.bin/indent/io.c:1.112 src/usr.bin/indent/io.c:1.113
--- src/usr.bin/indent/io.c:1.112	Thu Nov  4 17:08:50 2021
+++ src/usr.bin/indent/io.c	Thu Nov  4 17:10:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.112 2021/11/04 17:08:50 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.113 2021/11/04 17:10:37 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)io.c	8.1 (Be
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.112 2021/11/04 17:08:50 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.113 2021/11/04 17:10:37 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -294,6 +294,24 @@ dump_line_ff(void)
 output_line('\f');
 }
 
+static int
+compute_code_indent_lineup(int base_ind)
+{
+int ti = paren_indent;
+int overflow = ind_add(ti, code.s, code.e) - opt.max_line_length;
+if (overflow < 0)
+	return ti;
+
+if (ind_add(base_ind, code.s, code.e) < opt.max_line_length) {
+	ti -= overflow + 2;
+	if (ti > base_ind)
+	return ti;
+	return base_ind;
+}
+
+return ti;
+}
+
 int
 compute_code_indent(void)
 {
@@ -308,20 +326,7 @@ compute_code_indent(void)
 if (opt.lineup_to_parens) {
 	if (opt.lineup_to_parens_always)
 	return paren_indent;
-
-	int ti = paren_indent;
-	int overflow = ind_add(ti, code.s, code.e) - opt.max_line_length;
-	if (overflow < 0)
-	return ti;
-
-	if (ind_add(base_ind, code.s, code.e) < opt.max_line_length) {
-	ti -= overflow + 2;
-	if (ti > base_ind)
-		return ti;
-	return base_ind;
-	}
-
-	return ti;
+	return compute_code_indent_lineup(base_ind);
 }
 
 if (2 * opt.continuation_indent == opt.indent_size)



CVS commit: src/usr.bin/indent

2021-11-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Nov  4 17:10:37 UTC 2021

Modified Files:
src/usr.bin/indent: io.c

Log Message:
indent: extract compute_code_indent_lineup into separate function

Having 9 different paths in a single function made it more complicated
to understand than necessary.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.112 -r1.113 src/usr.bin/indent/io.c

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



CVS commit: src/usr.bin/indent

2021-11-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Nov  4 17:08:50 UTC 2021

Modified Files:
src/usr.bin/indent: io.c

Log Message:
indent: fix off-by-one confusion in paren_indent

The variable was called 'indent' but actually contained a 'column',
which was off by one.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 src/usr.bin/indent/io.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/indent/io.c
diff -u src/usr.bin/indent/io.c:1.111 src/usr.bin/indent/io.c:1.112
--- src/usr.bin/indent/io.c:1.111	Thu Nov  4 17:07:02 2021
+++ src/usr.bin/indent/io.c	Thu Nov  4 17:08:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.111 2021/11/04 17:07:02 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.112 2021/11/04 17:08:50 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)io.c	8.1 (Be
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.111 2021/11/04 17:07:02 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.112 2021/11/04 17:08:50 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -275,7 +275,7 @@ output_line(char line_terminator)
 
 if (ps.paren_level > 0) {
 	/* TODO: explain what negative indentation means */
-	paren_indent = -ps.paren_indents[ps.paren_level - 1];
+	paren_indent = -1 - ps.paren_indents[ps.paren_level - 1];
 	debug_println("paren_indent is now %d", paren_indent);
 }
 
@@ -306,16 +306,10 @@ compute_code_indent(void)
 }
 
 if (opt.lineup_to_parens) {
-	if (opt.lineup_to_parens_always) {
-	/*
-	 * XXX: where does this '- 1' come from?  It looks strange but is
-	 * nevertheless needed for proper indentation, as demonstrated in
-	 * the test opt-lpl.0.
-	 */
-	return paren_indent - 1;
-	}
+	if (opt.lineup_to_parens_always)
+	return paren_indent;
 
-	int ti = paren_indent - 1;
+	int ti = paren_indent;
 	int overflow = ind_add(ti, code.s, code.e) - opt.max_line_length;
 	if (overflow < 0)
 	return ti;



CVS commit: src/usr.bin/indent

2021-11-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Nov  4 17:08:50 UTC 2021

Modified Files:
src/usr.bin/indent: io.c

Log Message:
indent: fix off-by-one confusion in paren_indent

The variable was called 'indent' but actually contained a 'column',
which was off by one.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 src/usr.bin/indent/io.c

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



CVS commit: src/usr.bin/indent

2021-11-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Nov  4 17:07:02 UTC 2021

Modified Files:
src/usr.bin/indent: io.c

Log Message:
indent: replace column computation with indentation computation

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/usr.bin/indent/io.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/indent/io.c
diff -u src/usr.bin/indent/io.c:1.110 src/usr.bin/indent/io.c:1.111
--- src/usr.bin/indent/io.c:1.110	Thu Nov  4 00:13:57 2021
+++ src/usr.bin/indent/io.c	Thu Nov  4 17:07:02 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.110 2021/11/04 00:13:57 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.111 2021/11/04 17:07:02 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)io.c	8.1 (Be
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.110 2021/11/04 00:13:57 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.111 2021/11/04 17:07:02 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -315,19 +315,19 @@ compute_code_indent(void)
 	return paren_indent - 1;
 	}
 
-	int w;
-	int t = paren_indent;
-
-	/* TODO: remove '+ 1' and '- 1' */
-	if ((w = 1 + ind_add(t - 1, code.s, code.e) - opt.max_line_length) > 0
-	&& 1 + ind_add(base_ind, code.s, code.e) <= opt.max_line_length) {
-	t -= w + 1;
-	if (t > base_ind + 1)
-		return t - 1;
+	int ti = paren_indent - 1;
+	int overflow = ind_add(ti, code.s, code.e) - opt.max_line_length;
+	if (overflow < 0)
+	return ti;
+
+	if (ind_add(base_ind, code.s, code.e) < opt.max_line_length) {
+	ti -= overflow + 2;
+	if (ti > base_ind)
+		return ti;
 	return base_ind;
 	}
 
-	return t - 1;
+	return ti;
 }
 
 if (2 * opt.continuation_indent == opt.indent_size)



CVS commit: src/usr.bin/indent

2021-11-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Nov  4 17:07:02 UTC 2021

Modified Files:
src/usr.bin/indent: io.c

Log Message:
indent: replace column computation with indentation computation

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/usr.bin/indent/io.c

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



CVS commit: src/etc

2021-11-04 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Thu Nov  4 12:40:01 UTC 2021

Modified Files:
src/etc: security

Log Message:
Recognize argon2 passwords as valid in daily security reports.

from RVP in misc/56486


To generate a diff of this commit:
cvs rdiff -u -r1.128 -r1.129 src/etc/security

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

Modified files:

Index: src/etc/security
diff -u src/etc/security:1.128 src/etc/security:1.129
--- src/etc/security:1.128	Sun Jan 10 23:24:25 2021
+++ src/etc/security	Thu Nov  4 12:40:00 2021
@@ -1,6 +1,6 @@
 #!/bin/sh -
 #
-#	$NetBSD: security,v 1.128 2021/01/10 23:24:25 riastradh Exp $
+#	$NetBSD: security,v 1.129 2021/11/04 12:40:00 nia Exp $
 #	from: @(#)security	8.1 (Berkeley) 6/9/93
 #
 
@@ -274,6 +274,7 @@ if checkyesno check_passwd; then
 			$2 !~ /^\$1/ &&
 			$2 !~ /^\$2/ &&
 			$2 !~ /^\$sha1/ &&
+			$2 !~ /^\$argon2(i|d|id)/ &&
 			$2 != "" &&
 			(permit_star || $2 != "*") &&
 			$2 !~ /^\*[A-z-]+$/ &&



CVS commit: src/etc

2021-11-04 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Thu Nov  4 12:40:01 UTC 2021

Modified Files:
src/etc: security

Log Message:
Recognize argon2 passwords as valid in daily security reports.

from RVP in misc/56486


To generate a diff of this commit:
cvs rdiff -u -r1.128 -r1.129 src/etc/security

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



CVS commit: src/sys/dev/pci

2021-11-04 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Nov  4 12:25:05 UTC 2021

Modified Files:
src/sys/dev/pci: if_wm.c

Log Message:
Add some sysctl info for debugging.


To generate a diff of this commit:
cvs rdiff -u -r1.715 -r1.716 src/sys/dev/pci/if_wm.c

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

Modified files:

Index: src/sys/dev/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.715 src/sys/dev/pci/if_wm.c:1.716
--- src/sys/dev/pci/if_wm.c:1.715	Wed Oct 20 08:10:26 2021
+++ src/sys/dev/pci/if_wm.c	Thu Nov  4 12:25:05 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.715 2021/10/20 08:10:26 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.716 2021/11/04 12:25:05 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.715 2021/10/20 08:10:26 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.716 2021/11/04 12:25:05 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -1068,6 +1068,8 @@ static bool	wm_phy_need_linkdown_discard
 static void	wm_set_linkdown_discard(struct wm_softc *);
 static void	wm_clear_linkdown_discard(struct wm_softc *);
 
+static int	wm_sysctl_tdh_handler(SYSCTLFN_PROTO);
+static int	wm_sysctl_tdt_handler(SYSCTLFN_PROTO);
 #ifdef WM_DEBUG
 static int	wm_sysctl_debug(SYSCTLFN_PROTO);
 #endif
@@ -5991,6 +5993,7 @@ wm_init_sysctls(struct wm_softc *sc)
 		sc->sc_queue[i].sysctlname, SYSCTL_DESCR("Queue Name"),
 		NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL) != 0)
 			break;
+
 		if (sysctl_createv(log, 0, , ,
 		CTLFLAG_READONLY, CTLTYPE_INT,
 		"txq_free", SYSCTL_DESCR("TX queue free"),
@@ -5999,10 +6002,58 @@ wm_init_sysctls(struct wm_softc *sc)
 			break;
 		if (sysctl_createv(log, 0, , ,
 		CTLFLAG_READONLY, CTLTYPE_INT,
+		"txd_head", SYSCTL_DESCR("TX descriptor head"),
+		wm_sysctl_tdh_handler, 0, (void *)txq,
+		0, CTL_CREATE, CTL_EOL) != 0)
+			break;
+		if (sysctl_createv(log, 0, , ,
+		CTLFLAG_READONLY, CTLTYPE_INT,
+		"txd_tail", SYSCTL_DESCR("TX descriptor tail"),
+		wm_sysctl_tdt_handler, 0, (void *)txq,
+		0, CTL_CREATE, CTL_EOL) != 0)
+			break;
+		if (sysctl_createv(log, 0, , ,
+		CTLFLAG_READONLY, CTLTYPE_INT,
 		"txq_next", SYSCTL_DESCR("TX queue next"),
 		NULL, 0, >txq_next,
 		0, CTL_CREATE, CTL_EOL) != 0)
 			break;
+		if (sysctl_createv(log, 0, , ,
+		CTLFLAG_READONLY, CTLTYPE_INT,
+		"txq_sfree", SYSCTL_DESCR("TX queue sfree"),
+		NULL, 0, >txq_sfree,
+		0, CTL_CREATE, CTL_EOL) != 0)
+			break;
+		if (sysctl_createv(log, 0, , ,
+		CTLFLAG_READONLY, CTLTYPE_INT,
+		"txq_snext", SYSCTL_DESCR("TX queue snext"),
+		NULL, 0, >txq_snext,
+		0, CTL_CREATE, CTL_EOL) != 0)
+			break;
+		if (sysctl_createv(log, 0, , ,
+		CTLFLAG_READONLY, CTLTYPE_INT,
+		"txq_sdirty", SYSCTL_DESCR("TX queue sdirty"),
+		NULL, 0, >txq_sdirty,
+		0, CTL_CREATE, CTL_EOL) != 0)
+			break;
+		if (sysctl_createv(log, 0, , ,
+		CTLFLAG_READONLY, CTLTYPE_INT,
+		"txq_flags", SYSCTL_DESCR("TX queue flags"),
+		NULL, 0, >txq_flags,
+		0, CTL_CREATE, CTL_EOL) != 0)
+			break;
+		if (sysctl_createv(log, 0, , ,
+		CTLFLAG_READONLY, CTLTYPE_BOOL,
+		"txq_stopping", SYSCTL_DESCR("TX queue stopping"),
+		NULL, 0, >txq_stopping,
+		0, CTL_CREATE, CTL_EOL) != 0)
+			break;
+		if (sysctl_createv(log, 0, , ,
+		CTLFLAG_READONLY, CTLTYPE_BOOL,
+		"txq_sending", SYSCTL_DESCR("TX queue sending"),
+		NULL, 0, >txq_sending,
+		0, CTL_CREATE, CTL_EOL) != 0)
+			break;
 
 		if (sysctl_createv(log, 0, , ,
 		CTLFLAG_READONLY, CTLTYPE_INT,
@@ -17084,7 +17135,35 @@ wm_legacy_irq_quirk_spt(struct wm_softc 
 	CSR_WRITE(sc, WMREG_FEXTNVM9, reg);
 }
 
-/* Sysctl function */
+/* Sysctl functions */
+static int
+wm_sysctl_tdh_handler(SYSCTLFN_ARGS)
+{
+	struct sysctlnode node = *rnode;
+	struct wm_txqueue *txq = (struct wm_txqueue *)node.sysctl_data;
+	struct wm_queue *wmq = container_of(txq, struct wm_queue, wmq_txq);
+	struct wm_softc *sc = txq->txq_sc; 
+	uint32_t reg;
+
+	reg = CSR_READ(sc, WMREG_TDH(wmq->wmq_id));
+	node.sysctl_data = 
+	return sysctl_lookup(SYSCTLFN_CALL());
+}
+
+static int
+wm_sysctl_tdt_handler(SYSCTLFN_ARGS)
+{
+	struct sysctlnode node = *rnode;
+	struct wm_txqueue *txq = (struct wm_txqueue *)node.sysctl_data;
+	struct wm_queue *wmq = container_of(txq, struct wm_queue, wmq_txq);
+	struct wm_softc *sc = txq->txq_sc; 
+	uint32_t reg;
+
+	reg = CSR_READ(sc, WMREG_TDT(wmq->wmq_id));
+	node.sysctl_data = 
+	return sysctl_lookup(SYSCTLFN_CALL());
+}
+
 #ifdef WM_DEBUG
 static int
 wm_sysctl_debug(SYSCTLFN_ARGS)
@@ -17102,6 +17181,8 @@ wm_sysctl_debug(SYSCTLFN_ARGS)
 		return error;
 
 	sc->sc_debug = dflags;
+	device_printf(sc->sc_dev, "TARC0: %08x\n", CSR_READ(sc, WMREG_TARC0));
+	device_printf(sc->sc_dev, "TDT0: %08x\n", CSR_READ(sc, 

CVS commit: src/sys/dev/pci

2021-11-04 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Nov  4 12:25:05 UTC 2021

Modified Files:
src/sys/dev/pci: if_wm.c

Log Message:
Add some sysctl info for debugging.


To generate a diff of this commit:
cvs rdiff -u -r1.715 -r1.716 src/sys/dev/pci/if_wm.c

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



CVS commit: src/sys/stand/efiboot

2021-11-04 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Nov  4 07:28:34 UTC 2021

Modified Files:
src/sys/stand/efiboot: boot.c

Log Message:
Fix non-ACPI builds.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/stand/efiboot/boot.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/stand/efiboot/boot.c
diff -u src/sys/stand/efiboot/boot.c:1.41 src/sys/stand/efiboot/boot.c:1.42
--- src/sys/stand/efiboot/boot.c:1.41	Wed Nov  3 22:02:36 2021
+++ src/sys/stand/efiboot/boot.c	Thu Nov  4 07:28:34 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.41 2021/11/03 22:02:36 skrll Exp $	*/
+/*	$NetBSD: boot.c,v 1.42 2021/11/04 07:28:34 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -93,7 +93,9 @@ static char rndseed_path[255];
 int	set_bootfile(const char *);
 int	set_bootargs(const char *);
 
+#ifdef EFIBOOT_ACPI
 void	command_acpi(char *);
+#endif
 void	command_boot(char *);
 void	command_dev(char *);
 void	command_initrd(char *);
@@ -116,7 +118,9 @@ void	command_version(char *);
 void	command_quit(char *);
 
 const struct boot_command commands[] = {
+#ifdef EFIBOOT_ACPI
 	{ "acpi",	command_acpi,		"acpi [{on|off}]" },
+#endif
 	{ "boot",	command_boot,		"boot [dev:][filename] [args]\n (ex. \"hd0a:\\netbsd.old -s\"" },
 	{ "dev",	command_dev,		"dev" },
 #ifdef EFIBOOT_FDT
@@ -174,6 +178,7 @@ command_help(char *arg)
 	}
 }
 
+#ifdef EFIBOOT_ACPI
 void
 command_acpi(char *arg)
 {
@@ -191,6 +196,8 @@ command_acpi(char *arg)
 		efi_acpi_enabled() ? "en" : "dis");
 	}
 }
+#endif
+
 void
 command_boot(char *arg)
 {



CVS commit: src/sys/stand/efiboot

2021-11-04 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Nov  4 07:28:34 UTC 2021

Modified Files:
src/sys/stand/efiboot: boot.c

Log Message:
Fix non-ACPI builds.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/stand/efiboot/boot.c

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



Re: CVS commit: src

2021-11-04 Thread Rin Okuyama

On 2021/11/01 12:09, Alistair G. Crooks wrote:

Module Name:src
Committed By:   agc
Date:   Mon Nov  1 03:09:59 UTC 2021

Modified Files:
src/external/apache2/argon2/dist/phc-winner-argon2/src: argon2.c core.c
src/lib/libcrypt: Makefile

Log Message:
Remove the

COPTS.*+=   -Wno-error=.*

lines for building argon2 sources, by fixing the problems at source.

Addresses Rin Okuyama's concerns on tech-userlevel/tech-crypto in

Message-ID: 


Thanks! It got clearer!

rin


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

2021-11-04 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Nov  4 06:57:51 UTC 2021

Modified Files:
src/sys/arch/arm/at91: at91emac.c

Log Message:
Remove unnecessary duplicate bit define in mask

PR port-arm/50687


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/arm/at91/at91emac.c

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



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

2021-11-04 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Nov  4 06:57:51 UTC 2021

Modified Files:
src/sys/arch/arm/at91: at91emac.c

Log Message:
Remove unnecessary duplicate bit define in mask

PR port-arm/50687


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/arm/at91/at91emac.c

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

Modified files:

Index: src/sys/arch/arm/at91/at91emac.c
diff -u src/sys/arch/arm/at91/at91emac.c:1.32 src/sys/arch/arm/at91/at91emac.c:1.33
--- src/sys/arch/arm/at91/at91emac.c:1.32	Wed Feb 19 02:51:54 2020
+++ src/sys/arch/arm/at91/at91emac.c	Thu Nov  4 06:57:51 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: at91emac.c,v 1.32 2020/02/19 02:51:54 thorpej Exp $	*/
+/*	$NetBSD: at91emac.c,v 1.33 2021/11/04 06:57:51 skrll Exp $	*/
 
 /*
  * Copyright (c) 2007 Embedtronics Oy
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: at91emac.c,v 1.32 2020/02/19 02:51:54 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: at91emac.c,v 1.33 2021/11/04 06:57:51 skrll Exp $");
 
 #include 
 #include 
@@ -774,7 +774,7 @@ emac_setaddr(struct ifnet *ifp)
 	/* disable receiver temporarily */
 	EMAC_WRITE(ETH_CTL, ctl & ~ETH_CTL_RE);
 
-	cfg &= ~(ETH_CFG_MTI | ETH_CFG_UNI | ETH_CFG_CAF | ETH_CFG_UNI);
+	cfg &= ~(ETH_CFG_MTI | ETH_CFG_UNI | ETH_CFG_CAF);
 
 	if (ifp->if_flags & IFF_PROMISC) {
 		cfg |=	ETH_CFG_CAF;