From f1fc9d3af5262402ac4bcf3da0be631fded70eae Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Wed, 7 Oct 2020 13:53:38 +0700 Subject: vty: fix vty_dump_element(): do not print empty Some attributes like CMD_ATTR_LIB_COMMAND are not being printed to the XML VTY reference (despite being set), so we should not print empty "". Change-Id: Ie7e53b080c10564bfef6f0e8ddeb470e46fad387 Related: SYS#4937 --- src/vty/command.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/vty/command.c b/src/vty/command.c index d71f686f..4952567d 100644 --- a/src/vty/command.c +++ b/src/vty/command.c @@ -631,6 +631,10 @@ static const struct value_string cmd_attr_desc[] = { { 0, NULL } }; +/* Public attributes (to be printed in the VTY / XML reference) */ +#define CMD_ATTR_PUBLIC_MASK \ + (CMD_ATTR_IMMEDIATE | CMD_ATTR_NODE_EXIT) + /* Get a flag character for a global VTY command attribute */ static char cmd_attr_get_flag(unsigned int attr) { @@ -670,7 +674,7 @@ static int vty_dump_element(struct cmd_element *cmd, print_func_t print_func, vo print_func(data, " %s", xml_string, newline); /* Print global attributes and their description */ - if (cmd->attr != 0x00) { /* ... if at least one flag is set */ + if (cmd->attr & CMD_ATTR_PUBLIC_MASK) { /* ... only public ones */ print_func(data, " %s", newline); for (i = 0; i < ARRAY_SIZE(cmd_attr_desc) - 1; i++) { -- cgit v1.2.3