[libvirt] [PATCH 6/9] virsh: introduce 'ret' in cmdDomFSInfo

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


Failing to print the table is also a reason to return failure
and print the reported error.

Switch to the usual pattern where we fall through the cleanup
label right after setting ret to true instead of infering the
return value from the number of filesystems returned.

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

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index d5026286c9..cb2da8eb5b 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -13941,6 +13941,7 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd)
     virDomainFSInfoPtr *info = NULL;
     vshTablePtr table = NULL;
     size_t ninfos = 0;
+    bool ret = false;
 
     if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
@@ -13953,6 +13954,7 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd)
     ninfos = rc;
 
     if (ninfos == 0) {
+        ret = true;
         vshError(ctl, _("No filesystems are mounted in the domain"));
         goto cleanup;
     }
@@ -13986,6 +13988,8 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd)
         vshTablePrintToStdout(table, ctl);
     }
 
+    ret = true;
+
  cleanup:
     if (info) {
         for (i = 0; i < ninfos; i++)
@@ -13994,7 +13998,7 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd)
     }
     vshTableFree(table);
     virshDomainFree(dom);
-    return rc >= 0;
+    return ret;
 }
 
 const vshCmdDef domManagementCmds[] = {
-- 
2.19.2




More information about the libvir-list mailing list