From f7d8392a80342d050953d6185b561da46fc94c09 Mon Sep 17 00:00:00 2001 From: rillig Date: Sun, 22 Aug 2021 15:06:49 +0000 Subject: [PATCH] lint: only include code in the binaries that is actually used No functional change. --- usr.bin/xlint/common/emit.c | 6 ++++-- usr.bin/xlint/common/externs.h | 4 +++- usr.bin/xlint/common/lint.h | 4 +++- usr.bin/xlint/common/mem.c | 6 ++++-- usr.bin/xlint/lint2/Makefile | 3 ++- usr.bin/xlint/xlint/Makefile | 3 ++- 6 files changed, 18 insertions(+), 8 deletions(-) diff --git a/usr.bin/xlint/common/emit.c b/usr.bin/xlint/common/emit.c index 97f6999e8d57..ba3f5812a096 100644 --- a/usr.bin/xlint/common/emit.c +++ b/usr.bin/xlint/common/emit.c @@ -1,4 +1,4 @@ -/* $NetBSD: emit.c,v 1.12 2021/08/03 17:44:58 rillig Exp $ */ +/* $NetBSD: emit.c,v 1.13 2021/08/22 15:06:49 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: emit.c,v 1.12 2021/08/03 17:44:58 rillig Exp $"); +__RCSID("$NetBSD: emit.c,v 1.13 2021/08/22 15:06:49 rillig Exp $"); #endif #include @@ -131,6 +131,7 @@ outchar(int c) *ob.o_next++ = (char)c; } +#if defined(IS_LINT1) /* * write a character to the output buffer, quoted if necessary */ @@ -181,6 +182,7 @@ outqchar(int c) } } } +#endif /* * write a string to the output buffer diff --git a/usr.bin/xlint/common/externs.h b/usr.bin/xlint/common/externs.h index fb5bcecab21d..94b1f8ebe73d 100644 --- a/usr.bin/xlint/common/externs.h +++ b/usr.bin/xlint/common/externs.h @@ -1,4 +1,4 @@ -/* $NetBSD: externs.h,v 1.19 2021/08/22 14:50:06 rillig Exp $ */ +/* $NetBSD: externs.h,v 1.20 2021/08/22 15:06:49 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -54,6 +54,7 @@ extern char *xasprintf(const char *, ...) __printflike(1, 2); /* * emit.c */ +#if defined(IS_LINT1) || defined(IS_LINT2) extern ob_t ob; extern void outopen(const char *); @@ -66,3 +67,4 @@ extern void outint(int); #define outname(a) outname1(__FILE__, __LINE__, a); extern void outname1(const char *, size_t, const char *); extern void outsrc(const char *); +#endif diff --git a/usr.bin/xlint/common/lint.h b/usr.bin/xlint/common/lint.h index 69b9e76889a0..aa3dec23be70 100644 --- a/usr.bin/xlint/common/lint.h +++ b/usr.bin/xlint/common/lint.h @@ -1,4 +1,4 @@ -/* $NetBSD: lint.h,v 1.28 2021/08/10 17:31:44 rillig Exp $ */ +/* $NetBSD: lint.h,v 1.29 2021/08/22 15:06:49 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -117,7 +117,9 @@ typedef struct { #define is_complex(t) (ttab[t].tt_is_complex) #define is_scalar(t) (ttab[t].tt_is_scalar) +#if defined(IS_LINT1) || defined(IS_LINT2) extern ttab_t ttab[]; +#endif typedef enum { diff --git a/usr.bin/xlint/common/mem.c b/usr.bin/xlint/common/mem.c index 851cc5f133c8..4625586ada8a 100644 --- a/usr.bin/xlint/common/mem.c +++ b/usr.bin/xlint/common/mem.c @@ -1,4 +1,4 @@ -/* $NetBSD: mem.c,v 1.16 2021/08/03 17:20:02 rillig Exp $ */ +/* $NetBSD: mem.c,v 1.17 2021/08/22 15:06:49 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: mem.c,v 1.16 2021/08/03 17:20:02 rillig Exp $"); +__RCSID("$NetBSD: mem.c,v 1.17 2021/08/22 15:06:49 rillig Exp $"); #endif #include @@ -83,6 +83,7 @@ xstrdup(const char *s) return not_null(strdup(s)); } +#if defined(IS_XLINT) char * xasprintf(const char *fmt, ...) { @@ -97,3 +98,4 @@ xasprintf(const char *fmt, ...) not_null(NULL); return str; } +#endif diff --git a/usr.bin/xlint/lint2/Makefile b/usr.bin/xlint/lint2/Makefile index b7295414f62b..236e671a833d 100644 --- a/usr.bin/xlint/lint2/Makefile +++ b/usr.bin/xlint/lint2/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.21 2021/08/08 11:56:35 rillig Exp $ +# $NetBSD: Makefile,v 1.22 2021/08/22 15:06:49 rillig Exp $ NOMAN= # defined @@ -7,6 +7,7 @@ SRCS= main2.c hash.c read.c mem.c mem2.c chk.c msg.c emit.c emit2.c \ inittyp.c tyname.c BINDIR= /usr/libexec CPPFLAGS+= -I${.CURDIR} +CPPFLAGS+= -DIS_LINT2 LINTFLAGS+= -T # strict bool mode COPTS.msg.c+= ${${ACTIVE_CC} == "clang":? -Wno-format-nonliteral :} diff --git a/usr.bin/xlint/xlint/Makefile b/usr.bin/xlint/xlint/Makefile index a9354046630b..93e7fcc99279 100644 --- a/usr.bin/xlint/xlint/Makefile +++ b/usr.bin/xlint/xlint/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.21 2021/08/22 14:35:44 rillig Exp $ +# $NetBSD: Makefile,v 1.22 2021/08/22 15:06:49 rillig Exp $ .PATH: ${.CURDIR}/../../mkdep @@ -9,6 +9,7 @@ MAN= lint.1 CPPFLAGS+= -I${.CURDIR}/../lint1 CPPFLAGS+= -I${.CURDIR}/../../mkdep +CPPFLAGS+= -DIS_XLINT .if (${HOSTPROG:U} == "") DPADD+= ${LIBUTIL}