From 0b2f3f20583595d0007fdfc8218fb4da4b999c49 Mon Sep 17 00:00:00 2001 From: Eric van Gyzen Date: Sat, 20 May 2017 17:33:47 +0000 Subject: [PATCH] libthr: Use CLI flags instead of pragmas to disable warnings People tweaking the build system or compilers tend to look into the Makefile and not into the source. Having some warning controls in the Makefile and some in the source code is surprising. Pragmas have the advantage that they leave the warnings enabled for more code, but that advantage isn't very relevant in these cases. Requested by: kib Reviewed by: kib MFC after: 3 days Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D10832 --- lib/libthr/Makefile | 6 ++++++ lib/libthr/thread/thr_stack.c | 17 ----------------- lib/libthr/thread/thr_symbols.c | 4 ---- 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/lib/libthr/Makefile b/lib/libthr/Makefile index 3e7a0244ef94..3e80503e2267 100644 --- a/lib/libthr/Makefile +++ b/lib/libthr/Makefile @@ -27,6 +27,12 @@ CFLAGS+=-I${SRCTOP}/libexec/rtld-elf/${MACHINE_CPUARCH} CFLAGS+=-I${SRCTOP}/lib/libthread_db CFLAGS+=-Winline +CFLAGS.thr_stack.c+= -Wno-cast-align +.include +.if !(${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} < 40300) +CFLAGS.thr_symbols.c+= -Wno-missing-variable-declarations +.endif + .ifndef NO_THREAD_UNWIND_STACK CFLAGS+=-fexceptions CFLAGS+=-D_PTHREAD_FORCED_UNWIND diff --git a/lib/libthr/thread/thr_stack.c b/lib/libthr/thread/thr_stack.c index 19bb2903f3c3..3510a74ab43f 100644 --- a/lib/libthr/thread/thr_stack.c +++ b/lib/libthr/thread/thr_stack.c @@ -290,19 +290,6 @@ _thr_stack_alloc(struct pthread_attr *attr) return (-1); } -/* - * Disable this warning from clang: - * - * cast from 'char *' to - * 'struct stack *' increases required alignment from 1 to 8 - * [-Werror,-Wcast-align] - * spare_stack = (struct stack *) - */ -#ifdef __clang__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wcast-align" -#endif - /* This function must be called with _thread_list_lock held. */ void _thr_stack_free(struct pthread_attr *attr) @@ -329,7 +316,3 @@ _thr_stack_free(struct pthread_attr *attr) attr->stackaddr_attr = NULL; } } - -#ifdef __clang__ -#pragma GCC diagnostic pop -#endif diff --git a/lib/libthr/thread/thr_symbols.c b/lib/libthr/thread/thr_symbols.c index 0c9ccb8788ec..9eef8db1a0a6 100644 --- a/lib/libthr/thread/thr_symbols.c +++ b/lib/libthr/thread/thr_symbols.c @@ -37,10 +37,6 @@ __FBSDID("$FreeBSD$"); #include "thr_private.h" -#ifdef __clang__ -#pragma GCC diagnostic ignored "-Wmissing-variable-declarations" -#endif - /* A collection of symbols needed by debugger */ /* int _libthr_debug */