]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: Fixing compiler warning in cputest
authorBoris Fiuczynski <fiuczy@linux.ibm.com>
Mon, 4 Apr 2022 18:22:37 +0000 (20:22 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 5 Apr 2022 08:32:41 +0000 (10:32 +0200)
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 <fiuczy@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tests/cputest.c

index 609b5df7c6bfa2fafdeb422539eef33109180c96..95fb37d15c1e2e5d3615bf052bd73f59717c9784 100644 (file)
@@ -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)) {