Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/xlint/lint1 lint: replace simple LERROR with lint_as...



details:   https://anonhg.NetBSD.org/src/rev/7b9ca54dd723
branches:  trunk
changeset: 958328:7b9ca54dd723
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Jan 01 09:28:22 2021 +0000

description:
lint: replace simple LERROR with lint_assert

diffstat:

 usr.bin/xlint/lint1/cgram.y |   7 +++----
 usr.bin/xlint/lint1/decl.c  |  31 ++++++++++++++-----------------
 usr.bin/xlint/lint1/emit1.c |   8 ++++----
 usr.bin/xlint/lint1/scan.l  |  27 +++++++++++----------------
 4 files changed, 32 insertions(+), 41 deletions(-)

diffs (265 lines):

diff -r eb4cb7457248 -r 7b9ca54dd723 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Fri Jan 01 09:11:40 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Fri Jan 01 09:28:22 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.123 2021/01/01 01:26:02 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.124 2021/01/01 09:28:22 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.123 2021/01/01 01:26:02 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.124 2021/01/01 09:28:22 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -2126,8 +2126,7 @@
        switch (dcs->d_ctx) {
        case EXTERN:
                if (renaming != NULL) {
-                       if (decl->s_rename != NULL)
-                               LERROR("idecl(rename)");
+                       lint_assert(decl->s_rename == NULL);
 
                        s = getlblk(1, renaming->sb_len + 1);
                        (void)memcpy(s, renaming->sb_name, renaming->sb_len + 1);
diff -r eb4cb7457248 -r 7b9ca54dd723 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Fri Jan 01 09:11:40 2021 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Fri Jan 01 09:28:22 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.92 2021/01/01 09:11:40 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.93 2021/01/01 09:28:22 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.92 2021/01/01 09:11:40 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.93 2021/01/01 09:28:22 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -615,7 +615,7 @@
        switch (di->d_ctx) {
        case EXTERN:
                /* there is nothing after external declarations */
-               LERROR("popdecl()");
+               lint_assert(0);
                /* NOTREACHED */
        case MOS:
        case MOU:
@@ -663,7 +663,7 @@
                rmsyms(di->d_dlsyms);
                break;
        default:
-               LERROR("popdecl()");
+               lint_assert(0);
        }
        free(di);
 }
@@ -1532,10 +1532,9 @@
                        sym->s_def = TDEF;
                } else if (sc == TYPEDEF) {
                        sym->s_def = DEF;
-               } else if (sc == EXTERN) {
+               } else {
+                       lint_assert(sc == EXTERN);
                        sym->s_def = DECL;
-               } else {
-                       LERROR("declarator_name()");
                }
                break;
        case PARG:
@@ -1544,11 +1543,10 @@
        case ARG:
                if ((sc = dcs->d_scl) == NOSCL) {
                        sc = AUTO;
-               } else if (sc == REG) {
+               } else {
+                       lint_assert(sc == REG);
                        sym->s_reg = 1;
                        sc = AUTO;
-               } else {
-                       LERROR("declarator_name()");
                }
                sym->s_def = DEF;
                break;
@@ -1568,14 +1566,13 @@
                        sym->s_reg = 1;
                        sc = AUTO;
                        sym->s_def = DEF;
-               } else if (sc == EXTERN) {
+               } else {
+                       lint_assert(sc == EXTERN);
                        sym->s_def = DECL;
-               } else {
-                       LERROR("declarator_name()");
                }
                break;
        default:
-               LERROR("declarator_name()");
+               lint_assert(0);
        }
        sym->s_scl = sc;
 
@@ -1757,7 +1754,7 @@
        case STRTAG:    s = "struct";   break;
        case UNIONTAG:  s = "union";    break;
        case ENUMTAG:   s = "enum";     break;
-       default:        LERROR("tagttoa()");
+       default:        lint_assert(0);
        }
        return s;
 }
@@ -2636,7 +2633,7 @@
                                 */
                                break;
                        default:
-                               LERROR("decl1loc()");
+                               lint_assert(0);
                        }
 
                } else if (dcs->d_rdcsym->s_blklev == blklev) {
@@ -3078,7 +3075,7 @@
                warning(235, sym->s_name);
                break;
        default:
-               LERROR("check_tag_usage()");
+               lint_assert(0);
        }
 }
 
diff -r eb4cb7457248 -r 7b9ca54dd723 usr.bin/xlint/lint1/emit1.c
--- a/usr.bin/xlint/lint1/emit1.c       Fri Jan 01 09:11:40 2021 +0000
+++ b/usr.bin/xlint/lint1/emit1.c       Fri Jan 01 09:28:22 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: emit1.c,v 1.30 2021/01/01 09:11:40 rillig Exp $ */
+/* $NetBSD: emit1.c,v 1.31 2021/01/01 09:28:22 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: emit1.c,v 1.30 2021/01/01 09:11:40 rillig Exp $");
+__RCSID("$NetBSD: emit1.c,v 1.31 2021/01/01 09:28:22 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -128,7 +128,7 @@
                case DCOMPLEX:  t = 'X';        s = '\0';       break;
                case LCOMPLEX:  t = 'X';        s = 'l';        break;
                default:
-                       LERROR("outtyp()");
+                       lint_assert(0);
                }
                if (tp->t_const)
                        outchar('c');
@@ -268,7 +268,7 @@
                outchar('e');
                break;
        default:
-               LERROR("outsym()");
+               lint_assert(0);
        }
        if (llibflg && def != DECL) {
                /*
diff -r eb4cb7457248 -r 7b9ca54dd723 usr.bin/xlint/lint1/scan.l
--- a/usr.bin/xlint/lint1/scan.l        Fri Jan 01 09:11:40 2021 +0000
+++ b/usr.bin/xlint/lint1/scan.l        Fri Jan 01 09:28:22 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: scan.l,v 1.106 2021/01/01 01:26:02 rillig Exp $ */
+/* $NetBSD: scan.l,v 1.107 2021/01/01 09:28:22 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: scan.l,v 1.106 2021/01/01 01:26:02 rillig Exp $");
+__RCSID("$NetBSD: scan.l,v 1.107 2021/01/01 09:28:22 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -505,8 +505,7 @@
        sb->sb_sym = sym;
 
        if (sym != NULL) {
-               if (blklev < sym->s_blklev)
-                       LERROR("name()");
+               lint_assert(blklev >= sym->s_blklev);
                sb->sb_name = sym->s_name;
                sb->sb_len = strlen(sym->s_name);
                tok = sym->s_scl == TYPEDEF ? T_TYPENAME : T_NAME;
@@ -621,8 +620,7 @@
        errno = 0;
 
        uq = strtouq(cp, &eptr, base);
-       if (eptr != cp + len)
-               LERROR("icon()");
+       lint_assert(eptr == cp + len);
        if (errno != 0)
                /* integer constant out of range */
                warning(252);
@@ -1473,7 +1471,7 @@
 
        if (sym != NULL) {
                if (sym->s_kind != symtyp)
-                       LERROR("storesym(%d, %d)", sym->s_kind, symtyp);
+                       LERROR("getsym(%d, %d)", sym->s_kind, symtyp);
                symtyp = FVFT;
                freesb(sb);
                return sym;
@@ -1491,8 +1489,7 @@
                di = dcs;
                while (di->d_next != NULL && di->d_next->d_next != NULL)
                        di = di->d_next;
-               if (di->d_ctx != AUTO)
-                       LERROR("storesym()");
+               lint_assert(di->d_ctx == AUTO);
        } else {
                sym = getblk(sizeof (sym_t));
                sym->s_name = sb->sb_name;
@@ -1600,8 +1597,8 @@
        sym->s_rlink = &symtab[h];
        symtab[h] = sym;
        sym->s_blklev = bl;
-       if (sym->s_link != NULL && sym->s_blklev < sym->s_link->s_blklev)
-               LERROR("inssym()");
+       lint_assert(sym->s_link == NULL ||
+           sym->s_blklev >= sym->s_link->s_blklev);
 }
 
 /*
@@ -1641,8 +1638,7 @@
 
        h = hash(sym->s_name);
        nsym = getblk(sizeof (sym_t));
-       if (sym->s_blklev > blklev)
-               LERROR("pushdown()");
+       lint_assert(sym->s_blklev <= blklev);
        nsym->s_name = sym->s_name;
        UNIQUE_CURR_POS(nsym->s_def_pos);
        nsym->s_kind = sym->s_kind;
@@ -1677,10 +1673,9 @@
                strg_t *strg = *(strg_t **)sp;
                if (strg->st_tspec == CHAR) {
                        free(strg->st_cp);
-               } else if (strg->st_tspec == WCHAR) {
+               } else {
+                       lint_assert(strg->st_tspec == WCHAR);
                        free(strg->st_wcp);
-               } else {
-                       LERROR("fryylv()");
                }
                free(strg);
        }



Home | Main Index | Thread Index | Old Index