]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Resolve Coverity NEGATIVE_RETURNS
authorJohn Ferlan <jferlan@redhat.com>
Mon, 18 May 2015 12:42:46 +0000 (08:42 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 26 May 2015 10:36:09 +0000 (06:36 -0400)
Commit id '73eda710' added virDomainKeyWrapDefParseXML which uses
virXPathNodeSet, but does not handle a -1 return thus causing a possible
loop condition exit problem later when the return value is used.

Change the logic to return the value from virXPathNodeSet if <= 0

src/conf/domain_conf.c

index d5207b1207eaa164e46d7af88414d73ba77e0c1c..0a3a6245ae0bf1b63080bc777aee871df9be90b2 100644 (file)
@@ -942,8 +942,8 @@ virDomainKeyWrapDefParseXML(virDomainDefPtr def, xmlXPathContextPtr ctxt)
     xmlNodePtr *nodes = NULL;
     int n;
 
-    if (!(n = virXPathNodeSet("./keywrap/cipher", ctxt, &nodes)))
-        return 0;
+    if ((n = virXPathNodeSet("./keywrap/cipher", ctxt, &nodes)) < 0)
+        return n;
 
     if (VIR_ALLOC(def->keywrap) < 0)
         goto cleanup;