eBPF-based security platform
build: refuse an unannotated switch fallthrough with clang too
Daniel Borkmannb4f2b76c4d0e
diff --git a/Makefile.shirudo b/Makefile.shirudoindex 11d4aafd..4c2e49d1 100644--- a/Makefile.shirudo+++ b/Makefile.shirudo@@ -81,7 +81,7 @@ WERROR_CFLAGS := $(if $(filter 1,$(WERROR)),-Werror)WARNINGS := -Wall -Wextra -Wno-unused-parameter -Wstrict-prototypes -Wvla \-Wmissing-prototypes -Wpointer-arith -Wshadow \-Wdeclaration-after-statement -Wformat-security -Wformat=2 \- -Wwrite-strings -Wundef -Wtype-limits \+ -Wwrite-strings -Wundef -Wtype-limits -Wimplicit-fallthrough \$(WERROR_CFLAGS)# The warnings that not every compiler shirudo builds with has, each@@ -193,6 +193,7 @@ endif# generate auto-named params that often go unused. Neither is# fixable upstream of us, so silence both for BPF compilation.CLANG_BPF := $(CLANG) -target bpf -O2 -g -Wall -Wextra -Wvla -Wshadow -Wtype-limits \+ -Wimplicit-fallthrough \-Wno-missing-declarations -Wno-unused-parameter \-Wdeclaration-after-statement $(WERROR_CFLAGS)diff --git a/bpf/lib/misc.h b/bpf/lib/misc.hindex 451462c0..3db68d81 100644--- a/bpf/lib/misc.h+++ b/bpf/lib/misc.h@@ -12,6 +12,7 @@#define BUILD_BUG_ON_MSG(cond, msg) _Static_assert(!(cond), msg)#define BUILD_BUG_ON(cond) \BUILD_BUG_ON_MSG(cond, "BUILD_BUG_ON failed: " #cond)+#define fallthrough __attribute__((__fallthrough__))/** One access to x that the compiler neither tears nor repeats nor mergesdiff --git a/include/shirudo/compiler.h b/include/shirudo/compiler.hindex 089ea92d..e1e4026d 100644--- a/include/shirudo/compiler.h+++ b/include/shirudo/compiler.h@@ -15,6 +15,11 @@#define noinline __attribute__((noinline))/* A function with a large frame that inlining would add to its caller's. */#define noinline_for_stack noinline+/*+ * clang's -Wimplicit-fallthrough takes the attribute and never a comment.+ * Token for token as in bpf/lib/misc.h.+ */+#define fallthrough __attribute__((__fallthrough__))/** An empty asm that may read memory through ptr, so that a store to that