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>
bool skip_dot = false;
for (; *name; name++) {
- if (virBufferError(buf))
- break;
if (strlen(virBufferCurrentContent(buf)) >= 64)
break;
virBufferCheckErrorInternal;
virBufferContentAndReset;
virBufferCurrentContent;
-virBufferError;
virBufferEscape;
virBufferEscapeRegex;
virBufferEscapeSexpr;
virBuffer buf = VIR_BUFFER_INITIALIZER;
virNWFilterVarAccessPrint(rule->varAccess[j], &buf);
- if (virBufferError(&buf)) {
- virReportOOMError();
- return -1;
- }
val = virNWFilterVarValueCreateSimpleCopyValue("1");
if (!val) {
macaddr);
}
- if (virBufferError(&buf)) {
- req->status = ENOMEM;
- goto done;
- }
-
filter = virBufferContentAndReset(&buf);
if (pcap_compile(handle, &fp, filter, 1, 0) != 0) {
if (vah_add_file(&buf, ctl->newfile, "rwk") != 0)
goto cleanup;
- if (virBufferError(&buf)) {
- virBufferFreeAndReset(&buf);
- vah_error(NULL, 0, _("failed to allocate file buffer"));
- goto cleanup;
- }
-
rc = 0;
ctl->files = virBufferContentAndReset(&buf);
virBufferAdd(&buf, ctl->files, -1);
}
- if (virBufferError(&buf)) {
- virBufferFreeAndReset(&buf);
- vah_error(ctl, 1, _("failed to allocate buffer"));
- }
-
included_files = virBufferContentAndReset(&buf);
/* (re)create the include file using included_files */
start = prev = cur;
}
- if (virBufferError(&buf)) {
- virBufferFreeAndReset(&buf);
- virReportOOMError();
- return NULL;
- }
-
return virBufferContentAndReset(&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:
* @buf: the buffer
const char *virBufferCurrentContent(virBufferPtr buf);
char *virBufferContentAndReset(virBufferPtr buf);
void virBufferFreeAndReset(virBufferPtr buf);
-int virBufferError(const virBuffer *buf);
int virBufferCheckErrorInternal(const virBuffer *buf)
ATTRIBUTE_NONNULL(1);
return;
}
- if (virBufferError(buf)) {
- cmd->has_error = ENOMEM;
- virBufferFreeAndReset(buf);
- return;
- }
if (!virBufferUse(buf)) {
cmd->has_error = EINVAL;
return;
}
/* Arg plus trailing NULL. */
- if (virBufferError(buf) ||
- VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, 1 + 1) < 0) {
+ if (VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, 1 + 1) < 0) {
cmd->has_error = ENOMEM;
virBufferFreeAndReset(buf);
return;
}
virLogUnlock();
- if (virBufferError(&filterbuf)) {
- virBufferFreeAndReset(&filterbuf);
- return NULL;
- }
-
return virBufferContentAndReset(&filterbuf);
}
}
}
- if (virBufferError(&outputbuf))
- goto error;
-
virLogUnlock();
return virBufferContentAndReset(&outputbuf);
virBufferAsprintf(&buf, ",%s", data->modelsName);
virBufferAddLit(&buf, "-result");
- if (virBufferError(&buf)) {
- virBufferFreeAndReset(&buf);
- goto cleanup;
- }
result = virBufferContentAndReset(&buf);
if (cpuTestCompareXML(data->arch, cpu, result) < 0)
if (networkAddFirewallRules(def) < 0)
goto cleanup;
- if (virBufferError(&buf))
- goto cleanup;
-
actual = actualargv = virBufferContentAndReset(&buf);
virTestClearCommandPath(actualargv);
virCommandSetDryRun(NULL, NULL, NULL);
if (ebiptables_driver.allTeardown("vnet0") < 0)
goto cleanup;
- if (virBufferError(&buf))
- goto cleanup;
-
actual = virBufferContentAndReset(&buf);
virTestClearCommandPath(actual);
if (ebiptables_driver.tearOldRules("vnet0") < 0)
goto cleanup;
- if (virBufferError(&buf))
- goto cleanup;
-
actual = virBufferContentAndReset(&buf);
virTestClearCommandPath(actual);
if (ebiptables_driver.removeBasicRules("vnet0") < 0)
goto cleanup;
- if (virBufferError(&buf))
- goto cleanup;
-
actual = virBufferContentAndReset(&buf);
virTestClearCommandPath(actual);
if (ebiptables_driver.tearNewRules("vnet0") < 0)
goto cleanup;
- if (virBufferError(&buf))
- goto cleanup;
-
actual = virBufferContentAndReset(&buf);
virTestClearCommandPath(actual);
if (ebiptables_driver.applyBasicRules("vnet0", &mac) < 0)
goto cleanup;
- if (virBufferError(&buf))
- goto cleanup;
-
actual = virBufferContentAndReset(&buf);
virTestClearCommandPath(actual);
if (ebiptables_driver.applyDHCPOnlyRules("vnet0", &mac, &val, false) < 0)
goto cleanup;
- if (virBufferError(&buf))
- goto cleanup;
-
actual = virBufferContentAndReset(&buf);
virTestClearCommandPath(actual);
if (ebiptables_driver.applyDropAllRules("vnet0") < 0)
goto cleanup;
- if (virBufferError(&buf))
- goto cleanup;
-
actual = virBufferContentAndReset(&buf);
virTestClearCommandPath(actual);
if (ebiptables_driver.applyNewRules("vnet0", inst.rules, inst.nrules) < 0)
goto cleanup;
- if (virBufferError(&buf))
- goto cleanup;
-
actualargv = virBufferContentAndReset(&buf);
virTestClearCommandPath(actualargv);
virCommandSetDryRun(NULL, NULL, NULL);
{
char *ret;
- if (virBufferError(&testLog.buf))
- return NULL;
ret = virBufferContentAndReset(&testLog.buf);
if (!ret)
ret = g_strdup("");
virBufferStrcat(&buf, *xmlLine, "\n", NULL);
}
- if (virBufferError(&buf)) {
- virReportOOMError();
- goto cleanup;
- }
-
ret = virBufferContentAndReset(&buf);
cleanup:
ret = -1;
}
if (virBufferGetIndent(buf) != 3 ||
- virBufferGetEffectiveIndent(buf) != 3 ||
- virBufferError(buf)) {
+ virBufferGetEffectiveIndent(buf) != 3) {
VIR_TEST_DEBUG("Wrong indentation");
ret = -1;
}
virBufferAdjustIndent(buf, -2);
if (virBufferGetIndent(buf) != 1 ||
- virBufferGetEffectiveIndent(buf) != 1 ||
- virBufferError(buf)) {
+ virBufferGetEffectiveIndent(buf) != 1) {
VIR_TEST_DEBUG("Wrong indentation");
ret = -1;
}
virBufferAdjustIndent(buf, 3);
virBufferFreeAndReset(buf);
if (virBufferGetIndent(buf) != 0 ||
- virBufferGetEffectiveIndent(buf) != 0 ||
- virBufferError(buf)) {
+ virBufferGetEffectiveIndent(buf) != 0) {
VIR_TEST_DEBUG("Reset didn't clear indentation");
ret = -1;
}
virBufferAdjustIndent(buf, 2);
virBufferAddLit(buf, "1");
- if (virBufferError(buf)) {
- VIR_TEST_DEBUG("Buffer had error");
- return -1;
- }
if (STRNEQ(virBufferCurrentContent(buf), " 1")) {
VIR_TEST_DEBUG("Wrong content");
ret = -1;
virBufferEscapeShell(buf, " 11");
virBufferAddChar(buf, '\n');
- if (virBufferError(buf)) {
- VIR_TEST_DEBUG("Buffer had error");
- return -1;
- }
-
result = virBufferContentAndReset(buf);
if (!result || STRNEQ(result, expected)) {
virTestDifference(stderr, expected, result);
virBufferTrim(buf, "b,,", 1);
virBufferTrim(buf, ",", -1);
- if (virBufferError(buf)) {
- VIR_TEST_DEBUG("Buffer had error");
- return -1;
- }
-
result = virBufferContentAndReset(buf);
if (!result || STRNEQ(result, expected)) {
virTestDifference(stderr, expected, result);
if (virFirewallApply(fw) < 0)
goto cleanup;
- if (virBufferError(&cmdbuf))
- goto cleanup;
-
actual = virBufferCurrentContent(&cmdbuf);
if (STRNEQ_NULLABLE(expected, actual)) {
if (virFirewallApply(fw) < 0)
goto cleanup;
- if (virBufferError(&cmdbuf))
- goto cleanup;
-
actual = virBufferCurrentContent(&cmdbuf);
if (STRNEQ_NULLABLE(expected, actual)) {
if (virFirewallApply(fw) < 0)
goto cleanup;
- if (virBufferError(&cmdbuf))
- goto cleanup;
-
actual = virBufferCurrentContent(&cmdbuf);
if (STRNEQ_NULLABLE(expected, actual)) {
if (virFirewallApply(fw) < 0)
goto cleanup;
- if (virBufferError(&cmdbuf))
- goto cleanup;
-
actual = virBufferCurrentContent(&cmdbuf);
if (STRNEQ_NULLABLE(expected, actual)) {
if (virFirewallApply(fw) < 0)
goto cleanup;
- if (virBufferError(&cmdbuf))
- goto cleanup;
-
actual = virBufferCurrentContent(&cmdbuf);
if (STRNEQ_NULLABLE(expected, actual)) {
goto cleanup;
}
- if (virBufferError(&cmdbuf))
- goto cleanup;
-
actual = virBufferCurrentContent(&cmdbuf);
if (STRNEQ_NULLABLE(expected, actual)) {
goto cleanup;
}
- if (virBufferError(&cmdbuf))
- goto cleanup;
-
actual = virBufferCurrentContent(&cmdbuf);
if (STRNEQ_NULLABLE(expected, actual)) {
goto cleanup;
}
- if (virBufferError(&cmdbuf))
- goto cleanup;
-
actual = virBufferCurrentContent(&cmdbuf);
if (STRNEQ_NULLABLE(expected, actual)) {
goto cleanup;
}
- if (virBufferError(&cmdbuf))
- goto cleanup;
-
actual = virBufferCurrentContent(&cmdbuf);
if (STRNEQ_NULLABLE(expected, actual)) {
if (virFirewallApply(fw) < 0)
goto cleanup;
- if (virBufferError(&cmdbuf))
- goto cleanup;
-
actual = virBufferCurrentContent(&cmdbuf);
if (expectedLineError) {
char *actual_cmd = NULL;
if (!(actual_cmd = virBufferContentAndReset(buf))) {
- int err = virBufferError(buf);
- if (err)
- fprintf(stderr, "buffer's in error state: %d", err);
- else
- fprintf(stderr, "cannot compare buffer to exp: %s", exp_cmd);
+ fprintf(stderr, "cannot compare buffer to exp: %s", exp_cmd);
goto cleanup;
}
goto cleanup;
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.
* Maybe that's expected, actually. */
}
setenv("LISTEN_FDS", nfdstr, 1);
setenv("LISTEN_PID", pidstr, 1);
- if (virBufferError(&names))
- goto cleanup;
-
if (useNames)
setenv("LISTEN_FDNAMES", virBufferCurrentContent(&names), 1);
else
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</domaincheckpoint>\n");
- if (virBufferError(&buf)) {
- vshError(ctl, "%s", _("Out of memory"));
- goto cleanup;
- }
-
buffer = virBufferContentAndReset(&buf);
if (vshCommandOptBool(cmd, "print-xml")) {
type, iface->addrs[j].addr,
iface->addrs[j].prefix);
- if (virBufferError(&buf)) {
- virBufferFreeAndReset(&buf);
- virReportOOMError();
- goto cleanup;
- }
-
ip_addr_str = virBufferContentAndReset(&buf);
if (!ip_addr_str)
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</disk>\n");
- if (virBufferError(&buf)) {
- vshError(ctl, "%s", _("Failed to allocate XML buffer"));
- goto cleanup;
- }
-
xml = virBufferContentAndReset(&buf);
if (vshCommandOptBool(cmd, "print-xml")) {
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</interface>\n");
- if (virBufferError(&buf)) {
- vshError(ctl, "%s", _("Failed to allocate XML buffer"));
- goto cleanup;
- }
-
xml = virBufferContentAndReset(&buf);
if (vshCommandOptBool(cmd, "print-xml")) {
virBufferTrim(&buf, " ", -1);
- if (virBufferError(&buf)) {
- vshError(ctl, "%s", _("Failed to collect new description/title"));
- goto cleanup;
- }
desc = virBufferContentAndReset(&buf);
if (edit || desc) {
virBufferTrim(&buf, " ", -1);
- if (virBufferError(&buf)) {
- vshError(ctl, "%s", _("Failed to collect command"));
- return false;
- }
monitor_cmd = virBufferContentAndReset(&buf);
if (vshCommandOptBool(cmd, "hmp"))
virBufferTrim(&buf, " ", -1);
- if (virBufferError(&buf)) {
- vshError(ctl, "%s", _("Failed to collect command"));
- goto cleanup;
- }
guest_agent_cmd = virBufferContentAndReset(&buf);
judge = vshCommandOptInt(ctl, cmd, "timeout", &timeout);
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 */
VIR_FREE(output);
output = virBufferContentAndReset(&buf);
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</pool>\n");
- if (virBufferError(&buf)) {
- vshError(ctl, "%s", _("Failed to allocate XML buffer"));
- return false;
- }
-
*xml = virBufferContentAndReset(&buf);
*retname = name;
return true;
}
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</source>\n");
- if (virBufferError(&buf)) {
- vshError(ctl, "%s", _("Out of memory"));
- return false;
- }
srcSpec = virBufferContentAndReset(&buf);
}
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</domainsnapshot>\n");
- if (virBufferError(&buf)) {
- vshError(ctl, "%s", _("Out of memory"));
- goto cleanup;
- }
-
buffer = virBufferContentAndReset(&buf);
if (vshCommandOptBool(cmd, "print-xml")) {
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</volume>\n");
- if (virBufferError(&buf)) {
- vshError(ctl, "%s", _("Failed to allocate XML buffer"));
- goto cleanup;
- }
xml = virBufferContentAndReset(&buf);
if (printXML) {
virBufferTrim(&buf, "\n", -1);
virBufferAddChar(&buf, '\n');
- if (virBufferError(&buf))
- goto error;
-
str = virBufferContentAndReset(&buf);
len = strlen(str);
int ret = -1;
const char *dev = (lookup)(devid, false, opaque);
- if (virBufferError(indent))
- goto cleanup;
-
/* Print this device, with indent if not at root */
vshPrint(ctl, "%s%s%s\n", virBufferCurrentContent(indent),
root ? "" : "+- ", dev);
if (!root) {
virBufferAddChar(indent, devid == lastdev ? ' ' : '|');
virBufferAddChar(indent, ' ');
- if (virBufferError(indent))
- goto cleanup;
}
/* Determine the index of the last child device */
/* Finally print all children */
virBufferAddLit(indent, " ");
- if (virBufferError(indent))
- goto cleanup;
for (i = 0; i < num_devices; i++) {
const char *parent = (lookup)(i, true, opaque);
if (xml) {
virBufferEscapeString(&xmlbuf, "%s", arg);
- if (virBufferError(&xmlbuf)) {
- vshError(ctl, "%s", _("Failed to allocate XML buffer"));
- return false;
- }
str = virBufferContentAndReset(&xmlbuf);
} else {
str = g_strdup(arg);
VIR_FREE(str);
}
- if (virBufferError(&buf)) {
- vshError(ctl, "%s", _("Failed to allocate XML buffer"));
- return false;
- }
arg = virBufferContentAndReset(&buf);
if (arg) {
if (err)