Module Name:    src
Committed By:   rillig
Date:           Thu Feb  8 20:59:20 UTC 2024

Modified Files:
        src/usr.bin/xlint/lint1: decl.c lex.c tree.c

Log Message:
lint: clean up variable names, parameter order, comments

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.392 -r1.393 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.216 -r1.217 src/usr.bin/xlint/lint1/lex.c
cvs rdiff -u -r1.604 -r1.605 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/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.392 src/usr.bin/xlint/lint1/decl.c:1.393
--- src/usr.bin/xlint/lint1/decl.c:1.392	Thu Feb  8 20:45:20 2024
+++ src/usr.bin/xlint/lint1/decl.c	Thu Feb  8 20:59:19 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.392 2024/02/08 20:45:20 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.393 2024/02/08 20:59:19 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.392 2024/02/08 20:45:20 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.393 2024/02/08 20:59:19 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -1341,8 +1341,8 @@ add_function(sym_t *decl, struct paramet
 	debug_dcs_all();
 	debug_sym("decl: ", decl, "\n");
 #ifdef DEBUG
-	for (const sym_t *arg = params.first; arg != NULL; arg = arg->s_next)
-		debug_sym("arg: ", arg, "\n");
+	for (const sym_t *p = params.first; p != NULL; p = p->s_next)
+		debug_sym("param: ", p, "\n");
 #endif
 
 	if (params.prototype) {

Index: src/usr.bin/xlint/lint1/lex.c
diff -u src/usr.bin/xlint/lint1/lex.c:1.216 src/usr.bin/xlint/lint1/lex.c:1.217
--- src/usr.bin/xlint/lint1/lex.c:1.216	Thu Feb  8 20:45:20 2024
+++ src/usr.bin/xlint/lint1/lex.c	Thu Feb  8 20:59:19 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.216 2024/02/08 20:45:20 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.217 2024/02/08 20:59:19 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.216 2024/02/08 20:45:20 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.217 2024/02/08 20:59:19 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -705,7 +705,7 @@ lex_operator(int t, op_t o)
 }
 
 static buffer *
-read_quoted(bool *complete, bool wide, char delim)
+read_quoted(bool *complete, char delim, bool wide)
 {
 	buffer *buf = xcalloc(1, sizeof(*buf));
 	buf_init(buf);
@@ -947,7 +947,7 @@ static buffer *
 lex_quoted(char delim, bool wide)
 {
 	bool complete;
-	buffer *buf = read_quoted(&complete, wide, delim);
+	buffer *buf = read_quoted(&complete, delim, wide);
 	check_quoted(buf, complete, delim);
 	return buf;
 }

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.604 src/usr.bin/xlint/lint1/tree.c:1.605
--- src/usr.bin/xlint/lint1/tree.c:1.604	Thu Feb  8 20:45:20 2024
+++ src/usr.bin/xlint/lint1/tree.c	Thu Feb  8 20:59:19 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.604 2024/02/08 20:45:20 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.605 2024/02/08 20:59:19 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.604 2024/02/08 20:45:20 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.605 2024/02/08 20:59:19 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -321,9 +321,8 @@ ic_expr(const tnode_t *tn)
 type_t *
 block_derive_type(type_t *tp, tspec_t t)
 {
-	type_t *tp2;
 
-	tp2 = block_zero_alloc(sizeof(*tp2), "type");
+	type_t *tp2 = block_zero_alloc(sizeof(*tp2), "type");
 	tp2->t_tspec = t;
 	tp2->t_subt = tp;
 	return tp2;
@@ -336,9 +335,8 @@ block_derive_type(type_t *tp, tspec_t t)
 type_t *
 expr_derive_type(type_t *tp, tspec_t t)
 {
-	type_t *tp2;
 
-	tp2 = expr_zero_alloc(sizeof(*tp2), "type");
+	type_t *tp2 = expr_zero_alloc(sizeof(*tp2), "type");
 	tp2->t_tspec = t;
 	tp2->t_subt = tp;
 	return tp2;
@@ -3806,55 +3804,48 @@ convert_constant_check_range(tspec_t ot,
 		warn_constant_check_range_loss(op, arg, tp, ot);
 }
 
-/*-
- * Converts a typed constant to a constant of another type.
- *
- * op		operator which requires conversion
- * arg		if op is FARG, # of parameter
- * tp		type to which to convert the constant
- * nv		new constant
- * v		old constant
- */
+/* Converts a typed constant to a constant of another type. */
 void
-convert_constant(op_t op, int arg, const type_t *tp, val_t *nv, val_t *v)
+convert_constant(op_t op, int arg, const type_t *ntp, val_t *nv, val_t *ov)
 {
 	/*
-	 * TODO: make 'v' const; the name of this function does not suggest
-	 *  that it modifies 'v'.
+	 * TODO: make 'ov' const; the name of this function does not suggest
+	 *  that it modifies 'ov'.
 	 */
-	tspec_t ot = v->v_tspec;
-	tspec_t nt = nv->v_tspec = tp->t_tspec;
+	tspec_t ot = ov->v_tspec;
+	tspec_t nt = nv->v_tspec = ntp->t_tspec;
 	bool range_check = false;
 
 	if (nt == BOOL) {	/* C99 6.3.1.2 */
 		nv->v_unsigned_since_c90 = false;
-		nv->u.integer = is_nonzero_val(v) ? 1 : 0;
+		nv->u.integer = is_nonzero_val(ov) ? 1 : 0;
 		return;
 	}
 
 	if (ot == FLOAT || ot == DOUBLE || ot == LDOUBLE)
-		convert_constant_floating(op, arg, ot, tp, nt, v, nv);
-	else if (!convert_constant_to_floating(nt, nv, ot, v)) {
+		convert_constant_floating(op, arg, ot, ntp, nt, ov, nv);
+	else if (!convert_constant_to_floating(nt, nv, ot, ov)) {
 		range_check = true;	/* Check for lost precision. */
-		nv->u.integer = v->u.integer;
+		nv->u.integer = ov->u.integer;
 	}
 
-	if (allow_trad && allow_c90 && v->v_unsigned_since_c90 &&
+	if (allow_trad && allow_c90 && ov->v_unsigned_since_c90 &&
 	    (is_floating(nt) || (
 		(is_integer(nt) && !is_uinteger(nt) &&
 		    portable_rank_cmp(nt, ot) > 0)))) {
 		/* C90 treats constant as unsigned */
 		warning(157);
-		v->v_unsigned_since_c90 = false;
+		ov->v_unsigned_since_c90 = false;
 	}
 
 	if (is_integer(nt)) {
-		nv->u.integer = convert_integer(nv->u.integer, nt,
-		    tp->t_bitfield ? tp->t_bit_field_width : size_in_bits(nt));
+		unsigned int size = ntp->t_bitfield
+		    ? ntp->t_bit_field_width : size_in_bits(nt);
+		nv->u.integer = convert_integer(nv->u.integer, nt, size);
 	}
 
 	if (range_check && op != CVT)
-		convert_constant_check_range(ot, tp, nt, op, arg, v, nv);
+		convert_constant_check_range(ot, ntp, nt, op, arg, ov, nv);
 }
 
 tnode_t *

Reply via email to