diff options
author | Chad Loder <cloder@cvs.openbsd.org> | 2005-12-01 05:06:41 +0000 |
---|---|---|
committer | Chad Loder <cloder@cvs.openbsd.org> | 2005-12-01 05:06:41 +0000 |
commit | 5dab7737fedf6f56432ce16e7e3c1f30ad588fa8 (patch) | |
tree | ccb8f3a2292daa8b4bc14822e781a1ab02d2500a /usr.bin/xlint | |
parent | ad33123d448d4efa2c44299b0c38c9bf2d73b0ae (diff) |
Make lint quieter by only warning on "foo declared but never used or
defined" when foo is declared in the translation unit that lint is working
on. This means that symbols that are declared in an included header file
don't get this warning, ever.
Diffstat (limited to 'usr.bin/xlint')
-rw-r--r-- | usr.bin/xlint/lint2/chk.c | 10 | ||||
-rw-r--r-- | usr.bin/xlint/lint2/externs2.h | 3 | ||||
-rw-r--r-- | usr.bin/xlint/lint2/read.c | 6 |
3 files changed, 13 insertions, 6 deletions
diff --git a/usr.bin/xlint/lint2/chk.c b/usr.bin/xlint/lint2/chk.c index c9af43571cf..ff7e2765684 100644 --- a/usr.bin/xlint/lint2/chk.c +++ b/usr.bin/xlint/lint2/chk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: chk.c,v 1.10 2005/11/20 17:42:50 deraadt Exp $ */ +/* $OpenBSD: chk.c,v 1.11 2005/12/01 05:06:40 cloder Exp $ */ /* $NetBSD: chk.c,v 1.2 1995/07/03 21:24:42 cgd Exp $ */ /* @@ -33,7 +33,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: chk.c,v 1.10 2005/11/20 17:42:50 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: chk.c,v 1.11 2005/12/01 05:06:40 cloder Exp $"; #endif #include <stdlib.h> @@ -270,6 +270,12 @@ chkdnud(hte_t *hte) if ((sym = hte->h_syms) != NULL) { if (sym->s_def != DECL) errx(1, "internal error: chkdnud() 1"); + + /* don't warn if the name was declared in a separate header */ + if (sym->s_pos.p_src != sym->s_pos.p_isrc) { + return; + } + /* %s declared( %s ), but never used or defined */ msg(2, hte->h_name, mkpos(&sym->s_pos)); } diff --git a/usr.bin/xlint/lint2/externs2.h b/usr.bin/xlint/lint2/externs2.h index 148eae113af..1b6a97f5fc0 100644 --- a/usr.bin/xlint/lint2/externs2.h +++ b/usr.bin/xlint/lint2/externs2.h @@ -1,4 +1,4 @@ -/* $OpenBSD: externs2.h,v 1.4 2002/02/17 19:42:35 millert Exp $ */ +/* $OpenBSD: externs2.h,v 1.5 2005/12/01 05:06:40 cloder Exp $ */ /* $NetBSD: externs2.h,v 1.2 1995/07/03 21:24:46 cgd Exp $ */ /* @@ -59,6 +59,7 @@ extern void forall(void (*)(hte_t *)); */ extern const char **fnames; extern type_t **tlst; +extern int csrcfile; extern void readfile(const char *); extern void mkstatic(hte_t *); diff --git a/usr.bin/xlint/lint2/read.c b/usr.bin/xlint/lint2/read.c index 3945ad22920..d59bf939d1d 100644 --- a/usr.bin/xlint/lint2/read.c +++ b/usr.bin/xlint/lint2/read.c @@ -1,4 +1,4 @@ -/* $OpenBSD: read.c,v 1.8 2005/11/30 18:47:10 deraadt Exp $ */ +/* $OpenBSD: read.c,v 1.9 2005/12/01 05:06:40 cloder Exp $ */ /* $NetBSD: read.c,v 1.2 1995/07/03 21:24:59 cgd Exp $ */ /* @@ -33,7 +33,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: read.c,v 1.8 2005/11/30 18:47:10 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: read.c,v 1.9 2005/12/01 05:06:40 cloder Exp $"; #endif #include <stdio.h> @@ -80,7 +80,7 @@ type_t **tlst; /* array for indexed access */ static size_t tlstlen; /* length of tlst */ /* index of current C source file (as spezified at the command line) */ -static int csrcfile; +int csrcfile; static void inperr(void); |