Module Name: src
Committed By: rillig
Date: Fri Jan 1 09:28:22 UTC 2021
Modified Files:
src/usr.bin/xlint/lint1: cgram.y decl.c emit1.c scan.l
Log Message:
lint: replace simple LERROR with lint_assert
To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.124 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.92 -r1.93 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.30 -r1.31 src/usr.bin/xlint/lint1/emit1.c
cvs rdiff -u -r1.106 -r1.107 src/usr.bin/xlint/lint1/scan.l
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/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.123 src/usr.bin/xlint/lint1/cgram.y:1.124
--- src/usr.bin/xlint/lint1/cgram.y:1.123 Fri Jan 1 01:26:02 2021
+++ src/usr.bin/xlint/lint1/cgram.y Fri Jan 1 09:28:22 2021
@@ -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 @@ idecl(sym_t *decl, int initflg, sbuf_t *
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);
Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.92 src/usr.bin/xlint/lint1/decl.c:1.93
--- src/usr.bin/xlint/lint1/decl.c:1.92 Fri Jan 1 09:11:40 2021
+++ src/usr.bin/xlint/lint1/decl.c Fri Jan 1 09:28:22 2021
@@ -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 @@ popdecl(void)
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 @@ popdecl(void)
rmsyms(di->d_dlsyms);
break;
default:
- LERROR("popdecl()");
+ lint_assert(0);
}
free(di);
}
@@ -1532,10 +1532,9 @@ declarator_name(sym_t *sym)
sym->s_def = TDEF;
} else if (sc == TYPEDEF) {
sym->s_def = DEF;
- } else if (sc == EXTERN) {
- sym->s_def = DECL;
} else {
- LERROR("declarator_name()");
+ lint_assert(sc == EXTERN);
+ sym->s_def = DECL;
}
break;
case PARG:
@@ -1544,11 +1543,10 @@ declarator_name(sym_t *sym)
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 @@ declarator_name(sym_t *sym)
sym->s_reg = 1;
sc = AUTO;
sym->s_def = DEF;
- } else if (sc == EXTERN) {
- sym->s_def = DECL;
} else {
- LERROR("declarator_name()");
+ lint_assert(sc == EXTERN);
+ sym->s_def = DECL;
}
break;
default:
- LERROR("declarator_name()");
+ lint_assert(0);
}
sym->s_scl = sc;
@@ -1757,7 +1754,7 @@ storage_class_name(scl_t sc)
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 @@ decl1loc(sym_t *dsym, int initflg)
*/
break;
default:
- LERROR("decl1loc()");
+ lint_assert(0);
}
} else if (dcs->d_rdcsym->s_blklev == blklev) {
@@ -3078,7 +3075,7 @@ check_tag_usage(sym_t *sym)
warning(235, sym->s_name);
break;
default:
- LERROR("check_tag_usage()");
+ lint_assert(0);
}
}
Index: src/usr.bin/xlint/lint1/emit1.c
diff -u src/usr.bin/xlint/lint1/emit1.c:1.30 src/usr.bin/xlint/lint1/emit1.c:1.31
--- src/usr.bin/xlint/lint1/emit1.c:1.30 Fri Jan 1 09:11:40 2021
+++ src/usr.bin/xlint/lint1/emit1.c Fri Jan 1 09:28:22 2021
@@ -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 @@ outtype(type_t *tp)
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 @@ outsym(sym_t *sym, scl_t sc, def_t def)
outchar('e');
break;
default:
- LERROR("outsym()");
+ lint_assert(0);
}
if (llibflg && def != DECL) {
/*
Index: src/usr.bin/xlint/lint1/scan.l
diff -u src/usr.bin/xlint/lint1/scan.l:1.106 src/usr.bin/xlint/lint1/scan.l:1.107
--- src/usr.bin/xlint/lint1/scan.l:1.106 Fri Jan 1 01:26:02 2021
+++ src/usr.bin/xlint/lint1/scan.l Fri Jan 1 09:28:22 2021
@@ -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 @@ name(void)
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 @@ icon(int base)
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 @@ getsym(sbuf_t *sb)
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 @@ getsym(sbuf_t *sb)
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 @@ inssym(int bl, sym_t *sym)
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 @@ pushdown(sym_t *sym)
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 @@ freeyyv(void *sp, int tok)
strg_t *strg = *(strg_t **)sp;
if (strg->st_tspec == CHAR) {
free(strg->st_cp);
- } else if (strg->st_tspec == WCHAR) {
- free(strg->st_wcp);
} else {
- LERROR("fryylv()");
+ lint_assert(strg->st_tspec == WCHAR);
+ free(strg->st_wcp);
}
free(strg);
}