Re: [libvirt] [PATCH v3 3/8] vsh: vshCmddefHelp: Retrieve command info after we know the command is non-NULL
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--- 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 signature.asc Description: Digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v3 3/8] vsh: vshCmddefHelp: Retrieve command info after we know the command is non-NULL
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--- 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"); -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"))); fputs(_("\n SYNOPSIS\n"), stdout); fprintf(stdout, "%s", def->name); @@ -695,6 +694,7 @@ vshCmddefHelp(vshControl *ctl, const char *cmdname) } fputc('\n', stdout); +desc = vshCmddefGetInfo(def, "desc"); if (desc && *desc) { /* Print the description only if it's not empty. */ fputs(_("\n DESCRIPTION\n"), stdout); -- 2.5.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list