mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
util: buffer: Remove virBufferError
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:
parent
418aa809fd
commit
205d6a2af7
@ -30521,8 +30521,6 @@ virDomainMachineNameAppendValid(virBufferPtr buf,
|
|||||||
bool skip_dot = false;
|
bool skip_dot = false;
|
||||||
|
|
||||||
for (; *name; name++) {
|
for (; *name; name++) {
|
||||||
if (virBufferError(buf))
|
|
||||||
break;
|
|
||||||
if (strlen(virBufferCurrentContent(buf)) >= 64)
|
if (strlen(virBufferCurrentContent(buf)) >= 64)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1592,7 +1592,6 @@ virBufferAsprintf;
|
|||||||
virBufferCheckErrorInternal;
|
virBufferCheckErrorInternal;
|
||||||
virBufferContentAndReset;
|
virBufferContentAndReset;
|
||||||
virBufferCurrentContent;
|
virBufferCurrentContent;
|
||||||
virBufferError;
|
|
||||||
virBufferEscape;
|
virBufferEscape;
|
||||||
virBufferEscapeRegex;
|
virBufferEscapeRegex;
|
||||||
virBufferEscapeSexpr;
|
virBufferEscapeSexpr;
|
||||||
|
@ -431,10 +431,6 @@ virNWFilterDetermineMissingVarsRec(virNWFilterDefPtr filter,
|
|||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||||
|
|
||||||
virNWFilterVarAccessPrint(rule->varAccess[j], &buf);
|
virNWFilterVarAccessPrint(rule->varAccess[j], &buf);
|
||||||
if (virBufferError(&buf)) {
|
|
||||||
virReportOOMError();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
val = virNWFilterVarValueCreateSimpleCopyValue("1");
|
val = virNWFilterVarValueCreateSimpleCopyValue("1");
|
||||||
if (!val) {
|
if (!val) {
|
||||||
|
@ -456,11 +456,6 @@ learnIPAddressThread(void *arg)
|
|||||||
macaddr);
|
macaddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virBufferError(&buf)) {
|
|
||||||
req->status = ENOMEM;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
filter = virBufferContentAndReset(&buf);
|
filter = virBufferContentAndReset(&buf);
|
||||||
|
|
||||||
if (pcap_compile(handle, &fp, filter, 1, 0) != 0) {
|
if (pcap_compile(handle, &fp, filter, 1, 0) != 0) {
|
||||||
|
@ -1314,12 +1314,6 @@ get_files(vahControl * ctl)
|
|||||||
if (vah_add_file(&buf, ctl->newfile, "rwk") != 0)
|
if (vah_add_file(&buf, ctl->newfile, "rwk") != 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virBufferError(&buf)) {
|
|
||||||
virBufferFreeAndReset(&buf);
|
|
||||||
vah_error(NULL, 0, _("failed to allocate file buffer"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = 0;
|
rc = 0;
|
||||||
ctl->files = virBufferContentAndReset(&buf);
|
ctl->files = virBufferContentAndReset(&buf);
|
||||||
|
|
||||||
@ -1507,11 +1501,6 @@ main(int argc, char **argv)
|
|||||||
virBufferAdd(&buf, ctl->files, -1);
|
virBufferAdd(&buf, ctl->files, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virBufferError(&buf)) {
|
|
||||||
virBufferFreeAndReset(&buf);
|
|
||||||
vah_error(ctl, 1, _("failed to allocate buffer"));
|
|
||||||
}
|
|
||||||
|
|
||||||
included_files = virBufferContentAndReset(&buf);
|
included_files = virBufferContentAndReset(&buf);
|
||||||
|
|
||||||
/* (re)create the include file using included_files */
|
/* (re)create the include file using included_files */
|
||||||
|
@ -446,12 +446,6 @@ virBitmapFormat(virBitmapPtr bitmap)
|
|||||||
start = prev = cur;
|
start = prev = cur;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virBufferError(&buf)) {
|
|
||||||
virBufferFreeAndReset(&buf);
|
|
||||||
virReportOOMError();
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return virBufferContentAndReset(&buf);
|
return virBufferContentAndReset(&buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,21 +276,6 @@ void virBufferFreeAndReset(virBufferPtr buf)
|
|||||||
memset(buf, 0, sizeof(*buf));
|
memset(buf, 0, sizeof(*buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* virBufferError:
|
|
||||||
* @buf: the buffer
|
|
||||||
*
|
|
||||||
* Check to see if the buffer is in an error state due
|
|
||||||
* to failed memory allocation or usage error
|
|
||||||
*
|
|
||||||
* Return positive errno value or -1 on usage error, 0 if normal
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
virBufferError(const virBuffer *buf G_GNUC_UNUSED)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* virBufferCheckErrorInternal:
|
* virBufferCheckErrorInternal:
|
||||||
* @buf: the buffer
|
* @buf: the buffer
|
||||||
|
@ -43,7 +43,6 @@ struct _virBuffer {
|
|||||||
const char *virBufferCurrentContent(virBufferPtr buf);
|
const char *virBufferCurrentContent(virBufferPtr buf);
|
||||||
char *virBufferContentAndReset(virBufferPtr buf);
|
char *virBufferContentAndReset(virBufferPtr buf);
|
||||||
void virBufferFreeAndReset(virBufferPtr buf);
|
void virBufferFreeAndReset(virBufferPtr buf);
|
||||||
int virBufferError(const virBuffer *buf);
|
|
||||||
int virBufferCheckErrorInternal(const virBuffer *buf)
|
int virBufferCheckErrorInternal(const virBuffer *buf)
|
||||||
ATTRIBUTE_NONNULL(1);
|
ATTRIBUTE_NONNULL(1);
|
||||||
|
|
||||||
|
@ -1389,11 +1389,6 @@ virCommandAddEnvBuffer(virCommandPtr cmd, virBufferPtr buf)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virBufferError(buf)) {
|
|
||||||
cmd->has_error = ENOMEM;
|
|
||||||
virBufferFreeAndReset(buf);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!virBufferUse(buf)) {
|
if (!virBufferUse(buf)) {
|
||||||
cmd->has_error = EINVAL;
|
cmd->has_error = EINVAL;
|
||||||
return;
|
return;
|
||||||
@ -1525,8 +1520,7 @@ virCommandAddArgBuffer(virCommandPtr cmd, virBufferPtr buf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Arg plus trailing NULL. */
|
/* Arg plus trailing NULL. */
|
||||||
if (virBufferError(buf) ||
|
if (VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, 1 + 1) < 0) {
|
||||||
VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, 1 + 1) < 0) {
|
|
||||||
cmd->has_error = ENOMEM;
|
cmd->has_error = ENOMEM;
|
||||||
virBufferFreeAndReset(buf);
|
virBufferFreeAndReset(buf);
|
||||||
return;
|
return;
|
||||||
|
@ -1137,11 +1137,6 @@ virLogGetFilters(void)
|
|||||||
}
|
}
|
||||||
virLogUnlock();
|
virLogUnlock();
|
||||||
|
|
||||||
if (virBufferError(&filterbuf)) {
|
|
||||||
virBufferFreeAndReset(&filterbuf);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return virBufferContentAndReset(&filterbuf);
|
return virBufferContentAndReset(&filterbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1185,9 +1180,6 @@ virLogGetOutputs(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virBufferError(&outputbuf))
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
virLogUnlock();
|
virLogUnlock();
|
||||||
return virBufferContentAndReset(&outputbuf);
|
return virBufferContentAndReset(&outputbuf);
|
||||||
|
|
||||||
|
@ -268,10 +268,6 @@ cpuTestGuestCPU(const void *arg)
|
|||||||
virBufferAsprintf(&buf, ",%s", data->modelsName);
|
virBufferAsprintf(&buf, ",%s", data->modelsName);
|
||||||
virBufferAddLit(&buf, "-result");
|
virBufferAddLit(&buf, "-result");
|
||||||
|
|
||||||
if (virBufferError(&buf)) {
|
|
||||||
virBufferFreeAndReset(&buf);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
result = virBufferContentAndReset(&buf);
|
result = virBufferContentAndReset(&buf);
|
||||||
|
|
||||||
if (cpuTestCompareXML(data->arch, cpu, result) < 0)
|
if (cpuTestCompareXML(data->arch, cpu, result) < 0)
|
||||||
|
@ -76,9 +76,6 @@ static int testCompareXMLToArgvFiles(const char *xml,
|
|||||||
if (networkAddFirewallRules(def) < 0)
|
if (networkAddFirewallRules(def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virBufferError(&buf))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
actual = actualargv = virBufferContentAndReset(&buf);
|
actual = actualargv = virBufferContentAndReset(&buf);
|
||||||
virTestClearCommandPath(actualargv);
|
virTestClearCommandPath(actualargv);
|
||||||
virCommandSetDryRun(NULL, NULL, NULL);
|
virCommandSetDryRun(NULL, NULL, NULL);
|
||||||
|
@ -109,9 +109,6 @@ testNWFilterEBIPTablesAllTeardown(const void *opaque G_GNUC_UNUSED)
|
|||||||
if (ebiptables_driver.allTeardown("vnet0") < 0)
|
if (ebiptables_driver.allTeardown("vnet0") < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virBufferError(&buf))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
actual = virBufferContentAndReset(&buf);
|
actual = virBufferContentAndReset(&buf);
|
||||||
virTestClearCommandPath(actual);
|
virTestClearCommandPath(actual);
|
||||||
|
|
||||||
@ -180,9 +177,6 @@ testNWFilterEBIPTablesTearOldRules(const void *opaque G_GNUC_UNUSED)
|
|||||||
if (ebiptables_driver.tearOldRules("vnet0") < 0)
|
if (ebiptables_driver.tearOldRules("vnet0") < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virBufferError(&buf))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
actual = virBufferContentAndReset(&buf);
|
actual = virBufferContentAndReset(&buf);
|
||||||
virTestClearCommandPath(actual);
|
virTestClearCommandPath(actual);
|
||||||
|
|
||||||
@ -229,9 +223,6 @@ testNWFilterEBIPTablesRemoveBasicRules(const void *opaque G_GNUC_UNUSED)
|
|||||||
if (ebiptables_driver.removeBasicRules("vnet0") < 0)
|
if (ebiptables_driver.removeBasicRules("vnet0") < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virBufferError(&buf))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
actual = virBufferContentAndReset(&buf);
|
actual = virBufferContentAndReset(&buf);
|
||||||
virTestClearCommandPath(actual);
|
virTestClearCommandPath(actual);
|
||||||
|
|
||||||
@ -263,9 +254,6 @@ testNWFilterEBIPTablesTearNewRules(const void *opaque G_GNUC_UNUSED)
|
|||||||
if (ebiptables_driver.tearNewRules("vnet0") < 0)
|
if (ebiptables_driver.tearNewRules("vnet0") < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virBufferError(&buf))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
actual = virBufferContentAndReset(&buf);
|
actual = virBufferContentAndReset(&buf);
|
||||||
virTestClearCommandPath(actual);
|
virTestClearCommandPath(actual);
|
||||||
|
|
||||||
@ -335,9 +323,6 @@ testNWFilterEBIPTablesApplyBasicRules(const void *opaque G_GNUC_UNUSED)
|
|||||||
if (ebiptables_driver.applyBasicRules("vnet0", &mac) < 0)
|
if (ebiptables_driver.applyBasicRules("vnet0", &mac) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virBufferError(&buf))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
actual = virBufferContentAndReset(&buf);
|
actual = virBufferContentAndReset(&buf);
|
||||||
virTestClearCommandPath(actual);
|
virTestClearCommandPath(actual);
|
||||||
|
|
||||||
@ -425,9 +410,6 @@ testNWFilterEBIPTablesApplyDHCPOnlyRules(const void *opaque G_GNUC_UNUSED)
|
|||||||
if (ebiptables_driver.applyDHCPOnlyRules("vnet0", &mac, &val, false) < 0)
|
if (ebiptables_driver.applyDHCPOnlyRules("vnet0", &mac, &val, false) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virBufferError(&buf))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
actual = virBufferContentAndReset(&buf);
|
actual = virBufferContentAndReset(&buf);
|
||||||
virTestClearCommandPath(actual);
|
virTestClearCommandPath(actual);
|
||||||
|
|
||||||
@ -498,9 +480,6 @@ testNWFilterEBIPTablesApplyDropAllRules(const void *opaque G_GNUC_UNUSED)
|
|||||||
if (ebiptables_driver.applyDropAllRules("vnet0") < 0)
|
if (ebiptables_driver.applyDropAllRules("vnet0") < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virBufferError(&buf))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
actual = virBufferContentAndReset(&buf);
|
actual = virBufferContentAndReset(&buf);
|
||||||
virTestClearCommandPath(actual);
|
virTestClearCommandPath(actual);
|
||||||
|
|
||||||
|
@ -394,9 +394,6 @@ static int testCompareXMLToArgvFiles(const char *xml,
|
|||||||
if (ebiptables_driver.applyNewRules("vnet0", inst.rules, inst.nrules) < 0)
|
if (ebiptables_driver.applyNewRules("vnet0", inst.rules, inst.nrules) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virBufferError(&buf))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
actualargv = virBufferContentAndReset(&buf);
|
actualargv = virBufferContentAndReset(&buf);
|
||||||
virTestClearCommandPath(actualargv);
|
virTestClearCommandPath(actualargv);
|
||||||
virCommandSetDryRun(NULL, NULL, NULL);
|
virCommandSetDryRun(NULL, NULL, NULL);
|
||||||
|
@ -763,8 +763,6 @@ virTestLogContentAndReset(void)
|
|||||||
{
|
{
|
||||||
char *ret;
|
char *ret;
|
||||||
|
|
||||||
if (virBufferError(&testLog.buf))
|
|
||||||
return NULL;
|
|
||||||
ret = virBufferContentAndReset(&testLog.buf);
|
ret = virBufferContentAndReset(&testLog.buf);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ret = g_strdup("");
|
ret = g_strdup("");
|
||||||
|
@ -36,11 +36,6 @@ testFilterXML(char *xml)
|
|||||||
virBufferStrcat(&buf, *xmlLine, "\n", NULL);
|
virBufferStrcat(&buf, *xmlLine, "\n", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virBufferError(&buf)) {
|
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = virBufferContentAndReset(&buf);
|
ret = virBufferContentAndReset(&buf);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
@ -29,15 +29,13 @@ static int testBufAutoIndent(const void *data G_GNUC_UNUSED)
|
|||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
if (virBufferGetIndent(buf) != 3 ||
|
if (virBufferGetIndent(buf) != 3 ||
|
||||||
virBufferGetEffectiveIndent(buf) != 3 ||
|
virBufferGetEffectiveIndent(buf) != 3) {
|
||||||
virBufferError(buf)) {
|
|
||||||
VIR_TEST_DEBUG("Wrong indentation");
|
VIR_TEST_DEBUG("Wrong indentation");
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
virBufferAdjustIndent(buf, -2);
|
virBufferAdjustIndent(buf, -2);
|
||||||
if (virBufferGetIndent(buf) != 1 ||
|
if (virBufferGetIndent(buf) != 1 ||
|
||||||
virBufferGetEffectiveIndent(buf) != 1 ||
|
virBufferGetEffectiveIndent(buf) != 1) {
|
||||||
virBufferError(buf)) {
|
|
||||||
VIR_TEST_DEBUG("Wrong indentation");
|
VIR_TEST_DEBUG("Wrong indentation");
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
@ -50,17 +48,12 @@ static int testBufAutoIndent(const void *data G_GNUC_UNUSED)
|
|||||||
virBufferAdjustIndent(buf, 3);
|
virBufferAdjustIndent(buf, 3);
|
||||||
virBufferFreeAndReset(buf);
|
virBufferFreeAndReset(buf);
|
||||||
if (virBufferGetIndent(buf) != 0 ||
|
if (virBufferGetIndent(buf) != 0 ||
|
||||||
virBufferGetEffectiveIndent(buf) != 0 ||
|
virBufferGetEffectiveIndent(buf) != 0) {
|
||||||
virBufferError(buf)) {
|
|
||||||
VIR_TEST_DEBUG("Reset didn't clear indentation");
|
VIR_TEST_DEBUG("Reset didn't clear indentation");
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
virBufferAdjustIndent(buf, 2);
|
virBufferAdjustIndent(buf, 2);
|
||||||
virBufferAddLit(buf, "1");
|
virBufferAddLit(buf, "1");
|
||||||
if (virBufferError(buf)) {
|
|
||||||
VIR_TEST_DEBUG("Buffer had error");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (STRNEQ(virBufferCurrentContent(buf), " 1")) {
|
if (STRNEQ(virBufferCurrentContent(buf), " 1")) {
|
||||||
VIR_TEST_DEBUG("Wrong content");
|
VIR_TEST_DEBUG("Wrong content");
|
||||||
ret = -1;
|
ret = -1;
|
||||||
@ -87,11 +80,6 @@ static int testBufAutoIndent(const void *data G_GNUC_UNUSED)
|
|||||||
virBufferEscapeShell(buf, " 11");
|
virBufferEscapeShell(buf, " 11");
|
||||||
virBufferAddChar(buf, '\n');
|
virBufferAddChar(buf, '\n');
|
||||||
|
|
||||||
if (virBufferError(buf)) {
|
|
||||||
VIR_TEST_DEBUG("Buffer had error");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = virBufferContentAndReset(buf);
|
result = virBufferContentAndReset(buf);
|
||||||
if (!result || STRNEQ(result, expected)) {
|
if (!result || STRNEQ(result, expected)) {
|
||||||
virTestDifference(stderr, expected, result);
|
virTestDifference(stderr, expected, result);
|
||||||
@ -125,11 +113,6 @@ static int testBufTrim(const void *data G_GNUC_UNUSED)
|
|||||||
virBufferTrim(buf, "b,,", 1);
|
virBufferTrim(buf, "b,,", 1);
|
||||||
virBufferTrim(buf, ",", -1);
|
virBufferTrim(buf, ",", -1);
|
||||||
|
|
||||||
if (virBufferError(buf)) {
|
|
||||||
VIR_TEST_DEBUG("Buffer had error");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = virBufferContentAndReset(buf);
|
result = virBufferContentAndReset(buf);
|
||||||
if (!result || STRNEQ(result, expected)) {
|
if (!result || STRNEQ(result, expected)) {
|
||||||
virTestDifference(stderr, expected, result);
|
virTestDifference(stderr, expected, result);
|
||||||
|
@ -234,9 +234,6 @@ testFirewallSingleGroup(const void *opaque)
|
|||||||
if (virFirewallApply(fw) < 0)
|
if (virFirewallApply(fw) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virBufferError(&cmdbuf))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
actual = virBufferCurrentContent(&cmdbuf);
|
actual = virBufferCurrentContent(&cmdbuf);
|
||||||
|
|
||||||
if (STRNEQ_NULLABLE(expected, actual)) {
|
if (STRNEQ_NULLABLE(expected, actual)) {
|
||||||
@ -300,9 +297,6 @@ testFirewallRemoveRule(const void *opaque)
|
|||||||
if (virFirewallApply(fw) < 0)
|
if (virFirewallApply(fw) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virBufferError(&cmdbuf))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
actual = virBufferCurrentContent(&cmdbuf);
|
actual = virBufferCurrentContent(&cmdbuf);
|
||||||
|
|
||||||
if (STRNEQ_NULLABLE(expected, actual)) {
|
if (STRNEQ_NULLABLE(expected, actual)) {
|
||||||
@ -373,9 +367,6 @@ testFirewallManyGroups(const void *opaque G_GNUC_UNUSED)
|
|||||||
if (virFirewallApply(fw) < 0)
|
if (virFirewallApply(fw) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virBufferError(&cmdbuf))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
actual = virBufferCurrentContent(&cmdbuf);
|
actual = virBufferCurrentContent(&cmdbuf);
|
||||||
|
|
||||||
if (STRNEQ_NULLABLE(expected, actual)) {
|
if (STRNEQ_NULLABLE(expected, actual)) {
|
||||||
@ -469,9 +460,6 @@ testFirewallIgnoreFailGroup(const void *opaque G_GNUC_UNUSED)
|
|||||||
if (virFirewallApply(fw) < 0)
|
if (virFirewallApply(fw) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virBufferError(&cmdbuf))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
actual = virBufferCurrentContent(&cmdbuf);
|
actual = virBufferCurrentContent(&cmdbuf);
|
||||||
|
|
||||||
if (STRNEQ_NULLABLE(expected, actual)) {
|
if (STRNEQ_NULLABLE(expected, actual)) {
|
||||||
@ -543,9 +531,6 @@ testFirewallIgnoreFailRule(const void *opaque G_GNUC_UNUSED)
|
|||||||
if (virFirewallApply(fw) < 0)
|
if (virFirewallApply(fw) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virBufferError(&cmdbuf))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
actual = virBufferCurrentContent(&cmdbuf);
|
actual = virBufferCurrentContent(&cmdbuf);
|
||||||
|
|
||||||
if (STRNEQ_NULLABLE(expected, actual)) {
|
if (STRNEQ_NULLABLE(expected, actual)) {
|
||||||
@ -611,9 +596,6 @@ testFirewallNoRollback(const void *opaque G_GNUC_UNUSED)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virBufferError(&cmdbuf))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
actual = virBufferCurrentContent(&cmdbuf);
|
actual = virBufferCurrentContent(&cmdbuf);
|
||||||
|
|
||||||
if (STRNEQ_NULLABLE(expected, actual)) {
|
if (STRNEQ_NULLABLE(expected, actual)) {
|
||||||
@ -698,9 +680,6 @@ testFirewallSingleRollback(const void *opaque G_GNUC_UNUSED)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virBufferError(&cmdbuf))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
actual = virBufferCurrentContent(&cmdbuf);
|
actual = virBufferCurrentContent(&cmdbuf);
|
||||||
|
|
||||||
if (STRNEQ_NULLABLE(expected, actual)) {
|
if (STRNEQ_NULLABLE(expected, actual)) {
|
||||||
@ -788,9 +767,6 @@ testFirewallManyRollback(const void *opaque G_GNUC_UNUSED)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virBufferError(&cmdbuf))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
actual = virBufferCurrentContent(&cmdbuf);
|
actual = virBufferCurrentContent(&cmdbuf);
|
||||||
|
|
||||||
if (STRNEQ_NULLABLE(expected, actual)) {
|
if (STRNEQ_NULLABLE(expected, actual)) {
|
||||||
@ -908,9 +884,6 @@ testFirewallChainedRollback(const void *opaque G_GNUC_UNUSED)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virBufferError(&cmdbuf))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
actual = virBufferCurrentContent(&cmdbuf);
|
actual = virBufferCurrentContent(&cmdbuf);
|
||||||
|
|
||||||
if (STRNEQ_NULLABLE(expected, actual)) {
|
if (STRNEQ_NULLABLE(expected, actual)) {
|
||||||
@ -1085,9 +1058,6 @@ testFirewallQuery(const void *opaque G_GNUC_UNUSED)
|
|||||||
if (virFirewallApply(fw) < 0)
|
if (virFirewallApply(fw) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virBufferError(&cmdbuf))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
actual = virBufferCurrentContent(&cmdbuf);
|
actual = virBufferCurrentContent(&cmdbuf);
|
||||||
|
|
||||||
if (expectedLineError) {
|
if (expectedLineError) {
|
||||||
|
@ -69,11 +69,7 @@ checkOutput(virBufferPtr buf, const char *exp_cmd)
|
|||||||
char *actual_cmd = NULL;
|
char *actual_cmd = NULL;
|
||||||
|
|
||||||
if (!(actual_cmd = virBufferContentAndReset(buf))) {
|
if (!(actual_cmd = virBufferContentAndReset(buf))) {
|
||||||
int err = virBufferError(buf);
|
fprintf(stderr, "cannot compare buffer to exp: %s", exp_cmd);
|
||||||
if (err)
|
|
||||||
fprintf(stderr, "buffer's in error state: %d", err);
|
|
||||||
else
|
|
||||||
fprintf(stderr, "cannot compare buffer to exp: %s", exp_cmd);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,11 +84,6 @@ testVirNetDevBandwidthSet(const void *data)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!(actual_cmd = virBufferContentAndReset(&buf))) {
|
if (!(actual_cmd = virBufferContentAndReset(&buf))) {
|
||||||
int err = virBufferError(&buf);
|
|
||||||
if (err) {
|
|
||||||
fprintf(stderr, "buffer's in error state: %d", err);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
/* This is interesting, no command has been executed.
|
/* This is interesting, no command has been executed.
|
||||||
* Maybe that's expected, actually. */
|
* Maybe that's expected, actually. */
|
||||||
}
|
}
|
||||||
|
@ -570,9 +570,6 @@ testActivation(bool useNames)
|
|||||||
setenv("LISTEN_FDS", nfdstr, 1);
|
setenv("LISTEN_FDS", nfdstr, 1);
|
||||||
setenv("LISTEN_PID", pidstr, 1);
|
setenv("LISTEN_PID", pidstr, 1);
|
||||||
|
|
||||||
if (virBufferError(&names))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (useNames)
|
if (useNames)
|
||||||
setenv("LISTEN_FDNAMES", virBufferCurrentContent(&names), 1);
|
setenv("LISTEN_FDNAMES", virBufferCurrentContent(&names), 1);
|
||||||
else
|
else
|
||||||
|
@ -267,11 +267,6 @@ cmdCheckpointCreateAs(vshControl *ctl,
|
|||||||
virBufferAdjustIndent(&buf, -2);
|
virBufferAdjustIndent(&buf, -2);
|
||||||
virBufferAddLit(&buf, "</domaincheckpoint>\n");
|
virBufferAddLit(&buf, "</domaincheckpoint>\n");
|
||||||
|
|
||||||
if (virBufferError(&buf)) {
|
|
||||||
vshError(ctl, "%s", _("Out of memory"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer = virBufferContentAndReset(&buf);
|
buffer = virBufferContentAndReset(&buf);
|
||||||
|
|
||||||
if (vshCommandOptBool(cmd, "print-xml")) {
|
if (vshCommandOptBool(cmd, "print-xml")) {
|
||||||
|
@ -2410,12 +2410,6 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
|
|||||||
type, iface->addrs[j].addr,
|
type, iface->addrs[j].addr,
|
||||||
iface->addrs[j].prefix);
|
iface->addrs[j].prefix);
|
||||||
|
|
||||||
if (virBufferError(&buf)) {
|
|
||||||
virBufferFreeAndReset(&buf);
|
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
ip_addr_str = virBufferContentAndReset(&buf);
|
ip_addr_str = virBufferContentAndReset(&buf);
|
||||||
|
|
||||||
if (!ip_addr_str)
|
if (!ip_addr_str)
|
||||||
|
@ -754,11 +754,6 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
|
|||||||
virBufferAdjustIndent(&buf, -2);
|
virBufferAdjustIndent(&buf, -2);
|
||||||
virBufferAddLit(&buf, "</disk>\n");
|
virBufferAddLit(&buf, "</disk>\n");
|
||||||
|
|
||||||
if (virBufferError(&buf)) {
|
|
||||||
vshError(ctl, "%s", _("Failed to allocate XML buffer"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
xml = virBufferContentAndReset(&buf);
|
xml = virBufferContentAndReset(&buf);
|
||||||
|
|
||||||
if (vshCommandOptBool(cmd, "print-xml")) {
|
if (vshCommandOptBool(cmd, "print-xml")) {
|
||||||
@ -1072,11 +1067,6 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
|
|||||||
virBufferAdjustIndent(&buf, -2);
|
virBufferAdjustIndent(&buf, -2);
|
||||||
virBufferAddLit(&buf, "</interface>\n");
|
virBufferAddLit(&buf, "</interface>\n");
|
||||||
|
|
||||||
if (virBufferError(&buf)) {
|
|
||||||
vshError(ctl, "%s", _("Failed to allocate XML buffer"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
xml = virBufferContentAndReset(&buf);
|
xml = virBufferContentAndReset(&buf);
|
||||||
|
|
||||||
if (vshCommandOptBool(cmd, "print-xml")) {
|
if (vshCommandOptBool(cmd, "print-xml")) {
|
||||||
@ -8396,10 +8386,6 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd)
|
|||||||
|
|
||||||
virBufferTrim(&buf, " ", -1);
|
virBufferTrim(&buf, " ", -1);
|
||||||
|
|
||||||
if (virBufferError(&buf)) {
|
|
||||||
vshError(ctl, "%s", _("Failed to collect new description/title"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
desc = virBufferContentAndReset(&buf);
|
desc = virBufferContentAndReset(&buf);
|
||||||
|
|
||||||
if (edit || desc) {
|
if (edit || desc) {
|
||||||
@ -9517,10 +9503,6 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd)
|
|||||||
|
|
||||||
virBufferTrim(&buf, " ", -1);
|
virBufferTrim(&buf, " ", -1);
|
||||||
|
|
||||||
if (virBufferError(&buf)) {
|
|
||||||
vshError(ctl, "%s", _("Failed to collect command"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
monitor_cmd = virBufferContentAndReset(&buf);
|
monitor_cmd = virBufferContentAndReset(&buf);
|
||||||
|
|
||||||
if (vshCommandOptBool(cmd, "hmp"))
|
if (vshCommandOptBool(cmd, "hmp"))
|
||||||
@ -9818,10 +9800,6 @@ cmdQemuAgentCommand(vshControl *ctl, const vshCmd *cmd)
|
|||||||
|
|
||||||
virBufferTrim(&buf, " ", -1);
|
virBufferTrim(&buf, " ", -1);
|
||||||
|
|
||||||
if (virBufferError(&buf)) {
|
|
||||||
vshError(ctl, "%s", _("Failed to collect command"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
guest_agent_cmd = virBufferContentAndReset(&buf);
|
guest_agent_cmd = virBufferContentAndReset(&buf);
|
||||||
|
|
||||||
judge = vshCommandOptInt(ctl, cmd, "timeout", &timeout);
|
judge = vshCommandOptInt(ctl, cmd, "timeout", &timeout);
|
||||||
@ -11551,12 +11529,6 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
|
|||||||
params = true;
|
params = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ensure we can print our URI */
|
|
||||||
if (virBufferError(&buf)) {
|
|
||||||
vshError(ctl, "%s", _("Failed to create display URI"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Print out our full URI */
|
/* Print out our full URI */
|
||||||
VIR_FREE(output);
|
VIR_FREE(output);
|
||||||
output = virBufferContentAndReset(&buf);
|
output = virBufferContentAndReset(&buf);
|
||||||
|
@ -416,11 +416,6 @@ virshBuildPoolXML(vshControl *ctl,
|
|||||||
virBufferAdjustIndent(&buf, -2);
|
virBufferAdjustIndent(&buf, -2);
|
||||||
virBufferAddLit(&buf, "</pool>\n");
|
virBufferAddLit(&buf, "</pool>\n");
|
||||||
|
|
||||||
if (virBufferError(&buf)) {
|
|
||||||
vshError(ctl, "%s", _("Failed to allocate XML buffer"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
*xml = virBufferContentAndReset(&buf);
|
*xml = virBufferContentAndReset(&buf);
|
||||||
*retname = name;
|
*retname = name;
|
||||||
return true;
|
return true;
|
||||||
@ -1480,10 +1475,6 @@ cmdPoolDiscoverSourcesAs(vshControl * ctl, const vshCmd * cmd G_GNUC_UNUSED)
|
|||||||
}
|
}
|
||||||
virBufferAdjustIndent(&buf, -2);
|
virBufferAdjustIndent(&buf, -2);
|
||||||
virBufferAddLit(&buf, "</source>\n");
|
virBufferAddLit(&buf, "</source>\n");
|
||||||
if (virBufferError(&buf)) {
|
|
||||||
vshError(ctl, "%s", _("Out of memory"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
srcSpec = virBufferContentAndReset(&buf);
|
srcSpec = virBufferContentAndReset(&buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -445,11 +445,6 @@ cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd)
|
|||||||
virBufferAdjustIndent(&buf, -2);
|
virBufferAdjustIndent(&buf, -2);
|
||||||
virBufferAddLit(&buf, "</domainsnapshot>\n");
|
virBufferAddLit(&buf, "</domainsnapshot>\n");
|
||||||
|
|
||||||
if (virBufferError(&buf)) {
|
|
||||||
vshError(ctl, "%s", _("Out of memory"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer = virBufferContentAndReset(&buf);
|
buffer = virBufferContentAndReset(&buf);
|
||||||
|
|
||||||
if (vshCommandOptBool(cmd, "print-xml")) {
|
if (vshCommandOptBool(cmd, "print-xml")) {
|
||||||
|
@ -341,10 +341,6 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
|
|||||||
virBufferAdjustIndent(&buf, -2);
|
virBufferAdjustIndent(&buf, -2);
|
||||||
virBufferAddLit(&buf, "</volume>\n");
|
virBufferAddLit(&buf, "</volume>\n");
|
||||||
|
|
||||||
if (virBufferError(&buf)) {
|
|
||||||
vshError(ctl, "%s", _("Failed to allocate XML buffer"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
xml = virBufferContentAndReset(&buf);
|
xml = virBufferContentAndReset(&buf);
|
||||||
|
|
||||||
if (printXML) {
|
if (printXML) {
|
||||||
|
18
tools/vsh.c
18
tools/vsh.c
@ -2269,9 +2269,6 @@ vshOutputLogFile(vshControl *ctl, int log_level, const char *msg_format,
|
|||||||
virBufferTrim(&buf, "\n", -1);
|
virBufferTrim(&buf, "\n", -1);
|
||||||
virBufferAddChar(&buf, '\n');
|
virBufferAddChar(&buf, '\n');
|
||||||
|
|
||||||
if (virBufferError(&buf))
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
str = virBufferContentAndReset(&buf);
|
str = virBufferContentAndReset(&buf);
|
||||||
len = strlen(str);
|
len = strlen(str);
|
||||||
|
|
||||||
@ -2532,9 +2529,6 @@ vshTreePrintInternal(vshControl *ctl,
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
const char *dev = (lookup)(devid, false, opaque);
|
const char *dev = (lookup)(devid, false, opaque);
|
||||||
|
|
||||||
if (virBufferError(indent))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
/* Print this device, with indent if not at root */
|
/* Print this device, with indent if not at root */
|
||||||
vshPrint(ctl, "%s%s%s\n", virBufferCurrentContent(indent),
|
vshPrint(ctl, "%s%s%s\n", virBufferCurrentContent(indent),
|
||||||
root ? "" : "+- ", dev);
|
root ? "" : "+- ", dev);
|
||||||
@ -2543,8 +2537,6 @@ vshTreePrintInternal(vshControl *ctl,
|
|||||||
if (!root) {
|
if (!root) {
|
||||||
virBufferAddChar(indent, devid == lastdev ? ' ' : '|');
|
virBufferAddChar(indent, devid == lastdev ? ' ' : '|');
|
||||||
virBufferAddChar(indent, ' ');
|
virBufferAddChar(indent, ' ');
|
||||||
if (virBufferError(indent))
|
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Determine the index of the last child device */
|
/* Determine the index of the last child device */
|
||||||
@ -2561,8 +2553,6 @@ vshTreePrintInternal(vshControl *ctl,
|
|||||||
|
|
||||||
/* Finally print all children */
|
/* Finally print all children */
|
||||||
virBufferAddLit(indent, " ");
|
virBufferAddLit(indent, " ");
|
||||||
if (virBufferError(indent))
|
|
||||||
goto cleanup;
|
|
||||||
for (i = 0; i < num_devices; i++) {
|
for (i = 0; i < num_devices; i++) {
|
||||||
const char *parent = (lookup)(i, true, opaque);
|
const char *parent = (lookup)(i, true, opaque);
|
||||||
|
|
||||||
@ -3315,10 +3305,6 @@ cmdEcho(vshControl *ctl, const vshCmd *cmd)
|
|||||||
|
|
||||||
if (xml) {
|
if (xml) {
|
||||||
virBufferEscapeString(&xmlbuf, "%s", arg);
|
virBufferEscapeString(&xmlbuf, "%s", arg);
|
||||||
if (virBufferError(&xmlbuf)) {
|
|
||||||
vshError(ctl, "%s", _("Failed to allocate XML buffer"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
str = virBufferContentAndReset(&xmlbuf);
|
str = virBufferContentAndReset(&xmlbuf);
|
||||||
} else {
|
} else {
|
||||||
str = g_strdup(arg);
|
str = g_strdup(arg);
|
||||||
@ -3332,10 +3318,6 @@ cmdEcho(vshControl *ctl, const vshCmd *cmd)
|
|||||||
VIR_FREE(str);
|
VIR_FREE(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virBufferError(&buf)) {
|
|
||||||
vshError(ctl, "%s", _("Failed to allocate XML buffer"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
arg = virBufferContentAndReset(&buf);
|
arg = virBufferContentAndReset(&buf);
|
||||||
if (arg) {
|
if (arg) {
|
||||||
if (err)
|
if (err)
|
||||||
|
Loading…
Reference in New Issue
Block a user