|
|
796689 |
commit ae81be0024ea4eaf139b7ba57e9a8ce9e4a163ec
|
|
|
796689 |
Author: Jim Meyering <jim@meyering.net>
|
|
|
796689 |
Date: Fri Apr 6 17:17:11 2018 -0700
|
|
|
796689 |
|
|
|
796689 |
maint: avoid warnings from GCC8
|
|
|
796689 |
|
|
|
796689 |
Hi Andreas,
|
|
|
796689 |
|
|
|
796689 |
I configured with --enable-gcc-warnings and bleeding-edge gcc
|
|
|
796689 |
(version 8.0.1 20180406) and hit some warning-escalated-to-errors.
|
|
|
796689 |
This fixes them:
|
|
|
796689 |
|
|
|
796689 |
>From a71ddb200dbe7ac0f9258796b5a51979b2740e88 Mon Sep 17 00:00:00 2001
|
|
|
796689 |
From: Jim Meyering <meyering@fb.com>
|
|
|
796689 |
Date: Fri, 6 Apr 2018 16:47:00 -0700
|
|
|
796689 |
Subject: [PATCH] maint: avoid warnings from GCC8
|
|
|
796689 |
|
|
|
796689 |
* src/common.h (FALLTHROUGH): Define.
|
|
|
796689 |
* src/patch.c (abort_hunk_context): Use FALLTHROUGH macro in place of
|
|
|
796689 |
a comment. This avoids a warning from -Wimplicit-fallthrough=.
|
|
|
796689 |
* src/pch.c (do_ed_script): Add otherwise unnecessary initialization
|
|
|
796689 |
to avoid warning from -Wmaybe-uninitialized.
|
|
|
796689 |
(another_hunk): Use FALLTHROUGH macro here, too, twice.
|
|
|
796689 |
|
|
|
796689 |
diff --git a/src/common.h b/src/common.h
|
|
|
796689 |
index ec50b40..904a3f8 100644
|
|
|
796689 |
--- a/src/common.h
|
|
|
796689 |
+++ b/src/common.h
|
|
|
796689 |
@@ -218,3 +218,11 @@ bool merge_hunk (int hunk, struct outstate *, lin where, bool *);
|
|
|
796689 |
#else
|
|
|
796689 |
# define merge_hunk(hunk, outstate, where, somefailed) false
|
|
|
796689 |
#endif
|
|
|
796689 |
+
|
|
|
796689 |
+#ifndef FALLTHROUGH
|
|
|
796689 |
+# if __GNUC__ < 7
|
|
|
796689 |
+# define FALLTHROUGH ((void) 0)
|
|
|
796689 |
+# else
|
|
|
796689 |
+# define FALLTHROUGH __attribute__ ((__fallthrough__))
|
|
|
796689 |
+# endif
|
|
|
796689 |
+#endif
|
|
|
796689 |
diff --git a/src/patch.c b/src/patch.c
|
|
|
796689 |
index 0fe6d72..1ae91d9 100644
|
|
|
796689 |
--- a/src/patch.c
|
|
|
796689 |
+++ b/src/patch.c
|
|
|
796689 |
@@ -1381,7 +1381,7 @@ abort_hunk_context (bool header, bool reverse)
|
|
|
796689 |
break;
|
|
|
796689 |
case ' ': case '-': case '+': case '!':
|
|
|
796689 |
fprintf (rejfp, "%c ", pch_char (i));
|
|
|
796689 |
- /* fall into */
|
|
|
796689 |
+ FALLTHROUGH;
|
|
|
796689 |
case '\n':
|
|
|
796689 |
pch_write_line (i, rejfp);
|
|
|
796689 |
break;
|
|
|
796689 |
diff --git a/src/pch.c b/src/pch.c
|
|
|
796689 |
index 1055542..cda3dfa 100644
|
|
|
796689 |
--- a/src/pch.c
|
|
|
796689 |
+++ b/src/pch.c
|
|
|
796689 |
@@ -1735,7 +1735,7 @@ another_hunk (enum diff difftype, bool rev)
|
|
|
796689 |
break;
|
|
|
796689 |
case '=':
|
|
|
796689 |
ch = ' ';
|
|
|
796689 |
- /* FALL THROUGH */
|
|
|
796689 |
+ FALLTHROUGH;
|
|
|
796689 |
case ' ':
|
|
|
796689 |
if (fillsrc > p_ptrn_lines) {
|
|
|
796689 |
free(s);
|
|
|
796689 |
@@ -1756,7 +1756,7 @@ another_hunk (enum diff difftype, bool rev)
|
|
|
796689 |
p_end = fillsrc-1;
|
|
|
796689 |
return -1;
|
|
|
796689 |
}
|
|
|
796689 |
- /* FALL THROUGH */
|
|
|
796689 |
+ FALLTHROUGH;
|
|
|
796689 |
case '+':
|
|
|
796689 |
if (filldst > p_end) {
|
|
|
796689 |
free(s);
|
|
|
796689 |
@@ -2394,8 +2394,7 @@ do_ed_script (char const *inname, char const *outname,
|
|
|
796689 |
size_t chars_read;
|
|
|
796689 |
FILE *tmpfp = 0;
|
|
|
796689 |
char const *tmpname;
|
|
|
796689 |
- int tmpfd;
|
|
|
796689 |
- pid_t pid;
|
|
|
796689 |
+ int tmpfd = -1; /* placate gcc's -Wmaybe-uninitialized */
|
|
|
796689 |
int exclusive = *outname_needs_removal ? 0 : O_EXCL;
|
|
|
796689 |
char const **ed_argv;
|
|
|
796689 |
int stdin_dup, status;
|