提交 9b86282e 编写于 作者: E Erik Skultety

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: NErik Skultety <eskultet@redhat.com>
上级 c91cddb6
......@@ -629,18 +629,17 @@ bool
vshCmddefHelp(vshControl *ctl, const char *cmdname)
{
const vshCmdDef *def = vshCmddefSearch(cmdname);
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");
const char *desc = NULL;
char buf[256];
uint64_t opts_need_arg;
uint64_t opts_required;
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)) {
vshError(ctl, _("internal error: bad options in command: '%s'"),
def->name);
......@@ -700,7 +699,8 @@ vshCmddefHelp(vshControl *ctl, const char *cmdname)
}
fputc('\n', stdout);
if (desc[0]) {
desc = vshCmddefGetInfo(def, "desc");
if (*desc) {
/* Print the description only if it's not empty. */
fputs(_("\n DESCRIPTION\n"), stdout);
fprintf(stdout, " %s\n", _(desc));
......@@ -753,7 +753,7 @@ vshCmddefHelp(vshControl *ctl, const char *cmdname)
}
}
fputc('\n', stdout);
}
return true;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册