From 6cae135625159733c0fc1b02ad0cd3ee25ff4d2b Mon Sep 17 00:00:00 2001 From: Jian Yu Date: Sat, 22 Jan 2022 18:28:56 -0800 Subject: [PATCH] LU-15220 utils: use 'fallthrough' pseudo keyword for switch '/* fallthrough */' hits implicit-fallthrough error with GCC 11. This patch replaces the existing '/* fallthrough */' comments and its variants with the 'fallthrough' pseudo keyword, which was added by Linux kernel commit v5.4-rc2-141-g294f69e662d1. Test-Parameters: trivial Change-Id: Icace4c9953950f86d3c48068d8c6bba7dd1160a7 Signed-off-by: Jian Yu --- lustre/include/lustre/lustreapi.h | 4 +++ lustre/utils/gss/gss_util.h | 4 +++ lustre/utils/gss/svcgssd_proc.c | 2 +- lustre/utils/lfs.c | 68 ++++++++++++++++++++++----------------- lustre/utils/lustre_rsync.c | 1 + lustre/utils/obd.c | 2 +- 6 files changed, 50 insertions(+), 31 deletions(-) diff --git a/lustre/include/lustre/lustreapi.h b/lustre/include/lustre/lustreapi.h index 2ce4bf1..8f6b755 100644 --- a/lustre/include/lustre/lustreapi.h +++ b/lustre/include/lustre/lustreapi.h @@ -61,6 +61,10 @@ extern "C" { #define LOV_PATTERN_DEFAULT 0xffffffff #endif +#ifndef fallthrough +#define fallthrough do {} while (0) /* fallthrough */ +#endif + typedef struct statx lstatx_t; #define lustre_fid struct lu_fid diff --git a/lustre/utils/gss/gss_util.h b/lustre/utils/gss/gss_util.h index e7cc128..a251fca 100644 --- a/lustre/utils/gss/gss_util.h +++ b/lustre/utils/gss/gss_util.h @@ -34,6 +34,10 @@ #include #include "write_bytes.h" +#ifndef fallthrough +#define fallthrough do {} while (0) /* fallthrough */ +#endif + extern char *this_realm; extern gss_cred_id_t gssd_creds; diff --git a/lustre/utils/gss/svcgssd_proc.c b/lustre/utils/gss/svcgssd_proc.c index da8dcf8..57176e9 100644 --- a/lustre/utils/gss/svcgssd_proc.c +++ b/lustre/utils/gss/svcgssd_proc.c @@ -319,7 +319,7 @@ get_ids(gss_name_t client_name, gss_OID mech, struct svc_cred *cred, cred->cr_uid = 0; cred->cr_usr_oss = 1; } - /* fall through */ + fallthrough; case LUSTRE_GSS_SVC_OSS: if (!strcmp(sname, LUSTRE_ROOT_NAME)) { cred->cr_uid = 0; diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 8a21d28..c9a5a0d 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -3663,7 +3663,7 @@ static int lfs_setstripe_internal(int argc, char **argv, goto usage_error; } lsa.lsa_pattern = LLAPI_LAYOUT_OVERSTRIPING; - /* fall through */ + fallthrough; case 'c': errno = 0; lsa.lsa_stripe_count = strtoul(optarg, &end, 0); @@ -4434,19 +4434,25 @@ static time_t set_time(struct find_param *param, time_t *time, time_t *set, switch (*endptr) { case 'y': unit *= 52; /* 52 weeks + 1 day below */ - case 'w': /* fallthrough */ + fallthrough; + case 'w': unit *= 7; if (param->fp_time_margin == FP_DEFAULT_TIME_MARGIN) param->fp_time_margin *= (1 + unit / 52); unit += (*endptr == 'y'); /* +1 day for 365 days/year */ + fallthrough; case '\0': /* days are default unit if none used */ - case 'd': /* fallthrough */ + fallthrough; + case 'd': unit *= 24; - case 'h': /* fallthrough */ + fallthrough; + case 'h': unit *= 60; - case 'm': /* fallthrough */ + fallthrough; + case 'm': unit *= 60; - case 's': /* fallthrough */ + fallthrough; + case 's': break; /* don't need to multiply by 1 for seconds */ default: @@ -4990,6 +4996,7 @@ static int lfs_find(int argc, char **argv) xsign = ¶m.fp_asign; param.fp_exclude_atime = !!neg_opt; /* no break, this falls through to 'B' for btime */ + fallthrough; case 'B': if (c == 'B') { xtime = ¶m.fp_btime; @@ -4997,6 +5004,7 @@ static int lfs_find(int argc, char **argv) param.fp_exclude_btime = !!neg_opt; } /* no break, this falls through to 'C' for ctime */ + fallthrough; case 'C': if (c == 'C') { xtime = ¶m.fp_ctime; @@ -5004,6 +5012,7 @@ static int lfs_find(int argc, char **argv) param.fp_exclude_ctime = !!neg_opt; } /* no break, this falls through to 'M' for mtime */ + fallthrough; case 'M': if (c == 'M') { xtime = ¶m.fp_mtime; @@ -6205,12 +6214,13 @@ static int lfs_getdirstripe(int argc, char **argv) case 't': fprintf(stderr, "warning: '-t' deprecated, use '--mdt-hash' or '-H' instead\n"); - /* fallthrough */ + fallthrough; #endif case 'H': param.fp_verbose |= VERBOSE_HASH_TYPE; break; - case 'i': /* fallthrough */ + case 'i': + fallthrough; case 'm': param.fp_verbose |= VERBOSE_STRIPE_OFFSET; break; @@ -6241,7 +6251,7 @@ static int lfs_getdirstripe(int argc, char **argv) default: fprintf(stderr, "%s: unrecognized option '%s'\n", progname, argv[optind - 1]); - /* fallthrough */ + fallthrough; case 'h': return CMD_HELP; } @@ -6732,7 +6742,7 @@ static int lfs_setdirstripe(int argc, char **argv) case 't': fprintf(stderr, "warning: '--hash-type' and '-t' deprecated, use '--mdt-hash' or '-H' instead\n"); - /* fallthrough */ + fallthrough; #endif case 'H': lsa.lsa_pattern = check_hashtype(optarg); @@ -6829,7 +6839,7 @@ static int lfs_setdirstripe(int argc, char **argv) default: fprintf(stderr, "%s: unrecognized option '%s'\n", progname, argv[optind - 1]); - /* fallthrough */ + fallthrough; case 'h': return CMD_HELP; } @@ -7321,7 +7331,7 @@ static int lfs_getname(int argc, char **argv) default: fprintf(stderr, "%s: unrecognized option '%s'\n", progname, argv[optind - 1]); - /* fallthrough */ + fallthrough; case 'h': return CMD_HELP; } @@ -7613,7 +7623,7 @@ quota_type: default: fprintf(stderr, "%s: unrecognized option '%s'\n", progname, argv[optind - 1]); - /* fallthrough */ + fallthrough; case 'h': return CMD_HELP; } @@ -7822,7 +7832,7 @@ quota_type_def: fprintf(stderr, "%s setquota: unrecognized option '%s'\n", progname, argv[optind - 1]); - /* fallthrough */ + fallthrough; case 'h': rc = CMD_HELP; goto out; @@ -9476,7 +9486,7 @@ static int lfs_data_version(int argc, char **argv) fprintf(stderr, "%s data_version: unrecognized option '%s'\n", progname, argv[optind - 1]); - /* fallthrough */ + fallthrough; case 'h': return CMD_HELP; } @@ -9620,7 +9630,7 @@ static int lfs_hsm_change_flags(int argc, char **argv, int mode) default: fprintf(stderr, "%s: unrecognized option '%s'\n", progname, argv[optind - 1]); - /* fallthrough */ + fallthrough; case 'h': return CMD_HELP; } @@ -9854,7 +9864,7 @@ static int lfs_hsm_request(int argc, char **argv, int action) default: fprintf(stderr, "%s: unrecognized option '%s'\n", progname, argv[optind - 1]); - /* fallthrough */ + fallthrough; case 'h': return CMD_HELP; } @@ -10154,7 +10164,7 @@ static int lfs_ladvise(int argc, char **argv) default: fprintf(stderr, "%s: unrecognized option '%s'\n", progname, argv[optind - 1]); - /* fallthrough */ + fallthrough; case 'h': return CMD_HELP; } @@ -10343,7 +10353,7 @@ static int lfs_heat_set(int argc, char **argv) default: fprintf(stderr, "%s: unrecognized option '%s'\n", progname, argv[optind - 1]); - /* fallthrough */ + fallthrough; case 'h': return CMD_HELP; } @@ -10796,7 +10806,7 @@ static inline int lfs_mirror_resync(int argc, char **argv) default: fprintf(stderr, "%s: unrecognized option '%s'\n", progname, argv[optind - 1]); - /* fallthrough */ + fallthrough; case 'h': rc = CMD_HELP; goto error; @@ -10942,7 +10952,7 @@ static inline int lfs_mirror_read(int argc, char **argv) default: fprintf(stderr, "%s: unrecognized option '%s'\n", progname, argv[optind - 1]); - /* fallthrough */ + fallthrough; case 'h': return CMD_HELP; } @@ -11107,7 +11117,7 @@ static inline int lfs_mirror_write(int argc, char **argv) default: fprintf(stderr, "%s: unrecognized option '%s'\n", progname, argv[optind - 1]); - /* fallthrough */ + fallthrough; case 'h': return CMD_HELP; } @@ -11357,7 +11367,7 @@ static inline int lfs_mirror_copy(int argc, char **argv) default: fprintf(stderr, "%s: unrecognized option '%s'\n", progname, argv[optind - 1]); - /* fallthrough */ + fallthrough; case 'h': return CMD_HELP; } @@ -12123,7 +12133,7 @@ static inline int lfs_mirror_verify(int argc, char **argv) default: fprintf(stderr, "%s: unrecognized option '%s'\n", progname, argv[optind - 1]); - /* fallthrough */ + fallthrough; case 'h': rc = CMD_HELP; goto error; @@ -12230,7 +12240,7 @@ static int lfs_getsom(int argc, char **argv) default: fprintf(stderr, "%s: unrecognized option '%s'\n", progname, argv[optind - 1]); - /* fallthrough */ + fallthrough; case 'h': return CMD_HELP; } @@ -12333,7 +12343,7 @@ static int lfs_pcc_attach(int argc, char **argv) default: fprintf(stderr, "%s: unrecognized option '%s'\n", progname, argv[optind - 1]); - /* fallthrough */ + fallthrough; case 'h': return CMD_HELP; } @@ -12410,7 +12420,7 @@ static int lfs_pcc_attach_fid(int argc, char **argv) default: fprintf(stderr, "%s: unrecognized option '%s'\n", progname, argv[optind - 1]); - /* fallthrough */ + fallthrough; case 'h': return CMD_HELP; } @@ -12473,7 +12483,7 @@ static int lfs_pcc_detach(int argc, char **argv) default: fprintf(stderr, "%s: unrecognized option '%s'\n", progname, argv[optind - 1]); - /* fallthrough */ + fallthrough; case 'h': return CMD_HELP; } @@ -12526,7 +12536,7 @@ static int lfs_pcc_detach_fid(int argc, char **argv) default: fprintf(stderr, "%s: unrecognized option '%s'\n", progname, argv[optind - 1]); - /* fallthrough */ + fallthrough; case 'h': return CMD_HELP; } diff --git a/lustre/utils/lustre_rsync.c b/lustre/utils/lustre_rsync.c index e36aabe..b333b77 100644 --- a/lustre/utils/lustre_rsync.c +++ b/lustre/utils/lustre_rsync.c @@ -1683,6 +1683,7 @@ int lr_replicate(void) * Nothing needs to be done for these entries * fallthrough */ + fallthrough; default: break; } diff --git a/lustre/utils/obd.c b/lustre/utils/obd.c index 0cf763a..b7a1c23 100644 --- a/lustre/utils/obd.c +++ b/lustre/utils/obd.c @@ -5197,7 +5197,7 @@ int jt_pool_cmd(int argc, char **argv) if (ostnames_buf) free(ostnames_buf); } - /* fall through */ + fallthrough; } } /* switch */ -- 1.8.3.1