[PATCH 17/19] util: buffer: Remove virBufferError

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The function now never returned an error so we can drop it fully.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/conf/domain_conf.c                 |  2 --
 src/libvirt_private.syms               |  1 -
 src/nwfilter/nwfilter_gentech_driver.c |  4 ----
 src/nwfilter/nwfilter_learnipaddr.c    |  5 -----
 src/security/virt-aa-helper.c          | 11 ----------
 src/util/virbitmap.c                   |  6 ------
 src/util/virbuffer.c                   | 15 -------------
 src/util/virbuffer.h                   |  1 -
 src/util/vircommand.c                  |  8 +------
 src/util/virlog.c                      |  8 -------
 tests/cputest.c                        |  4 ----
 tests/networkxml2firewalltest.c        |  3 ---
 tests/nwfilterebiptablestest.c         | 21 ------------------
 tests/nwfilterxml2firewalltest.c       |  3 ---
 tests/testutils.c                      |  2 --
 tests/vboxsnapshotxmltest.c            |  5 -----
 tests/virbuftest.c                     | 23 +++-----------------
 tests/virfirewalltest.c                | 30 --------------------------
 tests/virkmodtest.c                    |  6 +-----
 tests/virnetdevbandwidthtest.c         |  5 -----
 tests/virsystemdtest.c                 |  3 ---
 tools/virsh-checkpoint.c               |  5 -----
 tools/virsh-domain-monitor.c           |  6 ------
 tools/virsh-domain.c                   | 28 ------------------------
 tools/virsh-pool.c                     |  9 --------
 tools/virsh-snapshot.c                 |  5 -----
 tools/virsh-volume.c                   |  4 ----
 tools/vsh.c                            | 18 ----------------
 28 files changed, 5 insertions(+), 236 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 81006119aa..1fb538b9a8 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -30527,8 +30527,6 @@ virDomainMachineNameAppendValid(virBufferPtr buf,
     bool skip_dot = false;

     for (; *name; name++) {
-        if (virBufferError(buf))
-            break;
         if (strlen(virBufferCurrentContent(buf)) >= 64)
             break;

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 94c2e4ef6a..089b28f85b 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1592,7 +1592,6 @@ virBufferAsprintf;
 virBufferCheckErrorInternal;
 virBufferContentAndReset;
 virBufferCurrentContent;
-virBufferError;
 virBufferEscape;
 virBufferEscapeRegex;
 virBufferEscapeSexpr;
diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter_gentech_driver.c
index d39f1ecb6d..0366deaf8b 100644
--- a/src/nwfilter/nwfilter_gentech_driver.c
+++ b/src/nwfilter/nwfilter_gentech_driver.c
@@ -431,10 +431,6 @@ virNWFilterDetermineMissingVarsRec(virNWFilterDefPtr filter,
                     virBuffer buf = VIR_BUFFER_INITIALIZER;

                     virNWFilterVarAccessPrint(rule->varAccess[j], &buf);
-                    if (virBufferError(&buf)) {
-                        virReportOOMError();
-                        return -1;
-                    }

                     val = virNWFilterVarValueCreateSimpleCopyValue("1");
                     if (!val) {
diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_learnipaddr.c
index d7754c0c7a..293007300a 100644
--- a/src/nwfilter/nwfilter_learnipaddr.c
+++ b/src/nwfilter/nwfilter_learnipaddr.c
@@ -456,11 +456,6 @@ learnIPAddressThread(void *arg)
                           macaddr);
     }

-    if (virBufferError(&buf)) {
-        req->status = ENOMEM;
-        goto done;
-    }
-
     filter = virBufferContentAndReset(&buf);

     if (pcap_compile(handle, &fp, filter, 1, 0) != 0) {
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index 7d7262ca39..54c07894c8 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -1314,12 +1314,6 @@ get_files(vahControl * ctl)
         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);

@@ -1507,11 +1501,6 @@ main(int argc, char **argv)
                 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 */
diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
index a9d8e6c3d5..80eccaadce 100644
--- a/src/util/virbitmap.c
+++ b/src/util/virbitmap.c
@@ -446,12 +446,6 @@ virBitmapFormat(virBitmapPtr bitmap)
         start = prev = cur;
     }

-    if (virBufferError(&buf)) {
-        virBufferFreeAndReset(&buf);
-        virReportOOMError();
-        return NULL;
-    }
-
     return virBufferContentAndReset(&buf);
 }

diff --git a/src/util/virbuffer.c b/src/util/virbuffer.c
index e6480ca4ef..b513c59268 100644
--- a/src/util/virbuffer.c
+++ b/src/util/virbuffer.c
@@ -276,21 +276,6 @@ void virBufferFreeAndReset(virBufferPtr 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
diff --git a/src/util/virbuffer.h b/src/util/virbuffer.h
index 9adec89f57..c7f0568067 100644
--- a/src/util/virbuffer.h
+++ b/src/util/virbuffer.h
@@ -43,7 +43,6 @@ struct _virBuffer {
 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);

diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index 223a2a824e..6baa0b251f 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -1389,11 +1389,6 @@ virCommandAddEnvBuffer(virCommandPtr cmd, virBufferPtr buf)
         return;
     }

-    if (virBufferError(buf)) {
-        cmd->has_error = ENOMEM;
-        virBufferFreeAndReset(buf);
-        return;
-    }
     if (!virBufferUse(buf)) {
         cmd->has_error = EINVAL;
         return;
@@ -1525,8 +1520,7 @@ virCommandAddArgBuffer(virCommandPtr cmd, virBufferPtr buf)
     }

     /* 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;
diff --git a/src/util/virlog.c b/src/util/virlog.c
index 27843363e7..cf0599c880 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -1137,11 +1137,6 @@ virLogGetFilters(void)
     }
     virLogUnlock();

-    if (virBufferError(&filterbuf)) {
-        virBufferFreeAndReset(&filterbuf);
-        return NULL;
-    }
-
     return virBufferContentAndReset(&filterbuf);
 }

@@ -1185,9 +1180,6 @@ virLogGetOutputs(void)
         }
     }

-    if (virBufferError(&outputbuf))
-        goto error;
-
     virLogUnlock();
     return virBufferContentAndReset(&outputbuf);

diff --git a/tests/cputest.c b/tests/cputest.c
index 83b494857f..a277224918 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -268,10 +268,6 @@ cpuTestGuestCPU(const void *arg)
         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)
diff --git a/tests/networkxml2firewalltest.c b/tests/networkxml2firewalltest.c
index b8e974971a..6822a4f4c2 100644
--- a/tests/networkxml2firewalltest.c
+++ b/tests/networkxml2firewalltest.c
@@ -76,9 +76,6 @@ static int testCompareXMLToArgvFiles(const char *xml,
     if (networkAddFirewallRules(def) < 0)
         goto cleanup;

-    if (virBufferError(&buf))
-        goto cleanup;
-
     actual = actualargv = virBufferContentAndReset(&buf);
     virTestClearCommandPath(actualargv);
     virCommandSetDryRun(NULL, NULL, NULL);
diff --git a/tests/nwfilterebiptablestest.c b/tests/nwfilterebiptablestest.c
index 61b3284397..f7fb03396d 100644
--- a/tests/nwfilterebiptablestest.c
+++ b/tests/nwfilterebiptablestest.c
@@ -109,9 +109,6 @@ testNWFilterEBIPTablesAllTeardown(const void *opaque G_GNUC_UNUSED)
     if (ebiptables_driver.allTeardown("vnet0") < 0)
         goto cleanup;

-    if (virBufferError(&buf))
-        goto cleanup;
-
     actual = virBufferContentAndReset(&buf);
     virTestClearCommandPath(actual);

@@ -180,9 +177,6 @@ testNWFilterEBIPTablesTearOldRules(const void *opaque G_GNUC_UNUSED)
     if (ebiptables_driver.tearOldRules("vnet0") < 0)
         goto cleanup;

-    if (virBufferError(&buf))
-        goto cleanup;
-
     actual = virBufferContentAndReset(&buf);
     virTestClearCommandPath(actual);

@@ -229,9 +223,6 @@ testNWFilterEBIPTablesRemoveBasicRules(const void *opaque G_GNUC_UNUSED)
     if (ebiptables_driver.removeBasicRules("vnet0") < 0)
         goto cleanup;

-    if (virBufferError(&buf))
-        goto cleanup;
-
     actual = virBufferContentAndReset(&buf);
     virTestClearCommandPath(actual);

@@ -263,9 +254,6 @@ testNWFilterEBIPTablesTearNewRules(const void *opaque G_GNUC_UNUSED)
     if (ebiptables_driver.tearNewRules("vnet0") < 0)
         goto cleanup;

-    if (virBufferError(&buf))
-        goto cleanup;
-
     actual = virBufferContentAndReset(&buf);
     virTestClearCommandPath(actual);

@@ -335,9 +323,6 @@ testNWFilterEBIPTablesApplyBasicRules(const void *opaque G_GNUC_UNUSED)
     if (ebiptables_driver.applyBasicRules("vnet0", &mac) < 0)
         goto cleanup;

-    if (virBufferError(&buf))
-        goto cleanup;
-
     actual = virBufferContentAndReset(&buf);
     virTestClearCommandPath(actual);

@@ -425,9 +410,6 @@ testNWFilterEBIPTablesApplyDHCPOnlyRules(const void *opaque G_GNUC_UNUSED)
     if (ebiptables_driver.applyDHCPOnlyRules("vnet0", &mac, &val, false) < 0)
         goto cleanup;

-    if (virBufferError(&buf))
-        goto cleanup;
-
     actual = virBufferContentAndReset(&buf);
     virTestClearCommandPath(actual);

@@ -498,9 +480,6 @@ testNWFilterEBIPTablesApplyDropAllRules(const void *opaque G_GNUC_UNUSED)
     if (ebiptables_driver.applyDropAllRules("vnet0") < 0)
         goto cleanup;

-    if (virBufferError(&buf))
-        goto cleanup;
-
     actual = virBufferContentAndReset(&buf);
     virTestClearCommandPath(actual);

diff --git a/tests/nwfilterxml2firewalltest.c b/tests/nwfilterxml2firewalltest.c
index bef3790da2..6b17a33953 100644
--- a/tests/nwfilterxml2firewalltest.c
+++ b/tests/nwfilterxml2firewalltest.c
@@ -394,9 +394,6 @@ static int testCompareXMLToArgvFiles(const char *xml,
     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);
diff --git a/tests/testutils.c b/tests/testutils.c
index a141abc91b..da236c74a1 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -763,8 +763,6 @@ virTestLogContentAndReset(void)
 {
     char *ret;

-    if (virBufferError(&testLog.buf))
-        return NULL;
     ret = virBufferContentAndReset(&testLog.buf);
     if (!ret)
         ret = g_strdup("");
diff --git a/tests/vboxsnapshotxmltest.c b/tests/vboxsnapshotxmltest.c
index 3d6171e266..38dbba9eff 100644
--- a/tests/vboxsnapshotxmltest.c
+++ b/tests/vboxsnapshotxmltest.c
@@ -36,11 +36,6 @@ testFilterXML(char *xml)
         virBufferStrcat(&buf, *xmlLine, "\n", NULL);
     }

-    if (virBufferError(&buf)) {
-        virReportOOMError();
-        goto cleanup;
-    }
-
     ret = virBufferContentAndReset(&buf);

  cleanup:
diff --git a/tests/virbuftest.c b/tests/virbuftest.c
index 34aa8b678b..56a6ece8f6 100644
--- a/tests/virbuftest.c
+++ b/tests/virbuftest.c
@@ -29,15 +29,13 @@ static int testBufAutoIndent(const void *data G_GNUC_UNUSED)
         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;
     }
@@ -50,17 +48,12 @@ static int testBufAutoIndent(const void *data G_GNUC_UNUSED)
     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;
@@ -87,11 +80,6 @@ static int testBufAutoIndent(const void *data G_GNUC_UNUSED)
     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);
@@ -125,11 +113,6 @@ static int testBufTrim(const void *data G_GNUC_UNUSED)
     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);
diff --git a/tests/virfirewalltest.c b/tests/virfirewalltest.c
index a5323a4256..c4827918c3 100644
--- a/tests/virfirewalltest.c
+++ b/tests/virfirewalltest.c
@@ -234,9 +234,6 @@ testFirewallSingleGroup(const void *opaque)
     if (virFirewallApply(fw) < 0)
         goto cleanup;

-    if (virBufferError(&cmdbuf))
-        goto cleanup;
-
     actual = virBufferCurrentContent(&cmdbuf);

     if (STRNEQ_NULLABLE(expected, actual)) {
@@ -300,9 +297,6 @@ testFirewallRemoveRule(const void *opaque)
     if (virFirewallApply(fw) < 0)
         goto cleanup;

-    if (virBufferError(&cmdbuf))
-        goto cleanup;
-
     actual = virBufferCurrentContent(&cmdbuf);

     if (STRNEQ_NULLABLE(expected, actual)) {
@@ -373,9 +367,6 @@ testFirewallManyGroups(const void *opaque G_GNUC_UNUSED)
     if (virFirewallApply(fw) < 0)
         goto cleanup;

-    if (virBufferError(&cmdbuf))
-        goto cleanup;
-
     actual = virBufferCurrentContent(&cmdbuf);

     if (STRNEQ_NULLABLE(expected, actual)) {
@@ -469,9 +460,6 @@ testFirewallIgnoreFailGroup(const void *opaque G_GNUC_UNUSED)
     if (virFirewallApply(fw) < 0)
         goto cleanup;

-    if (virBufferError(&cmdbuf))
-        goto cleanup;
-
     actual = virBufferCurrentContent(&cmdbuf);

     if (STRNEQ_NULLABLE(expected, actual)) {
@@ -543,9 +531,6 @@ testFirewallIgnoreFailRule(const void *opaque G_GNUC_UNUSED)
     if (virFirewallApply(fw) < 0)
         goto cleanup;

-    if (virBufferError(&cmdbuf))
-        goto cleanup;
-
     actual = virBufferCurrentContent(&cmdbuf);

     if (STRNEQ_NULLABLE(expected, actual)) {
@@ -611,9 +596,6 @@ testFirewallNoRollback(const void *opaque G_GNUC_UNUSED)
         goto cleanup;
     }

-    if (virBufferError(&cmdbuf))
-        goto cleanup;
-
     actual = virBufferCurrentContent(&cmdbuf);

     if (STRNEQ_NULLABLE(expected, actual)) {
@@ -698,9 +680,6 @@ testFirewallSingleRollback(const void *opaque G_GNUC_UNUSED)
         goto cleanup;
     }

-    if (virBufferError(&cmdbuf))
-        goto cleanup;
-
     actual = virBufferCurrentContent(&cmdbuf);

     if (STRNEQ_NULLABLE(expected, actual)) {
@@ -788,9 +767,6 @@ testFirewallManyRollback(const void *opaque G_GNUC_UNUSED)
         goto cleanup;
     }

-    if (virBufferError(&cmdbuf))
-        goto cleanup;
-
     actual = virBufferCurrentContent(&cmdbuf);

     if (STRNEQ_NULLABLE(expected, actual)) {
@@ -908,9 +884,6 @@ testFirewallChainedRollback(const void *opaque G_GNUC_UNUSED)
         goto cleanup;
     }

-    if (virBufferError(&cmdbuf))
-        goto cleanup;
-
     actual = virBufferCurrentContent(&cmdbuf);

     if (STRNEQ_NULLABLE(expected, actual)) {
@@ -1085,9 +1058,6 @@ testFirewallQuery(const void *opaque G_GNUC_UNUSED)
     if (virFirewallApply(fw) < 0)
         goto cleanup;

-    if (virBufferError(&cmdbuf))
-        goto cleanup;
-
     actual = virBufferCurrentContent(&cmdbuf);

     if (expectedLineError) {
diff --git a/tests/virkmodtest.c b/tests/virkmodtest.c
index 853f4ea14e..e013f8f3b6 100644
--- a/tests/virkmodtest.c
+++ b/tests/virkmodtest.c
@@ -69,11 +69,7 @@ checkOutput(virBufferPtr buf, const char *exp_cmd)
     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;
     }

diff --git a/tests/virnetdevbandwidthtest.c b/tests/virnetdevbandwidthtest.c
index 59647173c3..8039fedbc4 100644
--- a/tests/virnetdevbandwidthtest.c
+++ b/tests/virnetdevbandwidthtest.c
@@ -84,11 +84,6 @@ testVirNetDevBandwidthSet(const void *data)
         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. */
     }
diff --git a/tests/virsystemdtest.c b/tests/virsystemdtest.c
index 1a78f006cc..b85259f61f 100644
--- a/tests/virsystemdtest.c
+++ b/tests/virsystemdtest.c
@@ -570,9 +570,6 @@ testActivation(bool useNames)
     setenv("LISTEN_FDS", nfdstr, 1);
     setenv("LISTEN_PID", pidstr, 1);

-    if (virBufferError(&names))
-        goto cleanup;
-
     if (useNames)
         setenv("LISTEN_FDNAMES", virBufferCurrentContent(&names), 1);
     else
diff --git a/tools/virsh-checkpoint.c b/tools/virsh-checkpoint.c
index 7fd3914ef2..f9749b5f6d 100644
--- a/tools/virsh-checkpoint.c
+++ b/tools/virsh-checkpoint.c
@@ -267,11 +267,6 @@ cmdCheckpointCreateAs(vshControl *ctl,
     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")) {
diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index bfff08b0f6..d3beda5670 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -2410,12 +2410,6 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
                               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)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 2f3ac2d430..ae7777df09 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -754,11 +754,6 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
     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")) {
@@ -1072,11 +1067,6 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
     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")) {
@@ -8396,10 +8386,6 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd)

     virBufferTrim(&buf, " ", -1);

-    if (virBufferError(&buf)) {
-        vshError(ctl, "%s", _("Failed to collect new description/title"));
-        goto cleanup;
-    }
     desc = virBufferContentAndReset(&buf);

     if (edit || desc) {
@@ -9517,10 +9503,6 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd)

     virBufferTrim(&buf, " ", -1);

-    if (virBufferError(&buf)) {
-        vshError(ctl, "%s", _("Failed to collect command"));
-        return false;
-    }
     monitor_cmd = virBufferContentAndReset(&buf);

     if (vshCommandOptBool(cmd, "hmp"))
@@ -9818,10 +9800,6 @@ cmdQemuAgentCommand(vshControl *ctl, const vshCmd *cmd)

     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);
@@ -11551,12 +11529,6 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
             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);
diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c
index bd876aefda..2b315caaa7 100644
--- a/tools/virsh-pool.c
+++ b/tools/virsh-pool.c
@@ -416,11 +416,6 @@ virshBuildPoolXML(vshControl *ctl,
     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;
@@ -1480,10 +1475,6 @@ cmdPoolDiscoverSourcesAs(vshControl * ctl, const vshCmd * cmd G_GNUC_UNUSED)
         }
         virBufferAdjustIndent(&buf, -2);
         virBufferAddLit(&buf, "</source>\n");
-        if (virBufferError(&buf)) {
-            vshError(ctl, "%s", _("Out of memory"));
-            return false;
-        }
         srcSpec = virBufferContentAndReset(&buf);
     }

diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c
index 751186ebf8..a42397b42e 100644
--- a/tools/virsh-snapshot.c
+++ b/tools/virsh-snapshot.c
@@ -445,11 +445,6 @@ cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd)
     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")) {
diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c
index d09d4435ad..3637e7f603 100644
--- a/tools/virsh-volume.c
+++ b/tools/virsh-volume.c
@@ -341,10 +341,6 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
     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) {
diff --git a/tools/vsh.c b/tools/vsh.c
index 58ee94b52f..5bab5b5c83 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -2269,9 +2269,6 @@ vshOutputLogFile(vshControl *ctl, int log_level, const char *msg_format,
     virBufferTrim(&buf, "\n", -1);
     virBufferAddChar(&buf, '\n');

-    if (virBufferError(&buf))
-        goto error;
-
     str = virBufferContentAndReset(&buf);
     len = strlen(str);

@@ -2532,9 +2529,6 @@ vshTreePrintInternal(vshControl *ctl,
     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);
@@ -2543,8 +2537,6 @@ vshTreePrintInternal(vshControl *ctl,
     if (!root) {
         virBufferAddChar(indent, devid == lastdev ? ' ' : '|');
         virBufferAddChar(indent, ' ');
-        if (virBufferError(indent))
-            goto cleanup;
     }

     /* Determine the index of the last child device */
@@ -2561,8 +2553,6 @@ vshTreePrintInternal(vshControl *ctl,

     /* 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);

@@ -3318,10 +3308,6 @@ cmdEcho(vshControl *ctl, const vshCmd *cmd)

         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);
@@ -3335,10 +3321,6 @@ cmdEcho(vshControl *ctl, const vshCmd *cmd)
         VIR_FREE(str);
     }

-    if (virBufferError(&buf)) {
-        vshError(ctl, "%s", _("Failed to allocate XML buffer"));
-        return false;
-    }
     arg = virBufferContentAndReset(&buf);
     if (arg) {
         if (err)
-- 
2.21.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux