virPCIDeviceAddress addr = {0};
if (virPCIDeviceAddressParseXML(addrNodes[i], &addr) < 0)
goto cleanup;
- if (VIR_ALLOC(pciAddr) < 0)
- goto cleanup;
+ pciAddr = g_new0(virPCIDeviceAddress, 1);
pciAddr->domain = addr.domain;
pciAddr->bus = addr.bus;
pciAddr->slot = addr.slot;
ctxt->node = pciExpressNode;
if ((lnk = virXPathNode("./link[@validity='cap']", ctxt))) {
- if (VIR_ALLOC(pci_express->link_cap) < 0)
- goto cleanup;
+ pci_express->link_cap = g_new0(virPCIELink, 1);
if (virPCIEDeviceInfoLinkParseXML(ctxt, lnk,
pci_express->link_cap) < 0)
}
if ((lnk = virXPathNode("./link[@validity='sta']", ctxt))) {
- if (VIR_ALLOC(pci_express->link_sta) < 0)
- goto cleanup;
+ pci_express->link_sta = g_new0(virPCIELink, 1);
if (virPCIEDeviceInfoLinkParseXML(ctxt, lnk,
pci_express->link_sta) < 0)
{
xmlNodePtr address = virXPathNode("./address[1]", ctxt);
- if (VIR_ALLOC(pci_dev->physical_function) < 0)
- return -1;
+ pci_dev->physical_function = g_new0(virPCIDeviceAddress, 1);
if (!address) {
virReportError(VIR_ERR_XML_ERROR, "%s",
goto cleanup;
}
- if (VIR_ALLOC_N(pci_dev->virtual_functions, naddresses) < 0)
- goto cleanup;
+ pci_dev->virtual_functions = g_new0(virPCIDeviceAddressPtr, naddresses);
for (i = 0; i < naddresses; i++) {
g_autoptr(virPCIDeviceAddress) addr = NULL;
- if (VIR_ALLOC(addr) < 0)
- goto cleanup;
+ addr = g_new0(virPCIDeviceAddress, 1);
if (virPCIDeviceAddressParseXML(addresses[i], addr) < 0)
goto cleanup;
for (i = 0; i < nmdev_types; i++) {
ctxt->node = nodes[i];
- if (VIR_ALLOC(type) < 0)
- goto cleanup;
+ type = g_new0(virMediatedDeviceType, 1);
if (!(type->id = virXPathString("string(./@id[1])", ctxt))) {
virReportError(VIR_ERR_XML_ERROR, "%s",
goto out;
if ((pciExpress = virXPathNode("./pci-express[1]", ctxt))) {
- if (VIR_ALLOC(pci_express) < 0)
- goto out;
+ pci_express = g_new0(virPCIEDeviceInfo, 1);
if (virPCIEDeviceInfoParseXML(ctxt, pciExpress, pci_express) < 0)
goto out;
char *tmp;
int val, ret = -1;
- if (VIR_ALLOC(caps) < 0)
- return NULL;
+ caps = g_new0(virNodeDevCapsDef, 1);
tmp = virXMLPropString(node, "type");
if (!tmp) {
int n, m;
size_t i;
- if (VIR_ALLOC(def) < 0)
- return NULL;
+ def = g_new0(virNodeDeviceDef, 1);
/* Extract device name */
if (create == EXISTING_DEVICE) {
if ((n = virXPathNodeSet("./devnode", ctxt, &nodes)) < 0)
goto error;
- if (VIR_ALLOC_N(def->devlinks, n + 1) < 0)
- goto error;
+ def->devlinks = g_new0(char *, n + 1);
for (i = 0, m = 0; i < n; i++) {
xmlNodePtr node = nodes[i];
if (virNodeDeviceUpdateCaps(def) < 0)
goto cleanup;
- if (want_list && VIR_ALLOC_N(tmp, VIR_NODE_DEV_CAP_LAST - 1) < 0)
- goto cleanup;
+ if (want_list)
+ tmp = g_new0(virNodeDevCapType, VIR_NODE_DEV_CAP_LAST - 1);
for (caps = def->caps; caps; caps = caps->next) {
unsigned int flags;