diff options
| author | rillig <rillig@NetBSD.org> | 2021-07-31 09:30:17 +0000 |
|---|---|---|
| committer | rillig <rillig@NetBSD.org> | 2021-07-31 09:30:17 +0000 |
| commit | f0384cf51a0a7decc5c73f3801ac2730b3aee5a8 (patch) | |
| tree | 0a7ffeab732f2d73f30ce1c5d37d471b93c57fe2 /usr.bin/make | |
| parent | 675b921214b7463e3a1020e0b9eec13351a5d630 (diff) | |
make: fix lint warnings
The string functions from str.h are declared as 'static __unused' when
compiled with GCC, but lint explicitly undefines __GCC__ during
preprocessing. Therefore, make those functions inline, to prevent
warnings that they are unused.
The macro UNCONST is used in a few places, and (again) since lint
undefines __GCC__, that macro expanded to a simple type cast, which lint
warned about. To prevent this warning, implement UNCONST as a function
that works everywhere and hides the type cast.
In filemon_open, the code for closing F->in was obviously unreachable.
No functional change.
Diffstat (limited to 'usr.bin/make')
| -rw-r--r-- | usr.bin/make/Makefile | 3 | ||||
| -rw-r--r-- | usr.bin/make/filemon/filemon_ktrace.c | 3 | ||||
| -rw-r--r-- | usr.bin/make/make.h | 26 | ||||
| -rw-r--r-- | usr.bin/make/suff.c | 5 | ||||
| -rw-r--r-- | usr.bin/make/var.c | 6 |
5 files changed, 25 insertions, 18 deletions
diff --git a/usr.bin/make/Makefile b/usr.bin/make/Makefile index 3bbefb2285f..5ec88f3e801 100644 --- a/usr.bin/make/Makefile +++ b/usr.bin/make/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.115 2021/05/30 21:03:08 rillig Exp $ +# $NetBSD: Makefile,v 1.116 2021/07/31 09:30:17 rillig Exp $ # @(#)Makefile 5.2 (Berkeley) 12/28/90 PROG= make @@ -117,6 +117,7 @@ SUBDIR+= unit-tests .endif LINTFLAGS+= -T # strict bool mode, available since 2021-01-11 +LINTFLAGS+= -w # treat warnings as errors CLEANFILES+= *.o # for filemon objects COPTS.arch.c+= ${GCC_NO_FORMAT_TRUNCATION} diff --git a/usr.bin/make/filemon/filemon_ktrace.c b/usr.bin/make/filemon/filemon_ktrace.c index 1abef7e78af..53a85cbe74f 100644 --- a/usr.bin/make/filemon/filemon_ktrace.c +++ b/usr.bin/make/filemon/filemon_ktrace.c @@ -1,4 +1,4 @@ -/* $NetBSD: filemon_ktrace.c,v 1.14 2021/02/01 21:34:41 rillig Exp $ */ +/* $NetBSD: filemon_ktrace.c,v 1.15 2021/07/31 09:30:17 rillig Exp $ */ /* * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -227,7 +227,6 @@ filemon_open(void) /* Success! */ return F; - (void)fclose(F->in); fail1: (void)close(ktrpipe[0]); (void)close(ktrpipe[1]); fail0: free(F); diff --git a/usr.bin/make/make.h b/usr.bin/make/make.h index 4075ca34631..0fa7dd00e87 100644 --- a/usr.bin/make/make.h +++ b/usr.bin/make/make.h @@ -1,4 +1,4 @@ -/* $NetBSD: make.h,v 1.263 2021/06/21 10:33:11 rillig Exp $ */ +/* $NetBSD: make.h,v 1.264 2021/07/31 09:30:17 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -131,7 +131,14 @@ #endif #define MAKE_INLINE static inline MAKE_ATTR_UNUSED + +/* MAKE_STATIC marks a function that may or may not be inlined. */ +#if defined(lint) +/* As of 2021-07-31, NetBSD lint ignores __attribute__((unused)). */ +#define MAKE_STATIC MAKE_INLINE +#else #define MAKE_STATIC static MAKE_ATTR_UNUSED +#endif #if __STDC_VERSION__ >= 199901L || defined(lint) || defined(USE_C99_BOOLEAN) #include <stdbool.h> @@ -742,16 +749,13 @@ GNode_VarArchive(GNode *gn) { return GNode_ValueDirect(gn, ARCHIVE); } MAKE_INLINE const char * GNode_VarMember(GNode *gn) { return GNode_ValueDirect(gn, MEMBER); } -#if defined(__GNUC__) && __STDC_VERSION__ >= 199901L -#define UNCONST(ptr) ({ \ - union __unconst { \ - const void *__cp; \ - void *__p; \ - } __d; \ - __d.__cp = ptr, __d.__p; }) -#else -#define UNCONST(ptr) (void *)(ptr) -#endif +MAKE_INLINE void * +UNCONST(const void *ptr) +{ + void *ret; + memcpy(&ret, &ptr, sizeof(ret)); + return ret; +} /* At least GNU/Hurd systems lack hardcoded MAXPATHLEN/PATH_MAX */ #include <limits.h> diff --git a/usr.bin/make/suff.c b/usr.bin/make/suff.c index b2c926a2b8b..0dc6624b667 100644 --- a/usr.bin/make/suff.c +++ b/usr.bin/make/suff.c @@ -1,4 +1,4 @@ -/* $NetBSD: suff.c,v 1.350 2021/04/04 10:05:08 rillig Exp $ */ +/* $NetBSD: suff.c,v 1.351 2021/07/31 09:30:17 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -115,7 +115,7 @@ #include "dir.h" /* "@(#)suff.c 8.4 (Berkeley) 3/21/94" */ -MAKE_RCSID("$NetBSD: suff.c,v 1.350 2021/04/04 10:05:08 rillig Exp $"); +MAKE_RCSID("$NetBSD: suff.c,v 1.351 2021/07/31 09:30:17 rillig Exp $"); typedef List SuffixList; typedef ListNode SuffixListNode; @@ -619,6 +619,7 @@ Suff_AddTransform(const char *name) /* TODO: Avoid the redundant parsing here. */ bool ok = ParseTransform(name, &srcSuff, &targSuff); assert(ok); + /* LINTED 129 *//* expression has null effect */ (void)ok; } diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c index edc77f93645..c8f4921a2ec 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.944 2021/07/31 00:17:04 rillig Exp $ */ +/* $NetBSD: var.c,v 1.945 2021/07/31 09:30:17 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -140,7 +140,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.944 2021/07/31 00:17:04 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.945 2021/07/31 09:30:17 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -4019,6 +4019,8 @@ ApplyModifiers( char endc /* ')' or '}'; or '\0' for indirect modifiers */ ) { + /* LINTED 115 *//* warning: left operand of '=' must be modifiable lvalue */ + /* That's a bug in lint; see tests/usr.bin/xlint/lint1/msg_115.c. */ ModChain ch = ModChain_Literal(expr, startc, endc, ' ', false); const char *p; const char *mod; |
