
On Wed, Apr 26, 2017 at 04:55:29PM +0200, Erik Skultety wrote:
Since there's at least SRIOV and MDEV sub-capabilities to be parsed, let's make the code more readable by splitting it to several logical blocks.
Signed-off-by: Erik Skultety <eskultet@redhat.com> --- src/conf/node_device_conf.c | 130 ++++++++++++++++++++++++++------------------ 1 file changed, 77 insertions(+), 53 deletions(-)
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 85cfd8396..d70d9942c 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -1286,76 +1286,102 @@ virPCIEDeviceInfoParseXML(xmlXPathContextPtr ctxt,
static int -virNodeDevPCICapabilityParseXML(xmlXPathContextPtr ctxt, - xmlNodePtr node, - virNodeDevCapPCIDevPtr pci_dev) +virNodeDevPCICapSRIOVPhysicalParseXML(xmlXPathContextPtr ctxt, + virNodeDevCapPCIDevPtr pci_dev) { - char *maxFuncsStr = virXMLPropString(node, "maxCount"); - char *type = virXMLPropString(node, "type"); - xmlNodePtr *addresses = NULL; - xmlNodePtr orignode = ctxt->node; - int ret = -1; - size_t i = 0; - - ctxt->node = node; - - if (!type) { - virReportError(VIR_ERR_XML_ERROR, "%s", _("Missing capability type")); - goto out; - } - - if (STREQ(type, "phys_function")) { - xmlNodePtr address = virXPathNode("./address[1]", ctxt); + xmlNodePtr address = virXPathNode("./address[1]", ctxt);
if (VIR_ALLOC(pci_dev->physical_function) < 0) - goto out; + return -1;
if (!address) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Missing address in 'phys_function' capability")); - goto out; + return -1; }
if (virPCIDeviceAddressParseXML(address, pci_dev->physical_function) < 0) - goto out; + return -1;
pci_dev->flags |= VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION;
Wrong indentation of the function body. Pavel