]> xenbits.xensource.com Git - libvirt.git/commitdiff
hellolibvirt: Resolve Coverity issues
authorJohn Ferlan <jferlan@redhat.com>
Thu, 11 Jul 2013 11:19:37 +0000 (07:19 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 11 Jul 2013 18:18:11 +0000 (14:18 -0400)
Recent changes uncovered a NEGATIVE_RETURNS when processing 'numNames'
in 'showDomains' in the for loop after a possible -1 return.

examples/hellolibvirt/hellolibvirt.c

index 83045b1dc4b2261fb409c1647c9c125a731d1074..0179fad35d553932b7ce53a8803bcc7e77f304a4 100644 (file)
@@ -90,6 +90,13 @@ showDomains(virConnectPtr conn)
     numNames = virConnectListAllDomains(conn,
                                         &nameList,
                                         flags);
+    if (numNames == -1) {
+        ret = 1;
+        printf("Failed to get a list of all domains: %s\n",
+               virGetLastErrorMessage());
+        goto out;
+    }
+
     for (i = 0; i < numNames; i++) {
         int active = virDomainIsActive(nameList[i]);
         printf("  %8s (%s)\n",