!15 maint: avoid warnings from GCC8

From: @CTC-XiboWang 
Reviewed-by: @xiezhipeng1 
Signed-off-by: @xiezhipeng1
This commit is contained in:
openeuler-ci-bot 2022-12-29 09:17:21 +00:00 committed by Gitee
commit 044c5d4801
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 90 additions and 1 deletions

View File

@ -0,0 +1,85 @@
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

View File

@ -1,6 +1,6 @@
Name: patch Name: patch
Version: 2.7.6 Version: 2.7.6
Release: 16 Release: 17
Summary: Utiliity which applies a patch file to original files. Summary: Utiliity which applies a patch file to original files.
License: GPLv3+ License: GPLv3+
URL: http://www.gnu.org/software/patch/patch.html 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 Patch9: Avoid-set_file_attributes-sign-conversion-warnings.patch
Patch10: Test-suite-compatibility-fixes.patch Patch10: Test-suite-compatibility-fixes.patch
Patch11: Test-suite-fix-Korn-shell-incompatibility.patch Patch11: Test-suite-fix-Korn-shell-incompatibility.patch
Patch12: backport-maint-avoid-warnings-from-GCC8.patch
BuildRequires: gcc libselinux-devel libattr-devel ed BuildRequires: gcc libselinux-devel libattr-devel ed
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-root Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-root
@ -59,6 +60,9 @@ CFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE"
%{_mandir}/man1/* %{_mandir}/man1/*
%changelog %changelog
* Wed Dec 28 2022 Xibo.Wang <wangxb12@chinatelecom.cn> - 2.7.6-17
- maint: avoid warnings from GCC8
* Wed Dec 28 2022 Xibo.Wang <wangxb12@chinatelecom.cn> - 2.7.6-16 * Wed Dec 28 2022 Xibo.Wang <wangxb12@chinatelecom.cn> - 2.7.6-16
- Test suite: fix Korn shell incompatibility - Test suite: fix Korn shell incompatibility