[libvirt] [PATCH v3 3/8] vsh: vshCmddefHelp: Retrieve command info after we know the command is non-NULL

Ján Tomko jtomko at redhat.com
Fri Sep 16 11:54:38 UTC 2016


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 <eskultet at 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.

Jan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20160916/97a91026/attachment-0001.sig>


More information about the libvir-list mailing list