提交 3814e767 编写于 作者: D Daniel Henrique Barboza 提交者: Ján Tomko

conf: remove unneeded cleanup labels

Signed-off-by: NDaniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 26791f39
......@@ -1789,7 +1789,6 @@ virDomainVirtioSerialAddrNext(virDomainDefPtr def,
virDomainDeviceVirtioSerialAddress *addr,
bool allowZero)
{
int ret = -1;
ssize_t port, startPort = 0;
ssize_t i;
unsigned int controller;
......@@ -1801,7 +1800,7 @@ virDomainVirtioSerialAddrNext(virDomainDefPtr def,
if (addrs->ncontrollers == 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("no virtio-serial controllers are available"));
goto cleanup;
return -1;
}
for (i = 0; i < addrs->ncontrollers; i++) {
......@@ -1818,7 +1817,7 @@ virDomainVirtioSerialAddrNext(virDomainDefPtr def,
if (idx == -1) {
if (virDomainVirtioSerialAddrSetAutoaddController(def, addrs, i) < 0)
goto cleanup;
return -1;
controller = i;
port = startPort + 1;
goto success;
......@@ -1829,8 +1828,7 @@ virDomainVirtioSerialAddrNext(virDomainDefPtr def,
virReportError(VIR_ERR_XML_ERROR, "%s",
_("Unable to find a free virtio-serial port"));
cleanup:
return ret;
return -1;
success:
addr->bus = 0;
......@@ -1838,8 +1836,7 @@ virDomainVirtioSerialAddrNext(virDomainDefPtr def,
addr->controller = controller;
VIR_DEBUG("Found free virtio serial controller %u port %u", addr->controller,
addr->port);
ret = 0;
goto cleanup;
return 0;
}
static int
......@@ -1880,7 +1877,6 @@ virDomainVirtioSerialAddrAssign(virDomainDefPtr def,
bool allowZero,
bool portOnly)
{
int ret = -1;
virDomainDeviceInfo nfo = { 0 };
virDomainDeviceInfoPtr ptr = allowZero ? &nfo : info;
......@@ -1889,20 +1885,17 @@ virDomainVirtioSerialAddrAssign(virDomainDefPtr def,
if (portOnly) {
if (virDomainVirtioSerialAddrNextFromController(addrs,
&ptr->addr.vioserial) < 0)
goto cleanup;
return -1;
} else {
if (virDomainVirtioSerialAddrNext(def, addrs, &ptr->addr.vioserial,
allowZero) < 0)
goto cleanup;
return -1;
}
if (virDomainVirtioSerialAddrReserve(NULL, NULL, ptr, addrs) < 0)
goto cleanup;
ret = 0;
return -1;
cleanup:
return ret;
return 0;
}
/* virDomainVirtioSerialAddrAutoAssign
......
......@@ -288,7 +288,6 @@ virDomainCapsEnumSet(virDomainCapsEnumPtr capsEnum,
size_t nvalues,
unsigned int *values)
{
int ret = -1;
size_t i;
for (i = 0; i < nvalues; i++) {
......@@ -300,15 +299,13 @@ virDomainCapsEnumSet(virDomainCapsEnumPtr capsEnum,
_("integer overflow on %s. Please contact the "
"libvirt development team at libvir-list@redhat.com"),
capsEnumName);
goto cleanup;
return -1;
}
capsEnum->values |= val;
}
ret = 0;
cleanup:
return ret;
return 0;
}
......@@ -325,19 +322,15 @@ virDomainCapsEnumFormat(virBufferPtr buf,
const char *capsEnumName,
virDomainCapsValToStr valToStr)
{
int ret = -1;
size_t i;
if (!capsEnum->report) {
ret = 0;
goto cleanup;
}
if (!capsEnum->report)
return 0;
virBufferAsprintf(buf, "<enum name='%s'", capsEnumName);
if (!capsEnum->values) {
virBufferAddLit(buf, "/>\n");
ret = 0;
goto cleanup;
return 0;
}
virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 2);
......@@ -354,9 +347,7 @@ virDomainCapsEnumFormat(virBufferPtr buf,
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</enum>\n");
ret = 0;
cleanup:
return ret;
return 0;
}
......
此差异已折叠。
......@@ -264,15 +264,11 @@ virNetDevBandwidthFormat(virNetDevBandwidthPtr def,
unsigned int class_id,
virBufferPtr buf)
{
int ret = -1;
if (!buf)
goto cleanup;
return -1;
if (!def) {
ret = 0;
goto cleanup;
}
if (!def)
return 0;
virBufferAddLit(buf, "<bandwidth");
if (class_id)
......@@ -281,14 +277,11 @@ virNetDevBandwidthFormat(virNetDevBandwidthPtr def,
virBufferAdjustIndent(buf, 2);
if (virNetDevBandwidthRateFormat(def->in, buf, "inbound") < 0 ||
virNetDevBandwidthRateFormat(def->out, buf, "outbound") < 0)
goto cleanup;
return -1;
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</bandwidth>\n");
ret = 0;
cleanup:
return ret;
return 0;
}
void
......
......@@ -3059,18 +3059,17 @@ virNetworkDefUpdateIPDHCPRange(virNetworkDefPtr def,
unsigned int fflags G_GNUC_UNUSED)
{
size_t i;
int ret = -1;
virNetworkIPDefPtr ipdef = virNetworkIPDefByIndex(def, parentIndex);
virSocketAddrRange range;
memset(&range, 0, sizeof(range));
if (virNetworkDefUpdateCheckElementName(def, ctxt->node, "range") < 0)
goto cleanup;
return -1;
/* ipdef is the ip element that needs its range array updated */
if (!ipdef)
goto cleanup;
return -1;
/* parse the xml into a virSocketAddrRange */
if (command == VIR_NETWORK_UPDATE_COMMAND_MODIFY) {
......@@ -3078,18 +3077,18 @@ virNetworkDefUpdateIPDHCPRange(virNetworkDefPtr def,
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("dhcp ranges cannot be modified, "
"only added or deleted"));
goto cleanup;
return -1;
}
if (virSocketAddrRangeParseXML(def->name, ipdef, ctxt->node, &range) < 0)
goto cleanup;
return -1;
if (VIR_SOCKET_ADDR_FAMILY(&ipdef->address)
!= VIR_SOCKET_ADDR_FAMILY(&range.start)) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("the address family of a dhcp range must match "
"the address family of the dhcp element's parent"));
goto cleanup;
return -1;
}
/* check if an entry with same name/address/ip already exists */
......@@ -3104,7 +3103,7 @@ virNetworkDefUpdateIPDHCPRange(virNetworkDefPtr def,
(command == VIR_NETWORK_UPDATE_COMMAND_ADD_LAST)) {
if (virNetworkDefUpdateCheckMultiDHCP(def, ipdef) < 0)
goto cleanup;
return -1;
if (i < ipdef->nranges) {
char *startip = virSocketAddrFormat(&range.start);
......@@ -3119,7 +3118,7 @@ virNetworkDefUpdateIPDHCPRange(virNetworkDefPtr def,
endip ? endip : "unknown");
VIR_FREE(startip);
VIR_FREE(endip);
goto cleanup;
return -1;
}
/* add to beginning/end of list */
......@@ -3127,14 +3126,14 @@ virNetworkDefUpdateIPDHCPRange(virNetworkDefPtr def,
command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST
? 0 : ipdef->nranges,
ipdef->nranges, range) < 0)
goto cleanup;
return -1;
} else if (command == VIR_NETWORK_UPDATE_COMMAND_DELETE) {
if (i == ipdef->nranges) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("couldn't locate a matching dhcp range entry "
"in network '%s'"), def->name);
goto cleanup;
return -1;
}
/* remove it */
......@@ -3143,12 +3142,10 @@ virNetworkDefUpdateIPDHCPRange(virNetworkDefPtr def,
} else {
virNetworkDefUpdateUnknownCommand(command);
goto cleanup;
return -1;
}
ret = 0;
cleanup:
return ret;
return 0;
}
......
......@@ -2112,7 +2112,6 @@ virNodeDeviceGetWWNs(virNodeDeviceDefPtr def,
char **wwpn)
{
virNodeDevCapsDefPtr cap = NULL;
int ret = -1;
cap = def->caps;
while (cap != NULL) {
......@@ -2129,12 +2128,10 @@ virNodeDeviceGetWWNs(virNodeDeviceDefPtr def,
if (cap == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Device is not a fibre channel HBA"));
goto cleanup;
return -1;
}
ret = 0;
cleanup:
return ret;
return 0;
}
......@@ -2501,7 +2498,7 @@ virNodeDeviceGetPCISRIOVCaps(const char *sysfsPath,
ret = virPCIGetPhysicalFunction(sysfsPath,
&pci_dev->physical_function);
if (ret < 0)
goto cleanup;
return ret;
if (pci_dev->physical_function)
pci_dev->flags |= VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION;
......@@ -2510,13 +2507,12 @@ virNodeDeviceGetPCISRIOVCaps(const char *sysfsPath,
&pci_dev->num_virtual_functions,
&pci_dev->max_virtual_functions);
if (ret < 0)
goto cleanup;
return ret;
if (pci_dev->num_virtual_functions > 0 ||
pci_dev->max_virtual_functions > 0)
pci_dev->flags |= VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION;
cleanup:
return ret;
}
......@@ -2525,7 +2521,7 @@ static int
virNodeDeviceGetPCIIOMMUGroupCaps(virNodeDevCapPCIDevPtr pci_dev)
{
size_t i;
int tmpGroup, ret = -1;
int tmpGroup;
virPCIDeviceAddress addr;
/* this could be a refresh, so clear out the old data */
......@@ -2542,23 +2538,19 @@ virNodeDeviceGetPCIIOMMUGroupCaps(virNodeDevCapPCIDevPtr pci_dev)
tmpGroup = virPCIDeviceAddressGetIOMMUGroupNum(&addr);
if (tmpGroup == -1) {
/* error was already reported */
goto cleanup;
return -1;
}
if (tmpGroup == -2) {
if (tmpGroup == -2)
/* -2 return means there is no iommu_group data */
ret = 0;
goto cleanup;
}
return 0;
if (tmpGroup >= 0) {
if (virPCIDeviceAddressGetIOMMUGroupAddresses(&addr, &pci_dev->iommuGroupDevices,
&pci_dev->nIommuGroupDevices) < 0)
goto cleanup;
return -1;
pci_dev->iommuGroupNumber = tmpGroup;
}
ret = 0;
cleanup:
return ret;
return 0;
}
......
......@@ -390,24 +390,22 @@ int virDomainNumatuneGetMode(virDomainNumaPtr numatune,
int cellid,
virDomainNumatuneMemMode *mode)
{
int ret = -1;
virDomainNumatuneMemMode tmp_mode;
if (!numatune)
return ret;
return -1;
if (virDomainNumatuneNodeSpecified(numatune, cellid))
tmp_mode = numatune->mem_nodes[cellid].mode;
else if (numatune->memory.specified)
tmp_mode = numatune->memory.mode;
else
goto cleanup;
return -1;
if (mode)
*mode = tmp_mode;
ret = 0;
cleanup:
return ret;
return 0;
}
virBitmapPtr
......@@ -498,8 +496,6 @@ virDomainNumatuneSet(virDomainNumaPtr numa,
int mode,
virBitmapPtr nodeset)
{
int ret = -1;
/* No need to do anything in this case */
if (mode == -1 && placement == -1 && !nodeset)
return 0;
......@@ -517,7 +513,7 @@ virDomainNumatuneSet(virDomainNumaPtr numa,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unsupported numatune mode '%d'"),
mode);
goto cleanup;
return -1;
}
if (placement != -1 &&
......@@ -525,7 +521,7 @@ virDomainNumatuneSet(virDomainNumaPtr numa,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unsupported numatune placement '%d'"),
mode);
goto cleanup;
return -1;
}
if (mode != -1)
......@@ -534,7 +530,7 @@ virDomainNumatuneSet(virDomainNumaPtr numa,
if (nodeset) {
virBitmapFree(numa->memory.nodeset);
if (!(numa->memory.nodeset = virBitmapNewCopy(nodeset)))
goto cleanup;
return -1;
if (placement == -1)
placement = VIR_DOMAIN_NUMATUNE_PLACEMENT_STATIC;
}
......@@ -551,7 +547,7 @@ virDomainNumatuneSet(virDomainNumaPtr numa,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("nodeset for NUMA memory tuning must be set "
"if 'placement' is 'static'"));
goto cleanup;
return -1;
}
/* setting nodeset when placement auto is invalid */
......@@ -566,10 +562,7 @@ virDomainNumatuneSet(virDomainNumaPtr numa,
numa->memory.specified = true;
ret = 0;
cleanup:
return ret;
return 0;
}
static bool
......
......@@ -2085,13 +2085,11 @@ virNWFilterIncludeParse(xmlNodePtr cur)
if (!ret->params)
goto err_exit;
cleanup:
return ret;
err_exit:
virNWFilterIncludeDefFree(ret);
ret = NULL;
goto cleanup;
return NULL;
}
......
......@@ -343,17 +343,14 @@ int
virStoragePoolOptionsPoolTypeSetXMLNamespace(int type,
virXMLNamespacePtr ns)
{
int ret = -1;
virStoragePoolTypeInfoPtr backend = virStoragePoolTypeInfoLookup(type);
if (!backend)
goto cleanup;
return -1;
backend->poolOptions.ns = *ns;
ret = 0;
cleanup:
return ret;
return 0;
}
......
......@@ -766,14 +766,13 @@ virNetworkObjConfigChangeSetup(virNetworkObjPtr obj,
unsigned int flags)
{
bool isActive;
int ret = -1;
isActive = virNetworkObjIsActive(obj);
if (!isActive && (flags & VIR_NETWORK_UPDATE_AFFECT_LIVE)) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("network is not running"));
goto cleanup;
return -1;
}
if (flags & VIR_NETWORK_UPDATE_AFFECT_CONFIG) {
......@@ -781,18 +780,16 @@ virNetworkObjConfigChangeSetup(virNetworkObjPtr obj,
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot change persistent config of a "
"transient network"));
goto cleanup;
return -1;
}
/* this should already have been done by the driver, but do it
* anyway just in case.
*/
if (isActive && (virNetworkObjSetDefTransient(obj, false, xmlopt) < 0))
goto cleanup;
return -1;
}
ret = 0;
cleanup:
return ret;
return 0;
}
......@@ -1673,10 +1670,9 @@ virNetworkObjLookupPort(virNetworkObjPtr net,
virReportError(VIR_ERR_NO_NETWORK_PORT,
_("Network port with UUID %s does not exist"),
uuidstr);
goto cleanup;
return NULL;
}
cleanup:
return ret;
}
......
......@@ -732,14 +732,13 @@ virSecretObjGetValue(virSecretObjPtr obj)
virUUIDFormat(def->uuid, uuidstr);
virReportError(VIR_ERR_NO_SECRET,
_("secret '%s' does not have a value"), uuidstr);
goto cleanup;
return NULL;
}
if (VIR_ALLOC_N(ret, obj->value_size) < 0)
goto cleanup;
return NULL;
memcpy(ret, obj->value, obj->value_size);
cleanup:
return ret;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册