]> xenbits.xensource.com Git - libvirt.git/commitdiff
vshCmddefCheckInternals: Remove refactoring safety checks
authorPeter Krempa <pkrempa@redhat.com>
Tue, 5 Mar 2024 15:23:19 +0000 (16:23 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 13 Mar 2024 14:02:52 +0000 (15:02 +0100)
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 <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tools/vsh.c

index ef6451f70e87ff0a5aa7d7711b4fdf0accd19614..e80c6e84f15b30f2621020bb079c38a7b7b9fadb 100644 (file)
@@ -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, ", ");