summaryrefslogtreecommitdiffstats
path: root/src/vlib
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2019-12-11 09:46:56 -0500
committerFlorin Coras <florin.coras@gmail.com>2019-12-12 18:02:48 +0000
commit6d5df8d22971280c8a22b0d96656f4922fe06d56 (patch)
treea79230de8a21b96ca996306b66a270f5e2cdd354 /src/vlib
parentef4f3e7fea359f651c548182a7597abc066ca372 (diff)
vlib: fix "<command> help"
Walk the sub_commands vector directly. Type: fix Fixes: 6b3f25caff262b536a5449ac5461dd041c92a655 Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: I3022b39e5a739647ec68effc6756166ce2da85b6
Diffstat (limited to 'src/vlib')
-rw-r--r--src/vlib/cli.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/vlib/cli.c b/src/vlib/cli.c
index 0ecdac386f3..6088fc215a8 100644
--- a/src/vlib/cli.c
+++ b/src/vlib/cli.c
@@ -392,8 +392,6 @@ vlib_cli_dispatch_sub_commands (vlib_main_t * vm,
unformat_input_t sub_input;
u8 *string;
uword is_main_dispatch = cm == &vm->cli_main;
- uword value;
- u8 *key;
parent = vec_elt_at_index (cm->commands, parent_command_index);
if (is_main_dispatch && unformat (input, "help"))
@@ -428,17 +426,15 @@ vlib_cli_dispatch_sub_commands (vlib_main_t * vm,
else
{
vlib_cli_sub_rule_t *sr, *subs = 0;
-
- /* *INDENT-OFF* */
- hash_foreach_mem (key, value, c->sub_command_index_by_name,
- ({
- (void) key;
- vec_add2 (subs, sr, 1);
- sr->name = c->sub_commands[value].name;
- sr->command_index = value;
- sr->rule_index = ~0;
- }));
- /* *INDENT-ON* */
+ vlib_cli_sub_command_t *sc;
+
+ vec_foreach (sc, c->sub_commands)
+ {
+ vec_add2 (subs, sr, 1);
+ sr->name = sc->name;
+ sr->command_index = sc->index;
+ sr->rule_index = ~0;
+ }
vec_sort_with_function (subs, vlib_cli_cmp_rule);