]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Fix build with picky GCC
authorPeter Krempa <pkrempa@redhat.com>
Thu, 25 Aug 2016 22:40:09 +0000 (18:40 -0400)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 26 Aug 2016 15:32:38 +0000 (11:32 -0400)
../../src/conf/domain_conf.c:4425:21: error: potential null pointer dereference [-Werror=null-dereference]
         switch (vcpu->hotpluggable) {
                 ~~~~^~~~~~~~~~~~~~

src/conf/domain_conf.c

index ae3eb14c5a38efc69f4b15bf61c7fcbf665267c2..61f6dbbbaff2aa7e9f30d489f8961168e202ff19 100644 (file)
@@ -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)