Module Name:    src
Committed By:   rillig
Date:           Sun Feb 27 08:31:26 UTC 2022

Modified Files:
        src/tests/usr.bin/xlint/lint1: d_c99_bool_strict.c
        src/usr.bin/xlint/lint1: cgram.y decl.c externs1.h func.c init.c lex.c
            mem1.c tree.c

Log Message:
lint: encode lifetime of allocated memory in the function names

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c
cvs rdiff -u -r1.382 -r1.383 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.245 -r1.246 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.146 -r1.147 src/usr.bin/xlint/lint1/externs1.h
cvs rdiff -u -r1.126 -r1.127 src/usr.bin/xlint/lint1/func.c
cvs rdiff -u -r1.230 -r1.231 src/usr.bin/xlint/lint1/init.c
cvs rdiff -u -r1.100 -r1.101 src/usr.bin/xlint/lint1/lex.c
cvs rdiff -u -r1.59 -r1.60 src/usr.bin/xlint/lint1/mem1.c
cvs rdiff -u -r1.404 -r1.405 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_c99_bool_strict.c
diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c:1.36 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c:1.37
--- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c:1.36	Sat Jan 15 14:22:03 2022
+++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c	Sun Feb 27 08:31:26 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: d_c99_bool_strict.c,v 1.36 2022/01/15 14:22:03 rillig Exp $	*/
+/*	$NetBSD: d_c99_bool_strict.c,v 1.37 2022/02/27 08:31:26 rillig Exp $	*/
 # 3 "d_c99_bool_strict.c"
 
 /*
@@ -1042,7 +1042,7 @@ controlling_expression(FILE *f, const ch
 	/*
 	 * Before cgram.y 1.369 from 2021-11-16, the comment following
 	 * 'stdio_stdout' did not prevent the search for '('.  At the point
-	 * where build_name called expr_zalloc_tnode, the parser was already
+	 * where build_name called expr_alloc_tnode, the parser was already
 	 * in the main file again, thus treating 'stdio_stdout' as not coming
 	 * from a system header.
 	 *

Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.382 src/usr.bin/xlint/lint1/cgram.y:1.383
--- src/usr.bin/xlint/lint1/cgram.y:1.382	Sun Feb 27 01:47:28 2022
+++ src/usr.bin/xlint/lint1/cgram.y	Sun Feb 27 08:31:26 2022
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.382 2022/02/27 01:47:28 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.383 2022/02/27 08:31:26 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.382 2022/02/27 01:47:28 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.383 2022/02/27 08:31:26 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -58,7 +58,7 @@ int	block_level;
  * for these can't be freed after the declaration, but symbols must
  * be removed from the symbol table after the declaration.
  */
-int	mem_block_level;
+size_t	mem_block_level;
 
 /*
  * Save the no-warns state and restore it to avoid the problem where
@@ -477,12 +477,12 @@ generic_assoc_list:
 /* K&R ---, C90 ---, C99 ---, C11 6.5.1.1 */
 generic_association:
 	  type_name T_COLON assignment_expression {
-		$$ = getblk(sizeof(*$$));
+		$$ = block_zero_alloc(sizeof(*$$));
 		$$->ga_arg = $1;
 		$$->ga_result = $3;
 	  }
 	| T_DEFAULT T_COLON assignment_expression {
-		$$ = getblk(sizeof(*$$));
+		$$ = block_zero_alloc(sizeof(*$$));
 		$$->ga_arg = NULL;
 		$$->ga_result = $3;
 	  }
@@ -549,12 +549,12 @@ gcc_statement_expr_item:
 		$$ = NULL;
 	  }
 	| non_expr_statement {
-		$$ = expr_zalloc_tnode();
+		$$ = expr_alloc_tnode();
 		$$->tn_type = gettyp(VOID);
 	  }
 	| expression T_SEMI {
 		if ($1 == NULL) {	/* in case of syntax errors */
-			$$ = expr_zalloc_tnode();
+			$$ = expr_alloc_tnode();
 			$$->tn_type = gettyp(VOID);
 		} else {
 			/* XXX: do that only on the last name */
@@ -1692,7 +1692,7 @@ compound_statement_lbrace:
 compound_statement_rbrace:
 	  T_RBRACE {
 		end_declaration_level();
-		freeblk();
+		level_free_all(mem_block_level);
 		mem_block_level--;
 		block_level--;
 		seen_fallthrough = false;

Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.245 src/usr.bin/xlint/lint1/decl.c:1.246
--- src/usr.bin/xlint/lint1/decl.c:1.245	Sun Feb 27 01:47:28 2022
+++ src/usr.bin/xlint/lint1/decl.c	Sun Feb 27 08:31:26 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.245 2022/02/27 01:47:28 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.246 2022/02/27 08:31:26 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.245 2022/02/27 01:47:28 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.246 2022/02/27 08:31:26 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -176,7 +176,7 @@ dup_type(const type_t *tp)
 {
 	type_t	*ntp;
 
-	ntp = getblk(sizeof(*ntp));
+	ntp = block_zero_alloc(sizeof(*ntp));
 	*ntp = *tp;
 	return ntp;
 }
@@ -190,7 +190,7 @@ expr_dup_type(const type_t *tp)
 {
 	type_t	*ntp;
 
-	ntp = expr_zalloc(sizeof(*ntp));
+	ntp = expr_zero_alloc(sizeof(*ntp));
 	*ntp = *tp;
 	return ntp;
 }
@@ -206,7 +206,7 @@ expr_unqualified_type(const type_t *tp)
 {
 	type_t *ntp;
 
-	ntp = expr_zalloc(sizeof(*ntp));
+	ntp = expr_zero_alloc(sizeof(*ntp));
 	*ntp = *tp;
 	ntp->t_const = false;
 	ntp->t_volatile = false;
@@ -1252,7 +1252,7 @@ bitfield(sym_t *dsym, int len)
 {
 
 	if (dsym == NULL) {
-		dsym = getblk(sizeof(*dsym));
+		dsym = block_zero_alloc(sizeof(*dsym));
 		dsym->s_name = unnamed;
 		dsym->s_kind = FMEMBER;
 		dsym->s_scl = MOS;
@@ -1328,7 +1328,7 @@ add_pointer(sym_t *decl, qual_ptr *p)
 		return decl;
 
 	while (p != NULL) {
-		*tpp = tp = getblk(sizeof(*tp));
+		*tpp = tp = block_zero_alloc(sizeof(*tp));
 		tp->t_tspec = PTR;
 		tp->t_const = p->p_const;
 		tp->t_volatile = p->p_volatile;
@@ -1355,7 +1355,7 @@ add_array(sym_t *decl, bool dim, int n)
 	if (*tpp == NULL)
 	    return decl;
 
-	*tpp = tp = getblk(sizeof(*tp));
+	*tpp = tp = block_zero_alloc(sizeof(*tp));
 	tp->t_tspec = ARRAY;
 	tp->t_subt = dcs->d_type;
 	tp->t_dim = n;
@@ -1418,7 +1418,7 @@ add_function(sym_t *decl, sym_t *args)
 	if (*tpp == NULL)
 	    return decl;	/* see msg_347 */
 
-	*tpp = tp = getblk(sizeof(*tp));
+	*tpp = tp = block_zero_alloc(sizeof(*tp));
 	tp->t_tspec = FUNC;
 	tp->t_subt = dcs->d_next->d_type;
 	if ((tp->t_proto = dcs->d_proto) != false)
@@ -1669,19 +1669,19 @@ mktag(sym_t *tag, tspec_t kind, bool dec
 		}
 		if (tag->s_scl == NOSCL) {
 			tag->s_scl = scl;
-			tag->s_type = tp = getblk(sizeof(*tp));
+			tag->s_type = tp = block_zero_alloc(sizeof(*tp));
 			tp->t_packed = dcs->d_packed;
 		} else {
 			tp = tag->s_type;
 		}
 	} else {
-		tag = getblk(sizeof(*tag));
+		tag = block_zero_alloc(sizeof(*tag));
 		tag->s_name = unnamed;
 		UNIQUE_CURR_POS(tag->s_def_pos);
 		tag->s_kind = FTAG;
 		tag->s_scl = scl;
 		tag->s_block_level = -1;
-		tag->s_type = tp = getblk(sizeof(*tp));
+		tag->s_type = tp = block_zero_alloc(sizeof(*tp));
 		tp->t_packed = dcs->d_packed;
 		dcs->d_next->d_nonempty_decl = true;
 	}
@@ -1689,12 +1689,12 @@ mktag(sym_t *tag, tspec_t kind, bool dec
 	if (tp->t_tspec == NOTSPEC) {
 		tp->t_tspec = kind;
 		if (kind != ENUM) {
-			tp->t_str = getblk(sizeof(*tp->t_str));
+			tp->t_str = block_zero_alloc(sizeof(*tp->t_str));
 			tp->t_str->sou_align_in_bits = CHAR_SIZE;
 			tp->t_str->sou_tag = tag;
 		} else {
 			tp->t_is_enum = true;
-			tp->t_enum = getblk(sizeof(*tp->t_enum));
+			tp->t_enum = block_zero_alloc(sizeof(*tp->t_enum));
 			tp->t_enum->en_tag = tag;
 		}
 		setcomplete(tp, false);
@@ -1902,7 +1902,7 @@ declare_extern(sym_t *dsym, bool initflg
 	if (renaming != NULL) {
 		lint_assert(dsym->s_rename == NULL);
 
-		s = getlblk(1, renaming->sb_len + 1);
+		s = level_zero_alloc(1, renaming->sb_len + 1);
 		(void)memcpy(s, renaming->sb_name, renaming->sb_len + 1);
 		dsym->s_rename = s;
 	}
@@ -2863,7 +2863,7 @@ abstract_name(void)
 
 	lint_assert(dcs->d_ctx == ABSTRACT || dcs->d_ctx == PROTO_ARG);
 
-	sym = getblk(sizeof(*sym));
+	sym = block_zero_alloc(sizeof(*sym));
 
 	sym->s_name = unnamed;
 	sym->s_def = DEF;

Index: src/usr.bin/xlint/lint1/externs1.h
diff -u src/usr.bin/xlint/lint1/externs1.h:1.146 src/usr.bin/xlint/lint1/externs1.h:1.147
--- src/usr.bin/xlint/lint1/externs1.h:1.146	Sat Feb 26 20:36:11 2022
+++ src/usr.bin/xlint/lint1/externs1.h	Sun Feb 27 08:31:26 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: externs1.h,v 1.146 2022/02/26 20:36:11 rillig Exp $	*/
+/*	$NetBSD: externs1.h,v 1.147 2022/02/27 08:31:26 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -61,7 +61,7 @@ extern	void	norecover(void);
  * cgram.y
  */
 extern	int	block_level;
-extern	int	mem_block_level;
+extern	size_t	mem_block_level;
 extern	int	yydebug;
 
 extern	int	yyerror(const char *);
@@ -100,13 +100,12 @@ extern	const char *transform_filename(co
 
 extern	void	initmem(void);
 
-extern	void	*getblk(size_t);
-extern	void	*getlblk(size_t, size_t);
-extern	void	freeblk(void);
-extern	void	freelblk(int);
+extern	void	*block_zero_alloc(size_t);
+extern	void	*level_zero_alloc(size_t, size_t);
+extern	void	level_free_all(size_t);
 
-extern	void	*expr_zalloc(size_t);
-extern	tnode_t	*expr_zalloc_tnode(void);
+extern	void	*expr_zero_alloc(size_t);
+extern	tnode_t	*expr_alloc_tnode(void);
 extern	void	expr_free_all(void);
 extern	struct	memory_block *expr_save_memory(void);
 extern	void	expr_restore_memory(struct memory_block *);

Index: src/usr.bin/xlint/lint1/func.c
diff -u src/usr.bin/xlint/lint1/func.c:1.126 src/usr.bin/xlint/lint1/func.c:1.127
--- src/usr.bin/xlint/lint1/func.c:1.126	Tue Nov 16 21:01:05 2021
+++ src/usr.bin/xlint/lint1/func.c	Sun Feb 27 08:31:26 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: func.c,v 1.126 2021/11/16 21:01:05 rillig Exp $	*/
+/*	$NetBSD: func.c,v 1.127 2022/02/27 08:31:26 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: func.c,v 1.126 2021/11/16 21:01:05 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.127 2022/02/27 08:31:26 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -1086,7 +1086,7 @@ do_return(bool sys, tnode_t *tn)
 	if (tn != NULL) {
 
 		/* Create a temporary node for the left side */
-		ln = expr_zalloc(sizeof(*ln));
+		ln = expr_zero_alloc(sizeof(*ln));
 		ln->tn_op = NAME;
 		ln->tn_type = expr_unqualified_type(funcsym->s_type->t_subt);
 		ln->tn_lvalue = true;

Index: src/usr.bin/xlint/lint1/init.c
diff -u src/usr.bin/xlint/lint1/init.c:1.230 src/usr.bin/xlint/lint1/init.c:1.231
--- src/usr.bin/xlint/lint1/init.c:1.230	Wed Dec 22 14:35:23 2021
+++ src/usr.bin/xlint/lint1/init.c	Sun Feb 27 08:31:26 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: init.c,v 1.230 2021/12/22 14:35:23 rillig Exp $	*/
+/*	$NetBSD: init.c,v 1.231 2022/02/27 08:31:26 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: init.c,v 1.230 2021/12/22 14:35:23 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.231 2022/02/27 08:31:26 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -314,7 +314,7 @@ check_init_expr(const type_t *ltp, sym_t
 	lutp = expr_unqualified_type(ltp);
 
 	/* Create a temporary node for the left side. */
-	ln = expr_zalloc(sizeof(*ln));
+	ln = expr_zero_alloc(sizeof(*ln));
 	ln->tn_op = NAME;
 	ln->tn_type = lutp;
 	ln->tn_lvalue = true;

Index: src/usr.bin/xlint/lint1/lex.c
diff -u src/usr.bin/xlint/lint1/lex.c:1.100 src/usr.bin/xlint/lint1/lex.c:1.101
--- src/usr.bin/xlint/lint1/lex.c:1.100	Sun Feb 27 07:50:09 2022
+++ src/usr.bin/xlint/lint1/lex.c	Sun Feb 27 08:31:26 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.100 2022/02/27 07:50:09 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.101 2022/02/27 08:31:26 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: lex.c,v 1.100 2022/02/27 07:50:09 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.101 2022/02/27 08:31:26 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -297,7 +297,7 @@ add_keyword(const struct keyword *kw, bo
 		name = xstrdup(buf);
 	}
 
-	sym = getblk(sizeof(*sym));
+	sym = block_zero_alloc(sizeof(*sym));
 	sym->s_name = name;
 	sym->s_keyword = kw;
 	sym->s_value.v_quad = kw->kw_token;
@@ -407,7 +407,7 @@ lex_name(const char *yytext, size_t yyle
 		sb->sb_len = strlen(sym->s_name);
 		tok = sym->s_scl == TYPEDEF ? T_TYPENAME : T_NAME;
 	} else {
-		s = getblk(yyleng + 1);
+		s = block_zero_alloc(yyleng + 1);
 		(void)memcpy(s, yytext, yyleng + 1);
 		sb->sb_name = s;
 		sb->sb_len = yyleng;
@@ -1352,8 +1352,8 @@ getsym(sbuf_t *sb)
 
 	/* labels must always be allocated at level 1 (outermost block) */
 	if (symtyp == FLABEL) {
-		sym = getlblk(1, sizeof(*sym));
-		s = getlblk(1, sb->sb_len + 1);
+		sym = level_zero_alloc(1, sizeof(*sym));
+		s = level_zero_alloc(1, sb->sb_len + 1);
 		(void)memcpy(s, sb->sb_name, sb->sb_len + 1);
 		sym->s_name = s;
 		sym->s_block_level = 1;
@@ -1362,7 +1362,7 @@ getsym(sbuf_t *sb)
 			di = di->d_next;
 		lint_assert(di->d_ctx == AUTO);
 	} else {
-		sym = getblk(sizeof(*sym));
+		sym = block_zero_alloc(sizeof(*sym));
 		sym->s_name = sb->sb_name;
 		sym->s_block_level = block_level;
 		di = dcs;
@@ -1391,8 +1391,8 @@ sym_t *
 mktempsym(type_t *t)
 {
 	static int n = 0;
-	char *s = getlblk(block_level, 64);
-	sym_t *sym = getblk(sizeof(*sym));
+	char *s = level_zero_alloc(block_level, 64);
+	sym_t *sym = block_zero_alloc(sizeof(*sym));
 	scl_t scl;
 
 	(void)snprintf(s, 64, "%.8d_tmp", n++);
@@ -1476,7 +1476,7 @@ void
 cleanup(void)
 {
 	sym_t	*sym, *nsym;
-	int	i;
+	size_t	i;
 
 	for (i = 0; i < HSHSIZ1; i++) {
 		for (sym = symtab[i]; sym != NULL; sym = nsym) {
@@ -1487,7 +1487,7 @@ cleanup(void)
 	}
 
 	for (i = mem_block_level; i > 0; i--)
-		freelblk(i);
+		level_free_all(i);
 }
 
 /*
@@ -1500,7 +1500,7 @@ pushdown(const sym_t *sym)
 
 	debug_step("pushdown '%s' %s '%s'",
 	    sym->s_name, symt_name(sym->s_kind), type_name(sym->s_type));
-	nsym = getblk(sizeof(*nsym));
+	nsym = block_zero_alloc(sizeof(*nsym));
 	lint_assert(sym->s_block_level <= block_level);
 	nsym->s_name = sym->s_name;
 	UNIQUE_CURR_POS(nsym->s_def_pos);

Index: src/usr.bin/xlint/lint1/mem1.c
diff -u src/usr.bin/xlint/lint1/mem1.c:1.59 src/usr.bin/xlint/lint1/mem1.c:1.60
--- src/usr.bin/xlint/lint1/mem1.c:1.59	Sun Feb 27 07:38:54 2022
+++ src/usr.bin/xlint/lint1/mem1.c	Sun Feb 27 08:31:26 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: mem1.c,v 1.59 2022/02/27 07:38:54 rillig Exp $	*/
+/*	$NetBSD: mem1.c,v 1.60 2022/02/27 08:31:26 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.59 2022/02/27 07:38:54 rillig Exp $");
+__RCSID("$NetBSD: mem1.c,v 1.60 2022/02/27 08:31:26 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -243,7 +243,7 @@ initmem(void)
 
 /* Allocate memory associated with level l, initialized with zero. */
 void *
-getlblk(size_t l, size_t s)
+level_zero_alloc(size_t l, size_t s)
 {
 
 	while (l >= nmblks) {
@@ -254,40 +254,27 @@ getlblk(size_t l, size_t s)
 	return xgetblk(&mblks[l], s);
 }
 
-/*
- * Return allocated memory for the current mem_block_level, initialized with
- * zero.
- */
+/* Allocate memory that is freed at the end of the current block. */
 void *
-getblk(size_t s)
+block_zero_alloc(size_t s)
 {
 
-	return getlblk(mem_block_level, s);
+	return level_zero_alloc(mem_block_level, s);
 }
 
-/* Free all memory associated with level l. */
 void
-freelblk(int l)
+level_free_all(size_t level)
 {
 
-	xfreeblk(&mblks[l]);
+	xfreeblk(&mblks[level]);
 }
 
-void
-freeblk(void)
-{
-
-	freelblk(mem_block_level);
-}
 
 static	memory_block	*tmblk;
 
-/*
- * Return zero-initialized memory that is freed at the end of the current
- * expression.
- */
+/* Allocate memory that is freed at the end of the current expression. */
 void *
-expr_zalloc(size_t s)
+expr_zero_alloc(size_t s)
 {
 
 	return xgetblk(&tmblk, s);
@@ -311,9 +298,9 @@ str_endswith(const char *haystack, const
  * bool mode less restrictive.
  */
 tnode_t *
-expr_zalloc_tnode(void)
+expr_alloc_tnode(void)
 {
-	tnode_t *tn = expr_zalloc(sizeof(*tn));
+	tnode_t *tn = expr_zero_alloc(sizeof(*tn));
 	/*
 	 * files named *.c that are different from the main translation unit
 	 * typically contain generated code that cannot be influenced, such

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.404 src/usr.bin/xlint/lint1/tree.c:1.405
--- src/usr.bin/xlint/lint1/tree.c:1.404	Sat Feb 26 20:36:11 2022
+++ src/usr.bin/xlint/lint1/tree.c	Sun Feb 27 08:31:26 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.404 2022/02/26 20:36:11 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.405 2022/02/27 08:31:26 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.404 2022/02/26 20:36:11 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.405 2022/02/27 08:31:26 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -108,7 +108,7 @@ derive_type(type_t *tp, tspec_t t)
 {
 	type_t	*tp2;
 
-	tp2 = getblk(sizeof(*tp2));
+	tp2 = block_zero_alloc(sizeof(*tp2));
 	tp2->t_tspec = t;
 	tp2->t_subt = tp;
 	return tp2;
@@ -123,7 +123,7 @@ expr_derive_type(type_t *tp, tspec_t t)
 {
 	type_t	*tp2;
 
-	tp2 = expr_zalloc(sizeof(*tp2));
+	tp2 = expr_zero_alloc(sizeof(*tp2));
 	tp2->t_tspec = t;
 	tp2->t_subt = tp;
 	return tp2;
@@ -137,10 +137,10 @@ build_constant(type_t *tp, val_t *v)
 {
 	tnode_t	*n;
 
-	n = expr_zalloc_tnode();
+	n = expr_alloc_tnode();
 	n->tn_op = CON;
 	n->tn_type = tp;
-	n->tn_val = expr_zalloc(sizeof(*n->tn_val));
+	n->tn_val = expr_zero_alloc(sizeof(*n->tn_val));
 	n->tn_val->v_tspec = tp->t_tspec;
 	n->tn_val->v_unsigned_since_c90 = v->v_unsigned_since_c90;
 	n->tn_val->v_u = v->v_u;
@@ -153,10 +153,10 @@ build_integer_constant(tspec_t t, int64_
 {
 	tnode_t	*n;
 
-	n = expr_zalloc_tnode();
+	n = expr_alloc_tnode();
 	n->tn_op = CON;
 	n->tn_type = gettyp(t);
-	n->tn_val = expr_zalloc(sizeof(*n->tn_val));
+	n->tn_val = expr_zero_alloc(sizeof(*n->tn_val));
 	n->tn_val->v_tspec = t;
 	n->tn_val->v_quad = q;
 	return n;
@@ -277,11 +277,11 @@ build_name(sym_t *sym, bool is_funcname)
 
 	lint_assert(sym->s_kind == FVFT || sym->s_kind == FMEMBER);
 
-	n = expr_zalloc_tnode();
+	n = expr_alloc_tnode();
 	n->tn_type = sym->s_type;
 	if (sym->s_scl == CTCONST) {
 		n->tn_op = CON;
-		n->tn_val = expr_zalloc(sizeof(*n->tn_val));
+		n->tn_val = expr_zero_alloc(sizeof(*n->tn_val));
 		*n->tn_val = sym->s_value;
 	} else {
 		n->tn_op = NAME;
@@ -302,9 +302,9 @@ build_string(strg_t *strg)
 
 	len = strg->st_len;
 
-	n = expr_zalloc_tnode();
+	n = expr_alloc_tnode();
 
-	tp = expr_zalloc(sizeof(*tp));
+	tp = expr_zero_alloc(sizeof(*tp));
 	tp->t_tspec = ARRAY;
 	tp->t_subt = gettyp(strg->st_tspec);
 	tp->t_dim = (int)(len + 1);
@@ -313,17 +313,17 @@ build_string(strg_t *strg)
 	n->tn_type = tp;
 	n->tn_lvalue = true;
 
-	n->tn_string = expr_zalloc(sizeof(*n->tn_string));
+	n->tn_string = expr_zero_alloc(sizeof(*n->tn_string));
 	n->tn_string->st_tspec = strg->st_tspec;
 	n->tn_string->st_len = len;
 
 	if (strg->st_tspec == CHAR) {
-		n->tn_string->st_cp = expr_zalloc(len + 1);
+		n->tn_string->st_cp = expr_zero_alloc(len + 1);
 		(void)memcpy(n->tn_string->st_cp, strg->st_cp, len + 1);
 		free(strg->st_cp);
 	} else {
 		size_t size = (len + 1) * sizeof(*n->tn_string->st_wcp);
-		n->tn_string->st_wcp = expr_zalloc(size);
+		n->tn_string->st_wcp = expr_zero_alloc(size);
 		(void)memcpy(n->tn_string->st_wcp, strg->st_wcp, size);
 		free(strg->st_wcp);
 	}
@@ -355,8 +355,8 @@ struct_or_union_member(tnode_t *tn, op_t
 		rmsym(msym);
 		msym->s_kind = FMEMBER;
 		msym->s_scl = MOS;
-		msym->s_styp = expr_zalloc(sizeof(*msym->s_styp));
-		msym->s_styp->sou_tag = expr_zalloc(
+		msym->s_styp = expr_zero_alloc(sizeof(*msym->s_styp));
+		msym->s_styp->sou_tag = expr_zero_alloc(
 		    sizeof(*msym->s_styp->sou_tag));
 		msym->s_styp->sou_tag->s_name = unnamed;
 		msym->s_value.v_tspec = INT;
@@ -1834,7 +1834,7 @@ new_tnode(op_t op, bool sys, type_t *typ
 	uint64_t rnum;
 #endif
 
-	ntn = expr_zalloc_tnode();
+	ntn = expr_alloc_tnode();
 
 	ntn->tn_op = op;
 	ntn->tn_type = type;
@@ -2080,7 +2080,7 @@ convert(op_t op, int arg, type_t *tp, tn
 		check_pointer_conversion(tn, tp);
 	}
 
-	ntn = expr_zalloc_tnode();
+	ntn = expr_alloc_tnode();
 	ntn->tn_op = CVT;
 	ntn->tn_type = tp;
 	ntn->tn_cast = op == CVT;
@@ -2090,7 +2090,7 @@ convert(op_t op, int arg, type_t *tp, tn
 		ntn->tn_left = tn;
 	} else {
 		ntn->tn_op = CON;
-		ntn->tn_val = expr_zalloc(sizeof(*ntn->tn_val));
+		ntn->tn_val = expr_zero_alloc(sizeof(*ntn->tn_val));
 		convert_constant(op, arg, ntn->tn_type, ntn->tn_val,
 		    tn->tn_val);
 	}
@@ -3609,7 +3609,7 @@ cast(tnode_t *tn, type_t *tp)
 		for (m = str->sou_first_member; m != NULL; m = m->s_next) {
 			if (eqtype(m->s_type, tn->tn_type,
 			    false, false, NULL)) {
-				tn = expr_zalloc_tnode();
+				tn = expr_alloc_tnode();
 				tn->tn_op = CVT;
 				tn->tn_type = tp;
 				tn->tn_cast = true;

Reply via email to