File 0002-LU-12635-build-Support-for-gcc-Wimplicit-fallthrough.patch of Package lustre_2_12

From 1c710fc302cb21745ea583a0a699915526376e46 Mon Sep 17 00:00:00 2001
From: Shaun Tancheff <stancheff@cray.com>
Date: Thu, 15 Aug 2019 13:50:01 -0500
Subject: [PATCH 02/35] LU-12635 build: Support for gcc -Wimplicit-fallthrough

Linux 5.3 enables -Wimplicit-fallthrough
Add decorators for implicit-fallthrough compiler checks.

Test-Parameters: trivial
Cray-bug-id: LUS-7690
Signed-off-by: Shaun Tancheff <stancheff@cray.com>
Change-Id: I5bccb2cfd6b5900ff7f0e21b5546eec9ffa83c19
Reviewed-on: https://review.whamcloud.com/35708
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Petros Koutoupis <pkoutoupis@cray.com>
---
 lnet/klnds/socklnd/socklnd.c     | 18 ++++++-------
 lnet/lnet/lib-move.c             |  1 +
 lustre/ldlm/ldlm_request.c       |  1 +
 lustre/llite/file.c              |  2 ++
 lustre/llite/namei.c             | 43 +++++++++++++++++---------------
 lustre/mdt/mdt_handler.c         |  2 ++
 lustre/mgs/mgs_barrier.c         |  2 ++
 lustre/mgs/mgs_llog.c            |  1 +
 lustre/obdclass/lprocfs_status.c |  4 +++
 lustre/obdecho/echo_client.c     | 22 +++++++++-------
 lustre/osc/osc_cache.c           |  1 +
 lustre/ptlrpc/gss/gss_keyring.c  |  3 +++
 lustre/ptlrpc/pack_generic.c     |  7 +++---
 lustre/quota/qmt_handler.c       |  2 ++
 14 files changed, 68 insertions(+), 41 deletions(-)

diff --git a/lnet/klnds/socklnd/socklnd.c b/lnet/klnds/socklnd/socklnd.c
index b7137478e309..9b199e3ab541 100644
--- a/lnet/klnds/socklnd/socklnd.c
+++ b/lnet/klnds/socklnd/socklnd.c
@@ -2270,16 +2270,16 @@ ksocknal_base_shutdown(void)
 	       atomic_read (&libcfs_kmemory));
 	LASSERT (ksocknal_data.ksnd_nnets == 0);
 
-        switch (ksocknal_data.ksnd_init) {
-        default:
-                LASSERT (0);
-
-        case SOCKNAL_INIT_ALL:
-        case SOCKNAL_INIT_DATA:
-                LASSERT (ksocknal_data.ksnd_peers != NULL);
-                for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) {
+	switch (ksocknal_data.ksnd_init) {
+	default:
+		LASSERT(0);
+		/* fallthrough */
+
+	case SOCKNAL_INIT_ALL:
+	case SOCKNAL_INIT_DATA:
+		LASSERT(ksocknal_data.ksnd_peers != NULL);
+		for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++)
 			LASSERT(list_empty(&ksocknal_data.ksnd_peers[i]));
-                }
 
 		LASSERT(list_empty(&ksocknal_data.ksnd_nets));
 		LASSERT(list_empty(&ksocknal_data.ksnd_enomem_conns));
diff --git a/lnet/lnet/lib-move.c b/lnet/lnet/lib-move.c
index b178fd09f9cc..b66715c50bdd 100644
--- a/lnet/lnet/lib-move.c
+++ b/lnet/lnet/lib-move.c
@@ -3612,6 +3612,7 @@ lnet_mt_event_handler(struct lnet_event *event)
 	case LNET_EVENT_UNLINK:
 		CDEBUG(D_NET, "%s recovery ping unlinked\n",
 		       libcfs_nid2str(ev_info->mt_nid));
+		/* fallthrough */
 	case LNET_EVENT_REPLY:
 		lnet_handle_recovery_reply(ev_info, event->status,
 					   event->type == LNET_EVENT_UNLINK);
diff --git a/lustre/ldlm/ldlm_request.c b/lustre/ldlm/ldlm_request.c
index ef7c7ba7ea95..0bc4df685525 100644
--- a/lustre/ldlm/ldlm_request.c
+++ b/lustre/ldlm/ldlm_request.c
@@ -1535,6 +1535,7 @@ ldlm_cancel_no_wait_policy(struct ldlm_namespace *ns, struct ldlm_lock *lock,
 		case LDLM_IBITS:
 			if (ns->ns_cancel != NULL && ns->ns_cancel(lock) != 0)
 				break;
+			/* fallthrough */
 		default:
 			result = LDLM_POLICY_SKIP_LOCK;
 			break;
diff --git a/lustre/llite/file.c b/lustre/llite/file.c
index f382e077014b..a5b80802569a 100644
--- a/lustre/llite/file.c
+++ b/lustre/llite/file.c
@@ -157,6 +157,7 @@ static int ll_close_inode_openhandle(struct inode *inode,
 		op_data->op_attr_blocks += ((struct inode *)data)->i_blocks;
 		op_data->op_attr.ia_valid |= ATTR_SIZE;
 		op_data->op_xvalid |= OP_XVALID_BLOCKS;
+		/* fallthrough */
 	case MDS_CLOSE_LAYOUT_SPLIT:
 	case MDS_CLOSE_LAYOUT_SWAP: {
 		struct split_param *sp = data;
@@ -2941,6 +2942,7 @@ static int ll_ladvise_sanity(struct inode *inode,
 			       ladvise_names[advice], rc);
 			GOTO(out, rc);
 		}
+		/* fallthrough */
 	case LU_LADVISE_WILLREAD:
 	case LU_LADVISE_DONTNEED:
 	default:
diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c
index 8acac7248ad7..b36476482931 100644
--- a/lustre/llite/namei.c
+++ b/lustre/llite/namei.c
@@ -398,11 +398,13 @@ int ll_md_need_convert(struct ldlm_lock *lock)
 	switch (lock->l_req_mode) {
 	case LCK_PR:
 		mode = LCK_PR;
+		/* fallthrough */
 	case LCK_PW:
 		mode |= LCK_CR;
 		break;
 	case LCK_CW:
 		mode = LCK_CW;
+		/* fallthrough */
 	case LCK_CR:
 		mode |= LCK_CR;
 		break;
@@ -1376,37 +1378,38 @@ static int ll_mknod(struct inode *dir, struct dentry *dchild, ll_umode_t mode,
 {
 	struct qstr *name = &dchild->d_name;
 	int err;
-        ENTRY;
+	ENTRY;
 
 	CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s, dir="DFID"(%p) mode %o dev %x\n",
 	       name->len, name->name, PFID(ll_inode2fid(dir)), dir,
-               mode, rdev);
+	       mode, rdev);
 
 	if (!IS_POSIXACL(dir) || !exp_connect_umask(ll_i2mdexp(dir)))
 		mode &= ~current_umask();
 
-        switch (mode & S_IFMT) {
-        case 0:
-                mode |= S_IFREG; /* for mode = 0 case, fallthrough */
-        case S_IFREG:
-        case S_IFCHR:
-        case S_IFBLK:
-        case S_IFIFO:
-        case S_IFSOCK:
+	switch (mode & S_IFMT) {
+	case 0:
+		mode |= S_IFREG;
+		/* fallthrough */
+	case S_IFREG:
+	case S_IFCHR:
+	case S_IFBLK:
+	case S_IFIFO:
+	case S_IFSOCK:
 		err = ll_new_node(dir, dchild, NULL, mode, old_encode_dev(rdev),
 				  LUSTRE_OPC_MKNOD);
-                break;
-        case S_IFDIR:
-                err = -EPERM;
-                break;
-        default:
-                err = -EINVAL;
-        }
+		break;
+	case S_IFDIR:
+		err = -EPERM;
+		break;
+	default:
+		err = -EINVAL;
+	}
 
-        if (!err)
-                ll_stats_ops_tally(ll_i2sbi(dir), LPROC_LL_MKNOD, 1);
+	if (!err)
+		ll_stats_ops_tally(ll_i2sbi(dir), LPROC_LL_MKNOD, 1);
 
-        RETURN(err);
+	RETURN(err);
 }
 
 #ifdef HAVE_IOP_ATOMIC_OPEN
diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c
index 0da292737c84..24cee1e96f66 100644
--- a/lustre/mdt/mdt_handler.c
+++ b/lustre/mdt/mdt_handler.c
@@ -2732,12 +2732,14 @@ static int mdt_quotactl(struct tgt_session_info *tsi)
 	case LUSTRE_Q_SETDEFAULT:
 		if (!nodemap_can_setquota(nodemap))
 			GOTO(out_nodemap, rc = -EPERM);
+		/* fallthrough */
 	case Q_GETINFO:
 	case Q_GETQUOTA:
 	case LUSTRE_Q_GETDEFAULT:
 		if (qmt == NULL)
 			GOTO(out_nodemap, rc = -EOPNOTSUPP);
 		/* slave quotactl */
+		/* fallthrough */
 	case Q_GETOINFO:
 	case Q_GETOQUOTA:
 		break;
diff --git a/lustre/mgs/mgs_barrier.c b/lustre/mgs/mgs_barrier.c
index 225bfa98483d..7ea09157670b 100644
--- a/lustre/mgs/mgs_barrier.c
+++ b/lustre/mgs/mgs_barrier.c
@@ -358,6 +358,7 @@ static int mgs_barrier_freeze(const struct lu_env *env,
 			rc = -EALREADY;
 			break;
 		}
+		/* fallthrough */
 	case BS_INIT:
 	case BS_THAWED:
 	case BS_EXPIRED:
@@ -683,6 +684,7 @@ static int mgs_barrier_rescan(const struct lu_env *env,
 			rc = -EBUSY;
 			break;
 		}
+		/* fallthrough */
 	case BS_INIT:
 	case BS_THAWED:
 	case BS_EXPIRED:
diff --git a/lustre/mgs/mgs_llog.c b/lustre/mgs/mgs_llog.c
index 2dc1a8ab87aa..95e34f35acf0 100644
--- a/lustre/mgs/mgs_llog.c
+++ b/lustre/mgs/mgs_llog.c
@@ -4713,6 +4713,7 @@ static int mgs_lcfg_fork_handler(const struct lu_env *env,
 			} /* else case fall through */
 		} /* else case fall through */
 	}
+	/* fallthrough */
 	default: {
 		for (i = 1; i < cnt; i++) {
 			o_buflen = o_lcfg->lcfg_buflens[i];
diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c
index d14a66e51e3e..111d880f6d3d 100644
--- a/lustre/obdclass/lprocfs_status.c
+++ b/lustre/obdclass/lprocfs_status.c
@@ -1786,15 +1786,19 @@ static int get_mult(char unit, __u64 *mult)
 	case 'p':
 	case 'P':
 		units <<= 10;
+		/* fallthrough */
 	case 't':
 	case 'T':
 		units <<= 10;
+		/* fallthrough */
 	case 'g':
 	case 'G':
 		units <<= 10;
+		/* fallthrough */
 	case 'm':
 	case 'M':
 		units <<= 10;
+		/* fallthrough */
 	case 'k':
 	case 'K':
 		units <<= 10;
diff --git a/lustre/obdecho/echo_client.c b/lustre/obdecho/echo_client.c
index 202c4ed4868b..78cd38aa86d7 100644
--- a/lustre/obdecho/echo_client.c
+++ b/lustre/obdecho/echo_client.c
@@ -977,16 +977,20 @@ out:
                         CERROR("Cleanup obd device %s error(%d)\n",
                                obd->obd_name, rc2);
         }
+	/* fallthrough */
 
-        case 3:
-                echo_site_fini(env, ed);
-        case 2:
-                cl_device_fini(&ed->ed_cl);
-        case 1:
-                OBD_FREE_PTR(ed);
-        case 0:
-        default:
-                break;
+	case 3:
+		echo_site_fini(env, ed);
+		/* fallthrough */
+	case 2:
+		cl_device_fini(&ed->ed_cl);
+		/* fallthrough */
+	case 1:
+		OBD_FREE_PTR(ed);
+		/* fallthrough */
+	case 0:
+	default:
+		break;
         }
         return(ERR_PTR(rc));
 }
diff --git a/lustre/osc/osc_cache.c b/lustre/osc/osc_cache.c
index 41d5b66e73fa..5652e74222be 100644
--- a/lustre/osc/osc_cache.c
+++ b/lustre/osc/osc_cache.c
@@ -216,6 +216,7 @@ static int osc_extent_sanity_check0(struct osc_extent *ext,
 			GOTO(out, rc = 60);
 		if (ext->oe_fsync_wait && !ext->oe_urgent && !ext->oe_hp)
 			GOTO(out, rc = 65);
+		/* fallthrough */
 	default:
 		if (atomic_read(&ext->oe_users) > 0)
 			GOTO(out, rc = 70);
diff --git a/lustre/ptlrpc/gss/gss_keyring.c b/lustre/ptlrpc/gss/gss_keyring.c
index 4047e14f5576..15bf99427489 100644
--- a/lustre/ptlrpc/gss/gss_keyring.c
+++ b/lustre/ptlrpc/gss/gss_keyring.c
@@ -695,16 +695,19 @@ static void request_key_unlink(struct key *key)
 		ring = key_get(cred->thread_keyring);
 		if (ring)
 			break;
+		/* fallthrough */
 	case KEY_REQKEY_DEFL_PROCESS_KEYRING:
 		ring = key_get(cred->process_keyring);
 		if (ring)
 			break;
+		/* fallthrough */
 	case KEY_REQKEY_DEFL_SESSION_KEYRING:
 		rcu_read_lock();
 		ring = key_get(rcu_dereference(cred->session_keyring));
 		rcu_read_unlock();
 		if (ring)
 			break;
+		/* fallthrough */
 	case KEY_REQKEY_DEFL_USER_SESSION_KEYRING:
 		ring = get_user_session_keyring(cred);
 		break;
diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c
index 79ddfae3d485..0d425804b1a1 100644
--- a/lustre/ptlrpc/pack_generic.c
+++ b/lustre/ptlrpc/pack_generic.c
@@ -856,7 +856,7 @@ __u32 lustre_msg_get_flags(struct lustre_msg *msg)
 
 		CERROR("invalid msg %p: no ptlrpc body!\n", msg);
 	}
-	/* no break */
+	/* fallthrough */
 	default:
 		/* flags might be printed in debug code while message
 		 * uninitialized */
@@ -920,7 +920,7 @@ __u32 lustre_msg_get_op_flags(struct lustre_msg *msg)
 
 		CERROR("invalid msg %p: no ptlrpc body!\n", msg);
 	}
-	/* no break */
+	/* fallthrough */
 	default:
 		return 0;
 	}
@@ -1125,7 +1125,7 @@ int lustre_msg_get_status(struct lustre_msg *msg)
 			return pb->pb_status;
 		CERROR("invalid msg %p: no ptlrpc body!\n", msg);
 	}
-	/* no break */
+	/* fallthrough */
 	default:
 		/* status might be printed in debug code while message
 		* uninitialized */
@@ -2178,6 +2178,7 @@ void lustre_swab_lmv_user_md(struct lmv_user_md *lum)
 	switch (lum->lum_magic) {
 	case LMV_USER_MAGIC_SPECIFIC:
 		count = lum->lum_stripe_count;
+		/* fallthrough */
 	case __swab32(LMV_USER_MAGIC_SPECIFIC):
 		lustre_swab_lmv_user_md_objects(lum->lum_objects, count);
 		break;
diff --git a/lustre/quota/qmt_handler.c b/lustre/quota/qmt_handler.c
index ab48ae7c9019..784fdab870a4 100644
--- a/lustre/quota/qmt_handler.c
+++ b/lustre/quota/qmt_handler.c
@@ -351,6 +351,7 @@ static int qmt_quotactl(const struct lu_env *env, struct lu_device *ld,
 
 	case LUSTRE_Q_GETDEFAULT:
 		is_default = true;
+		/* fallthrough */
 
 	case Q_GETQUOTA: /* consult quota limit */
 		/* extract quota ID from quotactl request */
@@ -381,6 +382,7 @@ static int qmt_quotactl(const struct lu_env *env, struct lu_device *ld,
 
 	case LUSTRE_Q_SETDEFAULT:
 		is_default = true;
+		/* fallthrough */
 
 	case Q_SETQUOTA: /* change quota limits */
 		/* extract quota ID from quotactl request */
-- 
2.41.0

openSUSE Build Service is sponsored by