diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c3dbba6919..1d04cac104 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -24353,13 +24353,14 @@ virDomainControllerDefFormat(virBufferPtr buf, const char *model = NULL; const char *modelName = NULL; virBuffer childBuf = VIR_BUFFER_INITIALIZER; + int ret = -1; virBufferSetChildIndent(&childBuf, buf); if (!type) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected controller type %d"), def->type); - return -1; + goto cleanup; } if (def->model != -1) { @@ -24368,7 +24369,7 @@ virDomainControllerDefFormat(virBufferPtr buf, if (!model) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected model type %d"), def->model); - return -1; + goto cleanup; } } @@ -24432,7 +24433,7 @@ virDomainControllerDefFormat(virBufferPtr buf, virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected model name value %d"), def->opts.pciopts.modelName); - return -1; + goto cleanup; } virBufferAsprintf(&childBuf, "\n", modelName); } @@ -24483,7 +24484,7 @@ virDomainControllerDefFormat(virBufferPtr buf, } if (virBufferCheckError(&childBuf) < 0) - return -1; + goto cleanup; if (virBufferUse(&childBuf)) { virBufferAddLit(buf, ">\n"); @@ -24493,6 +24494,11 @@ virDomainControllerDefFormat(virBufferPtr buf, virBufferAddLit(buf, "/>\n"); } + ret = 0; + + cleanup: + virBufferFreeAndReset(&childBuf); + return 0; } @@ -24523,17 +24529,18 @@ virDomainFSDefFormat(virBufferPtr buf, const char *wrpolicy = virDomainFSWrpolicyTypeToString(def->wrpolicy); const char *src = def->src->path; virBuffer driverBuf = VIR_BUFFER_INITIALIZER; + int ret = -1; if (!type) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected filesystem type %d"), def->type); - return -1; + goto cleanup; } if (!accessmode) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected accessmode %d"), def->accessmode); - return -1; + goto cleanup; } @@ -24557,7 +24564,7 @@ virDomainFSDefFormat(virBufferPtr buf, virDomainVirtioOptionsFormat(&driverBuf, def->virtio); if (virBufferCheckError(&driverBuf) < 0) - return -1; + goto cleanup; if (virBufferUse(&driverBuf)) { virBufferAddLit(buf, "\n"); - return 0; + + ret = 0; + + cleanup: + virBufferFreeAndReset(&driverBuf); + + return ret; } @@ -25847,13 +25860,14 @@ virDomainSoundDefFormat(virBufferPtr buf, const char *model = virDomainSoundModelTypeToString(def->model); virBuffer childBuf = VIR_BUFFER_INITIALIZER; size_t i; + int ret = -1; virBufferSetChildIndent(&childBuf, buf); if (!model) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected sound model %d"), def->model); - return -1; + goto cleanup; } for (i = 0; i < def->ncodecs; i++) @@ -25862,7 +25876,7 @@ virDomainSoundDefFormat(virBufferPtr buf, virDomainDeviceInfoFormat(&childBuf, &def->info, flags); if (virBufferCheckError(&childBuf) < 0) - return -1; + goto cleanup; virBufferAsprintf(buf, "\n"); } + ret = 0; + + cleanup: + virBufferFreeAndReset(&childBuf); + return 0; } @@ -25884,11 +25903,12 @@ virDomainMemballoonDefFormat(virBufferPtr buf, { const char *model = virDomainMemballoonModelTypeToString(def->model); virBuffer childrenBuf = VIR_BUFFER_INITIALIZER; + int ret = -1; if (!model) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected memballoon model %d"), def->model); - return -1; + goto cleanup; } virBufferAsprintf(buf, "virtio); - if (virBufferCheckError(&driverBuf) < 0) { - virBufferFreeAndReset(&childrenBuf); - return -1; - } + if (virBufferCheckError(&driverBuf) < 0) + goto cleanup; + if (virBufferUse(&driverBuf)) { virBufferAddLit(&childrenBuf, "\n"); @@ -25931,6 +25950,11 @@ virDomainMemballoonDefFormat(virBufferPtr buf, virBufferAddLit(buf, "\n"); } + ret = 0; + + cleanup: + virBufferFreeAndReset(&childrenBuf); + return 0; } @@ -25958,25 +25982,26 @@ virDomainWatchdogDefFormat(virBufferPtr buf, const char *model = virDomainWatchdogModelTypeToString(def->model); const char *action = virDomainWatchdogActionTypeToString(def->action); virBuffer childBuf = VIR_BUFFER_INITIALIZER; + int ret = -1; virBufferSetChildIndent(&childBuf, buf); if (!model) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected watchdog model %d"), def->model); - return -1; + goto cleanup; } if (!action) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected watchdog action %d"), def->action); - return -1; + goto cleanup; } virDomainDeviceInfoFormat(&childBuf, &def->info, flags); if (virBufferCheckError(&childBuf) < 0) - return -1; + goto cleanup; virBufferAsprintf(buf, "\n"); } - return 0; + ret = 0; + + cleanup: + virBufferFreeAndReset(&childBuf); + + return ret; } static int virDomainPanicDefFormat(virBufferPtr buf, virDomainPanicDefPtr def) { virBuffer childrenBuf = VIR_BUFFER_INITIALIZER; + int ret = -1; virBufferAddLit(buf, "info, 0); if (virBufferCheckError(&childrenBuf) < 0) - return -1; + goto cleanup; if (virBufferUse(&childrenBuf)) { virBufferAddLit(buf, ">\n"); @@ -26016,8 +26047,13 @@ static int virDomainPanicDefFormat(virBufferPtr buf, } else { virBufferAddLit(buf, "/>\n"); } + + ret = 0; + + cleanup: virBufferFreeAndReset(&childrenBuf); - return 0; + + return ret; } static int @@ -26067,6 +26103,7 @@ virDomainRNGDefFormat(virBufferPtr buf, const char *model = virDomainRNGModelTypeToString(def->model); const char *backend = virDomainRNGBackendTypeToString(def->backend); virBuffer driverBuf = VIR_BUFFER_INITIALIZER; + int ret = -1; virBufferAsprintf(buf, "\n", model); virBufferAdjustIndent(buf, 2); @@ -26085,11 +26122,11 @@ virDomainRNGDefFormat(virBufferPtr buf, case VIR_DOMAIN_RNG_BACKEND_EGD: if (virDomainChrAttrsDefFormat(buf, def->source.chardev, false) < 0) - return -1; + goto cleanup; virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); if (virDomainChrSourceDefFormat(buf, def->source.chardev, flags) < 0) - return -1; + goto cleanup; virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); @@ -26099,7 +26136,7 @@ virDomainRNGDefFormat(virBufferPtr buf, virDomainVirtioOptionsFormat(&driverBuf, def->virtio); if (virBufferCheckError(&driverBuf) < 0) - return -1; + goto cleanup; if (virBufferUse(&driverBuf)) { virBufferAddLit(buf, "\n"); - return 0; + + ret = 0; + + cleanup: + virBufferFreeAndReset(&driverBuf); + + return ret; } void @@ -26258,18 +26301,19 @@ virDomainVideoDefFormat(virBufferPtr buf, { const char *model = virDomainVideoTypeToString(def->type); virBuffer driverBuf = VIR_BUFFER_INITIALIZER; + int ret = -1; if (!model) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected video model %d"), def->type); - return -1; + goto cleanup; } virBufferAddLit(buf, "