diff options
author | Brian Behlendorf <[email protected]> | 2021-09-14 09:17:54 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2021-09-14 10:17:54 -0600 |
commit | 6954c22f35cc8182f76bd18ab259a7d3eaf40b65 (patch) | |
tree | 0397dcd7c2fb6dd73754d30e0ad61feeff62625c /config/always-compiler-options.m4 | |
parent | 7443299fe0b8caaadbfc18f778732bb26c899e41 (diff) |
Use fallthrough macro
As of the Linux 5.9 kernel a fallthrough macro has been added which
should be used to anotate all intentional fallthrough paths. Once
all of the kernel code paths have been updated to use fallthrough
the -Wimplicit-fallthrough option will because the default. To
avoid warnings in the OpenZFS code base when this happens apply
the fallthrough macro.
Additional reading: https://lwn.net/Articles/794944/
Reviewed-by: Tony Nguyen <[email protected]>
Reviewed-by: George Melikov <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #12441
Diffstat (limited to 'config/always-compiler-options.m4')
-rw-r--r-- | config/always-compiler-options.m4 | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/config/always-compiler-options.m4 b/config/always-compiler-options.m4 index a84123317..ce84f7e60 100644 --- a/config/always-compiler-options.m4 +++ b/config/always-compiler-options.m4 @@ -162,6 +162,29 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_NO_UNUSED_BUT_SET_VARIABLE], [ ]) dnl # +dnl # Check if gcc supports -Wimplicit-fallthrough option. +dnl # +AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_IMPLICIT_FALLTHROUGH], [ + AC_MSG_CHECKING([whether $CC supports -Wimplicit-fallthrough]) + + saved_flags="$CFLAGS" + CFLAGS="$CFLAGS -Werror -Wimplicit-fallthrough" + + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [ + IMPLICIT_FALLTHROUGH=-Wimplicit-fallthrough + AC_DEFINE([HAVE_IMPLICIT_FALLTHROUGH], 1, + [Define if compiler supports -Wimplicit-fallthrough]) + AC_MSG_RESULT([yes]) + ], [ + IMPLICIT_FALLTHROUGH= + AC_MSG_RESULT([no]) + ]) + + CFLAGS="$saved_flags" + AC_SUBST([IMPLICIT_FALLTHROUGH]) +]) + +dnl # dnl # Check if gcc supports -fno-omit-frame-pointer option. dnl # AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_NO_OMIT_FRAME_POINTER], [ |