From f7b1fea6bff50c190e9e644f86d709921aaa1974 Mon Sep 17 00:00:00 2001 From: Timothy Day Date: Sat, 8 Mar 2025 16:05:27 -0500 Subject: [PATCH] LU-16518 lustre: fix implicit-fallthrough warnings Explicitly lable switch-case intentional fallthroughs and reorder cases as needed to silence implicit-fallthrough warngins as reported by Clang. Test-Parameters: trivial Signed-off-by: Timothy Day Change-Id: I7322b3e4f37bcd1716ca48a31ce698798b58e6cf Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58348 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- lustre/llite/vvp_io.c | 2 ++ lustre/lod/lod_qos.c | 2 +- lustre/lov/lov_io.c | 4 ++-- lustre/mdd/mdd_object.c | 1 + lustre/mgs/mgs_nids.c | 1 + lustre/obdclass/cl_io.c | 1 + lustre/obdclass/obd_config.c | 4 ++-- lustre/ptlrpc/lproc_ptlrpc.c | 5 +++-- lustre/ptlrpc/nrs_orr.c | 4 ++-- lustre/ptlrpc/sec.c | 2 ++ 10 files changed, 17 insertions(+), 9 deletions(-) diff --git a/lustre/llite/vvp_io.c b/lustre/llite/vvp_io.c index 45cd1c6..65e5d9b 100644 --- a/lustre/llite/vvp_io.c +++ b/lustre/llite/vvp_io.c @@ -64,8 +64,10 @@ static bool can_populate_pages(const struct lu_env *env, struct cl_io *io, io->ci_continue = 0; rc = false; } + fallthrough; case CIT_FAULT: /* fault is okay because we've already had a page. */ + fallthrough; default: break; } diff --git a/lustre/lod/lod_qos.c b/lustre/lod/lod_qos.c index 39fbd8d..f407131 100644 --- a/lustre/lod/lod_qos.c +++ b/lustre/lod/lod_qos.c @@ -2468,7 +2468,7 @@ int lod_qos_parse_config(const struct lu_env *env, struct lod_object *lo, case __swab32(LOV_USER_MAGIC_COMP_V1): lustre_swab_lov_comp_md_v1(comp_v1); magic = comp_v1->lcm_magic; - /* fall trhough */ + fallthrough; case LOV_USER_MAGIC_COMP_V1: break; case __swab32(LOV_USER_MAGIC_FOREIGN): diff --git a/lustre/lov/lov_io.c b/lustre/lov/lov_io.c index 1a9199f..d00b53d 100644 --- a/lustre/lov/lov_io.c +++ b/lustre/lov/lov_io.c @@ -1890,8 +1890,6 @@ int lov_io_init_empty(const struct lu_env *env, struct cl_object *obj, lio->lis_object = lov; switch (io->ci_type) { - default: - LBUG(); case CIT_MISC: case CIT_GLIMPSE: case CIT_READ: @@ -1912,6 +1910,8 @@ int lov_io_init_empty(const struct lu_env *env, struct cl_object *obj, CERROR("Page fault on a file without stripes: "DFID"\n", PFID(lu_object_fid(&obj->co_lu))); break; + default: + LBUG(); } if (result == 0) { cl_io_slice_add(io, &lio->lis_cl, obj, &lov_empty_io_ops); diff --git a/lustre/mdd/mdd_object.c b/lustre/mdd/mdd_object.c index 80815a8..cb0cc41 100644 --- a/lustre/mdd/mdd_object.c +++ b/lustre/mdd/mdd_object.c @@ -3528,6 +3528,7 @@ mdd_layout_change(const struct lu_env *env, struct md_object *o, if (intent->lai_opc == LAYOUT_INTENT_PCCRO_SET || intent->lai_opc == LAYOUT_INTENT_PCCRO_CLEAR) RETURN(mdd_layout_update_pccro(env, o, mlc)); + break; } case MD_LAYOUT_RESYNC: case MD_LAYOUT_RESYNC_DONE: diff --git a/lustre/mgs/mgs_nids.c b/lustre/mgs/mgs_nids.c index 62eae1d..5f1722b 100644 --- a/lustre/mgs/mgs_nids.c +++ b/lustre/mgs/mgs_nids.c @@ -578,6 +578,7 @@ int mgs_ir_update(const struct lu_env *env, struct mgs_device *mgs, break; case IR_DISABLED: notify = false; + fallthrough; case IR_STARTUP: case IR_PARTIAL: break; diff --git a/lustre/obdclass/cl_io.c b/lustre/obdclass/cl_io.c index b4da6d5..0d64d04 100644 --- a/lustre/obdclass/cl_io.c +++ b/lustre/obdclass/cl_io.c @@ -100,6 +100,7 @@ void cl_io_fini(const struct lu_env *env, struct cl_io *io) /* Check ignore layout change conf */ LASSERT(ergo(io->ci_ignore_layout || !io->ci_verify_layout, !io->ci_need_restart)); + break; case CIT_GLIMPSE: break; case CIT_LADVISE: diff --git a/lustre/obdclass/obd_config.c b/lustre/obdclass/obd_config.c index 09cec64..e72b1a7 100644 --- a/lustre/obdclass/obd_config.c +++ b/lustre/obdclass/obd_config.c @@ -467,14 +467,14 @@ static int class_parse_value(char *buf, int opc, void *value, char **endh, tmp = *endp; *endp = '\0'; switch (opc) { - default: - LBUG(); case CLASS_PARSE_NID: rc = parse_nid(buf, value, quiet); break; case CLASS_PARSE_NET: rc = parse_net(buf, value); break; + default: + LBUG(); } *endp = tmp; if (rc != 0) diff --git a/lustre/ptlrpc/lproc_ptlrpc.c b/lustre/ptlrpc/lproc_ptlrpc.c index d603e5e..47c77b7 100644 --- a/lustre/ptlrpc/lproc_ptlrpc.c +++ b/lustre/ptlrpc/lproc_ptlrpc.c @@ -460,8 +460,6 @@ LUSTRE_RW_ATTR(threads_max); static const char *nrs_state2str(enum ptlrpc_nrs_pol_state state) { switch (state) { - default: - LBUG(); case NRS_POL_STATE_INVALID: return "invalid"; case NRS_POL_STATE_STOPPED: @@ -472,6 +470,9 @@ static const char *nrs_state2str(enum ptlrpc_nrs_pol_state state) return "starting"; case NRS_POL_STATE_STARTED: return "started"; + default: + LBUG(); + return NULL; } } diff --git a/lustre/ptlrpc/nrs_orr.c b/lustre/ptlrpc/nrs_orr.c index b30f805..5ce91c0 100644 --- a/lustre/ptlrpc/nrs_orr.c +++ b/lustre/ptlrpc/nrs_orr.c @@ -1668,14 +1668,14 @@ LDEBUGFS_SEQ_FOPS(ptlrpc_lprocfs_nrs_orr_offset_type); static const char *nrs_orr_supp2str(enum nrs_orr_supp supp) { switch(supp) { - default: - LBUG(); case NOS_OST_READ: return LPROCFS_NRS_SUPP_NAME_READS; case NOS_OST_WRITE: return LPROCFS_NRS_SUPP_NAME_WRITES; case NOS_OST_RW: return LPROCFS_NRS_SUPP_NAME_READWRITES; + default: + LBUG(); } } diff --git a/lustre/ptlrpc/sec.c b/lustre/ptlrpc/sec.c index 34361df..5c70df6 100644 --- a/lustre/ptlrpc/sec.c +++ b/lustre/ptlrpc/sec.c @@ -1104,6 +1104,7 @@ static int do_cli_unwrap_reply(struct ptlrpc_request *req) case 1: req_capsule_set_rep_swabbed(&req->rq_pill, MSG_PTLRPC_HEADER_OFF); + break; case 0: break; default: @@ -2385,6 +2386,7 @@ int sptlrpc_svc_unwrap_request(struct ptlrpc_request *req) case 1: req_capsule_set_req_swabbed(&req->rq_pill, MSG_PTLRPC_HEADER_OFF); + break; case 0: break; default: -- 1.8.3.1