[PATCH 4/7] virsh: Simplify control flow for 'desc' command

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

 



Just like the commit 8941c800, It does the similar thing.

Signed-off-by: Lin Ma <lma@xxxxxxxx>
---
 tools/virsh-domain.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 1f3ea0c939..65170225a7 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -8330,7 +8330,6 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd)
     char *tmpstr;
     const vshCmdOpt *opt = NULL;
     virBuffer buf = VIR_BUFFER_INITIALIZER;
-    bool pad = false;
     bool ret = false;
     unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
 
@@ -8348,18 +8347,16 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd)
     if ((state = virshDomainState(ctl, dom, NULL)) < 0)
         goto cleanup;
 
-    while ((opt = vshCommandOptArgv(ctl, cmd, opt))) {
-        if (pad)
-            virBufferAddChar(&buf, ' ');
-        pad = true;
-        virBufferAdd(&buf, opt->data, -1);
-    }
-
     if (title)
         type = VIR_DOMAIN_METADATA_TITLE;
     else
         type = VIR_DOMAIN_METADATA_DESCRIPTION;
 
+    while ((opt = vshCommandOptArgv(ctl, cmd, opt)))
+        virBufferAsprintf(&buf, "%s ", opt->data);
+
+    virBufferTrim(&buf, " ", -1);
+
     if (virBufferError(&buf)) {
         vshError(ctl, "%s", _("Failed to collect new description/title"));
         goto cleanup;
-- 
2.15.1

--
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