[Libvirt-cim] [PATCH 08/19] Coverity: Resolve DEADCODE - do_parse()

John Ferlan jferlan at redhat.com
Thu May 16 14:57:43 UTC 2013


747             if (nsv == NULL)
748                     goto out;
749
750             dev_nodes = nsv->nodeTab;

(2) Event notnull:
    At condition "nsv", the value of "nsv" cannot be NULL.
(3) Event dead_error_condition:
    The condition "nsv" must be true.
(4) Event dead_error_line:
    Execution cannot reach this expression "0" inside statement
    "count = (nsv ? nsv->nodeNr ...".

751             count = nsv ? nsv->nodeNr : 0;

Resolve by not checking nsv and moving up a line to right after the
nsv == NULL check
---
 libxkutil/device_parsing.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c
index 264d4cc..edd8bc4 100644
--- a/libxkutil/device_parsing.c
+++ b/libxkutil/device_parsing.c
@@ -746,9 +746,9 @@ static int do_parse(xmlNodeSet *nsv, dev_parse_func_t do_real_parse,
 
         if (nsv == NULL)
                 goto out;
+        count = nsv->nodeNr;
 
         dev_nodes = nsv->nodeTab;
-        count = nsv ? nsv->nodeNr : 0;
 
         if (count <= 0)
                 goto out;
-- 
1.8.1.4




More information about the Libvirt-cim mailing list