From 0e7707d830d4b78b4e3764339bed05518852b005 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Tue, 12 Feb 2019 09:02:32 +0100 Subject: [PATCH] virsh: use virBufferTrim in cmdDomFSInfo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add comma after every string and trim the final one. Signed-off-by: Ján Tomko --- 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);