Module Name:    src
Committed By:   rillig
Date:           Sat Oct  1 10:04:06 UTC 2022

Modified Files:
        src/tests/usr.bin/xlint/lint2: emit.ln msg_001.ln
        src/usr.bin/xlint/lint1: decl.c lex.c tree.c

Log Message:
lint: miscellaneous cleanup

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint2/emit.ln
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint2/msg_001.ln
cvs rdiff -u -r1.301 -r1.302 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.133 -r1.134 src/usr.bin/xlint/lint1/lex.c
cvs rdiff -u -r1.481 -r1.482 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/lint2/emit.ln
diff -u src/tests/usr.bin/xlint/lint2/emit.ln:1.5 src/tests/usr.bin/xlint/lint2/emit.ln:1.6
--- src/tests/usr.bin/xlint/lint2/emit.ln:1.5	Sat Jan 15 17:33:42 2022
+++ src/tests/usr.bin/xlint/lint2/emit.ln	Sat Oct  1 10:04:06 2022
@@ -1,4 +1,4 @@
-# $NetBSD: emit.ln,v 1.5 2022/01/15 17:33:42 rillig Exp $
+# $NetBSD: emit.ln,v 1.6 2022/10/01 10:04:06 rillig Exp $
 #
 # Test emitting a lint library file.
 
@@ -25,8 +25,8 @@ S emit.c
 122 d 0.122 e 38return_implicit_int_unknown_parameters F I
 125 d 0.125 e 32extern_return_void_no_parameters F0 V
 
-# Function calls are not part of a library's interface, therefore they are
-# omitted from the output.
+# Function calls are written as 'c'.  They are not part of a library's
+# interface, therefore they are omitted from the output.
 161 c 0.161 s2"%" i 9my_printf f2 PcC PC V
 
 # Function definitions are copied to the output.

Index: src/tests/usr.bin/xlint/lint2/msg_001.ln
diff -u src/tests/usr.bin/xlint/lint2/msg_001.ln:1.4 src/tests/usr.bin/xlint/lint2/msg_001.ln:1.5
--- src/tests/usr.bin/xlint/lint2/msg_001.ln:1.4	Tue Aug 24 23:38:51 2021
+++ src/tests/usr.bin/xlint/lint2/msg_001.ln	Sat Oct  1 10:04:06 2022
@@ -1,4 +1,4 @@
-# $NetBSD: msg_001.ln,v 1.4 2021/08/24 23:38:51 rillig Exp $
+# $NetBSD: msg_001.ln,v 1.5 2022/10/01 10:04:06 rillig Exp $
 #
 # Test data for message 1 of lint2:
 #	%s defined( %s ), but never used
@@ -16,7 +16,7 @@ S msg_001.c
 # extern main() {}
 12 d 0.12 e 4main F I
 
-# If a function is declared once in old style and once with prototype,
+# If a function is declared once in old-style and once with prototype,
 # the prototype definition is preferred; see chkname.
 #
 # extern merge_old_style_and_prototype();

Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.301 src/usr.bin/xlint/lint1/decl.c:1.302
--- src/usr.bin/xlint/lint1/decl.c:1.301	Sat Oct  1 09:59:40 2022
+++ src/usr.bin/xlint/lint1/decl.c	Sat Oct  1 10:04:06 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.301 2022/10/01 09:59:40 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.302 2022/10/01 10:04:06 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.301 2022/10/01 09:59:40 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.302 2022/10/01 10:04:06 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -252,8 +252,8 @@ dcs_add_storage_class(scl_t sc)
  * dcs_end_type to build the type used for all declarators in this
  * declaration.
  *
- * If tp->t_typedef is 1, the type comes from a previously defined typename.
- * Otherwise it comes from a type specifier (int, long, ...) or a
+ * If tp->t_typedef is true, the type comes from a previously defined
+ * typename. Otherwise, it comes from a type specifier (int, long, ...) or a
  * struct/union/enum tag.
  */
 void
@@ -596,6 +596,7 @@ end_declaration_level(void)
 	lint_assert(dcs->d_enclosing != NULL);
 	di = dcs;
 	dcs = di->d_enclosing;
+
 	switch (di->d_kind) {
 	case DK_MOS:
 	case DK_MOU:
@@ -642,7 +643,7 @@ end_declaration_level(void)
 		rmsyms(di->d_dlsyms);
 		break;
 	case DK_EXTERN:
-		/* there is nothing after external declarations */
+		/* there is nothing around an external declarations */
 		/* FALLTHROUGH */
 	default:
 		lint_assert(/*CONSTCOND*/false);
@@ -1862,11 +1863,11 @@ complete_tag_struct_or_union(type_t *tp,
 }
 
 type_t *
-complete_tag_enum(type_t *tp, sym_t *fmem)
+complete_tag_enum(type_t *tp, sym_t *first_enumerator)
 {
 
 	tp->t_enum->en_incomplete = false;
-	tp->t_enum->en_first_enumerator = fmem;
+	tp->t_enum->en_first_enumerator = first_enumerator;
 	return tp;
 }
 
@@ -2974,11 +2975,11 @@ mark_as_used(sym_t *sym, bool fcall, boo
 		UNIQUE_CURR_POS(sym->s_use_pos);
 	}
 	/*
-	 * for function calls another record is written
+	 * For function calls, another record is written.
 	 *
-	 * XXX Should symbols used in sizeof() be treated as used or not?
-	 * Probably not, because there is no sense to declare an
-	 * external variable only to get their size.
+	 * XXX: Should symbols used in sizeof() be treated as used or not?
+	 * Probably not, because there is no point in declaring an external
+	 * variable only to get its size.
 	 */
 	if (!fcall && !szof && sym->s_kind == FVFT && sym->s_scl == EXTERN)
 		outusg(sym);

Index: src/usr.bin/xlint/lint1/lex.c
diff -u src/usr.bin/xlint/lint1/lex.c:1.133 src/usr.bin/xlint/lint1/lex.c:1.134
--- src/usr.bin/xlint/lint1/lex.c:1.133	Thu Aug 25 19:03:47 2022
+++ src/usr.bin/xlint/lint1/lex.c	Sat Oct  1 10:04:06 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.133 2022/08/25 19:03:47 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.134 2022/10/01 10:04:06 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.133 2022/08/25 19:03:47 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.134 2022/10/01 10:04:06 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -636,18 +636,17 @@ lex_integer_constant(const char *yytext,
 /*
  * Extend or truncate q to match t.  If t is signed, sign-extend.
  *
- * len is the number of significant bits. If len is -1, len is set
+ * len is the number of significant bits. If len is 0, len is set
  * to the width of type t.
  */
 int64_t
 convert_integer(int64_t q, tspec_t t, unsigned int len)
 {
-	uint64_t vbits;
 
 	if (len == 0)
 		len = size_in_bits(t);
 
-	vbits = value_bits(len);
+	uint64_t vbits = value_bits(len);
 	return t == PTR || is_uinteger(t) || ((q & bit(len - 1)) == 0)
 	    ? (int64_t)(q & vbits)
 	    : (int64_t)(q | ~vbits);
@@ -710,8 +709,8 @@ lex_floating_constant(const char *yytext
 			errno = 0;
 			break;
 		default:
-			INTERNAL_ERROR("lex_floating_constant(%s->%s)",
-			    cp, eptr);
+			INTERNAL_ERROR("lex_floating_constant(%.*s)",
+			    (int)(eptr - cp), cp);
 		}
 	}
 	if (errno != 0)
@@ -729,11 +728,10 @@ lex_floating_constant(const char *yytext
 
 	yylval.y_val = xcalloc(1, sizeof(*yylval.y_val));
 	yylval.y_val->v_tspec = typ;
-	if (typ == FLOAT) {
+	if (typ == FLOAT)
 		yylval.y_val->v_ldbl = f;
-	} else {
+	else
 		yylval.y_val->v_ldbl = d;
-	}
 
 	return T_CON;
 }
@@ -863,7 +861,7 @@ get_escaped_char(int delim)
 			return -2;
 		}
 		return c;
-	case 0:
+	case '\0':
 		/* syntax error '%s' */
 		error(249, "EOF or null byte in literal");
 		return -2;

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.481 src/usr.bin/xlint/lint1/tree.c:1.482
--- src/usr.bin/xlint/lint1/tree.c:1.481	Sat Oct  1 09:42:40 2022
+++ src/usr.bin/xlint/lint1/tree.c	Sat Oct  1 10:04:06 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.481 2022/10/01 09:42:40 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.482 2022/10/01 10:04:06 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.481 2022/10/01 09:42:40 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.482 2022/10/01 10:04:06 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -3357,6 +3357,7 @@ build_colon(bool sys, tnode_t *ln, tnode
 	return ntn;
 }
 
+/* TODO: check for varargs */
 static bool
 is_cast_redundant(const tnode_t *tn)
 {

Reply via email to