From 443fc056a057b6d653986b454c8b1514b6f0299e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Tue, 12 Feb 2019 07:47:10 +0100 Subject: [PATCH] virsh: introduce ninfos variable in cmdDomFSInfo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Do not use 'ret' throughout the whole function to avoid confusion and comparison of unsigned 'i' against signed 'ret'. Signed-off-by: Ján Tomko --- tools/virsh-domain.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 8b20059335..630761e40e 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -13940,6 +13940,7 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd) size_t i, j; virDomainFSInfoPtr *info; vshTablePtr table = NULL; + size_t ninfos = 0; if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -13949,7 +13950,9 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd) vshError(ctl, _("Unable to get filesystem information")); goto cleanup; } - if (ret == 0) { + ninfos = ret; + + if (ninfos == 0) { vshError(ctl, _("No filesystems are mounted in the domain")); goto cleanup; } @@ -13959,7 +13962,7 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd) if (!table) goto cleanup; - for (i = 0; i < ret; i++) { + for (i = 0; i < ninfos; i++) { virBuffer targetsBuff = VIR_BUFFER_INITIALIZER; VIR_AUTOFREE(char *) targets = NULL; @@ -13985,7 +13988,7 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd) cleanup: if (info) { - for (i = 0; i < ret; i++) + for (i = 0; i < ninfos; i++) virDomainFSInfoFree(info[i]); VIR_FREE(info); }