]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh: Simplify control flow for 'qemu-agent-command' command
authorLin Ma <lma@suse.com>
Fri, 4 May 2018 09:28:52 +0000 (17:28 +0800)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 4 May 2018 10:46:22 +0000 (12:46 +0200)
Signed-off-by: Lin Ma <lma@suse.com>
tools/virsh-domain.c

index 65170225a77b78ccb773d6dc0254d19e361a96f4..598d2fa4a4bd9d52069579a1c343e658ac83255f 100644 (file)
@@ -9796,19 +9796,17 @@ cmdQemuAgentCommand(vshControl *ctl, const vshCmd *cmd)
     unsigned int flags = 0;
     const vshCmdOpt *opt = NULL;
     virBuffer buf = VIR_BUFFER_INITIALIZER;
-    bool pad = false;
     virJSONValuePtr pretty = NULL;
 
     dom = virshCommandOptDomain(ctl, cmd, NULL);
     if (dom == NULL)
         goto cleanup;
 
-    while ((opt = vshCommandOptArgv(ctl, cmd, opt))) {
-        if (pad)
-            virBufferAddChar(&buf, ' ');
-        pad = true;
-        virBufferAdd(&buf, opt->data, -1);
-    }
+    while ((opt = vshCommandOptArgv(ctl, cmd, opt)))
+        virBufferAsprintf(&buf, "%s ", opt->data);
+
+    virBufferTrim(&buf, " ", -1);
+
     if (virBufferError(&buf)) {
         vshError(ctl, "%s", _("Failed to collect command"));
         goto cleanup;