From 093c842d3e2aa2f66be9b06eca37b5c3e59114e0 Mon Sep 17 00:00:00 2001 From: Liwei Ge Date: Fri, 25 Sep 2020 09:12:08 +0800 Subject: [PATCH] use extern in header files when declaring global variables this change has given better compatible with both gcc8 and gcc10 toolchain, should be maintained util upstream fixes A common mistake in C is omitting extern when declaring a global variable in a header file. If the header is included by several files it results in multiple definitions of the same variable. In previous GCC versions this error is ignored. GCC 10 defaults to -fno-common, which means a linker error will now be reported. To fix this, use extern in header files when declaring global variables, and ensure each global is defined in exactly one C file. If tentative definitions of particular variables need to be placed in a common block, __attribute__((__common__)) can be used to force that behavior even in code compiled without -fcommon. As a workaround, legacy C code where all tentative definitions should be placed into a common block can be compiled with -fcommon. int x; // tentative definition - avoid in header files extern int y; // correct declaration in a header file this change has given better compatible with gcc10 toolchain, should be maintained util upstream fixes 'multiple definition ...' warnings refer url: https://gcc.gnu.org/gcc-10/porting_to.html Signed-off-by: Liwei Ge Signed-off-by: weitao zhou --- ...ckpolicy-remove-unused-te_assertions.patch | 42 +++++++++++++++++++ checkpolicy.spec | 11 ++++- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 1001-checkpolicy-remove-unused-te_assertions.patch diff --git a/1001-checkpolicy-remove-unused-te_assertions.patch b/1001-checkpolicy-remove-unused-te_assertions.patch new file mode 100644 index 0000000..01b567d --- /dev/null +++ b/1001-checkpolicy-remove-unused-te_assertions.patch @@ -0,0 +1,42 @@ +From 95d8f16ece96829109eb75a605b1459a25b5a6be Mon Sep 17 00:00:00 2001 +From: Ondrej Mosnacek +Date: Thu, 23 Jan 2020 13:57:15 +0100 +Subject: [PATCH] checkpolicy: remove unused te_assertions + +This variable is declared in a header file, but never defined or used. +The te_assert structure definition is only used in this declaration, so +remove both. + +Signed-off-by: Ondrej Mosnacek +--- + checkpolicy.h | 14 -------------- + 1 file changed, 14 deletions(-) + +diff --git a/checkpolicy.h b/checkpolicy.h +index 3868f1fa023b..f127687e72a6 100644 +--- a/checkpolicy.h ++++ b/checkpolicy.h +@@ -1,20 +1,6 @@ + #ifndef _CHECKPOLICY_H_ + #define _CHECKPOLICY_H_ + +-#include +- +-typedef struct te_assert { +- ebitmap_t stypes; +- ebitmap_t ttypes; +- ebitmap_t tclasses; +- int self; +- sepol_access_vector_t *avp; +- unsigned long line; +- struct te_assert *next; +-} te_assert_t; +- +-te_assert_t *te_assertions; +- + extern unsigned int policyvers; + + #endif +-- +2.24.1 + diff --git a/checkpolicy.spec b/checkpolicy.spec index ddee784..92b5165 100644 --- a/checkpolicy.spec +++ b/checkpolicy.spec @@ -1,14 +1,20 @@ +%define anolis_release .0.1 %define libselinuxver 2.9-1 %define libsepolver 2.9-1 Summary: SELinux policy compiler Name: checkpolicy Version: 2.9 -Release: 1%{?dist} +Release: 1%{anolis_release}%{?dist} License: GPLv2 Source: https://github.com/SELinuxProject/selinux/releases/download/20190315/checkpolicy-2.9.tar.gz # git format-patch 20190315 -- checkpolicy # i=1; for j in 00*patch; do printf "Patch%04d: %s\n" $i $j; i=$((i+1));done + +#Begin: Anolis customized patches +Patch1001: 1001-checkpolicy-remove-unused-te_assertions.patch +#End: Anolis customized patches + Conflicts: selinux-policy-base < 3.13.1-138 BuildRequires: gcc BuildRequires: byacc bison flex flex-static libsepol-static >= %{libsepolver} libselinux-devel >= %{libselinuxver} @@ -56,6 +62,9 @@ install test/dispol ${RPM_BUILD_ROOT}%{_bindir}/sedispol %{_bindir}/sedispol %changelog +* Thu Nov 18 2021 Weitao Zhou 2.9-1.0.1 +- Use extern in header files when declaring global variables for compatible gcc10 build + * Mon Mar 25 2019 Petr Lautrbach - 2.9-1 - SELinux userspace 2.9 release -- Gitee