From 57b8a38840fc0fd33b75783cbe5a496adcad6f02 Mon Sep 17 00:00:00 2001 From: Erik Skultety Date: Thu, 3 Sep 2015 16:52:44 +0200 Subject: [PATCH] vsh: adjust vshInit signature and remove redundant error label 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 | 2 +- tools/vsh.c | 14 +++++--------- tools/vsh.h | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index 391c1555b6..77d3754efd 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -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) || diff --git a/tools/vsh.c b/tools/vsh.c index 54c4614a67..e6ecc03854 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -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 diff --git a/tools/vsh.h b/tools/vsh.h index 37416c7c94..e2e33ba160 100644 --- a/tools/vsh.h +++ b/tools/vsh.h @@ -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, ...) -- GitLab