[PATCH 08/32] tools: use g_auto() for all virBuffers

Laine Stump laine at redhat.com
Mon Jul 6 03:41:03 UTC 2020


Signed-off-by: Laine Stump <laine at redhat.com>
---
 tools/virsh-checkpoint.c     |  3 +-
 tools/virsh-domain-monitor.c |  3 +-
 tools/virsh-domain.c         | 58 +++++++++++++++++-------------------
 tools/virsh-pool.c           |  6 ++--
 tools/virsh-secret.c         |  2 +-
 tools/virsh-snapshot.c       |  3 +-
 tools/virsh-volume.c         |  3 +-
 tools/vsh-table.c            |  2 +-
 tools/vsh.c                  | 15 ++++------
 9 files changed, 42 insertions(+), 53 deletions(-)

diff --git a/tools/virsh-checkpoint.c b/tools/virsh-checkpoint.c
index 853fe05fc4..821212f86b 100644
--- a/tools/virsh-checkpoint.c
+++ b/tools/virsh-checkpoint.c
@@ -235,7 +235,7 @@ cmdCheckpointCreateAs(vshControl *ctl,
     char *buffer = NULL;
     const char *name = NULL;
     const char *desc = NULL;
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
     unsigned int flags = 0;
     const vshCmdOpt *opt = NULL;
 
@@ -278,7 +278,6 @@ cmdCheckpointCreateAs(vshControl *ctl,
     ret = virshCheckpointCreate(ctl, dom, buffer, flags, NULL);
 
  cleanup:
-    virBufferFreeAndReset(&buf);
     VIR_FREE(buffer);
     virshDomainFree(dom);
 
diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index 9b8c69fa9d..d8333a2f44 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -2413,7 +2413,7 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
         }
 
         for (j = 0; j < iface->naddrs; j++) {
-            virBuffer buf = VIR_BUFFER_INITIALIZER;
+            g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 
             switch (iface->addrs[j].type) {
             case VIR_IP_ADDR_TYPE_IPV4:
@@ -2442,7 +2442,6 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
                 vshPrint(ctl, " %-10s %-17s    %s\n",
                          "-", "-", ip_addr_str);
 
-            virBufferFreeAndReset(&buf);
             VIR_FREE(ip_addr_str);
         }
     }
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 085b88b097..f0f3456b77 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -575,7 +575,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
     int ret;
     unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
     const char *stype = NULL;
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
     char *xml = NULL;
     struct stat st;
     bool current = vshCommandOptBool(cmd, "current");
@@ -778,7 +778,6 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
  cleanup:
     VIR_FREE(xml);
     virshDomainFree(dom);
-    virBufferFreeAndReset(&buf);
     return functionReturn;
 }
 
@@ -905,7 +904,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
     virDomainNetType typ;
     int ret;
     bool functionReturn = false;
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
     char *xml = NULL;
     unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
     bool current = vshCommandOptBool(cmd, "current");
@@ -1091,7 +1090,6 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
  cleanup:
     VIR_FREE(xml);
     virshDomainFree(dom);
-    virBufferFreeAndReset(&buf);
     return functionReturn;
 }
 
@@ -2412,7 +2410,7 @@ cmdBlockcopy(vshControl *ctl, const vshCmd *cmd)
         }
 
         if (!xmlstr) {
-            virBuffer buf = VIR_BUFFER_INITIALIZER;
+            g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
             virBufferAsprintf(&buf, "<disk type='%s'>\n",
                               blockdev ? "block" : "file");
             virBufferAdjustIndent(&buf, 2);
@@ -8504,7 +8502,7 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd)
     char *tmp = NULL;
     char *tmpstr;
     const vshCmdOpt *opt = NULL;
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
     bool ret = false;
     unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
 
@@ -9642,7 +9640,7 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd)
     g_autoptr(virJSONValue) resultjson = NULL;
     unsigned int flags = 0;
     const vshCmdOpt *opt = NULL;
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
     bool pretty = vshCommandOptBool(cmd, "pretty");
     bool returnval = vshCommandOptBool(cmd, "return-value");
     virJSONValuePtr formatjson;
@@ -9956,7 +9954,7 @@ cmdQemuAgentCommand(vshControl *ctl, const vshCmd *cmd)
     int judge = 0;
     unsigned int flags = 0;
     const vshCmdOpt *opt = NULL;
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
     virJSONValuePtr pretty = NULL;
 
     dom = virshCommandOptDomain(ctl, cmd, NULL);
@@ -11506,7 +11504,7 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
     xmlDocPtr xml = NULL;
     xmlXPathContextPtr ctxt = NULL;
     virDomainPtr dom;
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
     bool ret = false;
     char *xpath = NULL;
     char *listen_addr = NULL;
@@ -13202,7 +13200,7 @@ virshEventGenericPrint(virConnectPtr conn G_GNUC_UNUSED,
                        virDomainPtr dom,
                        void *opaque)
 {
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 
     virBufferAsprintf(&buf, _("event '%s' for domain %s\n"),
                       ((virshDomEventData *) opaque)->cb->name,
@@ -13217,7 +13215,7 @@ virshEventLifecyclePrint(virConnectPtr conn G_GNUC_UNUSED,
                          int detail,
                          void *opaque)
 {
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 
     virBufferAsprintf(&buf, _("event 'lifecycle' for domain %s: %s %s\n"),
                       virDomainGetName(dom),
@@ -13232,7 +13230,7 @@ virshEventRTCChangePrint(virConnectPtr conn G_GNUC_UNUSED,
                          long long utcoffset,
                          void *opaque)
 {
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 
     virBufferAsprintf(&buf, _("event 'rtc-change' for domain %s: %lld\n"),
                       virDomainGetName(dom),
@@ -13246,7 +13244,7 @@ virshEventWatchdogPrint(virConnectPtr conn G_GNUC_UNUSED,
                         int action,
                         void *opaque)
 {
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 
     virBufferAsprintf(&buf, _("event 'watchdog' for domain %s: %s\n"),
                       virDomainGetName(dom),
@@ -13262,7 +13260,7 @@ virshEventIOErrorPrint(virConnectPtr conn G_GNUC_UNUSED,
                        int action,
                        void *opaque)
 {
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 
     virBufferAsprintf(&buf, _("event 'io-error' for domain %s: %s (%s) %s\n"),
                       virDomainGetName(dom),
@@ -13282,7 +13280,7 @@ virshEventGraphicsPrint(virConnectPtr conn G_GNUC_UNUSED,
                         const virDomainEventGraphicsSubject *subject,
                         void *opaque)
 {
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
     size_t i;
 
     virBufferAsprintf(&buf, _("event 'graphics' for domain %s: "
@@ -13313,7 +13311,7 @@ virshEventIOErrorReasonPrint(virConnectPtr conn G_GNUC_UNUSED,
                              const char *reason,
                              void *opaque)
 {
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 
     virBufferAsprintf(&buf, _("event 'io-error-reason' for domain %s: "
                               "%s (%s) %s due to %s\n"),
@@ -13333,7 +13331,7 @@ virshEventBlockJobPrint(virConnectPtr conn G_GNUC_UNUSED,
                         int status,
                         void *opaque)
 {
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 
     virBufferAsprintf(&buf, _("event '%s' for domain %s: %s for %s %s\n"),
                       ((virshDomEventData *) opaque)->cb->name,
@@ -13353,7 +13351,7 @@ virshEventDiskChangePrint(virConnectPtr conn G_GNUC_UNUSED,
                           int reason,
                           void *opaque)
 {
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 
     virBufferAsprintf(&buf, _("event 'disk-change' for domain %s disk %s: "
                               "%s -> %s: %s\n"),
@@ -13372,7 +13370,7 @@ virshEventTrayChangePrint(virConnectPtr conn G_GNUC_UNUSED,
                           int reason,
                           void *opaque)
 {
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 
     virBufferAsprintf(&buf, _("event 'tray-change' for domain %s disk %s: %s\n"),
                       virDomainGetName(dom),
@@ -13398,7 +13396,7 @@ virshEventBalloonChangePrint(virConnectPtr conn G_GNUC_UNUSED,
                              unsigned long long actual,
                              void *opaque)
 {
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 
     virBufferAsprintf(&buf, _("event 'balloon-change' for domain %s: %lluKiB\n"),
                       virDomainGetName(dom),
@@ -13412,7 +13410,7 @@ virshEventDeviceRemovedPrint(virConnectPtr conn G_GNUC_UNUSED,
                              const char *alias,
                              void *opaque)
 {
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 
     virBufferAsprintf(&buf, _("event 'device-removed' for domain %s: %s\n"),
                       virDomainGetName(dom),
@@ -13426,7 +13424,7 @@ virshEventDeviceAddedPrint(virConnectPtr conn G_GNUC_UNUSED,
                            const char *alias,
                            void *opaque)
 {
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 
     virBufferAsprintf(&buf, _("event 'device-added' for domain %s: %s\n"),
                       virDomainGetName(dom),
@@ -13441,7 +13439,7 @@ virshEventTunablePrint(virConnectPtr conn G_GNUC_UNUSED,
                        int nparams,
                        void *opaque)
 {
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
     size_t i;
     char *value;
 
@@ -13479,7 +13477,7 @@ virshEventAgentLifecyclePrint(virConnectPtr conn G_GNUC_UNUSED,
                               int reason,
                               void *opaque)
 {
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 
     virBufferAsprintf(&buf, _("event 'agent-lifecycle' for domain %s: state: "
                               "'%s' reason: '%s'\n"),
@@ -13495,7 +13493,7 @@ virshEventMigrationIterationPrint(virConnectPtr conn G_GNUC_UNUSED,
                                   int iteration,
                                   void *opaque)
 {
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 
     virBufferAsprintf(&buf, _("event 'migration-iteration' for domain %s: "
                               "iteration: '%d'\n"),
@@ -13512,7 +13510,7 @@ virshEventJobCompletedPrint(virConnectPtr conn G_GNUC_UNUSED,
                             int nparams,
                             void *opaque)
 {
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
     size_t i;
     char *value;
 
@@ -13535,7 +13533,7 @@ virshEventDeviceRemovalFailedPrint(virConnectPtr conn G_GNUC_UNUSED,
                                    const char *alias,
                                    void *opaque)
 {
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 
     virBufferAsprintf(&buf, _("event 'device-removal-failed' for domain %s: %s\n"),
                       virDomainGetName(dom),
@@ -13557,7 +13555,7 @@ virshEventMetadataChangePrint(virConnectPtr conn G_GNUC_UNUSED,
                               const char *nsuri,
                               void *opaque)
 {
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 
     virBufferAsprintf(&buf, _("event 'metadata-change' for domain %s: %s %s\n"),
                       virDomainGetName(dom),
@@ -13576,7 +13574,7 @@ virshEventBlockThresholdPrint(virConnectPtr conn G_GNUC_UNUSED,
                               unsigned long long excess,
                               void *opaque)
 {
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 
     virBufferAsprintf(&buf, _("event 'block-threshold' for domain %s: "
                               "dev: %s(%s) %llu %llu\n"),
@@ -14167,7 +14165,7 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd)
             goto cleanup;
 
         for (i = 0; i < ninfos; i++) {
-            virBuffer targetsBuff = VIR_BUFFER_INITIALIZER;
+            g_auto(virBuffer) targetsBuff = VIR_BUFFER_INITIALIZER;
             g_autofree char *targets = NULL;
 
             for (j = 0; j < info[i]->ndevAlias; j++)
diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c
index d190eed2b1..885e000ed2 100644
--- a/tools/virsh-pool.c
+++ b/tools/virsh-pool.c
@@ -325,7 +325,7 @@ virshBuildPoolXML(vshControl *ctl,
                *adapterWwnn = NULL, *adapterWwpn = NULL, *secretUUID = NULL,
                *adapterParentWwnn = NULL, *adapterParentWwpn = NULL,
                *adapterParentFabricWwn = NULL, *protoVer = NULL;
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 
     VSH_EXCLUSIVE_OPTIONS("secret-usage", "secret-uuid");
 
@@ -421,7 +421,6 @@ virshBuildPoolXML(vshControl *ctl,
     return true;
 
  cleanup:
-    virBufferFreeAndReset(&buf);
     return false;
 }
 
@@ -1450,11 +1449,10 @@ cmdPoolDiscoverSourcesAs(vshControl * ctl, const vshCmd * cmd G_GNUC_UNUSED)
 
     if (host) {
         const char *port = NULL;
-        virBuffer buf = VIR_BUFFER_INITIALIZER;
+        g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 
         if (vshCommandOptStringReq(ctl, cmd, "port", &port) < 0) {
             vshError(ctl, "%s", _("missing argument"));
-            virBufferFreeAndReset(&buf);
             return false;
         }
         virBufferAddLit(&buf, "<source>\n");
diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c
index be4adc416e..7bd0acda58 100644
--- a/tools/virsh-secret.c
+++ b/tools/virsh-secret.c
@@ -585,7 +585,7 @@ cmdSecretList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
         int usageType = virSecretGetUsageType(sec);
         const char *usageStr = virSecretUsageTypeToString(usageType);
         char uuid[VIR_UUID_STRING_BUFLEN];
-        virBuffer buf = VIR_BUFFER_INITIALIZER;
+        g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
         g_autofree char *usage = NULL;
 
         if (virSecretGetUUIDString(sec, uuid) < 0) {
diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c
index d5e68e4b18..4ac6cb1dcd 100644
--- a/tools/virsh-snapshot.c
+++ b/tools/virsh-snapshot.c
@@ -395,7 +395,7 @@ cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd)
     const char *name = NULL;
     const char *desc = NULL;
     const char *memspec = NULL;
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
     unsigned int flags = VIR_DOMAIN_SNAPSHOT_CREATE_VALIDATE;
     const vshCmdOpt *opt = NULL;
 
@@ -456,7 +456,6 @@ cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd)
     ret = virshSnapshotCreate(ctl, dom, buffer, flags, NULL);
 
  cleanup:
-    virBufferFreeAndReset(&buf);
     VIR_FREE(buffer);
     virshDomainFree(dom);
 
diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c
index 72394915d8..fec8278a5d 100644
--- a/tools/virsh-volume.c
+++ b/tools/virsh-volume.c
@@ -226,7 +226,7 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
     const char *name, *capacityStr = NULL, *allocationStr = NULL, *format = NULL;
     const char *snapshotStrVol = NULL, *snapshotStrFormat = NULL;
     unsigned long long capacity, allocation = 0;
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
     unsigned long flags = 0;
     virshControlPtr priv = ctl->privData;
     bool ret = false;
@@ -356,7 +356,6 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
     ret = true;
 
  cleanup:
-    virBufferFreeAndReset(&buf);
     if (vol)
         virStorageVolFree(vol);
     virStoragePoolFree(pool);
diff --git a/tools/vsh-table.c b/tools/vsh-table.c
index e21514e86f..60554b7b2f 100644
--- a/tools/vsh-table.c
+++ b/tools/vsh-table.c
@@ -368,7 +368,7 @@ vshTablePrint(vshTablePtr table, bool header)
     size_t j;
     size_t *maxwidths;
     size_t **widths;
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
     char *ret = NULL;
 
     if (VIR_ALLOC_N(maxwidths, table->rows[0]->ncells))
diff --git a/tools/vsh.c b/tools/vsh.c
index 58bb1e6a3c..527c135424 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -2183,7 +2183,7 @@ void
 vshOutputLogFile(vshControl *ctl, int log_level, const char *msg_format,
                  va_list ap)
 {
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
     char *str = NULL;
     size_t len;
     const char *lvl = "";
@@ -2241,7 +2241,6 @@ vshOutputLogFile(vshControl *ctl, int log_level, const char *msg_format,
  error:
     vshCloseLogFile(ctl);
     vshError(ctl, "%s", _("failed to write the log file"));
-    virBufferFreeAndReset(&buf);
     VIR_FREE(str);
 }
 
@@ -2531,13 +2530,12 @@ vshTreePrint(vshControl *ctl, vshTreeLookup lookup, void *opaque,
              int num_devices, int devid)
 {
     int ret;
-    virBuffer indent = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) indent = VIR_BUFFER_INITIALIZER;
 
     ret = vshTreePrintInternal(ctl, lookup, opaque, num_devices,
                                devid, devid, true, &indent);
     if (ret < 0)
         vshError(ctl, "%s", _("Failed to complete tree listing"));
-    virBufferFreeAndReset(&indent);
     return ret;
 }
 
@@ -2806,7 +2804,7 @@ vshReadlineParse(const char *text, int state)
 
     if (ret &&
         !rl_completion_quote_character) {
-        virBuffer buf = VIR_BUFFER_INITIALIZER;
+        g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
         virBufferEscapeShell(&buf, ret);
         VIR_FREE(ret);
         ret = virBufferContentAndReset(&buf);
@@ -3217,7 +3215,7 @@ cmdEcho(vshControl *ctl, const vshCmd *cmd)
     int count = 0;
     const vshCmdOpt *opt = NULL;
     char *arg;
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 
     if (vshCommandOptBool(cmd, "shell"))
         shell = true;
@@ -3228,7 +3226,7 @@ cmdEcho(vshControl *ctl, const vshCmd *cmd)
 
     while ((opt = vshCommandOptArgv(ctl, cmd, opt))) {
         char *str;
-        virBuffer xmlbuf = VIR_BUFFER_INITIALIZER;
+        g_auto(virBuffer) xmlbuf = VIR_BUFFER_INITIALIZER;
 
         arg = opt->data;
 
@@ -3366,7 +3364,7 @@ cmdComplete(vshControl *ctl, const vshCmd *cmd)
     const char *arg = "";
     const vshCmdOpt *opt = NULL;
     char **matches = NULL, **iter;
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 
     if (vshCommandOptStringQuiet(ctl, cmd, "string", &arg) <= 0)
         goto cleanup;
@@ -3406,7 +3404,6 @@ cmdComplete(vshControl *ctl, const vshCmd *cmd)
 
     ret = true;
  cleanup:
-    virBufferFreeAndReset(&buf);
     virStringListFree(matches);
     return ret;
 }
-- 
2.25.4




More information about the libvir-list mailing list