From 55a07252ec06f514b77ffbffbc0b70ccd98b9ac8 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Tue, 5 Mar 2024 16:23:19 +0100 Subject: [PATCH] vshCmddefCheckInternals: Remove refactoring safety checks MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Now that the code was refactored and proved identical, remove the checks so that they don't impede further refactors. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- tools/vsh.c | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/tools/vsh.c b/tools/vsh.c index ef6451f70e..e80c6e84f1 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -248,7 +248,6 @@ vshCmddefCheckInternals(vshControl *ctl, { size_t i; bool seenOptionalOption = false; - bool seenPositionalOption = false; g_auto(virBuffer) complbuf = VIR_BUFFER_INITIALIZER; /* in order to perform the validation resolve the alias first */ @@ -302,8 +301,6 @@ vshCmddefCheckInternals(vshControl *ctl, for (i = 0; cmd->opts[i].name; i++) { const vshCmdOptDef *opt = &cmd->opts[i]; - bool isPositional = false; - bool isRequired = false; if (i > 63) { vshError(ctl, "command '%s' has too many options", cmd->name); @@ -402,10 +399,6 @@ vshCmddefCheckInternals(vshControl *ctl, opt->name, cmd->name); return -1; } - - isRequired = opt->flags & VSH_OFLAG_REQ; - /* ARGV argument is positional if there are no positional options */ - isPositional = !seenPositionalOption; break; case VSH_OT_DATA: @@ -415,10 +408,6 @@ vshCmddefCheckInternals(vshControl *ctl, return -1; } - isRequired = true; - isPositional = true; - seenPositionalOption = true; - if (seenOptionalOption) { vshError(ctl, "parameter '%s' of command '%s' must be listed before optional parameters", opt->name, cmd->name); @@ -433,33 +422,10 @@ vshCmddefCheckInternals(vshControl *ctl, opt->name, cmd->name); return -1; } - - isRequired = true; - - /* allow INT arguments which are required and non-positional */ - if (!(opt->flags & VSH_OFLAG_REQ_OPT)) { - seenPositionalOption = true; - isPositional = true; - } - } else { - isPositional = false; - isRequired = false; } break; } - - if (opt->required != isRequired) { - vshError(ctl, "parameter '%s' of command '%s' 'required' state mismatch", - opt->name, cmd->name); - return -1; - } - - if (opt->positional != isPositional) { - vshError(ctl, "parameter '%s' of command '%s' 'positional' state mismatch", - opt->name, cmd->name); - return -1; - } } virBufferTrim(&complbuf, ", "); -- 2.47.2