tools: vshCmddefOptParse: Remove 'optional' command validation

Since vshCmddefCheckInternals now has this check we no longer need it in
vshCmddefOptParse.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2020-11-12 13:34:51 +01:00
parent 0d00e95298
commit cd0602290a

View File

@ -399,7 +399,6 @@ vshCmddefOptParse(const vshCmdDef *cmd, uint64_t *opts_need_arg,
uint64_t *opts_required) uint64_t *opts_required)
{ {
size_t i; size_t i;
bool optional = false;
*opts_need_arg = 0; *opts_need_arg = 0;
*opts_required = 0; *opts_required = 0;
@ -410,30 +409,17 @@ vshCmddefOptParse(const vshCmdDef *cmd, uint64_t *opts_need_arg,
for (i = 0; cmd->opts[i].name; i++) { for (i = 0; cmd->opts[i].name; i++) {
const vshCmdOptDef *opt = &cmd->opts[i]; const vshCmdOptDef *opt = &cmd->opts[i];
if (opt->type == VSH_OT_BOOL) { if (opt->type == VSH_OT_BOOL)
optional = true;
continue; continue;
}
if (opt->flags & VSH_OFLAG_REQ_OPT) {
if (opt->flags & VSH_OFLAG_REQ)
*opts_required |= 1ULL << i;
else
optional = true;
continue;
}
if (opt->type == VSH_OT_ALIAS) if (opt->type == VSH_OT_ALIAS)
continue; /* skip the alias option */ continue; /* skip the alias option */
if (!(opt->flags & VSH_OFLAG_REQ_OPT))
*opts_need_arg |= 1ULL << i; *opts_need_arg |= 1ULL << i;
if (opt->flags & VSH_OFLAG_REQ) {
if (optional && opt->type != VSH_OT_ARGV) if (opt->flags & VSH_OFLAG_REQ)
return -1; /* mandatory options must be listed first */
*opts_required |= 1ULL << i; *opts_required |= 1ULL << i;
} else {
optional = true;
}
} }
return 0; return 0;