Fri Apr 2 09:52:36 2021 UTC ()
lint: rename getnode to expr_zalloc_tnode

The new name highlights that the returned memory is only valid in the
scope of the current expression.  This was misleading before since the
other related functions all have a 't' (probably for 'temporary') in
their names.

Also encode in the function name that the returned memory is zeroed out
as that could not be inferred from the old name.

No functional change.


(rillig)
diff -r1.207 -r1.208 src/usr.bin/xlint/lint1/cgram.y
diff -r1.96 -r1.97 src/usr.bin/xlint/lint1/externs1.h
diff -r1.39 -r1.40 src/usr.bin/xlint/lint1/mem1.c
diff -r1.255 -r1.256 src/usr.bin/xlint/lint1/tree.c

cvs diff -r1.207 -r1.208 src/usr.bin/xlint/lint1/cgram.y (expand / switch to context diff)
--- src/usr.bin/xlint/lint1/cgram.y 2021/03/30 14:25:28 1.207
+++ src/usr.bin/xlint/lint1/cgram.y 2021/04/02 09:52:36 1.208
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.207 2021/03/30 14:25:28 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.208 2021/04/02 09:52:36 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.207 2021/03/30 14:25:28 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.208 2021/04/02 09:52:36 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -1596,7 +1596,7 @@
 		seen_fallthrough = false;
 	  }
 	| non_expr_statement {
-		$$ = getnode();
+		$$ = expr_zalloc_tnode();
 		$$->tn_type = gettyp(VOID);
 	  }
 	;

cvs diff -r1.96 -r1.97 src/usr.bin/xlint/lint1/externs1.h (expand / switch to context diff)
--- src/usr.bin/xlint/lint1/externs1.h 2021/04/02 09:39:25 1.96
+++ src/usr.bin/xlint/lint1/externs1.h 2021/04/02 09:52:36 1.97
@@ -1,4 +1,4 @@
-/*	$NetBSD: externs1.h,v 1.96 2021/04/02 09:39:25 rillig Exp $	*/
+/*	$NetBSD: externs1.h,v 1.97 2021/04/02 09:52:36 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -106,7 +106,7 @@
 extern	void	freelblk(int);
 
 extern	void	*tgetblk(size_t);
-extern	tnode_t	*getnode(void);
+extern	tnode_t	*expr_zalloc_tnode(void);
 extern	void	tfreeblk(void);
 extern	struct	memory_block *tsave(void);
 extern	void	trestor(struct memory_block *);

cvs diff -r1.39 -r1.40 src/usr.bin/xlint/lint1/mem1.c (expand / switch to context diff)
--- src/usr.bin/xlint/lint1/mem1.c 2021/04/02 09:45:55 1.39
+++ src/usr.bin/xlint/lint1/mem1.c 2021/04/02 09:52:36 1.40
@@ -1,4 +1,4 @@
-/*	$NetBSD: mem1.c,v 1.39 2021/04/02 09:45:55 rillig Exp $	*/
+/*	$NetBSD: mem1.c,v 1.40 2021/04/02 09:52:36 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: mem1.c,v 1.39 2021/04/02 09:45:55 rillig Exp $");
+__RCSID("$NetBSD: mem1.c,v 1.40 2021/04/02 09:52:36 rillig Exp $");
 #endif
 
 #include <sys/types.h>
@@ -344,7 +344,7 @@
 
 /* Return a freshly allocated tree node. */
 tnode_t *
-getnode(void)
+expr_zalloc_tnode(void)
 {
 	tnode_t *tn = tgetblk(sizeof *tn);
 	tn->tn_from_system_header = in_system_header;

cvs diff -r1.255 -r1.256 src/usr.bin/xlint/lint1/tree.c (expand / switch to context diff)
--- src/usr.bin/xlint/lint1/tree.c 2021/04/01 15:06:49 1.255
+++ src/usr.bin/xlint/lint1/tree.c 2021/04/02 09:52:36 1.256
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.255 2021/04/01 15:06:49 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.256 2021/04/02 09:52:36 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.255 2021/04/01 15:06:49 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.256 2021/04/02 09:52:36 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -181,7 +181,7 @@
 {
 	tnode_t	*n;
 
-	n = getnode();
+	n = expr_zalloc_tnode();
 	n->tn_op = CON;
 	n->tn_type = tp;
 	n->tn_val = tgetblk(sizeof *n->tn_val);
@@ -197,7 +197,7 @@
 {
 	tnode_t	*n;
 
-	n = getnode();
+	n = expr_zalloc_tnode();
 	n->tn_op = CON;
 	n->tn_type = gettyp(t);
 	n->tn_val = tgetblk(sizeof *n->tn_val);
@@ -279,7 +279,7 @@
 
 	lint_assert(sym->s_kind == FVFT || sym->s_kind == FMEMBER);
 
-	n = getnode();
+	n = expr_zalloc_tnode();
 	n->tn_type = sym->s_type;
 	if (sym->s_scl != CTCONST) {
 		n->tn_op = NAME;
@@ -303,7 +303,7 @@
 
 	len = strg->st_len;
 
-	n = getnode();
+	n = expr_zalloc_tnode();
 
 	n->tn_op = STRING;
 	n->tn_type = tincref(gettyp(strg->st_tspec), ARRAY);
@@ -1809,7 +1809,7 @@
 	uint64_t rnum;
 #endif
 
-	ntn = getnode();
+	ntn = expr_zalloc_tnode();
 
 	ntn->tn_op = op;
 	ntn->tn_type = type;
@@ -2056,7 +2056,7 @@
 		check_pointer_conversion(op, tn, tp);
 	}
 
-	ntn = getnode();
+	ntn = expr_zalloc_tnode();
 	ntn->tn_op = CVT;
 	ntn->tn_type = tp;
 	ntn->tn_cast = op == CVT;
@@ -3501,7 +3501,7 @@
 		}
 		for (m = str->sou_first_member; m != NULL; m = m->s_next) {
 			if (sametype(m->s_type, tn->tn_type)) {
-				tn = getnode();
+				tn = expr_zalloc_tnode();
 				tn->tn_op = CVT;
 				tn->tn_type = tp;
 				tn->tn_cast = true;