backport from https://git.savannah.gnu.org/gitweb/?p=patch.git;a=commit;h=ae81be0 I configured with --enable-gcc-warnings and bleeding-edge gcc (version 8.0.1 20180406) and hit some warning-escalated-to-errors. This fixes them: * src/common.h (FALLTHROUGH): Define. * src/patch.c (abort_hunk_context): Use FALLTHROUGH macro in place of a comment. This avoids a warning from -Wimplicit-fallthrough=. * src/pch.c (do_ed_script): Add otherwise unnecessary initialization to avoid warning from -Wmaybe-uninitialized. (another_hunk): Use FALLTHROUGH macro here, too, twice. Signed-off-by: Xibo.Wang <wangxb12@chinatelecom.cn>
86 lines
2.3 KiB
Diff
86 lines
2.3 KiB
Diff
From 040f114197ca1797bf84caedb252119c1ec07be5 Mon Sep 17 00:00:00 2001
|
|
From: Jim Meyering <jim@meyering.net>
|
|
Date: Fri, 6 Apr 2018 17:17:11 -0700
|
|
Subject: [PATCH] maint: avoid warnings from GCC8
|
|
|
|
Hi Andreas,
|
|
|
|
I configured with --enable-gcc-warnings and bleeding-edge gcc
|
|
(version 8.0.1 20180406) and hit some warning-escalated-to-errors.
|
|
This fixes them:
|
|
|
|
>From a71ddb200dbe7ac0f9258796b5a51979b2740e88 Mon Sep 17 00:00:00 2001
|
|
From: Jim Meyering <meyering@fb.com>
|
|
Date: Fri, 6 Apr 2018 16:47:00 -0700
|
|
Subject: [PATCH] maint: avoid warnings from GCC8
|
|
|
|
* src/common.h (FALLTHROUGH): Define.
|
|
* src/patch.c (abort_hunk_context): Use FALLTHROUGH macro in place of
|
|
a comment. This avoids a warning from -Wimplicit-fallthrough=.
|
|
* src/pch.c (do_ed_script): Add otherwise unnecessary initialization
|
|
to avoid warning from -Wmaybe-uninitialized.
|
|
(another_hunk): Use FALLTHROUGH macro here, too, twice.
|
|
|
|
Conflicts:
|
|
src/pch.c
|
|
---
|
|
src/common.h | 8 ++++++++
|
|
src/patch.c | 2 +-
|
|
src/pch.c | 4 ++--
|
|
3 files changed, 11 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/src/common.h b/src/common.h
|
|
index 2524628..dfac17a 100644
|
|
--- a/src/common.h
|
|
+++ b/src/common.h
|
|
@@ -223,3 +223,11 @@ bool merge_hunk (int hunk, struct outstate *, lin where, bool *);
|
|
#else
|
|
# define merge_hunk(hunk, outstate, where, somefailed) false
|
|
#endif
|
|
+
|
|
+#ifndef FALLTHROUGH
|
|
+# if __GNUC__ < 7
|
|
+# define FALLTHROUGH ((void) 0)
|
|
+# else
|
|
+# define FALLTHROUGH __attribute__ ((__fallthrough__))
|
|
+# endif
|
|
+#endif
|
|
diff --git a/src/patch.c b/src/patch.c
|
|
index 065a05a..99a5904 100644
|
|
--- a/src/patch.c
|
|
+++ b/src/patch.c
|
|
@@ -1382,7 +1382,7 @@ abort_hunk_context (bool header, bool reverse)
|
|
break;
|
|
case ' ': case '-': case '+': case '!':
|
|
fprintf (rejfp, "%c ", pch_char (i));
|
|
- /* fall into */
|
|
+ FALLTHROUGH;
|
|
case '\n':
|
|
pch_write_line (i, rejfp);
|
|
break;
|
|
diff --git a/src/pch.c b/src/pch.c
|
|
index 8dda771..4368561 100644
|
|
--- a/src/pch.c
|
|
+++ b/src/pch.c
|
|
@@ -1742,7 +1742,7 @@ another_hunk (enum diff difftype, bool rev)
|
|
break;
|
|
case '=':
|
|
ch = ' ';
|
|
- /* FALL THROUGH */
|
|
+ FALLTHROUGH;
|
|
case ' ':
|
|
if (fillsrc > p_ptrn_lines) {
|
|
free(s);
|
|
@@ -1763,7 +1763,7 @@ another_hunk (enum diff difftype, bool rev)
|
|
p_end = fillsrc-1;
|
|
return -1;
|
|
}
|
|
- /* FALL THROUGH */
|
|
+ FALLTHROUGH;
|
|
case '+':
|
|
if (filldst > p_end) {
|
|
free(s);
|
|
--
|
|
1.8.3.1
|
|
|