]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
maint: update to work with GCC7's -Werror=implicit-fallthrough=5
authorJim Meyering <meyering@fb.com>
Sat, 10 Jun 2017 17:02:31 +0000 (10:02 -0700)
committerJim Meyering <meyering@fb.com>
Sun, 11 Jun 2017 02:40:49 +0000 (19:40 -0700)
* src/system.h (FALLTHROUGH): Define.
* src/cp.c (main): Use new FALLTHROUGH macro in place of comments.
* src/basename.c (main): Likewise.
* src/dircolors.c (append_quoted): Likewise.
* src/echo.c (main): Likewise.
* src/fold.c (main): Likewise.
* src/join.c (main): Likewise.
* src/kill.c (main): Likewise.
* src/ls.c (get_funky_string, gobble_file): Likewise.
* src/sort.c (parse_field_count, main): Likewise.
* src/stat.c (print_it): Likewise.
* src/tail.c (parse_obsolete_option): Likewise.
* src/test.c (posixtest): Likewise.
* src/wc.c (wc): Likewise.
* src/who.c (main): Likewise.

15 files changed:
src/basename.c
src/cp.c
src/dircolors.c
src/echo.c
src/fold.c
src/join.c
src/kill.c
src/ls.c
src/sort.c
src/stat.c
src/system.h
src/tail.c
src/test.c
src/wc.c
src/who.c

index d593197e80946abb02d0fcb24a33b61fbcba54f2..5c0f11d848379e082fef4fe79d772a06e4af2026 100644 (file)
@@ -147,7 +147,7 @@ main (int argc, char **argv)
         case 's':
           suffix = optarg;
           /* -s implies -a, so...  */
-          /* fall through */
+          FALLTHROUGH;
 
         case 'a':
           multiple_names = true;
index a2f67d864b477738a6f36d727b660e6cb9af4703..ec09ed5ddcb0e707e367206cdaced4bfc329ebd1 100644 (file)
--- a/src/cp.c
+++ b/src/cp.c
@@ -1045,7 +1045,7 @@ main (int argc, char **argv)
               x.require_preserve = true;
               break;
             }
-          /* fall through */
+          FALLTHROUGH;
 
         case 'p':
           x.preserve_ownership = true;
index d0cfdbadeac7f884acafb217220d75caf8361256..069f448720f1742072344b7e2d85ed66f56ff158 100644 (file)
@@ -216,7 +216,7 @@ append_quoted (const char *str)
         case '=':
           if (need_backslash)
             APPEND_CHAR ('\\');
-          /* Fall through */
+          FALLTHROUGH;
 
         default:
           need_backslash = true;
index 0df0f25b7356f740edcfaba535e476c1c5522717..852309d238b2ef025d6765ea70fc558825061931 100644 (file)
@@ -231,7 +231,7 @@ just_echo:
                       if (! ('0' <= *s && *s <= '7'))
                         break;
                       c = *s++;
-                      /* Fall through.  */
+                      FALLTHROUGH;
                     case '1': case '2': case '3':
                     case '4': case '5': case '6': case '7':
                       c -= '0';
index 6c1459d42e463d19d3275b3e85350392cf65a3e2..05c05f6ba0e47429f2e4ed4546ee0e49d58f264c 100644 (file)
@@ -278,7 +278,7 @@ main (int argc, char **argv)
               optargbuf[1] = '\0';
               optarg = optargbuf;
             }
-          /* Fall through.  */
+          FALLTHROUGH;
         case 'w':              /* Line width. */
           width = xdectoumax (optarg, 1, SIZE_MAX - TAB_WIDTH - 1, "",
                               _("invalid number of columns"), 0);
index 082f50893f8dc87bdf71b8de7b968d71980eba27..93570adeb4437b239215245bcbca8760f60368ab 100644 (file)
@@ -1041,7 +1041,7 @@ main (int argc, char **argv)
         {
         case 'v':
             print_pairables = false;
-            /* Fall through.  */
+            FALLTHROUGH;
 
         case 'a':
           {
index fd998790db4e8d49220a754df9e72b01a3a6471f..330fa8ff43808f0fef7512a97189cb5f92287fde 100644 (file)
@@ -246,7 +246,7 @@ main (int argc, char **argv)
             optind--;
             goto no_more_options;
           }
-        /* Fall through.  */
+        FALLTHROUGH;
       case 'A': case 'B': case 'C': case 'D': case 'E':
       case 'F': case 'G': case 'H': case 'I': case 'J':
       case 'K': /*case 'L':*/ case 'M': case 'N': case 'O':
@@ -261,7 +261,7 @@ main (int argc, char **argv)
             usage (EXIT_FAILURE);
           }
         optarg--;
-        /* Fall through.  */
+        FALLTHROUGH;
       case 'n': /* -n is not documented, but is for Bash compatibility.  */
       case 's':
         if (0 <= signum)
@@ -277,7 +277,7 @@ main (int argc, char **argv)
       case 'L': /* -L is not documented, but is for procps compatibility.  */
       case 't':
         table = true;
-        /* Fall through.  */
+        FALLTHROUGH;
       case 'l':
         if (list)
           {
index 73498181eda4b8fa7304229d2c3ebe138e3309fa..9477d31be3366b1c983ea0f0169b4521e2f00a9e 100644 (file)
--- a/src/ls.c
+++ b/src/ls.c
@@ -2269,7 +2269,7 @@ get_funky_string (char **dest, const char **src, bool equals_end,
                   state = ST_END; /* End */
                   break;
                 }
-              /* else fall through */
+              FALLTHROUGH;
             default:
               *(q++) = *(p++);
               ++count;
@@ -3157,7 +3157,7 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
                  directory, and --dereference-command-line-symlink-to-dir is
                  in effect.  Fall through so that we call lstat instead.  */
             }
-          /* fall through */
+          FALLTHROUGH;
 
         default: /* DEREF_NEVER */
           err = lstat (absolute_name, &f->stat);
index e5fecf90af45b911807d6bb2234b168581dcf4d9..d9a2edbfde5d2aeebc7e4b58e863dee328909b80 100644 (file)
@@ -4086,7 +4086,7 @@ parse_field_count (char const *string, size_t *val, char const *msgid)
       *val = n;
       if (*val == n)
         break;
-      /* Fall through.  */
+      FALLTHROUGH;
     case LONGINT_OVERFLOW:
     case LONGINT_OVERFLOW | LONGINT_INVALID_SUFFIX_CHAR:
       *val = SIZE_MAX;
@@ -4386,7 +4386,7 @@ main (int argc, char **argv)
 
         case SORT_OPTION:
           c = XARGMATCH ("--sort", optarg, sort_args, sort_types);
-          /* Fall through. */
+          FALLTHROUGH;
         case 'b':
         case 'd':
         case 'f':
@@ -4410,7 +4410,7 @@ main (int argc, char **argv)
           c = (optarg
                ? XARGMATCH ("--check", optarg, check_args, check_types)
                : 'c');
-          /* Fall through.  */
+          FALLTHROUGH;
         case 'c':
         case 'C':
           if (checkonly && checkonly != c)
index d085cd059c2b9748cf41d042ae5afb46279075d5..f5e930b1be54c26a8bf09544660f35b1c56acb78 100644 (file)
@@ -1252,7 +1252,7 @@ print_it (char const *format, int fd, char const *filename,
               {
               case '\0':
                 --b;
-                /* fall through */
+                FALLTHROUGH;
               case '%':
                 if (0 < len)
                   {
index bbd8b13b57a0a91a8116418aa20bf3d0ca407a69..71ff8419e112465148c2012c6192708e1ac40d0e 100644 (file)
@@ -781,3 +781,11 @@ is_ENOTSUP (int err)
   quotearg_style (shell_escape_always_quoting_style, arg)
 #define quoteaf_n(n, arg) \
   quotearg_n_style (n, shell_escape_always_quoting_style, arg)
+
+#ifndef FALLTHROUGH
+# if __GNUC__ < 7
+#  define FALLTHROUGH ((void) 0)
+# else
+#  define FALLTHROUGH __attribute__ ((__fallthrough__))
+# endif
+#endif
index 3582321bce882b3e731871bcf87cd5bb09e5c07a..34fa25c904b3176c3d0dce7eb944bb1c670fab5c 100644 (file)
@@ -2064,8 +2064,8 @@ parse_obsolete_option (int argc, char * const *argv, uintmax_t *n_units)
 
   switch (*p)
     {
-    case 'b': default_count *= 512;    /* Fall through.  */
-    case 'c': t_count_lines = false;   /* Fall through.  */
+    case 'b': default_count *= 512; FALLTHROUGH;
+    case 'c': t_count_lines = false; FALLTHROUGH;
     case 'l': p++; break;
     }
 
index dcb83536c88c1cd181fab28ef0668a9622d49065..05774d32587dfe329b86db3d233f46544b50ff63 100644 (file)
@@ -686,7 +686,7 @@ posixtest (int nargs)
             advance (false);
             break;
           }
-        /* FALLTHROUGH */
+        FALLTHROUGH;
       case 5:
       default:
         if (nargs <= 0)
index be4f3062dfd996703192dd35330989a446f55afb..8a656c3d0bc201081367734d1a88ff160d0704b0 100644 (file)
--- a/src/wc.c
+++ b/src/wc.c
@@ -426,7 +426,7 @@ wc (int fd, char const *file_x, struct fstatus *fstatus, off_t current_pos)
                 {
                 case '\n':
                   lines++;
-                  /* Fall through. */
+                  FALLTHROUGH;
                 case '\r':
                 case '\f':
                   if (linepos > linelength)
@@ -438,7 +438,7 @@ wc (int fd, char const *file_x, struct fstatus *fstatus, off_t current_pos)
                   goto mb_word_separator;
                 case ' ':
                   linepos++;
-                  /* Fall through. */
+                  FALLTHROUGH;
                 case '\v':
                 mb_word_separator:
                   words += in_word;
@@ -500,7 +500,7 @@ wc (int fd, char const *file_x, struct fstatus *fstatus, off_t current_pos)
                 {
                 case '\n':
                   lines++;
-                  /* Fall through. */
+                  FALLTHROUGH;
                 case '\r':
                 case '\f':
                   if (linepos > linelength)
@@ -512,7 +512,7 @@ wc (int fd, char const *file_x, struct fstatus *fstatus, off_t current_pos)
                   goto word_separator;
                 case ' ':
                   linepos++;
-                  /* Fall through. */
+                  FALLTHROUGH;
                 case '\v':
                 word_separator:
                   words += in_word;
index 497589d9207ae73c37498ef6404f48e4a6697282..d4454f8e5b57038982e36aa20535420894f42194 100644 (file)
--- a/src/who.c
+++ b/src/who.c
@@ -816,7 +816,7 @@ main (int argc, char **argv)
     {
     case 2:                    /* who <blurf> <glop> */
       my_line_only = true;
-      /* Fall through.  */
+      FALLTHROUGH;
     case -1:
     case 0:                    /* who */
       who (UTMP_FILE, READ_UTMP_CHECK_PIDS);