VTY: ensure all cmd_elements are declared 'static'
While doing 'nm' on a VTY-using object file I noticed that all cmd_elements are global symbols, which is not good. Unfortuantely there are some vty-internal cmd_elements that need to span across object files, so I had to introduce gDEFUN() and gALIAS(). The old macros now all declare static structures.
This commit is contained in:
parent
0809d79ef8
commit
f32cc4bee5
|
@ -173,6 +173,17 @@ struct desc {
|
|||
|
||||
/* helper defines for end-user DEFUN* macros */
|
||||
#define DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attrs, dnum) \
|
||||
static struct cmd_element cmdname = \
|
||||
{ \
|
||||
.string = cmdstr, \
|
||||
.func = funcname, \
|
||||
.doc = helpstr, \
|
||||
.attr = attrs, \
|
||||
.daemon = dnum, \
|
||||
};
|
||||
|
||||
/* global (non static) cmd_element */
|
||||
#define gDEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attrs, dnum) \
|
||||
struct cmd_element cmdname = \
|
||||
{ \
|
||||
.string = cmdstr, \
|
||||
|
@ -195,6 +206,12 @@ struct desc {
|
|||
DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, 0) \
|
||||
DEFUN_CMD_FUNC_TEXT(funcname)
|
||||
|
||||
/* global (non static) cmd_element */
|
||||
#define gDEFUN(funcname, cmdname, cmdstr, helpstr) \
|
||||
DEFUN_CMD_FUNC_DECL(funcname) \
|
||||
gDEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, 0) \
|
||||
DEFUN_CMD_FUNC_TEXT(funcname)
|
||||
|
||||
#define DEFUN_ATTR(funcname, cmdname, cmdstr, helpstr, attr) \
|
||||
DEFUN_CMD_FUNC_DECL(funcname) \
|
||||
DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attr, 0) \
|
||||
|
@ -236,6 +253,10 @@ struct desc {
|
|||
#define ALIAS(funcname, cmdname, cmdstr, helpstr) \
|
||||
DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, 0)
|
||||
|
||||
/* global (non static) cmd_element */
|
||||
#define gALIAS(funcname, cmdname, cmdstr, helpstr) \
|
||||
gDEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, 0)
|
||||
|
||||
#define ALIAS_ATTR(funcname, cmdname, cmdstr, helpstr, attr) \
|
||||
DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attr, 0)
|
||||
|
||||
|
|
|
@ -2311,7 +2311,7 @@ DEFUN(disable,
|
|||
}
|
||||
|
||||
/* Down vty node level. */
|
||||
DEFUN(config_exit,
|
||||
gDEFUN(config_exit,
|
||||
config_exit_cmd, "exit", "Exit current mode and down to previous mode\n")
|
||||
{
|
||||
switch (vty->node) {
|
||||
|
@ -2372,11 +2372,11 @@ DEFUN(config_exit,
|
|||
}
|
||||
|
||||
/* quit is alias of exit. */
|
||||
ALIAS(config_exit,
|
||||
gALIAS(config_exit,
|
||||
config_quit_cmd, "quit", "Exit current mode and down to previous mode\n")
|
||||
|
||||
/* End of configuration. */
|
||||
DEFUN(config_end,
|
||||
gDEFUN(config_end,
|
||||
config_end_cmd, "end", "End current mode and change to enable mode.")
|
||||
{
|
||||
switch (vty->node) {
|
||||
|
@ -2407,7 +2407,7 @@ DEFUN(show_version,
|
|||
}
|
||||
|
||||
/* Help display function for all node. */
|
||||
DEFUN(config_help,
|
||||
gDEFUN(config_help,
|
||||
config_help_cmd, "help", "Description of the interactive help system\n")
|
||||
{
|
||||
vty_out(vty,
|
||||
|
@ -2428,7 +2428,7 @@ argument.%s\
|
|||
}
|
||||
|
||||
/* Help display function for all node. */
|
||||
DEFUN(config_list, config_list_cmd, "list", "Print command list\n")
|
||||
gDEFUN(config_list, config_list_cmd, "list", "Print command list\n")
|
||||
{
|
||||
unsigned int i;
|
||||
struct cmd_node *cnode = vector_slot(cmdvec, vty->node);
|
||||
|
|
Loading…
Reference in New Issue