Previous patch used 'g_autofree' to eliminate instances of
VIR_FREE(), making some cleanup labels obsolete. This
patch removes them.
Signed-off-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
---
src/conf/domain_addr.c | 98 +++++++++++++++---------------------------
1 file changed, 34 insertions(+), 64 deletions(-)
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index ee4dcf1d3b..0dd4b15225 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -829,30 +829,29 @@ virDomainPCIAddressReserveAddrInternal(virDomainPCIAddressSetPtr
addrs,
unsigned int isolationGroup,
bool fromConfig)
{
- int ret = -1;
g_autofree char *addrStr = NULL;
virDomainPCIAddressBusPtr bus;
virErrorNumber errType = (fromConfig
? VIR_ERR_XML_ERROR : VIR_ERR_INTERNAL_ERROR);
if (!(addrStr = virPCIDeviceAddressAsString(addr)))
- goto cleanup;
+ return -1;
/* Add an extra bus if necessary */
if (addrs->dryRun && virDomainPCIAddressSetGrow(addrs, addr, flags) <
0)
- goto cleanup;
+ return -1;
/* Check that the requested bus exists, is the correct type, and we
* are asking for a valid slot
*/
if (!virDomainPCIAddressValidate(addrs, addr, addrStr, flags, fromConfig))
- goto cleanup;
+ return -1;
bus = &addrs->buses[addr->bus];
if (bus->slot[addr->slot].functions & (1 << addr->function)) {
virReportError(errType,
_("Attempted double use of PCI Address %s"), addrStr);
- goto cleanup;
+ return -1;
}
/* if this is the first function to be reserved on this slot, and
@@ -889,9 +888,7 @@ virDomainPCIAddressReserveAddrInternal(virDomainPCIAddressSetPtr
addrs,
VIR_DEBUG("Reserving PCI address %s (aggregate='%s')", addrStr,
bus->slot[addr->slot].aggregate ? "true" :
"false");
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
@@ -910,7 +907,6 @@ virDomainPCIAddressEnsureAddr(virDomainPCIAddressSetPtr addrs,
virDomainDeviceInfoPtr dev,
virDomainPCIConnectFlags flags)
{
- int ret = -1;
g_autofree char *addrStr = NULL;
/* if flags is 0, the particular model of this device on this
@@ -920,7 +916,7 @@ virDomainPCIAddressEnsureAddr(virDomainPCIAddressSetPtr addrs,
return 0;
if (!(addrStr = virPCIDeviceAddressAsString(&dev->addr.pci)))
- goto cleanup;
+ return -1;
if (virDeviceInfoPCIAddressIsPresent(dev)) {
/* We do not support hotplug multi-function PCI device now, so we should
@@ -930,31 +926,28 @@ virDomainPCIAddressEnsureAddr(virDomainPCIAddressSetPtr addrs,
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Only PCI device addresses with function=0"
" are supported"));
- goto cleanup;
+ return -1;
}
if (!virDomainPCIAddressValidate(addrs, &dev->addr.pci,
addrStr, flags, true))
- goto cleanup;
+ return -1;
if (virDomainPCIAddressReserveAddrInternal(addrs, &dev->addr.pci,
flags, dev->isolationGroup,
true) < 0) {
- goto cleanup;
+ return -1;
}
} else {
if (virDomainPCIAddressReserveNextAddr(addrs, dev, flags, -1) < 0)
- goto cleanup;
+ return -1;
}
dev->addr.pci.extFlags = dev->pciAddrExtFlags;
if (virDomainPCIAddressExtensionEnsureAddr(addrs, &dev->addr.pci) < 0)
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- return ret;
+ return 0;
}
@@ -1102,13 +1095,12 @@
virDomainPCIAddressFindUnusedFunctionOnBus(virDomainPCIAddressBusPtr bus,
virDomainPCIConnectFlags flags,
bool *found)
{
- int ret = -1;
g_autofree char *addrStr = NULL;
*found = false;
if (!(addrStr = virPCIDeviceAddressAsString(searchAddr)))
- goto cleanup;
+ return -1;
if (!virDomainPCIAddressFlagsCompatible(searchAddr, addrStr, bus->flags,
flags, false, false)) {
@@ -1154,10 +1146,7 @@
virDomainPCIAddressFindUnusedFunctionOnBus(virDomainPCIAddressBusPtr bus,
}
}
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
@@ -1410,7 +1399,6 @@ virDomainCCWAddressAssign(virDomainDeviceInfoPtr dev,
virDomainCCWAddressSetPtr addrs,
bool autoassign)
{
- int ret = -1;
g_autofree char *addr = NULL;
if (dev->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW)
@@ -1418,27 +1406,27 @@ virDomainCCWAddressAssign(virDomainDeviceInfoPtr dev,
if (!autoassign && dev->addr.ccw.assigned) {
if (!(addr = virDomainCCWAddressAsString(&dev->addr.ccw)))
- goto cleanup;
+ return -1;
if (virHashLookup(addrs->defined, addr)) {
virReportError(VIR_ERR_XML_ERROR,
_("The CCW devno '%s' is in use already "),
addr);
- goto cleanup;
+ return -1;
}
} else if (autoassign && !dev->addr.ccw.assigned) {
if (!(addr = virDomainCCWAddressAsString(&addrs->next)))
- goto cleanup;
+ return -1;
while (virHashLookup(addrs->defined, addr)) {
if (virDomainCCWAddressIncrement(&addrs->next) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("There are no more free CCW devnos."));
- goto cleanup;
+ return -1;
}
VIR_FREE(addr);
if (!(addr = virDomainCCWAddressAsString(&addrs->next)))
- goto cleanup;
+ return -1;
}
dev->addr.ccw = addrs->next;
dev->addr.ccw.assigned = true;
@@ -1447,14 +1435,11 @@ virDomainCCWAddressAssign(virDomainDeviceInfoPtr dev,
}
if (virHashAddEntry(addrs->defined, addr, addr) < 0)
- goto cleanup;
+ return -1;
else
addr = NULL; /* memory will be freed by hash table */
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
static int ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4)
@@ -1683,7 +1668,6 @@ virDomainVirtioSerialAddrReserve(virDomainDefPtr def G_GNUC_UNUSED,
void *data)
{
virDomainVirtioSerialAddrSetPtr addrs = data;
- int ret = -1;
virBitmapPtr map = NULL;
bool b;
ssize_t i;
@@ -1699,7 +1683,7 @@ virDomainVirtioSerialAddrReserve(virDomainDefPtr def G_GNUC_UNUSED,
virReportError(VIR_ERR_XML_ERROR,
_("virtio serial controller %u is missing"),
info->addr.vioserial.controller);
- goto cleanup;
+ return -1;
}
map = addrs->controllers[i]->ports;
@@ -1708,7 +1692,7 @@ virDomainVirtioSerialAddrReserve(virDomainDefPtr def G_GNUC_UNUSED,
_("virtio serial controller %u does not have port %u"),
info->addr.vioserial.controller,
info->addr.vioserial.port);
- goto cleanup;
+ return -1;
}
if (b) {
@@ -1716,15 +1700,12 @@ virDomainVirtioSerialAddrReserve(virDomainDefPtr def
G_GNUC_UNUSED,
_("virtio serial port %u on controller %u is already
occupied"),
info->addr.vioserial.port,
info->addr.vioserial.controller);
- goto cleanup;
+ return -1;
}
ignore_value(virBitmapSetBit(map, info->addr.vioserial.port));
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
/* virDomainVirtioSerialAddrSetCreateFromDomain
@@ -2343,7 +2324,6 @@ virDomainUSBAddressAssignFromBus(virDomainUSBAddressSetPtr addrs,
unsigned int portpath[VIR_DOMAIN_DEVICE_USB_MAX_PORT_DEPTH] = { 0 };
virDomainUSBAddressHubPtr hub = addrs->buses[bus];
g_autofree char *portStr = NULL;
- int ret = -1;
if (!hub)
return -2;
@@ -2353,7 +2333,7 @@ virDomainUSBAddressAssignFromBus(virDomainUSBAddressSetPtr addrs,
/* we found a free port */
if (!(portStr = virDomainUSBAddressPortFormat(portpath)))
- goto cleanup;
+ return -1;
info->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB;
info->addr.usb.bus = bus;
@@ -2361,11 +2341,9 @@ virDomainUSBAddressAssignFromBus(virDomainUSBAddressSetPtr addrs,
VIR_DEBUG("Assigning USB addr bus=%u port=%s",
info->addr.usb.bus, portStr);
if (virDomainUSBAddressReserve(info, addrs) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
@@ -2421,7 +2399,6 @@ virDomainUSBAddressReserve(virDomainDeviceInfoPtr info,
virDomainUSBAddressSetPtr addrs = data;
virDomainUSBAddressHubPtr targetHub = NULL;
g_autofree char *portStr = NULL;
- int ret = -1;
int targetPort;
if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB)
@@ -2432,26 +2409,23 @@ virDomainUSBAddressReserve(virDomainDeviceInfoPtr info,
portStr = virDomainUSBAddressPortFormat(info->addr.usb.port);
if (!portStr)
- goto cleanup;
+ return -1;
VIR_DEBUG("Reserving USB address bus=%u port=%s", info->addr.usb.bus,
portStr);
if (!(targetHub = virDomainUSBAddressFindPort(addrs, info, &targetPort,
portStr)))
- goto cleanup;
+ return -1;
if (virBitmapIsBitSet(targetHub->portmap, targetPort)) {
virReportError(VIR_ERR_XML_ERROR,
_("Duplicate USB address bus %u port %s"),
info->addr.usb.bus, portStr);
- goto cleanup;
+ return -1;
}
ignore_value(virBitmapSetBit(targetHub->portmap, targetPort));
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
@@ -2483,7 +2457,6 @@ virDomainUSBAddressRelease(virDomainUSBAddressSetPtr addrs,
virDomainUSBAddressHubPtr targetHub = NULL;
g_autofree char *portStr = NULL;
int targetPort;
- int ret = -1;
if (!addrs || info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB ||
!virDomainUSBAddressPortIsValid(info->addr.usb.port))
@@ -2494,12 +2467,9 @@ virDomainUSBAddressRelease(virDomainUSBAddressSetPtr addrs,
if (!(targetHub = virDomainUSBAddressFindPort(addrs, info, &targetPort,
portStr)))
- goto cleanup;
+ return -1;
ignore_value(virBitmapClearBit(targetHub->portmap, targetPort));
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
--
2.24.1