1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

conf: remove unneeded cleanup labels

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Daniel Henrique Barboza 2019-10-21 15:18:51 -03:00 committed by Ján Tomko
parent 26791f39c0
commit 3814e767d5
11 changed files with 166 additions and 305 deletions

View File

@ -1789,7 +1789,6 @@ virDomainVirtioSerialAddrNext(virDomainDefPtr def,
virDomainDeviceVirtioSerialAddress *addr, virDomainDeviceVirtioSerialAddress *addr,
bool allowZero) bool allowZero)
{ {
int ret = -1;
ssize_t port, startPort = 0; ssize_t port, startPort = 0;
ssize_t i; ssize_t i;
unsigned int controller; unsigned int controller;
@ -1801,7 +1800,7 @@ virDomainVirtioSerialAddrNext(virDomainDefPtr def,
if (addrs->ncontrollers == 0) { if (addrs->ncontrollers == 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("no virtio-serial controllers are available")); _("no virtio-serial controllers are available"));
goto cleanup; return -1;
} }
for (i = 0; i < addrs->ncontrollers; i++) { for (i = 0; i < addrs->ncontrollers; i++) {
@ -1818,7 +1817,7 @@ virDomainVirtioSerialAddrNext(virDomainDefPtr def,
if (idx == -1) { if (idx == -1) {
if (virDomainVirtioSerialAddrSetAutoaddController(def, addrs, i) < 0) if (virDomainVirtioSerialAddrSetAutoaddController(def, addrs, i) < 0)
goto cleanup; return -1;
controller = i; controller = i;
port = startPort + 1; port = startPort + 1;
goto success; goto success;
@ -1829,8 +1828,7 @@ virDomainVirtioSerialAddrNext(virDomainDefPtr def,
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("Unable to find a free virtio-serial port")); _("Unable to find a free virtio-serial port"));
cleanup: return -1;
return ret;
success: success:
addr->bus = 0; addr->bus = 0;
@ -1838,8 +1836,7 @@ virDomainVirtioSerialAddrNext(virDomainDefPtr def,
addr->controller = controller; addr->controller = controller;
VIR_DEBUG("Found free virtio serial controller %u port %u", addr->controller, VIR_DEBUG("Found free virtio serial controller %u port %u", addr->controller,
addr->port); addr->port);
ret = 0; return 0;
goto cleanup;
} }
static int static int
@ -1880,7 +1877,6 @@ virDomainVirtioSerialAddrAssign(virDomainDefPtr def,
bool allowZero, bool allowZero,
bool portOnly) bool portOnly)
{ {
int ret = -1;
virDomainDeviceInfo nfo = { 0 }; virDomainDeviceInfo nfo = { 0 };
virDomainDeviceInfoPtr ptr = allowZero ? &nfo : info; virDomainDeviceInfoPtr ptr = allowZero ? &nfo : info;
@ -1889,20 +1885,17 @@ virDomainVirtioSerialAddrAssign(virDomainDefPtr def,
if (portOnly) { if (portOnly) {
if (virDomainVirtioSerialAddrNextFromController(addrs, if (virDomainVirtioSerialAddrNextFromController(addrs,
&ptr->addr.vioserial) < 0) &ptr->addr.vioserial) < 0)
goto cleanup; return -1;
} else { } else {
if (virDomainVirtioSerialAddrNext(def, addrs, &ptr->addr.vioserial, if (virDomainVirtioSerialAddrNext(def, addrs, &ptr->addr.vioserial,
allowZero) < 0) allowZero) < 0)
goto cleanup; return -1;
} }
if (virDomainVirtioSerialAddrReserve(NULL, NULL, ptr, addrs) < 0) if (virDomainVirtioSerialAddrReserve(NULL, NULL, ptr, addrs) < 0)
goto cleanup; return -1;
ret = 0; return 0;
cleanup:
return ret;
} }
/* virDomainVirtioSerialAddrAutoAssign /* virDomainVirtioSerialAddrAutoAssign

View File

@ -288,7 +288,6 @@ virDomainCapsEnumSet(virDomainCapsEnumPtr capsEnum,
size_t nvalues, size_t nvalues,
unsigned int *values) unsigned int *values)
{ {
int ret = -1;
size_t i; size_t i;
for (i = 0; i < nvalues; i++) { for (i = 0; i < nvalues; i++) {
@ -300,15 +299,13 @@ virDomainCapsEnumSet(virDomainCapsEnumPtr capsEnum,
_("integer overflow on %s. Please contact the " _("integer overflow on %s. Please contact the "
"libvirt development team at libvir-list@redhat.com"), "libvirt development team at libvir-list@redhat.com"),
capsEnumName); capsEnumName);
goto cleanup; return -1;
} }
capsEnum->values |= val; capsEnum->values |= val;
} }
ret = 0; return 0;
cleanup:
return ret;
} }
@ -325,19 +322,15 @@ virDomainCapsEnumFormat(virBufferPtr buf,
const char *capsEnumName, const char *capsEnumName,
virDomainCapsValToStr valToStr) virDomainCapsValToStr valToStr)
{ {
int ret = -1;
size_t i; size_t i;
if (!capsEnum->report) { if (!capsEnum->report)
ret = 0; return 0;
goto cleanup;
}
virBufferAsprintf(buf, "<enum name='%s'", capsEnumName); virBufferAsprintf(buf, "<enum name='%s'", capsEnumName);
if (!capsEnum->values) { if (!capsEnum->values) {
virBufferAddLit(buf, "/>\n"); virBufferAddLit(buf, "/>\n");
ret = 0; return 0;
goto cleanup;
} }
virBufferAddLit(buf, ">\n"); virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 2); virBufferAdjustIndent(buf, 2);
@ -354,9 +347,7 @@ virDomainCapsEnumFormat(virBufferPtr buf,
virBufferAdjustIndent(buf, -2); virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</enum>\n"); virBufferAddLit(buf, "</enum>\n");
ret = 0; return 0;
cleanup:
return ret;
} }

View File

@ -7111,7 +7111,6 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
{ {
g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
g_auto(virBuffer) childBuf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) childBuf = VIR_BUFFER_INITIALIZER;
int ret = -1;
if ((flags & VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT) && info->bootIndex) { if ((flags & VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT) && info->bootIndex) {
virBufferAsprintf(buf, "<boot order='%u'", info->bootIndex); virBufferAsprintf(buf, "<boot order='%u'", info->bootIndex);
@ -7154,11 +7153,9 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
} }
if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE || if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE ||
info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390) { info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390)
/* We're done here */ /* We're done here */
ret = 0; return 0;
goto cleanup;
}
virBufferAsprintf(&attrBuf, " type='%s'", virBufferAsprintf(&attrBuf, " type='%s'",
virDomainDeviceAddressTypeToString(info->type)); virDomainDeviceAddressTypeToString(info->type));
@ -7254,10 +7251,7 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
virXMLFormatElement(buf, "address", &attrBuf, &childBuf); virXMLFormatElement(buf, "address", &attrBuf, &childBuf);
ret = 0; return 0;
cleanup:
return ret;
} }
static int static int
@ -8432,10 +8426,10 @@ virDomainNetDefCoalesceParseXML(xmlNodePtr node,
str = virXPathString("string(./rx/frames/@max)", ctxt); str = virXPathString("string(./rx/frames/@max)", ctxt);
if (!str) if (!str)
goto cleanup; return NULL;
if (VIR_ALLOC(ret) < 0) if (VIR_ALLOC(ret) < 0)
goto cleanup; return NULL;
if (virStrToLong_ullp(str, NULL, 10, &tmp) < 0) { if (virStrToLong_ullp(str, NULL, 10, &tmp) < 0) {
virReportError(VIR_ERR_XML_DETAIL, virReportError(VIR_ERR_XML_DETAIL,
@ -8453,12 +8447,11 @@ virDomainNetDefCoalesceParseXML(xmlNodePtr node,
} }
ret->rx_max_coalesced_frames = tmp; ret->rx_max_coalesced_frames = tmp;
cleanup:
return ret; return ret;
error: error:
VIR_FREE(ret); VIR_FREE(ret);
goto cleanup; return NULL;
} }
static void static void
@ -9871,7 +9864,6 @@ virDomainDiskDefParsePrivateData(xmlXPathContextPtr ctxt,
{ {
xmlNodePtr private_node = virXPathNode("./privateData", ctxt); xmlNodePtr private_node = virXPathNode("./privateData", ctxt);
VIR_XPATH_NODE_AUTORESTORE(ctxt); VIR_XPATH_NODE_AUTORESTORE(ctxt);
int ret = -1;
if (!xmlopt || if (!xmlopt ||
!xmlopt->privateData.diskParse || !xmlopt->privateData.diskParse ||
@ -9881,12 +9873,9 @@ virDomainDiskDefParsePrivateData(xmlXPathContextPtr ctxt,
ctxt->node = private_node; ctxt->node = private_node;
if (xmlopt->privateData.diskParse(ctxt, disk) < 0) if (xmlopt->privateData.diskParse(ctxt, disk) < 0)
goto cleanup; return -1;
ret = 0; return 0;
cleanup:
return ret;
} }
@ -11340,7 +11329,6 @@ virDomainChrSourceReconnectDefParseXML(virDomainChrSourceReconnectDefPtr def,
xmlNodePtr node, xmlNodePtr node,
xmlXPathContextPtr ctxt) xmlXPathContextPtr ctxt)
{ {
int ret = -1;
int tmpVal; int tmpVal;
VIR_XPATH_NODE_AUTORESTORE(ctxt); VIR_XPATH_NODE_AUTORESTORE(ctxt);
xmlNodePtr cur; xmlNodePtr cur;
@ -11354,7 +11342,7 @@ virDomainChrSourceReconnectDefParseXML(virDomainChrSourceReconnectDefPtr def,
virReportError(VIR_ERR_XML_ERROR, virReportError(VIR_ERR_XML_ERROR,
_("invalid reconnect enabled value: '%s'"), _("invalid reconnect enabled value: '%s'"),
tmp); tmp);
goto cleanup; return -1;
} }
def->enabled = tmpVal; def->enabled = tmpVal;
VIR_FREE(tmp); VIR_FREE(tmp);
@ -11366,20 +11354,18 @@ virDomainChrSourceReconnectDefParseXML(virDomainChrSourceReconnectDefPtr def,
virReportError(VIR_ERR_XML_ERROR, virReportError(VIR_ERR_XML_ERROR,
_("invalid reconnect timeout value: '%s'"), _("invalid reconnect timeout value: '%s'"),
tmp); tmp);
goto cleanup; return -1;
} }
} else { } else {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("missing timeout for chardev with " _("missing timeout for chardev with "
"reconnect enabled")); "reconnect enabled"));
goto cleanup; return -1;
} }
} }
} }
ret = 0; return 0;
cleanup:
return ret;
} }
@ -12601,7 +12587,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
virSecurityLabelDefPtr* vmSeclabels, virSecurityLabelDefPtr* vmSeclabels,
int nvmSeclabels) int nvmSeclabels)
{ {
int ret = -1;
bool logParsed = false; bool logParsed = false;
bool protocolParsed = false; bool protocolParsed = false;
int sourceParsed = 0; int sourceParsed = 0;
@ -12716,13 +12701,11 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
} }
} }
ret = 0; return 0;
cleanup:
return ret;
error: error:
virDomainChrSourceDefClear(def); virDomainChrSourceDefClear(def);
goto cleanup; return -1;
} }
@ -13917,7 +13900,6 @@ virDomainGraphicsDefParseXMLSDL(virDomainGraphicsDefPtr def,
VIR_XPATH_NODE_AUTORESTORE(ctxt); VIR_XPATH_NODE_AUTORESTORE(ctxt);
int enableVal; int enableVal;
xmlNodePtr glNode; xmlNodePtr glNode;
int ret = -1;
g_autofree char *fullscreen = virXMLPropString(node, "fullscreen"); g_autofree char *fullscreen = virXMLPropString(node, "fullscreen");
g_autofree char *enable = NULL; g_autofree char *enable = NULL;
@ -13927,7 +13909,7 @@ virDomainGraphicsDefParseXMLSDL(virDomainGraphicsDefPtr def,
if (virStringParseYesNo(fullscreen, &def->data.sdl.fullscreen) < 0) { if (virStringParseYesNo(fullscreen, &def->data.sdl.fullscreen) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown fullscreen value '%s'"), fullscreen); _("unknown fullscreen value '%s'"), fullscreen);
goto cleanup; return -1;
} }
} else { } else {
def->data.sdl.fullscreen = false; def->data.sdl.fullscreen = false;
@ -13942,21 +13924,19 @@ virDomainGraphicsDefParseXMLSDL(virDomainGraphicsDefPtr def,
if (!enable) { if (!enable) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("sdl gl element missing enable")); _("sdl gl element missing enable"));
goto cleanup; return -1;
} }
enableVal = virTristateBoolTypeFromString(enable); enableVal = virTristateBoolTypeFromString(enable);
if (enableVal < 0) { if (enableVal < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown enable value '%s'"), enable); _("unknown enable value '%s'"), enable);
goto cleanup; return -1;
} }
def->data.sdl.gl = enableVal; def->data.sdl.gl = enableVal;
} }
ret = 0; return 0;
cleanup:
return ret;
} }
@ -14992,7 +14972,6 @@ virSysinfoBaseBoardParseXML(xmlXPathContextPtr ctxt,
virSysinfoBaseBoardDefPtr *baseBoard, virSysinfoBaseBoardDefPtr *baseBoard,
size_t *nbaseBoard) size_t *nbaseBoard)
{ {
int ret = -1;
size_t i, nboards = 0; size_t i, nboards = 0;
VIR_XPATH_NODE_AUTORESTORE(ctxt); VIR_XPATH_NODE_AUTORESTORE(ctxt);
int n; int n;
@ -15000,10 +14979,10 @@ virSysinfoBaseBoardParseXML(xmlXPathContextPtr ctxt,
g_autofree xmlNodePtr *nodes = NULL; g_autofree xmlNodePtr *nodes = NULL;
if ((n = virXPathNodeSet("./baseBoard", ctxt, &nodes)) < 0) if ((n = virXPathNodeSet("./baseBoard", ctxt, &nodes)) < 0)
return ret; return -1;
if (n && VIR_ALLOC_N(boards, n) < 0) if (n && VIR_ALLOC_N(boards, n) < 0)
goto cleanup; return -1;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
virSysinfoBaseBoardDefPtr def = boards + nboards; virSysinfoBaseBoardDefPtr def = boards + nboards;
@ -15033,9 +15012,8 @@ virSysinfoBaseBoardParseXML(xmlXPathContextPtr ctxt,
*baseBoard = g_steal_pointer(&boards); *baseBoard = g_steal_pointer(&boards);
*nbaseBoard = nboards; *nbaseBoard = nboards;
ret = 0;
cleanup: return 0;
return ret;
} }
@ -15972,7 +15950,6 @@ virDomainMemorySourceDefParseXML(xmlNodePtr node,
xmlXPathContextPtr ctxt, xmlXPathContextPtr ctxt,
virDomainMemoryDefPtr def) virDomainMemoryDefPtr def)
{ {
int ret = -1;
VIR_XPATH_NODE_AUTORESTORE(ctxt); VIR_XPATH_NODE_AUTORESTORE(ctxt);
ctxt->node = node; ctxt->node = node;
g_autofree char *nodemask = NULL; g_autofree char *nodemask = NULL;
@ -15981,17 +15958,17 @@ virDomainMemorySourceDefParseXML(xmlNodePtr node,
case VIR_DOMAIN_MEMORY_MODEL_DIMM: case VIR_DOMAIN_MEMORY_MODEL_DIMM:
if (virDomainParseMemory("./pagesize", "./pagesize/@unit", ctxt, if (virDomainParseMemory("./pagesize", "./pagesize/@unit", ctxt,
&def->pagesize, false, false) < 0) &def->pagesize, false, false) < 0)
goto cleanup; return -1;
if ((nodemask = virXPathString("string(./nodemask)", ctxt))) { if ((nodemask = virXPathString("string(./nodemask)", ctxt))) {
if (virBitmapParse(nodemask, &def->sourceNodes, if (virBitmapParse(nodemask, &def->sourceNodes,
VIR_DOMAIN_CPUMASK_LEN) < 0) VIR_DOMAIN_CPUMASK_LEN) < 0)
goto cleanup; return -1;
if (virBitmapIsAllClear(def->sourceNodes)) { if (virBitmapIsAllClear(def->sourceNodes)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Invalid value of 'nodemask': %s"), nodemask); _("Invalid value of 'nodemask': %s"), nodemask);
goto cleanup; return -1;
} }
} }
break; break;
@ -16000,12 +15977,12 @@ virDomainMemorySourceDefParseXML(xmlNodePtr node,
if (!(def->nvdimmPath = virXPathString("string(./path)", ctxt))) { if (!(def->nvdimmPath = virXPathString("string(./path)", ctxt))) {
virReportError(VIR_ERR_XML_DETAIL, "%s", virReportError(VIR_ERR_XML_DETAIL, "%s",
_("path is required for model 'nvdimm'")); _("path is required for model 'nvdimm'"));
goto cleanup; return -1;
} }
if (virDomainParseMemory("./alignsize", "./alignsize/@unit", ctxt, if (virDomainParseMemory("./alignsize", "./alignsize/@unit", ctxt,
&def->alignsize, false, false) < 0) &def->alignsize, false, false) < 0)
goto cleanup; return -1;
if (virXPathBoolean("boolean(./pmem)", ctxt)) if (virXPathBoolean("boolean(./pmem)", ctxt))
def->nvdimmPmem = true; def->nvdimmPmem = true;
@ -16017,10 +15994,7 @@ virDomainMemorySourceDefParseXML(xmlNodePtr node,
break; break;
} }
ret = 0; return 0;
cleanup:
return ret;
} }
@ -16029,7 +16003,6 @@ virDomainMemoryTargetDefParseXML(xmlNodePtr node,
xmlXPathContextPtr ctxt, xmlXPathContextPtr ctxt,
virDomainMemoryDefPtr def) virDomainMemoryDefPtr def)
{ {
int ret = -1;
VIR_XPATH_NODE_AUTORESTORE(ctxt); VIR_XPATH_NODE_AUTORESTORE(ctxt);
ctxt->node = node; ctxt->node = node;
int rv; int rv;
@ -16041,38 +16014,35 @@ virDomainMemoryTargetDefParseXML(xmlNodePtr node,
(rv == 0 && def->targetNode < 0)) { (rv == 0 && def->targetNode < 0)) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("invalid value of memory device node")); _("invalid value of memory device node"));
goto cleanup; return -1;
} }
if (virDomainParseMemory("./size", "./size/@unit", ctxt, if (virDomainParseMemory("./size", "./size/@unit", ctxt,
&def->size, true, false) < 0) &def->size, true, false) < 0)
goto cleanup; return -1;
if (def->model == VIR_DOMAIN_MEMORY_MODEL_NVDIMM) { if (def->model == VIR_DOMAIN_MEMORY_MODEL_NVDIMM) {
if (virDomainParseMemory("./label/size", "./label/size/@unit", ctxt, if (virDomainParseMemory("./label/size", "./label/size/@unit", ctxt,
&def->labelsize, false, false) < 0) &def->labelsize, false, false) < 0)
goto cleanup; return -1;
if (def->labelsize && def->labelsize < 128) { if (def->labelsize && def->labelsize < 128) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("nvdimm label must be at least 128KiB")); _("nvdimm label must be at least 128KiB"));
goto cleanup; return -1;
} }
if (def->labelsize >= def->size) { if (def->labelsize >= def->size) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("label size must be smaller than NVDIMM size")); _("label size must be smaller than NVDIMM size"));
goto cleanup; return -1;
} }
if (virXPathBoolean("boolean(./readonly)", ctxt)) if (virXPathBoolean("boolean(./readonly)", ctxt))
def->readonly = true; def->readonly = true;
} }
ret = 0; return 0;
cleanup:
return ret;
} }
@ -16223,7 +16193,6 @@ static virDomainIOMMUDefPtr
virDomainIOMMUDefParseXML(xmlNodePtr node, virDomainIOMMUDefParseXML(xmlNodePtr node,
xmlXPathContextPtr ctxt) xmlXPathContextPtr ctxt)
{ {
virDomainIOMMUDefPtr ret = NULL;
VIR_XPATH_NODE_AUTORESTORE(ctxt); VIR_XPATH_NODE_AUTORESTORE(ctxt);
xmlNodePtr driver; xmlNodePtr driver;
int val; int val;
@ -16233,17 +16202,17 @@ virDomainIOMMUDefParseXML(xmlNodePtr node,
ctxt->node = node; ctxt->node = node;
if (VIR_ALLOC(iommu) < 0) if (VIR_ALLOC(iommu) < 0)
goto cleanup; return NULL;
if (!(tmp = virXMLPropString(node, "model"))) { if (!(tmp = virXMLPropString(node, "model"))) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("missing model for IOMMU device")); _("missing model for IOMMU device"));
goto cleanup; return NULL;
} }
if ((val = virDomainIOMMUModelTypeFromString(tmp)) < 0) { if ((val = virDomainIOMMUModelTypeFromString(tmp)) < 0) {
virReportError(VIR_ERR_XML_ERROR, _("unknown IOMMU model: %s"), tmp); virReportError(VIR_ERR_XML_ERROR, _("unknown IOMMU model: %s"), tmp);
goto cleanup; return NULL;
} }
iommu->model = val; iommu->model = val;
@ -16253,7 +16222,7 @@ virDomainIOMMUDefParseXML(xmlNodePtr node,
if ((tmp = virXMLPropString(driver, "intremap"))) { if ((tmp = virXMLPropString(driver, "intremap"))) {
if ((val = virTristateSwitchTypeFromString(tmp)) < 0) { if ((val = virTristateSwitchTypeFromString(tmp)) < 0) {
virReportError(VIR_ERR_XML_ERROR, _("unknown intremap value: %s"), tmp); virReportError(VIR_ERR_XML_ERROR, _("unknown intremap value: %s"), tmp);
goto cleanup; return NULL;
} }
iommu->intremap = val; iommu->intremap = val;
} }
@ -16262,7 +16231,7 @@ virDomainIOMMUDefParseXML(xmlNodePtr node,
if ((tmp = virXMLPropString(driver, "caching_mode"))) { if ((tmp = virXMLPropString(driver, "caching_mode"))) {
if ((val = virTristateSwitchTypeFromString(tmp)) < 0) { if ((val = virTristateSwitchTypeFromString(tmp)) < 0) {
virReportError(VIR_ERR_XML_ERROR, _("unknown caching_mode value: %s"), tmp); virReportError(VIR_ERR_XML_ERROR, _("unknown caching_mode value: %s"), tmp);
goto cleanup; return NULL;
} }
iommu->caching_mode = val; iommu->caching_mode = val;
} }
@ -16270,7 +16239,7 @@ virDomainIOMMUDefParseXML(xmlNodePtr node,
if ((tmp = virXMLPropString(driver, "iotlb"))) { if ((tmp = virXMLPropString(driver, "iotlb"))) {
if ((val = virTristateSwitchTypeFromString(tmp)) < 0) { if ((val = virTristateSwitchTypeFromString(tmp)) < 0) {
virReportError(VIR_ERR_XML_ERROR, _("unknown iotlb value: %s"), tmp); virReportError(VIR_ERR_XML_ERROR, _("unknown iotlb value: %s"), tmp);
goto cleanup; return NULL;
} }
iommu->iotlb = val; iommu->iotlb = val;
} }
@ -16279,16 +16248,13 @@ virDomainIOMMUDefParseXML(xmlNodePtr node,
if ((tmp = virXMLPropString(driver, "eim"))) { if ((tmp = virXMLPropString(driver, "eim"))) {
if ((val = virTristateSwitchTypeFromString(tmp)) < 0) { if ((val = virTristateSwitchTypeFromString(tmp)) < 0) {
virReportError(VIR_ERR_XML_ERROR, _("unknown eim value: %s"), tmp); virReportError(VIR_ERR_XML_ERROR, _("unknown eim value: %s"), tmp);
goto cleanup; return NULL;
} }
iommu->eim = val; iommu->eim = val;
} }
} }
ret = g_steal_pointer(&iommu); return g_steal_pointer(&iommu);
cleanup:
return ret;
} }
@ -16298,7 +16264,6 @@ virDomainVsockDefParseXML(virDomainXMLOptionPtr xmlopt,
xmlXPathContextPtr ctxt, xmlXPathContextPtr ctxt,
unsigned int flags) unsigned int flags)
{ {
virDomainVsockDefPtr ret = NULL;
VIR_XPATH_NODE_AUTORESTORE(ctxt); VIR_XPATH_NODE_AUTORESTORE(ctxt);
xmlNodePtr cid; xmlNodePtr cid;
int val; int val;
@ -16308,12 +16273,12 @@ virDomainVsockDefParseXML(virDomainXMLOptionPtr xmlopt,
ctxt->node = node; ctxt->node = node;
if (!(vsock = virDomainVsockDefNew(xmlopt))) if (!(vsock = virDomainVsockDefNew(xmlopt)))
goto cleanup; return NULL;
if ((tmp = virXMLPropString(node, "model"))) { if ((tmp = virXMLPropString(node, "model"))) {
if ((val = virDomainVsockModelTypeFromString(tmp)) < 0) { if ((val = virDomainVsockModelTypeFromString(tmp)) < 0) {
virReportError(VIR_ERR_XML_ERROR, _("unknown vsock model: %s"), tmp); virReportError(VIR_ERR_XML_ERROR, _("unknown vsock model: %s"), tmp);
goto cleanup; return NULL;
} }
vsock->model = val; vsock->model = val;
} }
@ -16328,7 +16293,7 @@ virDomainVsockDefParseXML(virDomainXMLOptionPtr xmlopt,
virReportError(VIR_ERR_XML_DETAIL, virReportError(VIR_ERR_XML_DETAIL,
_("'cid' attribute must be a positive number: %s"), _("'cid' attribute must be a positive number: %s"),
tmp); tmp);
goto cleanup; return NULL;
} }
} }
@ -16339,19 +16304,16 @@ virDomainVsockDefParseXML(virDomainXMLOptionPtr xmlopt,
virReportError(VIR_ERR_XML_DETAIL, virReportError(VIR_ERR_XML_DETAIL,
_("'auto' attribute can be 'yes' or 'no': %s"), _("'auto' attribute can be 'yes' or 'no': %s"),
tmp); tmp);
goto cleanup; return NULL;
} }
vsock->auto_cid = val; vsock->auto_cid = val;
} }
} }
if (virDomainDeviceInfoParseXML(xmlopt, node, &vsock->info, flags) < 0) if (virDomainDeviceInfoParseXML(xmlopt, node, &vsock->info, flags) < 0)
goto cleanup; return NULL;
ret = g_steal_pointer(&vsock); return g_steal_pointer(&vsock);
cleanup:
return ret;
} }
virDomainDeviceDefPtr virDomainDeviceDefPtr
@ -18509,7 +18471,6 @@ virDomainHugepagesParseXML(xmlNodePtr node,
xmlXPathContextPtr ctxt, xmlXPathContextPtr ctxt,
virDomainHugePagePtr hugepage) virDomainHugePagePtr hugepage)
{ {
int ret = -1;
VIR_XPATH_NODE_AUTORESTORE(ctxt); VIR_XPATH_NODE_AUTORESTORE(ctxt);
g_autofree char *nodeset = NULL; g_autofree char *nodeset = NULL;
@ -18517,29 +18478,27 @@ virDomainHugepagesParseXML(xmlNodePtr node,
if (virDomainParseMemory("./@size", "./@unit", ctxt, if (virDomainParseMemory("./@size", "./@unit", ctxt,
&hugepage->size, true, false) < 0) &hugepage->size, true, false) < 0)
goto cleanup; return -1;
if (!hugepage->size) { if (!hugepage->size) {
virReportError(VIR_ERR_XML_DETAIL, "%s", virReportError(VIR_ERR_XML_DETAIL, "%s",
_("hugepage size can't be zero")); _("hugepage size can't be zero"));
goto cleanup; return -1;
} }
if ((nodeset = virXMLPropString(node, "nodeset"))) { if ((nodeset = virXMLPropString(node, "nodeset"))) {
if (virBitmapParse(nodeset, &hugepage->nodemask, if (virBitmapParse(nodeset, &hugepage->nodemask,
VIR_DOMAIN_CPUMASK_LEN) < 0) VIR_DOMAIN_CPUMASK_LEN) < 0)
goto cleanup; return -1;
if (virBitmapIsAllClear(hugepage->nodemask)) { if (virBitmapIsAllClear(hugepage->nodemask)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Invalid value of 'nodeset': %s"), nodeset); _("Invalid value of 'nodeset': %s"), nodeset);
goto cleanup; return -1;
} }
} }
ret = 0; return 0;
cleanup:
return ret;
} }
@ -19188,7 +19147,6 @@ virDomainCachetuneDefParseCache(xmlXPathContextPtr ctxt,
unsigned int cache; unsigned int cache;
int type; int type;
unsigned long long size; unsigned long long size;
int ret = -1;
g_autofree char *tmp = NULL; g_autofree char *tmp = NULL;
ctxt->node = node; ctxt->node = node;
@ -19197,13 +19155,13 @@ virDomainCachetuneDefParseCache(xmlXPathContextPtr ctxt,
if (!tmp) { if (!tmp) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("Missing cachetune attribute 'id'")); _("Missing cachetune attribute 'id'"));
goto cleanup; return -1;
} }
if (virStrToLong_uip(tmp, NULL, 10, &cache) < 0) { if (virStrToLong_uip(tmp, NULL, 10, &cache) < 0) {
virReportError(VIR_ERR_XML_ERROR, virReportError(VIR_ERR_XML_ERROR,
_("Invalid cachetune attribute 'id' value '%s'"), _("Invalid cachetune attribute 'id' value '%s'"),
tmp); tmp);
goto cleanup; return -1;
} }
VIR_FREE(tmp); VIR_FREE(tmp);
@ -19211,13 +19169,13 @@ virDomainCachetuneDefParseCache(xmlXPathContextPtr ctxt,
if (!tmp) { if (!tmp) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("Missing cachetune attribute 'level'")); _("Missing cachetune attribute 'level'"));
goto cleanup; return -1;
} }
if (virStrToLong_uip(tmp, NULL, 10, &level) < 0) { if (virStrToLong_uip(tmp, NULL, 10, &level) < 0) {
virReportError(VIR_ERR_XML_ERROR, virReportError(VIR_ERR_XML_ERROR,
_("Invalid cachetune attribute 'level' value '%s'"), _("Invalid cachetune attribute 'level' value '%s'"),
tmp); tmp);
goto cleanup; return -1;
} }
VIR_FREE(tmp); VIR_FREE(tmp);
@ -19225,27 +19183,25 @@ virDomainCachetuneDefParseCache(xmlXPathContextPtr ctxt,
if (!tmp) { if (!tmp) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("Missing cachetune attribute 'type'")); _("Missing cachetune attribute 'type'"));
goto cleanup; return -1;
} }
type = virCacheTypeFromString(tmp); type = virCacheTypeFromString(tmp);
if (type < 0) { if (type < 0) {
virReportError(VIR_ERR_XML_ERROR, virReportError(VIR_ERR_XML_ERROR,
_("Invalid cachetune attribute 'type' value '%s'"), _("Invalid cachetune attribute 'type' value '%s'"),
tmp); tmp);
goto cleanup; return -1;
} }
if (virDomainParseScaledValue("./@size", "./@unit", if (virDomainParseScaledValue("./@size", "./@unit",
ctxt, &size, 1024, ctxt, &size, 1024,
ULLONG_MAX, true) < 0) ULLONG_MAX, true) < 0)
goto cleanup; return -1;
if (virResctrlAllocSetCacheSize(alloc, level, type, cache, size) < 0) if (virResctrlAllocSetCacheSize(alloc, level, type, cache, size) < 0)
goto cleanup; return -1;
ret = 0; return 0;
cleanup:
return ret;
} }
@ -19638,7 +19594,6 @@ virDomainMemorytuneDefParseMemory(xmlXPathContextPtr ctxt,
VIR_XPATH_NODE_AUTORESTORE(ctxt); VIR_XPATH_NODE_AUTORESTORE(ctxt);
unsigned int id; unsigned int id;
unsigned int bandwidth; unsigned int bandwidth;
int ret = -1;
g_autofree char *tmp = NULL; g_autofree char *tmp = NULL;
ctxt->node = node; ctxt->node = node;
@ -19647,13 +19602,13 @@ virDomainMemorytuneDefParseMemory(xmlXPathContextPtr ctxt,
if (!tmp) { if (!tmp) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("Missing memorytune attribute 'id'")); _("Missing memorytune attribute 'id'"));
goto cleanup; return -1;
} }
if (virStrToLong_uip(tmp, NULL, 10, &id) < 0) { if (virStrToLong_uip(tmp, NULL, 10, &id) < 0) {
virReportError(VIR_ERR_XML_ERROR, virReportError(VIR_ERR_XML_ERROR,
_("Invalid memorytune attribute 'id' value '%s'"), _("Invalid memorytune attribute 'id' value '%s'"),
tmp); tmp);
goto cleanup; return -1;
} }
VIR_FREE(tmp); VIR_FREE(tmp);
@ -19661,20 +19616,18 @@ virDomainMemorytuneDefParseMemory(xmlXPathContextPtr ctxt,
if (!tmp) { if (!tmp) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("Missing memorytune attribute 'bandwidth'")); _("Missing memorytune attribute 'bandwidth'"));
goto cleanup; return -1;
} }
if (virStrToLong_uip(tmp, NULL, 10, &bandwidth) < 0) { if (virStrToLong_uip(tmp, NULL, 10, &bandwidth) < 0) {
virReportError(VIR_ERR_XML_ERROR, virReportError(VIR_ERR_XML_ERROR,
_("Invalid memorytune attribute 'bandwidth' value '%s'"), _("Invalid memorytune attribute 'bandwidth' value '%s'"),
tmp); tmp);
goto cleanup; return -1;
} }
if (virResctrlAllocSetMemoryBandwidth(alloc, id, bandwidth) < 0) if (virResctrlAllocSetMemoryBandwidth(alloc, id, bandwidth) < 0)
goto cleanup; return -1;
ret = 0; return 0;
cleanup:
return ret;
} }
@ -24099,7 +24052,6 @@ virDomainDiskSourceFormatPrivateData(virBufferPtr buf,
virDomainXMLOptionPtr xmlopt) virDomainXMLOptionPtr xmlopt)
{ {
g_auto(virBuffer) childBuf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) childBuf = VIR_BUFFER_INITIALIZER;
int ret = -1;
if (!(flags & VIR_DOMAIN_DEF_FORMAT_STATUS) || if (!(flags & VIR_DOMAIN_DEF_FORMAT_STATUS) ||
!xmlopt || !xmlopt->privateData.storageFormat) !xmlopt || !xmlopt->privateData.storageFormat)
@ -24108,14 +24060,10 @@ virDomainDiskSourceFormatPrivateData(virBufferPtr buf,
virBufferSetChildIndent(&childBuf, buf); virBufferSetChildIndent(&childBuf, buf);
if (xmlopt->privateData.storageFormat(src, &childBuf) < 0) if (xmlopt->privateData.storageFormat(src, &childBuf) < 0)
goto cleanup; return -1;
virXMLFormatElement(buf, "privateData", NULL, &childBuf); virXMLFormatElement(buf, "privateData", NULL, &childBuf);
return 0;
ret = 0;
cleanup:
return ret;
} }
@ -24803,18 +24751,17 @@ virDomainFSDefFormat(virBufferPtr buf,
const char *wrpolicy = virDomainFSWrpolicyTypeToString(def->wrpolicy); const char *wrpolicy = virDomainFSWrpolicyTypeToString(def->wrpolicy);
const char *src = def->src->path; const char *src = def->src->path;
g_auto(virBuffer) driverBuf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) driverBuf = VIR_BUFFER_INITIALIZER;
int ret = -1;
if (!type) { if (!type) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected filesystem type %d"), def->type); _("unexpected filesystem type %d"), def->type);
goto cleanup; return -1;
} }
if (!accessmode) { if (!accessmode) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected accessmode %d"), def->accessmode); _("unexpected accessmode %d"), def->accessmode);
goto cleanup; return -1;
} }
virBufferAsprintf(buf, virBufferAsprintf(buf,
@ -24890,7 +24837,7 @@ virDomainFSDefFormat(virBufferPtr buf,
virBufferAddLit(buf, "<readonly/>\n"); virBufferAddLit(buf, "<readonly/>\n");
if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
goto cleanup; return -1;
if (def->space_hard_limit) if (def->space_hard_limit)
virBufferAsprintf(buf, "<space_hard_limit unit='bytes'>" virBufferAsprintf(buf, "<space_hard_limit unit='bytes'>"
@ -24902,10 +24849,7 @@ virDomainFSDefFormat(virBufferPtr buf,
virBufferAdjustIndent(buf, -2); virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</filesystem>\n"); virBufferAddLit(buf, "</filesystem>\n");
ret = 0; return 0;
cleanup:
return ret;
} }
@ -26016,14 +25960,13 @@ virDomainSmartcardDefFormat(virBufferPtr buf,
const char *mode = virDomainSmartcardTypeToString(def->type); const char *mode = virDomainSmartcardTypeToString(def->type);
g_auto(virBuffer) childBuf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) childBuf = VIR_BUFFER_INITIALIZER;
size_t i; size_t i;
int ret = -1;
virBufferSetChildIndent(&childBuf, buf); virBufferSetChildIndent(&childBuf, buf);
if (!mode) { if (!mode) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected smartcard type %d"), def->type); _("unexpected smartcard type %d"), def->type);
goto cleanup; return -1;
} }
switch (def->type) { switch (def->type) {
@ -26041,21 +25984,21 @@ virDomainSmartcardDefFormat(virBufferPtr buf,
case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH: case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH:
if (virDomainChrSourceDefFormat(&childBuf, def->data.passthru, flags) < 0) if (virDomainChrSourceDefFormat(&childBuf, def->data.passthru, flags) < 0)
goto cleanup; return -1;
break; break;
default: default:
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected smartcard type %d"), def->type); _("unexpected smartcard type %d"), def->type);
goto cleanup; return -1;
} }
if (virDomainDeviceInfoFormat(&childBuf, &def->info, flags) < 0) if (virDomainDeviceInfoFormat(&childBuf, &def->info, flags) < 0)
goto cleanup; return -1;
virBufferAsprintf(buf, "<smartcard mode='%s'", mode); virBufferAsprintf(buf, "<smartcard mode='%s'", mode);
if (def->type == VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH && if (def->type == VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH &&
virDomainChrAttrsDefFormat(buf, def->data.passthru, false) < 0) { virDomainChrAttrsDefFormat(buf, def->data.passthru, false) < 0) {
goto cleanup; return -1;
} }
if (virBufferUse(&childBuf)) { if (virBufferUse(&childBuf)) {
@ -26066,10 +26009,7 @@ virDomainSmartcardDefFormat(virBufferPtr buf,
virBufferAddLit(buf, "/>\n"); virBufferAddLit(buf, "/>\n");
} }
ret = 0; return 0;
cleanup:
return ret;
} }
static int static int
@ -26146,21 +26086,20 @@ virDomainSoundDefFormat(virBufferPtr buf,
const char *model = virDomainSoundModelTypeToString(def->model); const char *model = virDomainSoundModelTypeToString(def->model);
g_auto(virBuffer) childBuf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) childBuf = VIR_BUFFER_INITIALIZER;
size_t i; size_t i;
int ret = -1;
virBufferSetChildIndent(&childBuf, buf); virBufferSetChildIndent(&childBuf, buf);
if (!model) { if (!model) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected sound model %d"), def->model); _("unexpected sound model %d"), def->model);
goto cleanup; return -1;
} }
for (i = 0; i < def->ncodecs; i++) for (i = 0; i < def->ncodecs; i++)
virDomainSoundCodecDefFormat(&childBuf, def->codecs[i]); virDomainSoundCodecDefFormat(&childBuf, def->codecs[i]);
if (virDomainDeviceInfoFormat(&childBuf, &def->info, flags) < 0) if (virDomainDeviceInfoFormat(&childBuf, &def->info, flags) < 0)
goto cleanup; return -1;
virBufferAsprintf(buf, "<sound model='%s'", model); virBufferAsprintf(buf, "<sound model='%s'", model);
if (virBufferUse(&childBuf)) { if (virBufferUse(&childBuf)) {
@ -26171,10 +26110,7 @@ virDomainSoundDefFormat(virBufferPtr buf,
virBufferAddLit(buf, "/>\n"); virBufferAddLit(buf, "/>\n");
} }
ret = 0; return 0;
cleanup:
return ret;
} }
@ -26539,12 +26475,11 @@ virDomainVideoDefFormat(virBufferPtr buf,
{ {
const char *model = virDomainVideoTypeToString(def->type); const char *model = virDomainVideoTypeToString(def->type);
g_auto(virBuffer) driverBuf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) driverBuf = VIR_BUFFER_INITIALIZER;
int ret = -1;
if (!model) { if (!model) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected video model %d"), def->type); _("unexpected video model %d"), def->type);
goto cleanup; return -1;
} }
virBufferAddLit(buf, "<video>\n"); virBufferAddLit(buf, "<video>\n");
@ -26591,15 +26526,12 @@ virDomainVideoDefFormat(virBufferPtr buf,
} }
if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
goto cleanup; return -1;
virBufferAdjustIndent(buf, -2); virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</video>\n"); virBufferAddLit(buf, "</video>\n");
ret = 0; return 0;
cleanup:
return ret;
} }
static int static int
@ -27614,37 +27546,34 @@ virDomainCachetuneDefFormat(virBufferPtr buf,
{ {
g_auto(virBuffer) childrenBuf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) childrenBuf = VIR_BUFFER_INITIALIZER;
size_t i = 0; size_t i = 0;
int ret = -1;
g_autofree char *vcpus = NULL; g_autofree char *vcpus = NULL;
virBufferSetChildIndent(&childrenBuf, buf); virBufferSetChildIndent(&childrenBuf, buf);
if (virResctrlAllocForeachCache(resctrl->alloc, if (virResctrlAllocForeachCache(resctrl->alloc,
virDomainCachetuneDefFormatHelper, virDomainCachetuneDefFormatHelper,
&childrenBuf) < 0) &childrenBuf) < 0)
goto cleanup; return -1;
for (i = 0; i < resctrl->nmonitors; i++) { for (i = 0; i < resctrl->nmonitors; i++) {
if (virDomainResctrlMonDefFormatHelper(resctrl->monitors[i], if (virDomainResctrlMonDefFormatHelper(resctrl->monitors[i],
VIR_RESCTRL_MONITOR_TYPE_CACHE, VIR_RESCTRL_MONITOR_TYPE_CACHE,
&childrenBuf) < 0) &childrenBuf) < 0)
goto cleanup; return -1;
} }
if (!virBufferUse(&childrenBuf)) { if (!virBufferUse(&childrenBuf))
ret = 0; return 0;
goto cleanup;
}
vcpus = virBitmapFormat(resctrl->vcpus); vcpus = virBitmapFormat(resctrl->vcpus);
if (!vcpus) if (!vcpus)
goto cleanup; return -1;
virBufferAsprintf(buf, "<cachetune vcpus='%s'", vcpus); virBufferAsprintf(buf, "<cachetune vcpus='%s'", vcpus);
if (!(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE)) { if (!(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE)) {
const char *alloc_id = virResctrlAllocGetID(resctrl->alloc); const char *alloc_id = virResctrlAllocGetID(resctrl->alloc);
if (!alloc_id) if (!alloc_id)
goto cleanup; return -1;
virBufferAsprintf(buf, " id='%s'", alloc_id); virBufferAsprintf(buf, " id='%s'", alloc_id);
} }
@ -27653,9 +27582,7 @@ virDomainCachetuneDefFormat(virBufferPtr buf,
virBufferAddBuffer(buf, &childrenBuf); virBufferAddBuffer(buf, &childrenBuf);
virBufferAddLit(buf, "</cachetune>\n"); virBufferAddLit(buf, "</cachetune>\n");
ret = 0; return 0;
cleanup:
return ret;
} }
@ -27679,30 +27606,28 @@ virDomainMemorytuneDefFormat(virBufferPtr buf,
unsigned int flags) unsigned int flags)
{ {
g_auto(virBuffer) childrenBuf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) childrenBuf = VIR_BUFFER_INITIALIZER;
int ret = -1;
g_autofree char *vcpus = NULL; g_autofree char *vcpus = NULL;
virBufferSetChildIndent(&childrenBuf, buf); virBufferSetChildIndent(&childrenBuf, buf);
if (virResctrlAllocForeachMemory(resctrl->alloc, if (virResctrlAllocForeachMemory(resctrl->alloc,
virDomainMemorytuneDefFormatHelper, virDomainMemorytuneDefFormatHelper,
&childrenBuf) < 0) &childrenBuf) < 0)
goto cleanup; return -1;
if (!virBufferUse(&childrenBuf)) {
ret = 0; if (!virBufferUse(&childrenBuf))
goto cleanup; return 0;
}
vcpus = virBitmapFormat(resctrl->vcpus); vcpus = virBitmapFormat(resctrl->vcpus);
if (!vcpus) if (!vcpus)
goto cleanup; return -1;
virBufferAsprintf(buf, "<memorytune vcpus='%s'", vcpus); virBufferAsprintf(buf, "<memorytune vcpus='%s'", vcpus);
if (!(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE)) { if (!(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE)) {
const char *alloc_id = virResctrlAllocGetID(resctrl->alloc); const char *alloc_id = virResctrlAllocGetID(resctrl->alloc);
if (!alloc_id) if (!alloc_id)
goto cleanup; return -1;
virBufferAsprintf(buf, " id='%s'", alloc_id); virBufferAsprintf(buf, " id='%s'", alloc_id);
} }
@ -27711,9 +27636,7 @@ virDomainMemorytuneDefFormat(virBufferPtr buf,
virBufferAddBuffer(buf, &childrenBuf); virBufferAddBuffer(buf, &childrenBuf);
virBufferAddLit(buf, "</memorytune>\n"); virBufferAddLit(buf, "</memorytune>\n");
ret = 0; return 0;
cleanup:
return ret;
} }
static int static int
@ -27723,7 +27646,6 @@ virDomainCputuneDefFormat(virBufferPtr buf,
{ {
size_t i; size_t i;
g_auto(virBuffer) childrenBuf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) childrenBuf = VIR_BUFFER_INITIALIZER;
int ret = -1;
virBufferSetChildIndent(&childrenBuf, buf); virBufferSetChildIndent(&childrenBuf, buf);
@ -27771,7 +27693,7 @@ virDomainCputuneDefFormat(virBufferPtr buf,
continue; continue;
if (!(cpumask = virBitmapFormat(vcpu->cpumask))) if (!(cpumask = virBitmapFormat(vcpu->cpumask)))
goto cleanup; return -1;
virBufferAsprintf(&childrenBuf, virBufferAsprintf(&childrenBuf,
"<vcpupin vcpu='%zu' cpuset='%s'/>\n", i, cpumask); "<vcpupin vcpu='%zu' cpuset='%s'/>\n", i, cpumask);
@ -27784,7 +27706,7 @@ virDomainCputuneDefFormat(virBufferPtr buf,
virBufferAddLit(&childrenBuf, "<emulatorpin "); virBufferAddLit(&childrenBuf, "<emulatorpin ");
if (!(cpumask = virBitmapFormat(def->cputune.emulatorpin))) if (!(cpumask = virBitmapFormat(def->cputune.emulatorpin)))
goto cleanup; return -1;
virBufferAsprintf(&childrenBuf, "cpuset='%s'/>\n", cpumask); virBufferAsprintf(&childrenBuf, "cpuset='%s'/>\n", cpumask);
VIR_FREE(cpumask); VIR_FREE(cpumask);
@ -27801,7 +27723,7 @@ virDomainCputuneDefFormat(virBufferPtr buf,
def->iothreadids[i]->iothread_id); def->iothreadids[i]->iothread_id);
if (!(cpumask = virBitmapFormat(def->iothreadids[i]->cpumask))) if (!(cpumask = virBitmapFormat(def->iothreadids[i]->cpumask)))
goto cleanup; return -1;
virBufferAsprintf(&childrenBuf, "cpuset='%s'/>\n", cpumask); virBufferAsprintf(&childrenBuf, "cpuset='%s'/>\n", cpumask);
VIR_FREE(cpumask); VIR_FREE(cpumask);
@ -27836,10 +27758,7 @@ virDomainCputuneDefFormat(virBufferPtr buf,
virBufferAddLit(buf, "</cputune>\n"); virBufferAddLit(buf, "</cputune>\n");
} }
ret = 0; return 0;
cleanup:
return ret;
} }
@ -27910,7 +27829,6 @@ virDomainIOMMUDefFormat(virBufferPtr buf,
g_auto(virBuffer) childBuf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) childBuf = VIR_BUFFER_INITIALIZER;
g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
g_auto(virBuffer) driverAttrBuf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) driverAttrBuf = VIR_BUFFER_INITIALIZER;
int ret = -1;
virBufferSetChildIndent(&childBuf, buf); virBufferSetChildIndent(&childBuf, buf);
@ -27938,9 +27856,7 @@ virDomainIOMMUDefFormat(virBufferPtr buf,
virXMLFormatElement(buf, "iommu", &attrBuf, &childBuf); virXMLFormatElement(buf, "iommu", &attrBuf, &childBuf);
ret = 0; return 0;
return ret;
} }
@ -28014,7 +27930,6 @@ virDomainVsockDefFormat(virBufferPtr buf,
g_auto(virBuffer) childBuf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) childBuf = VIR_BUFFER_INITIALIZER;
g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
g_auto(virBuffer) cidAttrBuf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) cidAttrBuf = VIR_BUFFER_INITIALIZER;
int ret = -1;
if (vsock->model) { if (vsock->model) {
virBufferAsprintf(&attrBuf, " model='%s'", virBufferAsprintf(&attrBuf, " model='%s'",
@ -28032,14 +27947,11 @@ virDomainVsockDefFormat(virBufferPtr buf,
virXMLFormatElement(&childBuf, "cid", &cidAttrBuf, NULL); virXMLFormatElement(&childBuf, "cid", &cidAttrBuf, NULL);
if (virDomainDeviceInfoFormat(&childBuf, &vsock->info, 0) < 0) if (virDomainDeviceInfoFormat(&childBuf, &vsock->info, 0) < 0)
goto cleanup; return -1;
virXMLFormatElement(buf, "vsock", &attrBuf, &childBuf); virXMLFormatElement(buf, "vsock", &attrBuf, &childBuf);
ret = 0; return 0;
cleanup:
return ret;
} }

View File

@ -264,15 +264,11 @@ virNetDevBandwidthFormat(virNetDevBandwidthPtr def,
unsigned int class_id, unsigned int class_id,
virBufferPtr buf) virBufferPtr buf)
{ {
int ret = -1;
if (!buf) if (!buf)
goto cleanup; return -1;
if (!def) { if (!def)
ret = 0; return 0;
goto cleanup;
}
virBufferAddLit(buf, "<bandwidth"); virBufferAddLit(buf, "<bandwidth");
if (class_id) if (class_id)
@ -281,14 +277,11 @@ virNetDevBandwidthFormat(virNetDevBandwidthPtr def,
virBufferAdjustIndent(buf, 2); virBufferAdjustIndent(buf, 2);
if (virNetDevBandwidthRateFormat(def->in, buf, "inbound") < 0 || if (virNetDevBandwidthRateFormat(def->in, buf, "inbound") < 0 ||
virNetDevBandwidthRateFormat(def->out, buf, "outbound") < 0) virNetDevBandwidthRateFormat(def->out, buf, "outbound") < 0)
goto cleanup; return -1;
virBufferAdjustIndent(buf, -2); virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</bandwidth>\n"); virBufferAddLit(buf, "</bandwidth>\n");
ret = 0; return 0;
cleanup:
return ret;
} }
void void

View File

@ -3059,18 +3059,17 @@ virNetworkDefUpdateIPDHCPRange(virNetworkDefPtr def,
unsigned int fflags G_GNUC_UNUSED) unsigned int fflags G_GNUC_UNUSED)
{ {
size_t i; size_t i;
int ret = -1;
virNetworkIPDefPtr ipdef = virNetworkIPDefByIndex(def, parentIndex); virNetworkIPDefPtr ipdef = virNetworkIPDefByIndex(def, parentIndex);
virSocketAddrRange range; virSocketAddrRange range;
memset(&range, 0, sizeof(range)); memset(&range, 0, sizeof(range));
if (virNetworkDefUpdateCheckElementName(def, ctxt->node, "range") < 0) if (virNetworkDefUpdateCheckElementName(def, ctxt->node, "range") < 0)
goto cleanup; return -1;
/* ipdef is the ip element that needs its range array updated */ /* ipdef is the ip element that needs its range array updated */
if (!ipdef) if (!ipdef)
goto cleanup; return -1;
/* parse the xml into a virSocketAddrRange */ /* parse the xml into a virSocketAddrRange */
if (command == VIR_NETWORK_UPDATE_COMMAND_MODIFY) { if (command == VIR_NETWORK_UPDATE_COMMAND_MODIFY) {
@ -3078,18 +3077,18 @@ virNetworkDefUpdateIPDHCPRange(virNetworkDefPtr def,
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("dhcp ranges cannot be modified, " _("dhcp ranges cannot be modified, "
"only added or deleted")); "only added or deleted"));
goto cleanup; return -1;
} }
if (virSocketAddrRangeParseXML(def->name, ipdef, ctxt->node, &range) < 0) if (virSocketAddrRangeParseXML(def->name, ipdef, ctxt->node, &range) < 0)
goto cleanup; return -1;
if (VIR_SOCKET_ADDR_FAMILY(&ipdef->address) if (VIR_SOCKET_ADDR_FAMILY(&ipdef->address)
!= VIR_SOCKET_ADDR_FAMILY(&range.start)) { != VIR_SOCKET_ADDR_FAMILY(&range.start)) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s", virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("the address family of a dhcp range must match " _("the address family of a dhcp range must match "
"the address family of the dhcp element's parent")); "the address family of the dhcp element's parent"));
goto cleanup; return -1;
} }
/* check if an entry with same name/address/ip already exists */ /* 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)) { (command == VIR_NETWORK_UPDATE_COMMAND_ADD_LAST)) {
if (virNetworkDefUpdateCheckMultiDHCP(def, ipdef) < 0) if (virNetworkDefUpdateCheckMultiDHCP(def, ipdef) < 0)
goto cleanup; return -1;
if (i < ipdef->nranges) { if (i < ipdef->nranges) {
char *startip = virSocketAddrFormat(&range.start); char *startip = virSocketAddrFormat(&range.start);
@ -3119,7 +3118,7 @@ virNetworkDefUpdateIPDHCPRange(virNetworkDefPtr def,
endip ? endip : "unknown"); endip ? endip : "unknown");
VIR_FREE(startip); VIR_FREE(startip);
VIR_FREE(endip); VIR_FREE(endip);
goto cleanup; return -1;
} }
/* add to beginning/end of list */ /* add to beginning/end of list */
@ -3127,14 +3126,14 @@ virNetworkDefUpdateIPDHCPRange(virNetworkDefPtr def,
command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST
? 0 : ipdef->nranges, ? 0 : ipdef->nranges,
ipdef->nranges, range) < 0) ipdef->nranges, range) < 0)
goto cleanup; return -1;
} else if (command == VIR_NETWORK_UPDATE_COMMAND_DELETE) { } else if (command == VIR_NETWORK_UPDATE_COMMAND_DELETE) {
if (i == ipdef->nranges) { if (i == ipdef->nranges) {
virReportError(VIR_ERR_OPERATION_INVALID, virReportError(VIR_ERR_OPERATION_INVALID,
_("couldn't locate a matching dhcp range entry " _("couldn't locate a matching dhcp range entry "
"in network '%s'"), def->name); "in network '%s'"), def->name);
goto cleanup; return -1;
} }
/* remove it */ /* remove it */
@ -3143,12 +3142,10 @@ virNetworkDefUpdateIPDHCPRange(virNetworkDefPtr def,
} else { } else {
virNetworkDefUpdateUnknownCommand(command); virNetworkDefUpdateUnknownCommand(command);
goto cleanup; return -1;
} }
ret = 0; return 0;
cleanup:
return ret;
} }

View File

@ -2112,7 +2112,6 @@ virNodeDeviceGetWWNs(virNodeDeviceDefPtr def,
char **wwpn) char **wwpn)
{ {
virNodeDevCapsDefPtr cap = NULL; virNodeDevCapsDefPtr cap = NULL;
int ret = -1;
cap = def->caps; cap = def->caps;
while (cap != NULL) { while (cap != NULL) {
@ -2129,12 +2128,10 @@ virNodeDeviceGetWWNs(virNodeDeviceDefPtr def,
if (cap == NULL) { if (cap == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Device is not a fibre channel HBA")); "%s", _("Device is not a fibre channel HBA"));
goto cleanup; return -1;
} }
ret = 0; return 0;
cleanup:
return ret;
} }
@ -2501,7 +2498,7 @@ virNodeDeviceGetPCISRIOVCaps(const char *sysfsPath,
ret = virPCIGetPhysicalFunction(sysfsPath, ret = virPCIGetPhysicalFunction(sysfsPath,
&pci_dev->physical_function); &pci_dev->physical_function);
if (ret < 0) if (ret < 0)
goto cleanup; return ret;
if (pci_dev->physical_function) if (pci_dev->physical_function)
pci_dev->flags |= VIR_NODE_DEV_CAP_FLAG_PCI_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->num_virtual_functions,
&pci_dev->max_virtual_functions); &pci_dev->max_virtual_functions);
if (ret < 0) if (ret < 0)
goto cleanup; return ret;
if (pci_dev->num_virtual_functions > 0 || if (pci_dev->num_virtual_functions > 0 ||
pci_dev->max_virtual_functions > 0) pci_dev->max_virtual_functions > 0)
pci_dev->flags |= VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION; pci_dev->flags |= VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION;
cleanup:
return ret; return ret;
} }
@ -2525,7 +2521,7 @@ static int
virNodeDeviceGetPCIIOMMUGroupCaps(virNodeDevCapPCIDevPtr pci_dev) virNodeDeviceGetPCIIOMMUGroupCaps(virNodeDevCapPCIDevPtr pci_dev)
{ {
size_t i; size_t i;
int tmpGroup, ret = -1; int tmpGroup;
virPCIDeviceAddress addr; virPCIDeviceAddress addr;
/* this could be a refresh, so clear out the old data */ /* this could be a refresh, so clear out the old data */
@ -2542,23 +2538,19 @@ virNodeDeviceGetPCIIOMMUGroupCaps(virNodeDevCapPCIDevPtr pci_dev)
tmpGroup = virPCIDeviceAddressGetIOMMUGroupNum(&addr); tmpGroup = virPCIDeviceAddressGetIOMMUGroupNum(&addr);
if (tmpGroup == -1) { if (tmpGroup == -1) {
/* error was already reported */ /* error was already reported */
goto cleanup; return -1;
} }
if (tmpGroup == -2) { if (tmpGroup == -2)
/* -2 return means there is no iommu_group data */ /* -2 return means there is no iommu_group data */
ret = 0; return 0;
goto cleanup;
}
if (tmpGroup >= 0) { if (tmpGroup >= 0) {
if (virPCIDeviceAddressGetIOMMUGroupAddresses(&addr, &pci_dev->iommuGroupDevices, if (virPCIDeviceAddressGetIOMMUGroupAddresses(&addr, &pci_dev->iommuGroupDevices,
&pci_dev->nIommuGroupDevices) < 0) &pci_dev->nIommuGroupDevices) < 0)
goto cleanup; return -1;
pci_dev->iommuGroupNumber = tmpGroup; pci_dev->iommuGroupNumber = tmpGroup;
} }
ret = 0; return 0;
cleanup:
return ret;
} }

View File

@ -390,24 +390,22 @@ int virDomainNumatuneGetMode(virDomainNumaPtr numatune,
int cellid, int cellid,
virDomainNumatuneMemMode *mode) virDomainNumatuneMemMode *mode)
{ {
int ret = -1;
virDomainNumatuneMemMode tmp_mode; virDomainNumatuneMemMode tmp_mode;
if (!numatune) if (!numatune)
return ret; return -1;
if (virDomainNumatuneNodeSpecified(numatune, cellid)) if (virDomainNumatuneNodeSpecified(numatune, cellid))
tmp_mode = numatune->mem_nodes[cellid].mode; tmp_mode = numatune->mem_nodes[cellid].mode;
else if (numatune->memory.specified) else if (numatune->memory.specified)
tmp_mode = numatune->memory.mode; tmp_mode = numatune->memory.mode;
else else
goto cleanup; return -1;
if (mode) if (mode)
*mode = tmp_mode; *mode = tmp_mode;
ret = 0;
cleanup: return 0;
return ret;
} }
virBitmapPtr virBitmapPtr
@ -498,8 +496,6 @@ virDomainNumatuneSet(virDomainNumaPtr numa,
int mode, int mode,
virBitmapPtr nodeset) virBitmapPtr nodeset)
{ {
int ret = -1;
/* No need to do anything in this case */ /* No need to do anything in this case */
if (mode == -1 && placement == -1 && !nodeset) if (mode == -1 && placement == -1 && !nodeset)
return 0; return 0;
@ -517,7 +513,7 @@ virDomainNumatuneSet(virDomainNumaPtr numa,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unsupported numatune mode '%d'"), _("Unsupported numatune mode '%d'"),
mode); mode);
goto cleanup; return -1;
} }
if (placement != -1 && if (placement != -1 &&
@ -525,7 +521,7 @@ virDomainNumatuneSet(virDomainNumaPtr numa,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unsupported numatune placement '%d'"), _("Unsupported numatune placement '%d'"),
mode); mode);
goto cleanup; return -1;
} }
if (mode != -1) if (mode != -1)
@ -534,7 +530,7 @@ virDomainNumatuneSet(virDomainNumaPtr numa,
if (nodeset) { if (nodeset) {
virBitmapFree(numa->memory.nodeset); virBitmapFree(numa->memory.nodeset);
if (!(numa->memory.nodeset = virBitmapNewCopy(nodeset))) if (!(numa->memory.nodeset = virBitmapNewCopy(nodeset)))
goto cleanup; return -1;
if (placement == -1) if (placement == -1)
placement = VIR_DOMAIN_NUMATUNE_PLACEMENT_STATIC; placement = VIR_DOMAIN_NUMATUNE_PLACEMENT_STATIC;
} }
@ -551,7 +547,7 @@ virDomainNumatuneSet(virDomainNumaPtr numa,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("nodeset for NUMA memory tuning must be set " _("nodeset for NUMA memory tuning must be set "
"if 'placement' is 'static'")); "if 'placement' is 'static'"));
goto cleanup; return -1;
} }
/* setting nodeset when placement auto is invalid */ /* setting nodeset when placement auto is invalid */
@ -566,10 +562,7 @@ virDomainNumatuneSet(virDomainNumaPtr numa,
numa->memory.specified = true; numa->memory.specified = true;
ret = 0; return 0;
cleanup:
return ret;
} }
static bool static bool

View File

@ -2085,13 +2085,11 @@ virNWFilterIncludeParse(xmlNodePtr cur)
if (!ret->params) if (!ret->params)
goto err_exit; goto err_exit;
cleanup:
return ret; return ret;
err_exit: err_exit:
virNWFilterIncludeDefFree(ret); virNWFilterIncludeDefFree(ret);
ret = NULL; return NULL;
goto cleanup;
} }

View File

@ -343,17 +343,14 @@ int
virStoragePoolOptionsPoolTypeSetXMLNamespace(int type, virStoragePoolOptionsPoolTypeSetXMLNamespace(int type,
virXMLNamespacePtr ns) virXMLNamespacePtr ns)
{ {
int ret = -1;
virStoragePoolTypeInfoPtr backend = virStoragePoolTypeInfoLookup(type); virStoragePoolTypeInfoPtr backend = virStoragePoolTypeInfoLookup(type);
if (!backend) if (!backend)
goto cleanup; return -1;
backend->poolOptions.ns = *ns; backend->poolOptions.ns = *ns;
ret = 0;
cleanup: return 0;
return ret;
} }

View File

@ -766,14 +766,13 @@ virNetworkObjConfigChangeSetup(virNetworkObjPtr obj,
unsigned int flags) unsigned int flags)
{ {
bool isActive; bool isActive;
int ret = -1;
isActive = virNetworkObjIsActive(obj); isActive = virNetworkObjIsActive(obj);
if (!isActive && (flags & VIR_NETWORK_UPDATE_AFFECT_LIVE)) { if (!isActive && (flags & VIR_NETWORK_UPDATE_AFFECT_LIVE)) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s", virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("network is not running")); _("network is not running"));
goto cleanup; return -1;
} }
if (flags & VIR_NETWORK_UPDATE_AFFECT_CONFIG) { if (flags & VIR_NETWORK_UPDATE_AFFECT_CONFIG) {
@ -781,18 +780,16 @@ virNetworkObjConfigChangeSetup(virNetworkObjPtr obj,
virReportError(VIR_ERR_OPERATION_INVALID, "%s", virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot change persistent config of a " _("cannot change persistent config of a "
"transient network")); "transient network"));
goto cleanup; return -1;
} }
/* this should already have been done by the driver, but do it /* this should already have been done by the driver, but do it
* anyway just in case. * anyway just in case.
*/ */
if (isActive && (virNetworkObjSetDefTransient(obj, false, xmlopt) < 0)) if (isActive && (virNetworkObjSetDefTransient(obj, false, xmlopt) < 0))
goto cleanup; return -1;
} }
ret = 0; return 0;
cleanup:
return ret;
} }
@ -1673,10 +1670,9 @@ virNetworkObjLookupPort(virNetworkObjPtr net,
virReportError(VIR_ERR_NO_NETWORK_PORT, virReportError(VIR_ERR_NO_NETWORK_PORT,
_("Network port with UUID %s does not exist"), _("Network port with UUID %s does not exist"),
uuidstr); uuidstr);
goto cleanup; return NULL;
} }
cleanup:
return ret; return ret;
} }

View File

@ -732,14 +732,13 @@ virSecretObjGetValue(virSecretObjPtr obj)
virUUIDFormat(def->uuid, uuidstr); virUUIDFormat(def->uuid, uuidstr);
virReportError(VIR_ERR_NO_SECRET, virReportError(VIR_ERR_NO_SECRET,
_("secret '%s' does not have a value"), uuidstr); _("secret '%s' does not have a value"), uuidstr);
goto cleanup; return NULL;
} }
if (VIR_ALLOC_N(ret, obj->value_size) < 0) if (VIR_ALLOC_N(ret, obj->value_size) < 0)
goto cleanup; return NULL;
memcpy(ret, obj->value, obj->value_size); memcpy(ret, obj->value, obj->value_size);
cleanup:
return ret; return ret;
} }