Discussion:
[PATCH] maint: update to work with GCC7's -Werror=implicit-fallthrough=
Add Reply
Jim Meyering
2017-06-10 17:13:57 UTC
Reply
Permalink
Raw Message
I've just pushed this:

From b47afb1438293decd3982d8097157411ba6b5ed4 Mon Sep 17 00:00:00 2001
From: Jim Meyering <***@fb.com>
Date: Sat, 10 Jun 2017 10:11:47 -0700
Subject: [PATCH] maint: update to work with GCC7's
-Werror=implicit-fallthrough=

* lib/savewd.c (FALLTHROUGH): Define.
(savewd_save, savewd_restore): Use this, rather than a comment,
whenever one switch case falls through into the next.
---
ChangeLog | 7 +++++++
lib/savewd.c | 12 ++++++++++--
2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 19fa986e4..abc3c174c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2017-06-10 Jim Meyering <***@fb.com>
+
+ maint: update to work with GCC7's -Werror=implicit-fallthrough=
+ * lib/savewd.c (FALLTHROUGH): Define.
+ (savewd_save, savewd_restore): Use this, rather than a comment,
+ whenever one switch case falls through into the next.
+
2017-06-08 Bruno Haible <***@clisp.org>

host-cpu-c-abi: Support for aarch64 ILP32 ABI.
diff --git a/lib/savewd.c b/lib/savewd.c
index 33fd85bd5..4579d3066 100644
--- a/lib/savewd.c
+++ b/lib/savewd.c
@@ -36,6 +36,14 @@
#include "dosname.h"
#include "fcntl-safer.h"

+#ifndef FALLTHROUGH
+# if __GNUC__ < 7
+# define FALLTHROUGH ((void) 0)
+# else
+# define FALLTHROUGH __attribute__ ((__fallthrough__))
+# endif
+#endif
+
/* Save the working directory into *WD, if it hasn't been saved
already. Return true if a child has been forked to do the real
work. */
@@ -63,7 +71,7 @@ savewd_save (struct savewd *wd)
}
wd->state = FORKING_STATE;
wd->val.child = -1;
- /* Fall through. */
+ FALLTHROUGH;
case FORKING_STATE:
if (wd->val.child < 0)
{
@@ -188,7 +196,7 @@ savewd_restore (struct savewd *wd, int status)
wd->state = ERROR_STATE;
wd->val.errnum = chdir_errno;
}
- /* Fall through. */
+ FALLTHROUGH;
case ERROR_STATE:
/* Report an error if asked to restore the working directory. */
errno = wd->val.errnum;
--
2.13.0
Loading...