[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] maint: update to work with GCC7's -Werror=implicit-fallthrough=
From: |
Jim Meyering |
Subject: |
[PATCH] maint: update to work with GCC7's -Werror=implicit-fallthrough= |
Date: |
Sat, 10 Jun 2017 13:04:50 -0700 |
This (with today's gnulib/lib/savewd.c change) addresses all of
coreutils' build errors due to -Werror=implicit-fallthrough=
>From 68f9e301d1737158f8ec5455c019826431bdba93 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sat, 10 Jun 2017 10:02:31 -0700
Subject: [PATCH] maint: update to work with GCC7's
-Werror=implicit-fallthrough=
* 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.
---
src/basename.c | 2 +-
src/cp.c | 2 +-
src/dircolors.c | 2 +-
src/echo.c | 2 +-
src/fold.c | 2 +-
src/join.c | 2 +-
src/kill.c | 6 +++---
src/ls.c | 4 ++--
src/sort.c | 6 +++---
src/stat.c | 2 +-
src/system.h | 8 ++++++++
src/tail.c | 4 ++--
src/test.c | 2 +-
src/wc.c | 8 ++++----
src/who.c | 2 +-
15 files changed, 31 insertions(+), 23 deletions(-)
diff --git a/src/basename.c b/src/basename.c
index d593197e8..5c0f11d84 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 a2f67d864..ec09ed5dd 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 d0cfdbade..069f44872 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 0df0f25b7..852309d23 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 6c1459d42..05c05f6ba 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 082f50893..93570adeb 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 fd998790d..330fa8ff4 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 73498181e..9477d31be 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 e5fecf90a..d9a2edbfd 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 d085cd059..f5e930b1b 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 bbd8b13b5..71ff8419e 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 3582321bc..34fa25c90 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 dcb83536c..05774d325 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 be4f3062d..8a656c3d0 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 497589d92..d4454f8e5 100644
--- 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);
--
2.13.0
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] maint: update to work with GCC7's -Werror=implicit-fallthrough=,
Jim Meyering <=