From bdf926616a20745ca14ab2b492fb79ef03fdb6b8 Mon Sep 17 00:00:00 2001 From: Shaun Tancheff Date: Mon, 28 Feb 2022 00:30:19 -0800 Subject: [PATCH] LU-15492 build: fallthrough macro for pre/post gcc-7 gcc-7.5 on openSUSE 15: error: this statement may fall through [-Werror=implicit-fallthrough=] Use the __attribute__((fallthrough)) for gcc-7 and later. and use a no op statement for earlier gcc where the fallthrough attribute is not available. Lustre-change: https://review.whamcloud.com/46357 Lustre-commit: TBD (from 48145f2eaed1537506bfffb1c0a44a8cfdb38254) Test-Parameters: trivial Fixes: 5549b1b9e0 ("LU-15220 lustre: use 'fallthrough' pseudo keyword for switch") Signed-off-by: Shaun Tancheff Change-Id: Ib72f5996149c738805f15e354e1e1606d981ce29 Reviewed-on: https://review.whamcloud.com/46643 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Yang Sheng Reviewed-by: Andreas Dilger --- lnet/include/lnet/lib-lnet.h | 6 +++++- lustre/include/lustre/lustreapi.h | 6 +++++- lustre/include/lustre_compat.h | 6 +++++- lustre/utils/gss/gss_util.h | 6 +++++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/lnet/include/lnet/lib-lnet.h b/lnet/include/lnet/lib-lnet.h index 98b5e83..d6df30d 100644 --- a/lnet/include/lnet/lib-lnet.h +++ b/lnet/include/lnet/lib-lnet.h @@ -111,7 +111,11 @@ extern struct lnet the_lnet; /* THE network */ #endif #ifndef fallthrough -#define fallthrough do {} while (0) /* fallthrough */ +# if defined(__GNUC__) && __GNUC__ >= 7 +# define fallthrough __attribute__((fallthrough)) /* fallthrough */ +# else +# define fallthrough do {} while (0) /* fallthrough */ +# endif #endif int choose_ipv4_src(__u32 *ret, diff --git a/lustre/include/lustre/lustreapi.h b/lustre/include/lustre/lustreapi.h index ed1c3d7..1e90c87 100644 --- a/lustre/include/lustre/lustreapi.h +++ b/lustre/include/lustre/lustreapi.h @@ -63,7 +63,11 @@ extern "C" { #endif #ifndef fallthrough -#define fallthrough do {} while (0) /* fallthrough */ +# if defined(__GNUC__) && __GNUC__ >= 7 +# define fallthrough __attribute__((fallthrough)) /* fallthrough */ +# else +# define fallthrough do {} while (0) /* fallthrough */ +# endif #endif typedef struct statx lstatx_t; diff --git a/lustre/include/lustre_compat.h b/lustre/include/lustre_compat.h index d3c0c20..07aaabe 100644 --- a/lustre/include/lustre_compat.h +++ b/lustre/include/lustre_compat.h @@ -590,7 +590,11 @@ static inline int ll_vfs_removexattr(struct dentry *dentry, struct inode *inode, #endif #ifndef fallthrough -#define fallthrough do {} while (0) /* fallthrough */ +# if defined(__GNUC__) && __GNUC__ >= 7 +# define fallthrough __attribute__((fallthrough)) /* fallthrough */ +# else +# define fallthrough do {} while (0) /* fallthrough */ +# endif #endif static inline void ll_security_release_secctx(char *secdata, u32 seclen) diff --git a/lustre/utils/gss/gss_util.h b/lustre/utils/gss/gss_util.h index a251fca..07b0f30 100644 --- a/lustre/utils/gss/gss_util.h +++ b/lustre/utils/gss/gss_util.h @@ -35,7 +35,11 @@ #include "write_bytes.h" #ifndef fallthrough -#define fallthrough do {} while (0) /* fallthrough */ +# if defined(__GNUC__) && __GNUC__ >= 7 +# define fallthrough __attribute__((fallthrough)) /* fallthrough */ +# else +# define fallthrough do {} while (0) /* fallthrough */ +# endif #endif extern char *this_realm; -- 1.8.3.1