From fbf3f4b4d79dc210aa1e7959e4c6318b4caccda8 Mon Sep 17 00:00:00 2001 From: "Xibo.Wang" Date: Thu, 29 Dec 2022 17:05:05 +0800 Subject: [PATCH] maint: avoid warnings from GCC8 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 --- backport-maint-avoid-warnings-from-GCC8.patch | 85 +++++++++++++++++++ patch.spec | 6 +- 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 backport-maint-avoid-warnings-from-GCC8.patch diff --git a/backport-maint-avoid-warnings-from-GCC8.patch b/backport-maint-avoid-warnings-from-GCC8.patch new file mode 100644 index 0000000..1b352ea --- /dev/null +++ b/backport-maint-avoid-warnings-from-GCC8.patch @@ -0,0 +1,85 @@ +From 040f114197ca1797bf84caedb252119c1ec07be5 Mon Sep 17 00:00:00 2001 +From: Jim Meyering +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 +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 + diff --git a/patch.spec b/patch.spec index d17e98f..916502d 100644 --- a/patch.spec +++ b/patch.spec @@ -1,6 +1,6 @@ Name: patch Version: 2.7.6 -Release: 16 +Release: 17 Summary: Utiliity which applies a patch file to original files. License: GPLv3+ URL: http://www.gnu.org/software/patch/patch.html @@ -17,6 +17,7 @@ Patch8: patch-selinux.patch Patch9: Avoid-set_file_attributes-sign-conversion-warnings.patch Patch10: Test-suite-compatibility-fixes.patch Patch11: Test-suite-fix-Korn-shell-incompatibility.patch +Patch12: backport-maint-avoid-warnings-from-GCC8.patch BuildRequires: gcc libselinux-devel libattr-devel ed Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-root @@ -59,6 +60,9 @@ CFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE" %{_mandir}/man1/* %changelog +* Wed Dec 28 2022 Xibo.Wang - 2.7.6-17 +- maint: avoid warnings from GCC8 + * Wed Dec 28 2022 Xibo.Wang - 2.7.6-16 - Test suite: fix Korn shell incompatibility