]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
domain_conf: Resolve Coverity REVERSE_INULL
authorJohn Ferlan <jferlan@redhat.com>
Wed, 27 Aug 2014 12:01:44 +0000 (08:01 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 27 Aug 2014 16:52:27 +0000 (12:52 -0400)
In virDomainActualNetDefFormat() a call to virDomainNetGetActualType(def)
was made before a check for (!def) a few lines later. This triggered
Coverity to note the possible NULL deref.  Just moving the initialization
to after the !def checks resolves the issue

src/conf/domain_conf.c

index 91f92a46519c35700950154d7389625490d68df0..53733379cdde12d1422db67cf75ba009f5767f4a 100644 (file)
@@ -16211,11 +16211,13 @@ virDomainActualNetDefFormat(virBufferPtr buf,
                             virDomainNetDefPtr def,
                             unsigned int flags)
 {
-    unsigned int type = virDomainNetGetActualType(def);
-    const char *typeStr = virDomainNetTypeToString(type);
+    unsigned int type;
+    const char *typeStr;
 
     if (!def)
         return 0;
+    type = virDomainNetGetActualType(def);
+    typeStr = virDomainNetTypeToString(type);
 
     if (!typeStr) {
         virReportError(VIR_ERR_INTERNAL_ERROR,