]> xenbits.xensource.com Git - libvirt.git/commitdiff
vsh: adjust vshInit signature and remove redundant error label
authorErik Skultety <eskultet@redhat.com>
Thu, 3 Sep 2015 14:52:44 +0000 (16:52 +0200)
committerErik Skultety <eskultet@redhat.com>
Fri, 4 Sep 2015 12:12:34 +0000 (14:12 +0200)
As part of the effort to stay consistent, change the vshInit signature
from returning int to returning bool. Moreover, remove the
unnecessary error label as there is no cleanup that would make use of
it.

tools/virsh.c
tools/vsh.c
tools/vsh.h

index 391c1555b630133977fd638f7300f0f9207c08b2..77d3754efdfdd477e3f2698af6d43c8ad5e798e2 100644 (file)
@@ -904,7 +904,7 @@ main(int argc, char **argv)
     if ((defaultConn = virGetEnvBlockSUID("VIRSH_DEFAULT_CONNECT_URI")))
         ctl->connname = vshStrdup(ctl, defaultConn);
 
-    if (vshInit(ctl, cmdGroups, NULL) < 0)
+    if (!vshInit(ctl, cmdGroups, NULL))
         exit(EXIT_FAILURE);
 
     if (!virshParseArgv(ctl, argc, argv) ||
index 54c4614a67814624b3d945c74ce40e140876d607..e6ecc0385494c96e55dc1642d4b5ba6e426c113b 100644 (file)
@@ -2714,20 +2714,18 @@ vshInitDebug(vshControl *ctl)
 /*
  * Initialize global data
  */
-int
+bool
 vshInit(vshControl *ctl, const vshCmdGrp *groups, const vshCmdDef *set)
 {
-    int ret = -1;
-
     if (!ctl->hooks) {
         vshError(ctl, "%s", _("client hooks cannot be NULL"));
-        goto error;
+        return false;
     }
 
     if (!groups && !set) {
         vshError(ctl, "%s", _("command groups and command set "
                               "cannot both be NULL"));
-        goto error;
+        return false;
     }
 
     cmdGroups = groups;
@@ -2735,11 +2733,9 @@ vshInit(vshControl *ctl, const vshCmdGrp *groups, const vshCmdDef *set)
     vshInitDebug(ctl);
 
     if (ctl->imode && vshReadlineInit(ctl) < 0)
-        goto error;
+        return false;
 
-    ret = 0;
- error:
-    return ret;
+    return true;
 }
 
 void
index 37416c7c94e2579fd9209212b244718f18cc8ac5..e2e33ba160e4146affd6955cd1d8f4e4553fb6bc 100644 (file)
@@ -302,7 +302,7 @@ int vshCommandOptTimeoutToMs(vshControl *ctl, const vshCmd *cmd, int *timeout);
 
 void vshPrintExtra(vshControl *ctl, const char *format, ...)
     ATTRIBUTE_FMT_PRINTF(2, 3);
-int vshInit(vshControl *ctl, const vshCmdGrp *groups, const vshCmdDef *set);
+bool vshInit(vshControl *ctl, const vshCmdGrp *groups, const vshCmdDef *set);
 void vshDeinit(vshControl *ctl);
 void vshInitDebug(vshControl *ctl);
 void vshDebug(vshControl *ctl, int level, const char *format, ...)