Module Name: src
Committed By: rillig
Date: Sat Jul 31 09:30:17 UTC 2021
Modified Files:
src/usr.bin/make: Makefile make.h suff.c var.c
src/usr.bin/make/filemon: filemon_ktrace.c
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.116 src/usr.bin/make/Makefile
cvs rdiff -u -r1.263 -r1.264 src/usr.bin/make/make.h
cvs rdiff -u -r1.350 -r1.351 src/usr.bin/make/suff.c
cvs rdiff -u -r1.944 -r1.945 src/usr.bin/make/var.c
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/filemon/filemon_ktrace.c
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/make/Makefile
diff -u src/usr.bin/make/Makefile:1.115 src/usr.bin/make/Makefile:1.116
--- src/usr.bin/make/Makefile:1.115 Sun May 30 21:03:08 2021
+++ src/usr.bin/make/Makefile Sat Jul 31 09:30:17 2021
@@ -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}
Index: src/usr.bin/make/make.h
diff -u src/usr.bin/make/make.h:1.263 src/usr.bin/make/make.h:1.264
--- src/usr.bin/make/make.h:1.263 Mon Jun 21 10:33:11 2021
+++ src/usr.bin/make/make.h Sat Jul 31 09:30:17 2021
@@ -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 GNo
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>
Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.350 src/usr.bin/make/suff.c:1.351
--- src/usr.bin/make/suff.c:1.350 Sun Apr 4 10:05:08 2021
+++ src/usr.bin/make/suff.c Sat Jul 31 09:30:17 2021
@@ -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;
}
Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.944 src/usr.bin/make/var.c:1.945
--- src/usr.bin/make/var.c:1.944 Sat Jul 31 00:17:04 2021
+++ src/usr.bin/make/var.c Sat Jul 31 09:30:17 2021
@@ -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;
Index: src/usr.bin/make/filemon/filemon_ktrace.c
diff -u src/usr.bin/make/filemon/filemon_ktrace.c:1.14 src/usr.bin/make/filemon/filemon_ktrace.c:1.15
--- src/usr.bin/make/filemon/filemon_ktrace.c:1.14 Mon Feb 1 21:34:41 2021
+++ src/usr.bin/make/filemon/filemon_ktrace.c Sat Jul 31 09:30:17 2021
@@ -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);