Sat Jan 2 01:06:15 2021 UTC ()
lint: use bool instead of u_int:1 in structures

Better late than never.


(rillig)
diff -r1.20 -r1.21 src/usr.bin/xlint/common/lint.h
diff -r1.55 -r1.56 src/usr.bin/xlint/lint1/init.c
diff -r1.46 -r1.47 src/usr.bin/xlint/lint1/lint1.h
diff -r1.7 -r1.8 src/usr.bin/xlint/lint1/op.h
diff -r1.109 -r1.110 src/usr.bin/xlint/lint1/scan.l
diff -r1.11 -r1.12 src/usr.bin/xlint/lint2/lint2.h

cvs diff -r1.20 -r1.21 src/usr.bin/xlint/common/lint.h (expand / switch to context diff)
--- src/usr.bin/xlint/common/lint.h 2021/01/01 11:58:03 1.20
+++ src/usr.bin/xlint/common/lint.h 2021/01/02 01:06:15 1.21
@@ -1,4 +1,4 @@
-/*	$NetBSD: lint.h,v 1.20 2021/01/01 11:58:03 rillig Exp $	*/
+/*	$NetBSD: lint.h,v 1.21 2021/01/02 01:06:15 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -38,9 +38,10 @@
 #endif
 
 #include <sys/types.h>
-#include <stddef.h>
 #include <err.h>
 #include <inttypes.h>
+#include <stdbool.h>
+#include <stddef.h>
 #include <stdio.h>
 
 #include "param.h"
@@ -95,12 +96,12 @@
 					   if pflag is set */
 	tspec_t	tt_signed_counterpart;
 	tspec_t	tt_unsigned_counterpart;
-	u_int	tt_is_int : 1;		/* 1 if integer type */
-	u_int	tt_is_uint : 1;		/* 1 if unsigned integer type */
-	u_int	tt_is_float : 1;	/* 1 if floating point type */
-	u_int	tt_is_arith : 1;	/* 1 if arithmetic type */
-	u_int	tt_is_scalar : 1;	/* 1 if scalar type */
-	u_int	tt_is_complex : 1;	/* 1 if complex type */
+	bool	tt_is_int : 1;		/* integer type */
+	bool	tt_is_uint : 1;		/* unsigned integer type */
+	bool	tt_is_float : 1;	/* floating point type */
+	bool	tt_is_arith : 1;	/* arithmetic type */
+	bool	tt_is_scalar : 1;	/* scalar type */
+	bool	tt_is_complex : 1;	/* complex type */
 	const char *tt_name;		/* name of the type */
 } ttab_t;
 

cvs diff -r1.55 -r1.56 src/usr.bin/xlint/lint1/init.c (expand / switch to context diff)
--- src/usr.bin/xlint/lint1/init.c 2021/01/01 20:02:56 1.55
+++ src/usr.bin/xlint/lint1/init.c 2021/01/02 01:06:15 1.56
@@ -1,4 +1,4 @@
-/*	$NetBSD: init.c,v 1.55 2021/01/01 20:02:56 rillig Exp $	*/
+/*	$NetBSD: init.c,v 1.56 2021/01/02 01:06:15 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.55 2021/01/01 20:02:56 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.56 2021/01/02 01:06:15 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -65,9 +65,9 @@
 typedef	struct istk {
 	type_t	*i_type;		/* type of initialisation */
 	type_t	*i_subt;		/* type of next level */
-	u_int	i_brace : 1;		/* need } for pop */
-	u_int	i_nolimit : 1;		/* incomplete array type */
-	u_int	i_namedmem : 1;		/* has c9x named members */
+	bool	i_brace : 1;		/* need } for pop */
+	bool	i_nolimit : 1;		/* incomplete array type */
+	bool	i_namedmem : 1;		/* has c9x named members */
 	sym_t	*i_mem;			/* next structure member */
 	int	i_remaining;		/* # of remaining elements */
 	struct	istk *i_next;		/* previous level */

cvs diff -r1.46 -r1.47 src/usr.bin/xlint/lint1/lint1.h (expand / switch to context diff)
--- src/usr.bin/xlint/lint1/lint1.h 2021/01/01 19:15:58 1.46
+++ src/usr.bin/xlint/lint1/lint1.h 2021/01/02 01:06:15 1.47
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.46 2021/01/01 19:15:58 rillig Exp $ */
+/* $NetBSD: lint1.h,v 1.47 2021/01/02 01:06:15 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -127,7 +127,7 @@
 typedef	struct {
 	u_int	size;		/* size in bit */
 	u_int	align : 15;	/* alignment in bit */
-	u_int	sincompl : 1;	/* set if incomplete type */
+	bool	sincompl : 1;	/* set if incomplete type */
 	struct	sym *memb;	/* list of members */
 	struct	sym *stag;	/* symbol table entry of tag */
 	struct	sym *stdef;	/* symbol table entry of first typename */
@@ -137,7 +137,7 @@
  * same as above for enums
  */
 typedef	struct {
-	u_int	eincompl : 1;	/* incomplete enum type */
+	bool	eincompl : 1;	/* incomplete enum type */
 	struct	sym *elem;	/* list of enumerators */
 	struct	sym *etag;	/* symbol table entry of tag */
 	struct	sym *etdef;	/* symbol table entry of first typename */
@@ -149,15 +149,15 @@
  */
 struct type {
 	tspec_t	t_tspec;	/* type specifier */
-	u_int	t_aincompl : 1;	/* incomplete array type */
-	u_int	t_const : 1;	/* const modifier */
-	u_int	t_volatile : 1;	/* volatile modifier */
-	u_int	t_proto : 1;	/* function prototype (t_args valid) */
-	u_int	t_vararg : 1;	/* prototype with ... */
-	u_int	t_typedef : 1;	/* type defined with typedef */
-	u_int	t_isfield : 1;	/* type is bitfield */
-	u_int	t_isenum : 1;	/* type is (or was) enum (t_enum valid) */
-	u_int	t_ispacked : 1;	/* type is packed */
+	bool	t_aincompl : 1;	/* incomplete array type */
+	bool	t_const : 1;	/* const modifier */
+	bool	t_volatile : 1;	/* volatile modifier */
+	bool	t_proto : 1;	/* function prototype (t_args valid) */
+	bool	t_vararg : 1;	/* prototype with ... */
+	bool	t_typedef : 1;	/* type defined with typedef */
+	bool	t_isfield : 1;	/* type is bitfield */
+	bool	t_isenum : 1;	/* type is (or was) enum (t_enum valid) */
+	bool	t_ispacked : 1;	/* type is packed */
 	union {
 		int	_t_dim;		/* dimension */
 		str_t	*_t_str;	/* struct/union tag */
@@ -226,16 +226,16 @@
 	pos_t	s_use_pos;	/* position of first use */
 	symt_t	s_kind;		/* type of symbol */
 	void   *s_keyword;
-	u_int	s_bitfield : 1;
-	u_int	s_set : 1;	/* variable set, label defined */
-	u_int	s_used : 1;	/* variable/label used */
-	u_int	s_arg : 1;	/* symbol is function argument */
-	u_int	s_reg : 1;	/* symbol is register variable */
-	u_int	s_defarg : 1;	/* undefined symbol in old style function
+	bool	s_bitfield : 1;
+	bool	s_set : 1;	/* variable set, label defined */
+	bool	s_used : 1;	/* variable/label used */
+	bool	s_arg : 1;	/* symbol is function argument */
+	bool	s_reg : 1;	/* symbol is register variable */
+	bool	s_defarg : 1;	/* undefined symbol in old style function
 				   definition */
-	u_int	s_rimpl : 1;	/* return value of function implicit decl. */
-	u_int	s_osdef : 1;	/* symbol stems from old style function def. */
-	u_int	s_inline : 1;	/* true if this is an inline function */
+	bool	s_rimpl : 1;	/* return value of function implicit decl. */
+	bool	s_osdef : 1;	/* symbol stems from old style function def. */
+	bool	s_inline : 1;	/* true if this is an inline function */
 	struct	sym *s_ext_sym;	/* for local declared external symbols pointer
 				   to external symbol with same name */
 	def_t	s_def;		/* declared, tentative defined, defined */
@@ -284,9 +284,9 @@
 typedef	struct tnode {
 	op_t	tn_op;		/* operator */
 	type_t	*tn_type;	/* type */
-	u_int	tn_lvalue : 1;	/* node is lvalue */
-	u_int	tn_cast : 1;	/* if tn_op == CVT, it's an explicit cast */
-	u_int	tn_parenthesized : 1; /* node parenthesized */
+	bool	tn_lvalue : 1;	/* node is lvalue */
+	bool	tn_cast : 1;	/* if tn_op == CVT, it's an explicit cast */
+	bool	tn_parenthesized : 1;
 	union {
 		struct {
 			struct	tnode *_tn_left;	/* (left) operand */
@@ -332,18 +332,18 @@
 	int	d_offset;	/* offset of next structure member */
 	int	d_stralign;	/* alignment required for current structure */
 	scl_t	d_ctx;		/* context of declaration */
-	u_int	d_const : 1;	/* const in declaration specifiers */
-	u_int	d_volatile : 1;	/* volatile in declaration specifiers */
-	u_int	d_inline : 1;	/* inline in declaration specifiers */
-	u_int	d_mscl : 1;	/* multiple storage classes */
-	u_int	d_terr : 1;	/* invalid type combination */
-	u_int	d_nedecl : 1;	/* 1 if at least a tag is declared */
-	u_int	d_vararg : 1;	/* ... in in current function decl. */
-	u_int	d_proto : 1;	/* current funct. decl. is prototype */
-	u_int	d_notyp : 1;	/* set if no type specifier was present */
-	u_int	d_asm : 1;	/* set if d_ctx == AUTO and asm() present */
-	u_int	d_ispacked : 1;	/* packed */
-	u_int	d_used : 1;	/* used */
+	bool	d_const : 1;	/* const in declaration specifiers */
+	bool	d_volatile : 1;	/* volatile in declaration specifiers */
+	bool	d_inline : 1;	/* inline in declaration specifiers */
+	bool	d_mscl : 1;	/* multiple storage classes */
+	bool	d_terr : 1;	/* invalid type combination */
+	bool	d_nedecl : 1;	/* if at least one tag is declared */
+	bool	d_vararg : 1;	/* ... in in current function decl. */
+	bool	d_proto : 1;	/* current function decl. is prototype */
+	bool	d_notyp : 1;	/* set if no type specifier was present */
+	bool	d_asm : 1;	/* set if d_ctx == AUTO and asm() present */
+	bool	d_ispacked : 1;	/* packed */
+	bool	d_used : 1;	/* used */
 	type_t	*d_tagtyp;	/* tag during member declaration */
 	sym_t	*d_fargs;	/* list of arguments during function def. */
 	pos_t	d_fdpos;	/* position of function definition */
@@ -360,8 +360,8 @@
  */
 typedef	struct pqinf {
 	int	p_pcnt;			/* number of asterisks */
-	u_int	p_const : 1;
-	u_int	p_volatile : 1;
+	bool	p_const : 1;
+	bool	p_volatile : 1;
 	struct	pqinf *p_next;
 } pqinf_t;
 
@@ -378,16 +378,16 @@
  */
 typedef struct cstk {
 	int	c_env;			/* type of statement (T_IF, ...) */
-	u_int	c_loop : 1;		/* continue && break are valid */
-	u_int	c_switch : 1;		/* case && break are valid */
-	u_int	c_break : 1;		/* loop/switch has break */
-	u_int	c_cont : 1;		/* loop has continue */
-	u_int	c_default : 1;		/* switch has default */
-	u_int	c_infinite : 1;		/* break condition always false
+	bool	c_loop : 1;		/* continue && break are valid */
+	bool	c_switch : 1;		/* case && break are valid */
+	bool	c_break : 1;		/* loop/switch has break */
+	bool	c_cont : 1;		/* loop has continue */
+	bool	c_default : 1;		/* switch has default */
+	bool	c_infinite : 1;		/* break condition always false
 					   (for (;;), while (1)) */
-	u_int	c_rchif : 1;		/* end of if-branch reached */
-	u_int	c_noretval : 1;		/* had "return;" */
-	u_int	c_retval : 1;		/* had "return (e);" */
+	bool	c_rchif : 1;		/* end of if-branch reached */
+	bool	c_noretval : 1;		/* had "return;" */
+	bool	c_retval : 1;		/* had "return (e);" */
 	type_t	*c_swtype;		/* type of switch expression */
 	clst_t	*c_clst;		/* list of case values */
 	struct	mbl *c_fexprm;		/* saved memory for end of loop

cvs diff -r1.7 -r1.8 src/usr.bin/xlint/lint1/op.h (expand / switch to context diff)
--- src/usr.bin/xlint/lint1/op.h 2020/12/28 19:38:54 1.7
+++ src/usr.bin/xlint/lint1/op.h 2021/01/02 01:06:15 1.8
@@ -1,4 +1,4 @@
-/*	$NetBSD: op.h,v 1.7 2020/12/28 19:38:54 rillig Exp $	*/
+/*	$NetBSD: op.h,v 1.8 2021/01/02 01:06:15 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -31,28 +31,30 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <stdbool.h>
+
 /*
  * Various information about operators
  */
 typedef	struct {
-	u_int	m_binary : 1;	/* binary operator */
-	u_int	m_logical : 1;	/* logical operator, result is int */
-	u_int	m_requires_integer : 1;
-	u_int	m_requires_scalar : 1;
-	u_int	m_requires_arith : 1;
-	u_int	m_fold : 1;	/* operands should be folded */
-	u_int	m_vctx : 1;	/* value context for left operand */
-	u_int	m_tctx : 1;	/* test context for left operand */
-	u_int	m_balance : 1;	/* operator requires balancing */
-	u_int	m_sideeff : 1;	/* operator has side effect */
-	u_int	m_tlansiu : 1;	/* warn if left op. is unsign. in ANSI C */
-	u_int	m_transiu : 1;	/* warn if right op. is unsign. in ANSI C */
-	u_int	m_tpconf : 1;	/* test possible precedence confusion */
-	u_int	m_comp : 1;	/* operator performs comparison */
-	u_int	m_valid_on_enum : 1;	/* valid operation on enums */
-	u_int	m_bad_on_enum : 1;	/* dubious operation on enums */
-	u_int	m_eqwarn : 1;	/* warning if on operand stems from == */
-	u_int	m_requires_integer_or_complex : 1;
+	bool	m_binary : 1;	/* binary operator */
+	bool	m_logical : 1;	/* logical operator, result is int */
+	bool	m_requires_integer : 1;
+	bool	m_requires_scalar : 1;
+	bool	m_requires_arith : 1;
+	bool	m_fold : 1;	/* operands should be folded */
+	bool	m_vctx : 1;	/* value context for left operand */
+	bool	m_tctx : 1;	/* test context for left operand */
+	bool	m_balance : 1;	/* operator requires balancing */
+	bool	m_sideeff : 1;	/* operator has side effect */
+	bool	m_tlansiu : 1;	/* warn if left op. is unsign. in ANSI C */
+	bool	m_transiu : 1;	/* warn if right op. is unsign. in ANSI C */
+	bool	m_tpconf : 1;	/* test possible precedence confusion */
+	bool	m_comp : 1;	/* operator performs comparison */
+	bool	m_valid_on_enum : 1;	/* valid operation on enums */
+	bool	m_bad_on_enum : 1;	/* dubious operation on enums */
+	bool	m_eqwarn : 1;	/* warning if on operand stems from == */
+	bool	m_requires_integer_or_complex : 1;
 	const char *m_name;	/* name of op. */
 } mod_t;
 

cvs diff -r1.109 -r1.110 src/usr.bin/xlint/lint1/scan.l (expand / switch to context diff)
--- src/usr.bin/xlint/lint1/scan.l 2021/01/01 11:51:15 1.109
+++ src/usr.bin/xlint/lint1/scan.l 2021/01/02 01:06:15 1.110
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: scan.l,v 1.109 2021/01/01 11:51:15 rillig Exp $ */
+/* $NetBSD: scan.l,v 1.110 2021/01/02 01:06:15 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: scan.l,v 1.109 2021/01/01 11:51:15 rillig Exp $");
+__RCSID("$NetBSD: scan.l,v 1.110 2021/01/02 01:06:15 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -199,10 +199,10 @@
 	scl_t	kw_scl;		/* storage class if kw_token T_SCLASS */
 	tspec_t	kw_tspec;	/* type spec. if kw_token T_TYPE or T_SOU */
 	tqual_t	kw_tqual;	/* type qual. fi kw_token T_QUAL */
-	u_int	kw_c89 : 1;	/* c89 keyword */
-	u_int	kw_c99 : 1;	/* c99 keyword */
-	u_int	kw_gcc : 1;	/* GCC keyword */
-	u_int	kw_attr : 1;	/* GCC attribute, keyword */
+	bool	kw_c89 : 1;	/* C89 keyword */
+	bool	kw_c99 : 1;	/* C99 keyword */
+	bool	kw_gcc : 1;	/* GCC keyword */
+	bool	kw_attr : 1;	/* GCC attribute, keyword */
 	u_int	kw_deco : 3;	/* 1 = name, 2 = __name, 4 = __name__ */
 } kwtab[] = {
 #ifdef INT128_SIZE

cvs diff -r1.11 -r1.12 src/usr.bin/xlint/lint2/lint2.h (expand / switch to context diff)
--- src/usr.bin/xlint/lint2/lint2.h 2020/12/30 10:46:11 1.11
+++ src/usr.bin/xlint/lint2/lint2.h 2021/01/02 01:06:15 1.12
@@ -1,4 +1,4 @@
-/* $NetBSD: lint2.h,v 1.11 2020/12/30 10:46:11 rillig Exp $ */
+/* $NetBSD: lint2.h,v 1.12 2021/01/02 01:06:15 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -39,14 +39,14 @@
  */
 struct type {
 	tspec_t	t_tspec;	/* type specifier */
-	u_int	t_const : 1;	/* constant */
-	u_int	t_volatile : 1;	/* volatile */
-	u_int	t_vararg : 1;	/* function has variable number of arguments */
-	u_int	t_isenum : 1;	/* enum type */
-	u_int	t_proto : 1;	/* this is a prototype */
-	u_int	t_istag : 1;	/* tag with _t_tag valid */
-	u_int	t_istynam : 1;	/* tag with _t_tynam valid */
-	u_int	t_isuniqpos : 1; /* tag with _t_uniqpos valid */
+	bool	t_const : 1;	/* constant */
+	bool	t_volatile : 1;	/* volatile */
+	bool	t_vararg : 1;	/* function has variable number of arguments */
+	bool	t_isenum : 1;	/* enum type */
+	bool	t_proto : 1;	/* this is a prototype */
+	bool	t_istag : 1;	/* tag with _t_tag valid */
+	bool	t_istynam : 1;	/* tag with _t_tynam valid */
+	bool	t_isuniqpos : 1; /* tag with _t_uniqpos valid */
 	union {
 		int	_t_dim;		/* if the type is an ARRAY than this
 					   is the dimension of the array. */
@@ -82,10 +82,10 @@
  */
 typedef	struct arginf {
 	int	a_num;		/* # of argument (1..) */
-	u_int	a_zero : 1;	/* argument is 0 */
-	u_int	a_pcon : 1;	/* msb of argument is not set */
-	u_int	a_ncon : 1;	/* msb of argument is set */
-	u_int	a_fmt : 1;	/* a_fstrg points to format string */
+	bool	a_zero : 1;	/* argument is 0 */
+	bool	a_pcon : 1;	/* msb of argument is not set */
+	bool	a_ncon : 1;	/* msb of argument is set */
+	bool	a_fmt : 1;	/* a_fstrg points to format string */
 	char	*a_fstrg;	/* format string */
 	struct	arginf *a_next;	/* information for next const. argument */
 } arginf_t;
@@ -118,13 +118,13 @@
 #else
 		def_t	s_def;
 #endif
-		u_int	s_rval : 1;	/* function has return value */
-		u_int	s_inline : 1;	/* function is inline */
-		u_int	s_osdef : 1;	/* old style function definition */
-		u_int	s_static : 1;	/* symbol is static */
-		u_int	s_va : 1;	/* check only first s_nva arguments */
-		u_int	s_prfl : 1;	/* printflike */
-		u_int	s_scfl : 1;	/* scanflike */
+		bool	s_rval : 1;	/* function has return value */
+		bool	s_inline : 1;	/* function is inline */
+		bool	s_osdef : 1;	/* old style function definition */
+		bool	s_static : 1;	/* symbol is static */
+		bool	s_va : 1;	/* check only first s_nva arguments */
+		bool	s_prfl : 1;	/* printflike */
+		bool	s_scfl : 1;	/* scanflike */
 		u_short	s_type;		/* type */
 		struct	sym *s_next;	/* next symbol with same name */
 	} s_s;
@@ -150,8 +150,8 @@
  */
 typedef	struct fcall {
 	pos_t	f_pos;		/* position of call */
-	u_int	f_rused : 1;	/* return value used */
-	u_int	f_rdisc : 1;	/* return value discarded (casted to void) */
+	bool	f_rused : 1;	/* return value used */
+	bool	f_rdisc : 1;	/* return value discarded (casted to void) */
 	u_short	f_type;		/* types of expected return value and args */
 	arginf_t *f_args;	/* information about constant arguments */
 	struct	fcall *f_next;	/* next call of same function */
@@ -171,9 +171,9 @@
  */
 typedef	struct hte {
 	const	char *h_name;	/* name */
-	u_int	h_used : 1;	/* symbol is used */
-	u_int	h_def : 1;	/* symbol is defined */
-	u_int	h_static : 1;	/* static symbol */
+	bool	h_used : 1;	/* symbol is used */
+	bool	h_def : 1;	/* symbol is defined */
+	bool	h_static : 1;	/* static symbol */
 	sym_t	*h_syms;	/* declarations and definitions */
 	sym_t	**h_lsym;	/* points to s_next of last decl./def. */
 	fcall_t	*h_calls;	/* function calls */