]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
conf: Report error for unknown shmem ioeventfd value
authorLuyao Huang <lhuang@redhat.com>
Mon, 11 May 2015 12:59:37 +0000 (20:59 +0800)
committerMartin Kletzander <mkletzan@redhat.com>
Mon, 11 May 2015 14:05:07 +0000 (16:05 +0200)
https://bugzilla.redhat.com/show_bug.cgi?id=1220265

Passing the return value to an enum directly is not safe.  Fix this by
comparing the true integer result of virTristateSwitchTypeFromString().

Signed-off-by: Luyao Huang <lhuang@redhat.com>
src/conf/domain_conf.c

index e3e0f637d50fb61a32acaff38fc880b7b4b15945..19b4d95150c91a8712057ec1170892a93a484841 100644 (file)
@@ -10829,12 +10829,16 @@ virDomainShmemDefParseXML(xmlNodePtr node,
         }
         VIR_FREE(tmp);
 
-        if ((tmp = virXMLPropString(msi, "ioeventfd")) &&
-            (def->msi.ioeventfd = virTristateSwitchTypeFromString(tmp)) <= 0) {
-            virReportError(VIR_ERR_XML_ERROR,
-                           _("invalid msi ioeventfd setting for shmem: '%s'"),
-                           tmp);
-            goto cleanup;
+        if ((tmp = virXMLPropString(msi, "ioeventfd"))) {
+            int val;
+
+            if ((val = virTristateSwitchTypeFromString(tmp)) <= 0) {
+                virReportError(VIR_ERR_XML_ERROR,
+                               _("invalid msi ioeventfd setting for shmem: '%s'"),
+                               tmp);
+                goto cleanup;
+            }
+            def->msi.ioeventfd = val;
         }
         VIR_FREE(tmp);
     }