On Mon, Mar 11, 2024 at 12:30:38 +0100, Peter Krempa wrote: > None of the clients use the 'command set' approach and other pieces of > code such as the command validator already assume that command groups > are in use. Remove the unused 'command set' stuff. > > Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> > --- > tools/virsh.c | 2 +- > tools/virt-admin.c | 2 +- > tools/vsh.c | 38 +++++++------------------------------- > tools/vsh.h | 2 +- > 4 files changed, 10 insertions(+), 34 deletions(-) The compiler on mingw started thinking after this patch that it sees a potential NULL dereference. To avoid that (while it's impossible as we check the assumptions which would make the command lookup function return NULL) I'll be squashing in the following to silence it: diff --git a/tools/vsh.c b/tools/vsh.c index cbd0d88078..7a8e9f7f8c 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -1402,7 +1402,11 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser, vshCmd **partial) if (cmd->flags & VSH_CMD_FLAG_ALIAS) { VIR_FREE(tkdata); tkdata = g_strdup(cmd->alias); - cmd = vshCmddefSearch(tkdata); + if (!(cmd = vshCmddefSearch(tkdata))) { + /* self-test ensures that the alias exists */ + vshError(ctl, _("unknown command: '%1$s'"), tkdata); + goto syntaxError; + } } vshCmddefOptParse(cmd, &opts_need_arg, &opts_required); @@ -1527,7 +1531,10 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser, vshCmd **partial) if (STRNEQ(tmpopt->def->name, "help")) continue; - help = vshCmddefSearch("help"); + /* the self-test code ensures that help exists */ + if (!(help = vshCmddefSearch("help"))) + break; + vshCommandOptFree(first); first = g_new0(vshCmdOpt, 1); first->def = help->opts; @@ -3132,6 +3139,9 @@ cmdHelp(vshControl *ctl, const vshCmd *cmd) if ((def = vshCmddefSearch(name))) { if (def->flags & VSH_CMD_FLAG_ALIAS) def = vshCmddefSearch(def->alias); + } + + if (def) { return vshCmddefHelp(def); } else if ((grp = vshCmdGrpSearch(name))) { return vshCmdGrpHelp(ctl, grp); _______________________________________________ Devel mailing list -- devel@xxxxxxxxxxxxxxxxx To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx