Use virBufferCheckError everywhere we report OOM error

Replace:
if (virBufferError(&buf)) {
    virBufferFreeAndReset(&buf);
    virReportOOMError();
    ...
}

with:
if (virBufferCheckError(&buf) < 0)
    ...

This should not be a functional change (unless some callers
misused the virBuffer APIs - a different error would be reported
then)
This commit is contained in:
Ján Tomko 2014-06-27 10:40:15 +02:00
parent 28b9be2481
commit 92a8e72f9d
51 changed files with 158 additions and 456 deletions

View File

@ -258,10 +258,8 @@ bhyveConnectGetSysinfo(virConnectPtr conn, unsigned int flags)
if (virSysinfoFormat(&buf, privconn->hostsysinfo) < 0)
return NULL;
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
return NULL;
}
return virBufferContentAndReset(&buf);
}
@ -701,10 +699,8 @@ bhyveConnectDomainXMLToNative(virConnectPtr conn,
virBufferAddChar(&buf, '\n');
virBufferAdd(&buf, virCommandToString(cmd), -1);
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto cleanup;
}
ret = virBufferContentAndReset(&buf);

View File

@ -494,13 +494,11 @@ virCPUDefFormat(virCPUDefPtr def,
if (virCPUDefFormatBufFull(&buf, def, flags) < 0)
goto cleanup;
if (virBufferError(&buf))
goto no_memory;
if (virBufferCheckError(&buf) < 0)
goto cleanup;
return virBufferContentAndReset(&buf);
no_memory:
virReportOOMError();
cleanup:
virBufferFreeAndReset(&buf);
return NULL;

View File

@ -11335,11 +11335,8 @@ virDomainDefParseXML(xmlDocPtr xml,
}
}
if (virBufferError(&buffer)) {
virReportOOMError();
virBufferFreeAndReset(&buffer);
if (virBufferCheckError(&buffer) < 0)
goto error;
}
string = virBufferContentAndReset(&buffer);
@ -17972,13 +17969,11 @@ virDomainDefFormatInternal(virDomainDefPtr def,
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</domain>\n");
if (virBufferError(buf))
goto no_memory;
if (virBufferCheckError(buf) < 0)
goto error;
return 0;
no_memory:
virReportOOMError();
error:
virBufferFreeAndReset(buf);
return -1;
@ -18030,13 +18025,11 @@ virDomainObjFormat(virDomainXMLOptionPtr xmlopt,
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</domstatus>\n");
if (virBufferError(&buf))
goto no_memory;
if (virBufferCheckError(&buf) < 0)
goto error;
return virBufferContentAndReset(&buf);
no_memory:
virReportOOMError();
error:
virBufferFreeAndReset(&buf);
return NULL;

View File

@ -1101,11 +1101,11 @@ virInterfaceDefDevFormat(virBufferPtr buf, const virInterfaceDef *def,
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</interface>\n");
if (virBufferError(buf))
goto no_memory;
if (virBufferCheckError(buf) < 0)
goto cleanup;
return 0;
no_memory:
virReportOOMError();
cleanup:
return -1;
}

View File

@ -2830,13 +2830,11 @@ virNetworkDefFormat(const virNetworkDef *def,
if (virNetworkDefFormatBuf(&buf, def, flags) < 0)
goto error;
if (virBufferError(&buf))
goto no_memory;
if (virBufferCheckError(&buf) < 0)
goto error;
return virBufferContentAndReset(&buf);
no_memory:
virReportOOMError();
error:
virBufferFreeAndReset(&buf);
return NULL;
@ -2871,13 +2869,11 @@ virNetworkObjFormat(virNetworkObjPtr net,
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</networkstatus>");
if (virBufferError(&buf))
goto no_memory;
if (virBufferCheckError(&buf) < 0)
goto error;
return virBufferContentAndReset(&buf);
no_memory:
virReportOOMError();
error:
virBufferFreeAndReset(&buf);
return NULL;

View File

@ -555,15 +555,10 @@ char *virNodeDeviceDefFormat(const virNodeDeviceDef *def)
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</device>\n");
if (virBufferError(&buf))
goto no_memory;
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
no_memory:
virReportOOMError();
virBufferFreeAndReset(&buf);
return NULL;
}
/**

View File

@ -967,10 +967,8 @@ virNWFilterPrintTCPFlags(uint8_t flags)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
printTCPFlags(&buf, flags);
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
return NULL;
}
return virBufferContentAndReset(&buf);
}
@ -2548,11 +2546,8 @@ virNWFilterIsAllowedChain(const char *chainname)
printed = true;
}
if (virBufferError(&buf)) {
virReportOOMError();
virBufferFreeAndReset(&buf);
if (virBufferCheckError(&buf) < 0)
goto err_exit;
}
msg = virBufferContentAndReset(&buf);
@ -3484,14 +3479,11 @@ virNWFilterDefFormat(const virNWFilterDef *def)
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</filter>\n");
if (virBufferError(&buf))
goto no_memory;
if (virBufferCheckError(&buf) < 0)
goto err_exit;
return virBufferContentAndReset(&buf);
no_memory:
virReportOOMError();
err_exit:
virBufferFreeAndReset(&buf);
return NULL;

View File

@ -318,13 +318,11 @@ virSecretDefFormat(const virSecretDef *def)
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</secret>\n");
if (virBufferError(&buf))
goto no_memory;
if (virBufferCheckError(&buf) < 0)
goto error;
return virBufferContentAndReset(&buf);
no_memory:
virReportOOMError();
error:
virBufferFreeAndReset(&buf);
return NULL;

View File

@ -705,11 +705,8 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid,
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</domainsnapshot>\n");
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
return NULL;
}
return virBufferContentAndReset(&buf);
}

View File

@ -1239,13 +1239,11 @@ virStoragePoolDefFormat(virStoragePoolDefPtr def)
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</pool>\n");
if (virBufferError(&buf))
goto no_memory;
if (virBufferCheckError(&buf) < 0)
goto cleanup;
return virBufferContentAndReset(&buf);
no_memory:
virReportOOMError();
cleanup:
virBufferFreeAndReset(&buf);
return NULL;
@ -1662,13 +1660,11 @@ virStorageVolDefFormat(virStoragePoolDefPtr pool,
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</volume>\n");
if (virBufferError(&buf))
goto no_memory;
if (virBufferCheckError(&buf) < 0)
goto cleanup;
return virBufferContentAndReset(&buf);
no_memory:
virReportOOMError();
cleanup:
virBufferFreeAndReset(&buf);
return NULL;
@ -2013,13 +2009,11 @@ virStoragePoolSourceListFormat(virStoragePoolSourceListPtr def)
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</sources>\n");
if (virBufferError(&buf))
goto no_memory;
if (virBufferCheckError(&buf) < 0)
goto cleanup;
return virBufferContentAndReset(&buf);
no_memory:
virReportOOMError();
cleanup:
virBufferFreeAndReset(&buf);
return NULL;

View File

@ -112,12 +112,14 @@ int cpuMapLoad(const char *arch,
goto cleanup;
}
if ((ctxt = xmlXPathNewContext(xml)) == NULL)
goto no_memory;
if ((ctxt = xmlXPathNewContext(xml)) == NULL) {
virReportOOMError();
goto cleanup;
}
virBufferAsprintf(&buf, "./arch[@name='%s']", arch);
if (virBufferError(&buf))
goto no_memory;
if (virBufferCheckError(&buf) < 0)
goto cleanup;
xpath = virBufferContentAndReset(&buf);
@ -146,8 +148,4 @@ int cpuMapLoad(const char *arch,
VIR_FREE(mapfile);
return ret;
no_memory:
virReportOOMError();
goto cleanup;
}

View File

@ -1221,11 +1221,8 @@ x86CPUDataFormat(const virCPUData *data)
}
virBufferAddLit(&buf, "</cpudata>\n");
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
return NULL;
}
return virBufferContentAndReset(&buf);
}

View File

@ -340,10 +340,8 @@ esxFormatVMXFileName(const char *fileName, void *opaque)
virBufferAddChar(&buffer, separator);
virBufferAdd(&buffer, directoryAndFileName, -1);
if (virBufferError(&buffer)) {
virReportOOMError();
if (virBufferCheckError(&buffer) < 0)
goto cleanup;
}
result = virBufferContentAndReset(&buffer);
} else if (*fileName == '/') {
@ -2701,10 +2699,8 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
virBufferAddLit(&buffer, "&dsName=");
virBufferURIEncodeString(&buffer, datastoreName);
if (virBufferError(&buffer)) {
virReportOOMError();
if (virBufferCheckError(&buffer) < 0)
goto cleanup;
}
url = virBufferContentAndReset(&buffer);
@ -3169,10 +3165,8 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml)
virBufferAddLit(&buffer, "&dsName=");
virBufferURIEncodeString(&buffer, datastoreName);
if (virBufferError(&buffer)) {
virReportOOMError();
if (virBufferCheckError(&buffer) < 0)
goto cleanup;
}
url = virBufferContentAndReset(&buffer);

View File

@ -425,12 +425,8 @@ esxUtil_EscapeBase64(const char *string)
}
}
if (virBufferError(&buffer)) {
virReportOOMError();
virBufferFreeAndReset(&buffer);
if (virBufferCheckError(&buffer) < 0)
return NULL;
}
return virBufferContentAndReset(&buffer);
}
@ -498,12 +494,8 @@ esxUtil_EscapeForXml(const char *string)
virBufferEscapeString(&buffer, "%s", string);
if (virBufferError(&buffer)) {
virReportOOMError();
virBufferFreeAndReset(&buffer);
if (virBufferCheckError(&buffer) < 0)
return NULL;
}
return virBufferContentAndReset(&buffer);
}

View File

@ -426,10 +426,8 @@ esxVI_CURL_Download(esxVI_CURL *curl, const char *url, char **content,
goto cleanup;
}
if (virBufferError(&buffer)) {
virReportOOMError();
if (virBufferCheckError(&buffer) < 0)
goto cleanup;
}
if (length) {
*length = virBufferUse(&buffer);
@ -1046,10 +1044,8 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const char *path)
goto cleanup;
}
if (virBufferError(&buffer)) {
virReportOOMError();
if (virBufferCheckError(&buffer) < 0)
goto cleanup;
}
ctx->datacenterPath = virBufferContentAndReset(&buffer);
@ -1116,10 +1112,8 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const char *path)
goto cleanup;
}
if (virBufferError(&buffer)) {
virReportOOMError();
if (virBufferCheckError(&buffer) < 0)
goto cleanup;
}
ctx->computeResourcePath = virBufferContentAndReset(&buffer);
@ -1259,10 +1253,8 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName,
goto cleanup;
}
if (virBufferError(&buffer)) {
virReportOOMError();
if (virBufferCheckError(&buffer) < 0)
goto cleanup;
}
(*response)->content = virBufferContentAndReset(&buffer);
@ -4243,10 +4235,8 @@ esxVI_HandleVirtualMachineQuestion
++answerIndex;
}
if (virBufferError(&buffer)) {
virReportOOMError();
if (virBufferCheckError(&buffer) < 0)
goto cleanup;
}
possibleAnswers = virBufferContentAndReset(&buffer);
}

View File

@ -126,10 +126,8 @@
virBufferAddLit(&buffer, "</"#_name">"); \
virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER); \
\
if (virBufferError(&buffer)) { \
virReportOOMError(); \
if (virBufferCheckError(&buffer) < 0) \
goto cleanup; \
} \
\
request = virBufferContentAndReset(&buffer); \
\

View File

@ -128,10 +128,8 @@ hypervEnumAndPull(hypervPrivate *priv, virBufferPtr query, const char *root,
return -1;
}
if (virBufferError(query)) {
virReportOOMError();
if (virBufferCheckError(query) < 0)
return -1;
}
serializerContext = wsmc_get_serialization_context(priv->client);

View File

@ -544,10 +544,8 @@ libxlConnectGetSysinfo(virConnectPtr conn, unsigned int flags)
if (virSysinfoFormat(&buf, driver->hostsysinfo) < 0)
return NULL;
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
return NULL;
}
return virBufferContentAndReset(&buf);
}

View File

@ -819,11 +819,8 @@ virLockManagerSanlockRegisterKillscript(int sock,
virBufferEscape(&buf, '\\', "\\ ", "%s",
virDomainLockFailureTypeToString(action));
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto cleanup;
}
/* Unfortunately, sanlock_killpath() does not use const for either
* path or args even though it will just copy them into its own

View File

@ -1181,8 +1181,8 @@ virLXCControllerSetupUsernsMap(virDomainIdMapEntryPtr map,
virBufferAsprintf(&map_value, "%u %u %u\n",
map[i].start, map[i].target, map[i].count);
if (virBufferError(&map_value))
goto no_memory;
if (virBufferCheckError(&map_value) < 0)
goto cleanup;
VIR_DEBUG("Set '%s' to '%s'", path, virBufferCurrentContent(&map_value));
@ -1195,10 +1195,6 @@ virLXCControllerSetupUsernsMap(virDomainIdMapEntryPtr map,
cleanup:
virBufferFreeAndReset(&map_value);
return ret;
no_memory:
virReportOOMError();
goto cleanup;
}
/**

View File

@ -2749,10 +2749,8 @@ lxcDomainGetBlkioParameters(virDomainPtr dom,
vm->def->blkio.devices[j].path,
vm->def->blkio.devices[j].weight);
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto cleanup;
}
param->value.s = virBufferContentAndReset(&buf);
}
if (virTypedParameterAssign(param,
@ -2778,10 +2776,8 @@ lxcDomainGetBlkioParameters(virDomainPtr dom,
vm->def->blkio.devices[j].path,
vm->def->blkio.devices[j].riops);
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto cleanup;
}
param->value.s = virBufferContentAndReset(&buf);
}
if (virTypedParameterAssign(param,
@ -2807,10 +2803,8 @@ lxcDomainGetBlkioParameters(virDomainPtr dom,
vm->def->blkio.devices[j].path,
vm->def->blkio.devices[j].wiops);
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto cleanup;
}
param->value.s = virBufferContentAndReset(&buf);
}
if (virTypedParameterAssign(param,
@ -2836,10 +2830,8 @@ lxcDomainGetBlkioParameters(virDomainPtr dom,
vm->def->blkio.devices[j].path,
vm->def->blkio.devices[j].rbps);
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto cleanup;
}
param->value.s = virBufferContentAndReset(&buf);
}
if (virTypedParameterAssign(param,
@ -2865,10 +2857,8 @@ lxcDomainGetBlkioParameters(virDomainPtr dom,
vm->def->blkio.devices[j].path,
vm->def->blkio.devices[j].wbps);
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto cleanup;
}
param->value.s = virBufferContentAndReset(&buf);
}
if (virTypedParameterAssign(param,
@ -2913,10 +2903,8 @@ lxcDomainGetBlkioParameters(virDomainPtr dom,
persistentDef->blkio.devices[j].path,
persistentDef->blkio.devices[j].weight);
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto cleanup;
}
param->value.s = virBufferContentAndReset(&buf);
}
if (!param->value.s && VIR_STRDUP(param->value.s, "") < 0)
@ -2947,10 +2935,8 @@ lxcDomainGetBlkioParameters(virDomainPtr dom,
persistentDef->blkio.devices[j].path,
persistentDef->blkio.devices[j].riops);
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto cleanup;
}
param->value.s = virBufferContentAndReset(&buf);
}
if (!param->value.s && VIR_STRDUP(param->value.s, "") < 0)
@ -2980,10 +2966,8 @@ lxcDomainGetBlkioParameters(virDomainPtr dom,
persistentDef->blkio.devices[j].path,
persistentDef->blkio.devices[j].wiops);
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto cleanup;
}
param->value.s = virBufferContentAndReset(&buf);
}
if (!param->value.s && VIR_STRDUP(param->value.s, "") < 0)
@ -3013,10 +2997,8 @@ lxcDomainGetBlkioParameters(virDomainPtr dom,
persistentDef->blkio.devices[j].path,
persistentDef->blkio.devices[j].rbps);
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto cleanup;
}
param->value.s = virBufferContentAndReset(&buf);
}
if (!param->value.s && VIR_STRDUP(param->value.s, "") < 0)
@ -3047,10 +3029,8 @@ lxcDomainGetBlkioParameters(virDomainPtr dom,
persistentDef->blkio.devices[j].path,
persistentDef->blkio.devices[j].wbps);
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto cleanup;
}
param->value.s = virBufferContentAndReset(&buf);
}
if (!param->value.s && VIR_STRDUP(param->value.s, "") < 0)
@ -5374,10 +5354,8 @@ lxcConnectGetSysinfo(virConnectPtr conn, unsigned int flags)
if (virSysinfoFormat(&buf, driver->hostsysinfo) < 0)
return NULL;
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
return NULL;
}
return virBufferContentAndReset(&buf);
}

View File

@ -180,10 +180,10 @@ networkRunHook(virNetworkObjPtr network,
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</hookData>");
if (virBufferError(&buf) ||
!(xml = virBufferContentAndReset(&buf)))
if (virBufferCheckError(&buf) < 0)
goto cleanup;
xml = virBufferContentAndReset(&buf);
hookret = virHookCall(VIR_HOOK_DRIVER_NETWORK, network->def->name,
op, sub_op, NULL, xml, NULL);
@ -1537,10 +1537,8 @@ networkRadvdConfContents(virNetworkObjPtr network, char **configstr)
virBufferAddLit(&configbuf, "};\n");
if (virBufferError(&configbuf)) {
virReportOOMError();
if (virBufferCheckError(&configbuf) < 0)
goto cleanup;
}
*configstr = virBufferContentAndReset(&configbuf);

View File

@ -333,12 +333,8 @@ static int udevGenerateDeviceName(struct udev_device *device,
virBufferAsprintf(&buf, "_%s", s);
}
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
VIR_ERROR(_("Buffer error when generating device name for device "
"with sysname '%s'"), udev_device_get_sysname(device));
ret = -1;
}
if (virBufferCheckError(&buf) < 0)
return -1;
def->name = virBufferContentAndReset(&buf);

View File

@ -306,11 +306,8 @@ _printDataType(virNWFilterVarCombIterPtr vars,
}
}
if (virBufferError(&vb)) {
virReportOOMError();
virBufferFreeAndReset(&vb);
if (virBufferCheckError(&vb) < 0)
return -1;
}
flags = virBufferContentAndReset(&vb);
@ -1560,11 +1557,8 @@ printStateMatchFlags(int32_t flags, char **bufptr)
"",
flags,
false);
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
return -1;
}
*bufptr = virBufferContentAndReset(&buf);
return 0;
}

View File

@ -259,11 +259,8 @@ virNWFilterPrintVars(virHashTablePtr vars,
virHashForEach(vars, printString, &ps);
if (virBufferError(&ps.buf)) {
virBufferFreeAndReset(&ps.buf);
virReportOOMError();
if (virBufferCheckError(&ps.buf) < 0)
return NULL;
}
return virBufferContentAndReset(&ps.buf);
}

View File

@ -186,11 +186,8 @@ phypExec(LIBSSH2_SESSION *session, const char *cmd, int *exit_status,
channel = NULL;
VIR_FREE(buffer);
if (virBufferError(&tex_ret)) {
virBufferFreeAndReset(&tex_ret);
virReportOOMError();
if (virBufferCheckError(&tex_ret) < 0)
return NULL;
}
return virBufferContentAndReset(&tex_ret);
err:
@ -211,11 +208,8 @@ phypExecBuffer(LIBSSH2_SESSION *session, virBufferPtr buf, int *exit_status,
char *cmd;
char *ret;
if (virBufferError(buf)) {
virBufferFreeAndReset(buf);
virReportOOMError();
if (virBufferCheckError(buf) < 0)
return NULL;
}
cmd = virBufferContentAndReset(buf);
ret = phypExec(session, cmd, exit_status, conn);
VIR_FREE(cmd);

View File

@ -2962,10 +2962,8 @@ qemuBuildNetworkDriveURI(int protocol,
if (src)
virBufferAsprintf(&buf, ":exportname=%s", src);
if (virBufferError(&buf) < 0) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto cleanup;
}
ret = virBufferContentAndReset(&buf);
goto cleanup;
@ -3098,10 +3096,8 @@ qemuBuildNetworkDriveURI(int protocol,
}
}
if (virBufferError(&buf) < 0) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto cleanup;
}
ret = virBufferContentAndReset(&buf);
break;
@ -3557,10 +3553,8 @@ qemuBuildDriveStr(virConnectPtr conn,
disk->blkdeviotune.write_iops_sec);
}
if (virBufferError(&opt)) {
virReportOOMError();
if (virBufferCheckError(&opt) < 0)
goto error;
}
return virBufferContentAndReset(&opt);
@ -3899,10 +3893,8 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
}
}
if (virBufferError(&opt)) {
virReportOOMError();
if (virBufferCheckError(&opt) < 0)
goto error;
}
return virBufferContentAndReset(&opt);
@ -3975,10 +3967,8 @@ char *qemuBuildFSStr(virDomainFSDefPtr fs,
}
}
if (virBufferError(&opt)) {
virReportOOMError();
if (virBufferCheckError(&opt) < 0)
goto error;
}
return virBufferContentAndReset(&opt);
@ -4009,10 +3999,8 @@ qemuBuildFSDevStr(virDomainDefPtr def,
if (qemuBuildDeviceAddressStr(&opt, def, &fs->info, qemuCaps) < 0)
goto error;
if (virBufferError(&opt)) {
virReportOOMError();
if (virBufferCheckError(&opt) < 0)
goto error;
}
return virBufferContentAndReset(&opt);
@ -4252,10 +4240,8 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef,
if (qemuBuildDeviceAddressStr(&buf, domainDef, &def->info, qemuCaps) < 0)
goto error;
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto error;
}
return virBufferContentAndReset(&buf);
@ -4365,10 +4351,8 @@ qemuBuildNicDevStr(virDomainDefPtr def,
if (bootindex && virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX))
virBufferAsprintf(&buf, ",bootindex=%d", bootindex);
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto error;
}
return virBufferContentAndReset(&buf);
@ -4502,11 +4486,8 @@ qemuBuildHostNetStr(virDomainNetDefPtr net,
virObjectUnref(cfg);
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
return NULL;
}
return virBufferContentAndReset(&buf);
}
@ -4530,10 +4511,8 @@ qemuBuildWatchdogDevStr(virDomainDefPtr def,
if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
goto error;
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto error;
}
return virBufferContentAndReset(&buf);
@ -4571,10 +4550,8 @@ qemuBuildMemballoonDevStr(virDomainDefPtr def,
if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
goto error;
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto error;
}
return virBufferContentAndReset(&buf);
@ -4598,10 +4575,8 @@ qemuBuildNVRAMDevStr(virDomainNVRAMDefPtr dev)
goto error;
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto error;
}
return virBufferContentAndReset(&buf);
@ -4634,10 +4609,8 @@ qemuBuildUSBInputDevStr(virDomainDefPtr def,
if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
goto error;
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto error;
}
return virBufferContentAndReset(&buf);
@ -4687,10 +4660,8 @@ qemuBuildSoundDevStr(virDomainDefPtr def,
if (qemuBuildDeviceAddressStr(&buf, def, &sound->info, qemuCaps) < 0)
goto error;
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto error;
}
return virBufferContentAndReset(&buf);
@ -4802,10 +4773,8 @@ qemuBuildDeviceVideoStr(virDomainDefPtr def,
if (qemuBuildDeviceAddressStr(&buf, def, &video->info, qemuCaps) < 0)
goto error;
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto error;
}
return virBufferContentAndReset(&buf);
@ -4889,10 +4858,8 @@ qemuBuildPCIHostdevDevStr(virDomainDefPtr def,
if (qemuBuildRomStr(&buf, dev->info, qemuCaps) < 0)
goto error;
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto error;
}
return virBufferContentAndReset(&buf);
@ -5010,10 +4977,8 @@ qemuBuildRedirdevDevStr(virDomainDefPtr def,
if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
goto error;
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto error;
}
return virBufferContentAndReset(&buf);
@ -5050,10 +5015,8 @@ qemuBuildUSBHostdevDevStr(virDomainDefPtr def,
if (qemuBuildDeviceAddressStr(&buf, def, dev->info, qemuCaps) < 0)
goto error;
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto error;
}
return virBufferContentAndReset(&buf);
@ -5088,10 +5051,8 @@ qemuBuildHubDevStr(virDomainDefPtr def,
if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
goto error;
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto error;
}
return virBufferContentAndReset(&buf);
@ -5157,10 +5118,8 @@ qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev,
}
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto error;
}
VIR_FREE(sg);
return virBufferContentAndReset(&buf);
@ -5222,10 +5181,8 @@ qemuBuildSCSIHostdevDevStr(virDomainDefPtr def,
if (dev->info->bootIndex)
virBufferAsprintf(&buf, ",bootindex=%d", dev->info->bootIndex);
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto error;
}
return virBufferContentAndReset(&buf);
error:
@ -5342,10 +5299,8 @@ qemuBuildChrChardevStr(virDomainChrSourceDefPtr dev, const char *alias,
goto error;
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto error;
}
return virBufferContentAndReset(&buf);
@ -5438,10 +5393,8 @@ qemuBuildChrArgStr(virDomainChrSourceDefPtr dev, const char *prefix)
break;
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto error;
}
return virBufferContentAndReset(&buf);
@ -5518,10 +5471,8 @@ qemuBuildVirtioSerialPortDevStr(virDomainChrDefPtr dev,
} else {
virBufferAsprintf(&buf, ",id=%s", dev->info.alias);
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto error;
}
return virBufferContentAndReset(&buf);
@ -5550,10 +5501,8 @@ qemuBuildSclpDevStr(virDomainChrDefPtr dev)
}
virBufferAsprintf(&buf, ",chardev=char%s,id=%s",
dev->info.alias, dev->info.alias);
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto error;
}
return virBufferContentAndReset(&buf);
@ -5703,10 +5652,8 @@ static char *qemuBuildTPMBackendStr(const virDomainDef *def,
goto error;
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto error;
}
return virBufferContentAndReset(&buf);
@ -5741,10 +5688,8 @@ static char *qemuBuildTPMDevStr(const virDomainDef *def,
virBufferAsprintf(&buf, "%s,tpmdev=tpm-%s,id=%s",
model, tpm->info.alias, tpm->info.alias);
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto error;
}
return virBufferContentAndReset(&buf);
@ -5777,10 +5722,8 @@ static char *qemuBuildSmbiosBiosStr(virSysinfoDefPtr def)
if (def->bios_release)
virBufferAsprintf(&buf, ",release=%s", def->bios_release);
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto error;
}
return virBufferContentAndReset(&buf);
@ -5824,10 +5767,8 @@ static char *qemuBuildSmbiosSystemStr(virSysinfoDefPtr def, bool skip_uuid)
if (def->system_family)
virBufferAsprintf(&buf, ",family=%s", def->system_family);
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto error;
}
return virBufferContentAndReset(&buf);
@ -5944,10 +5885,8 @@ qemuBuildClockArgStr(virDomainClockDefPtr def)
}
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto error;
}
return virBufferContentAndReset(&buf);
@ -6185,10 +6124,8 @@ qemuBuildCpuArgStr(virQEMUDriverPtr driver,
}
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto cleanup;
}
*opt = virBufferContentAndReset(&buf);
@ -6390,11 +6327,8 @@ qemuBuildSmpArgStr(const virDomainDef *def,
return NULL;
}
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
return NULL;
}
return virBufferContentAndReset(&buf);
}
@ -6432,10 +6366,8 @@ qemuBuildNumaArgStr(const virDomainDef *def, virCommandPtr cmd)
1024) * 1024;
virBufferAsprintf(&buf, ",mem=%d", def->cpu->cells[i].mem / 1024);
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto cleanup;
}
virCommandAddArgBuffer(cmd, &buf);
}
@ -7690,10 +7622,8 @@ qemuBuildCommandLine(virConnectPtr conn,
if (boot_nparams > 0) {
virCommandAddArg(cmd, "-boot");
if (virBufferError(&boot_buf)) {
virReportOOMError();
if (virBufferCheckError(&boot_buf) < 0)
goto error;
}
if (boot_nparams < 2 || emitBootindex) {
virCommandAddArgBuffer(cmd, &boot_buf);
@ -9167,10 +9097,8 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
}
}
if (virBufferError(&cmd)) {
virReportOOMError();
if (virBufferCheckError(&cmd) < 0)
goto error;
}
*deviceStr = virBufferContentAndReset(&cmd);
return 0;

View File

@ -1203,10 +1203,8 @@ qemuConnectGetSysinfo(virConnectPtr conn, unsigned int flags)
if (virSysinfoFormat(&buf, driver->hostsysinfo) < 0)
return NULL;
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
return NULL;
}
return virBufferContentAndReset(&buf);
}
@ -8005,10 +8003,8 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
vm->def->blkio.devices[j].path,
vm->def->blkio.devices[j].weight);
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto cleanup;
}
param->value.s = virBufferContentAndReset(&buf);
}
if (virTypedParameterAssign(param,
@ -8034,10 +8030,8 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
vm->def->blkio.devices[j].path,
vm->def->blkio.devices[j].riops);
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto cleanup;
}
param->value.s = virBufferContentAndReset(&buf);
}
if (virTypedParameterAssign(param,
@ -8063,10 +8057,8 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
vm->def->blkio.devices[j].path,
vm->def->blkio.devices[j].wiops);
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto cleanup;
}
param->value.s = virBufferContentAndReset(&buf);
}
if (virTypedParameterAssign(param,
@ -8092,10 +8084,8 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
vm->def->blkio.devices[j].path,
vm->def->blkio.devices[j].rbps);
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto cleanup;
}
param->value.s = virBufferContentAndReset(&buf);
}
if (virTypedParameterAssign(param,
@ -8121,10 +8111,8 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
vm->def->blkio.devices[j].path,
vm->def->blkio.devices[j].wbps);
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto cleanup;
}
param->value.s = virBufferContentAndReset(&buf);
}
if (virTypedParameterAssign(param,
@ -8173,10 +8161,8 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
persistentDef->blkio.devices[j].path,
persistentDef->blkio.devices[j].weight);
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto cleanup;
}
param->value.s = virBufferContentAndReset(&buf);
}
if (!param->value.s && VIR_STRDUP(param->value.s, "") < 0)
@ -8207,10 +8193,8 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
persistentDef->blkio.devices[j].path,
persistentDef->blkio.devices[j].riops);
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto cleanup;
}
param->value.s = virBufferContentAndReset(&buf);
}
if (!param->value.s && VIR_STRDUP(param->value.s, "") < 0)
@ -8240,10 +8224,8 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
persistentDef->blkio.devices[j].path,
persistentDef->blkio.devices[j].wiops);
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto cleanup;
}
param->value.s = virBufferContentAndReset(&buf);
}
if (!param->value.s && VIR_STRDUP(param->value.s, "") < 0)
@ -8273,10 +8255,8 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
persistentDef->blkio.devices[j].path,
persistentDef->blkio.devices[j].rbps);
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto cleanup;
}
param->value.s = virBufferContentAndReset(&buf);
}
if (!param->value.s && VIR_STRDUP(param->value.s, "") < 0)
@ -8307,10 +8287,8 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
persistentDef->blkio.devices[j].path,
persistentDef->blkio.devices[j].wbps);
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto cleanup;
}
param->value.s = virBufferContentAndReset(&buf);
}
if (!param->value.s && VIR_STRDUP(param->value.s, "") < 0)

View File

@ -666,11 +666,8 @@ static char *qemuMigrationCookieXMLFormatStr(virQEMUDriverPtr driver,
return NULL;
}
if (virBufferError(&buf)) {
virReportOOMError();
virBufferFreeAndReset(&buf);
if (virBufferCheckError(&buf) < 0)
return NULL;
}
return virBufferContentAndReset(&buf);
}

View File

@ -2297,11 +2297,8 @@ int qemuMonitorMigrateToFile(qemuMonitorPtr mon,
/* Migrate to file */
virBufferEscapeShell(&buf, target);
if (virBufferError(&buf)) {
virReportOOMError();
virBufferFreeAndReset(&buf);
if (virBufferCheckError(&buf) < 0)
goto cleanup;
}
safe_target = virBufferContentAndReset(&buf);
/* Two dd processes, sharing the same stdout, are necessary to

View File

@ -1576,11 +1576,8 @@ int qemuMonitorTextMigrate(qemuMonitorPtr mon,
virBufferAddLit(&extra, " -b");
if (flags & QEMU_MONITOR_MIGRATE_NON_SHARED_INC)
virBufferAddLit(&extra, " -i");
if (virBufferError(&extra)) {
virBufferFreeAndReset(&extra);
virReportOOMError();
if (virBufferCheckError(&extra) < 0)
goto cleanup;
}
extrastr = virBufferContentAndReset(&extra);
if (virAsprintf(&cmd, "migrate %s\"%s\"", extrastr ? extrastr : "",
@ -2911,10 +2908,8 @@ int qemuMonitorTextSendKey(qemuMonitorPtr mon,
if (holdtime)
virBufferAsprintf(&buf, " %u", holdtime);
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
return -1;
}
cmd = virBufferContentAndReset(&buf);
if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)

View File

@ -728,10 +728,8 @@ int virNetSocketNewConnectSSH(const char *nodename,
virCommandAddArgList(cmd, nodename, "sh", "-c", NULL);
virBufferEscapeShell(&buf, netcat);
if (virBufferError(&buf)) {
if (virBufferCheckError(&buf) < 0) {
virCommandFree(cmd);
virBufferFreeAndReset(&buf);
virReportOOMError();
return -1;
}
quoted = virBufferContentAndReset(&buf);

View File

@ -372,10 +372,8 @@ virNetSSHCheckHostKey(virNetSSHSessionPtr sess)
virBufferAsprintf(&buff, "%02hhX:", keyhash[i]);
virBufferTrim(&buff, ":", 1);
if (virBufferError(&buff) != 0) {
virReportOOMError();
if (virBufferCheckError(&buff) < 0)
return -1;
}
keyhashstr = virBufferContentAndReset(&buff);
@ -439,10 +437,8 @@ virNetSSHCheckHostKey(virNetSSHSessionPtr sess)
* to port number */
virBufferAsprintf(&buff, "[%s]:%d", sess->hostname, sess->port);
if (virBufferError(&buff) != 0) {
virReportOOMError();
if (virBufferCheckError(&buff) < 0)
return -1;
}
hostnameStr = virBufferContentAndReset(&buff);

View File

@ -760,14 +760,12 @@ virStorageBackendCreateQemuImgOpts(char **opts,
virBufferTrim(&buf, ",", -1);
if (virBufferError(&buf))
goto no_memory;
if (virBufferCheckError(&buf) < 0)
goto error;
*opts = virBufferContentAndReset(&buf);
return 0;
no_memory:
virReportOOMError();
error:
virBufferFreeAndReset(&buf);
return -1;

View File

@ -188,10 +188,8 @@ static int virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr ptr,
}
}
if (virBufferError(&mon_host)) {
virReportOOMError();
goto cleanup;
}
if (virBufferCheckError(&mon_host) < 0)
goto cleanup;
mon_buff = virBufferContentAndReset(&mon_host);
VIR_DEBUG("RADOS mon_host has been set to: %s", mon_buff);

View File

@ -266,10 +266,8 @@ umlBuildCommandLineNet(virConnectPtr conn,
def->data.socket.port);
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
return NULL;
}
return virBufferContentAndReset(&buf);

View File

@ -1843,11 +1843,8 @@ virCommandToString(virCommandPtr cmd)
virBufferEscapeShell(&buf, cmd->args[i]);
}
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
return NULL;
}
return virBufferContentAndReset(&buf);
}

View File

@ -979,11 +979,8 @@ virConfWriteFile(const char *filename, virConfPtr conf)
cur = cur->next;
}
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
return -1;
}
fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
if (fd < 0) {
@ -1035,11 +1032,8 @@ virConfWriteMem(char *memory, int *len, virConfPtr conf)
cur = cur->next;
}
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
return -1;
}
use = virBufferUse(&buf);
content = virBufferContentAndReset(&buf);

View File

@ -119,10 +119,8 @@ int virNetDevOpenvswitchAddPort(const char *brname, const char *ifname,
virBufferAsprintf(&buf, "%d", virtVlan->tag[i]);
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto cleanup;
}
virCommandAddArg(cmd, virBufferCurrentContent(&buf));
} else if (virtVlan->nTags) {
virCommandAddArgFormat(cmd, "tag=%d", virtVlan->tag[0]);

View File

@ -1946,10 +1946,8 @@ virStorageFileCanonicalizeFormatPath(char **components,
virBufferAdd(&buf, components[i], -1);
}
if (virBufferError(&buf) != 0) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
return NULL;
}
/* if the output string is empty just return an empty string */
if (!(ret = virBufferContentAndReset(&buf)))

View File

@ -158,10 +158,8 @@ char *virStringJoin(const char **strings,
virBufferAdd(&buf, delim, -1);
strings++;
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
return NULL;
}
ret = virBufferContentAndReset(&buf);
if (!ret)
ignore_value(VIR_STRDUP(ret, ""));
@ -909,10 +907,8 @@ virStringReplace(const char *haystack,
tmp1 = tmp2;
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
return NULL;
}
return virBufferContentAndReset(&buf);
}

View File

@ -1064,10 +1064,8 @@ virSysinfoFormat(virBufferPtr buf, virSysinfoDefPtr def)
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</sysinfo>\n");
if (virBufferError(buf)) {
virReportOOMError();
if (virBufferCheckError(buf) < 0)
return -1;
}
return 0;
}

View File

@ -94,10 +94,8 @@ char *virSystemdMakeScopeName(const char *name,
virSystemdEscapeName(&buf, name);
virBufferAddLit(&buf, ".scope");
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
return NULL;
}
return virBufferContentAndReset(&buf);
}
@ -113,10 +111,8 @@ char *virSystemdMakeSliceName(const char *partition)
virSystemdEscapeName(&buf, partition);
virBufferAddLit(&buf, ".slice");
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
return NULL;
}
return virBufferContentAndReset(&buf);
}

View File

@ -286,11 +286,8 @@ char *virURIFormatParams(virURIPtr uri)
}
}
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
return NULL;
}
return virBufferContentAndReset(&buf);
}

View File

@ -3344,10 +3344,8 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe
}
/* Get final VMX output */
if (virBufferError(&buffer)) {
virReportOOMError();
if (virBufferCheckError(&buffer) < 0)
goto cleanup;
}
vmx = virBufferContentAndReset(&buffer);

View File

@ -659,10 +659,8 @@ xenUnifiedConnectGetSysinfo(virConnectPtr conn ATTRIBUTE_UNUSED,
if (virSysinfoFormat(&buf, hostsysinfo) < 0)
return NULL;
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
return NULL;
}
return virBufferContentAndReset(&buf);
}

View File

@ -505,11 +505,8 @@ xend_op_ext(virConnectPtr xend, const char *path, const char *key, va_list ap)
virBufferAddChar(&buf, '&');
}
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
return -1;
}
content = virBufferContentAndReset(&buf);
VIR_DEBUG("xend op: %s\n", content);
@ -2611,10 +2608,8 @@ xenDaemonDomainSetAutostart(virConnectPtr conn,
goto error;
}
if (virBufferError(&buffer)) {
virReportOOMError();
if (virBufferCheckError(&buffer) < 0)
goto error;
}
content = virBufferContentAndReset(&buffer);

View File

@ -284,11 +284,8 @@ mapDomainPinVcpu(unsigned char *cpumap, int maplen)
}
}
}
if (virBufferError(&buf)) {
virReportOOMError();
virBufferFreeAndReset(&buf);
if (virBufferCheckError(&buf) < 0)
return NULL;
}
ret = virBufferContentAndReset(&buf);
len = strlen(ret);
if (len > 0 && ret[len - 1] == ',')

View File

@ -1693,10 +1693,8 @@ xenFormatSxprChr(virDomainChrDefPtr def,
return -1;
}
if (virBufferError(buf)) {
virReportOOMError();
if (virBufferCheckError(buf) < 0)
return -1;
}
return 0;
}
@ -2118,10 +2116,8 @@ xenFormatSxprSound(virDomainDefPtr def,
virBufferEscapeSexpr(buf, "%s", str);
}
if (virBufferError(buf)) {
virReportOOMError();
if (virBufferCheckError(buf) < 0)
return -1;
}
return 0;
}
@ -2551,10 +2547,8 @@ xenFormatSxpr(virConnectPtr conn,
virBufferAddLit(&buf, ")"); /* closes (vm */
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto error;
}
bufout = virBufferContentAndReset(&buf);
VIR_DEBUG("Formatted sexpr: \n%s", bufout);

View File

@ -1261,10 +1261,8 @@ xenFormatXMDisk(virConfValuePtr list,
return -1;
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto cleanup;
}
if (VIR_ALLOC(val) < 0)
goto cleanup;
@ -1300,10 +1298,8 @@ static int xenFormatXMSerial(virConfValuePtr list,
} else {
virBufferAddLit(&buf, "none");
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto cleanup;
}
if (VIR_ALLOC(val) < 0)
goto cleanup;
@ -1406,10 +1402,8 @@ static int xenFormatXMNet(virConnectPtr conn,
virBufferAsprintf(&buf, ",vifname=%s",
net->ifname);
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto cleanup;
}
if (VIR_ALLOC(val) < 0)
goto cleanup;
@ -1861,11 +1855,8 @@ virConfPtr xenFormatXM(virConnectPtr conn,
virBufferAsprintf(&buf, ",keymap=%s",
def->graphics[0]->data.vnc.keymap);
}
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto cleanup;
}
vfbstr = virBufferContentAndReset(&buf);

View File

@ -58,10 +58,8 @@ testFilterXML(char *xml)
virBufferStrcat(&buf, *xmlLine, "\n", NULL);
}
if (virBufferError(&buf)) {
virReportOOMError();
if (virBufferCheckError(&buf) < 0)
goto cleanup;
}
ret = virBufferContentAndReset(&buf);