On Fri, Sep 16, 2016 at 12:50:40PM +0200, Erik Skultety wrote:
Recent changes discarded an unnecessary 'else' block from vshCmddefHelp.
However, that also moved some var declarations as well as definitions to the
beginning of the function block and now we're trying to retrieve command's
.info element before actually checking whether we got a valid command or not.
So this patch fixes it accordingly. Also it removes variable 'help', since
there isn't any functional need for it.

Signed-off-by: Erik Skultety <eskul...@redhat.com>
tools/vsh.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/vsh.c b/tools/vsh.c
index 4c63bd3..4d16299 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -624,9 +624,7 @@ bool
vshCmddefHelp(vshControl *ctl, const char *cmdname)
    const vshCmdDef *def = vshCmddefSearch(cmdname);
-    /* Don't translate desc if it is "".  */
-    const char *desc = vshCmddefGetInfo(def, "desc");

This can be squashed into the previous patch.

-    const char *help = _(vshCmddefGetInfo(def, "help"));
+    const char *desc = NULL;
    char buf[256];
    uint64_t opts_need_arg;
    uint64_t opts_required;
@@ -644,7 +642,8 @@ vshCmddefHelp(vshControl *ctl, const char *cmdname)

    fputs(_("  NAME\n"), stdout);
-    fprintf(stdout, "    %s - %s\n", def->name, help);
+    fprintf(stdout, "    %s - %s\n", def->name,
+            _(vshCmddefGetInfo(def, "help")));

And this change (along with the 'help' variable removal) can stand on
its own before the previous patch.


Attachment: signature.asc
Description: Digital signature

libvir-list mailing list

Reply via email to