From: Michal Privoznik Date: Fri, 17 Sep 2021 07:58:03 +0000 (+0200) Subject: vsh: Ensure that bool --options don't have completer X-Git-Tag: v7.8.0-rc1~138 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b480a5cb5c65545c290baa2f266eef4318f8c13b;p=thirdparty%2Flibvirt.git vsh: Ensure that bool --options don't have completer Let's check whether a boolean --option doesn't have completer or completer_flags set. These options are just flags and don't accept any value, thus they can't have any completer. Signed-off-by: Michal Privoznik Reviewed-by: Ján Tomko --- diff --git a/tools/vsh.c b/tools/vsh.c index dd6930730d..e81369f224 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -337,8 +337,16 @@ vshCmddefCheckInternals(vshControl *ctl, virBufferStrcat(&complbuf, opt->name, ", ", NULL); switch (opt->type) { - case VSH_OT_STRING: case VSH_OT_BOOL: + if (opt->completer || opt->completer_flags) { + vshError(ctl, _("bool parameter '%s' of command '%s' has completer set"), + opt->name, cmd->name); + return -1; + } + + G_GNUC_FALLTHROUGH; + + case VSH_OT_STRING: if (opt->flags & VSH_OFLAG_REQ) { vshError(ctl, _("parameter '%s' of command '%s' misused VSH_OFLAG_REQ"), opt->name, cmd->name);