[libvirt] [PATCH 1/4] virsh: reduce the optimism in cmdIOThreadInfo

Ján Tomko jtomko at redhat.com
Tue Feb 12 11:06:20 UTC 2019


Instead of using niothreads which defaults to zero, use the common
pattern with a ret varaible set to true just before the cleanup label.

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 8b20059335..420ab5e2c3 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -7538,6 +7538,7 @@ cmdIOThreadInfo(vshControl *ctl, const vshCmd *cmd)
     unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
     virshControlPtr priv = ctl->privData;
     vshTablePtr table = NULL;
+    bool ret = false;
 
     VSH_EXCLUSIVE_OPTIONS_VAR(current, live);
     VSH_EXCLUSIVE_OPTIONS_VAR(current, config);
@@ -7559,6 +7560,7 @@ cmdIOThreadInfo(vshControl *ctl, const vshCmd *cmd)
     }
 
     if (niothreads == 0) {
+        ret = true;
         vshPrintExtra(ctl, _("No IOThreads found for the domain"));
         goto cleanup;
     }
@@ -7582,13 +7584,15 @@ cmdIOThreadInfo(vshControl *ctl, const vshCmd *cmd)
 
     vshTablePrintToStdout(table, ctl);
 
+    ret = true;
+
  cleanup:
     for (i = 0; i < niothreads; i++)
         virDomainIOThreadInfoFree(info[i]);
     VIR_FREE(info);
     vshTableFree(table);
     virshDomainFree(dom);
-    return niothreads >= 0;
+    return ret;
 }
 
 /*
-- 
2.19.2




More information about the libvir-list mailing list