Module Name:    src
Committed By:   rillig
Date:           Sat Jan  6 14:21:26 UTC 2024

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

Log Message:
lint: remove redundant comments


To generate a diff of this commit:
cvs rdiff -u -r1.587 -r1.588 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/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.587 src/usr.bin/xlint/lint1/tree.c:1.588
--- src/usr.bin/xlint/lint1/tree.c:1.587	Sun Dec  3 18:17:41 2023
+++ src/usr.bin/xlint/lint1/tree.c	Sat Jan  6 14:21:26 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.587 2023/12/03 18:17:41 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.588 2024/01/06 14:21:26 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.587 2023/12/03 18:17:41 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.588 2024/01/06 14:21:26 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -707,10 +707,6 @@ usual_arithmetic_conversion_c90(tspec_t 
 	if (lt == FLOAT || rt == FLOAT)
 		return FLOAT;
 
-	/*
-	 * If type A has more bits than type B, it should be able to hold all
-	 * possible values of type B.
-	 */
 	if (size_in_bits(lt) > size_in_bits(rt))
 		return lt;
 	if (size_in_bits(lt) < size_in_bits(rt))
@@ -762,9 +758,6 @@ balance(op_t op, tnode_t **lnp, tnode_t 
 		*rnp = apply_usual_arithmetic_conversions(op, *rnp, t);
 }
 
-/*
- * Create a tree node for the unary & operator
- */
 static tnode_t *
 build_address(bool sys, tnode_t *tn, bool noign)
 {
@@ -938,9 +931,6 @@ fold(tnode_t *tn)
 	return cn;
 }
 
-/*
- * Create a new node for one of the operators POINT and ARROW.
- */
 static tnode_t *
 build_struct_access(op_t op, bool sys, tnode_t *ln, tnode_t *rn)
 {
@@ -1035,9 +1025,6 @@ subt_size_in_bytes(type_t *tp)
 	    (int64_t)(elem * elsz_in_bits / CHAR_SIZE));
 }
 
-/*
- * Create a node for INCAFT, INCBEF, DECAFT and DECBEF.
- */
 static tnode_t *
 build_prepost_incdec(op_t op, bool sys, tnode_t *ln)
 {
@@ -1080,11 +1067,6 @@ check_enum_array_index(const tnode_t *ln
 	if (max_enum_value == max_array_index)
 		return;
 
-	/*
-	 * If the name of the largest enum constant contains 'MAX' or 'NUM',
-	 * that constant is typically not part of the allowed enum values but a
-	 * marker for the number of actual enum values.
-	 */
 	if (max_enum_value == max_array_index + 1 &&
 	    (strstr(max_ec->s_name, "MAX") != NULL ||
 	     strstr(max_ec->s_name, "max") != NULL ||
@@ -1097,14 +1079,10 @@ check_enum_array_index(const tnode_t *ln
 	print_previous_declaration(max_ec);
 }
 
-/*
- * Create a node for operators PLUS and MINUS.
- */
 static tnode_t *
 build_plus_minus(op_t op, bool sys, tnode_t *ln, tnode_t *rn)
 {
 
-	/* If pointer and integer, move the pointer to the left. */
 	if (rn->tn_type->t_tspec == PTR && is_integer(ln->tn_type->t_tspec)) {
 		tnode_t *tmp = ln;
 		ln = rn;
@@ -1150,9 +1128,6 @@ build_plus_minus(op_t op, bool sys, tnod
 	return build_op(op, sys, ln->tn_type, ln, rn);
 }
 
-/*
- * Create a node for operators SHL and SHR.
- */
 static tnode_t *
 build_bit_shift(op_t op, bool sys, tnode_t *ln, tnode_t *rn)
 {
@@ -1207,7 +1182,6 @@ merge_qualifiers(type_t *tp1, const type
 static tnode_t *
 build_colon(bool sys, tnode_t *ln, tnode_t *rn)
 {
-
 	tspec_t lt = ln->tn_type->t_tspec;
 	tspec_t rt = rn->tn_type->t_tspec;
 
@@ -1220,7 +1194,6 @@ build_colon(bool sys, tnode_t *ln, tnode
 	} else if (lt == VOID || rt == VOID) {
 		tp = gettyp(VOID);
 	} else if (is_struct_or_union(lt)) {
-		/* Both types must be identical. */
 		lint_assert(is_struct_or_union(rt));
 		lint_assert(ln->tn_type->t_sou == rn->tn_type->t_sou);
 		if (is_incomplete(ln->tn_type)) {
@@ -1316,7 +1289,6 @@ is_assignment(op_t op)
 	    op == INIT;
 }
 
-/* Create a node for an assignment operator (both '=' and 'op='). */
 static tnode_t *
 build_assignment(op_t op, bool sys, tnode_t *ln, tnode_t *rn)
 {
@@ -1378,9 +1350,6 @@ build_assignment(op_t op, bool sys, tnod
 	return build_op(op, sys, ln->tn_type, ln, rn);
 }
 
-/*
- * Create a node for REAL, IMAG
- */
 static tnode_t *
 build_real_imag(op_t op, bool sys, tnode_t *ln)
 {
@@ -1683,16 +1652,8 @@ build_binary(tnode_t *ln, op_t op, bool 
 	if (ln == NULL || (mp->m_binary && rn == NULL))
 		return NULL;
 
-	/*
-	 * Apply class conversions to the left operand, but only if its value
-	 * is needed or compared with zero.
-	 */
 	if (mp->m_value_context || mp->m_compares_with_zero)
 		ln = cconv(ln);
-	/*
-	 * The right operand is almost always in a test or value context,
-	 * except if it is a struct or union member.
-	 */
 	if (mp->m_binary && op != ARROW && op != POINT)
 		rn = cconv(rn);
 
@@ -1713,11 +1674,6 @@ build_binary(tnode_t *ln, op_t op, bool 
 		rn = promote(op, false, rn);
 	}
 
-	/*
-	 * If the result of the operation is different for signed or unsigned
-	 * operands and one of the operands is signed only in C90, print a
-	 * warning.
-	 */
 	if (mp->m_warn_if_left_unsigned_in_c90 &&
 	    ln->tn_op == CON && ln->tn_val.v_unsigned_since_c90) {
 		/* C90 treats constant as unsigned, op '%s' */
@@ -1731,18 +1687,12 @@ build_binary(tnode_t *ln, op_t op, bool 
 		rn->tn_val.v_unsigned_since_c90 = false;
 	}
 
-	/* Make sure both operands are of the same type */
 	if (mp->m_balance_operands || (!allow_c90 && (op == SHL || op == SHR)))
 		balance(op, &ln, &rn);
 
-	/*
-	 * Check types for compatibility with the operation and mutual
-	 * compatibility. Return if there are serious problems.
-	 */
 	if (!typeok(op, 0, ln, rn))
 		return NULL;
 
-	/* And now create the node. */
 	tnode_t *ntn;
 	switch (op) {
 	case POINT:
@@ -1809,18 +1759,12 @@ build_binary(tnode_t *ln, op_t op, bool 
 		break;
 	}
 
-	/* Return if an error occurred. */
 	if (ntn == NULL)
 		return NULL;
 
-	/* Print a warning if precedence confusion is possible */
 	if (mp->m_possible_precedence_confusion)
 		check_precedence_confusion(ntn);
 
-	/*
-	 * Print a warning if one of the operands is in a context where it is
-	 * compared with zero and if this operand is a constant.
-	 */
 	if (hflag && !suppress_constcond &&
 	    mp->m_compares_with_zero &&
 	    (ln->tn_op == CON ||
@@ -1831,7 +1775,6 @@ build_binary(tnode_t *ln, op_t op, bool 
 		warning(161);
 	}
 
-	/* Fold if the operator requires it */
 	if (mp->m_fold_constant_operands) {
 		if (ln->tn_op == CON && (!mp->m_binary || rn->tn_op == CON)) {
 			if (mp->m_compares_with_zero) {
@@ -2000,10 +1943,6 @@ struct_or_union_member(tnode_t *tn, op_t
 		return msym;
 	}
 
-	/*
-	 * Now the left operand of ARROW does not point to a struct/union or
-	 * the left operand of POINT is no struct/union.
-	 */
 	if (eq) {
 		if (op == POINT) {
 			if (!allow_c90) {
@@ -2065,10 +2004,6 @@ build_member_access(tnode_t *ln, op_t op
 tnode_t *
 cconv(tnode_t *tn)
 {
-	/*
-	 * Array-lvalue (array of type T) is converted into rvalue (pointer to
-	 * type T)
-	 */
 	if (tn->tn_type->t_tspec == ARRAY) {
 		if (!tn->tn_lvalue) {
 			/* XXX print correct operator */
@@ -2079,15 +2014,9 @@ cconv(tnode_t *tn)
 		    expr_derive_type(tn->tn_type->t_subt, PTR), tn, NULL);
 	}
 
-	/*
-	 * Expression of type function (function with return value of type T)
-	 * in rvalue-expression (pointer to function with return value of type
-	 * T)
-	 */
 	if (tn->tn_type->t_tspec == FUNC)
 		tn = build_address(tn->tn_sys, tn, true);
 
-	/* lvalue to rvalue */
 	if (tn->tn_lvalue) {
 		type_t *tp = expr_dup_type(tn->tn_type);
 		/* C99 6.3.2.1p2 sentence 2 says to remove the qualifiers. */
@@ -2291,10 +2220,6 @@ typeok_shr(op_t op,
 		if (!ic_maybe_signed(ln->tn_type, &lc))
 			return;
 
-		/*
-		 * The left operand is signed. This means that the operation is
-		 * (possibly) nonportable.
-		 */
 		if (ln->tn_op != CON) {
 			/* bitwise '%s' on signed value possibly nonportable */
 			warning(117, op_name(op));
@@ -2374,10 +2299,6 @@ is_typeok_eq(const tnode_t *ln, tspec_t 
 	return false;
 }
 
-/*
- * Called if incompatible pointer types are detected.
- * Print an appropriate warning.
- */
 static void
 warn_incompatible_pointers(op_t op, const type_t *ltp, const type_t *rtp)
 {
@@ -2548,10 +2469,6 @@ typeok_colon(const tnode_t *ln, const ty
 	return false;
 }
 
-/*
- * Returns true if the given structure or union has a constant member
- * (maybe recursively).
- */
 static bool
 has_constant_member(const type_t *tp)
 {
@@ -2593,7 +2510,6 @@ typeok_assign(op_t op, const tnode_t *ln
 	return true;
 }
 
-/* Check the types using the information from modtab[]. */
 static bool
 typeok_scalar(op_t op, const mod_t *mp,
 	      const type_t *ltp, tspec_t lt,
@@ -2905,10 +2821,8 @@ check_assign_types_compatible(op_t op, i
 		return true;
 
 	if (is_struct_or_union(lt) && is_struct_or_union(rt))
-		/* both are struct or union */
 		return ltp->t_sou == rtp->t_sou;
 
-	/* a null pointer may be assigned to any pointer */
 	if (lt == PTR && is_null_pointer(rn)) {
 		if (is_integer(rn->tn_type->t_tspec))
 			/* implicit conversion from integer 0 to pointer ... */
@@ -3092,7 +3006,6 @@ typeok_op(op_t op, int arg,
 	return true;
 }
 
-/* Prints a warning if a strange operator is used on an enum type. */
 static void
 check_bad_enum_operation(op_t op, const tnode_t *ln, const tnode_t *rn)
 {
@@ -3111,7 +3024,6 @@ check_bad_enum_operation(op_t op, const 
 	warning(241, op_name(op));
 }
 
-/* Prints a warning if an operator is applied to two different enum types. */
 static void
 check_enum_type_mismatch(op_t op, int arg, const tnode_t *ln, const tnode_t *rn)
 {
@@ -3146,7 +3058,6 @@ check_enum_type_mismatch(op_t op, int ar
 		warning(243, op_name(op), type_name(ln->tn_type));
 }
 
-/* Prints a warning if the operands mix between enum and integer. */
 static void
 check_enum_int_mismatch(op_t op, int arg, const tnode_t *ln, const tnode_t *rn)
 {
@@ -3381,7 +3292,6 @@ check_prototype_conversion(int arg, tspe
 	    nt == SHORT || nt == USHORT)
 		return;
 
-	/* apply the default promotion */
 	tnode_t *ptn = promote(NOOP, true, tn);
 	ot = ptn->tn_type->t_tspec;
 
@@ -3802,11 +3712,6 @@ convert_constant_check_range_bitor(size_
 	}
 }
 
-/*
- * Print a warning if additional bits are not all 1
- * and the most significant bit of the old value is 1,
- * or if at least one (but not all) removed bit was 0.
- */
 static void
 convert_constant_check_range_bitand(size_t nsz, size_t osz,
 				    uint64_t xmask, const val_t *nv,
@@ -3918,10 +3823,6 @@ convert_constant_check_range(tspec_t ot,
 	nbitsz = tp->t_bitfield ? tp->t_bit_field_width : size_in_bits(nt);
 	xmask = value_bits(nbitsz) ^ value_bits(obitsz);
 	xmsk1 = value_bits(nbitsz) ^ value_bits(obitsz - 1);
-	/*
-	 * For bitwise operations we are not interested in the arithmetic
-	 * value, but in the bits itself.
-	 */
 	if (op == ORASS || op == BITOR || op == BITXOR) {
 		convert_constant_check_range_bitor(
 		    nbitsz, obitsz, v, xmask, op);
@@ -3991,9 +3892,6 @@ convert_constant(op_t op, int arg, const
 		convert_constant_check_range(ot, tp, nt, op, arg, v, nv);
 }
 
-/*
- * Create a constant node for sizeof.
- */
 tnode_t *
 build_sizeof(const type_t *tp)
 {
@@ -4004,9 +3902,6 @@ build_sizeof(const type_t *tp)
 	return tn;
 }
 
-/*
- * Create a constant node for offsetof.
- */
 tnode_t *
 build_offsetof(const type_t *tp, const sym_t *sym)
 {
@@ -4148,9 +4043,6 @@ cast_to_union(tnode_t *otn, type_t *ntp)
 	return NULL;
 }
 
-/*
- * Type casts.
- */
 tnode_t *
 cast(tnode_t *tn, type_t *tp)
 {
@@ -4310,7 +4202,6 @@ check_function_arguments(type_t *ftp, tn
 			warning(152, n);
 		}
 
-		/* class conversions (arg in value context) */
 		arg->tn_left = cconv(arg->tn_left);
 
 		if (param != NULL) {
@@ -4327,10 +4218,6 @@ check_function_arguments(type_t *ftp, tn
 	return args;
 }
 
-/*
- * Create the node for a function call. Also check types of
- * function arguments and insert conversions, if necessary.
- */
 tnode_t *
 build_function_call(tnode_t *func, bool sys, tnode_t *args)
 {
@@ -4343,7 +4230,6 @@ build_function_call(tnode_t *func, bool 
 
 	check_ctype_function_call(func, args);
 
-	/* Turn the function name into a pointer to the function. */
 	func = cconv(func);
 
 	if (func->tn_type->t_tspec != PTR ||
@@ -4460,7 +4346,6 @@ expr(tnode_t *tn, bool vctx, bool cond, 
 	}
 	debug_node(tn);
 
-	/* free the tree memory */
 	if (dofreeblk)
 		expr_free_all();
 }
@@ -4497,7 +4382,6 @@ check_array_index(tnode_t *tn, bool ampe
 	if (is_incomplete(ln->tn_left->tn_type) && rn->tn_val.u.integer >= 0)
 		return;
 
-	/* Get the size of one array element */
 	int elsz = length_in_bits(ln->tn_type->t_subt, NULL);
 	if (elsz == 0)
 		return;
@@ -4529,7 +4413,6 @@ check_expr_addr(const tnode_t *ln, bool 
 		mark_as_used(ln->tn_sym, fcall, szof);
 	}
 	if (ln->tn_op == INDIR && ln->tn_left->tn_op == PLUS)
-		/* check the range of array indices */
 		check_array_index(ln->tn_left, true);
 }
 
@@ -4537,7 +4420,6 @@ static void
 check_expr_load(const tnode_t *ln)
 {
 	if (ln->tn_op == INDIR && ln->tn_left->tn_op == PLUS)
-		/* check the range of array indices */
 		check_array_index(ln->tn_left, false);
 }
 

Reply via email to