[libvirt] [PATCH 8/9] virsh: use virBufferTrim in cmdDomFSInfo

Ján Tomko jtomko at redhat.com
Tue Feb 12 09:21:26 UTC 2019


Add comma after every string and trim the final one.

Signed-off-by: Ján Tomko <jtomko at redhat.com>
---
 tools/virsh-domain.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index d21e77ce75..6124126576 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -13968,11 +13968,9 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd)
             virBuffer targetsBuff = VIR_BUFFER_INITIALIZER;
             VIR_AUTOFREE(char *) targets = NULL;
 
-            for (j = 0; j < info[i]->ndevAlias; j++) {
-                virBufferAdd(&targetsBuff, info[i]->devAlias[j], -1);
-                if (j != info[i]->ndevAlias - 1)
-                    virBufferAddChar(&targetsBuff, ',');
-            }
+            for (j = 0; j < info[i]->ndevAlias; j++)
+                virBufferAsprintf(&targetsBuff, "%s,", info[i]->devAlias[j]);
+            virBufferTrim(&targetsBuff, ",", -1);
 
             targets = virBufferContentAndReset(&targetsBuff);
 
-- 
2.19.2




More information about the libvir-list mailing list