conf: remove unneeded labels

Remove unneeded, easy to remove goto labels (cleanup|error|done|...).

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
Daniel Henrique Barboza 2020-01-06 18:57:26 -03:00 committed by Erik Skultety
parent fbf3f3d86a
commit a7c024e26d
10 changed files with 121 additions and 210 deletions

View File

@ -747,11 +747,11 @@ virCapabilitiesDomainDataLookupInternal(virCapsPtr caps,
_("could not find capabilities for %s"), _("could not find capabilities for %s"),
virBufferCurrentContent(&buf)); virBufferCurrentContent(&buf));
virBufferFreeAndReset(&buf); virBufferFreeAndReset(&buf);
goto error; return ret;
} }
if (VIR_ALLOC(ret) < 0) if (VIR_ALLOC(ret) < 0)
goto error; return ret;
ret->ostype = foundguest->ostype; ret->ostype = foundguest->ostype;
ret->arch = foundguest->arch.id; ret->arch = foundguest->arch.id;
@ -764,7 +764,6 @@ virCapabilitiesDomainDataLookupInternal(virCapsPtr caps,
if (foundmachine) if (foundmachine)
ret->machinetype = foundmachine->name; ret->machinetype = foundmachine->name;
error:
return ret; return ret;
} }
@ -1179,13 +1178,13 @@ virCapabilitiesFormatHostXML(virCapsHostPtr host,
if (host->numa && if (host->numa &&
virCapabilitiesHostNUMAFormat(host->numa, buf) < 0) virCapabilitiesHostNUMAFormat(host->numa, buf) < 0)
goto error; return -1;
if (virCapabilitiesFormatCaches(buf, &host->cache) < 0) if (virCapabilitiesFormatCaches(buf, &host->cache) < 0)
goto error; return -1;
if (virCapabilitiesFormatMemoryBandwidth(buf, &host->memBW) < 0) if (virCapabilitiesFormatMemoryBandwidth(buf, &host->memBW) < 0)
goto error; return -1;
for (i = 0; i < host->nsecModels; i++) { for (i = 0; i < host->nsecModels; i++) {
virBufferAddLit(buf, "<secmodel>\n"); virBufferAddLit(buf, "<secmodel>\n");
@ -1207,9 +1206,6 @@ virCapabilitiesFormatHostXML(virCapsHostPtr host,
virBufferAddLit(buf, "</host>\n\n"); virBufferAddLit(buf, "</host>\n\n");
return 0; return 0;
error:
return -1;
} }

View File

@ -992,7 +992,6 @@ virCPUDefIsEqual(virCPUDefPtr src,
virCPUDefPtr dst, virCPUDefPtr dst,
bool reportError) bool reportError)
{ {
bool identical = false;
size_t i; size_t i;
if (!src && !dst) if (!src && !dst)
@ -1004,91 +1003,91 @@ virCPUDefIsEqual(virCPUDefPtr src,
if ((src && !dst) || (!src && dst)) { if ((src && !dst) || (!src && dst)) {
MISMATCH("%s", _("Target CPU does not match source")); MISMATCH("%s", _("Target CPU does not match source"));
goto cleanup; return false;
} }
if (src->type != dst->type) { if (src->type != dst->type) {
MISMATCH(_("Target CPU type %s does not match source %s"), MISMATCH(_("Target CPU type %s does not match source %s"),
virCPUTypeToString(dst->type), virCPUTypeToString(dst->type),
virCPUTypeToString(src->type)); virCPUTypeToString(src->type));
goto cleanup; return false;
} }
if (src->mode != dst->mode) { if (src->mode != dst->mode) {
MISMATCH(_("Target CPU mode %s does not match source %s"), MISMATCH(_("Target CPU mode %s does not match source %s"),
virCPUModeTypeToString(dst->mode), virCPUModeTypeToString(dst->mode),
virCPUModeTypeToString(src->mode)); virCPUModeTypeToString(src->mode));
goto cleanup; return false;
} }
if (src->check != dst->check) { if (src->check != dst->check) {
MISMATCH(_("Target CPU check %s does not match source %s"), MISMATCH(_("Target CPU check %s does not match source %s"),
virCPUCheckTypeToString(dst->check), virCPUCheckTypeToString(dst->check),
virCPUCheckTypeToString(src->check)); virCPUCheckTypeToString(src->check));
goto cleanup; return false;
} }
if (src->arch != dst->arch) { if (src->arch != dst->arch) {
MISMATCH(_("Target CPU arch %s does not match source %s"), MISMATCH(_("Target CPU arch %s does not match source %s"),
virArchToString(dst->arch), virArchToString(dst->arch),
virArchToString(src->arch)); virArchToString(src->arch));
goto cleanup; return false;
} }
if (STRNEQ_NULLABLE(src->model, dst->model)) { if (STRNEQ_NULLABLE(src->model, dst->model)) {
MISMATCH(_("Target CPU model %s does not match source %s"), MISMATCH(_("Target CPU model %s does not match source %s"),
NULLSTR(dst->model), NULLSTR(src->model)); NULLSTR(dst->model), NULLSTR(src->model));
goto cleanup; return false;
} }
if (STRNEQ_NULLABLE(src->vendor, dst->vendor)) { if (STRNEQ_NULLABLE(src->vendor, dst->vendor)) {
MISMATCH(_("Target CPU vendor %s does not match source %s"), MISMATCH(_("Target CPU vendor %s does not match source %s"),
NULLSTR(dst->vendor), NULLSTR(src->vendor)); NULLSTR(dst->vendor), NULLSTR(src->vendor));
goto cleanup; return false;
} }
if (STRNEQ_NULLABLE(src->vendor_id, dst->vendor_id)) { if (STRNEQ_NULLABLE(src->vendor_id, dst->vendor_id)) {
MISMATCH(_("Target CPU vendor id %s does not match source %s"), MISMATCH(_("Target CPU vendor id %s does not match source %s"),
NULLSTR(dst->vendor_id), NULLSTR(src->vendor_id)); NULLSTR(dst->vendor_id), NULLSTR(src->vendor_id));
goto cleanup; return false;
} }
if (src->sockets != dst->sockets) { if (src->sockets != dst->sockets) {
MISMATCH(_("Target CPU sockets %d does not match source %d"), MISMATCH(_("Target CPU sockets %d does not match source %d"),
dst->sockets, src->sockets); dst->sockets, src->sockets);
goto cleanup; return false;
} }
if (src->cores != dst->cores) { if (src->cores != dst->cores) {
MISMATCH(_("Target CPU cores %d does not match source %d"), MISMATCH(_("Target CPU cores %d does not match source %d"),
dst->cores, src->cores); dst->cores, src->cores);
goto cleanup; return false;
} }
if (src->threads != dst->threads) { if (src->threads != dst->threads) {
MISMATCH(_("Target CPU threads %d does not match source %d"), MISMATCH(_("Target CPU threads %d does not match source %d"),
dst->threads, src->threads); dst->threads, src->threads);
goto cleanup; return false;
} }
if (src->nfeatures != dst->nfeatures) { if (src->nfeatures != dst->nfeatures) {
MISMATCH(_("Target CPU feature count %zu does not match source %zu"), MISMATCH(_("Target CPU feature count %zu does not match source %zu"),
dst->nfeatures, src->nfeatures); dst->nfeatures, src->nfeatures);
goto cleanup; return false;
} }
for (i = 0; i < src->nfeatures; i++) { for (i = 0; i < src->nfeatures; i++) {
if (STRNEQ(src->features[i].name, dst->features[i].name)) { if (STRNEQ(src->features[i].name, dst->features[i].name)) {
MISMATCH(_("Target CPU feature %s does not match source %s"), MISMATCH(_("Target CPU feature %s does not match source %s"),
dst->features[i].name, src->features[i].name); dst->features[i].name, src->features[i].name);
goto cleanup; return false;
} }
if (src->features[i].policy != dst->features[i].policy) { if (src->features[i].policy != dst->features[i].policy) {
MISMATCH(_("Target CPU feature policy %s does not match source %s"), MISMATCH(_("Target CPU feature policy %s does not match source %s"),
virCPUFeaturePolicyTypeToString(dst->features[i].policy), virCPUFeaturePolicyTypeToString(dst->features[i].policy),
virCPUFeaturePolicyTypeToString(src->features[i].policy)); virCPUFeaturePolicyTypeToString(src->features[i].policy));
goto cleanup; return false;
} }
} }
@ -1098,15 +1097,12 @@ virCPUDefIsEqual(virCPUDefPtr src,
(src->cache->level != dst->cache->level || (src->cache->level != dst->cache->level ||
src->cache->mode != dst->cache->mode))) { src->cache->mode != dst->cache->mode))) {
MISMATCH("%s", _("Target CPU cache does not match source")); MISMATCH("%s", _("Target CPU cache does not match source"));
goto cleanup; return false;
} }
#undef MISMATCH #undef MISMATCH
identical = true; return true;
cleanup:
return identical;
} }

View File

@ -1175,7 +1175,7 @@ virDomainPCIAddressGetNextAddr(virDomainPCIAddressSetPtr addrs,
if (addrs->nbuses == 0) { if (addrs->nbuses == 0) {
virReportError(VIR_ERR_XML_ERROR, "%s", _("No PCI buses available")); virReportError(VIR_ERR_XML_ERROR, "%s", _("No PCI buses available"));
goto error; return -1;
} }
/* if the caller asks for "any function", give them function 0 */ /* if the caller asks for "any function", give them function 0 */
@ -1199,7 +1199,7 @@ virDomainPCIAddressGetNextAddr(virDomainPCIAddressSetPtr addrs,
if (virDomainPCIAddressFindUnusedFunctionOnBus(bus, &a, function, if (virDomainPCIAddressFindUnusedFunctionOnBus(bus, &a, function,
flags, &found) < 0) { flags, &found) < 0) {
goto error; return -1;
} }
if (found) if (found)
@ -1223,7 +1223,7 @@ virDomainPCIAddressGetNextAddr(virDomainPCIAddressSetPtr addrs,
if (virDomainPCIAddressFindUnusedFunctionOnBus(bus, &a, function, if (virDomainPCIAddressFindUnusedFunctionOnBus(bus, &a, function,
flags, &found) < 0) { flags, &found) < 0) {
goto error; return -1;
} }
/* The isolation group for the bus will actually be changed /* The isolation group for the bus will actually be changed
@ -1236,7 +1236,7 @@ virDomainPCIAddressGetNextAddr(virDomainPCIAddressSetPtr addrs,
if (addrs->dryRun) { if (addrs->dryRun) {
/* a is already set to the first new bus */ /* a is already set to the first new bus */
if (virDomainPCIAddressSetGrow(addrs, &a, flags) < 0) if (virDomainPCIAddressSetGrow(addrs, &a, flags) < 0)
goto error; return -1;
/* this device will use the first slot of the new bus */ /* this device will use the first slot of the new bus */
a.slot = addrs->buses[a.bus].minSlot; a.slot = addrs->buses[a.bus].minSlot;
goto success; goto success;
@ -1244,7 +1244,6 @@ virDomainPCIAddressGetNextAddr(virDomainPCIAddressSetPtr addrs,
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("No more available PCI slots")); "%s", _("No more available PCI slots"));
error:
return -1; return -1;
success: success:

View File

@ -3682,8 +3682,6 @@ virDomainObjSetDefTransient(virDomainXMLOptionPtr xmlopt,
virDomainObjPtr domain, virDomainObjPtr domain,
void *parseOpaque) void *parseOpaque)
{ {
int ret = -1;
if (!domain->persistent) if (!domain->persistent)
return 0; return 0;
@ -3692,11 +3690,9 @@ virDomainObjSetDefTransient(virDomainXMLOptionPtr xmlopt,
if (!(domain->newDef = virDomainDefCopy(domain->def, xmlopt, if (!(domain->newDef = virDomainDefCopy(domain->def, xmlopt,
parseOpaque, false))) parseOpaque, false)))
goto out; return -1;
ret = 0; return 0;
out:
return ret;
} }
@ -7701,7 +7697,6 @@ static int
virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr node, virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr node,
virDomainHostdevDefPtr def) virDomainHostdevDefPtr def)
{ {
int ret = -1;
bool got_product, got_vendor; bool got_product, got_vendor;
xmlNodePtr cur; xmlNodePtr cur;
virDomainHostdevSubsysUSBPtr usbsrc = &def->source.subsys.u.usb; virDomainHostdevSubsysUSBPtr usbsrc = &def->source.subsys.u.usb;
@ -7715,7 +7710,7 @@ virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr node,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unknown startup policy '%s'"), _("Unknown startup policy '%s'"),
startupPolicy); startupPolicy);
goto out; return -1;
} }
} }
@ -7738,12 +7733,12 @@ virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr node,
if (virStrToLong_ui(vendor, NULL, 0, &usbsrc->vendor) < 0) { if (virStrToLong_ui(vendor, NULL, 0, &usbsrc->vendor) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse vendor id %s"), vendor); _("cannot parse vendor id %s"), vendor);
goto out; return -1;
} }
} else { } else {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("usb vendor needs id")); "%s", _("usb vendor needs id"));
goto out; return -1;
} }
} else if (virXMLNodeNameEqual(cur, "product")) { } else if (virXMLNodeNameEqual(cur, "product")) {
g_autofree char *product = virXMLPropString(cur, "id"); g_autofree char *product = virXMLPropString(cur, "id");
@ -7755,12 +7750,12 @@ virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr node,
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse product %s"), _("cannot parse product %s"),
product); product);
goto out; return -1;
} }
} else { } else {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("usb product needs id")); "%s", _("usb product needs id"));
goto out; return -1;
} }
} else if (virXMLNodeNameEqual(cur, "address")) { } else if (virXMLNodeNameEqual(cur, "address")) {
g_autofree char *bus = NULL; g_autofree char *bus = NULL;
@ -7771,12 +7766,12 @@ virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr node,
if (virStrToLong_ui(bus, NULL, 0, &usbsrc->bus) < 0) { if (virStrToLong_ui(bus, NULL, 0, &usbsrc->bus) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse bus %s"), bus); _("cannot parse bus %s"), bus);
goto out; return -1;
} }
} else { } else {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("usb address needs bus id")); "%s", _("usb address needs bus id"));
goto out; return -1;
} }
device = virXMLPropString(cur, "device"); device = virXMLPropString(cur, "device");
@ -7785,18 +7780,18 @@ virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr node,
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse device %s"), _("cannot parse device %s"),
device); device);
goto out; return -1;
} }
} else { } else {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("usb address needs device id")); _("usb address needs device id"));
goto out; return -1;
} }
} else { } else {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown usb source type '%s'"), _("unknown usb source type '%s'"),
cur->name); cur->name);
goto out; return -1;
} }
} }
cur = cur->next; cur = cur->next;
@ -7805,23 +7800,21 @@ virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr node,
if (got_vendor && usbsrc->vendor == 0) { if (got_vendor && usbsrc->vendor == 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("vendor cannot be 0.")); "%s", _("vendor cannot be 0."));
goto out; return -1;
} }
if (!got_vendor && got_product) { if (!got_vendor && got_product) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("missing vendor")); "%s", _("missing vendor"));
goto out; return -1;
} }
if (got_vendor && !got_product) { if (got_vendor && !got_product) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("missing product")); "%s", _("missing product"));
goto out; return -1;
} }
ret = 0; return 0;
out:
return ret;
} }
/* The internal XML for host PCI device's original states: /* The internal XML for host PCI device's original states:
@ -7865,7 +7858,6 @@ virDomainHostdevSubsysPCIDefParseXML(xmlNodePtr node,
virDomainHostdevDefPtr def, virDomainHostdevDefPtr def,
unsigned int flags) unsigned int flags)
{ {
int ret = -1;
xmlNodePtr cur; xmlNodePtr cur;
cur = node->children; cur = node->children;
@ -7876,25 +7868,23 @@ virDomainHostdevSubsysPCIDefParseXML(xmlNodePtr node,
&def->source.subsys.u.pci.addr; &def->source.subsys.u.pci.addr;
if (virPCIDeviceAddressParseXML(cur, addr) < 0) if (virPCIDeviceAddressParseXML(cur, addr) < 0)
goto out; return -1;
} else if ((flags & VIR_DOMAIN_DEF_PARSE_PCI_ORIG_STATES) && } else if ((flags & VIR_DOMAIN_DEF_PARSE_PCI_ORIG_STATES) &&
virXMLNodeNameEqual(cur, "origstates")) { virXMLNodeNameEqual(cur, "origstates")) {
virDomainHostdevOrigStatesPtr states = &def->origstates; virDomainHostdevOrigStatesPtr states = &def->origstates;
if (virDomainHostdevSubsysPCIOrigStatesDefParseXML(cur, states) < 0) if (virDomainHostdevSubsysPCIOrigStatesDefParseXML(cur, states) < 0)
goto out; return -1;
} else { } else {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown pci source type '%s'"), _("unknown pci source type '%s'"),
cur->name); cur->name);
goto out; return -1;
} }
} }
cur = cur->next; cur = cur->next;
} }
ret = 0; return 0;
out:
return ret;
} }
@ -8622,7 +8612,6 @@ virDomainHostdevDefParseXMLCaps(xmlNodePtr node G_GNUC_UNUSED,
virDomainHostdevDefPtr def) virDomainHostdevDefPtr def)
{ {
xmlNodePtr sourcenode; xmlNodePtr sourcenode;
int ret = -1;
/* @type is passed in from the caller rather than read from the /* @type is passed in from the caller rather than read from the
* xml document, because it is specified in different places for * xml document, because it is specified in different places for
@ -8638,18 +8627,18 @@ virDomainHostdevDefParseXMLCaps(xmlNodePtr node G_GNUC_UNUSED,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown host device source address type '%s'"), _("unknown host device source address type '%s'"),
type); type);
goto error; return -1;
} }
} else { } else {
virReportError(VIR_ERR_XML_ERROR, virReportError(VIR_ERR_XML_ERROR,
"%s", _("missing source address type")); "%s", _("missing source address type"));
goto error; return -1;
} }
if (!(sourcenode = virXPathNode("./source", ctxt))) { if (!(sourcenode = virXPathNode("./source", ctxt))) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("Missing <source> element in hostdev device")); _("Missing <source> element in hostdev device"));
goto error; return -1;
} }
switch (def->source.caps.type) { switch (def->source.caps.type) {
@ -8658,7 +8647,7 @@ virDomainHostdevDefParseXMLCaps(xmlNodePtr node G_GNUC_UNUSED,
virXPathString("string(./source/block[1])", ctxt))) { virXPathString("string(./source/block[1])", ctxt))) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("Missing <block> element in hostdev storage device")); _("Missing <block> element in hostdev storage device"));
goto error; return -1;
} }
break; break;
case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_MISC: case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_MISC:
@ -8666,7 +8655,7 @@ virDomainHostdevDefParseXMLCaps(xmlNodePtr node G_GNUC_UNUSED,
virXPathString("string(./source/char[1])", ctxt))) { virXPathString("string(./source/char[1])", ctxt))) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("Missing <char> element in hostdev character device")); _("Missing <char> element in hostdev character device"));
goto error; return -1;
} }
break; break;
case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET: case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET:
@ -8674,21 +8663,20 @@ virDomainHostdevDefParseXMLCaps(xmlNodePtr node G_GNUC_UNUSED,
virXPathString("string(./source/interface[1])", ctxt))) { virXPathString("string(./source/interface[1])", ctxt))) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("Missing <interface> element in hostdev net device")); _("Missing <interface> element in hostdev net device"));
goto error; return -1;
} }
if (virDomainNetIPInfoParseXML(_("Domain hostdev device"), if (virDomainNetIPInfoParseXML(_("Domain hostdev device"),
ctxt, &def->source.caps.u.net.ip) < 0) ctxt, &def->source.caps.u.net.ip) < 0)
goto error; return -1;
break; break;
default: default:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("address type='%s' not supported in hostdev interfaces"), _("address type='%s' not supported in hostdev interfaces"),
virDomainHostdevCapsTypeToString(def->source.caps.type)); virDomainHostdevCapsTypeToString(def->source.caps.type));
goto error; return -1;
} }
ret = 0;
error: return 0;
return ret;
} }
@ -9166,13 +9154,11 @@ virDomainLeaseDefParseXML(xmlNodePtr node)
def->lockspace = g_steal_pointer(&lockspace); def->lockspace = g_steal_pointer(&lockspace);
def->path = g_steal_pointer(&path); def->path = g_steal_pointer(&path);
cleanup:
return def; return def;
error: error:
virDomainLeaseDefFree(def); virDomainLeaseDefFree(def);
def = NULL; return NULL;
goto cleanup;
} }
static int static int
@ -11084,13 +11070,11 @@ virDomainControllerDefParseXML(virDomainXMLOptionPtr xmlopt,
break; break;
} }
cleanup:
return def; return def;
error: error:
virDomainControllerDefFree(def); virDomainControllerDefFree(def);
def = NULL; return NULL;
goto cleanup;
} }
@ -11277,13 +11261,11 @@ virDomainFSDefParseXML(virDomainXMLOptionPtr xmlopt,
if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags) < 0) if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags) < 0)
goto error; goto error;
cleanup:
return def; return def;
error: error:
virDomainFSDefFree(def); virDomainFSDefFree(def);
def = NULL; return NULL;
goto cleanup;
} }
static int static int
@ -13037,13 +13019,11 @@ virDomainChrDefParseXML(virDomainXMLOptionPtr xmlopt,
goto error; goto error;
} }
cleanup:
return def; return def;
error: error:
virDomainChrDefFree(def); virDomainChrDefFree(def);
def = NULL; return NULL;
goto cleanup;
} }
static virDomainSmartcardDefPtr static virDomainSmartcardDefPtr
@ -13167,13 +13147,11 @@ virDomainSmartcardDefParseXML(virDomainXMLOptionPtr xmlopt,
goto error; goto error;
} }
cleanup:
return def; return def;
error: error:
virDomainSmartcardDefFree(def); virDomainSmartcardDefFree(def);
def = NULL; return NULL;
goto cleanup;
} }
/* Parse the XML definition for a TPM device /* Parse the XML definition for a TPM device
@ -13295,13 +13273,11 @@ virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlopt,
if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags) < 0) if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags) < 0)
goto error; goto error;
cleanup:
return def; return def;
error: error:
virDomainTPMDefFree(def); virDomainTPMDefFree(def);
def = NULL; return NULL;
goto cleanup;
} }
static virDomainPanicDefPtr static virDomainPanicDefPtr
@ -13327,13 +13303,11 @@ virDomainPanicDefParseXML(virDomainXMLOptionPtr xmlopt,
goto error; goto error;
} }
cleanup:
return panic; return panic;
error: error:
virDomainPanicDefFree(panic); virDomainPanicDefFree(panic);
panic = NULL; return NULL;
goto cleanup;
} }
/* Parse the XML definition for an input device */ /* Parse the XML definition for an input device */
@ -13485,13 +13459,11 @@ virDomainInputDefParseXML(virDomainXMLOptionPtr xmlopt,
&def->virtio) < 0) &def->virtio) < 0)
goto error; goto error;
cleanup:
return def; return def;
error: error:
virDomainInputDefFree(def); virDomainInputDefFree(def);
def = NULL; return NULL;
goto cleanup;
} }
@ -13524,13 +13496,11 @@ virDomainHubDefParseXML(virDomainXMLOptionPtr xmlopt,
if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags) < 0) if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags) < 0)
goto error; goto error;
cleanup:
return def; return def;
error: error:
virDomainHubDefFree(def); virDomainHubDefFree(def);
def = NULL; return NULL;
goto cleanup;
} }
@ -13649,12 +13619,11 @@ virDomainTimerDefParseXML(xmlNodePtr node,
} }
} }
cleanup:
return def; return def;
error: error:
VIR_FREE(def); VIR_FREE(def);
goto cleanup; return def;
} }
@ -14541,13 +14510,12 @@ virDomainGraphicsDefParseXML(virDomainXMLOptionPtr xmlopt,
break; break;
} }
cleanup:
return def; return def;
error: error:
virDomainGraphicsDefFree(def); virDomainGraphicsDefFree(def);
def = NULL; def = NULL;
goto cleanup; return NULL;
} }
@ -14567,13 +14535,11 @@ virDomainSoundCodecDefParseXML(xmlNodePtr node)
goto error; goto error;
} }
cleanup:
return def; return def;
error: error:
virDomainSoundCodecDefFree(def); virDomainSoundCodecDefFree(def);
def = NULL; return NULL;
goto cleanup;
} }
@ -14629,13 +14595,11 @@ virDomainSoundDefParseXML(virDomainXMLOptionPtr xmlopt,
if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags) < 0) if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags) < 0)
goto error; goto error;
cleanup:
return def; return def;
error: error:
virDomainSoundDefFree(def); virDomainSoundDefFree(def);
def = NULL; return NULL;
goto cleanup;
} }
@ -14719,13 +14683,11 @@ virDomainWatchdogDefParseXML(virDomainXMLOptionPtr xmlopt,
if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags) < 0) if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags) < 0)
goto error; goto error;
cleanup:
return def; return def;
error: error:
virDomainWatchdogDefFree(def); virDomainWatchdogDefFree(def);
def = NULL; return NULL;
goto cleanup;
} }
@ -14832,13 +14794,12 @@ virDomainRNGDefParseXML(virDomainXMLOptionPtr xmlopt,
&def->virtio) < 0) &def->virtio) < 0)
goto error; goto error;
cleanup:
return def; return def;
error: error:
virDomainRNGDefFree(def); virDomainRNGDefFree(def);
def = NULL; def = NULL;
goto cleanup; return NULL;
} }
@ -14898,13 +14859,11 @@ virDomainMemballoonDefParseXML(virDomainXMLOptionPtr xmlopt,
&def->virtio) < 0) &def->virtio) < 0)
goto error; goto error;
cleanup:
return def; return def;
error: error:
virDomainMemballoonDefFree(def); virDomainMemballoonDefFree(def);
def = NULL; return NULL;
goto cleanup;
} }
static virDomainNVRAMDefPtr static virDomainNVRAMDefPtr
@ -15350,13 +15309,11 @@ virSysinfoParseXML(xmlNodePtr node,
goto error; goto error;
} }
cleanup:
return def; return def;
error: error:
virSysinfoDefFree(def); virSysinfoDefFree(def);
def = NULL; return NULL;
goto cleanup;
} }
unsigned int unsigned int
@ -15544,16 +15501,15 @@ virDomainVideoDriverDefParseXML(xmlNodePtr node)
return NULL; return NULL;
if (VIR_ALLOC(def) < 0) if (VIR_ALLOC(def) < 0)
goto cleanup; return def;
if ((val = virDomainVideoVGAConfTypeFromString(vgaconf)) <= 0) { if ((val = virDomainVideoVGAConfTypeFromString(vgaconf)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown vgaconf value '%s'"), vgaconf); _("unknown vgaconf value '%s'"), vgaconf);
goto cleanup; return def;
} }
def->vgaconf = val; def->vgaconf = val;
cleanup:
return def; return def;
} }
@ -15707,13 +15663,11 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xmlopt,
def->driver = virDomainVideoDriverDefParseXML(node); def->driver = virDomainVideoDriverDefParseXML(node);
cleanup:
return def; return def;
error: error:
virDomainVideoDefFree(def); virDomainVideoDefFree(def);
def = NULL; return NULL;
goto cleanup;
} }
static virDomainHostdevDefPtr static virDomainHostdevDefPtr
@ -15783,13 +15737,11 @@ virDomainHostdevDefParseXML(virDomainXMLOptionPtr xmlopt,
} }
} }
cleanup:
return def; return def;
error: error:
virDomainHostdevDefFree(def); virDomainHostdevDefFree(def);
def = NULL; return NULL;
goto cleanup;
} }
@ -15856,14 +15808,11 @@ virDomainRedirdevDefParseXML(virDomainXMLOptionPtr xmlopt,
goto error; goto error;
} }
cleanup:
return def; return def;
error: error:
virDomainRedirdevDefFree(def); virDomainRedirdevDefFree(def);
def = NULL; return NULL;
goto cleanup;
} }
/* /*
@ -15979,13 +15928,11 @@ virDomainRedirFilterUSBDevDefParseXML(xmlNodePtr node)
goto error; goto error;
} }
cleanup:
return def; return def;
error: error:
VIR_FREE(def); VIR_FREE(def);
def = NULL; return NULL;
goto cleanup;
} }
static virDomainRedirFilterDefPtr static virDomainRedirFilterDefPtr
@ -16284,13 +16231,11 @@ virDomainSEVDefParseXML(xmlNodePtr sevNode,
def->dh_cert = virXPathString("string(./dhCert)", ctxt); def->dh_cert = virXPathString("string(./dhCert)", ctxt);
def->session = virXPathString("string(./session)", ctxt); def->session = virXPathString("string(./session)", ctxt);
cleanup:
return def; return def;
error: error:
virDomainSEVDefFree(def); virDomainSEVDefFree(def);
def = NULL; return NULL;
goto cleanup;
} }
static virDomainMemoryDefPtr static virDomainMemoryDefPtr
@ -18238,7 +18183,7 @@ virDomainIdmapDefParseXML(xmlXPathContextPtr ctxt,
VIR_XPATH_NODE_AUTORESTORE(ctxt); VIR_XPATH_NODE_AUTORESTORE(ctxt);
if (VIR_ALLOC_N(idmap, num) < 0) if (VIR_ALLOC_N(idmap, num) < 0)
goto cleanup; return idmap;
for (i = 0; i < num; i++) { for (i = 0; i < num; i++) {
ctxt->node = node[i]; ctxt->node = node[i];
@ -18248,7 +18193,7 @@ virDomainIdmapDefParseXML(xmlXPathContextPtr ctxt,
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("invalid idmap start/target/count settings")); _("invalid idmap start/target/count settings"));
VIR_FREE(idmap); VIR_FREE(idmap);
goto cleanup; return NULL;
} }
} }
@ -18260,10 +18205,9 @@ virDomainIdmapDefParseXML(xmlXPathContextPtr ctxt,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("You must map the root user of container")); _("You must map the root user of container"));
VIR_FREE(idmap); VIR_FREE(idmap);
goto cleanup; return NULL;
} }
cleanup:
return idmap; return idmap;
} }
@ -18300,13 +18244,12 @@ virDomainIOThreadIDDefParseXML(xmlNodePtr node)
goto error; goto error;
} }
cleanup:
return iothrid; return iothrid;
error: error:
virDomainIOThreadIDDefFree(iothrid); virDomainIOThreadIDDefFree(iothrid);
iothrid = NULL; iothrid = NULL;
goto cleanup; return iothrid;
} }
@ -29000,18 +28943,15 @@ virDomainObjFormat(virDomainObjPtr obj,
if (xmlopt->privateData.format && if (xmlopt->privateData.format &&
xmlopt->privateData.format(&buf, obj) < 0) xmlopt->privateData.format(&buf, obj) < 0)
goto error; return NULL;
if (virDomainDefFormatInternal(obj->def, xmlopt, &buf, flags) < 0) if (virDomainDefFormatInternal(obj->def, xmlopt, &buf, flags) < 0)
goto error; return NULL;
virBufferAdjustIndent(&buf, -2); virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</domstatus>\n"); virBufferAddLit(&buf, "</domstatus>\n");
return virBufferContentAndReset(&buf); return virBufferContentAndReset(&buf);
error:
return NULL;
} }
static bool static bool
@ -29318,7 +29258,7 @@ virDomainChrDefForeach(virDomainDefPtr def,
rc = -1; rc = -1;
if (abortOnError && rc != 0) if (abortOnError && rc != 0)
goto done; return rc;
} }
for (i = 0; i < def->nparallels; i++) { for (i = 0; i < def->nparallels; i++) {
@ -29328,7 +29268,7 @@ virDomainChrDefForeach(virDomainDefPtr def,
rc = -1; rc = -1;
if (abortOnError && rc != 0) if (abortOnError && rc != 0)
goto done; return rc;
} }
for (i = 0; i < def->nchannels; i++) { for (i = 0; i < def->nchannels; i++) {
@ -29338,7 +29278,7 @@ virDomainChrDefForeach(virDomainDefPtr def,
rc = -1; rc = -1;
if (abortOnError && rc != 0) if (abortOnError && rc != 0)
goto done; return rc;
} }
for (i = 0; i < def->nconsoles; i++) { for (i = 0; i < def->nconsoles; i++) {
if (virDomainSkipBackcompatConsole(def, i, false)) if (virDomainSkipBackcompatConsole(def, i, false))
@ -29349,10 +29289,9 @@ virDomainChrDefForeach(virDomainDefPtr def,
rc = -1; rc = -1;
if (abortOnError && rc != 0) if (abortOnError && rc != 0)
goto done; return rc;
} }
done:
return rc; return rc;
} }
@ -29373,10 +29312,9 @@ virDomainSmartcardDefForeach(virDomainDefPtr def,
rc = -1; rc = -1;
if (abortOnError && rc != 0) if (abortOnError && rc != 0)
goto done; return rc;
} }
done:
return rc; return rc;
} }

View File

@ -1070,19 +1070,19 @@ virInterfaceDefDevFormat(virBufferPtr buf,
if (def == NULL) { if (def == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("virInterfaceDefFormat NULL def")); "%s", _("virInterfaceDefFormat NULL def"));
goto cleanup; return -1;
} }
if ((def->name == NULL) && (def->type != VIR_INTERFACE_TYPE_VLAN)) { if ((def->name == NULL) && (def->type != VIR_INTERFACE_TYPE_VLAN)) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("virInterfaceDefFormat missing interface name")); "%s", _("virInterfaceDefFormat missing interface name"));
goto cleanup; return -1;
} }
if (!(type = virInterfaceTypeToString(def->type))) { if (!(type = virInterfaceTypeToString(def->type))) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected interface type %d"), def->type); _("unexpected interface type %d"), def->type);
goto cleanup; return -1;
} }
virBufferAsprintf(buf, "<interface type='%s' ", type); virBufferAsprintf(buf, "<interface type='%s' ", type);
@ -1125,9 +1125,6 @@ virInterfaceDefDevFormat(virBufferPtr buf,
virBufferAddLit(buf, "</interface>\n"); virBufferAddLit(buf, "</interface>\n");
return 0; return 0;
cleanup:
return -1;
} }

View File

@ -2240,8 +2240,6 @@ static int
virNetworkIPDefFormat(virBufferPtr buf, virNetworkIPDefFormat(virBufferPtr buf,
const virNetworkIPDef *def) const virNetworkIPDef *def)
{ {
int result = -1;
virBufferAddLit(buf, "<ip"); virBufferAddLit(buf, "<ip");
if (def->family) if (def->family)
@ -2249,14 +2247,14 @@ virNetworkIPDefFormat(virBufferPtr buf,
if (VIR_SOCKET_ADDR_VALID(&def->address)) { if (VIR_SOCKET_ADDR_VALID(&def->address)) {
char *addr = virSocketAddrFormat(&def->address); char *addr = virSocketAddrFormat(&def->address);
if (!addr) if (!addr)
goto error; return -1;
virBufferAsprintf(buf, " address='%s'", addr); virBufferAsprintf(buf, " address='%s'", addr);
VIR_FREE(addr); VIR_FREE(addr);
} }
if (VIR_SOCKET_ADDR_VALID(&def->netmask)) { if (VIR_SOCKET_ADDR_VALID(&def->netmask)) {
char *addr = virSocketAddrFormat(&def->netmask); char *addr = virSocketAddrFormat(&def->netmask);
if (!addr) if (!addr)
goto error; return -1;
virBufferAsprintf(buf, " netmask='%s'", addr); virBufferAsprintf(buf, " netmask='%s'", addr);
VIR_FREE(addr); VIR_FREE(addr);
} }
@ -2283,11 +2281,11 @@ virNetworkIPDefFormat(virBufferPtr buf,
for (i = 0; i < def->nranges; i++) { for (i = 0; i < def->nranges; i++) {
char *saddr = virSocketAddrFormat(&def->ranges[i].start); char *saddr = virSocketAddrFormat(&def->ranges[i].start);
if (!saddr) if (!saddr)
goto error; return -1;
char *eaddr = virSocketAddrFormat(&def->ranges[i].end); char *eaddr = virSocketAddrFormat(&def->ranges[i].end);
if (!eaddr) { if (!eaddr) {
VIR_FREE(saddr); VIR_FREE(saddr);
goto error; return -1;
} }
virBufferAsprintf(buf, "<range start='%s' end='%s'/>\n", virBufferAsprintf(buf, "<range start='%s' end='%s'/>\n",
saddr, eaddr); saddr, eaddr);
@ -2305,7 +2303,7 @@ virNetworkIPDefFormat(virBufferPtr buf,
if (VIR_SOCKET_ADDR_VALID(&def->hosts[i].ip)) { if (VIR_SOCKET_ADDR_VALID(&def->hosts[i].ip)) {
char *ipaddr = virSocketAddrFormat(&def->hosts[i].ip); char *ipaddr = virSocketAddrFormat(&def->hosts[i].ip);
if (!ipaddr) if (!ipaddr)
goto error; return -1;
virBufferAsprintf(buf, " ip='%s'", ipaddr); virBufferAsprintf(buf, " ip='%s'", ipaddr);
VIR_FREE(ipaddr); VIR_FREE(ipaddr);
} }
@ -2317,7 +2315,7 @@ virNetworkIPDefFormat(virBufferPtr buf,
if (VIR_SOCKET_ADDR_VALID(&def->bootserver)) { if (VIR_SOCKET_ADDR_VALID(&def->bootserver)) {
char *ipaddr = virSocketAddrFormat(&def->bootserver); char *ipaddr = virSocketAddrFormat(&def->bootserver);
if (!ipaddr) if (!ipaddr)
goto error; return -1;
virBufferEscapeString(buf, " server='%s'", ipaddr); virBufferEscapeString(buf, " server='%s'", ipaddr);
VIR_FREE(ipaddr); VIR_FREE(ipaddr);
} }
@ -2332,9 +2330,7 @@ virNetworkIPDefFormat(virBufferPtr buf,
virBufferAdjustIndent(buf, -2); virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</ip>\n"); virBufferAddLit(buf, "</ip>\n");
result = 0; return 0;
error:
return result;
} }
@ -2458,7 +2454,7 @@ virNetworkDefFormatBuf(virBufferPtr buf,
virBufferGetIndent(buf) / 2, 1) < 0) { virBufferGetIndent(buf) / 2, 1) < 0) {
xmlBufferFree(xmlbuf); xmlBufferFree(xmlbuf);
xmlIndentTreeOutput = oldIndentTreeOutput; xmlIndentTreeOutput = oldIndentTreeOutput;
goto error; return -1;
} }
virBufferAsprintf(buf, "%s\n", (char *) xmlBufferContent(xmlbuf)); virBufferAsprintf(buf, "%s\n", (char *) xmlBufferContent(xmlbuf));
xmlBufferFree(xmlbuf); xmlBufferFree(xmlbuf);
@ -2475,7 +2471,7 @@ virNetworkDefFormatBuf(virBufferPtr buf,
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unknown forward type %d in network '%s'"), _("Unknown forward type %d in network '%s'"),
def->forward.type, def->name); def->forward.type, def->name);
goto error; return -1;
} }
virBufferAddLit(buf, "<forward"); virBufferAddLit(buf, "<forward");
virBufferEscapeString(buf, " dev='%s'", dev); virBufferEscapeString(buf, " dev='%s'", dev);
@ -2504,13 +2500,13 @@ virNetworkDefFormatBuf(virBufferPtr buf,
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected hostdev driver name type %d "), _("unexpected hostdev driver name type %d "),
def->forward.driverName); def->forward.driverName);
goto error; return -1;
} }
virBufferAsprintf(buf, "<driver name='%s'/>\n", driverName); virBufferAsprintf(buf, "<driver name='%s'/>\n", driverName);
} }
if (def->forward.type == VIR_NETWORK_FORWARD_NAT) { if (def->forward.type == VIR_NETWORK_FORWARD_NAT) {
if (virNetworkForwardNatDefFormat(buf, &def->forward) < 0) if (virNetworkForwardNatDefFormat(buf, &def->forward) < 0)
goto error; return -1;
} }
/* For now, hard-coded to at most 1 forward.pfs */ /* For now, hard-coded to at most 1 forward.pfs */
@ -2562,7 +2558,7 @@ virNetworkDefFormatBuf(virBufferPtr buf,
case VIR_NETWORK_FORWARD_LAST: case VIR_NETWORK_FORWARD_LAST:
default: default:
virReportEnumRangeError(virNetworkForwardType, def->forward.type); virReportEnumRangeError(virNetworkForwardType, def->forward.type);
goto error; return -1;
} }
if (hasbridge || def->bridge || def->macTableManager) { if (hasbridge || def->bridge || def->macTableManager) {
@ -2608,29 +2604,29 @@ virNetworkDefFormatBuf(virBufferPtr buf,
} }
if (virNetworkDNSDefFormat(buf, &def->dns) < 0) if (virNetworkDNSDefFormat(buf, &def->dns) < 0)
goto error; return -1;
if (virNetDevVlanFormat(&def->vlan, buf) < 0) if (virNetDevVlanFormat(&def->vlan, buf) < 0)
goto error; return -1;
if (virNetDevBandwidthFormat(def->bandwidth, 0, buf) < 0) if (virNetDevBandwidthFormat(def->bandwidth, 0, buf) < 0)
goto error; return -1;
for (i = 0; i < def->nips; i++) { for (i = 0; i < def->nips; i++) {
if (virNetworkIPDefFormat(buf, &def->ips[i]) < 0) if (virNetworkIPDefFormat(buf, &def->ips[i]) < 0)
goto error; return -1;
} }
for (i = 0; i < def->nroutes; i++) { for (i = 0; i < def->nroutes; i++) {
if (virNetDevIPRouteFormat(buf, def->routes[i]) < 0) if (virNetDevIPRouteFormat(buf, def->routes[i]) < 0)
goto error; return -1;
} }
if (virNetDevVPortProfileFormat(def->virtPortProfile, buf) < 0) if (virNetDevVPortProfileFormat(def->virtPortProfile, buf) < 0)
goto error; return -1;
for (i = 0; i < def->nPortGroups; i++) for (i = 0; i < def->nPortGroups; i++)
if (virPortGroupDefFormat(buf, &def->portGroups[i]) < 0) if (virPortGroupDefFormat(buf, &def->portGroups[i]) < 0)
goto error; return -1;
if (def->namespaceData && def->ns.format) { if (def->namespaceData && def->ns.format) {
if ((def->ns.format)(buf, def->namespaceData) < 0) if ((def->ns.format)(buf, def->namespaceData) < 0)
@ -2641,9 +2637,6 @@ virNetworkDefFormatBuf(virBufferPtr buf,
virBufferAddLit(buf, "</network>\n"); virBufferAddLit(buf, "</network>\n");
return 0; return 0;
error:
return -1;
} }

View File

@ -290,7 +290,6 @@ int
virNetDevIPRouteFormat(virBufferPtr buf, virNetDevIPRouteFormat(virBufferPtr buf,
const virNetDevIPRoute *def) const virNetDevIPRoute *def)
{ {
int result = -1;
char *addr = NULL; char *addr = NULL;
virBufferAddLit(buf, "<route"); virBufferAddLit(buf, "<route");
@ -299,13 +298,13 @@ virNetDevIPRouteFormat(virBufferPtr buf,
virBufferAsprintf(buf, " family='%s'", def->family); virBufferAsprintf(buf, " family='%s'", def->family);
if (!(addr = virSocketAddrFormat(&def->address))) if (!(addr = virSocketAddrFormat(&def->address)))
goto cleanup; return -1;
virBufferAsprintf(buf, " address='%s'", addr); virBufferAsprintf(buf, " address='%s'", addr);
VIR_FREE(addr); VIR_FREE(addr);
if (VIR_SOCKET_ADDR_VALID(&def->netmask)) { if (VIR_SOCKET_ADDR_VALID(&def->netmask)) {
if (!(addr = virSocketAddrFormat(&def->netmask))) if (!(addr = virSocketAddrFormat(&def->netmask)))
goto cleanup; return -1;
virBufferAsprintf(buf, " netmask='%s'", addr); virBufferAsprintf(buf, " netmask='%s'", addr);
VIR_FREE(addr); VIR_FREE(addr);
} }
@ -313,7 +312,7 @@ virNetDevIPRouteFormat(virBufferPtr buf,
virBufferAsprintf(buf, " prefix='%u'", def->prefix); virBufferAsprintf(buf, " prefix='%u'", def->prefix);
if (!(addr = virSocketAddrFormat(&def->gateway))) if (!(addr = virSocketAddrFormat(&def->gateway)))
goto cleanup; return -1;
virBufferAsprintf(buf, " gateway='%s'", addr); virBufferAsprintf(buf, " gateway='%s'", addr);
VIR_FREE(addr); VIR_FREE(addr);
@ -321,7 +320,5 @@ virNetDevIPRouteFormat(virBufferPtr buf,
virBufferAsprintf(buf, " metric='%u'", def->metric); virBufferAsprintf(buf, " metric='%u'", def->metric);
virBufferAddLit(buf, "/>\n"); virBufferAddLit(buf, "/>\n");
result = 0; return 0;
cleanup:
return result;
} }

View File

@ -2903,7 +2903,7 @@ virNWFilterRuleDefDetailsFormat(virBufferPtr buf,
_("formatter for %s %s reported error"), _("formatter for %s %s reported error"),
type, type,
att[i].name); att[i].name);
goto err_exit; return;
} }
} else if ((flags & NWFILTER_ENTRY_ITEM_FLAG_HAS_VAR)) { } else if ((flags & NWFILTER_ENTRY_ITEM_FLAG_HAS_VAR)) {
virBufferAddChar(buf, '$'); virBufferAddChar(buf, '$');
@ -2986,7 +2986,6 @@ virNWFilterRuleDefDetailsFormat(virBufferPtr buf,
virBufferAsprintf(buf, virBufferAsprintf(buf,
"<%s/>\n", type); "<%s/>\n", type);
err_exit:
return; return;
} }

View File

@ -672,12 +672,9 @@ virNWFilterHashTablePutAll(virHashTablePtr src,
virHashForEach(src, addToTable, &atts); virHashForEach(src, addToTable, &atts);
if (atts.errOccurred) if (atts.errOccurred)
goto err_exit; return -1;
return 0; return 0;
err_exit:
return -1;
} }
/* The general purpose function virNWFilterVarValueEqual returns a /* The general purpose function virNWFilterVarValueEqual returns a

View File

@ -1774,21 +1774,20 @@ virNetworkObjPortListExportCallback(void *payload,
if (data->filter && if (data->filter &&
!data->filter(data->net->conn, data->def, def)) !data->filter(data->net->conn, data->def, def))
goto cleanup; return 0;
if (!data->ports) { if (!data->ports) {
data->nports++; data->nports++;
goto cleanup; return 0;
} }
if (!(port = virGetNetworkPort(data->net, def->uuid))) { if (!(port = virGetNetworkPort(data->net, def->uuid))) {
data->error = true; data->error = true;
goto cleanup; return 0;
} }
data->ports[data->nports++] = port; data->ports[data->nports++] = port;
cleanup:
return 0; return 0;
} }