Module Name:    src
Committed By:   rillig
Date:           Fri Jun  9 15:36:31 UTC 2023

Modified Files:
        src/usr.bin/xlint/common: param.h
        src/usr.bin/xlint/lint1: decl.c emit1.c err.c func.c lex.c lint1.h
            tree.c

Log Message:
lint: miscellaneous clean-ups

No binary change, except for line numbers in assertions.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/xlint/common/param.h
cvs rdiff -u -r1.316 -r1.317 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.67 -r1.68 src/usr.bin/xlint/lint1/emit1.c
cvs rdiff -u -r1.198 -r1.199 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.155 -r1.156 src/usr.bin/xlint/lint1/func.c
cvs rdiff -u -r1.159 -r1.160 src/usr.bin/xlint/lint1/lex.c
cvs rdiff -u -r1.164 -r1.165 src/usr.bin/xlint/lint1/lint1.h
cvs rdiff -u -r1.526 -r1.527 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/common/param.h
diff -u src/usr.bin/xlint/common/param.h:1.10 src/usr.bin/xlint/common/param.h:1.11
--- src/usr.bin/xlint/common/param.h:1.10	Sat Jan 14 09:21:58 2023
+++ src/usr.bin/xlint/common/param.h	Fri Jun  9 15:36:31 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.10 2023/01/14 09:21:58 rillig Exp $	*/
+/*	$NetBSD: param.h,v 1.11 2023/06/09 15:36:31 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -53,12 +53,3 @@
  * Make sure this matches wchar_t.
  */
 #define WCHAR	INT
-
-/*
- * The sparc64 long double code generation is broken in old gcc.
- */
-#if !(defined(__sparc64__) && defined(__GNUC__) && __GNUC__ <= 2)
-typedef	long double ldbl_t;
-#else
-typedef	double	ldbl_t;
-#endif

Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.316 src/usr.bin/xlint/lint1/decl.c:1.317
--- src/usr.bin/xlint/lint1/decl.c:1.316	Fri Jun  9 13:03:49 2023
+++ src/usr.bin/xlint/lint1/decl.c	Fri Jun  9 15:36:31 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.316 2023/06/09 13:03:49 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.317 2023/06/09 15:36:31 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: decl.c,v 1.316 2023/06/09 13:03:49 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.317 2023/06/09 15:36:31 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -1601,7 +1601,7 @@ declarator_name(sym_t *sym)
 	case DK_AUTO:
 		if ((sc = dcs->d_scl) == NOSCL) {
 			/*
-			 * XXX somewhat ugly because we dont know whether
+			 * XXX somewhat ugly because we don't know whether
 			 * this is AUTO or EXTERN (functions). If we are
 			 * wrong it must be corrected in declare_local(),
 			 * where we have the necessary type information.
@@ -1893,7 +1893,7 @@ enumeration_constant(sym_t *sym, int val
 				/* redeclaration of '%s' */
 				error(27, sym->s_name);
 				/*
-				 * inside blocks it should not be too
+				 * Inside blocks, it should not be too
 				 * complicated to find the position of the
 				 * previous declaration
 				 */
@@ -2845,7 +2845,7 @@ declare_external_in_block(sym_t *dsym)
 
 	if (compatible) {
 		/*
-		 * Remember the external symbol so we can update usage
+		 * Remember the external symbol, so we can update usage
 		 * information at the end of the block.
 		 */
 		dsym->s_ext_sym = esym;

Index: src/usr.bin/xlint/lint1/emit1.c
diff -u src/usr.bin/xlint/lint1/emit1.c:1.67 src/usr.bin/xlint/lint1/emit1.c:1.68
--- src/usr.bin/xlint/lint1/emit1.c:1.67	Fri Jun  9 13:03:49 2023
+++ src/usr.bin/xlint/lint1/emit1.c	Fri Jun  9 15:36:31 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: emit1.c,v 1.67 2023/06/09 13:03:49 rillig Exp $ */
+/* $NetBSD: emit1.c,v 1.68 2023/06/09 15:36:31 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: emit1.c,v 1.67 2023/06/09 13:03:49 rillig Exp $");
+__RCSID("$NetBSD: emit1.c,v 1.68 2023/06/09 15:36:31 rillig Exp $");
 #endif
 
 #include "lint1.h"
@@ -193,12 +193,8 @@ outsym(const sym_t *sym, scl_t sc, def_t
 	/* reset buffer */
 	outclr();
 
-	/*
-	 * line number of .c source, 'd' for declaration, Id of current
-	 * source (.c or .h), and line in current source.
-	 */
 	outint(csrc_pos.p_line);
-	outchar('d');
+	outchar('d');		/* declaration */
 	outint(get_filename_id(sym->s_def_pos.p_file));
 	outchar('.');
 	outint(sym->s_def_pos.p_line);
@@ -239,10 +235,8 @@ outsym(const sym_t *sym, scl_t sc, def_t
 }
 
 /*
- * write information about function definition
- *
- * this is also done for static functions so we are able to check if
- * they are called with proper argument types
+ * Write information about a function definition. This is also done for static
+ * functions, to later check if they are called with proper argument types.
  */
 void
 outfdef(const sym_t *fsym, const pos_t *posp, bool rval, bool osdef,
@@ -254,20 +248,12 @@ outfdef(const sym_t *fsym, const pos_t *
 	/* reset the buffer */
 	outclr();
 
-	/*
-	 * line number of .c source, 'd' for declaration, Id of current
-	 * source (.c or .h), and line in current source
-	 *
-	 * we are already at the end of the function. If we are in the
-	 * .c source, posp->p_line is correct, otherwise csrc_pos.p_line
-	 * (for functions defined in header files).
-	 */
 	if (posp->p_file == csrc_pos.p_file) {
 		outint(posp->p_line);
 	} else {
 		outint(csrc_pos.p_line);
 	}
-	outchar('d');
+	outchar('d');		/* declaration */
 	outint(get_filename_id(posp->p_file));
 	outchar('.');
 	outint(posp->p_line);
@@ -359,12 +345,8 @@ outcall(const tnode_t *tn, bool retval_u
 	/* reset buffer */
 	outclr();
 
-	/*
-	 * line number of .c source, 'c' for function call, Id of current
-	 * source (.c or .h), and line in current source
-	 */
 	outint(csrc_pos.p_line);
-	outchar('c');
+	outchar('c');		/* function call */
 	outint(get_filename_id(curr_pos.p_file));
 	outchar('.');
 	outint(curr_pos.p_line);
@@ -587,18 +569,14 @@ outfstrg(strg_t *strg)
 void
 outusg(const sym_t *sym)
 {
-	if (ch_isdigit(sym->s_name[0]))	/* 00000000_tmp */
+	if (ch_isdigit(sym->s_name[0]))	/* 00000000_tmp, from mktempsym */
 		return;
 
 	/* reset buffer */
 	outclr();
 
-	/*
-	 * line number of .c source, 'u' for used, Id of current
-	 * source (.c or .h), and line in current source
-	 */
 	outint(csrc_pos.p_line);
-	outchar('u');
+	outchar('u');		/* used */
 	outint(get_filename_id(curr_pos.p_file));
 	outchar('.');
 	outint(curr_pos.p_line);

Index: src/usr.bin/xlint/lint1/err.c
diff -u src/usr.bin/xlint/lint1/err.c:1.198 src/usr.bin/xlint/lint1/err.c:1.199
--- src/usr.bin/xlint/lint1/err.c:1.198	Fri Jun  9 13:03:49 2023
+++ src/usr.bin/xlint/lint1/err.c	Fri Jun  9 15:36:31 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: err.c,v 1.198 2023/06/09 13:03:49 rillig Exp $	*/
+/*	$NetBSD: err.c,v 1.199 2023/06/09 15:36:31 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: err.c,v 1.198 2023/06/09 13:03:49 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.199 2023/06/09 15:36:31 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -435,7 +435,7 @@ suppress_messages(const char *p)
 		if (*end == '\0')
 			return;
 	}
-	errx(1, "invalid message ID '%.*s'", (int)(strcspn(p, ",")), p);
+	errx(1, "invalid message ID '%.*s'", (int)strcspn(p, ","), p);
 }
 
 void
@@ -746,5 +746,5 @@ enable_queries(const char *p)
 		if (*end == '\0')
 			return;
 	}
-	errx(1, "invalid query ID '%.*s'", (int)(strcspn(p, ",")), p);
+	errx(1, "invalid query ID '%.*s'", (int)strcspn(p, ","), p);
 }

Index: src/usr.bin/xlint/lint1/func.c
diff -u src/usr.bin/xlint/lint1/func.c:1.155 src/usr.bin/xlint/lint1/func.c:1.156
--- src/usr.bin/xlint/lint1/func.c:1.155	Fri Jun  9 13:03:49 2023
+++ src/usr.bin/xlint/lint1/func.c	Fri Jun  9 15:36:31 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: func.c,v 1.155 2023/06/09 13:03:49 rillig Exp $	*/
+/*	$NetBSD: func.c,v 1.156 2023/06/09 15:36:31 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: func.c,v 1.155 2023/06/09 13:03:49 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.156 2023/06/09 15:36:31 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -287,8 +287,7 @@ begin_function(sym_t *fsym)
 
 	/*
 	 * We must also remember the position. s_def_pos is overwritten
-	 * if this is an old-style definition and we had already a
-	 * prototype.
+	 * if this is an old-style definition, and we had already a prototype.
 	 */
 	dcs->d_func_def_pos = fsym->s_def_pos;
 
@@ -380,7 +379,7 @@ end_function(void)
 
 	/*
 	 * This warning is printed only if the return value was implicitly
-	 * declared to be int. Otherwise the wrong return statement
+	 * declared to be int. Otherwise, the wrong return statement
 	 * has already printed a warning.
 	 */
 	if (cstmt->c_had_return_noval && cstmt->c_had_return_value &&
@@ -1363,7 +1362,7 @@ bitfieldtype(int n)
 /*
  * PROTOLIB in conjunction with LINTLIBRARY can be used to handle
  * prototypes like function definitions. This is done if the argument
- * to PROTOLIB is nonzero. Otherwise prototypes are handled normally.
+ * to PROTOLIB is nonzero. Otherwise, prototypes are handled normally.
  */
 void
 protolib(int n)

Index: src/usr.bin/xlint/lint1/lex.c
diff -u src/usr.bin/xlint/lint1/lex.c:1.159 src/usr.bin/xlint/lint1/lex.c:1.160
--- src/usr.bin/xlint/lint1/lex.c:1.159	Fri Jun  9 13:03:49 2023
+++ src/usr.bin/xlint/lint1/lex.c	Fri Jun  9 15:36:31 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.159 2023/06/09 13:03:49 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.160 2023/06/09 15:36:31 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: lex.c,v 1.159 2023/06/09 13:03:49 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.160 2023/06/09 15:36:31 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -1115,7 +1115,7 @@ lex_comment(void)
 		}
 	}
 	arg[l] = '\0';
-	a = l != 0 ? atoi(arg) : -1;
+	a = l != 0 ? (int)atoi(arg) : -1;
 
 	/* skip whitespace after the argument */
 	while (isspace(c))

Index: src/usr.bin/xlint/lint1/lint1.h
diff -u src/usr.bin/xlint/lint1/lint1.h:1.164 src/usr.bin/xlint/lint1/lint1.h:1.165
--- src/usr.bin/xlint/lint1/lint1.h:1.164	Sat Apr 22 17:49:15 2023
+++ src/usr.bin/xlint/lint1/lint1.h	Fri Jun  9 15:36:31 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.164 2023/04/22 17:49:15 rillig Exp $ */
+/* $NetBSD: lint1.h,v 1.165 2023/06/09 15:36:31 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -110,8 +110,8 @@ typedef struct {
 	 */
 	bool	v_unsigned_since_c90;
 	union {
-		int64_t	_v_quad;	/* integers */
-		ldbl_t	_v_ldbl;	/* floats */
+		int64_t		_v_quad;	/* integers */
+		long double	_v_ldbl;	/* floats */
 	} v_u;
 } val_t;
 
@@ -375,7 +375,7 @@ typedef	struct dinfo {
 	bool	d_nonempty_decl:1; /* if at least one tag is declared
 				 * ... in the current function decl. */
 	bool	d_vararg:1;
-	bool	d_proto:1;	/* current function decl. is prototype */
+	bool	d_proto:1;	/* current function decl. is a 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_packed:1;

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.526 src/usr.bin/xlint/lint1/tree.c:1.527
--- src/usr.bin/xlint/lint1/tree.c:1.526	Fri Jun  9 13:03:49 2023
+++ src/usr.bin/xlint/lint1/tree.c	Fri Jun  9 15:36:31 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.526 2023/06/09 13:03:49 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.527 2023/06/09 15:36:31 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: tree.c,v 1.526 2023/06/09 13:03:49 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.527 2023/06/09 15:36:31 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -802,7 +802,7 @@ fold(tnode_t *tn)
 	if (is_binary(tn))
 		ur = sr = tn->tn_right->tn_val->v_quad;
 
-	mask = value_bits(size_in_bits(t));
+	mask = (int64_t)value_bits(size_in_bits(t));
 	ovfl = false;
 
 	switch (tn->tn_op) {
@@ -819,7 +819,7 @@ fold(tnode_t *tn)
 		break;
 	case MULT:
 		if (utyp) {
-			q = ul * ur;
+			q = (int64_t)(ul * ur);
 			if (q != (q & mask))
 				ovfl = true;
 			else if ((ul != 0) && ((q / ul) != ur))
@@ -873,7 +873,7 @@ fold(tnode_t *tn)
 		 * shifts of signed values are implementation dependent.
 		 */
 		/* TODO: warn about out-of-bounds 'sr'. */
-		q = ul >> (sr & 63);
+		q = (int64_t)(ul >> (sr & 63));
 		q = convert_integer(q, t, size_in_bits(t) - (int)sr);
 		break;
 	case LT:
@@ -1003,7 +1003,7 @@ subt_size_in_bytes(type_t *tp)
 		break;
 	case STRUCT:
 	case UNION:
-		if ((elsz_in_bits = tp->t_sou->sou_size_in_bits) == 0)
+		if ((elsz_in_bits = (int)tp->t_sou->sou_size_in_bits) == 0)
 			/* cannot do pointer arithmetic on operand of ... */
 			error(136);
 		break;
@@ -1541,8 +1541,8 @@ fold_bool(tnode_t *tn)
 	return build_constant(tn->tn_type, v);
 }
 
-static ldbl_t
-floating_error_value(tspec_t t, ldbl_t lv)
+static long double
+floating_error_value(tspec_t t, long double lv)
 {
 	if (t == FLOAT)
 		return lv < 0 ? -FLT_MAX : FLT_MAX;
@@ -1566,7 +1566,7 @@ floating_error_value(tspec_t t, ldbl_t l
 	 * few programs practically use 'long double'.
 	 */
 	/* LINTED 248: floating-point constant out of range */
-	ldbl_t max = LDBL_MAX;
+	long double max = LDBL_MAX;
 	return lv < 0 ? -max : max;
 }
 
@@ -1578,7 +1578,7 @@ fold_float(tnode_t *tn)
 {
 	val_t *v;
 	tspec_t t;
-	ldbl_t lv, rv = 0;
+	long double lv, rv = 0;
 
 	fpe = 0;
 	v = xcalloc(1, sizeof(*v));
@@ -1681,7 +1681,7 @@ build_binary(tnode_t *ln, op_t op, bool 
 
 	/*
 	 * Apply class conversions to the left operand, but only if its
-	 * value is needed or it is compared with zero.
+	 * value is needed or compared with zero.
 	 */
 	if (mp->m_value_context || mp->m_compares_with_zero)
 		ln = cconv(ln);
@@ -3676,7 +3676,7 @@ static void
 convert_constant_floating(op_t op, int arg, tspec_t ot, const type_t *tp,
 			  tspec_t nt, val_t *v, val_t *nv)
 {
-	ldbl_t max = 0.0, min = 0.0;
+	long double max = 0.0, min = 0.0;
 
 	switch (nt) {
 	case CHAR:
@@ -3754,7 +3754,7 @@ convert_constant_to_floating(tspec_t nt,
 		    (double)(uint64_t)v->v_quad : (double)v->v_quad;
 	} else if (nt == LDOUBLE) {
 		nv->v_ldbl = (ot == PTR || is_uinteger(ot)) ?
-		    (ldbl_t)(uint64_t)v->v_quad : (ldbl_t)v->v_quad;
+		    (long double)(uint64_t)v->v_quad : (long double)v->v_quad;
 	} else
 		return false;
 	return true;
@@ -3826,7 +3826,7 @@ convert_constant_check_range_signed(op_t
  * of the bits was set in an unsigned type or that at least one but not all
  * of the bits was set in a signed type. Loss of significant bits means that
  * it is not possible, also not with necessary casts, to convert back to the
- * original type. A example for a necessary cast is:
+ * original type. An example for a necessary cast is:
  *	char c;	int	i; c = 128;
  *	i = c;			** yields -128 **
  *	i = (unsigned char)c;	** yields 128 **
@@ -4392,7 +4392,7 @@ constant(tnode_t *tn, bool required)
 			v->v_quad = tn->tn_val->v_quad;
 			return v;
 		}
-		v->v_quad = tn->tn_val->v_ldbl;
+		v->v_quad = (int64_t)tn->tn_val->v_ldbl;
 	} else {
 		v->v_quad = 1;
 	}
@@ -4550,7 +4550,7 @@ check_expr_side_effect(const tnode_t *ln
 	if (ln->tn_op == NAME && (reached || !warn_about_unreachable)) {
 		scl_t sc = ln->tn_sym->s_scl;
 		/*
-		 * Look if there was a asm statement in one of the
+		 * Look if there was an asm statement in one of the
 		 * compound statements we are in. If not, we don't
 		 * print a warning.
 		 */
@@ -4774,7 +4774,7 @@ constant_addr(const tnode_t *tn, const s
 			return true;
 		} else {
 			/*
-			 * If this would be the front end of a compiler we
+			 * If this were the front end of a compiler, we
 			 * would return a label instead of 0, at least if
 			 * 'tn->tn_left->tn_op == STRING'.
 			 */

Reply via email to