Whamcloud - gitweb
LU-15220 utils: use 'fallthrough' pseudo keyword for switch
authorJian Yu <yujian@whamcloud.com>
Sun, 23 Jan 2022 10:25:29 +0000 (02:25 -0800)
committerAndreas Dilger <adilger@whamcloud.com>
Mon, 24 Jan 2022 05:42:02 +0000 (05:42 +0000)
'/* 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.

Lustre-change: https://review.whamcloud.com/46270
Lustre-commit: TBD (from 6cae135625159733c0fc1b02ad0cd3ee25ff4d2b)

Test-Parameters: trivial
Change-Id: Icace4c9953950f86d3c48068d8c6bba7dd1160a7
Signed-off-by: Jian Yu <yujian@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/46276
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/include/lustre/lustreapi.h
lustre/utils/gss/gss_util.h
lustre/utils/gss/svcgssd_proc.c
lustre/utils/lfs.c
lustre/utils/lustre_rsync.c
lustre/utils/obd.c

index 272390f..ed1c3d7 100644 (file)
@@ -62,6 +62,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
index e7cc128..a251fca 100644 (file)
 #include <stdlib.h>
 #include "write_bytes.h"
 
+#ifndef fallthrough
+#define fallthrough do {} while (0)  /* fallthrough */
+#endif
+
 extern char *this_realm;
 extern gss_cred_id_t   gssd_creds;
 
index da8dcf8..57176e9 100644 (file)
@@ -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;
index 090223a..6360ddd 100644 (file)
@@ -3695,7 +3695,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);
@@ -4466,19 +4466,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:
@@ -4792,6 +4798,7 @@ static int lfs_find(int argc, char **argv)
                        xsign = &param.fp_asign;
                        param.fp_exclude_atime = !!neg_opt;
                        /* no break, this falls through to 'B' for btime */
+                       fallthrough;
                case 'B':
                        if (c == 'B') {
                                xtime = &param.fp_btime;
@@ -4799,6 +4806,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 = &param.fp_ctime;
@@ -4806,6 +4814,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 = &param.fp_mtime;
index 2c419bc..2506499 100644 (file)
@@ -1684,6 +1684,7 @@ int lr_replicate(void)
                         * Nothing needs to be done for these entries
                         * fallthrough
                         */
+                       fallthrough;
                default:
                        break;
                }
index 86ba788..5bec61e 100644 (file)
@@ -5124,7 +5124,7 @@ int jt_pool_cmd(int argc, char **argv)
                        if (ostnames_buf)
                                free(ostnames_buf);
                }
-               /* fall through */
+               fallthrough;
        }
        } /* switch */