[libvirt] [PATCH 6/6] conf: Fix build with picky GCC

Peter Krempa pkrempa at redhat.com
Thu Aug 25 22:42:50 UTC 2016


../../src/conf/domain_conf.c:4425:21: error: potential null pointer dereference [-Werror=null-dereference]
         switch (vcpu->hotpluggable) {
                 ~~~~^~~~~~~~~~~~~~
---
 src/conf/domain_conf.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ae3eb14..61f6dbb 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4422,6 +4422,10 @@ virDomainVcpuDefPostParse(virDomainDefPtr def)
     for (i = 0; i < maxvcpus; i++) {
         vcpu = virDomainDefGetVcpu(def, i);

+        /* impossible but some compilers don't like it */
+        if (!vcpu)
+            continue;
+
         switch (vcpu->hotpluggable) {
         case VIR_TRISTATE_BOOL_ABSENT:
             if (vcpu->online)
-- 
2.8.2




More information about the libvir-list mailing list