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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
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

Attachment: signature.asc
Description: Digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]