Module Name:    src
Committed By:   rillig
Date:           Fri Mar 26 20:31:07 UTC 2021

Modified Files:
        src/usr.bin/xlint/common: tyname.c
        src/usr.bin/xlint/lint1: cgram.y decl.c err.c func.c init.c lex.c
            main1.c mem1.c tree.c
        src/usr.bin/xlint/lint2: chk.c emit2.c hash.c main2.c read.c
        src/usr.bin/xlint/xlint: xlint.c

Log Message:
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/xlint/common/tyname.c
cvs rdiff -u -r1.203 -r1.204 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.160 -r1.161 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.92 -r1.93 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.97 -r1.98 src/usr.bin/xlint/lint1/func.c
cvs rdiff -u -r1.133 -r1.134 src/usr.bin/xlint/lint1/init.c
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/xlint/lint1/lex.c
cvs rdiff -u -r1.38 -r1.39 src/usr.bin/xlint/lint1/main1.c
cvs rdiff -u -r1.27 -r1.28 src/usr.bin/xlint/lint1/mem1.c
cvs rdiff -u -r1.249 -r1.250 src/usr.bin/xlint/lint1/tree.c
cvs rdiff -u -r1.40 -r1.41 src/usr.bin/xlint/lint2/chk.c \
    src/usr.bin/xlint/lint2/read.c
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/xlint/lint2/emit2.c
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/xlint/lint2/hash.c \
    src/usr.bin/xlint/lint2/main2.c
cvs rdiff -u -r1.56 -r1.57 src/usr.bin/xlint/xlint/xlint.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/common/tyname.c
diff -u src/usr.bin/xlint/common/tyname.c:1.34 src/usr.bin/xlint/common/tyname.c:1.35
--- src/usr.bin/xlint/common/tyname.c:1.34	Sun Mar  7 17:12:41 2021
+++ src/usr.bin/xlint/common/tyname.c	Fri Mar 26 20:31:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tyname.c,v 1.34 2021/03/07 17:12:41 rillig Exp $	*/
+/*	$NetBSD: tyname.c,v 1.35 2021/03/26 20:31:07 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tyname.c,v 1.34 2021/03/07 17:12:41 rillig Exp $");
+__RCSID("$NetBSD: tyname.c,v 1.35 2021/03/26 20:31:07 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -74,7 +74,7 @@ new_name_tree_node(const char *name)
 {
 	name_tree_node *n;
 
-	n = xmalloc(sizeof(*n));
+	n = xmalloc(sizeof *n);
 	n->ntn_name = xstrdup(name);
 	n->ntn_less = NULL;
 	n->ntn_greater = NULL;
@@ -137,7 +137,7 @@ buf_add(buffer *buf, const char *s)
 static void
 buf_add_int(buffer *buf, int n)
 {
-	char num[1 + sizeof(n) * CHAR_BIT + 1];
+	char num[1 + sizeof n * CHAR_BIT + 1];
 
 	snprintf(num, sizeof num, "%d", n);
 	buf_add(buf, num);

Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.203 src/usr.bin/xlint/lint1/cgram.y:1.204
--- src/usr.bin/xlint/lint1/cgram.y:1.203	Fri Mar 26 18:54:39 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Fri Mar 26 20:31:07 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.203 2021/03/26 18:54:39 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.204 2021/03/26 20:31:07 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.203 2021/03/26 18:54:39 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.204 2021/03/26 20:31:07 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -1197,7 +1197,7 @@ pointer:
 
 asterisk:
 	  T_ASTERISK {
-		$$ = xcalloc(1, sizeof (pqinf_t));
+		$$ = xcalloc(1, sizeof *$$);
 		$$->p_pcnt = 1;
 	  }
 	;
@@ -1213,7 +1213,7 @@ type_qualifier_list:
 
 type_qualifier:
 	  T_QUAL {
-		$$ = xcalloc(1, sizeof (pqinf_t));
+		$$ = xcalloc(1, sizeof *$$);
 		if ($1 == CONST) {
 			$$->p_const = true;
 		} else if ($1 == VOLATILE) {

Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.160 src/usr.bin/xlint/lint1/decl.c:1.161
--- src/usr.bin/xlint/lint1/decl.c:1.160	Fri Mar 26 17:44:52 2021
+++ src/usr.bin/xlint/lint1/decl.c	Fri Mar 26 20:31:07 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.160 2021/03/26 17:44:52 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.161 2021/03/26 20:31:07 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.160 2021/03/26 17:44:52 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.161 2021/03/26 20:31:07 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -91,7 +91,7 @@ initdecl(void)
 	int i;
 
 	/* declaration stack */
-	dcs = xcalloc(1, sizeof (dinfo_t));
+	dcs = xcalloc(1, sizeof *dcs);
 	dcs->d_ctx = EXTERN;
 	dcs->d_ldlsym = &dcs->d_dlsyms;
 
@@ -99,7 +99,7 @@ initdecl(void)
 	inittyp();
 
 	/* shared type structures */
-	typetab = xcalloc(NTSPEC, sizeof (type_t));
+	typetab = xcalloc(NTSPEC, sizeof *typetab);
 	for (i = 0; i < NTSPEC; i++)
 		typetab[i].t_tspec = NOTSPEC;
 	typetab[BOOL].t_tspec = BOOL;
@@ -162,7 +162,7 @@ tduptyp(const type_t *tp)
 {
 	type_t	*ntp;
 
-	ntp = tgetblk(sizeof (type_t));
+	ntp = tgetblk(sizeof *ntp);
 	*ntp = *tp;
 	return ntp;
 }
@@ -593,7 +593,7 @@ begin_declaration_level(scl_t sc)
 	dinfo_t	*di;
 
 	/* put a new element on the declaration stack */
-	di = xcalloc(1, sizeof (dinfo_t));
+	di = xcalloc(1, sizeof *di);
 	di->d_next = dcs;
 	dcs = di;
 	di->d_ctx = sc;
@@ -1262,7 +1262,7 @@ bitfield(sym_t *dsym, int len)
 {
 
 	if (dsym == NULL) {
-		dsym = getblk(sizeof (sym_t));
+		dsym = getblk(sizeof *dsym);
 		dsym->s_name = unnamed;
 		dsym->s_kind = FMEMBER;
 		dsym->s_scl = MOS;
@@ -1334,7 +1334,7 @@ add_pointer(sym_t *decl, pqinf_t *pi)
 		return decl;
 
 	while (pi != NULL) {
-		*tpp = tp = getblk(sizeof (type_t));
+		*tpp = tp = getblk(sizeof *tp);
 		tp->t_tspec = PTR;
 		tp->t_const = pi->p_const;
 		tp->t_volatile = pi->p_volatile;
@@ -1361,7 +1361,7 @@ add_array(sym_t *decl, bool dim, int n)
 	if (*tpp == NULL)
 	    return decl;
 
-	*tpp = tp = getblk(sizeof (type_t));
+	*tpp = tp = getblk(sizeof *tp);
 	tp->t_tspec = ARRAY;
 	tp->t_subt = dcs->d_type;
 	tp->t_dim = n;
@@ -1416,7 +1416,7 @@ add_function(sym_t *decl, sym_t *args)
 	if (*tpp == NULL)
 	    return decl;
 
-	*tpp = tp = getblk(sizeof (type_t));
+	*tpp = tp = getblk(sizeof *tp);
 	tp->t_tspec = FUNC;
 	tp->t_subt = dcs->d_next->d_type;
 	if ((tp->t_proto = dcs->d_proto) != false)
@@ -1670,19 +1670,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 (type_t));
+			tag->s_type = tp = getblk(sizeof *tp);
 			tp->t_packed = dcs->d_packed;
 		} else {
 			tp = tag->s_type;
 		}
 	} else {
-		tag = getblk(sizeof (sym_t));
+		tag = getblk(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 (type_t));
+		tag->s_type = tp = getblk(sizeof *tp);
 		tp->t_packed = dcs->d_packed;
 		dcs->d_next->d_nonempty_decl = true;
 	}
@@ -1690,12 +1690,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 (struct_or_union));
+			tp->t_str = getblk(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 = getblk(sizeof *tp->t_enum);
 			tp->t_enum->en_tag = tag;
 		}
 		setcomplete(tp, false);
@@ -2872,7 +2872,7 @@ abstract_name(void)
 
 	lint_assert(dcs->d_ctx == ABSTRACT || dcs->d_ctx == PROTO_ARG);
 
-	sym = getblk(sizeof (sym_t));
+	sym = getblk(sizeof *sym);
 
 	sym->s_name = unnamed;
 	sym->s_def = DEF;

Index: src/usr.bin/xlint/lint1/err.c
diff -u src/usr.bin/xlint/lint1/err.c:1.92 src/usr.bin/xlint/lint1/err.c:1.93
--- src/usr.bin/xlint/lint1/err.c:1.92	Mon Mar 22 15:29:43 2021
+++ src/usr.bin/xlint/lint1/err.c	Fri Mar 26 20:31:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: err.c,v 1.92 2021/03/22 15:29:43 rillig Exp $	*/
+/*	$NetBSD: err.c,v 1.93 2021/03/26 20:31:07 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: err.c,v 1.92 2021/03/22 15:29:43 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.93 2021/03/26 20:31:07 rillig Exp $");
 #endif
 
 #include <sys/types.h>
@@ -405,7 +405,7 @@ msglist(void)
 {
 	size_t i;
 
-	for (i = 0; i < sizeof(msgs) / sizeof(msgs[0]); i++)
+	for (i = 0; i < sizeof msgs / sizeof msgs[0]; i++)
 		printf("%zu\t%s\n", i, msgs[i]);
 }
 

Index: src/usr.bin/xlint/lint1/func.c
diff -u src/usr.bin/xlint/lint1/func.c:1.97 src/usr.bin/xlint/lint1/func.c:1.98
--- src/usr.bin/xlint/lint1/func.c:1.97	Fri Mar 26 19:17:58 2021
+++ src/usr.bin/xlint/lint1/func.c	Fri Mar 26 20:31:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: func.c,v 1.97 2021/03/26 19:17:58 rillig Exp $	*/
+/*	$NetBSD: func.c,v 1.98 2021/03/26 20:31:07 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.97 2021/03/26 19:17:58 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.98 2021/03/26 20:31:07 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -157,7 +157,7 @@ begin_control_statement(control_statemen
 {
 	cstk_t	*ci;
 
-	ci = xcalloc(1, sizeof (cstk_t));
+	ci = xcalloc(1, sizeof *ci);
 	ci->c_kind = kind;
 	ci->c_surrounding = cstmt;
 	cstmt = ci;
@@ -683,7 +683,7 @@ switch1(tnode_t *tn)
 	 * duplicated. This is not too complicated because it is
 	 * only an integer type.
 	 */
-	tp = xcalloc(1, sizeof (type_t));
+	tp = xcalloc(1, sizeof *tp);
 	if (tn != NULL) {
 		tp->t_tspec = tn->tn_type->t_tspec;
 		if ((tp->t_is_enum = tn->tn_type->t_is_enum) != false)
@@ -1049,7 +1049,7 @@ do_return(tnode_t *tn)
 	if (tn != NULL) {
 
 		/* Create a temporary node for the left side */
-		ln = tgetblk(sizeof (tnode_t));
+		ln = tgetblk(sizeof *ln);
 		ln->tn_op = NAME;
 		ln->tn_type = tduptyp(funcsym->s_type->t_subt);
 		ln->tn_type->t_const = false;

Index: src/usr.bin/xlint/lint1/init.c
diff -u src/usr.bin/xlint/lint1/init.c:1.133 src/usr.bin/xlint/lint1/init.c:1.134
--- src/usr.bin/xlint/lint1/init.c:1.133	Thu Mar 25 22:53:05 2021
+++ src/usr.bin/xlint/lint1/init.c	Fri Mar 26 20:31:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: init.c,v 1.133 2021/03/25 22:53:05 rillig Exp $	*/
+/*	$NetBSD: init.c,v 1.134 2021/03/26 20:31:07 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: init.c,v 1.133 2021/03/25 22:53:05 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.134 2021/03/26 20:31:07 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -585,7 +585,7 @@ initstack_init(void)
 		initsym->s_type = duptyp(initsym->s_type);
 	/* TODO: does 'duptyp' create a memory leak? */
 
-	istk = initstk_lvalue = xcalloc(1, sizeof (initstack_element));
+	istk = initstk_lvalue = xcalloc(1, sizeof *initstk_lvalue);
 	istk->i_subt = initsym->s_type;
 	istk->i_remaining = 1;
 
@@ -890,7 +890,7 @@ initstack_push(void)
 	lint_assert(istk->i_remaining > 0);
 	lint_assert(istk->i_type == NULL || !is_scalar(istk->i_type->t_tspec));
 
-	initstk_lvalue = xcalloc(1, sizeof (initstack_element));
+	initstk_lvalue = xcalloc(1, sizeof *initstk_lvalue);
 	initstk_lvalue->i_enclosing = istk;
 	initstk_lvalue->i_type = istk->i_subt;
 	lint_assert(initstk_lvalue->i_type->t_tspec != FUNC);
@@ -1149,7 +1149,7 @@ check_init_expr(tnode_t *tn, scl_t sclas
 	struct mbl *tmem;
 
 	/* Create a temporary node for the left side. */
-	ln = tgetblk(sizeof (tnode_t));
+	ln = tgetblk(sizeof *ln);
 	ln->tn_op = NAME;
 	ln->tn_type = tduptyp(initstk->i_type);
 	ln->tn_type->t_const = false;

Index: src/usr.bin/xlint/lint1/lex.c
diff -u src/usr.bin/xlint/lint1/lex.c:1.16 src/usr.bin/xlint/lint1/lex.c:1.17
--- src/usr.bin/xlint/lint1/lex.c:1.16	Tue Mar 23 20:57:40 2021
+++ src/usr.bin/xlint/lint1/lex.c	Fri Mar 26 20:31:07 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.16 2021/03/23 20:57:40 christos Exp $ */
+/* $NetBSD: lex.c,v 1.17 2021/03/26 20:31:07 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.16 2021/03/23 20:57:40 christos Exp $");
+__RCSID("$NetBSD: lex.c,v 1.17 2021/03/26 20:31:07 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -273,12 +273,12 @@ add_keyword(struct kwtab *kw, int deco)
 		name = kw->kw_name;
 		break;
 	case 2:
-		snprintf(buf, sizeof(buf), "__%s", kw->kw_name);
+		snprintf(buf, sizeof buf, "__%s", kw->kw_name);
 		name = strdup(buf);
 		break;
 	default:
 		lint_assert(deco == 4);
-		snprintf(buf, sizeof(buf), "__%s__", kw->kw_name);
+		snprintf(buf, sizeof buf, "__%s__", kw->kw_name);
 		name = strdup(buf);
 		break;
 	}
@@ -286,7 +286,7 @@ add_keyword(struct kwtab *kw, int deco)
 	if (name == NULL)
 		err(1, "Can't init symbol table");
 
-	sym = getblk(sizeof (sym_t));
+	sym = getblk(sizeof *sym);
 	sym->s_name = name;
 	sym->s_keyword = kw;
 	sym->s_value.v_quad = kw->kw_token;
@@ -349,13 +349,13 @@ allocsb(void)
 	if ((sb = sbfrlst) != NULL) {
 		sbfrlst = sb->sb_next;
 #ifdef BLKDEBUG
-		(void)memset(sb, 0, sizeof (*sb));
+		(void)memset(sb, 0, sizeof *sb);
 #else
 		sb->sb_next = NULL;
 #endif
 	} else {
-		sb = xmalloc(sizeof (sbuf_t));
-		(void)memset(sb, 0, sizeof (*sb));
+		sb = xmalloc(sizeof *sb);
+		(void)memset(sb, 0, sizeof *sb);
 	}
 	return sb;
 }
@@ -367,7 +367,7 @@ static void
 freesb(sbuf_t *sb)
 {
 
-	(void)memset(sb, ZERO, sizeof (*sb));
+	(void)memset(sb, ZERO, sizeof *sb);
 	sb->sb_next = sbfrlst;
 	sbfrlst = sb;
 }
@@ -394,8 +394,8 @@ hash(const char *s)
 
 	v = 0;
 	for (us = (const u_char *)s; *us != '\0'; us++) {
-		v = (v << sizeof (v)) + *us;
-		v ^= v >> (sizeof (v) * CHAR_BIT - sizeof (v));
+		v = (v << sizeof v) + *us;
+		v ^= v >> (sizeof v * CHAR_BIT - sizeof v);
 	}
 	return v % HSHSIZ1;
 }
@@ -677,7 +677,8 @@ lex_integer_constant(const char *yytext,
 
 	uq = (uint64_t)xsign((int64_t)uq, typ, -1);
 
-	(yylval.y_val = xcalloc(1, sizeof (val_t)))->v_tspec = typ;
+	yylval.y_val = xcalloc(1, sizeof *yylval.y_val);
+	yylval.y_val->v_tspec = typ;
 	yylval.y_val->v_ansiu = ansiu;
 	yylval.y_val->v_quad = (int64_t)uq;
 
@@ -800,7 +801,8 @@ lex_floating_constant(const char *yytext
 		}
 	}
 
-	(yylval.y_val = xcalloc(1, sizeof (val_t)))->v_tspec = typ;
+	yylval.y_val = xcalloc(1, sizeof *yylval.y_val);
+	yylval.y_val->v_tspec = typ;
 	if (typ == FLOAT) {
 		yylval.y_val->v_ldbl = f;
 	} else {
@@ -838,6 +840,7 @@ lex_character_constant(void)
 		/* unterminated character constant */
 		error(253);
 	} else {
+		/* XXX: should rather be sizeof(TARG_INT) */
 		if (n > sizeof (int) || (n > 1 && (pflag || hflag))) {
 			/* too many characters in character constant */
 			error(71);
@@ -854,7 +857,7 @@ lex_character_constant(void)
 		val = cv;
 	}
 
-	yylval.y_val = xcalloc(1, sizeof (val_t));
+	yylval.y_val = xcalloc(1, sizeof *yylval.y_val);
 	yylval.y_val->v_tspec = INT;
 	yylval.y_val->v_quad = val;
 
@@ -903,7 +906,7 @@ lex_wide_character_constant(void)
 		}
 	}
 
-	yylval.y_val = xcalloc(1, sizeof (val_t));
+	yylval.y_val = xcalloc(1, sizeof *yylval.y_val);
 	yylval.y_val->v_tspec = WCHAR;
 	yylval.y_val->v_quad = wc;
 
@@ -1191,18 +1194,18 @@ lex_comment(void)
 
 	/* Read the potential keyword to keywd */
 	l = 0;
-	while (c != EOF && isupper(c) && l < sizeof (keywd) - 1) {
+	while (c != EOF && isupper(c) && l < sizeof keywd - 1) {
 		keywd[l++] = (char)c;
 		c = inpc();
 	}
 	keywd[l] = '\0';
 
 	/* look for the keyword */
-	for (i = 0; i < sizeof (keywtab) / sizeof (keywtab[0]); i++) {
+	for (i = 0; i < sizeof keywtab / sizeof keywtab[0]; i++) {
 		if (strcmp(keywtab[i].keywd, keywd) == 0)
 			break;
 	}
-	if (i == sizeof (keywtab) / sizeof (keywtab[0]))
+	if (i == sizeof keywtab / sizeof keywtab[0])
 		goto skip_rest;
 
 	/* skip whitespace after the keyword */
@@ -1212,7 +1215,7 @@ lex_comment(void)
 	/* read the argument, if the keyword accepts one and there is one */
 	l = 0;
 	if (keywtab[i].arg) {
-		while (c != EOF && isdigit(c) && l < sizeof (arg) - 1) {
+		while (c != EOF && isdigit(c) && l < sizeof arg - 1) {
 			arg[l++] = (char)c;
 			c = inpc();
 		}
@@ -1311,7 +1314,7 @@ lex_string(void)
 		/* unterminated string constant */
 		error(258);
 
-	strg = xcalloc(1, sizeof (strg_t));
+	strg = xcalloc(1, sizeof *strg);
 	strg->st_tspec = CHAR;
 	strg->st_len = len;
 	strg->st_cp = s;
@@ -1355,7 +1358,7 @@ lex_wide_string(void)
 			n = 1;
 	}
 
-	ws = xmalloc((wlen + 1) * sizeof (wchar_t));
+	ws = xmalloc((wlen + 1) * sizeof *ws);
 
 	/* convert from multibyte to wide char */
 	(void)mbtowc(NULL, NULL, 0);
@@ -1368,7 +1371,7 @@ lex_wide_string(void)
 	ws[wi] = 0;
 	free(s);
 
-	strg = xcalloc(1, sizeof (strg_t));
+	strg = xcalloc(1, sizeof *strg);
 	strg->st_tspec = WCHAR;
 	strg->st_len = wlen;
 	strg->st_wcp = ws;
@@ -1423,7 +1426,7 @@ getsym(sbuf_t *sb)
 
 	/* labels must always be allocated at level 1 (outermost block) */
 	if (symtyp == FLABEL) {
-		sym = getlblk(1, sizeof (sym_t));
+		sym = getlblk(1, sizeof *sym);
 		s = getlblk(1, sb->sb_len + 1);
 		(void)memcpy(s, sb->sb_name, sb->sb_len + 1);
 		sym->s_name = s;
@@ -1433,7 +1436,7 @@ getsym(sbuf_t *sb)
 			di = di->d_next;
 		lint_assert(di->d_ctx == AUTO);
 	} else {
-		sym = getblk(sizeof (sym_t));
+		sym = getblk(sizeof *sym);
 		sym->s_name = sb->sb_name;
 		sym->s_block_level = block_level;
 		di = dcs;
@@ -1467,7 +1470,7 @@ mktempsym(type_t *t)
 	static int n = 0;
 	int h;
 	char *s = getlblk(block_level, 64);
-	sym_t *sym = getblk(sizeof (sym_t));
+	sym_t *sym = getblk(sizeof *sym);
 
 	(void)snprintf(s, 64, "%.8d_tmp", n++);
 	h = hash(s);
@@ -1580,7 +1583,7 @@ pushdown(sym_t *sym)
 	sym_t	*nsym;
 
 	h = hash(sym->s_name);
-	nsym = getblk(sizeof (sym_t));
+	nsym = getblk(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/main1.c
diff -u src/usr.bin/xlint/lint1/main1.c:1.38 src/usr.bin/xlint/lint1/main1.c:1.39
--- src/usr.bin/xlint/lint1/main1.c:1.38	Sat Mar 20 20:39:35 2021
+++ src/usr.bin/xlint/lint1/main1.c	Fri Mar 26 20:31:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: main1.c,v 1.38 2021/03/20 20:39:35 rillig Exp $	*/
+/*	$NetBSD: main1.c,v 1.39 2021/03/26 20:31:07 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: main1.c,v 1.38 2021/03/20 20:39:35 rillig Exp $");
+__RCSID("$NetBSD: main1.c,v 1.39 2021/03/26 20:31:07 rillig Exp $");
 #endif
 
 #include <sys/types.h>
@@ -135,7 +135,7 @@ static const char builtins[] =
     "int __builtin_isnan(long double);\n"
     "int __builtin_copysign(long double, long double);\n"
 ;
-static size_t builtinlen = sizeof(builtins) - 1;
+static const size_t builtinlen = sizeof builtins - 1;
 
 static FILE *
 bltin(void)

Index: src/usr.bin/xlint/lint1/mem1.c
diff -u src/usr.bin/xlint/lint1/mem1.c:1.27 src/usr.bin/xlint/lint1/mem1.c:1.28
--- src/usr.bin/xlint/lint1/mem1.c:1.27	Wed Mar 17 01:15:31 2021
+++ src/usr.bin/xlint/lint1/mem1.c	Fri Mar 26 20:31:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mem1.c,v 1.27 2021/03/17 01:15:31 rillig Exp $	*/
+/*	$NetBSD: mem1.c,v 1.28 2021/03/26 20:31:07 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.27 2021/03/17 01:15:31 rillig Exp $");
+__RCSID("$NetBSD: mem1.c,v 1.28 2021/03/26 20:31:07 rillig Exp $");
 #endif
 
 #include <sys/types.h>
@@ -95,7 +95,7 @@ struct repl *replist;
 void
 fnaddreplsrcdir(char *arg)
 {
-	struct repl *r = xmalloc(sizeof(*r));
+	struct repl *r = xmalloc(sizeof *r);
 
 	r->orig = arg;
 	if ((r->repl = strchr(arg, '=')) == NULL)
@@ -120,7 +120,7 @@ fnxform(const char *name, size_t len)
 			break;
 	if (r == NULL)
 		return name;
-	snprintf(buf, sizeof(buf), "%s%s", r->repl, name + r->len);
+	snprintf(buf, sizeof buf, "%s%s", r->repl, name + r->len);
 	return buf;
 }
 
@@ -135,7 +135,7 @@ fnnalloc(const char *s, size_t len)
 		return NULL;
 
 	if ((fn = srchfn(s, len)) == NULL) {
-		fn = xmalloc(sizeof (fn_t));
+		fn = xmalloc(sizeof *fn);
 		/* Do not use strdup() because s is not NUL-terminated.*/
 		fn->fn_name = xmalloc(len + 1);
 		(void)memcpy(fn->fn_name, s, len);
@@ -203,7 +203,7 @@ static	mbl_t	*xnewblk(void);
 static mbl_t *
 xnewblk(void)
 {
-	mbl_t	*mb = xmalloc(sizeof (mbl_t));
+	mbl_t	*mb = xmalloc(sizeof *mb);
 
 	/* use mmap instead of malloc to avoid malloc's size overhead */
 	mb->blk = xmapalloc(mblklen);
@@ -285,7 +285,7 @@ initmem(void)
 	pgsz = getpagesize();
 	mblklen = ((MBLKSIZ + pgsz - 1) / pgsz) * pgsz;
 
-	mblks = xcalloc(nmblks = ML_INC, sizeof (mbl_t *));
+	mblks = xcalloc(nmblks = ML_INC, sizeof *mblks);
 }
 
 
@@ -295,8 +295,8 @@ getlblk(size_t l, size_t s)
 {
 
 	while (l >= nmblks) {
-		mblks = xrealloc(mblks, (nmblks + ML_INC) * sizeof (mbl_t *));
-		(void)memset(&mblks[nmblks], 0, ML_INC * sizeof (mbl_t *));
+		mblks = xrealloc(mblks, (nmblks + ML_INC) * sizeof *mblks);
+		(void)memset(&mblks[nmblks], 0, ML_INC * sizeof *mblks);
 		nmblks += ML_INC;
 	}
 	return xgetblk(&mblks[l], s);

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.249 src/usr.bin/xlint/lint1/tree.c:1.250
--- src/usr.bin/xlint/lint1/tree.c:1.249	Fri Mar 26 16:59:18 2021
+++ src/usr.bin/xlint/lint1/tree.c	Fri Mar 26 20:31:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.249 2021/03/26 16:59:18 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.250 2021/03/26 20:31:07 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.249 2021/03/26 16:59:18 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.250 2021/03/26 20:31:07 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -153,7 +153,7 @@ incref(type_t *tp, tspec_t t)
 {
 	type_t	*tp2;
 
-	tp2 = getblk(sizeof (type_t));
+	tp2 = getblk(sizeof *tp2);
 	tp2->t_tspec = t;
 	tp2->t_subt = tp;
 	return tp2;
@@ -167,7 +167,7 @@ tincref(type_t *tp, tspec_t t)
 {
 	type_t	*tp2;
 
-	tp2 = tgetblk(sizeof (type_t));
+	tp2 = tgetblk(sizeof *tp2);
 	tp2->t_tspec = t;
 	tp2->t_subt = tp;
 	return tp2;
@@ -184,7 +184,7 @@ new_constant_node(type_t *tp, val_t *v)
 	n = getnode();
 	n->tn_op = CON;
 	n->tn_type = tp;
-	n->tn_val = tgetblk(sizeof (val_t));
+	n->tn_val = tgetblk(sizeof *n->tn_val);
 	n->tn_val->v_tspec = tp->t_tspec;
 	n->tn_val->v_ansiu = v->v_ansiu;
 	n->tn_val->v_u = v->v_u;
@@ -200,7 +200,7 @@ new_integer_constant_node(tspec_t t, int
 	n = getnode();
 	n->tn_op = CON;
 	n->tn_type = gettyp(t);
-	n->tn_val = tgetblk(sizeof (val_t));
+	n->tn_val = tgetblk(sizeof *n->tn_val);
 	n->tn_val->v_tspec = t;
 	n->tn_val->v_quad = q;
 	return n;
@@ -288,7 +288,7 @@ new_name_node(sym_t *sym, int follow_tok
 			n->tn_lvalue = true;
 	} else {
 		n->tn_op = CON;
-		n->tn_val = tgetblk(sizeof (val_t));
+		n->tn_val = tgetblk(sizeof *n->tn_val);
 		*n->tn_val = sym->s_value;
 	}
 
@@ -310,7 +310,7 @@ new_string_node(strg_t *strg)
 	n->tn_type->t_dim = len + 1;
 	n->tn_lvalue = true;
 
-	n->tn_string = tgetblk(sizeof (strg_t));
+	n->tn_string = tgetblk(sizeof *n->tn_string);
 	n->tn_string->st_tspec = strg->st_tspec;
 	n->tn_string->st_len = len;
 
@@ -319,9 +319,9 @@ new_string_node(strg_t *strg)
 		(void)memcpy(n->tn_string->st_cp, strg->st_cp, len + 1);
 		free(strg->st_cp);
 	} else {
-		n->tn_string->st_wcp = tgetblk((len + 1) * sizeof (wchar_t));
-		(void)memcpy(n->tn_string->st_wcp, strg->st_wcp,
-			     (len + 1) * sizeof (wchar_t));
+		size_t size = (len + 1) * sizeof *n->tn_string->st_wcp;
+		n->tn_string->st_wcp = tgetblk(size);
+		(void)memcpy(n->tn_string->st_wcp, strg->st_wcp, size);
 		free(strg->st_wcp);
 	}
 	free(strg);
@@ -352,8 +352,8 @@ struct_or_union_member(tnode_t *tn, op_t
 		rmsym(msym);
 		msym->s_kind = FMEMBER;
 		msym->s_scl = MOS;
-		msym->s_styp = tgetblk(sizeof (struct_or_union));
-		msym->s_styp->sou_tag = tgetblk(sizeof (sym_t));
+		msym->s_styp = tgetblk(sizeof *msym->s_styp);
+		msym->s_styp->sou_tag = tgetblk(sizeof *msym->s_styp->sou_tag);
 		msym->s_styp->sou_tag->s_name = unnamed;
 		msym->s_value.v_tspec = INT;
 		return msym;
@@ -2066,7 +2066,7 @@ convert(op_t op, int arg, type_t *tp, tn
 		ntn->tn_left = tn;
 	} else {
 		ntn->tn_op = CON;
-		ntn->tn_val = tgetblk(sizeof (val_t));
+		ntn->tn_val = tgetblk(sizeof *ntn->tn_val);
 		convert_constant(op, arg, ntn->tn_type, ntn->tn_val,
 		    tn->tn_val);
 	}
@@ -2174,7 +2174,7 @@ check_integer_conversion(op_t op, int ar
 		case SHL:
 			/* suggest cast from '%s' to '%s' on op %s to ... */
 			warning(324, type_name(gettyp(ot)), type_name(tp),
-			    print_tnode(opbuf, sizeof(opbuf), tn));
+			    print_tnode(opbuf, sizeof opbuf, tn));
 			break;
 		default:
 			break;
@@ -3065,7 +3065,7 @@ fold(tnode_t *tn)
 	uint64_t ul, ur = 0;
 	tnode_t	*cn;
 
-	v = xcalloc(1, sizeof (val_t));
+	v = xcalloc(1, sizeof *v);
 	v->v_tspec = t = tn->tn_type->t_tspec;
 
 	utyp = t == PTR || is_uinteger(t);
@@ -3210,7 +3210,7 @@ fold_test(tnode_t *tn)
 	bool	l, r;
 	val_t	*v;
 
-	v = xcalloc(1, sizeof (val_t));
+	v = xcalloc(1, sizeof *v);
 	v->v_tspec = tn->tn_type->t_tspec;
 	lint_assert(v->v_tspec == INT || (Tflag && v->v_tspec == BOOL));
 
@@ -3248,7 +3248,7 @@ fold_float(tnode_t *tn)
 	ldbl_t	l, r = 0;
 
 	fpe = 0;
-	v = xcalloc(1, sizeof (val_t));
+	v = xcalloc(1, sizeof *v);
 	v->v_tspec = t = tn->tn_type->t_tspec;
 
 	lint_assert(is_floating(t));
@@ -3705,7 +3705,7 @@ check_prototype_argument(
 	tnode_t	*ln;
 	bool	dowarn;
 
-	ln = xcalloc(1, sizeof (tnode_t));
+	ln = xcalloc(1, sizeof *ln);
 	ln->tn_type = tduptyp(tp);
 	ln->tn_type->t_const = false;
 	ln->tn_lvalue = true;
@@ -3733,7 +3733,7 @@ constant(tnode_t *tn, bool required)
 	if (tn != NULL)
 		tn = promote(NOOP, false, tn);
 
-	v = xcalloc(1, sizeof (val_t));
+	v = xcalloc(1, sizeof *v);
 
 	if (tn == NULL) {
 		lint_assert(nerr != 0);

Index: src/usr.bin/xlint/lint2/chk.c
diff -u src/usr.bin/xlint/lint2/chk.c:1.40 src/usr.bin/xlint/lint2/chk.c:1.41
--- src/usr.bin/xlint/lint2/chk.c:1.40	Sun Feb 28 17:16:50 2021
+++ src/usr.bin/xlint/lint2/chk.c	Fri Mar 26 20:31:07 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: chk.c,v 1.40 2021/02/28 17:16:50 rillig Exp $ */
+/* $NetBSD: chk.c,v 1.41 2021/03/26 20:31:07 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: chk.c,v 1.40 2021/02/28 17:16:50 rillig Exp $");
+__RCSID("$NetBSD: chk.c,v 1.41 2021/03/26 20:31:07 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -1088,7 +1088,7 @@ chkrvu(hte_t *hte, sym_t *def)
 		if (hflag == 0)
 			return;
 		if (hflag == 1 && bsearch(hte->h_name, ignorelist,
-		    __arraycount(ignorelist), sizeof(ignorelist[0]),
+		    __arraycount(ignorelist), sizeof ignorelist[0],
 		    (int (*)(const void *, const void *))strcmp) != NULL)
 			return;
 
Index: src/usr.bin/xlint/lint2/read.c
diff -u src/usr.bin/xlint/lint2/read.c:1.40 src/usr.bin/xlint/lint2/read.c:1.41
--- src/usr.bin/xlint/lint2/read.c:1.40	Sun Feb 28 17:16:50 2021
+++ src/usr.bin/xlint/lint2/read.c	Fri Mar 26 20:31:07 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: read.c,v 1.40 2021/02/28 17:16:50 rillig Exp $ */
+/* $NetBSD: read.c,v 1.41 2021/03/26 20:31:07 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: read.c,v 1.40 2021/02/28 17:16:50 rillig Exp $");
+__RCSID("$NetBSD: read.c,v 1.41 2021/03/26 20:31:07 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -119,15 +119,15 @@ readfile(const char *name)
 	pos_t	pos;
 
 	if (inpfns == NULL)
-		inpfns = xcalloc(ninpfns = 128, sizeof (short));
+		inpfns = xcalloc(ninpfns = 128, sizeof *inpfns);
 	if (fnames == NULL)
-		fnames = xcalloc(nfnames = 256, sizeof (char *));
+		fnames = xcalloc(nfnames = 256, sizeof *fnames);
 	if (flines == NULL)
-		flines = xcalloc(nfnames, sizeof (size_t));
+		flines = xcalloc(nfnames, sizeof *flines);
 	if (tlstlen == 0)
-		tlst = xcalloc(tlstlen = 256, sizeof (type_t *));
+		tlst = xcalloc(tlstlen = 256, sizeof *tlst);
 	if (thtab == NULL)
-		thtab = xcalloc(THSHSIZ2, sizeof (thtab_t));
+		thtab = xcalloc(THSHSIZ2, sizeof *thtab);
 
 	_inithash(&renametab);
 
@@ -224,7 +224,7 @@ inperror(const char *file, size_t line, 
 	char buf[1024];
 
 	va_start(ap, fmt);
-	(void)vsnprintf(buf, sizeof(buf), fmt, ap);
+	(void)vsnprintf(buf, sizeof buf, fmt, ap);
 	va_end(ap);
 
 	errx(1, "%s,%zu: input file error: %s,%zu (%s)", file, line,
@@ -256,8 +256,8 @@ setfnid(int fid, const char *cp)
 		inperr("bad fid");
 
 	if ((size_t)fid >= ninpfns) {
-		inpfns = xrealloc(inpfns, (ninpfns * 2) * sizeof (short));
-		(void)memset(inpfns + ninpfns, 0, ninpfns * sizeof (short));
+		inpfns = xrealloc(inpfns, (ninpfns * 2) * sizeof *inpfns);
+		(void)memset(inpfns + ninpfns, 0, ninpfns * sizeof *inpfns);
 		ninpfns *= 2;
 	}
 	/*
@@ -282,7 +282,7 @@ funccall(pos_t *posp, const char *cp)
 	fcall_t	*fcall;
 	const char *name;
 
-	fcall = xalloc(sizeof (fcall_t));
+	fcall = xalloc(sizeof *fcall);
 	fcall->f_pos = *posp;
 
 	/* read flags */
@@ -310,7 +310,7 @@ funccall(pos_t *posp, const char *cp)
 		case 'p':
 		case 'n':
 		case 's':
-			ai = xalloc(sizeof (arginf_t));
+			ai = xalloc(sizeof *ai);
 			ai->a_num = (int)strtol(cp, &eptr, 10);
 			if (cp == eptr)
 				inperr("bad number: %s", cp);
@@ -365,7 +365,7 @@ decldef(pos_t *posp, const char *cp)
 	hte_t	*hte, *renamehte = NULL;
 	const char *name, *newname;
 
-	(void)memset(&sym, 0, sizeof (sym));
+	(void)memset(&sym, 0, sizeof sym);
 	sym.s_pos = *posp;
 	sym.s_def = NODECL;
 
@@ -501,10 +501,10 @@ decldef(pos_t *posp, const char *cp)
 	if (symp == NULL) {
 		/* allocsym does not reserve space for s_nva */
 		if (sym.s_va || sym.s_prfl || sym.s_scfl) {
-			symp = xalloc(sizeof (sym_t));
+			symp = xalloc(sizeof *symp);
 			*symp = sym;
 		} else {
-			symp = xalloc(sizeof (symp->s_s));
+			symp = xalloc(sizeof symp->s_s);
 			symp->s_s = sym.s_s;
 		}
 		*hte->h_lsym = symp;
@@ -529,7 +529,7 @@ usedsym(pos_t *posp, const char *cp)
 	hte_t	*hte;
 	const char *name;
 
-	usym = xalloc(sizeof (usym_t));
+	usym = xalloc(sizeof *usym);
 	usym->u_pos = *posp;
 
 	/* needed as delimiter between two numbers */
@@ -572,7 +572,7 @@ inptype(const char *cp, const char **epp
 	}
 
 	/* No, we must create a new type. */
-	tp = xalloc(sizeof (type_t));
+	tp = xalloc(sizeof *tp);
 
 	tidx = storetyp(tp, cp, tlen, h);
 
@@ -664,7 +664,7 @@ inptype(const char *cp, const char **epp
 			narg = (int)strtol(cp, &eptr, 10);
 			cp = eptr;
 			tp->t_args = xcalloc((size_t)(narg + 1),
-					     sizeof (type_t *));
+					     sizeof *tp->t_args);
 			for (i = 0; i < narg; i++) {
 				if (i == narg - 1 && *cp == 'E') {
 					tp->t_vararg = true;
@@ -1008,8 +1008,8 @@ storetyp(type_t *tp, const char *cp, siz
 		errx(1, "sorry, too many types");
 
 	if (tidx == tlstlen - 1) {
-		tlst = xrealloc(tlst, (tlstlen * 2) * sizeof (type_t *));
-		(void)memset(tlst + tlstlen, 0, tlstlen * sizeof (type_t *));
+		tlst = xrealloc(tlst, (tlstlen * 2) * sizeof *tlst);
+		(void)memset(tlst + tlstlen, 0, tlstlen * sizeof *tlst);
 		tlstlen *= 2;
 	}
 
@@ -1020,7 +1020,7 @@ storetyp(type_t *tp, const char *cp, siz
 	(void)memcpy(name, cp, len);
 	name[len] = '\0';
 
-	thte = xalloc(sizeof (thtab_t));
+	thte = xalloc(sizeof *thte);
 	thte->th_name = name;
 	thte->th_idx = tidx;
 	thte->th_next = thtab[h];
@@ -1039,8 +1039,8 @@ thash(const char *s, size_t len)
 
 	v = 0;
 	while (len-- != 0) {
-		v = (v << sizeof (v)) + (u_char)*s++;
-		v ^= v >> (sizeof (v) * CHAR_BIT - sizeof (v));
+		v = (v << sizeof v) + (u_char)*s++;
+		v ^= v >> (sizeof v * CHAR_BIT - sizeof v);
 	}
 	return v % THSHSIZ2;
 }
@@ -1174,10 +1174,10 @@ getfnidx(const char *fn)
 
 	if (i == nfnames - 1) {
 		size_t nlen = nfnames * 2;
-		fnames = xrealloc(fnames, nlen * sizeof(char *));
-		(void)memset(fnames + nfnames, 0, nfnames * sizeof(char *));
-		flines = xrealloc(flines, nlen * sizeof(size_t));
-		(void)memset(flines + nfnames, 0, nfnames * sizeof(size_t));
+		fnames = xrealloc(fnames, nlen * sizeof *fnames);
+		(void)memset(fnames + nfnames, 0, nfnames * sizeof *fnames);
+		flines = xrealloc(flines, nlen * sizeof *flines);
+		(void)memset(flines + nfnames, 0, nfnames * sizeof *flines);
 		nfnames = nlen;
 	}
 
@@ -1236,7 +1236,7 @@ mkstatic(hte_t *hte)
 	 */
 	for (nhte = hte; nhte->h_link != NULL; nhte = nhte->h_link)
 		continue;
-	nhte->h_link = xmalloc(sizeof (hte_t));
+	nhte->h_link = xmalloc(sizeof *nhte->h_link);
 	nhte = nhte->h_link;
 	nhte->h_name = hte->h_name;
 	nhte->h_used = true;

Index: src/usr.bin/xlint/lint2/emit2.c
diff -u src/usr.bin/xlint/lint2/emit2.c:1.17 src/usr.bin/xlint/lint2/emit2.c:1.18
--- src/usr.bin/xlint/lint2/emit2.c:1.17	Mon Feb 22 15:09:50 2021
+++ src/usr.bin/xlint/lint2/emit2.c	Fri Mar 26 20:31:07 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: emit2.c,v 1.17 2021/02/22 15:09:50 rillig Exp $ */
+/* $NetBSD: emit2.c,v 1.18 2021/03/26 20:31:07 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -34,7 +34,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: emit2.c,v 1.17 2021/02/22 15:09:50 rillig Exp $");
+__RCSID("$NetBSD: emit2.c,v 1.18 2021/03/26 20:31:07 rillig Exp $");
 #endif
 
 #include "lint2.h"
@@ -277,7 +277,7 @@ addoutfile(short num)
 	}
 
 	if (ofl == NULL) {
-		ofl = *pofl = xmalloc(sizeof (struct outflist));
+		ofl = *pofl = xmalloc(sizeof **pofl);
 		ofl->ofl_num = num;
 		ofl->ofl_next = NULL;
 	}

Index: src/usr.bin/xlint/lint2/hash.c
diff -u src/usr.bin/xlint/lint2/hash.c:1.13 src/usr.bin/xlint/lint2/hash.c:1.14
--- src/usr.bin/xlint/lint2/hash.c:1.13	Sat Jan 16 02:40:02 2021
+++ src/usr.bin/xlint/lint2/hash.c	Fri Mar 26 20:31:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: hash.c,v 1.13 2021/01/16 02:40:02 rillig Exp $	*/
+/*	$NetBSD: hash.c,v 1.14 2021/03/26 20:31:07 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: hash.c,v 1.13 2021/01/16 02:40:02 rillig Exp $");
+__RCSID("$NetBSD: hash.c,v 1.14 2021/03/26 20:31:07 rillig Exp $");
 #endif
 
 /*
@@ -66,7 +66,7 @@ _inithash(hte_t ***tablep)
 	if (tablep == NULL)
 		tablep = &htab;
 
-	*tablep = xcalloc(HSHSIZ2, sizeof (hte_t *));
+	*tablep = xcalloc(HSHSIZ2, sizeof **tablep);
 }
 
 /*
@@ -80,8 +80,8 @@ hash(const char *s)
 
 	v = 0;
 	for (us = (const u_char *)s; *us != '\0'; us++) {
-		v = (v << sizeof (v)) + *us;
-		v ^= v >> (sizeof (v) * CHAR_BIT - sizeof (v));
+		v = (v << sizeof v) + *us;
+		v ^= v >> (sizeof v * CHAR_BIT - sizeof v);
 	}
 	return v % HSHSIZ2;
 }
@@ -109,7 +109,7 @@ _hsearch(hte_t **table, const char *s, b
 		return hte;
 
 	/* create a new hte */
-	hte = xmalloc(sizeof (hte_t));
+	hte = xmalloc(sizeof *hte);
 	hte->h_name = xstrdup(s);
 	hte->h_used = false;
 	hte->h_def = false;
Index: src/usr.bin/xlint/lint2/main2.c
diff -u src/usr.bin/xlint/lint2/main2.c:1.13 src/usr.bin/xlint/lint2/main2.c:1.14
--- src/usr.bin/xlint/lint2/main2.c:1.13	Sat Jan 16 02:40:02 2021
+++ src/usr.bin/xlint/lint2/main2.c	Fri Mar 26 20:31:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: main2.c,v 1.13 2021/01/16 02:40:02 rillig Exp $	*/
+/*	$NetBSD: main2.c,v 1.14 2021/03/26 20:31:07 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: main2.c,v 1.13 2021/01/16 02:40:02 rillig Exp $");
+__RCSID("$NetBSD: main2.c,v 1.14 2021/03/26 20:31:07 rillig Exp $");
 #endif
 
 #include <stdio.h>
@@ -98,7 +98,7 @@ main(int argc, char *argv[])
 	size_t	len;
 	char	*lname;
 
-	libs = xcalloc(1, sizeof (char *));
+	libs = xcalloc(1, sizeof *libs);
 
 	opterr = 0;
 	while ((c = getopt(argc, argv, "hpstxuC:HTFl:")) != -1) {
@@ -141,7 +141,7 @@ main(int argc, char *argv[])
 		case 'l':
 			for (i = 0; libs[i] != NULL; i++)
 				continue;
-			libs = xrealloc(libs, (i + 2) * sizeof (char *));
+			libs = xrealloc(libs, (i + 2) * sizeof *libs);
 			libs[i] = xstrdup(optarg);
 			libs[i + 1] = NULL;
 			break;

Index: src/usr.bin/xlint/xlint/xlint.c
diff -u src/usr.bin/xlint/xlint/xlint.c:1.56 src/usr.bin/xlint/xlint/xlint.c:1.57
--- src/usr.bin/xlint/xlint/xlint.c:1.56	Sat Jan 16 16:53:24 2021
+++ src/usr.bin/xlint/xlint/xlint.c	Fri Mar 26 20:31:07 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: xlint.c,v 1.56 2021/01/16 16:53:24 rillig Exp $ */
+/* $NetBSD: xlint.c,v 1.57 2021/03/26 20:31:07 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: xlint.c,v 1.56 2021/01/16 16:53:24 rillig Exp $");
+__RCSID("$NetBSD: xlint.c,v 1.57 2021/03/26 20:31:07 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -158,7 +158,7 @@ appstrg(char ***lstp, char *s)
 	olst = *lstp;
 	for (i = 0; olst[i] != NULL; i++)
 		continue;
-	lst = xrealloc(olst, (i + 2) * sizeof (char *));
+	lst = xrealloc(olst, (i + 2) * sizeof *lst);
 	lst[i] = s;
 	lst[i + 1] = NULL;
 	*lstp = lst;
@@ -182,7 +182,7 @@ applst(char ***destp, char *const *src)
 		continue;
 	for (k = 0; src[k] != NULL; k++)
 		continue;
-	dest = xrealloc(odest, (i + k + 1) * sizeof (char *));
+	dest = xrealloc(odest, (i + k + 1) * sizeof *dest);
 	for (k = 0; src[k] != NULL; k++)
 		dest[i + k] = xstrdup(src[k]);
 	dest[i + k] = NULL;
@@ -322,7 +322,7 @@ main(int argc, char *argv[])
 		tmpdir = p;
 	}
 
-	cppout = xmalloc(strlen(tmpdir) + sizeof ("lint0.XXXXXX"));
+	cppout = xmalloc(strlen(tmpdir) + sizeof "lint0.XXXXXX");
 	(void)sprintf(cppout, "%slint0.XXXXXX", tmpdir);
 	cppoutfd = mkstemp(cppout);
 	if (cppoutfd == -1) {
@@ -330,16 +330,16 @@ main(int argc, char *argv[])
 		terminate(-1);
 	}
 
-	p1out = xcalloc(1, sizeof (char *));
-	p2in = xcalloc(1, sizeof (char *));
-	cflags = xcalloc(1, sizeof (char *));
-	lcflags = xcalloc(1, sizeof (char *));
-	l1flags = xcalloc(1, sizeof (char *));
-	l2flags = xcalloc(1, sizeof (char *));
-	l2libs = xcalloc(1, sizeof (char *));
-	deflibs = xcalloc(1, sizeof (char *));
-	libs = xcalloc(1, sizeof (char *));
-	libsrchpath = xcalloc(1, sizeof (char *));
+	p1out = xcalloc(1, sizeof *p1out);
+	p2in = xcalloc(1, sizeof *p2in);
+	cflags = xcalloc(1, sizeof *cflags);
+	lcflags = xcalloc(1, sizeof *lcflags);
+	l1flags = xcalloc(1, sizeof *l1flags);
+	l2flags = xcalloc(1, sizeof *l2flags);
+	l2libs = xcalloc(1, sizeof *l2libs);
+	deflibs = xcalloc(1, sizeof *deflibs);
+	libs = xcalloc(1, sizeof *libs);
+	libsrchpath = xcalloc(1, sizeof *libsrchpath);
 
 	appcstrg(&cflags, "-E");
 	appcstrg(&cflags, "-x");
@@ -481,7 +481,7 @@ main(int argc, char *argv[])
 				usage();
 			Cflag = true;
 			appstrg(&l2flags, concat2("-C", optarg));
-			p2out = xmalloc(sizeof ("llib-l.ln") + strlen(optarg));
+			p2out = xmalloc(sizeof "llib-l.ln" + strlen(optarg));
 			(void)sprintf(p2out, "llib-l%s.ln", optarg);
 			freelst(&deflibs);
 			break;
@@ -674,7 +674,7 @@ fname(const char *name)
 	if (!iflag)
 		appcstrg(&p1out, ofn);
 
-	args = xcalloc(1, sizeof (char *));
+	args = xcalloc(1, sizeof *args);
 
 	/* run cc */
 	if ((CC = getenv("CC")) == NULL)
@@ -709,7 +709,7 @@ fname(const char *name)
 	/* run lint1 */
 
 	if (!Bflag) {
-		pathname = xmalloc(strlen(PATH_LIBEXEC) + sizeof ("/lint1") +
+		pathname = xmalloc(strlen(PATH_LIBEXEC) + sizeof "/lint1" +
 		    strlen(target_prefix));
 		(void)sprintf(pathname, "%s/%slint1", PATH_LIBEXEC,
 		    target_prefix);
@@ -718,7 +718,7 @@ fname(const char *name)
 		 * XXX Unclear whether we should be using target_prefix
 		 * XXX here.  [email protected]
 		 */
-		pathname = xmalloc(strlen(libexec_path) + sizeof ("/lint1"));
+		pathname = xmalloc(strlen(libexec_path) + sizeof "/lint1");
 		(void)sprintf(pathname, "%s/lint1", libexec_path);
 	}
 
@@ -806,11 +806,11 @@ findlibs(char *const *liblst)
 	for (i = 0; (lib = liblst[i]) != NULL; i++) {
 		for (k = 0; (path = libsrchpath[k]) != NULL; k++) {
 			len = strlen(path) + strlen(lib);
-			lfn = xrealloc(lfn, len + sizeof ("/llib-l.ln"));
+			lfn = xrealloc(lfn, len + sizeof "/llib-l.ln");
 			(void)sprintf(lfn, "%s/llib-l%s.ln", path, lib);
 			if (rdok(lfn))
 				break;
-			lfn = xrealloc(lfn, len + sizeof ("/lint/llib-l.ln"));
+			lfn = xrealloc(lfn, len + sizeof "/lint/llib-l.ln");
 			(void)sprintf(lfn, "%s/lint/llib-l%s.ln", path, lib);
 			if (rdok(lfn))
 				break;
@@ -844,10 +844,10 @@ lint2(void)
 {
 	char	*path, **args;
 
-	args = xcalloc(1, sizeof (char *));
+	args = xcalloc(1, sizeof *args);
 
 	if (!Bflag) {
-		path = xmalloc(strlen(PATH_LIBEXEC) + sizeof ("/lint2") +
+		path = xmalloc(strlen(PATH_LIBEXEC) + sizeof "/lint2" +
 		    strlen(target_prefix));
 		(void)sprintf(path, "%s/%slint2", PATH_LIBEXEC,
 		    target_prefix);
@@ -856,7 +856,7 @@ lint2(void)
 		 * XXX Unclear whether we should be using target_prefix
 		 * XXX here.  [email protected]
 		 */
-		path = xmalloc(strlen(libexec_path) + sizeof ("/lint2"));
+		path = xmalloc(strlen(libexec_path) + sizeof "/lint2");
 		(void)sprintf(path, "%s/lint2", libexec_path);
 	}
 

Reply via email to