]> xenbits.xensource.com Git - libvirt.git/commitdiff
vsh: Remove VSH_CMD_FLAG_ALIAS
authorPeter Krempa <pkrempa@redhat.com>
Fri, 1 Mar 2024 22:14:51 +0000 (23:14 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 13 Mar 2024 14:02:51 +0000 (15:02 +0100)
It's obvious that a command is an alias when the 'alias' property is
set, thus an extra flag is redundant. Remove it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tools/virsh-nodedev.c
tools/virsh.c
tools/virt-admin.c
tools/vsh.c
tools/vsh.h

index c08de65a96290aa282054c362e38bc066d150473..b5a88b194f69ebb0f7100633846dac2f4b1f3201 100644 (file)
@@ -1415,7 +1415,6 @@ const vshCmdDef nodedevCmds[] = {
      .flags = 0
     },
     {.name = "nodedev-dettach",
-     .flags = VSH_CMD_FLAG_ALIAS,
      .alias = "nodedev-detach"
     },
     {.name = "nodedev-dumpxml",
index 18cd279aba73cb28ecf091de2cca14e63a4ed144..0d860d03909a4f8cbd27cd62ce7189c56506abc9 100644 (file)
@@ -460,7 +460,7 @@ virshUsage(void)
         fprintf(stdout, _(" %1$s (help keyword '%2$s')\n"),
                 grp->name, grp->keyword);
         for (cmd = grp->commands; cmd->name; cmd++) {
-            if (cmd->flags & VSH_CMD_FLAG_ALIAS ||
+            if (cmd->alias ||
                 cmd->flags & VSH_CMD_FLAG_HIDDEN)
                 continue;
             fprintf(stdout,
index f551b33c4b268f100701bce010e7b9538c4404bb..27bd123bfe392e2e324c370edb9fcd00ac3657a7 100644 (file)
@@ -1262,7 +1262,7 @@ vshAdmUsage(void)
         fprintf(stdout, _(" %1$s (help keyword '%2$s')\n"),
                 grp->name, grp->keyword);
         for (cmd = grp->commands; cmd->name; cmd++) {
-            if (cmd->flags & VSH_CMD_FLAG_ALIAS ||
+            if (cmd->alias ||
                 cmd->flags & VSH_CMD_FLAG_HIDDEN)
                 continue;
             fprintf(stdout,
@@ -1429,7 +1429,6 @@ static const vshCmdDef vshAdmCmds[] = {
 
 static const vshCmdDef monitoringCmds[] = {
     {.name = "srv-list",
-     .flags = VSH_CMD_FLAG_ALIAS,
      .alias = "server-list"
     },
     {.name = "server-list",
@@ -1439,7 +1438,6 @@ static const vshCmdDef monitoringCmds[] = {
      .flags = 0
     },
     {.name = "srv-threadpool-info",
-     .flags = VSH_CMD_FLAG_ALIAS,
      .alias = "server-threadpool-info"
     },
     {.name = "server-threadpool-info",
@@ -1449,7 +1447,6 @@ static const vshCmdDef monitoringCmds[] = {
      .flags = 0
     },
     {.name = "srv-clients-list",
-     .flags = VSH_CMD_FLAG_ALIAS,
      .alias = "client-list"
     },
     {.name = "client-list",
@@ -1465,7 +1462,6 @@ static const vshCmdDef monitoringCmds[] = {
      .flags = 0
     },
     {.name = "srv-clients-info",
-     .flags = VSH_CMD_FLAG_ALIAS,
      .alias = "server-clients-info"
     },
     {.name = "server-clients-info",
@@ -1479,7 +1475,6 @@ static const vshCmdDef monitoringCmds[] = {
 
 static const vshCmdDef managementCmds[] = {
     {.name = "srv-threadpool-set",
-     .flags = VSH_CMD_FLAG_ALIAS,
      .alias = "server-threadpool-set"
     },
     {.name = "server-threadpool-set",
@@ -1495,7 +1490,6 @@ static const vshCmdDef managementCmds[] = {
      .flags = 0
     },
     {.name = "srv-clients-set",
-     .flags = VSH_CMD_FLAG_ALIAS,
      .alias = "server-clients-set"
     },
     {.name = "server-clients-set",
@@ -1505,7 +1499,6 @@ static const vshCmdDef managementCmds[] = {
      .flags = 0
     },
     {.name = "srv-update-tls",
-     .flags = VSH_CMD_FLAG_ALIAS,
      .alias = "server-update-tls"
     },
     {.name = "server-update-tls",
index ad72b91d6c7048fbf527c748ee3c505a723965e7..63424fcf8fad04831113a162f51edc65fae5187c 100644 (file)
@@ -268,21 +268,16 @@ vshCmddefCheckInternals(vshControl *ctl,
     g_auto(virBuffer) complbuf = VIR_BUFFER_INITIALIZER;
 
     /* in order to perform the validation resolve the alias first */
-    if (cmd->flags & VSH_CMD_FLAG_ALIAS) {
+    if (cmd->alias) {
         const vshCmdDef *alias;
 
-        if (!cmd->alias) {
-            vshError(ctl, "command '%s' has inconsistent alias", cmd->name);
-            return -1;
-        }
-
         if (!(alias = vshCmddefSearch(cmd->alias))) {
             vshError(ctl, "command alias '%s' is pointing to a non-existent command '%s'",
                      cmd->name, cmd->alias);
             return -1;
         }
 
-        if (alias->flags & VSH_CMD_FLAG_ALIAS) {
+        if (alias->alias) {
             vshError(ctl, "command alias '%s' is pointing to another command alias '%s'",
                      cmd->name, cmd->alias);
             return -1;
@@ -303,7 +298,7 @@ vshCmddefCheckInternals(vshControl *ctl,
             return -1;
         }
 
-        if (cmd->flags & ~VSH_CMD_FLAG_ALIAS) {
+        if (cmd->flags != 0) {
             vshError(ctl, "command '%s' has multiple flags set", cmd->name);
             return -1;
         }
@@ -615,7 +610,7 @@ vshCmdGrpHelp(vshControl *ctl, const vshCmdGrp *grp)
              grp->keyword);
 
     for (cmd = grp->commands; cmd->name; cmd++) {
-        if (cmd->flags & VSH_CMD_FLAG_ALIAS ||
+        if (cmd->alias ||
             cmd->flags & VSH_CMD_FLAG_HIDDEN)
             continue;
         vshPrint(ctl, "    %-30s %s\n", cmd->name,
@@ -1407,7 +1402,7 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser, vshCmd **partial)
                 }
 
                 /* aliases need to be resolved to the actual commands */
-                if (cmd->flags & VSH_CMD_FLAG_ALIAS) {
+                if (cmd->alias) {
                     VIR_FREE(tkdata);
                     tkdata = g_strdup(cmd->alias);
                     if (!(cmd = vshCmddefSearch(tkdata))) {
@@ -2630,7 +2625,7 @@ vshReadlineCommandGenerator(void)
         for (cmd_list_index = 0; cmds[cmd_list_index].name; cmd_list_index++) {
             const char *name = cmds[cmd_list_index].name;
 
-            if (cmds[cmd_list_index].flags & VSH_CMD_FLAG_ALIAS ||
+            if (cmds[cmd_list_index].alias ||
                 cmds[cmd_list_index].flags & VSH_CMD_FLAG_HIDDEN)
                 continue;
 
@@ -3131,7 +3126,7 @@ cmdHelp(vshControl *ctl, const vshCmd *cmd)
                      grp->keyword);
 
             for (def = grp->commands; def->name; def++) {
-                if (def->flags & VSH_CMD_FLAG_ALIAS ||
+                if (def->alias ||
                     def->flags & VSH_CMD_FLAG_HIDDEN)
                     continue;
                 vshPrint(ctl, "    %-30s %s\n", def->name,
@@ -3145,7 +3140,7 @@ cmdHelp(vshControl *ctl, const vshCmd *cmd)
     }
 
     if ((def = vshCmddefSearch(name))) {
-        if (def->flags & VSH_CMD_FLAG_ALIAS)
+        if (def->alias)
             def = vshCmddefSearch(def->alias);
     }
 
index c49bed9d59979ce594b366b41732c68527de3573..57aa613382c3ec8f99b13a0cd1ee236d2265362a 100644 (file)
@@ -162,8 +162,7 @@ struct _vshCmdOpt {
  */
 enum {
     VSH_CMD_FLAG_NOCONNECT = (1 << 0),  /* no prior connection needed */
-    VSH_CMD_FLAG_ALIAS     = (1 << 1),  /* command is an alias */
-    VSH_CMD_FLAG_HIDDEN    = (1 << 2),  /* command is hidden/internal */
+    VSH_CMD_FLAG_HIDDEN    = (1 << 1),  /* command is hidden/internal */
 };
 
 /*