From 75a24e7f9afb128138c3b3462b80731cab0f5bdd Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Fri, 11 Apr 2025 09:34:36 -0400 Subject: [PATCH] ctld: Disable -Wshadow for GCC GCC raises shadow warnings in C++ when a global function shadows a structure type name (since it shadows the constructors for that type). System headers are full of such cases (and some such as struct sigaction vs sigaction() are mandated by POSIX), so just disable the warning. For example: In file included from usr.sbin/ctld/ctld.cc:33: sys/sys/event.h:366:20: error: 'int kqueue()' hides constructor for 'struct kqueue' [-Werror=shadow] 366 | int kqueue(void); | ^ sys/sys/event.h:371:43: error: 'int kevent(int, const kevent*, int, kevent*, int, const timespec*)' hides constructor for 'struct kevent' [-Werror=shadow] 371 | const struct timespec *timeout); | ^ In file included from usr.sbin/ctld/ctld.cc:37: sys/sys/stat.h:396:63: error: 'int stat(const char*, stat*)' hides constructor for 'struct stat' [-Werror=shadow] 396 | int stat(const char * __restrict, struct stat * __restrict); | ^ Reported by: bz --- usr.sbin/ctld/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/usr.sbin/ctld/Makefile b/usr.sbin/ctld/Makefile index f96f3152e06..79c69c95fbb 100644 --- a/usr.sbin/ctld/Makefile +++ b/usr.sbin/ctld/Makefile @@ -14,6 +14,7 @@ CFLAGS+= -I${SRCTOP}/sys/dev/iscsi CFLAGS+= -I${SRCTOP}/lib/libiscsiutil #CFLAGS+= -DICL_KERNEL_PROXY NO_WCAST_ALIGN= +CXXWARNFLAGS.gcc= -Wno-shadow MAN= ctld.8 ctl.conf.5 LIBADD= bsdxml iscsiutil md sbuf util ucl m nv