CVS commit: src/usr.bin/xlint

2022-02-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Feb 27 07:50:09 UTC 2022

Modified Files:
src/usr.bin/xlint: Makefile.inc
src/usr.bin/xlint/lint1: lex.c lint1.h

Log Message:
lint: clean up memory management for string buffers

There is no reason to duplicate all the work that is already done by the
memory allocator.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/xlint/Makefile.inc
cvs rdiff -u -r1.99 -r1.100 src/usr.bin/xlint/lint1/lex.c
cvs rdiff -u -r1.137 -r1.138 src/usr.bin/xlint/lint1/lint1.h

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

Modified files:

Index: src/usr.bin/xlint/Makefile.inc
diff -u src/usr.bin/xlint/Makefile.inc:1.19 src/usr.bin/xlint/Makefile.inc:1.20
--- src/usr.bin/xlint/Makefile.inc:1.19	Sat Feb 26 18:35:01 2022
+++ src/usr.bin/xlint/Makefile.inc	Sun Feb 27 07:50:09 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.19 2022/02/26 18:35:01 rillig Exp $
+#	$NetBSD: Makefile.inc,v 1.20 2022/02/27 07:50:09 rillig Exp $
 
 .include 
 
@@ -16,7 +16,6 @@ ARCHSUBDIR=	${MACHINE_CPU}
 
 CPPFLAGS+=	-I${.CURDIR}/../arch/${ARCHSUBDIR}
 CPPFLAGS+=	-I${.CURDIR}/../common
-CPPFLAGS+=	-DBLKDEBUG
 
 CLEANFILES+=	*.gcno *.gcda *.gcov
 

Index: src/usr.bin/xlint/lint1/lex.c
diff -u src/usr.bin/xlint/lint1/lex.c:1.99 src/usr.bin/xlint/lint1/lex.c:1.100
--- src/usr.bin/xlint/lint1/lex.c:1.99	Sun Feb 27 07:38:54 2022
+++ src/usr.bin/xlint/lint1/lex.c	Sun Feb 27 07:50:09 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.99 2022/02/27 07:38:54 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.100 2022/02/27 07:50:09 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: lex.c,v 1.99 2022/02/27 07:38:54 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.100 2022/02/27 07:50:09 rillig Exp $");
 #endif
 
 #include 
@@ -67,8 +67,6 @@ pos_t	csrc_pos = { "", 1, 0 };
 bool in_gcc_attribute;
 bool in_system_header;
 
-static	sbuf_t *allocsb(void);
-static	void	freesb(sbuf_t *);
 static	int	inpc(void);
 static	unsigned int hash(const char *);
 static	sym_t *	search(sbuf_t *);
@@ -258,8 +256,6 @@ static struct keyword {
 /* Symbol table */
 static	sym_t	*symtab[HSHSIZ1];
 
-static	sbuf_t	 *sbuf_free_list;
-
 /* type of next expected symbol */
 symt_t	symtyp;
 
@@ -342,40 +338,6 @@ initscan(void)
 }
 
 /*
- * Get a free sbuf structure, if possible from the free list
- */
-static sbuf_t *
-allocsb(void)
-{
-	sbuf_t	*sb;
-
-	if ((sb = sbuf_free_list) != NULL) {
-		sbuf_free_list = sb->sb_next;
-#ifdef BLKDEBUG
-		(void)memset(sb, 0, sizeof(*sb));
-#else
-		sb->sb_next = NULL;
-#endif
-	} else {
-		sb = xmalloc(sizeof(*sb));
-		(void)memset(sb, 0, sizeof(*sb));
-	}
-	return sb;
-}
-
-/*
- * Put a sbuf structure to the free list
- */
-static void
-freesb(sbuf_t *sb)
-{
-
-	(void)memset(sb, 0xa5, sizeof(*sb));
-	sb->sb_next = sbuf_free_list;
-	sbuf_free_list = sb;
-}
-
-/*
  * Read a character and ensure that it is positive (except EOF).
  * Increment line count(s) if necessary.
  */
@@ -429,11 +391,11 @@ lex_name(const char *yytext, size_t yyle
 	sym_t	*sym;
 	int	tok;
 
-	sb = allocsb();
+	sb = xmalloc(sizeof(*sb));
 	sb->sb_name = yytext;
 	sb->sb_len = yyleng;
 	if ((sym = search(sb)) != NULL && sym->s_keyword != NULL) {
-		freesb(sb);
+		free(sb);
 		return keyw(sym);
 	}
 
@@ -1382,7 +1344,7 @@ getsym(sbuf_t *sb)
 	if (sym != NULL) {
 		lint_assert(sym->s_kind == symtyp);
 		symtyp = FVFT;
-		freesb(sb);
+		free(sb);
 		return sym;
 	}
 
@@ -1417,7 +1379,7 @@ getsym(sbuf_t *sb)
 	*di->d_ldlsym = sym;
 	di->d_ldlsym = >s_dlnxt;
 
-	freesb(sb);
+	free(sb);
 	return sym;
 }
 
@@ -1563,7 +1525,7 @@ freeyyv(void *sp, int tok)
 {
 	if (tok == T_NAME || tok == T_TYPENAME) {
 		sbuf_t *sb = *(sbuf_t **)sp;
-		freesb(sb);
+		free(sb);
 	} else if (tok == T_CON) {
 		val_t *val = *(val_t **)sp;
 		free(val);

Index: src/usr.bin/xlint/lint1/lint1.h
diff -u src/usr.bin/xlint/lint1/lint1.h:1.137 src/usr.bin/xlint/lint1/lint1.h:1.138
--- src/usr.bin/xlint/lint1/lint1.h:1.137	Sun Feb 27 07:38:54 2022
+++ src/usr.bin/xlint/lint1/lint1.h	Sun Feb 27 07:50:09 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.137 2022/02/27 07:38:54 rillig Exp $ */
+/* $NetBSD: lint1.h,v 1.138 2022/02/27 07:50:09 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -294,7 +294,6 @@ typedef	struct sbuf {
 	const	char *sb_name;		/* name of symbol */
 	size_t	sb_len;			/* length (without '\0') */
 	sym_t	*sb_sym;		/* symbol table entry */
-	struct	sbuf *sb_next;		/* for freelist */
 } sbuf_t;
 
 



CVS commit: src/usr.bin/xlint

2022-02-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Feb 27 07:50:09 UTC 2022

Modified Files:
src/usr.bin/xlint: Makefile.inc
src/usr.bin/xlint/lint1: lex.c lint1.h

Log Message:
lint: clean up memory management for string buffers

There is no reason to duplicate all the work that is already done by the
memory allocator.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/xlint/Makefile.inc
cvs rdiff -u -r1.99 -r1.100 src/usr.bin/xlint/lint1/lex.c
cvs rdiff -u -r1.137 -r1.138 src/usr.bin/xlint/lint1/lint1.h

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



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

2022-02-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Feb 27 07:38:54 UTC 2022

Modified Files:
src/usr.bin/xlint/lint1: lex.c lint1.h mem1.c

Log Message:
lint: clean up memory allocation

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/usr.bin/xlint/lint1/lex.c
cvs rdiff -u -r1.136 -r1.137 src/usr.bin/xlint/lint1/lint1.h
cvs rdiff -u -r1.58 -r1.59 src/usr.bin/xlint/lint1/mem1.c

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

Modified files:

Index: src/usr.bin/xlint/lint1/lex.c
diff -u src/usr.bin/xlint/lint1/lex.c:1.98 src/usr.bin/xlint/lint1/lex.c:1.99
--- src/usr.bin/xlint/lint1/lex.c:1.98	Sat Feb 26 23:07:28 2022
+++ src/usr.bin/xlint/lint1/lex.c	Sun Feb 27 07:38:54 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.98 2022/02/26 23:07:28 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.99 2022/02/27 07:38:54 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: lex.c,v 1.98 2022/02/26 23:07:28 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.99 2022/02/27 07:38:54 rillig Exp $");
 #endif
 
 #include 
@@ -370,7 +370,7 @@ static void
 freesb(sbuf_t *sb)
 {
 
-	(void)memset(sb, INVALID_MEM_BYTE, sizeof(*sb));
+	(void)memset(sb, 0xa5, sizeof(*sb));
 	sb->sb_next = sbuf_free_list;
 	sbuf_free_list = sb;
 }

Index: src/usr.bin/xlint/lint1/lint1.h
diff -u src/usr.bin/xlint/lint1/lint1.h:1.136 src/usr.bin/xlint/lint1/lint1.h:1.137
--- src/usr.bin/xlint/lint1/lint1.h:1.136	Sun Feb 27 01:47:28 2022
+++ src/usr.bin/xlint/lint1/lint1.h	Sun Feb 27 07:38:54 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.136 2022/02/27 01:47:28 rillig Exp $ */
+/* $NetBSD: lint1.h,v 1.137 2022/02/27 07:38:54 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -485,12 +485,6 @@ typedef	struct err_set {
 			assert_failed(__FILE__, __LINE__, __func__, #cond); \
 	} while (false)
 
-#ifdef BLKDEBUG
-#define INVALID_MEM_BYTE	0xa5
-#else
-#define	INVALID_MEM_BYTE	0
-#endif
-
 extern err_set	msgset;
 
 

Index: src/usr.bin/xlint/lint1/mem1.c
diff -u src/usr.bin/xlint/lint1/mem1.c:1.58 src/usr.bin/xlint/lint1/mem1.c:1.59
--- src/usr.bin/xlint/lint1/mem1.c:1.58	Sun Feb 27 06:55:13 2022
+++ src/usr.bin/xlint/lint1/mem1.c	Sun Feb 27 07:38:54 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: mem1.c,v 1.58 2022/02/27 06:55:13 rillig Exp $	*/
+/*	$NetBSD: mem1.c,v 1.59 2022/02/27 07:38:54 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: mem1.c,v 1.58 2022/02/27 06:55:13 rillig Exp $");
+__RCSID("$NetBSD: mem1.c,v 1.59 2022/02/27 07:38:54 rillig Exp $");
 #endif
 
 #include 
@@ -172,45 +172,27 @@ get_filename_id(const char *s)
 }
 
 /*
- * Memory for declarations and other things which must be available
+ * Memory for declarations and other things that must be available
  * until the end of a block (or the end of the translation unit)
  * is associated with the corresponding mem_block_level, which may be 0.
  * Because this memory is allocated in large blocks associated with
  * a given level it can be freed easily at the end of a block.
  */
-#define	ML_INC	((size_t)32)		/* Increment for length of *mblks */
-
 typedef struct memory_block {
 	void	*start;			/* beginning of memory block */
 	void	*first_free;		/* first free byte */
 	size_t	nfree;			/* # of free bytes */
-	size_t	size;			/* total size of memory block */
 	struct	memory_block *next;
 } memory_block;
 
-/*
- * Array of pointers to lists of memory blocks. mem_block_level is used as
- * index into this array.
- */
-static	memory_block	**mblks;
-
-/* number of elements in *mblks */
-static	size_t	nmblks;
 
-/* length of new allocated memory blocks */
-static	size_t	mblklen;
+static	size_t	mblk_size;	/* size of newly allocated memory blocks */
 
+/* Array of lists of memory blocks, indexed by mem_block_level. */
+static	memory_block	**mblks;
+static	size_t	nmblks;		/* number of elements in *mblks */
+#define	ML_INC	((size_t)32)	/* Increment for length of *mblks */
 
-static memory_block *
-xnewblk(void)
-{
-	memory_block	*mb = xmalloc(sizeof(*mb));
-
-	mb->start = xmalloc(mblklen);
-	mb->size = mblklen;
-
-	return mb;
-}
 
 /* Allocate new memory, initialized with zero. */
 static void *
@@ -218,41 +200,23 @@ xgetblk(memory_block **mbp, size_t s)
 {
 	memory_block	*mb;
 	void	*p;
-	size_t	t = 0;
-
-	/*
-	 * If the first block of the list has not enough free space,
-	 * or there is no first block, get a new block. The new block
-	 * is taken from the free list or, if there is no block on the
-	 * free list, is allocated using xnewblk().
-	 *
-	 * If a new block is allocated it is initialized with zero.
-	 * Blocks taken from the free list are zero'd in xfreeblk().
-	 */
 
 	s = WORST_ALIGN(s);
+
 	if ((mb = *mbp) == NULL || 

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

2022-02-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Feb 27 07:38:54 UTC 2022

Modified Files:
src/usr.bin/xlint/lint1: lex.c lint1.h mem1.c

Log Message:
lint: clean up memory allocation

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/usr.bin/xlint/lint1/lex.c
cvs rdiff -u -r1.136 -r1.137 src/usr.bin/xlint/lint1/lint1.h
cvs rdiff -u -r1.58 -r1.59 src/usr.bin/xlint/lint1/mem1.c

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



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

2022-02-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Feb 27 06:55:13 UTC 2022

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

Log Message:
lint: remove custom free list for memory blocks

Trust the system memory allocator to do its thing, including marking the
memory as fresh or freed.  One less thing to worry about.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/usr.bin/xlint/lint1/mem1.c

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

Modified files:

Index: src/usr.bin/xlint/lint1/mem1.c
diff -u src/usr.bin/xlint/lint1/mem1.c:1.57 src/usr.bin/xlint/lint1/mem1.c:1.58
--- src/usr.bin/xlint/lint1/mem1.c:1.57	Sat Dec 25 13:51:42 2021
+++ src/usr.bin/xlint/lint1/mem1.c	Sun Feb 27 06:55:13 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: mem1.c,v 1.57 2021/12/25 13:51:42 rillig Exp $	*/
+/*	$NetBSD: mem1.c,v 1.58 2022/02/27 06:55:13 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: mem1.c,v 1.57 2021/12/25 13:51:42 rillig Exp $");
+__RCSID("$NetBSD: mem1.c,v 1.58 2022/02/27 06:55:13 rillig Exp $");
 #endif
 
 #include 
@@ -197,9 +197,6 @@ static	memory_block	**mblks;
 /* number of elements in *mblks */
 static	size_t	nmblks;
 
-/* free list for memory blocks */
-static	memory_block	*frmblks;
-
 /* length of new allocated memory blocks */
 static	size_t	mblklen;
 
@@ -235,20 +232,16 @@ xgetblk(memory_block **mbp, size_t s)
 
 	s = WORST_ALIGN(s);
 	if ((mb = *mbp) == NULL || mb->nfree < s) {
-		if ((mb = frmblks) == NULL || mb->size < s) {
-			if (s > mblklen) {
-t = mblklen;
-mblklen = s;
-			}
-			mb = xnewblk();
+		if (s > mblklen) {
+			t = mblklen;
+			mblklen = s;
+		}
+		mb = xnewblk();
 #ifndef BLKDEBUG
-			(void)memset(mb->start, 0, mb->size);
+		(void)memset(mb->start, 0, mb->size);
 #endif
-			if (t > 0)
-mblklen = t;
-		} else {
-			frmblks = mb->next;
-		}
+		if (t > 0)
+			mblklen = t;
 		mb->first_free = mb->start;
 		mb->nfree = mb->size;
 		mb->next = *mbp;
@@ -263,10 +256,7 @@ xgetblk(memory_block **mbp, size_t s)
 	return p;
 }
 
-/*
- * Move all blocks from list *fmbp to free list. For each block, set all
- * used memory to zero.
- */
+/* Free all blocks from list *fmbp. */
 static void
 xfreeblk(memory_block **fmbp)
 {
@@ -274,10 +264,7 @@ xfreeblk(memory_block **fmbp)
 
 	while ((mb = *fmbp) != NULL) {
 		*fmbp = mb->next;
-		mb->next = frmblks;
-		frmblks = mb;
-		(void)memset(mb->start, INVALID_MEM_BYTE,
-		mb->size - mb->nfree);
+		free(mb);
 	}
 }
 



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

2022-02-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Feb 27 06:55:13 UTC 2022

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

Log Message:
lint: remove custom free list for memory blocks

Trust the system memory allocator to do its thing, including marking the
memory as fresh or freed.  One less thing to worry about.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/usr.bin/xlint/lint1/mem1.c

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



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

2022-02-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Feb 27 01:47:28 UTC 2022

Modified Files:
src/usr.bin/xlint/lint1: cgram.y decl.c lint1.h

Log Message:
lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name.  This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.381 -r1.382 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.244 -r1.245 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.135 -r1.136 src/usr.bin/xlint/lint1/lint1.h

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

Modified files:

Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.381 src/usr.bin/xlint/lint1/cgram.y:1.382
--- src/usr.bin/xlint/lint1/cgram.y:1.381	Sat Feb 26 20:36:11 2022
+++ src/usr.bin/xlint/lint1/cgram.y	Sun Feb 27 01:47:28 2022
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.381 2022/02/26 20:36:11 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.382 2022/02/27 01:47:28 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.381 2022/02/26 20:36:11 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.382 2022/02/27 01:47:28 rillig Exp $");
 #endif
 
 #include 
@@ -1970,7 +1970,7 @@ function_definition:		/* C99 6.9.1 */
 		}
 		funcdef($1);
 		block_level++;
-		begin_declaration_level(ARG);
+		begin_declaration_level(OLD_STYLE_ARG);
 		if (lwarn == LWARN_NONE)
 			$1->s_used = true;
 	  } arg_declaration_list_opt {

Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.244 src/usr.bin/xlint/lint1/decl.c:1.245
--- src/usr.bin/xlint/lint1/decl.c:1.244	Mon Feb  7 02:44:49 2022
+++ src/usr.bin/xlint/lint1/decl.c	Sun Feb 27 01:47:28 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.244 2022/02/07 02:44:49 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.245 2022/02/27 01:47:28 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.244 2022/02/07 02:44:49 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.245 2022/02/27 01:47:28 rillig Exp $");
 #endif
 
 #include 
@@ -148,8 +148,8 @@ scl_name(scl_t scl)
 	static const char *const names[] = {
 	"none", "extern", "static", "auto", "register", "typedef",
 	"struct", "union", "enum", "member of struct", "member of union",
-	"compile-time constant", "abstract", "argument",
-	"prototype argument", "inline"
+	"compile-time constant", "abstract",
+	"old-style function argument", "prototype argument", "inline"
 	};
 
 	return names[scl];
@@ -498,7 +498,7 @@ tdeferr(type_t *td, tspec_t t)
  * Remember the symbol of a typedef name (2nd arg) in a struct, union
  * or enum tag if the typedef name is the first defined for this tag.
  *
- * If the tag is unnamed, the typdef name is used for identification
+ * If the tag is unnamed, the typedef name is used for identification
  * of this tag in lint2. Although it's possible that more than one typedef
  * name is defined for one tag, the first name defined should be unique
  * if the tag is unnamed.
@@ -651,7 +651,7 @@ end_declaration_level(void)
 		if ((*dcs->d_ldlsym = di->d_dlsyms) != NULL)
 			dcs->d_ldlsym = di->d_ldlsym;
 		break;
-	case ARG:
+	case OLD_STYLE_ARG:
 		/*
 		 * All symbols in dcs->d_dlsyms are introduced in old style
 		 * argument declarations (it's not clean, but possible).
@@ -751,7 +751,7 @@ dcs_adjust_storage_class(void)
 			error(8);
 			dcs->d_scl = NOSCL;
 		}
-	} else if (dcs->d_ctx == ARG || dcs->d_ctx == PROTO_ARG) {
+	} else if (dcs->d_ctx == OLD_STYLE_ARG || dcs->d_ctx == PROTO_ARG) {
 		if (dcs->d_scl != NOSCL && dcs->d_scl != REG) {
 			/* only register valid as formal parameter storage... */
 			error(9);
@@ -1565,7 +1565,7 @@ declarator_name(sym_t *sym)
 	case PROTO_ARG:
 		sym->s_arg = true;
 		/* FALLTHROUGH */
-	case ARG:
+	case OLD_STYLE_ARG:
 		if ((sc = dcs->d_scl) == NOSCL) {
 			sc = AUTO;
 		} else {
@@ -2027,7 +2027,7 @@ declare(sym_t *decl, bool initflg, sbuf_
 
 	if (dcs->d_ctx == EXTERN) {
 		declare_extern(decl, initflg, renaming);
-	} else if (dcs->d_ctx == ARG || dcs->d_ctx == PROTO_ARG) {
+	} else if (dcs->d_ctx == OLD_STYLE_ARG || dcs->d_ctx == PROTO_ARG) {
 		if (renaming != NULL) {
 			/* symbol renaming can't be used on function arguments */
 			error(310);

Index: src/usr.bin/xlint/lint1/lint1.h
diff -u src/usr.bin/xlint/lint1/lint1.h:1.135 src/usr.bin/xlint/lint1/lint1.h:1.136
--- src/usr.bin/xlint/lint1/lint1.h:1.135	Mon Feb  7 21:57:47 2022
+++ src/usr.bin/xlint/lint1/lint1.h	Sun Feb 27 01:47:28 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.135 2022/02/07 21:57:47 rillig Exp $ */
+/* 

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

2022-02-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Feb 27 01:47:28 UTC 2022

Modified Files:
src/usr.bin/xlint/lint1: cgram.y decl.c lint1.h

Log Message:
lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name.  This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.381 -r1.382 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.244 -r1.245 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.135 -r1.136 src/usr.bin/xlint/lint1/lint1.h

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



CVS commit: src/sys/sys

2022-02-26 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Sun Feb 27 01:03:14 UTC 2022

Modified Files:
src/sys/sys: lwp.h

Log Message:
lwp.h: correct grammar in a comment


To generate a diff of this commit:
cvs rdiff -u -r1.212 -r1.213 src/sys/sys/lwp.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/sys/lwp.h
diff -u src/sys/sys/lwp.h:1.212 src/sys/sys/lwp.h:1.213
--- src/sys/sys/lwp.h:1.212	Fri Oct 23 00:25:45 2020
+++ src/sys/sys/lwp.h	Sun Feb 27 01:03:14 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: lwp.h,v 1.212 2020/10/23 00:25:45 thorpej Exp $	*/
+/*	$NetBSD: lwp.h,v 1.213 2022/02/27 01:03:14 gutteridge Exp $	*/
 
 /*
  * Copyright (c) 2001, 2006, 2007, 2008, 2009, 2010, 2019, 2020
@@ -512,7 +512,7 @@ extern struct lwp	*curlwp;		/* Current r
 #define	curproc		(curlwp->l_proc)
 
 /*
- * This provide a way for  to get l_cpu for curlwp before
+ * This provides a way for  to get l_cpu for curlwp before
  * struct lwp is defined.
  */
 static __inline struct cpu_info *



CVS commit: src/sys/sys

2022-02-26 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Sun Feb 27 01:03:14 UTC 2022

Modified Files:
src/sys/sys: lwp.h

Log Message:
lwp.h: correct grammar in a comment


To generate a diff of this commit:
cvs rdiff -u -r1.212 -r1.213 src/sys/sys/lwp.h

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



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

2022-02-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 26 23:07:28 UTC 2022

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

Log Message:
lint: improve debug logging for symbol kinds


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/usr.bin/xlint/lint1/lex.c

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

Modified files:

Index: src/usr.bin/xlint/lint1/lex.c
diff -u src/usr.bin/xlint/lint1/lex.c:1.97 src/usr.bin/xlint/lint1/lex.c:1.98
--- src/usr.bin/xlint/lint1/lex.c:1.97	Sun Dec 26 18:16:41 2021
+++ src/usr.bin/xlint/lint1/lex.c	Sat Feb 26 23:07:28 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.97 2021/12/26 18:16:41 christos Exp $ */
+/* $NetBSD: lex.c,v 1.98 2022/02/26 23:07:28 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: lex.c,v 1.97 2021/12/26 18:16:41 christos Exp $");
+__RCSID("$NetBSD: lex.c,v 1.98 2022/02/26 23:07:28 rillig Exp $");
 #endif
 
 #include 
@@ -1332,6 +1332,20 @@ lex_wide_string(void)
 	return T_STRING;
 }
 
+#ifdef DEBUG
+static const char *
+symt_name(symt_t kind)
+{
+	static const char *name[] = {
+		"var-func-type",
+		"member",
+		"tag",
+		"label",
+	};
+	return name[kind];
+}
+#endif
+
 /*
  * As noted above, the scanner does not create new symbol table entries
  * for symbols it cannot find in the symbol table. This is to avoid
@@ -1366,8 +1380,7 @@ getsym(sbuf_t *sb)
 	}
 
 	if (sym != NULL) {
-		if (sym->s_kind != symtyp)
-			INTERNAL_ERROR("getsym(%d, %d)", sym->s_kind, symtyp);
+		lint_assert(sym->s_kind == symtyp);
 		symtyp = FVFT;
 		freesb(sb);
 		return sym;
@@ -1447,8 +1460,8 @@ void
 rmsym(sym_t *sym)
 {
 
-	debug_step("rmsym '%s' %d '%s'",
-	sym->s_name, (int)sym->s_kind, type_name(sym->s_type));
+	debug_step("rmsym '%s' %s '%s'",
+	sym->s_name, symt_name(sym->s_kind), type_name(sym->s_type));
 	symtab_remove(sym);
 
 	/* avoid that the symbol will later be put back to the symbol table */
@@ -1466,8 +1479,8 @@ rmsyms(sym_t *syms)
 
 	for (sym = syms; sym != NULL; sym = sym->s_dlnxt) {
 		if (sym->s_block_level != -1) {
-			debug_step("rmsyms '%s' %d '%s'",
-			sym->s_name, (int)sym->s_kind,
+			debug_step("rmsyms '%s' %s '%s'",
+			sym->s_name, symt_name(sym->s_kind),
 			type_name(sym->s_type));
 			symtab_remove(sym);
 			sym->s_rlink = NULL;
@@ -1482,8 +1495,8 @@ void
 inssym(int bl, sym_t *sym)
 {
 
-	debug_step("inssym '%s' %d '%s'",
-	sym->s_name, sym->s_kind, type_name(sym->s_type));
+	debug_step("inssym '%s' %s '%s'",
+	sym->s_name, symt_name(sym->s_kind), type_name(sym->s_type));
 	symtab_add(sym);
 	sym->s_block_level = bl;
 	lint_assert(sym->s_link == NULL ||
@@ -1523,8 +1536,8 @@ pushdown(const sym_t *sym)
 {
 	sym_t	*nsym;
 
-	debug_step("pushdown '%s' %d '%s'",
-	sym->s_name, (int)sym->s_kind, type_name(sym->s_type));
+	debug_step("pushdown '%s' %s '%s'",
+	sym->s_name, symt_name(sym->s_kind), type_name(sym->s_type));
 	nsym = getblk(sizeof(*nsym));
 	lint_assert(sym->s_block_level <= block_level);
 	nsym->s_name = sym->s_name;



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

2022-02-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 26 23:07:28 UTC 2022

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

Log Message:
lint: improve debug logging for symbol kinds


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/usr.bin/xlint/lint1/lex.c

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



Re: CVS commit: src/sys/dev/pci

2022-02-26 Thread Joerg Sonnenberger
Am Sat, Feb 26, 2022 at 03:04:40PM + schrieb Roland Illig:
> Module Name:  src
> Committed By: rillig
> Date: Sat Feb 26 15:04:40 UTC 2022
> 
> Modified Files:
>   src/sys/dev/pci: if_wm.c
> 
> Log Message:
> if_wm.c: fix value return from void function
> 
> lint complained:
> if_wm.c(10028): error:
> void function wm_txrxintr_disable cannot return value [213]
> if_wm.c(10049): error:
> void function wm_txrxintr_enable cannot return value [213]
> 
> No functional change.

Personally, I prefer the use of the C extension in cases like this. The
"portable" version is less readable...

Joerg


CVS commit: src

2022-02-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 26 20:36:11 UTC 2022

Modified Files:
src/tests/usr.bin/xlint/lint1: d_gcc_compound_statements2.c
t_integration.sh
src/usr.bin/xlint/lint1: cgram.y externs1.h tree.c

Log Message:
lint: fix memory corruption in statement expressions (since 2021-12-17)

The commit that introduced the assertion failure looks innocent, it only
adds a few predefined functions for GCC mode.  Nevertheless, before that
commit, lint consistently complained about 'error: void type illegal in
expression [109]', which doesn't make sense either.

This fix also removes the creative use of the initialization stack to
store the type of the statement expression.  Having a separate stack for
these statement expressions makes the code easier to understand.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/tests/usr.bin/xlint/lint1/d_gcc_compound_statements2.c
cvs rdiff -u -r1.74 -r1.75 src/tests/usr.bin/xlint/lint1/t_integration.sh
cvs rdiff -u -r1.380 -r1.381 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.145 -r1.146 src/usr.bin/xlint/lint1/externs1.h
cvs rdiff -u -r1.403 -r1.404 src/usr.bin/xlint/lint1/tree.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/d_gcc_compound_statements2.c
diff -u src/tests/usr.bin/xlint/lint1/d_gcc_compound_statements2.c:1.4 src/tests/usr.bin/xlint/lint1/d_gcc_compound_statements2.c:1.5
--- src/tests/usr.bin/xlint/lint1/d_gcc_compound_statements2.c:1.4	Fri Sep 10 20:02:51 2021
+++ src/tests/usr.bin/xlint/lint1/d_gcc_compound_statements2.c	Sat Feb 26 20:36:11 2022
@@ -1,13 +1,18 @@
-/*	$NetBSD: d_gcc_compound_statements2.c,v 1.4 2021/09/10 20:02:51 rillig Exp $	*/
+/*	$NetBSD: d_gcc_compound_statements2.c,v 1.5 2022/02/26 20:36:11 rillig Exp $	*/
 # 3 "d_gcc_compound_statements2.c"
 
-/* GCC compound statements with non-expressions */
+/*
+ * GCC statement expressions with non-expressions.
+ *
+ * https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
+ */
+
 struct cpu_info {
 	int bar;
 };
 
 int
-compound_expression_with_decl_and_stmt(void)
+statement_expr_with_decl_and_stmt(void)
 {
 	return ({
 	struct cpu_info *ci;
@@ -17,7 +22,7 @@ compound_expression_with_decl_and_stmt(v
 }
 
 int
-compound_expression_with_only_stmt(void)
+statement_expr_with_only_stmt(void)
 {
 	struct cpu_info ci = { 0 };
 	return ({
@@ -26,3 +31,19 @@ compound_expression_with_only_stmt(void)
 		ci;
 	}).bar;
 }
+
+/*
+ * Since main1.c 1.58 from 2021-12-17 and before tree.c 1.404 from
+ * 2022-02-26, lint ran into an assertion failure due to a use-after-free.
+ * When typeok checked the operand types of the '=', the left node and the
+ * right node overlapped by 16 out of their 40 bytes on x86_64.
+ */
+void
+statement_expr_with_loop(unsigned u)
+{
+	u = ({
+		do {
+		} while (0);
+		u;
+	});
+}

Index: src/tests/usr.bin/xlint/lint1/t_integration.sh
diff -u src/tests/usr.bin/xlint/lint1/t_integration.sh:1.74 src/tests/usr.bin/xlint/lint1/t_integration.sh:1.75
--- src/tests/usr.bin/xlint/lint1/t_integration.sh:1.74	Sat Feb 26 16:43:20 2022
+++ src/tests/usr.bin/xlint/lint1/t_integration.sh	Sat Feb 26 20:36:11 2022
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.74 2022/02/26 16:43:20 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.75 2022/02/26 20:36:11 rillig Exp $
 #
 # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -145,27 +145,6 @@ check_lint1()
 	fi
 }
 
-atf_test_case 'assertion_failures'
-assertion_failures_body()
-{
-	# seen in sys/external/bsd/drm2/include/linux/kref.h:73
-
-	cat <<'EOF' > input.c
-# 2 "input.c"
-void
-fn(unsigned int u)
-{
-	u = ({
-		do {} while (0);
-		u;
-	});
-}
-EOF
-
-	atf_check -s 'signal' -e 'match:lint: assertion ".*" failed' \
-	"$lint1" -gS 'input.c' '/dev/null'
-}
-
 atf_init_test_cases()
 {
 	local src name
@@ -183,6 +162,4 @@ atf_init_test_cases()
 		}"
 		atf_add_test_case "$name"
 	done
-
-	atf_add_test_case 'assertion_failures'
 }

Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.380 src/usr.bin/xlint/lint1/cgram.y:1.381
--- src/usr.bin/xlint/lint1/cgram.y:1.380	Sat Feb 26 19:01:09 2022
+++ src/usr.bin/xlint/lint1/cgram.y	Sat Feb 26 20:36:11 2022
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.380 2022/02/26 19:01:09 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.381 2022/02/26 20:36:11 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.380 2022/02/26 19:01:09 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.381 2022/02/26 20:36:11 rillig Exp $");
 #endif
 
 #include 
@@ -517,8 +517,10 @@ postfix_expression:
 		$$ = build_name(*current_initsym(), false);
 		end_initialization();
 	  }
-	| T_LPAREN compound_statement_lbrace gcc_statement_expr_list {
-		

CVS commit: src

2022-02-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 26 20:36:11 UTC 2022

Modified Files:
src/tests/usr.bin/xlint/lint1: d_gcc_compound_statements2.c
t_integration.sh
src/usr.bin/xlint/lint1: cgram.y externs1.h tree.c

Log Message:
lint: fix memory corruption in statement expressions (since 2021-12-17)

The commit that introduced the assertion failure looks innocent, it only
adds a few predefined functions for GCC mode.  Nevertheless, before that
commit, lint consistently complained about 'error: void type illegal in
expression [109]', which doesn't make sense either.

This fix also removes the creative use of the initialization stack to
store the type of the statement expression.  Having a separate stack for
these statement expressions makes the code easier to understand.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/tests/usr.bin/xlint/lint1/d_gcc_compound_statements2.c
cvs rdiff -u -r1.74 -r1.75 src/tests/usr.bin/xlint/lint1/t_integration.sh
cvs rdiff -u -r1.380 -r1.381 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.145 -r1.146 src/usr.bin/xlint/lint1/externs1.h
cvs rdiff -u -r1.403 -r1.404 src/usr.bin/xlint/lint1/tree.c

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



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

2022-02-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 26 19:01:09 UTC 2022

Modified Files:
src/usr.bin/xlint/lint1: cgram.y externs1.h tree.c

Log Message:
lint: extract code for handling statement expressions from the grammar

This prepares the fix of the memory corruption bug that is demonstrated
in t_integration.sh, test case assertion_failures.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.379 -r1.380 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.144 -r1.145 src/usr.bin/xlint/lint1/externs1.h
cvs rdiff -u -r1.402 -r1.403 src/usr.bin/xlint/lint1/tree.c

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

Modified files:

Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.379 src/usr.bin/xlint/lint1/cgram.y:1.380
--- src/usr.bin/xlint/lint1/cgram.y:1.379	Sat Jan 15 23:21:34 2022
+++ src/usr.bin/xlint/lint1/cgram.y	Sat Feb 26 19:01:09 2022
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.379 2022/01/15 23:21:34 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.380 2022/02/26 19:01:09 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.379 2022/01/15 23:21:34 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.380 2022/02/26 19:01:09 rillig Exp $");
 #endif
 
 #include 
@@ -518,16 +518,9 @@ postfix_expression:
 		end_initialization();
 	  }
 	| T_LPAREN compound_statement_lbrace gcc_statement_expr_list {
-		block_level--;
-		mem_block_level--;
-		begin_initialization(mktempsym(dup_type($3->tn_type)));
-		mem_block_level++;
-		block_level++;
-		/* ({ }) is a GCC extension */
-		gnuism(320);
+		do_statement_expr($3);
 	  } compound_statement_rbrace T_RPAREN {
-		$$ = build_name(*current_initsym(), false);
-		end_initialization();
+		$$ = end_statement_expr();
 	  }
 	;
 

Index: src/usr.bin/xlint/lint1/externs1.h
diff -u src/usr.bin/xlint/lint1/externs1.h:1.144 src/usr.bin/xlint/lint1/externs1.h:1.145
--- src/usr.bin/xlint/lint1/externs1.h:1.144	Tue Dec 21 21:04:08 2021
+++ src/usr.bin/xlint/lint1/externs1.h	Sat Feb 26 19:01:09 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: externs1.h,v 1.144 2021/12/21 21:04:08 rillig Exp $	*/
+/*	$NetBSD: externs1.h,v 1.145 2022/02/26 19:01:09 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -262,6 +262,9 @@ extern	bool	constant_addr(const tnode_t 
 extern	strg_t	*cat_strings(strg_t *, strg_t *);
 extern  unsigned int type_size_in_bits(const type_t *);
 
+void do_statement_expr(tnode_t *);
+tnode_t *end_statement_expr(void);
+
 /*
  * func.c
  */

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.402 src/usr.bin/xlint/lint1/tree.c:1.403
--- src/usr.bin/xlint/lint1/tree.c:1.402	Tue Dec 21 15:33:20 2021
+++ src/usr.bin/xlint/lint1/tree.c	Sat Feb 26 19:01:09 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.402 2021/12/21 15:33:20 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.403 2022/02/26 19:01:09 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.402 2021/12/21 15:33:20 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.403 2022/02/26 19:01:09 rillig Exp $");
 #endif
 
 #include 
@@ -4538,3 +4538,25 @@ check_precedence_confusion(tnode_t *tn)
 		warning(169);
 	}
 }
+
+void
+do_statement_expr(tnode_t *tn)
+{
+	block_level--;
+	mem_block_level--;
+	/* Use the initialization code as temporary symbol storage. */
+	begin_initialization(mktempsym(dup_type(tn->tn_type)));
+	mem_block_level++;
+	block_level++;
+	/* ({ }) is a GCC extension */
+	gnuism(320);
+
+}
+
+tnode_t *
+end_statement_expr(void)
+{
+	tnode_t *tn = build_name(*current_initsym(), false);
+	end_initialization();
+	return tn;
+}



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

2022-02-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 26 19:01:09 UTC 2022

Modified Files:
src/usr.bin/xlint/lint1: cgram.y externs1.h tree.c

Log Message:
lint: extract code for handling statement expressions from the grammar

This prepares the fix of the memory corruption bug that is demonstrated
in t_integration.sh, test case assertion_failures.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.379 -r1.380 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.144 -r1.145 src/usr.bin/xlint/lint1/externs1.h
cvs rdiff -u -r1.402 -r1.403 src/usr.bin/xlint/lint1/tree.c

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



CVS commit: src/external/mit/expat/lib/libexpat

2022-02-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Feb 26 18:49:42 UTC 2022

Modified Files:
src/external/mit/expat/lib/libexpat: expat_config.h

Log Message:
don't require arc4random_buf for tools build


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/external/mit/expat/lib/libexpat/expat_config.h

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



CVS commit: src/external/mit/expat/lib/libexpat

2022-02-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Feb 26 18:49:42 UTC 2022

Modified Files:
src/external/mit/expat/lib/libexpat: expat_config.h

Log Message:
don't require arc4random_buf for tools build


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/external/mit/expat/lib/libexpat/expat_config.h

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

Modified files:

Index: src/external/mit/expat/lib/libexpat/expat_config.h
diff -u src/external/mit/expat/lib/libexpat/expat_config.h:1.13 src/external/mit/expat/lib/libexpat/expat_config.h:1.14
--- src/external/mit/expat/lib/libexpat/expat_config.h:1.13	Sat Feb 26 10:40:09 2022
+++ src/external/mit/expat/lib/libexpat/expat_config.h	Sat Feb 26 13:49:42 2022
@@ -11,8 +11,10 @@
 /* Define to 1 if you have the `arc4random' function. */
 /* #undef HAVE_ARC4RANDOM */
 
+#ifndef TOOL_FCCACHE
 /* Define to 1 if you have the `arc4random_buf' function. */
 #define HAVE_ARC4RANDOM_BUF 1
+#endif
 
 /* Define to 1 if you have the  header file. */
 #define HAVE_DLFCN_H 1



CVS commit: src/usr.bin/xlint

2022-02-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 26 18:35:01 UTC 2022

Modified Files:
src/usr.bin/xlint: Makefile.inc

Log Message:
lint: enable memory debugging

Filling deallocated memory with 0x00 may hide errors, so rather fill
with 0xA5.

While this doesn't change anything about the test about the assertion
failure after a do-while loop (see t_integration.sh, test case
assertion_failures), it may detect other similar bugs earlier.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/xlint/Makefile.inc

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



CVS commit: src/usr.bin/xlint

2022-02-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 26 18:35:01 UTC 2022

Modified Files:
src/usr.bin/xlint: Makefile.inc

Log Message:
lint: enable memory debugging

Filling deallocated memory with 0x00 may hide errors, so rather fill
with 0xA5.

While this doesn't change anything about the test about the assertion
failure after a do-while loop (see t_integration.sh, test case
assertion_failures), it may detect other similar bugs earlier.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/xlint/Makefile.inc

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

Modified files:

Index: src/usr.bin/xlint/Makefile.inc
diff -u src/usr.bin/xlint/Makefile.inc:1.18 src/usr.bin/xlint/Makefile.inc:1.19
--- src/usr.bin/xlint/Makefile.inc:1.18	Mon Feb  7 21:57:47 2022
+++ src/usr.bin/xlint/Makefile.inc	Sat Feb 26 18:35:01 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.18 2022/02/07 21:57:47 rillig Exp $
+#	$NetBSD: Makefile.inc,v 1.19 2022/02/26 18:35:01 rillig Exp $
 
 .include 
 
@@ -16,6 +16,7 @@ ARCHSUBDIR=	${MACHINE_CPU}
 
 CPPFLAGS+=	-I${.CURDIR}/../arch/${ARCHSUBDIR}
 CPPFLAGS+=	-I${.CURDIR}/../common
+CPPFLAGS+=	-DBLKDEBUG
 
 CLEANFILES+=	*.gcno *.gcda *.gcov
 



CVS commit: src/external/bsd/cron/dist

2022-02-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Feb 26 17:02:47 UTC 2022

Modified Files:
src/external/bsd/cron/dist: crontab.5

Log Message:
explain CRON_WITHIN better.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/external/bsd/cron/dist/crontab.5

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

Modified files:

Index: src/external/bsd/cron/dist/crontab.5
diff -u src/external/bsd/cron/dist/crontab.5:1.10 src/external/bsd/cron/dist/crontab.5:1.11
--- src/external/bsd/cron/dist/crontab.5:1.10	Sat Apr 18 15:32:19 2020
+++ src/external/bsd/cron/dist/crontab.5	Sat Feb 26 12:02:47 2022
@@ -1,4 +1,4 @@
-.\" $NetBSD: crontab.5,v 1.10 2020/04/18 19:32:19 christos Exp $
+.\" $NetBSD: crontab.5,v 1.11 2022/02/26 17:02:47 christos Exp $
 .\"
 .\"/* Copyright 1988,1990,1993,1994 by Paul Vixie
 .\" * All rights reserved
@@ -21,7 +21,7 @@
 .\"
 .\" $OpenBSD: crontab.5,v 1.36 2018/06/13 13:27:37 jmc Exp $
 .\"
-.Dd April 17, 2020
+.Dd February 26, 2022
 .Dt CRONTAB 5
 .Os
 .Sh NAME
@@ -298,6 +298,12 @@ The
 .Ev CRON_WITHIN
 variable should indicate the number of seconds within a job's
 scheduled time that it should still be run.
+For example if a job is scheduled for 12:30pm and
+.Ev CRON_WITHIN
+is
+.Dv 120
+(2 minutes), then the job will not be run if the system attempts
+to start it past 12:32pm.
 On a heavily loaded system, or on a system that has just been
 .Dq woken up ,
 jobs will sometimes start later than originally intended, and by
@@ -308,7 +314,9 @@ If
 is defined but empty
 .Pq Ev CRON_WITHIN Ns = Ns \&"" ,
 or set to some non-positive value (0, a negative number, or a
-non-numeric string), it is treated as if it was unset.
+non-numeric string), it is treated as if it was unset, that is
+the job will always run, even if it is going to start at a time
+long past its scheduled time.
 .It Ev HOME
 Set from the user's
 .Pa /etc/passwd



CVS commit: src/external/bsd/cron/dist

2022-02-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Feb 26 17:02:47 UTC 2022

Modified Files:
src/external/bsd/cron/dist: crontab.5

Log Message:
explain CRON_WITHIN better.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/external/bsd/cron/dist/crontab.5

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



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

2022-02-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 26 16:43:20 UTC 2022

Modified Files:
src/tests/usr.bin/xlint/lint1: t_integration.sh

Log Message:
tests/lint: demonstrate assertion failure in GCC compound expression


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/tests/usr.bin/xlint/lint1/t_integration.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/xlint/lint1/t_integration.sh
diff -u src/tests/usr.bin/xlint/lint1/t_integration.sh:1.73 src/tests/usr.bin/xlint/lint1/t_integration.sh:1.74
--- src/tests/usr.bin/xlint/lint1/t_integration.sh:1.73	Sun Oct 10 18:16:12 2021
+++ src/tests/usr.bin/xlint/lint1/t_integration.sh	Sat Feb 26 16:43:20 2022
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.73 2021/10/10 18:16:12 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.74 2022/02/26 16:43:20 rillig Exp $
 #
 # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -145,6 +145,27 @@ check_lint1()
 	fi
 }
 
+atf_test_case 'assertion_failures'
+assertion_failures_body()
+{
+	# seen in sys/external/bsd/drm2/include/linux/kref.h:73
+
+	cat <<'EOF' > input.c
+# 2 "input.c"
+void
+fn(unsigned int u)
+{
+	u = ({
+		do {} while (0);
+		u;
+	});
+}
+EOF
+
+	atf_check -s 'signal' -e 'match:lint: assertion ".*" failed' \
+	"$lint1" -gS 'input.c' '/dev/null'
+}
+
 atf_init_test_cases()
 {
 	local src name
@@ -162,4 +183,6 @@ atf_init_test_cases()
 		}"
 		atf_add_test_case "$name"
 	done
+
+	atf_add_test_case 'assertion_failures'
 }



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

2022-02-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 26 16:43:20 UTC 2022

Modified Files:
src/tests/usr.bin/xlint/lint1: t_integration.sh

Log Message:
tests/lint: demonstrate assertion failure in GCC compound expression


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/tests/usr.bin/xlint/lint1/t_integration.sh

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



CVS commit: src/tests/sys/rc

2022-02-26 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Sat Feb 26 16:21:59 UTC 2022

Modified Files:
src/tests/sys/rc: t_rc_d_cli.sh

Log Message:
Mark randomly failing test cases as expected failures with a reference
to PR bin/56506.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/sys/rc/t_rc_d_cli.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/sys/rc/t_rc_d_cli.sh
diff -u src/tests/sys/rc/t_rc_d_cli.sh:1.4 src/tests/sys/rc/t_rc_d_cli.sh:1.5
--- src/tests/sys/rc/t_rc_d_cli.sh:1.4	Sun Nov  7 17:51:21 2010
+++ src/tests/sys/rc/t_rc_d_cli.sh	Sat Feb 26 16:21:59 2022
@@ -1,4 +1,4 @@
-# $NetBSD: t_rc_d_cli.sh,v 1.4 2010/11/07 17:51:21 jmmv Exp $
+# $NetBSD: t_rc_d_cli.sh,v 1.5 2022/02/26 16:21:59 gson Exp $
 #
 # Copyright (c) 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -48,8 +48,10 @@ default_start_no_args_body() {
 	export h_simple=YES
 	rc_helper=$(atf_get_srcdir)/h_simple
 
+	atf_expect_fail "PR bin/56506"
 	atf_check -s eq:0 -o ignore -e empty ${rc_helper} start
 	${rc_helper} forcestop
+	atf_fail "random failure did not happen this time"
 }
 
 atf_test_case default_start_with_args
@@ -77,8 +79,10 @@ default_stop_no_args_body() {
 	export h_simple=YES
 	rc_helper=$(atf_get_srcdir)/h_simple
 
+	atf_expect_fail "PR bin/56506"
 	${rc_helper} start
 	atf_check -s eq:0 -o ignore -e empty ${rc_helper} stop
+	atf_fail "random failure did not happen this time"
 }
 
 atf_test_case default_stop_with_args
@@ -108,9 +112,11 @@ default_restart_no_args_body() {
 	export h_simple=YES
 	rc_helper=$(atf_get_srcdir)/h_simple
 
+	atf_expect_fail "PR bin/56506"
 	${rc_helper} start
 	atf_check -s eq:0 -o ignore -e empty ${rc_helper} restart
 	${rc_helper} forcestop
+	atf_fail "random failure did not happen this time"
 }
 
 atf_test_case default_restart_with_args



CVS commit: src/tests/sys/rc

2022-02-26 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Sat Feb 26 16:21:59 UTC 2022

Modified Files:
src/tests/sys/rc: t_rc_d_cli.sh

Log Message:
Mark randomly failing test cases as expected failures with a reference
to PR bin/56506.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/sys/rc/t_rc_d_cli.sh

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



CVS commit: src/sys/external/bsd/drm2/include/linux

2022-02-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 26 15:57:22 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/include/linux: vmalloc.h

Log Message:
drm2: do not try to return a value from a void function

lint complained:
vmalloc.h(79): error: void function vfree cannot return value [213]

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/external/bsd/drm2/include/linux/vmalloc.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/external/bsd/drm2/include/linux/vmalloc.h
diff -u src/sys/external/bsd/drm2/include/linux/vmalloc.h:1.11 src/sys/external/bsd/drm2/include/linux/vmalloc.h:1.12
--- src/sys/external/bsd/drm2/include/linux/vmalloc.h:1.11	Sun Dec 19 12:07:55 2021
+++ src/sys/external/bsd/drm2/include/linux/vmalloc.h	Sat Feb 26 15:57:22 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmalloc.h,v 1.11 2021/12/19 12:07:55 riastradh Exp $	*/
+/*	$NetBSD: vmalloc.h,v 1.12 2022/02/26 15:57:22 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2013, 2018 The NetBSD Foundation, Inc.
@@ -76,7 +76,7 @@ vzalloc(unsigned long size)
 static inline void
 vfree(void *ptr)
 {
-	return kfree(ptr);
+	kfree(ptr);
 }
 
 #define	PAGE_KERNEL	UVM_PROT_RW



CVS commit: src/sys/external/bsd/drm2/include/linux

2022-02-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 26 15:57:22 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/include/linux: vmalloc.h

Log Message:
drm2: do not try to return a value from a void function

lint complained:
vmalloc.h(79): error: void function vfree cannot return value [213]

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/external/bsd/drm2/include/linux/vmalloc.h

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



CVS commit: src/external/mit/expat/lib/libexpat

2022-02-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Feb 26 15:40:09 UTC 2022

Modified Files:
src/external/mit/expat/lib/libexpat: expat_config.h

Log Message:
re-enable getrandom for the non-tools build (thanks martin)


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/external/mit/expat/lib/libexpat/expat_config.h

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

Modified files:

Index: src/external/mit/expat/lib/libexpat/expat_config.h
diff -u src/external/mit/expat/lib/libexpat/expat_config.h:1.12 src/external/mit/expat/lib/libexpat/expat_config.h:1.13
--- src/external/mit/expat/lib/libexpat/expat_config.h:1.12	Sat Feb 26 08:17:39 2022
+++ src/external/mit/expat/lib/libexpat/expat_config.h	Sat Feb 26 10:40:09 2022
@@ -23,8 +23,11 @@
 /* Define to 1 if you have the `getpagesize' function. */
 #define HAVE_GETPAGESIZE 1
 
+/* Host build might not have getrandom */
+#ifndef TOOL_FCCACHE
 /* Define to 1 if you have the `getrandom' function. */
-/* #define HAVE_GETRANDOM 1 */
+#define HAVE_GETRANDOM 1
+#endif
 
 /* Define to 1 if you have the  header file. */
 #define HAVE_INTTYPES_H 1



CVS commit: src/external/mit/expat/lib/libexpat

2022-02-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Feb 26 15:40:09 UTC 2022

Modified Files:
src/external/mit/expat/lib/libexpat: expat_config.h

Log Message:
re-enable getrandom for the non-tools build (thanks martin)


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/external/mit/expat/lib/libexpat/expat_config.h

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

2022-02-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 26 15:04:40 UTC 2022

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

Log Message:
if_wm.c: fix value return from void function

lint complained:
if_wm.c(10028): error:
void function wm_txrxintr_disable cannot return value [213]
if_wm.c(10049): error:
void function wm_txrxintr_enable cannot return value [213]

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.728 -r1.729 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.728 src/sys/dev/pci/if_wm.c:1.729
--- src/sys/dev/pci/if_wm.c:1.728	Sat Feb 26 14:53:05 2022
+++ src/sys/dev/pci/if_wm.c	Sat Feb 26 15:04:39 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.728 2022/02/26 14:53:05 rillig Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.729 2022/02/26 15:04:39 rillig Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.728 2022/02/26 14:53:05 rillig Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.729 2022/02/26 15:04:39 rillig Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -10025,7 +10025,8 @@ wm_txrxintr_disable(struct wm_queue *wmq
 	struct wm_softc *sc = wmq->wmq_txq.txq_sc;
 
 	if (__predict_false(!wm_is_using_msix(sc))) {
-		return wm_legacy_intr_disable(sc);
+		wm_legacy_intr_disable(sc);
+		return;
 	}
 
 	if (sc->sc_type == WM_T_82574)
@@ -10046,7 +10047,8 @@ wm_txrxintr_enable(struct wm_queue *wmq)
 	wm_itrs_calculate(sc, wmq);
 
 	if (__predict_false(!wm_is_using_msix(sc))) {
-		return wm_legacy_intr_enable(sc);
+		wm_legacy_intr_enable(sc);
+		return;
 	}
 
 	/*



CVS commit: src/sys/dev/pci

2022-02-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 26 15:04:40 UTC 2022

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

Log Message:
if_wm.c: fix value return from void function

lint complained:
if_wm.c(10028): error:
void function wm_txrxintr_disable cannot return value [213]
if_wm.c(10049): error:
void function wm_txrxintr_enable cannot return value [213]

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.728 -r1.729 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/pci

2022-02-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 26 14:53:05 UTC 2022

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

Log Message:
if_wm.c: remove stray semicolons from struct declaration

C99 does not allow 'struct { int member;; }'.

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.727 -r1.728 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.727 src/sys/dev/pci/if_wm.c:1.728
--- src/sys/dev/pci/if_wm.c:1.727	Wed Feb 16 03:15:27 2022
+++ src/sys/dev/pci/if_wm.c	Sat Feb 26 14:53:05 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.727 2022/02/16 03:15:27 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.728 2022/02/26 14:53:05 rillig Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.727 2022/02/16 03:15:27 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.728 2022/02/26 14:53:05 rillig Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -471,11 +471,11 @@ struct wm_rxqueue {
 	uint32_t rxq_bytes;		/* for AIM */
 #ifdef WM_EVENT_COUNTERS
 	/* RX event counters */
-	WM_Q_EVCNT_DEFINE(rxq, intr);	/* Interrupts */
-	WM_Q_EVCNT_DEFINE(rxq, defer);	/* Rx deferred processing */
+	WM_Q_EVCNT_DEFINE(rxq, intr)	/* Interrupts */
+	WM_Q_EVCNT_DEFINE(rxq, defer)	/* Rx deferred processing */
 
-	WM_Q_EVCNT_DEFINE(rxq, ipsum);	/* IP checksums checked */
-	WM_Q_EVCNT_DEFINE(rxq, tusum);	/* TCP/UDP cksums checked */
+	WM_Q_EVCNT_DEFINE(rxq, ipsum)	/* IP checksums checked */
+	WM_Q_EVCNT_DEFINE(rxq, tusum)	/* TCP/UDP cksums checked */
 #endif
 };
 



CVS commit: src/sys/dev/pci

2022-02-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 26 14:53:05 UTC 2022

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

Log Message:
if_wm.c: remove stray semicolons from struct declaration

C99 does not allow 'struct { int member;; }'.

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.727 -r1.728 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/usr.bin/vmstat

2022-02-26 Thread Roland Illig

Am 09.02.2022 um 08:34 schrieb matthew green:

Module Name:src
Committed By:   mrg
Date:   Wed Feb  9 07:34:18 UTC 2022

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

Log Message:
allow the number of disks displayed in the default output
to be controlled.


To generate a diff of this commit:
cvs rdiff -u -r1.249 -r1.250 src/usr.bin/vmstat/vmstat.c


Did you omit the "static" from the variable definition on purpose?  As a
general rule, I prefer to keep the scope of each variable as narrow as
possible.

Roland


CVS commit: src/crypto/external/bsd/openssh/dist

2022-02-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Feb 26 13:30:19 UTC 2022

Modified Files:
src/crypto/external/bsd/openssh/dist: misc.c

Log Message:
fix merge botch and reduce diff from upstream.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/crypto/external/bsd/openssh/dist/misc.c

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

Modified files:

Index: src/crypto/external/bsd/openssh/dist/misc.c
diff -u src/crypto/external/bsd/openssh/dist/misc.c:1.29 src/crypto/external/bsd/openssh/dist/misc.c:1.30
--- src/crypto/external/bsd/openssh/dist/misc.c:1.29	Wed Feb 23 14:07:20 2022
+++ src/crypto/external/bsd/openssh/dist/misc.c	Sat Feb 26 08:30:19 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: misc.c,v 1.29 2022/02/23 19:07:20 christos Exp $	*/
+/*	$NetBSD: misc.c,v 1.30 2022/02/26 13:30:19 christos Exp $	*/
 /* $OpenBSD: misc.c,v 1.174 2022/02/11 00:43:56 dtucker Exp $ */
 /*
  * Copyright (c) 2000 Markus Friedl.  All rights reserved.
@@ -19,7 +19,7 @@
  */
 
 #include "includes.h"
-__RCSID("$NetBSD: misc.c,v 1.29 2022/02/23 19:07:20 christos Exp $");
+__RCSID("$NetBSD: misc.c,v 1.30 2022/02/26 13:30:19 christos Exp $");
 
 #include 
 #include 
@@ -742,7 +742,7 @@ int
 parse_user_host_path(const char *s, char **userp, char **hostp, char **pathp)
 {
 	char *user = NULL, *host = NULL, *path = NULL;
-	char *tmp, *sdup;
+	char *sdup, *tmp;
 	int ret = -1;
 
 	if (userp != NULL)
@@ -1094,8 +1094,7 @@ tilde_expand(const char *filename, uid_t
 	const char *path = NULL, *user = NULL;
 	struct passwd *pw;
 	size_t len;
-	int ret = -1, r;
-	const char *sep, *homedir;
+	int ret = -1, r, slash;
 
 	*retp = NULL;
 	if (*filename != '~') {
@@ -1129,27 +1128,16 @@ tilde_expand(const char *filename, uid_t
 			error_f("No such user %s", user);
 			goto out;
 		}
-		homedir = pw->pw_dir;
-	} else {
-		if ((pw = getpwuid(uid)) == NULL) {	/* ~/path */
-			error_f("No such uid %ld", (long)uid);
-			goto out;
-		}
-		homedir = pw->pw_dir;
+	} else if ((pw = getpwuid(uid)) == NULL) {
+		error_f("No such uid %ld", (long)uid);
+		goto out;
 	}
 
 	/* Make sure directory has a trailing '/' */
-	len = strlen(homedir);
-	if (len == 0 || homedir[len - 1] != '/')
-		sep = "/";
-	else
-		sep = "";
-
-	/* Skip leading '/' from specified path */
-	if (path != NULL)
-		filename = path + 1;
+	slash = (len = strlen(pw->pw_dir)) == 0 || pw->pw_dir[len - 1] != '/';
 
-	if ((r = xasprintf(, "%s%s%s", homedir, sep, filename)) <= 0) {
+	if ((r = xasprintf(, "%s%s%s", pw->pw_dir,
+	slash ? "/" : "", path != NULL ? path : "")) <= 0) {
 		error_f("xasprintf failed");
 		goto out;
 	}



CVS commit: src/crypto/external/bsd/openssh/dist

2022-02-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Feb 26 13:30:19 UTC 2022

Modified Files:
src/crypto/external/bsd/openssh/dist: misc.c

Log Message:
fix merge botch and reduce diff from upstream.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/crypto/external/bsd/openssh/dist/misc.c

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



CVS commit: src/external/mit/expat/lib/libexpat

2022-02-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Feb 26 13:17:39 UTC 2022

Modified Files:
src/external/mit/expat/lib/libexpat: expat_config.h

Log Message:
ah, wiz added another endif.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/external/mit/expat/lib/libexpat/expat_config.h

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

Modified files:

Index: src/external/mit/expat/lib/libexpat/expat_config.h
diff -u src/external/mit/expat/lib/libexpat/expat_config.h:1.11 src/external/mit/expat/lib/libexpat/expat_config.h:1.12
--- src/external/mit/expat/lib/libexpat/expat_config.h:1.11	Sat Feb 26 08:15:18 2022
+++ src/external/mit/expat/lib/libexpat/expat_config.h	Sat Feb 26 08:17:39 2022
@@ -108,7 +108,6 @@
 /* #  undef WORDS_BIGENDIAN */
 # endif
 #endif
-#endif
 
 /* Define to allow retrieving the byte offsets for attribute names and values.
*/



CVS commit: src/external/mit/expat/lib/libexpat

2022-02-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Feb 26 13:17:39 UTC 2022

Modified Files:
src/external/mit/expat/lib/libexpat: expat_config.h

Log Message:
ah, wiz added another endif.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/external/mit/expat/lib/libexpat/expat_config.h

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



CVS commit: src/external/mit/expat/lib/libexpat

2022-02-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Feb 26 13:15:19 UTC 2022

Modified Files:
src/external/mit/expat/lib/libexpat: expat_config.h

Log Message:
remove stray #if 0


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/external/mit/expat/lib/libexpat/expat_config.h

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

Modified files:

Index: src/external/mit/expat/lib/libexpat/expat_config.h
diff -u src/external/mit/expat/lib/libexpat/expat_config.h:1.10 src/external/mit/expat/lib/libexpat/expat_config.h:1.11
--- src/external/mit/expat/lib/libexpat/expat_config.h:1.10	Sat Feb 26 05:16:35 2022
+++ src/external/mit/expat/lib/libexpat/expat_config.h	Sat Feb 26 08:15:18 2022
@@ -99,7 +99,6 @@
 
 /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
-#if 0
 #if defined AC_APPLE_UNIVERSAL_BUILD
 # if defined __BIG_ENDIAN__
 #  define WORDS_BIGENDIAN 1



CVS commit: src/external/mit/expat/lib/libexpat

2022-02-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Feb 26 13:15:19 UTC 2022

Modified Files:
src/external/mit/expat/lib/libexpat: expat_config.h

Log Message:
remove stray #if 0


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/external/mit/expat/lib/libexpat/expat_config.h

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



CVS commit: src/usr.bin/make

2022-02-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 26 11:57:21 UTC 2022

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

Log Message:
make: fix memory leak in Lst_Remove (since 2020-10-23)

The code to free the list node (as opposed to the node data) was
accidentally removed in lst.c 1.83 from 2020-10-23 as part of cleaning
up an unnecessarily complicated function for traversing linked lists.

The memory leak only affected a few lists that actually used Lst_Remove.
Most lists are append-only and are freed using Lst_Done or Lst_Free at
the end, which correctly free the memory.


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

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

Modified files:

Index: src/usr.bin/make/lst.c
diff -u src/usr.bin/make/lst.c:1.105 src/usr.bin/make/lst.c:1.106
--- src/usr.bin/make/lst.c:1.105	Mon Mar 15 16:45:30 2021
+++ src/usr.bin/make/lst.c	Sat Feb 26 11:57:21 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.105 2021/03/15 16:45:30 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.106 2022/02/26 11:57:21 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -34,7 +34,7 @@
 
 #include "make.h"
 
-MAKE_RCSID("$NetBSD: lst.c,v 1.105 2021/03/15 16:45:30 rillig Exp $");
+MAKE_RCSID("$NetBSD: lst.c,v 1.106 2022/02/26 11:57:21 rillig Exp $");
 
 static ListNode *
 LstNodeNew(ListNode *prev, ListNode *next, void *datum)
@@ -163,6 +163,8 @@ Lst_Remove(List *list, ListNode *ln)
 		list->first = ln->next;
 	if (list->last == ln)
 		list->last = ln->prev;
+
+	free(ln);
 }
 
 /* Replace the datum in the given node with the new datum. */



CVS commit: src/usr.bin/make

2022-02-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 26 11:57:21 UTC 2022

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

Log Message:
make: fix memory leak in Lst_Remove (since 2020-10-23)

The code to free the list node (as opposed to the node data) was
accidentally removed in lst.c 1.83 from 2020-10-23 as part of cleaning
up an unnecessarily complicated function for traversing linked lists.

The memory leak only affected a few lists that actually used Lst_Remove.
Most lists are append-only and are freed using Lst_Done or Lst_Free at
the end, which correctly free the memory.


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

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



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

2022-02-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 26 11:13:01 UTC 2022

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_230.c msg_230_uchar.c

Log Message:
tests/lint: sync tests for platform-dependent character comparisons


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/tests/usr.bin/xlint/lint1/msg_230.c
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/msg_230_uchar.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_230.c
diff -u src/tests/usr.bin/xlint/lint1/msg_230.c:1.10 src/tests/usr.bin/xlint/lint1/msg_230.c:1.11
--- src/tests/usr.bin/xlint/lint1/msg_230.c:1.10	Sat Oct  9 22:03:38 2021
+++ src/tests/usr.bin/xlint/lint1/msg_230.c	Sat Feb 26 11:13:01 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_230.c,v 1.10 2021/10/09 22:03:38 rillig Exp $	*/
+/*	$NetBSD: msg_230.c,v 1.11 2022/02/26 11:13:01 rillig Exp $	*/
 # 3 "msg_230.c"
 
 // Test for message: nonportable character comparison '%s %d' [230]
@@ -71,7 +71,7 @@ compare_plain_char_yoda(char c)
 }
 
 void
-compare_lt(char c)
+compare_greater(char c)
 {
 
 	/* expect+1: warning: nonportable character comparison '> -2' [230] */

Index: src/tests/usr.bin/xlint/lint1/msg_230_uchar.c
diff -u src/tests/usr.bin/xlint/lint1/msg_230_uchar.c:1.6 src/tests/usr.bin/xlint/lint1/msg_230_uchar.c:1.7
--- src/tests/usr.bin/xlint/lint1/msg_230_uchar.c:1.6	Thu Dec 16 21:14:59 2021
+++ src/tests/usr.bin/xlint/lint1/msg_230_uchar.c	Sat Feb 26 11:13:01 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_230_uchar.c,v 1.6 2021/12/16 21:14:59 rillig Exp $	*/
+/*	$NetBSD: msg_230_uchar.c,v 1.7 2022/02/26 11:13:01 rillig Exp $	*/
 # 3 "msg_230_uchar.c"
 
 // Test for message: nonportable character comparison '%s %d' [230]
@@ -46,32 +46,32 @@ compare_plain_char(char c)
 void
 compare_plain_char_yoda(char c)
 {
-	/* expect+1: warning: nonportable character comparison '== -129' */
+	/* expect+1: warning: nonportable character comparison '== -129' [230] */
 	if (-129 == c)
 		return;
-	/* expect+1: warning: nonportable character comparison '== -128' */
+	/* expect+1: warning: nonportable character comparison '== -128' [230] */
 	if (-128 == c)
 		return;
-	/* expect+1: warning: nonportable character comparison '== -1' */
+	/* expect+1: warning: nonportable character comparison '== -1' [230] */
 	if (-1 == c)
 		return;
 	if (0 == c)
 		return;
 	if (127 == c)
 		return;
-	/* expect+1: warning: nonportable character comparison '== 128' */
+	/* expect+1: warning: nonportable character comparison '== 128' [230] */
 	if (128 == c)
 		return;
-	/* expect+1: warning: nonportable character comparison '== 255' */
+	/* expect+1: warning: nonportable character comparison '== 255' [230] */
 	if (255 == c)
 		return;
-	/* expect+1: warning: nonportable character comparison '== 256' */
+	/* expect+1: warning: nonportable character comparison '== 256' [230] */
 	if (256 == c)
 		return;
 }
 
 void
-compare_lt(char c)
+compare_greater(char c)
 {
 
 	/* expect+1: warning: nonportable character comparison '> -2' [230] */
@@ -116,3 +116,19 @@ compare_lt(char c)
 	if (c >= 129)
 		return;
 }
+
+void
+compare_with_character_literal(char ch)
+{
+	/*
+	 * These comparisons are portable since the character constant is
+	 * interpreted using the type 'char' on the exact same platform as
+	 * where the comparison takes place.
+	 */
+	if (ch == '\200')
+		return;
+	if (ch == '\377')
+		return;
+	if (ch == '\000')
+		return;
+}



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

2022-02-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 26 11:13:01 UTC 2022

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_230.c msg_230_uchar.c

Log Message:
tests/lint: sync tests for platform-dependent character comparisons


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/tests/usr.bin/xlint/lint1/msg_230.c
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/msg_230_uchar.c

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



CVS commit: src/external/mit/expat/lib/libexpat

2022-02-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Feb 26 10:16:35 UTC 2022

Modified Files:
src/external/mit/expat/lib/libexpat: expat_config.h

Log Message:
Try to fix the build: HAVE_GETRANDOM does not compile


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/external/mit/expat/lib/libexpat/expat_config.h

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

Modified files:

Index: src/external/mit/expat/lib/libexpat/expat_config.h
diff -u src/external/mit/expat/lib/libexpat/expat_config.h:1.9 src/external/mit/expat/lib/libexpat/expat_config.h:1.10
--- src/external/mit/expat/lib/libexpat/expat_config.h:1.9	Fri Feb 25 21:52:47 2022
+++ src/external/mit/expat/lib/libexpat/expat_config.h	Sat Feb 26 10:16:35 2022
@@ -24,7 +24,7 @@
 #define HAVE_GETPAGESIZE 1
 
 /* Define to 1 if you have the `getrandom' function. */
-#define HAVE_GETRANDOM 1
+/* #define HAVE_GETRANDOM 1 */
 
 /* Define to 1 if you have the  header file. */
 #define HAVE_INTTYPES_H 1



CVS commit: src/external/mit/expat/lib/libexpat

2022-02-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Feb 26 10:16:35 UTC 2022

Modified Files:
src/external/mit/expat/lib/libexpat: expat_config.h

Log Message:
Try to fix the build: HAVE_GETRANDOM does not compile


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/external/mit/expat/lib/libexpat/expat_config.h

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