err:
VIR_FREE(cmd);
VIR_FREE(ret);
- return 0;
+ return -1;
}
static int
err:
VIR_FREE(cmd);
VIR_FREE(ret);
- return 0;
+ return -1;
}
static int
VIR_FREE(names[i]);
VIR_FREE(cmd);
VIR_FREE(ret);
- return 0;
+ return -1;
}
static virDomainPtr
int *ids = NULL;
unsigned int i = 0;
- if ((nids = phypNumDomainsGeneric(conn, 2)) == 0)
+ if ((nids = phypNumDomainsGeneric(conn, 2)) < 0)
goto err;
+ /* exit early if there are no domains */
+ if (nids == 0)
+ return 0;
+
if (VIR_ALLOC_N(ids, nids) < 0) {
virReportOOMError(conn);
goto err;
}
- if (phypListDomainsGeneric(conn, ids, nids, 1) == 0)
+ if ((nids = phypListDomainsGeneric(conn, ids, nids, 1)) < 0)
goto err;
+ /* exit early if there are no domains */
+ /* FIXME: phypNumDomainsGeneric() returned > 0 but phypListDomainsGeneric()
+ * returned 0. indicates this an error condition?
+ * an even stricter check would be to treat
+ *
+ * phypNumDomainsGeneric() != phypListDomainsGeneric()
+ *
+ * as an error */
+ if (nids == 0) {
+ VIR_FREE(ids);
+ return 0;
+ }
+
phyp_driver = conn->privateData;
uuid_table = phyp_driver->uuid_table;
uuid_table->nlpars = nids;