[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 4/3] conf: Resolve Coverity NEGATIVE_RETURNS



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

Signed-off-by: John Ferlan <jferlan redhat com>
---
 src/conf/domain_conf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e2b1194..a97e640 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -940,8 +940,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;
-- 
2.1.0


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]