vsh: vshCmddefHelp: Drop the unnecessary 'else' branch

If the initial check is true the function immediately returns so there's no
need to enclose the code following the check within an 'else' block.
Also, by removing the 'else' block, the declarations need to be moved to
beginning of the function block to conform with our guidelines.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
Erik Skultety 2016-09-15 17:52:11 +02:00
parent c91cddb6f7
commit 9b86282ecd

View File

@ -629,18 +629,17 @@ bool
vshCmddefHelp(vshControl *ctl, const char *cmdname) vshCmddefHelp(vshControl *ctl, const char *cmdname)
{ {
const vshCmdDef *def = vshCmddefSearch(cmdname); const vshCmdDef *def = vshCmddefSearch(cmdname);
const char *desc = NULL;
if (!def) {
vshError(ctl, _("command '%s' doesn't exist"), cmdname);
return false;
} else {
/* Don't translate desc if it is "". */
const char *desc = vshCmddefGetInfo(def, "desc");
char buf[256]; char buf[256];
uint64_t opts_need_arg; uint64_t opts_need_arg;
uint64_t opts_required; uint64_t opts_required;
bool shortopt = false; /* true if 'arg' works instead of '--opt arg' */ bool shortopt = false; /* true if 'arg' works instead of '--opt arg' */
if (!def) {
vshError(ctl, _("command '%s' doesn't exist"), cmdname);
return false;
}
if (vshCmddefOptParse(def, &opts_need_arg, &opts_required)) { if (vshCmddefOptParse(def, &opts_need_arg, &opts_required)) {
vshError(ctl, _("internal error: bad options in command: '%s'"), vshError(ctl, _("internal error: bad options in command: '%s'"),
def->name); def->name);
@ -700,7 +699,8 @@ vshCmddefHelp(vshControl *ctl, const char *cmdname)
} }
fputc('\n', stdout); fputc('\n', stdout);
if (desc[0]) { desc = vshCmddefGetInfo(def, "desc");
if (*desc) {
/* Print the description only if it's not empty. */ /* Print the description only if it's not empty. */
fputs(_("\n DESCRIPTION\n"), stdout); fputs(_("\n DESCRIPTION\n"), stdout);
fprintf(stdout, " %s\n", _(desc)); fprintf(stdout, " %s\n", _(desc));
@ -753,7 +753,7 @@ vshCmddefHelp(vshControl *ctl, const char *cmdname)
} }
} }
fputc('\n', stdout); fputc('\n', stdout);
}
return true; return true;
} }