From fa300bbccebc4c35245c976779e7a15bdeca0734 Mon Sep 17 00:00:00 2001 From: laokz Date: Sat, 9 Sep 2023 17:19:50 +0800 Subject: [PATCH 1/2] riscv64: workaround gcc false positive -Werror Gcc 12.3 complained on riscv64: ``` In function 'cpuTestUpdateLiveCompare', inlined from 'cpuTestUpdateLive' at ../../tests/cputest.c:855:11: ../../tests/cputest.c:764:21: error: potential null pointer dereference [-Werror=null-dereference] 764 | featAct->policy == VIR_CPU_FEATURE_REQUIRE) || | ~~~~~~~^~~~~~~~ cc1: all warnings being treated as errors ``` But that is wrong because the code is robust enouth though complexed too to avoid NULL pointer derefence. To workaround the problem just disable -Werror on riscv64. --- libvirt.spec | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libvirt.spec b/libvirt.spec index 77e0a22..0587a5d 100644 --- a/libvirt.spec +++ b/libvirt.spec @@ -93,7 +93,9 @@ %define qemu_user qemu %define qemu_group qemu +%ifnarch riscv64 %define enable_werror --enable-werror +%endif %define tls_priority "@LIBVIRT,SYSTEM" @@ -101,7 +103,7 @@ Summary: Library providing a simple virtualization API Name: libvirt Version: 6.2.0 -Release: 59 +Release: 60 License: LGPLv2+ URL: https://libvirt.org/ @@ -2225,6 +2227,9 @@ exit 0 %changelog +* Mon Sep 11 2023 laokz - 6.2.0-60 +- disable -Werror for riscv64 to workaround gcc false positive + * Wed Aug 9 2023 Jiabo Feng - 6.2.0-59 - virnetsshsession: Adapt to change libssh2 API - selinux: Reflect context_str() type change -- Gitee From 6cee9a56780139e43413a12f05c50e33e5925f0d Mon Sep 17 00:00:00 2001 From: laokz Date: Thu, 14 Sep 2023 11:19:13 +0800 Subject: [PATCH 2/2] upstream --- ...s-Fixing-compiler-warning-in-cputest.patch | 41 +++++++++++++++++++ libvirt.spec | 3 +- 2 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 0001-tests-Fixing-compiler-warning-in-cputest.patch diff --git a/0001-tests-Fixing-compiler-warning-in-cputest.patch b/0001-tests-Fixing-compiler-warning-in-cputest.patch new file mode 100644 index 0000000..77923d8 --- /dev/null +++ b/0001-tests-Fixing-compiler-warning-in-cputest.patch @@ -0,0 +1,41 @@ +From 67c77744d74fe99a6b0e4ddef6869b305e29d6aa Mon Sep 17 00:00:00 2001 +From: Boris Fiuczynski +Date: Mon, 4 Apr 2022 20:22:37 +0200 +Subject: [PATCH] tests: Fixing compiler warning in cputest +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Found when building on Fedora 36 on s390x. + + C compiler for the host machine: gcc (gcc 12.0.1 "gcc (GCC) 12.0.1 20220308 (Red Hat 12.0.1-0)") + C linker for the host machine: gcc ld.bfd 2.37-24 + + In function ‘cpuTestUpdateLiveCompare’, + inlined from ‘cpuTestUpdateLive’ at ../dist-unpack/libvirt-8.2.5/tests/cputest.c:784:12: + ../dist-unpack/libvirt-8.2.5/tests/cputest.c:696:21: warning: potential null pointer dereference [-Wnull-dereference] + 696 | featAct->policy == VIR_CPU_FEATURE_REQUIRE) || + | ~~~~~~~^~~~~~~~ + +Signed-off-by: Boris Fiuczynski +Reviewed-by: Michal Privoznik +--- + tests/cputest.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tests/cputest.c b/tests/cputest.c +index 609b5df7c6..95fb37d15c 100644 +--- a/tests/cputest.c ++++ b/tests/cputest.c +@@ -692,7 +692,7 @@ cpuTestUpdateLiveCompare(virArch arch, + if ((cmp == 0 && + featAct->policy == VIR_CPU_FEATURE_REQUIRE && + featExp->policy == VIR_CPU_FEATURE_DISABLE) || +- (cmp < 0 && ++ (cmp < 0 && featAct && + featAct->policy == VIR_CPU_FEATURE_REQUIRE) || + (cmp > 0 && + featExp->policy == VIR_CPU_FEATURE_DISABLE)) { +-- +2.40.1 + diff --git a/libvirt.spec b/libvirt.spec index 0587a5d..e8b6545 100644 --- a/libvirt.spec +++ b/libvirt.spec @@ -93,9 +93,7 @@ %define qemu_user qemu %define qemu_group qemu -%ifnarch riscv64 %define enable_werror --enable-werror -%endif %define tls_priority "@LIBVIRT,SYSTEM" @@ -491,6 +489,7 @@ Patch0376: selinux-adapt-to-libselinux.patch Patch0377: Revert-selinux-adapt-to-libselinux.patch Patch0378: selinux-Reflect-context_str-type-change.patch Patch0379: virnetsshsession-Adapt-to-change-libssh2-API.patch +Patch0380: 0001-tests-Fixing-compiler-warning-in-cputest.patch Requires: libvirt-daemon = %{version}-%{release} Requires: libvirt-daemon-config-network = %{version}-%{release} -- Gitee