From 555e15ebe8bf1eb33d00747173cfc80cc65648a4 Mon Sep 17 00:00:00 2001 From: Joshua Watt Date: Fri, 9 Feb 2018 10:27:18 -0600 Subject: Use fallthrough attribute. Use __attribute__ ((fallthrough)) to indicate switch case fall through instead of a comment. This ensures that the fallthrough warning is not triggered even if the file is pre-processed (hence stripping the comments) before it is compiled. The actual fallback implementation is hidden behind a FALLBACK macro in case the compiler doesn't support it. Finally, the -Wimplict-fallthrough warning was upgraded to only allow the attribute to satisfy it; a comment alone is no longer sufficient. Signed-off-by: Joshua Watt --- lib/ChangeLog | 4 ++++ lib/eu-config.h | 7 +++++++ 2 files changed, 11 insertions(+) (limited to 'lib') diff --git a/lib/ChangeLog b/lib/ChangeLog index 769c3dc9..0f03dab0 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,7 @@ +2018-02-09 Joshua Watt + + * eu-config.h (FALLTHROUGH): New macro. + 2017-10-16 Mark Wielaard * md5.{c,h}: Removed. diff --git a/lib/eu-config.h b/lib/eu-config.h index 135803e7..84b22d7c 100644 --- a/lib/eu-config.h +++ b/lib/eu-config.h @@ -198,5 +198,12 @@ asm (".section predict_data, \"aw\"; .previous\n" # define COMPAT_VERSION(name, version, prefix) error "should use #ifdef SYMBOL_VERSIONING" #endif +#ifndef FALLTHROUGH +# ifdef HAVE_FALLTHROUGH +# define FALLTHROUGH __attribute__ ((fallthrough)) +# else +# define FALLTHROUGH ((void) 0) +# endif +#endif #endif /* eu-config.h */ -- cgit v1.2.3