diff options
author | Jim Meyering <meyering@fb.com> | 2017-05-18 08:36:27 -0700 |
---|---|---|
committer | Jim Meyering <meyering@fb.com> | 2017-05-19 16:47:09 -0700 |
commit | 11fdf80b21f2b40a10687b9a3d16c852b19d512c (patch) | |
tree | 06b2c31b901f30ba9e802ab6487290e84a60c4f2 /lib/freopen-safer.c | |
parent | 06094e390b058f1318e7885b13c3b5c2aaa42927 (diff) | |
download | gnulib-11fdf80b21f2b40a10687b9a3d16c852b19d512c.tar.gz |
fallthrough: update for GCC 7/8
* lib/quotearg.c (FALLTHROUGH): New macro.
Use it whenever one switch case falls through into the next,
replacing "/* Fall through */" comments. This exposed one
instance of an unwarranted "fall through" comment: unwarranted
because it preceded a "goto" label not a case statement.
* lib/freopen-safer.c (freopen_safer): Likewise.
* lib/fts.c (leaf_optimization_applies): Likewise.
* lib/unistr/u8-uctomb-aux.c (u8_uctomb_aux): Likewise.
* tests/test-getopt_long.h (getopt_long_loop): Likewise.
* tests/test-tsearch.c (mangle_tree): Likewise. Also include
tests/macros.h for the definition.
* tests/test-argp.c (group1_parser): Likewise.
* tests/test-getopt.h (getopt_loop): Likewise.
Diffstat (limited to 'lib/freopen-safer.c')
-rw-r--r-- | lib/freopen-safer.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/freopen-safer.c b/lib/freopen-safer.c index 42dc39c7dd..be84ae68a2 100644 --- a/lib/freopen-safer.c +++ b/lib/freopen-safer.c @@ -26,6 +26,14 @@ #include <stdbool.h> #include <unistd.h> +#ifndef FALLTHROUGH +# if __GNUC__ < 7 +# define FALLTHROUGH ((void) 0) +# else +# define FALLTHROUGH __attribute__ ((__fallthrough__)) +# endif +#endif + /* Guarantee that FD is open; all smaller FDs must already be open. Return true if successful. */ static bool @@ -69,15 +77,15 @@ freopen_safer (char const *name, char const *mode, FILE *f) default: /* -1 or not a standard stream. */ if (dup2 (STDERR_FILENO, STDERR_FILENO) != STDERR_FILENO) protect_err = true; - /* fall through */ + FALLTHROUGH; case STDERR_FILENO: if (dup2 (STDOUT_FILENO, STDOUT_FILENO) != STDOUT_FILENO) protect_out = true; - /* fall through */ + FALLTHROUGH; case STDOUT_FILENO: if (dup2 (STDIN_FILENO, STDIN_FILENO) != STDIN_FILENO) protect_in = true; - /* fall through */ + FALLTHROUGH; case STDIN_FILENO: /* Nothing left to protect. */ break; |