Module Name:    src
Committed By:   rillig
Date:           Sat Feb 20 19:10:38 UTC 2021

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

Log Message:
lint: fix lint warnings

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/xlint/common/inittyp.c
cvs rdiff -u -r1.73 -r1.74 src/usr.bin/xlint/lint1/init.c
cvs rdiff -u -r1.211 -r1.212 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/inittyp.c
diff -u src/usr.bin/xlint/common/inittyp.c:1.18 src/usr.bin/xlint/common/inittyp.c:1.19
--- src/usr.bin/xlint/common/inittyp.c:1.18	Sun Jan 24 14:47:43 2021
+++ src/usr.bin/xlint/common/inittyp.c	Sat Feb 20 19:10:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: inittyp.c,v 1.18 2021/01/24 14:47:43 rillig Exp $	*/
+/*	$NetBSD: inittyp.c,v 1.19 2021/02/20 19:10:37 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: inittyp.c,v 1.18 2021/01/24 14:47:43 rillig Exp $");
+__RCSID("$NetBSD: inittyp.c,v 1.19 2021/02/20 19:10:37 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -48,7 +48,7 @@ __RCSID("$NetBSD: inittyp.c,v 1.18 2021/
 /* various type information */
 ttab_t	ttab[NTSPEC];
 
-#define INT_RSIZE	(INTPTR_TSPEC == LONG ? 3 : 4)
+#define INT_RSIZE	(/*CONSTCOND*/INTPTR_TSPEC == LONG ? 3 : 4)
 
 void
 inittyp(void)

Index: src/usr.bin/xlint/lint1/init.c
diff -u src/usr.bin/xlint/lint1/init.c:1.73 src/usr.bin/xlint/lint1/init.c:1.74
--- src/usr.bin/xlint/lint1/init.c:1.73	Sat Feb 20 17:44:39 2021
+++ src/usr.bin/xlint/lint1/init.c	Sat Feb 20 19:10:38 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: init.c,v 1.73 2021/02/20 17:44:39 rillig Exp $	*/
+/*	$NetBSD: init.c,v 1.74 2021/02/20 19:10:38 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.73 2021/02/20 17:44:39 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.74 2021/02/20 19:10:38 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -228,11 +228,15 @@ debug_named_member(void)
 #endif
 
 #ifdef DEBUG
+static const char *
+noyes(bool cond)
+{
+	return cond ? "yes" : "no";
+}
+
 static void
 debug_initstack(void)
 {
-	static const char *const noyes[] = { "no", "yes" };
-
 	if (initstk == NULL) {
 		debug_step("initstk is empty");
 		return;
@@ -243,9 +247,9 @@ debug_initstack(void)
 		debug_step("initstk[%zu]:", i);
 		debug_step("  i_type      = %s", type_name(elem->i_type));
 		debug_step("  i_subt      = %s", type_name(elem->i_subt));
-		debug_step("  i_brace     = %s", noyes[elem->i_brace]);
-		debug_step("  i_nolimit   = %s", noyes[elem->i_nolimit]);
-		debug_step("  i_namedmem  = %s", noyes[elem->i_namedmem]);
+		debug_step("  i_brace     = %s", noyes(elem->i_brace));
+		debug_step("  i_nolimit   = %s", noyes(elem->i_nolimit));
+		debug_step("  i_namedmem  = %s", noyes(elem->i_namedmem));
 		debug_step("  i_mem       = %s",
 		    elem->i_mem != NULL ? elem->i_mem->s_name : "(null)");
 		debug_step("  i_remaining = %d", elem->i_remaining);
@@ -301,7 +305,7 @@ initstack_pop_item(void)
 
 	istk = initstk;
 	debug_step("pop type=%s, brace=%d remaining=%d named=%d",
-	    type_name(istk->i_type ? istk->i_type : istk->i_subt),
+	    type_name(istk->i_type != NULL ? istk->i_type : istk->i_subt),
 	    istk->i_brace, istk->i_remaining, istk->i_namedmem);
 
 	initstk = istk->i_next;
@@ -310,14 +314,14 @@ initstack_pop_item(void)
 	lint_assert(istk != NULL);
 
 	debug_step("top type=%s, brace=%d remaining=%d named=%d",
-	    type_name(istk->i_type ? istk->i_type : istk->i_subt),
+	    type_name(istk->i_type != NULL ? istk->i_type : istk->i_subt),
 	    istk->i_brace, istk->i_remaining, istk->i_namedmem);
 
 	istk->i_remaining--;
 	lint_assert(istk->i_remaining >= 0);
 
 	debug_step("top remaining=%d rhs.name=%s",
-	    istk->i_remaining, namedmem ? namedmem->n_name : "*null*");
+	    istk->i_remaining, namedmem != NULL ? namedmem->n_name : "*null*");
 
 	if (istk->i_remaining >= 0 && namedmem != NULL) {
 
@@ -467,7 +471,7 @@ again:
 		istk->i_remaining = istk->i_type->t_dim;
 		debug_step("elements array %s[%d] %s",
 		    type_name(istk->i_subt), istk->i_remaining,
-		    namedmem ? namedmem->n_name : "*none*");
+		    namedmem != NULL ? namedmem->n_name : "*none*");
 		break;
 	case UNION:
 		if (tflag)
@@ -486,7 +490,8 @@ again:
 		cnt = 0;
 		debug_step("lookup type=%s, name=%s named=%d",
 		    type_name(istk->i_type),
-		    namedmem ? namedmem->n_name : "*none*", istk->i_namedmem);
+		    namedmem != NULL ? namedmem->n_name : "*none*",
+		    istk->i_namedmem);
 		for (m = istk->i_type->t_str->sou_first_member;
 		     m != NULL; m = m->s_next) {
 			if (m->s_bitfield && m->s_name == unnamed)
@@ -519,7 +524,8 @@ again:
 		}
 		istk->i_brace = true;
 		debug_step("unnamed type=%s, brace=%d",
-		    type_name(istk->i_type ? istk->i_type : istk->i_subt),
+		    type_name(
+			istk->i_type != NULL ? istk->i_type : istk->i_subt),
 		    istk->i_brace);
 		if (cnt == 0) {
 			/* cannot init. struct/union with no named member */
@@ -598,7 +604,8 @@ initstack_next_brace(void)
 	if (!initerr) {
 		initstk->i_brace = true;
 		debug_step("%p %s", namedmem, type_name(
-			initstk->i_type ? initstk->i_type : initstk->i_subt));
+		    initstk->i_type != NULL ? initstk->i_type
+			: initstk->i_subt));
 	}
 
 	debug_initstack();

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.211 src/usr.bin/xlint/lint1/tree.c:1.212
--- src/usr.bin/xlint/lint1/tree.c:1.211	Sat Feb 20 18:55:10 2021
+++ src/usr.bin/xlint/lint1/tree.c	Sat Feb 20 19:10:38 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.211 2021/02/20 18:55:10 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.212 2021/02/20 19:10:38 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.211 2021/02/20 18:55:10 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.212 2021/02/20 19:10:38 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -1009,9 +1009,7 @@ typeok_quest(tspec_t lt, const tnode_t *
 }
 
 static void
-typeok_colon_pointer(const mod_t *mp,
-		     const tnode_t *ln, const type_t *ltp,
-		     const tnode_t *rn, const type_t *rtp)
+typeok_colon_pointer(const mod_t *mp, const type_t *ltp, const type_t *rtp)
 {
 	type_t *lstp = ltp->t_subt;
 	type_t *rstp = rtp->t_subt;
@@ -1071,7 +1069,7 @@ typeok_colon(const mod_t *mp,
 	}
 
 	if (lt == PTR && rt == PTR) {
-		typeok_colon_pointer(mp, ln, ltp, rn, rtp);
+		typeok_colon_pointer(mp, ltp, rtp);
 		return true;
 	}
 
@@ -1259,9 +1257,7 @@ typeok_scalar_strict_bool(op_t op, const
 
 /* Check the types using the information from modtab[]. */
 static bool
-typeok_scalar(op_t op, const mod_t *mp,
-	      const tnode_t *ln, tspec_t lt,
-	      const tnode_t *rn, tspec_t rt)
+typeok_scalar(op_t op, const mod_t *mp, tspec_t lt, tspec_t rt)
 {
 	if (mp->m_takes_bool && lt == BOOL && rt == BOOL)
 		return true;
@@ -1490,7 +1486,7 @@ typeok(op_t op, int arg, const tnode_t *
 
 	if (Tflag && !typeok_scalar_strict_bool(op, mp, arg, ln, rn))
 		return false;
-	if (!typeok_scalar(op, mp, ln, lt, rn, rt))
+	if (!typeok_scalar(op, mp, lt, rt))
 		return false;
 
 	if (!typeok_op(op, mp, arg, ln, ltp, lt, rn, rtp, rt))

Reply via email to