util: buffer: Remove virBufferCheckError

The function now does not return an error so we can drop it fully.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2019-10-24 14:34:44 +02:00
parent 205d6a2af7
commit 0967708b81
81 changed files with 3 additions and 559 deletions

View File

@ -227,9 +227,6 @@ bhyveBuildAHCIControllerArgStr(const virDomainDef *def,
virBufferFreeAndReset(&device);
}
if (virBufferCheckError(&buf) < 0)
goto error;
virCommandAddArg(cmd, "-s");
virCommandAddArgFormat(cmd, "%d:0,ahci%s",
controller->info.addr.pci.slot,

View File

@ -258,8 +258,6 @@ bhyveConnectGetSysinfo(virConnectPtr conn, unsigned int flags)
if (virSysinfoFormat(&buf, privconn->hostsysinfo) < 0)
return NULL;
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -743,9 +741,6 @@ bhyveConnectDomainXMLToNative(virConnectPtr conn,
virBufferAdd(&buf, virCommandToString(cmd, false), -1);
if (virBufferCheckError(&buf) < 0)
goto cleanup;
ret = virBufferContentAndReset(&buf);
cleanup:

View File

@ -734,10 +734,6 @@ virCapabilitiesDomainDataLookupInternal(virCapsPtr caps,
if (virBufferCurrentContent(&buf) &&
!virBufferCurrentContent(&buf)[0])
virBufferAsprintf(&buf, "%s", _("any configuration"));
if (virBufferCheckError(&buf) < 0) {
virBufferFreeAndReset(&buf);
goto error;
}
virReportError(VIR_ERR_INVALID_ARG,
_("could not find capabilities for %s"),
@ -930,9 +926,6 @@ virCapabilitiesFormatResctrlMonitor(virBufferPtr buf,
monitor->features[i]);
}
if (virBufferCheckError(&childrenBuf) < 0)
return -1;
virBufferAddBuffer(buf, &childrenBuf);
virBufferAddLit(buf, "</monitor>\n");
@ -1014,9 +1007,6 @@ virCapabilitiesFormatCaches(virBufferPtr buf,
controls->max_allocation);
}
if (virBufferCheckError(&childrenBuf) < 0)
return -1;
if (virBufferUse(&childrenBuf)) {
virBufferAddLit(buf, ">\n");
virBufferAddBuffer(buf, &childrenBuf);
@ -1068,9 +1058,6 @@ virCapabilitiesFormatMemoryBandwidth(virBufferPtr buf,
control->granularity, control->min,
control->max_allocation);
if (virBufferCheckError(&childrenBuf) < 0)
return -1;
if (virBufferUse(&childrenBuf)) {
virBufferAddLit(buf, ">\n");
virBufferAddBuffer(buf, &childrenBuf);
@ -1367,9 +1354,6 @@ virCapabilitiesFormatXML(virCapsPtr caps)
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</capabilities>\n");
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
error:

View File

@ -496,9 +496,6 @@ virDomainCheckpointDefFormatInternal(virBufferPtr buf,
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</domaincheckpoint>\n");
if (virBufferCheckError(buf) < 0)
goto error;
return 0;
error:

View File

@ -668,9 +668,6 @@ virCPUDefFormat(virCPUDefPtr def,
if (virCPUDefFormatBufFull(&buf, def, numa) < 0)
goto cleanup;
if (virBufferCheckError(&buf) < 0)
goto cleanup;
return virBufferContentAndReset(&buf);
cleanup:
@ -731,10 +728,6 @@ virCPUDefFormatBufFull(virBufferPtr buf,
if (virDomainNumaDefCPUFormatXML(&childrenBuf, numa) < 0)
goto cleanup;
if (virBufferCheckError(&attributeBuf) < 0 ||
virBufferCheckError(&childrenBuf) < 0)
goto cleanup;
/* Put it all together */
if (virBufferUse(&attributeBuf) || virBufferUse(&childrenBuf)) {
virBufferAddLit(buf, "<cpu");

View File

@ -1985,8 +1985,6 @@ virDomainUSBAddressPortFormat(unsigned int *port)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
virDomainUSBAddressPortFormatBuf(&buf, port);
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}

View File

@ -654,7 +654,6 @@ virDomainCapsFormat(virDomainCapsPtr const caps)
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</domainCapabilities>\n");
virBufferCheckError(&buf);
return virBufferContentAndReset(&buf);
}

View File

@ -24848,9 +24848,6 @@ virDomainFSDefFormat(virBufferPtr buf,
virDomainVirtioOptionsFormat(&driverBuf, def->virtio);
if (virBufferCheckError(&driverBuf) < 0)
goto cleanup;
if (virBufferUse(&driverBuf)) {
virBufferAddLit(buf, "<driver");
virBufferAddBuffer(buf, &driverBuf);
@ -25291,9 +25288,6 @@ virDomainVirtioNetGuestOptsFormat(char **outstr,
}
virBufferTrim(&buf, " ", -1);
if (virBufferCheckError(&buf) < 0)
return -1;
*outstr = virBufferContentAndReset(&buf);
return 0;
}
@ -25334,9 +25328,6 @@ virDomainVirtioNetHostOptsFormat(char **outstr,
}
virBufferTrim(&buf, " ", -1);
if (virBufferCheckError(&buf) < 0)
return -1;
*outstr = virBufferContentAndReset(&buf);
return 0;
}
@ -25374,9 +25365,6 @@ virDomainVirtioNetDriverFormat(char **outstr,
virDomainVirtioOptionsFormat(&buf, def->virtio);
if (virBufferCheckError(&buf) < 0)
return -1;
*outstr = virBufferContentAndReset(&buf);
return 0;
}
@ -26077,9 +26065,6 @@ virDomainSmartcardDefFormat(virBufferPtr buf,
if (virDomainDeviceInfoFormat(&childBuf, &def->info, flags) < 0)
goto cleanup;
if (virBufferCheckError(&childBuf) < 0)
goto cleanup;
virBufferAsprintf(buf, "<smartcard mode='%s'", mode);
if (def->type == VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH &&
virDomainChrAttrsDefFormat(buf, def->data.passthru, false) < 0) {
@ -26190,9 +26175,6 @@ virDomainSoundDefFormat(virBufferPtr buf,
if (virDomainDeviceInfoFormat(&childBuf, &def->info, flags) < 0)
goto cleanup;
if (virBufferCheckError(&childBuf) < 0)
goto cleanup;
virBufferAsprintf(buf, "<sound model='%s'", model);
if (virBufferUse(&childBuf)) {
virBufferAddLit(buf, ">\n");
@ -26578,8 +26560,6 @@ virDomainVideoDefFormat(virBufferPtr buf,
virBufferAddLit(buf, "<video>\n");
virBufferAdjustIndent(buf, 2);
virDomainVirtioOptionsFormat(&driverBuf, def->virtio);
if (virBufferCheckError(&driverBuf) < 0)
goto cleanup;
if (virBufferUse(&driverBuf) || (def->driver && def->driver->vgaconf) ||
def->backend != VIR_DOMAIN_VIDEO_BACKEND_TYPE_DEFAULT) {
virBufferAddLit(buf, "<driver");
@ -27657,9 +27637,6 @@ virDomainCachetuneDefFormat(virBufferPtr buf,
goto cleanup;
}
if (virBufferCheckError(&childrenBuf) < 0)
goto cleanup;
if (!virBufferUse(&childrenBuf)) {
ret = 0;
goto cleanup;
@ -27718,9 +27695,6 @@ virDomainMemorytuneDefFormat(virBufferPtr buf,
&childrenBuf) < 0)
goto cleanup;
if (virBufferCheckError(&childrenBuf) < 0)
goto cleanup;
if (!virBufferUse(&childrenBuf)) {
ret = 0;
goto cleanup;
@ -27863,9 +27837,6 @@ virDomainCputuneDefFormat(virBufferPtr buf,
for (i = 0; i < def->nresctrls; i++)
virDomainMemorytuneDefFormat(&childrenBuf, def->resctrls[i], flags);
if (virBufferCheckError(&childrenBuf) < 0)
return -1;
if (virBufferUse(&childrenBuf)) {
virBufferAddLit(buf, "<cputune>\n");
virBufferAddBuffer(buf, &childrenBuf);
@ -28932,9 +28903,6 @@ virDomainDefFormatInternalSetRootName(virDomainDefPtr def,
virBufferAdjustIndent(buf, -2);
virBufferAsprintf(buf, "</%s>\n", rootname);
if (virBufferCheckError(buf) < 0)
goto error;
return 0;
error:
@ -29009,9 +28977,6 @@ virDomainObjFormat(virDomainXMLOptionPtr xmlopt,
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</domstatus>\n");
if (virBufferCheckError(&buf) < 0)
goto error;
return virBufferContentAndReset(&buf);
error:
@ -30446,8 +30411,6 @@ virDomainGetBlkioParametersAssignFromDef(virDomainDefPtr def,
def->blkio.devices[i].param); \
} \
virBufferTrim(&buf, ",", -1); \
if (virBufferCheckError(&buf) < 0) \
goto error; \
data = virBufferContentAndReset(&buf); \
if (virTypedParameterAssign(&(params[(*nparams)++]), name, \
VIR_TYPED_PARAM_STRING, data) < 0) \
@ -30565,7 +30528,6 @@ virDomainGenerateMachineName(const char *drivername,
virBufferAsprintf(&buf, "%d-", id);
virDomainMachineNameAppendValid(&buf, name);
virBufferCheckError(&buf);
return virBufferContentAndReset(&buf);
}

View File

@ -1124,9 +1124,6 @@ virInterfaceDefDevFormat(virBufferPtr buf,
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</interface>\n");
if (virBufferCheckError(buf) < 0)
goto cleanup;
return 0;
cleanup:

View File

@ -2660,9 +2660,6 @@ virNetworkDefFormat(const virNetworkDef *def,
if (virNetworkDefFormatBuf(&buf, def, xmlopt, flags) < 0)
goto error;
if (virBufferCheckError(&buf) < 0)
goto error;
return virBufferContentAndReset(&buf);
error:

View File

@ -610,9 +610,6 @@ virNodeDeviceDefFormat(const virNodeDeviceDef *def)
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</device>\n");
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}

View File

@ -951,8 +951,6 @@ virNWFilterPrintTCPFlags(uint8_t flags)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
printTCPFlags(&buf, flags);
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -2600,15 +2598,11 @@ virNWFilterIsAllowedChain(const char *chainname)
printed = true;
}
if (virBufferCheckError(&buf) < 0)
goto err_exit;
msg = virBufferContentAndReset(&buf);
virReportError(VIR_ERR_INVALID_ARG, "%s", msg);
VIR_FREE(msg);
err_exit:
return NULL;
}
@ -3078,9 +3072,6 @@ virNWFilterDefFormat(const virNWFilterDef *def)
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</filter>\n");
if (virBufferCheckError(&buf) < 0)
goto err_exit;
return virBufferContentAndReset(&buf);
err_exit:

View File

@ -298,9 +298,6 @@ virSecretDefFormat(const virSecretDef *def)
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</secret>\n");
if (virBufferCheckError(&buf) < 0)
goto error;
return virBufferContentAndReset(&buf);
error:

View File

@ -923,9 +923,6 @@ virDomainSnapshotDefFormatInternal(virBufferPtr buf,
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</domainsnapshot>\n");
if (virBufferCheckError(buf) < 0)
goto error;
return 0;
error:

View File

@ -1233,9 +1233,6 @@ virStoragePoolDefFormat(virStoragePoolDefPtr def)
if (virStoragePoolDefFormatBuf(&buf, def) < 0)
goto error;
if (virBufferCheckError(&buf) < 0)
goto error;
return virBufferContentAndReset(&buf);
error:
@ -1668,9 +1665,6 @@ virStorageVolDefFormat(virStoragePoolDefPtr pool,
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</volume>\n");
if (virBufferCheckError(&buf) < 0)
goto cleanup;
return virBufferContentAndReset(&buf);
cleanup:
@ -1709,9 +1703,6 @@ virStoragePoolSaveState(const char *stateFile,
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</poolstate>\n");
if (virBufferCheckError(&buf) < 0)
return -1;
if (!(xml = virBufferContentAndReset(&buf)))
return -1;
@ -1781,9 +1772,6 @@ virStoragePoolSourceListFormat(virStoragePoolSourceListPtr def)
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</sources>\n");
if (virBufferCheckError(&buf) < 0)
goto cleanup;
return virBufferContentAndReset(&buf);
cleanup:

View File

@ -843,9 +843,6 @@ virNetworkObjFormat(virNetworkObjPtr obj,
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</networkstatus>");
if (virBufferCheckError(&buf) < 0)
goto error;
return virBufferContentAndReset(&buf);
error:

View File

@ -323,9 +323,6 @@ virNetworkPortDefFormat(const virNetworkPortDef *def)
return NULL;
}
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}

View File

@ -230,9 +230,6 @@ virNWFilterBindingDefFormat(const virNWFilterBindingDef *def)
return NULL;
}
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}

View File

@ -297,8 +297,5 @@ virNWFilterBindingObjFormat(const virNWFilterBindingObj *obj)
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</filterbindingstatus>\n");
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}

View File

@ -133,9 +133,6 @@ virSaveCookieFormat(virObjectPtr obj,
if (virSaveCookieFormatBuf(&buf, obj, saveCookie) < 0)
goto error;
if (virBufferCheckError(&buf) < 0)
goto error;
return virBufferContentAndReset(&buf);
error:

View File

@ -201,8 +201,6 @@ int cpuMapLoad(const char *arch,
goto cleanup;
virBufferAsprintf(&buf, "./arch[@name='%s']", arch);
if (virBufferCheckError(&buf) < 0)
goto cleanup;
xpath = virBufferContentAndReset(&buf);

View File

@ -1652,9 +1652,6 @@ virCPUx86DataFormat(const virCPUData *data)
}
virBufferAddLit(&buf, "</cpudata>\n");
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -1992,9 +1989,6 @@ x86FormatSignatures(virCPUx86ModelPtr model)
virBufferTrim(&buf, ",", -1);
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -3075,10 +3069,6 @@ virCPUx86UpdateLive(virCPUDefPtr cpu,
virBufferTrim(&bufAdded, ",", -1);
virBufferTrim(&bufRemoved, ",", -1);
if (virBufferCheckError(&bufAdded) < 0 ||
virBufferCheckError(&bufRemoved) < 0)
goto cleanup;
added = virBufferContentAndReset(&bufAdded);
removed = virBufferContentAndReset(&bufRemoved);

View File

@ -325,9 +325,6 @@ esxFormatVMXFileName(const char *fileName, void *opaque)
virBufferAddChar(&buffer, separator);
virBufferAdd(&buffer, directoryAndFileName, -1);
if (virBufferCheckError(&buffer) < 0)
goto cleanup;
result = virBufferContentAndReset(&buffer);
} else if (*fileName == '/') {
/* FIXME: need to deal with Windows paths here too */
@ -2413,9 +2410,6 @@ esxDomainScreenshot(virDomainPtr domain, virStreamPtr stream,
domain->conn->uri->server, domain->conn->uri->port);
virBufferURIEncodeString(&buffer, virtualMachine->obj->value);
if (virBufferCheckError(&buffer))
goto cleanup;
url = virBufferContentAndReset(&buffer);
mimeType = g_strdup("image/png");
@ -2634,9 +2628,6 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
virBufferAddLit(&buffer, "&dsName=");
virBufferURIEncodeString(&buffer, datastoreName);
if (virBufferCheckError(&buffer) < 0)
goto cleanup;
url = virBufferContentAndReset(&buffer);
if (esxVI_CURL_Download(priv->primary->curl, url, &vmx, 0, NULL) < 0)
@ -3100,9 +3091,6 @@ esxDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
virBufferAddLit(&buffer, "&dsName=");
virBufferURIEncodeString(&buffer, datastoreName);
if (virBufferCheckError(&buffer) < 0)
goto cleanup;
url = virBufferContentAndReset(&buffer);
/* Check, if VMX file already exists */

View File

@ -398,9 +398,6 @@ esxUtil_EscapeBase64(const char *string)
}
}
if (virBufferCheckError(&buffer) < 0)
return NULL;
return virBufferContentAndReset(&buffer);
}
@ -464,8 +461,5 @@ esxUtil_EscapeForXml(const char *string)
virBufferEscapeString(&buffer, "%s", string);
if (virBufferCheckError(&buffer) < 0)
return NULL;
return virBufferContentAndReset(&buffer);
}

View File

@ -415,9 +415,6 @@ esxVI_CURL_Download(esxVI_CURL *curl, const char *url, char **content,
goto cleanup;
}
if (virBufferCheckError(&buffer) < 0)
goto cleanup;
if (length)
*length = virBufferUse(&buffer);
@ -1237,9 +1234,6 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const char *path)
goto cleanup;
}
if (virBufferCheckError(&buffer) < 0)
goto cleanup;
ctx->datacenterPath = virBufferContentAndReset(&buffer);
/* Lookup (Cluster)ComputeResource */
@ -1302,9 +1296,6 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const char *path)
goto cleanup;
}
if (virBufferCheckError(&buffer) < 0)
goto cleanup;
ctx->computeResourcePath = virBufferContentAndReset(&buffer);
/* Lookup HostSystem */
@ -1439,9 +1430,6 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName,
if ((*response)->responseCode < 0)
goto cleanup;
if (virBufferCheckError(&buffer) < 0)
goto cleanup;
(*response)->content = virBufferContentAndReset(&buffer);
if ((*response)->responseCode == 500 || (*response)->responseCode == 200) {
@ -4330,9 +4318,6 @@ esxVI_HandleVirtualMachineQuestion
++answerIndex;
}
if (virBufferCheckError(&buffer) < 0)
goto cleanup;
possibleAnswers = virBufferContentAndReset(&buffer);
}

View File

@ -122,9 +122,6 @@
\
virBufferAddLit(&buffer, "</"#_name">"); \
virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER); \
\
if (virBufferCheckError(&buffer) < 0) \
goto cleanup; \
\
request = virBufferContentAndReset(&buffer); \
\

View File

@ -865,9 +865,6 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
notes++;
}
if (virBufferCheckError(&buf))
goto cleanup;
def->description = virBufferContentAndReset(&buf);
}

View File

@ -511,11 +511,6 @@ hypervSerializeEprParam(hypervParamPtr p, hypervPrivate *priv,
}
wsmc_set_action_option(options, FLAG_ENUMERATION_ENUM_EPR);
/* Get query and create filter based on it */
if (virBufferCheckError(p->epr.query) < 0) {
virBufferFreeAndReset(p->epr.query);
goto cleanup;
}
query_string = virBufferContentAndReset(p->epr.query);
filter = filter_create_simple(WSM_WQL_FILTER_DIALECT, query_string);
@ -983,11 +978,6 @@ hypervEnumAndPull(hypervPrivate *priv, hypervWqlQueryPtr wqlQuery,
XML_TYPE_PTR data = NULL;
hypervObject *object;
if (virBufferCheckError(wqlQuery->query) < 0) {
virBufferFreeAndReset(wqlQuery->query);
return -1;
}
query_string = virBufferContentAndReset(wqlQuery->query);
if (list == NULL || *list != NULL) {

View File

@ -1589,7 +1589,6 @@ virBufferAddChar;
virBufferAddStr;
virBufferAdjustIndent;
virBufferAsprintf;
virBufferCheckErrorInternal;
virBufferContentAndReset;
virBufferCurrentContent;
virBufferEscape;

View File

@ -948,9 +948,6 @@ libxlMakeNetworkDiskSrcStr(virStorageSourcePtr src,
if (src->configFile)
virBufferEscape(&buf, '\\', ":", ":conf=%s", src->configFile);
if (virBufferCheckError(&buf) < 0)
goto cleanup;
ret = virBufferContentAndReset(&buf);
break;
}
@ -1314,8 +1311,6 @@ libxlMakeNic(virDomainDefPtr def,
}
}
}
if (virBufferCheckError(&buf) < 0)
goto cleanup;
x_nic->bridge = g_strdup(virBufferCurrentContent(&buf));
G_GNUC_FALLTHROUGH;
case VIR_DOMAIN_NET_TYPE_ETHERNET:

View File

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

View File

@ -134,9 +134,6 @@ libxlMigrationBakeCookie(libxlMigrationCookiePtr mig,
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</libxl-migration>\n");
if (virBufferCheckError(&buf) < 0)
return -1;
*cookieout = virBufferContentAndReset(&buf);
*cookieoutlen = strlen(*cookieout) + 1;

View File

@ -1598,9 +1598,6 @@ xenFormatSxprChr(virDomainChrDefPtr def,
return -1;
}
if (virBufferCheckError(buf) < 0)
return -1;
return 0;
}
@ -1619,8 +1616,6 @@ xenFormatSerial(virConfValuePtr list, virDomainChrDefPtr serial)
} else {
virBufferAddLit(&buf, "none");
}
if (virBufferCheckError(&buf) < 0)
goto cleanup;
if (VIR_ALLOC(val) < 0)
goto cleanup;
@ -1787,9 +1782,6 @@ xenFormatNet(virConnectPtr conn,
if (net->bandwidth && net->bandwidth->out && net->bandwidth->out->average)
virBufferAsprintf(&buf, ",rate=%lluKB/s", net->bandwidth->out->average);
if (virBufferCheckError(&buf) < 0)
goto cleanup;
if (VIR_ALLOC(val) < 0)
goto cleanup;
@ -2318,8 +2310,6 @@ xenFormatVfb(virConfPtr conf, virDomainDefPtr def)
virBufferAsprintf(&buf, ",keymap=%s",
def->graphics[0]->data.vnc.keymap);
}
if (virBufferCheckError(&buf) < 0)
return -1;
vfbstr = virBufferContentAndReset(&buf);
@ -2372,9 +2362,6 @@ xenFormatSound(virConfPtr conf, virDomainDefPtr def)
virBufferEscapeSexpr(&buf, "%s", model);
}
if (virBufferCheckError(&buf) < 0)
return -1;
str = virBufferContentAndReset(&buf);
return xenConfigSetString(conf, "soundhw", str);

View File

@ -1428,9 +1428,6 @@ xenFormatXLVnode(virConfValuePtr list,
int ret = -1;
virConfValuePtr numaPnode, tmp;
if (virBufferCheckError(buf) < 0)
goto cleanup;
if (VIR_ALLOC(numaPnode) < 0)
goto cleanup;
@ -1623,9 +1620,6 @@ xenFormatXLDiskSrcNet(virStorageSourcePtr src)
}
}
if (virBufferCheckError(&buf) < 0)
goto cleanup;
ret = virBufferContentAndReset(&buf);
break;
}
@ -1748,9 +1742,6 @@ xenFormatXLDisk(virConfValuePtr list, virDomainDiskDefPtr disk)
if (target)
virBufferAsprintf(&buf, ",target=%s", target);
if (virBufferCheckError(&buf) < 0)
goto cleanup;
if (VIR_ALLOC(val) < 0)
goto cleanup;

View File

@ -351,9 +351,6 @@ xenFormatXMDisk(virConfValuePtr list,
return -1;
}
if (virBufferCheckError(&buf) < 0)
goto cleanup;
if (VIR_ALLOC(val) < 0)
goto cleanup;

View File

@ -862,9 +862,6 @@ virLockManagerSanlockRegisterKillscript(int sock,
virBufferEscape(&buf, '\\', "\\ ", "%s",
virDomainLockFailureTypeToString(action));
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
* buffers.

View File

@ -217,9 +217,6 @@ static virCommandPtr lxcContainerBuildInitCmd(virDomainDefPtr vmDef,
}
virBufferTrim(&buf, NULL, 1);
if (virBufferCheckError(&buf) < 0)
return NULL;
virUUIDFormat(vmDef->uuid, uuidstr);
cmd = virCommandNew(vmDef->os.init);

View File

@ -1399,9 +1399,6 @@ virLXCControllerSetupUsernsMap(virDomainIdMapEntryPtr map,
virBufferAsprintf(&map_value, "%u %u %u\n",
map[i].start, map[i].target, map[i].count);
if (virBufferCheckError(&map_value) < 0)
goto cleanup;
VIR_DEBUG("Set '%s' to '%s'", path, virBufferCurrentContent(&map_value));
if (virFileWriteStr(path, virBufferCurrentContent(&map_value), 0) < 0) {

View File

@ -5033,8 +5033,6 @@ lxcConnectGetSysinfo(virConnectPtr conn, unsigned int flags)
if (virSysinfoFormat(&buf, driver->hostsysinfo) < 0)
return NULL;
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}

View File

@ -223,10 +223,6 @@ static int lxcProcReadMeminfo(char *hostpath, virDomainDefPtr def,
virBufferAdd(new_meminfo, line, -1);
}
if (virBufferCheckError(new_meminfo) < 0) {
res = -errno;
goto cleanup;
}
}
res = strlen(virBufferCurrentContent(new_meminfo));
if (res > size)

View File

@ -341,9 +341,6 @@ networkRunHook(virNetworkObjPtr obj,
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</hookData>");
if (virBufferCheckError(&buf) < 0)
goto cleanup;
xml = virBufferContentAndReset(&buf);
hookret = virHookCall(VIR_HOOK_DRIVER_NETWORK, def->name,
op, sub_op, NULL, xml, NULL);
@ -1926,9 +1923,6 @@ networkRadvdConfContents(virNetworkObjPtr obj,
virBufferAddLit(&configbuf, "};\n");
if (virBufferCheckError(&configbuf) < 0)
goto cleanup;
*configstr = virBufferContentAndReset(&configbuf);
ret = 0;

View File

@ -304,9 +304,6 @@ udevGenerateDeviceName(struct udev_device *device,
if (s != NULL)
virBufferAsprintf(&buf, "_%s", s);
if (virBufferCheckError(&buf) < 0)
return -1;
def->name = virBufferContentAndReset(&buf);
for (i = 0; i < strlen(def->name); i++) {

View File

@ -303,9 +303,6 @@ _printDataType(virNWFilterVarCombIterPtr vars,
}
}
if (virBufferCheckError(&vb) < 0)
return -1;
flags = virBufferContentAndReset(&vb);
if (virStrcpy(buf, flags, bufsize) < 0) {
@ -1559,8 +1556,6 @@ printStateMatchFlags(int32_t flags, char **bufptr)
"",
flags,
false);
if (virBufferCheckError(&buf) < 0)
return -1;
*bufptr = virBufferContentAndReset(&buf);
return 0;
}
@ -2413,9 +2408,6 @@ ebtablesCreateRuleInstance(virFirewallPtr fw,
if (ENTRY_WANT_NEG_SIGN(&rule->p.ipv6HdrFilter.dataICMPTypeStart))
virFirewallRuleAddArg(fw, fwrule, "!");
if (virBufferCheckError(&buf) < 0)
goto cleanup;
r = virBufferContentAndReset(&buf);
virFirewallRuleAddArg(fw, fwrule, r);

View File

@ -180,8 +180,6 @@ virNWFilterPrintVars(virHashTablePtr vars,
virHashForEach(vars, printString, &ps);
if (virBufferCheckError(&ps.buf) < 0)
return NULL;
return virBufferContentAndReset(&ps.buf);
}

View File

@ -220,8 +220,6 @@ phypExec(LIBSSH2_SESSION *session, const char *cmd, int *exit_status,
channel = NULL;
VIR_FREE(buffer);
if (virBufferCheckError(&tex_ret) < 0)
return NULL;
return virBufferContentAndReset(&tex_ret);
err:
@ -242,8 +240,6 @@ phypExecBuffer(LIBSSH2_SESSION *session, virBufferPtr buf, int *exit_status,
char *cmd;
char *ret;
if (virBufferCheckError(buf) < 0)
return NULL;
cmd = virBufferContentAndReset(buf);
ret = phypExec(session, cmd, exit_status, conn);
VIR_FREE(cmd);

View File

@ -4088,8 +4088,7 @@ virQEMUCapsFormatCache(virQEMUCapsPtr qemuCaps)
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</qemuCaps>\n");
if (virBufferCheckError(&buf) == 0)
ret = virBufferContentAndReset(&buf);
ret = virBufferContentAndReset(&buf);
return ret;
}

View File

@ -1007,9 +1007,6 @@ qemuBuildNetworkDriveStr(virStorageSourcePtr src,
if (src->path)
virBufferAsprintf(&buf, ":exportname=%s", src->path);
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
/* NBD code uses URI formatting scheme as others in some cases */
@ -1086,9 +1083,6 @@ qemuBuildNetworkDriveStr(virStorageSourcePtr src,
if (src->configFile)
virBufferEscape(&buf, '\\', ":", ":conf=%s", src->configFile);
if (virBufferCheckError(&buf) < 0)
return NULL;
ret = virBufferContentAndReset(&buf);
break;
@ -1858,9 +1852,6 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
qemuBuildDiskThrottling(disk, &opt);
if (virBufferCheckError(&opt) < 0)
goto error;
return virBufferContentAndReset(&opt);
error:
@ -2275,9 +2266,6 @@ qemuBuildDiskDeviceStr(const virDomainDef *def,
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_USB_STORAGE_WERROR))
qemuBuildDiskFrontendAttributeErrorPolicy(disk, &opt);
if (virBufferCheckError(&opt) < 0)
goto error;
return virBufferContentAndReset(&opt);
error:
@ -2296,9 +2284,6 @@ qemuBuildZPCIDevStr(virDomainDeviceInfoPtr dev)
dev->alias,
dev->addr.pci.zpci.uid);
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -2639,9 +2624,6 @@ qemuBuildFSStr(virDomainFSDefPtr fs)
if (fs->readonly)
virBufferAddLit(&opt, ",readonly");
if (virBufferCheckError(&opt) < 0)
return NULL;
return virBufferContentAndReset(&opt);
}
@ -2669,9 +2651,6 @@ qemuBuildFSDevStr(const virDomainDef *def,
if (qemuBuildDeviceAddressStr(&opt, def, &fs->info, qemuCaps) < 0)
return NULL;
if (virBufferCheckError(&opt) < 0)
return NULL;
return virBufferContentAndReset(&opt);
}
@ -3034,9 +3013,6 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
if (qemuBuildDeviceAddressStr(&buf, domainDef, &def->info, qemuCaps) < 0)
return -1;
if (virBufferCheckError(&buf) < 0)
return -1;
*devstr = virBufferContentAndReset(&buf);
return 0;
}
@ -3689,9 +3665,6 @@ qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem,
}
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -3877,9 +3850,6 @@ qemuBuildNicDevStr(virDomainDefPtr def,
qemuBuildVirtioOptionsStr(&buf, net->virtio, qemuCaps) < 0)
goto error;
if (virBufferCheckError(&buf) < 0)
goto error;
return virBufferContentAndReset(&buf);
error:
@ -4027,8 +3997,6 @@ qemuBuildHostNetStr(virDomainNetDefPtr net,
virBufferTrim(&buf, ",", -1);
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -4052,9 +4020,6 @@ qemuBuildWatchdogDevStr(const virDomainDef *def,
if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
return NULL;
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -4154,9 +4119,6 @@ qemuBuildNVRAMDevStr(virDomainNVRAMDefPtr dev)
return NULL;
}
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -4244,9 +4206,6 @@ qemuBuildVirtioInputDevStr(const virDomainDef *def,
if (qemuBuildVirtioOptionsStr(&buf, dev->virtio, qemuCaps) < 0)
return NULL;
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -4278,9 +4237,6 @@ qemuBuildUSBInputDevStr(const virDomainDef *def,
if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
return NULL;
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -4385,9 +4341,6 @@ qemuBuildSoundDevStr(const virDomainDef *def,
if (qemuBuildDeviceAddressStr(&buf, def, &sound->info, qemuCaps) < 0)
return NULL;
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -4602,9 +4555,6 @@ qemuBuildDeviceVideoStr(const virDomainDef *def,
if (qemuBuildVirtioOptionsStr(&buf, video->virtio, qemuCaps) < 0)
return NULL;
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -4819,9 +4769,6 @@ qemuBuildPCIHostdevDevStr(const virDomainDef *def,
if (qemuBuildRomStr(&buf, dev->info) < 0)
return NULL;
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -4852,9 +4799,6 @@ qemuBuildUSBHostdevDevStr(const virDomainDef *def,
if (qemuBuildDeviceAddressStr(&buf, def, dev->info, qemuCaps) < 0)
return NULL;
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -4884,9 +4828,6 @@ qemuBuildHubDevStr(const virDomainDef *def,
if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
return NULL;
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -4953,9 +4894,6 @@ qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDefPtr dev,
virBufferAddLit(&buf, ",if=none,format=raw");
}
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -4987,9 +4925,6 @@ qemuBuildSCSIVHostHostdevDevStr(const virDomainDef *def,
if (qemuBuildDeviceAddressStr(&buf, def, dev->info, qemuCaps) < 0)
return NULL;
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -5019,9 +4954,6 @@ qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev,
if (dev->readonly)
virBufferAddLit(&buf, ",readonly=on");
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -5080,9 +5012,6 @@ qemuBuildSCSIHostdevDevStr(const virDomainDef *def,
if (dev->info->bootIndex)
virBufferAsprintf(&buf, ",bootindex=%u", dev->info->bootIndex);
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -5408,9 +5337,6 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager,
return NULL;
}
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -5446,9 +5372,6 @@ qemuBuildHostdevMediatedDevStr(const virDomainDef *def,
if (dev->info->bootIndex)
virBufferAsprintf(&buf, ",bootindex=%u", dev->info->bootIndex);
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -5708,8 +5631,6 @@ qemuBuildVirtioSerialPortDevStr(const virDomainDef *def,
virBufferAsprintf(&buf, ",name=%s", dev->target.name
? dev->target.name : "com.redhat.spice.0");
}
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -5734,8 +5655,6 @@ qemuBuildSclpDevStr(virDomainChrDefPtr dev)
}
virBufferAsprintf(&buf, ",chardev=char%s,id=%s",
dev->info.alias, dev->info.alias);
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -5866,8 +5785,6 @@ qemuBuildRNGDevStr(const virDomainDef *def,
if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
return NULL;
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -6059,9 +5976,6 @@ qemuBuildSmbiosBaseBoardStr(virSysinfoBaseBoardDefPtr def)
virQEMUBuildBufferEscapeComma(&buf, def->location);
}
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -6120,9 +6034,6 @@ qemuBuildSmbiosChassisStr(virSysinfoChassisDefPtr def)
virQEMUBuildBufferEscapeComma(&buf, def->sku);
}
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -6369,9 +6280,6 @@ qemuBuildClockArgStr(virDomainClockDefPtr def)
}
}
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -6584,9 +6492,6 @@ qemuBuildBootCommandLine(virCommandPtr cmd,
virBufferTrim(&boot_buf, ",", -1);
if (virBufferCheckError(&boot_buf) < 0)
return -1;
boot_opts_str = virBufferContentAndReset(&boot_buf);
if (boot_opts_str) {
virCommandAddArg(cmd, "-boot");
@ -7011,11 +6916,6 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
virBufferAddLit(&buf, ",l3-cache=off");
}
if (virBufferCheckError(&cpu_buf) < 0)
return -1;
if (virBufferCheckError(&buf) < 0)
return -1;
cpu = virBufferContentAndReset(&cpu_buf);
cpu_flags = virBufferContentAndReset(&buf);
@ -7498,9 +7398,6 @@ qemuBuildSmpCommandLine(virCommandPtr cmd,
virBufferAsprintf(&buf, ",threads=%u", 1);
}
if (virBufferCheckError(&buf) < 0)
return -1;
virCommandAddArgBuffer(cmd, &buf);
return 0;
}
@ -7849,9 +7746,6 @@ qemuBuildGraphicsSDLCommandLine(virQEMUDriverConfigPtr cfg G_GNUC_UNUSED,
}
if (virBufferCheckError(&opt) < 0)
return -1;
virCommandAddArgBuffer(cmd, &opt);
return 0;
@ -8262,9 +8156,6 @@ qemuBuildGraphicsEGLHeadlessCommandLine(virQEMUDriverConfigPtr cfg G_GNUC_UNUSED
graphics->data.egl_headless.rendernode);
}
if (virBufferCheckError(&opt) < 0)
return -1;
virCommandAddArg(cmd, "-display");
virCommandAddArgBuffer(cmd, &opt);
@ -8915,9 +8806,6 @@ qemuBuildShmemDevLegacyStr(virDomainDefPtr def,
if (qemuBuildDeviceAddressStr(&buf, def, &shmem->info, qemuCaps) < 0)
return NULL;
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -8957,9 +8845,6 @@ qemuBuildShmemDevStr(virDomainDefPtr def,
if (qemuBuildDeviceAddressStr(&buf, def, &shmem->info, qemuCaps) < 0)
return NULL;
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -9487,9 +9372,6 @@ qemuBuildRedirdevDevStr(const virDomainDef *def,
if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
return NULL;
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -9627,9 +9509,6 @@ qemuBuildTPMDevStr(const virDomainDef *def,
virBufferAsprintf(&buf, "%s,tpmdev=tpm-%s,id=%s",
model, tpm->info.alias, tpm->info.alias);
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -9714,9 +9593,6 @@ qemuBuildTPMBackendStr(const virDomainDef *def,
return NULL;
}
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -10223,9 +10099,6 @@ qemuBuildVsockDevStr(virDomainDefPtr def,
if (qemuBuildDeviceAddressStr(&buf, def, &vsock->info, qemuCaps) < 0)
return NULL;
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -10586,9 +10459,6 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
if (qemuBuildDeviceAddressStr(&buf, def, &serial->info, qemuCaps) < 0)
return -1;
if (virBufferCheckError(&buf) < 0)
return -1;
*deviceStr = virBufferContentAndReset(&buf);
return 0;
}

View File

@ -7407,16 +7407,12 @@ qemuDomainChrDefDropDefaultPath(virDomainChrDefPtr chr,
virBufferAddLit(&buf, "/([^/]+\\.)|(domain-[^/]+/)");
virBufferEscapeRegex(&buf, "%s$", chr->target.name);
if (virBufferCheckError(&buf) < 0)
goto cleanup;
regexp = virBufferContentAndReset(&buf);
if (virStringMatch(chr->source->data.nix.path, regexp))
VIR_FREE(chr->source->data.nix.path);
ret = 0;
cleanup:
VIR_FREE(regexp);
virObjectUnref(cfg);
return ret;

View File

@ -1302,8 +1302,6 @@ qemuConnectGetSysinfo(virConnectPtr conn, unsigned int flags)
if (virSysinfoFormat(&buf, driver->hostsysinfo) < 0)
return NULL;
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}

View File

@ -877,9 +877,6 @@ qemuMigrationCookieXMLFormatStr(virQEMUDriverPtr driver,
return NULL;
}
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}

View File

@ -323,9 +323,6 @@ qemuMonitorJSONCommandWithFd(qemuMonitorPtr mon,
goto cleanup;
virBufferAddLit(&cmdbuf, "\r\n");
if (virBufferCheckError(&cmdbuf) < 0)
goto cleanup;
msg.txLength = virBufferUse(&cmdbuf);
msg.txBuffer = virBufferContentAndReset(&cmdbuf);
msg.txFD = scm_fd;

View File

@ -694,9 +694,6 @@ virNetLibsshAuthenticateKeyboardInteractive(virNetLibsshSessionPtr sess,
if (virBufferUse(&buff) > 0)
virBufferAddChar(&buff, '\n');
if (virBufferCheckError(&buff) < 0)
return -1;
for (iprompt = 0; iprompt < nprompts; ++iprompt) {
virConnectCredential retr_passphrase;
const char *promptStr;
@ -727,9 +724,6 @@ virNetLibsshAuthenticateKeyboardInteractive(virNetLibsshSessionPtr sess,
virBufferAddBuffer(&prompt_buff, &buff);
virBufferAdd(&prompt_buff, promptStr, promptStrLen);
if (virBufferCheckError(&prompt_buff) < 0)
goto prompt_error;
prompt = virBufferContentAndReset(&prompt_buff);
} else {
if (VIR_STRNDUP(prompt, promptStr, promptStrLen) < 0)

View File

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

View File

@ -359,9 +359,6 @@ virNetSSHCheckHostKey(virNetSSHSessionPtr sess)
virBufferAsprintf(&buff, "%02hhX:", keyhash[i]);
virBufferTrim(&buff, ":", 1);
if (virBufferCheckError(&buff) < 0)
return -1;
keyhashstr = virBufferContentAndReset(&buff);
askKey.type = VIR_CRED_ECHOPROMPT;
@ -424,9 +421,6 @@ virNetSSHCheckHostKey(virNetSSHSessionPtr sess)
* to port number */
virBufferAsprintf(&buff, "[%s]:%d", sess->hostname, sess->port);
if (virBufferCheckError(&buff) < 0)
return -1;
hostnameStr = virBufferContentAndReset(&buff);
if (libssh2_knownhost_addc(sess->knownHosts,

View File

@ -266,9 +266,6 @@ virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr ptr,
}
}
if (virBufferCheckError(&mon_host) < 0)
goto cleanup;
mon_buff = virBufferContentAndReset(&mon_host);
if (virStorageBackendRBDRADOSConfSet(ptr->cluster,
"mon_host",
@ -1224,9 +1221,6 @@ virStorageBackendRBDCloneImage(rados_ioctx_t io,
virBufferAsprintf(&snapname, "libvirt-%d", (int)virRandomInt(65534));
if (virBufferCheckError(&snapname) < 0)
goto cleanup;
snapname_buff = virBufferContentAndReset(&snapname);
if (virStorageBackendRBDSnapshotCreate(image, origvol, snapname_buff) < 0)

View File

@ -758,9 +758,6 @@ storageBackendCreateQemuImgOpts(virStorageEncryptionInfoDefPtr encinfo,
virBufferTrim(&buf, ",", -1);
if (virBufferCheckError(&buf) < 0)
goto error;
*opts = virBufferContentAndReset(&buf);
return 0;
@ -946,11 +943,6 @@ storageBackendCreateQemuImgSecretObject(virCommandPtr cmd,
virBufferAsprintf(&buf, "secret,id=%s,file=", secretAlias);
virQEMUBuildBufferEscapeComma(&buf, secretPath);
if (virBufferCheckError(&buf) < 0) {
virBufferFreeAndReset(&buf);
return -1;
}
commandStr = virBufferContentAndReset(&buf);
virCommandAddArgList(cmd, "--object", commandStr, NULL);
@ -976,11 +968,6 @@ storageBackendResizeQemuImgImageOpts(virCommandPtr cmd,
secretAlias);
virQEMUBuildBufferEscapeComma(&buf, path);
if (virBufferCheckError(&buf) < 0) {
virBufferFreeAndReset(&buf);
return -1;
}
commandStr = virBufferContentAndReset(&buf);
virCommandAddArgList(cmd, "--image-opts", commandStr, NULL);

View File

@ -369,7 +369,6 @@ virBitmapToString(virBitmapPtr bitmap,
bitmap->map[sz]);
}
virBufferCheckError(&buf);
ret = virBufferContentAndReset(&buf);
if (!ret)
return NULL;

View File

@ -276,20 +276,6 @@ void virBufferFreeAndReset(virBufferPtr buf)
memset(buf, 0, sizeof(*buf));
}
/**
* virBufferCheckErrorInternal:
* @buf: the buffer
*
* Report an error if the buffer is in an error state.
*
* Return -1 if an error has been reported, 0 otherwise.
*/
int
virBufferCheckErrorInternal(const virBuffer *buf G_GNUC_UNUSED)
{
return 0;
}
/**
* virBufferUse:
* @buf: the usage of the string in the buffer

View File

@ -43,22 +43,9 @@ struct _virBuffer {
const char *virBufferCurrentContent(virBufferPtr buf);
char *virBufferContentAndReset(virBufferPtr buf);
void virBufferFreeAndReset(virBufferPtr buf);
int virBufferCheckErrorInternal(const virBuffer *buf)
ATTRIBUTE_NONNULL(1);
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(virBuffer, virBufferFreeAndReset);
/**
* virBufferCheckError
*
* Checks if the buffer is in error state and reports an error.
*
* Returns 0 if no error has occurred, otherwise an error is reported
* and -1 is returned.
*/
#define virBufferCheckError(buf) \
virBufferCheckErrorInternal(buf)
size_t virBufferUse(const virBuffer *buf);
void virBufferAdd(virBufferPtr buf, const char *str, int len);
void virBufferAddBuffer(virBufferPtr buf, virBufferPtr toadd);

View File

@ -2125,9 +2125,6 @@ virCommandToString(virCommandPtr cmd, bool linebreaks)
prevopt = (cmd->args[i][0] == '-');
}
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}

View File

@ -1445,9 +1445,6 @@ virConfWriteFile(const char *filename, virConfPtr conf)
cur = cur->next;
}
if (virBufferCheckError(&buf) < 0)
return -1;
fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
if (fd < 0) {
virBufferFreeAndReset(&buf);
@ -1498,9 +1495,6 @@ virConfWriteMem(char *memory, int *len, virConfPtr conf)
cur = cur->next;
}
if (virBufferCheckError(&buf) < 0)
return -1;
use = virBufferUse(&buf);
content = virBufferContentAndReset(&buf);

View File

@ -151,9 +151,6 @@ addnhostsNew(const char *name,
virBufferEscapeString(&buf, "/%s", name);
virBufferAsprintf(&buf, ".%s", DNSMASQ_ADDNHOSTSFILE_SUFFIX);
if (virBufferCheckError(&buf) < 0)
goto error;
if (!(addnhostsfile->path = virBufferContentAndReset(&buf)))
goto error;
@ -365,9 +362,6 @@ hostsfileNew(const char *name,
virBufferEscapeString(&buf, "/%s", name);
virBufferAsprintf(&buf, ".%s", DNSMASQ_HOSTSFILE_SUFFIX);
if (virBufferCheckError(&buf) < 0)
goto error;
if (!(hostsfile->path = virBufferContentAndReset(&buf)))
goto error;
return hostsfile;

View File

@ -118,9 +118,6 @@ virFileCacheGetFileName(virFileCachePtr cache,
if (cache->suffix)
virBufferAsprintf(&buf, ".%s", cache->suffix);
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}

View File

@ -107,15 +107,12 @@ virNetDevOpenvswitchConstructVlans(virCommandPtr cmd, virNetDevVlanPtr virtVlan)
virBufferAsprintf(&buf, "%d", virtVlan->tag[i]);
}
if (virBufferCheckError(&buf) < 0)
goto cleanup;
virCommandAddArg(cmd, virBufferCurrentContent(&buf));
} else if (virtVlan->nTags) {
virCommandAddArgFormat(cmd, "tag=%d", virtVlan->tag[0]);
}
ret = 0;
cleanup:
virBufferFreeAndReset(&buf);
return ret;
}

View File

@ -50,14 +50,7 @@ char *virPidFileBuildPath(const char *dir, const char* name)
virBufferAsprintf(&buf, "%s", dir);
virBufferEscapeString(&buf, "/%s.pid", name);
if (virBufferCheckError(&buf) < 0)
goto error;
return virBufferContentAndReset(&buf);
error:
virBufferFreeAndReset(&buf);
return NULL;
}

View File

@ -274,9 +274,6 @@ virQEMUBuildDriveCommandlineFromJSON(virJSONValuePtr srcdef)
virQEMUBuildCommandLineJSONArrayNumbered) < 0)
goto cleanup;
if (virBufferCheckError(&buf) < 0)
goto cleanup;
ret = virBufferContentAndReset(&buf);
cleanup:

View File

@ -1437,7 +1437,7 @@ virResctrlAllocMemoryBandwidthFormat(virResctrlAllocPtr alloc,
virBufferTrim(buf, ";", 1);
virBufferAddChar(buf, '\n');
return virBufferCheckError(buf);
return 0;
}
@ -1582,7 +1582,7 @@ virResctrlAllocFormatCache(virResctrlAllocPtr alloc,
}
}
return virBufferCheckError(buf);
return 0;
}

View File

@ -3945,9 +3945,6 @@ virStorageFileCanonicalizeFormatPath(char **components,
virBufferAdd(&buf, components[i], -1);
}
if (virBufferCheckError(&buf) < 0)
return NULL;
/* if the output string is empty just return an empty string */
if (!(ret = virBufferContentAndReset(&buf)))
ret = g_strdup("");

View File

@ -155,8 +155,6 @@ char *virStringListJoin(const char **strings,
virBufferAdd(&buf, delim, -1);
strings++;
}
if (virBufferCheckError(&buf) < 0)
return NULL;
ret = virBufferContentAndReset(&buf);
if (!ret)
ret = g_strdup("");
@ -1197,9 +1195,6 @@ virStringReplace(const char *haystack,
tmp1 = tmp2;
}
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}

View File

@ -1510,9 +1510,6 @@ virSysinfoFormat(virBufferPtr buf, virSysinfoDefPtr def)
return -1;
}
if (virBufferCheckError(buf) < 0)
return -1;
return 0;
}

View File

@ -116,9 +116,6 @@ char *virSystemdMakeScopeName(const char *name,
virSystemdEscapeName(&buf, name);
virBufferAddLit(&buf, ".scope");
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -133,9 +130,6 @@ char *virSystemdMakeSliceName(const char *partition)
virSystemdEscapeName(&buf, partition);
virBufferAddLit(&buf, ".slice");
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}

View File

@ -275,9 +275,6 @@ char *virURIFormatParams(virURIPtr uri)
}
}
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}

View File

@ -1387,10 +1387,6 @@ virXMLFormatElement(virBufferPtr buf,
return 0;
}
if ((attrBuf && virBufferCheckError(attrBuf) < 0) ||
(childBuf && virBufferCheckError(childBuf) < 0))
goto cleanup;
virBufferAsprintf(buf, "<%s", name);
if (attrBuf && virBufferUse(attrBuf) > 0)
@ -1406,7 +1402,6 @@ virXMLFormatElement(virBufferPtr buf,
ret = 0;
cleanup:
virBufferFreeAndReset(attrBuf);
virBufferFreeAndReset(childBuf);
return ret;

View File

@ -3432,9 +3432,6 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe
}
/* Get final VMX output */
if (virBufferCheckError(&buffer) < 0)
goto cleanup;
vmx = virBufferContentAndReset(&buffer);
cleanup:

View File

@ -458,8 +458,6 @@ vzConnectGetSysinfo(virConnectPtr conn, unsigned int flags)
if (virSysinfoFormat(&buf, driver->hostsysinfo) < 0)
return NULL;
if (virBufferCheckError(&buf) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
@ -2768,9 +2766,6 @@ vzBakeCookie(vzDriverPtr driver,
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</vz-migration>\n");
if (virBufferCheckError(&buf) < 0)
return -1;
*cookieout = virBufferContentAndReset(&buf);
*cookieoutlen = strlen(*cookieout) + 1;

View File

@ -330,9 +330,6 @@ testQemuDiskXMLToPropsValidateFile(const void *opaque)
VIR_FREE(jsonstr);
}
if (virBufferCheckError(&buf) < 0)
goto cleanup;
actual = virBufferContentAndReset(&buf);
ret = virTestCompareToFile(actual, jsonpath);
@ -501,9 +498,6 @@ testQemuDiskXMLToPropsValidateFileSrcOnly(const void *opaque)
virBufferAdd(&buf, jsonstr, -1);
}
if (virBufferCheckError(&buf) < 0)
return -1;
actual = virBufferContentAndReset(&buf);
return virTestCompareToFile(actual, jsonpath);

View File

@ -2836,9 +2836,6 @@ testBlockNodeNameDetect(const void *opaque)
virBufferTrim(&buf, "\n", -1);
if (virBufferCheckError(&buf) < 0)
goto cleanup;
actual = virBufferContentAndReset(&buf);
if (virTestCompareToFile(actual, resultFile) < 0)
@ -2984,9 +2981,6 @@ testQueryJobs(const void *opaque)
virBufferTrim(&buf, "\n", -1);
if (virBufferCheckError(&buf) < 0)
goto cleanup;
actual = virBufferContentAndReset(&buf);
if (virTestCompareToFile(actual, filenameResult) < 0)

View File

@ -131,8 +131,6 @@ qemuMonitorTestAddErrorResponse(qemuMonitorTestPtr test,
usermsg = "unexpected command";
virBufferEscape(&buf, '\\', "\"", "%s", usermsg);
if (virBufferCheckError(&buf) < 0)
return -1;
escapemsg = virBufferContentAndReset(&buf);
/* replace newline/carriage return with space */

View File

@ -210,8 +210,6 @@ testCgroupDetectMounts(const void *args)
}
virBufferAsprintf(&buf, "%-12s %s\n",
"unified", NULLSTR(group->unified.mountPoint));
if (virBufferCheckError(&buf) < 0)
goto cleanup;
actual = virBufferCurrentContent(&buf);
if (virTestCompareToFile(actual, parsed) < 0)

View File

@ -2417,8 +2417,6 @@ cmdBlockcopy(vshControl *ctl, const vshCmd *cmd)
virBufferEscapeString(&buf, "<driver type='%s'/>\n", format);
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</disk>\n");
if (virBufferCheckError(&buf) < 0)
goto cleanup;
xmlstr = virBufferContentAndReset(&buf);
}

View File

@ -3464,9 +3464,6 @@ cmdComplete(vshControl *ctl, const vshCmd *cmd)
arg = opt->data;
}
if (virBufferCheckError(&buf) < 0)
goto cleanup;
vshReadlineInit(ctl);
if (!(rl_line_buffer = virBufferContentAndReset(&buf)))