Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint lint: fix lint warnings



details:   https://anonhg.NetBSD.org/src/rev/8686d720326b
branches:  trunk
changeset: 1018890:8686d720326b
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Feb 20 19:10:37 2021 +0000

description:
lint: fix lint warnings

No functional change.

diffstat:

 usr.bin/xlint/common/inittyp.c |   6 +++---
 usr.bin/xlint/lint1/init.c     |  35 +++++++++++++++++++++--------------
 usr.bin/xlint/lint1/tree.c     |  16 ++++++----------
 3 files changed, 30 insertions(+), 27 deletions(-)

diffs (199 lines):

diff -r 0fb0039a60f9 -r 8686d720326b usr.bin/xlint/common/inittyp.c
--- a/usr.bin/xlint/common/inittyp.c    Sat Feb 20 18:55:10 2021 +0000
+++ b/usr.bin/xlint/common/inittyp.c    Sat Feb 20 19:10:37 2021 +0000
@@ -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 @@
 /* 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)
diff -r 0fb0039a60f9 -r 8686d720326b usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c        Sat Feb 20 18:55:10 2021 +0000
+++ b/usr.bin/xlint/lint1/init.c        Sat Feb 20 19:10:37 2021 +0000
@@ -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 @@
 #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_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 @@
 
        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 @@
        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 @@
                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 @@
                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 @@
                }
                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 @@
        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();
diff -r 0fb0039a60f9 -r 8686d720326b usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Sat Feb 20 18:55:10 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Sat Feb 20 19:10:37 2021 +0000
@@ -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 @@
 }
 
 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 @@
        }
 
        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 @@
 
 /* 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 @@
 
        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))



Home | Main Index | Thread Index | Old Index