mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
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:
parent
c91cddb6f7
commit
9b86282ecd
18
tools/vsh.c
18
tools/vsh.c
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user