aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/include/vty
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2010-05-01 11:01:46 +0200
committerHarald Welte <laforge@gnumonks.org>2010-05-01 12:07:41 +0200
commitf32cc4bee55da4ff20be095eb5f4e883f2f54de6 (patch)
tree60bb59d167fa7d65e1ea2aa64822af956944ab30 /openbsc/include/vty
parent0809d79ef805fe21cb4bc4b55c78439b625b5b3d (diff)
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.
Diffstat (limited to 'openbsc/include/vty')
-rw-r--r--openbsc/include/vty/command.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/openbsc/include/vty/command.h b/openbsc/include/vty/command.h
index 03b071f70..738cce4f1 100644
--- a/openbsc/include/vty/command.h
+++ b/openbsc/include/vty/command.h
@@ -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)