From f843facff59226d3788d855d1d6948523ab8d944 Mon Sep 17 00:00:00 2001 From: Shaun Tancheff Date: Thu, 15 Aug 2019 13:50:01 -0500 Subject: [PATCH] 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 Change-Id: I5bccb2cfd6b5900ff7f0e21b5546eec9ffa83c19 Reviewed-on: https://review.whamcloud.com/35708 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Petros Koutoupis --- 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 | 4 ++++ 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, 59 insertions(+), 32 deletions(-) diff --git a/lnet/klnds/socklnd/socklnd.c b/lnet/klnds/socklnd/socklnd.c index 6c38119..cb27e2b 100644 --- a/lnet/klnds/socklnd/socklnd.c +++ b/lnet/klnds/socklnd/socklnd.c @@ -2266,16 +2266,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 49941de..e3bad23 100644 --- a/lnet/lnet/lib-move.c +++ b/lnet/lnet/lib-move.c @@ -3699,6 +3699,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 c0f4f2f..e2e194d 100644 --- a/lustre/ldlm/ldlm_request.c +++ b/lustre/ldlm/ldlm_request.c @@ -1729,6 +1729,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 adf5b6b..81decaf 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -163,6 +163,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; @@ -3020,6 +3021,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 4a412cc..1a73760 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; @@ -1449,37 +1451,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 b3f29e1..e08b2d5 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -2704,12 +2704,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 225bfa9..7ea0915 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 2740b2f..841afcd 100644 --- a/lustre/mgs/mgs_llog.c +++ b/lustre/mgs/mgs_llog.c @@ -4701,6 +4701,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 12ade8a..e85e395 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -1781,15 +1781,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 11191fb..1743b51 100644 --- a/lustre/obdecho/echo_client.c +++ b/lustre/obdecho/echo_client.c @@ -986,13 +986,17 @@ out: CERROR("Cleanup obd device %s error(%d)\n", obd->obd_name, rc2); } + /* fallthrough */ 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; diff --git a/lustre/osc/osc_cache.c b/lustre/osc/osc_cache.c index 431df82..8cf0158 100644 --- a/lustre/osc/osc_cache.c +++ b/lustre/osc/osc_cache.c @@ -220,6 +220,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 8d8ab4b..d744262 100644 --- a/lustre/ptlrpc/gss/gss_keyring.c +++ b/lustre/ptlrpc/gss/gss_keyring.c @@ -681,10 +681,12 @@ static void request_key_unlink(struct key *key) ring = key_get(key_cred(tsk)->thread_keyring); if (ring) break; + /* fallthrough */ case KEY_REQKEY_DEFL_PROCESS_KEYRING: ring = key_get(key_tgcred(tsk)->process_keyring); if (ring) break; + /* fallthrough */ case KEY_REQKEY_DEFL_SESSION_KEYRING: rcu_read_lock(); ring = key_get(rcu_dereference(key_tgcred(tsk) @@ -692,6 +694,7 @@ static void request_key_unlink(struct key *key) rcu_read_unlock(); if (ring) break; + /* fallthrough */ case KEY_REQKEY_DEFL_USER_SESSION_KEYRING: ring = key_get(key_cred(tsk)->user->session_keyring); break; diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c index de9437c..e733648 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -826,7 +826,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 */ @@ -890,7 +890,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; } @@ -1095,7 +1095,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 */ @@ -2152,6 +2152,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 3e8d7f5..511b7f9 100644 --- a/lustre/quota/qmt_handler.c +++ b/lustre/quota/qmt_handler.c @@ -348,6 +348,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 */ @@ -378,6 +379,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 */ -- 1.8.3.1