summaryrefslogtreecommitdiff
path: root/usr.bin/make/make.h
diff options
context:
space:
mode:
authorrillig <rillig@NetBSD.org>2021-07-31 09:30:17 +0000
committerrillig <rillig@NetBSD.org>2021-07-31 09:30:17 +0000
commitf0384cf51a0a7decc5c73f3801ac2730b3aee5a8 (patch)
tree0a7ffeab732f2d73f30ce1c5d37d471b93c57fe2 /usr.bin/make/make.h
parent675b921214b7463e3a1020e0b9eec13351a5d630 (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/make.h')
-rw-r--r--usr.bin/make/make.h26
1 files changed, 15 insertions, 11 deletions
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>