From: Jim Meyering Date: Sat, 10 Jun 2017 17:02:31 +0000 (-0700) Subject: maint: update to work with GCC7's -Werror=implicit-fallthrough=5 X-Git-Tag: v8.28~70 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=28042c4ff56ce1c22d620d3a3b0d6f52d98dd0e9;p=thirdparty%2Fcoreutils.git maint: update to work with GCC7's -Werror=implicit-fallthrough=5 * 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. --- diff --git a/src/basename.c b/src/basename.c index d593197e80..5c0f11d848 100644 --- a/src/basename.c +++ b/src/basename.c @@ -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; diff --git a/src/cp.c b/src/cp.c index a2f67d864b..ec09ed5ddc 100644 --- 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; diff --git a/src/dircolors.c b/src/dircolors.c index d0cfdbadea..069f448720 100644 --- a/src/dircolors.c +++ b/src/dircolors.c @@ -216,7 +216,7 @@ append_quoted (const char *str) case '=': if (need_backslash) APPEND_CHAR ('\\'); - /* Fall through */ + FALLTHROUGH; default: need_backslash = true; diff --git a/src/echo.c b/src/echo.c index 0df0f25b73..852309d238 100644 --- a/src/echo.c +++ b/src/echo.c @@ -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'; diff --git a/src/fold.c b/src/fold.c index 6c1459d42e..05c05f6ba0 100644 --- a/src/fold.c +++ b/src/fold.c @@ -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); diff --git a/src/join.c b/src/join.c index 082f50893f..93570adeb4 100644 --- a/src/join.c +++ b/src/join.c @@ -1041,7 +1041,7 @@ main (int argc, char **argv) { case 'v': print_pairables = false; - /* Fall through. */ + FALLTHROUGH; case 'a': { diff --git a/src/kill.c b/src/kill.c index fd998790db..330fa8ff43 100644 --- a/src/kill.c +++ b/src/kill.c @@ -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) { diff --git a/src/ls.c b/src/ls.c index 73498181ed..9477d31be3 100644 --- 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); diff --git a/src/sort.c b/src/sort.c index e5fecf90af..d9a2edbfde 100644 --- a/src/sort.c +++ b/src/sort.c @@ -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) diff --git a/src/stat.c b/src/stat.c index d085cd059c..f5e930b1be 100644 --- a/src/stat.c +++ b/src/stat.c @@ -1252,7 +1252,7 @@ print_it (char const *format, int fd, char const *filename, { case '\0': --b; - /* fall through */ + FALLTHROUGH; case '%': if (0 < len) { diff --git a/src/system.h b/src/system.h index bbd8b13b57..71ff8419e1 100644 --- a/src/system.h +++ b/src/system.h @@ -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 diff --git a/src/tail.c b/src/tail.c index 3582321bce..34fa25c904 100644 --- a/src/tail.c +++ b/src/tail.c @@ -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; } diff --git a/src/test.c b/src/test.c index dcb83536c8..05774d3258 100644 --- a/src/test.c +++ b/src/test.c @@ -686,7 +686,7 @@ posixtest (int nargs) advance (false); break; } - /* FALLTHROUGH */ + FALLTHROUGH; case 5: default: if (nargs <= 0) diff --git a/src/wc.c b/src/wc.c index be4f3062df..8a656c3d0b 100644 --- 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; diff --git a/src/who.c b/src/who.c index 497589d920..d4454f8e5b 100644 --- a/src/who.c +++ b/src/who.c @@ -816,7 +816,7 @@ main (int argc, char **argv) { case 2: /* who */ my_line_only = true; - /* Fall through. */ + FALLTHROUGH; case -1: case 0: /* who */ who (UTMP_FILE, READ_UTMP_CHECK_PIDS);