Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
src/conf/node_device_conf.c | 37 +++++++++++++------------------------
1 file changed, 13 insertions(+), 24 deletions(-)
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index e478238675..4adfdef572 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -1337,8 +1337,7 @@ virNodeDevCapPCIDevIommuGroupParseXML(xmlXPathContextPtr ctxt,
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;
@@ -1416,8 +1415,7 @@ virPCIEDeviceInfoParseXML(xmlXPathContextPtr ctxt,
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)
@@ -1425,8 +1423,7 @@ virPCIEDeviceInfoParseXML(xmlXPathContextPtr ctxt,
}
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)
@@ -1445,8 +1442,7 @@ virNodeDevPCICapSRIOVPhysicalParseXML(xmlXPathContextPtr ctxt,
{
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",
@@ -1485,14 +1481,12 @@ virNodeDevPCICapSRIOVVirtualParseXML(xmlXPathContextPtr ctxt,
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;
@@ -1530,8 +1524,7 @@ virNodeDevPCICapMdevTypesParseXML(xmlXPathContextPtr ctxt,
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",
@@ -1705,8 +1698,7 @@ virNodeDevCapPCIDevParseXML(xmlXPathContextPtr ctxt,
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;
@@ -1844,8 +1836,7 @@ virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt,
char *tmp;
int val, ret = -1;
- if (VIR_ALLOC(caps) < 0)
- return NULL;
+ caps = g_new0(virNodeDevCapsDef, 1);
tmp = virXMLPropString(node, "type");
if (!tmp) {
@@ -1940,8 +1931,7 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt,
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) {
@@ -1961,8 +1951,7 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt,
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];
@@ -2325,8 +2314,8 @@ virNodeDeviceCapsListExport(virNodeDeviceDefPtr def,
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;
--
2.26.2