summaryrefslogtreecommitdiffstats
path: root/patches/0010-maint-avoid-warnings-from-GCC8.patch
blob: e1f9e4e0e8c170bbc3280c5922b3ac04d4d43378 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
From ae81be0024ea4eaf139b7ba57e9a8ce9e4a163ec Mon Sep 17 00:00:00 2001
From: Jim Meyering <jim@meyering.net>
Date: Fri, 6 Apr 2018 17:17:11 -0700
Subject: [PATCH 10/17] 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.
---
 src/common.h | 8 ++++++++
 src/patch.c  | 2 +-
 src/pch.c    | 7 +++----
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/common.h b/src/common.h
index ec50b40..904a3f8 100644
--- a/src/common.h
+++ b/src/common.h
@@ -218,3 +218,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 0fe6d72..1ae91d9 100644
--- a/src/patch.c
+++ b/src/patch.c
@@ -1381,7 +1381,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 1055542..cda3dfa 100644
--- a/src/pch.c
+++ b/src/pch.c
@@ -1735,7 +1735,7 @@ another_hunk (enum diff difftype, bool rev)
 		break;
 	    case '=':
 		ch = ' ';
-		/* FALL THROUGH */
+		FALLTHROUGH;
 	    case ' ':
 		if (fillsrc > p_ptrn_lines) {
 		    free(s);
@@ -1756,7 +1756,7 @@ another_hunk (enum diff difftype, bool rev)
 		    p_end = fillsrc-1;
 		    return -1;
 		}
-		/* FALL THROUGH */
+		FALLTHROUGH;
 	    case '+':
 		if (filldst > p_end) {
 		    free(s);
@@ -2394,8 +2394,7 @@ do_ed_script (char const *inname, char const *outname,
     size_t chars_read;
     FILE *tmpfp = 0;
     char const *tmpname;
-    int tmpfd;
-    pid_t pid;
+    int tmpfd = -1; /* placate gcc's -Wmaybe-uninitialized */
     int exclusive = *outname_needs_removal ? 0 : O_EXCL;
     char const **ed_argv;
     int stdin_dup, status;
-- 
2.11.0