From 1b3e9a21dd4af572deed0d40dd26c8d041e94eae Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Wed, 27 Nov 2019 21:17:57 +0100 Subject: [PATCH] lib: make some variables static Signed-off-by: David Lamparter --- lib/agg_table.c | 2 +- lib/command_lex.l | 2 +- lib/if.c | 2 +- lib/netns_linux.c | 7 ++++--- lib/netns_other.c | 2 +- lib/nexthop_group.c | 2 +- lib/ns.h | 2 -- lib/routemap.c | 6 +++--- lib/systemd.c | 4 ++-- lib/vrf.c | 4 ++-- lib/vty.c | 2 +- lib/yang.c | 2 +- lib/yang.h | 3 --- 13 files changed, 18 insertions(+), 22 deletions(-) diff --git a/lib/agg_table.c b/lib/agg_table.c index dad6a13d67..22b981e284 100644 --- a/lib/agg_table.c +++ b/lib/agg_table.c @@ -41,7 +41,7 @@ static void agg_node_destroy(route_table_delegate_t *delegate, XFREE(MTYPE_TMP, anode); } -route_table_delegate_t agg_table_delegate = { +static route_table_delegate_t agg_table_delegate = { .create_node = agg_node_create, .destroy_node = agg_node_destroy, }; diff --git a/lib/command_lex.l b/lib/command_lex.l index f361db78e9..0556605d63 100644 --- a/lib/command_lex.l +++ b/lib/command_lex.l @@ -85,7 +85,7 @@ RANGE \({NUMBER}[ ]?\-[ ]?{NUMBER}\) . {return yytext[0];} %% -YY_BUFFER_STATE buffer; +static YY_BUFFER_STATE buffer; void set_lexer_string (yyscan_t *scn, const char *string) { diff --git a/lib/if.c b/lib/if.c index 31c1d9e8ba..c91407084e 100644 --- a/lib/if.c +++ b/lib/if.c @@ -58,7 +58,7 @@ DEFINE_QOBJ_TYPE(interface) DEFINE_HOOK(if_add, (struct interface * ifp), (ifp)) DEFINE_KOOH(if_del, (struct interface * ifp), (ifp)) -struct interface_master{ +static struct interface_master{ int (*create_hook)(struct interface *ifp); int (*up_hook)(struct interface *ifp); int (*down_hook)(struct interface *ifp); diff --git a/lib/netns_linux.c b/lib/netns_linux.c index 55c66fdc3d..d1a31ae35f 100644 --- a/lib/netns_linux.c +++ b/lib/netns_linux.c @@ -51,7 +51,7 @@ static struct ns *ns_lookup_name_internal(const char *name); RB_GENERATE(ns_head, ns, entry, ns_compare) -struct ns_head ns_tree = RB_INITIALIZER(&ns_tree); +static struct ns_head ns_tree = RB_INITIALIZER(&ns_tree); static struct ns *default_ns; static int ns_current_ns_fd; @@ -74,7 +74,8 @@ static inline int ns_map_compare(const struct ns_map_nsid *a, RB_HEAD(ns_map_nsid_head, ns_map_nsid); RB_PROTOTYPE(ns_map_nsid_head, ns_map_nsid, id_entry, ns_map_compare); RB_GENERATE(ns_map_nsid_head, ns_map_nsid, id_entry, ns_map_compare); -struct ns_map_nsid_head ns_map_nsid_list = RB_INITIALIZER(&ns_map_nsid_list); +static struct ns_map_nsid_head ns_map_nsid_list = + RB_INITIALIZER(&ns_map_nsid_list); static ns_id_t ns_id_external_numbering; @@ -123,7 +124,7 @@ static int have_netns(void) } /* Holding NS hooks */ -struct ns_master { +static struct ns_master { int (*ns_new_hook)(struct ns *ns); int (*ns_delete_hook)(struct ns *ns); int (*ns_enable_hook)(struct ns *ns); diff --git a/lib/netns_other.c b/lib/netns_other.c index b0aae4f8df..740d2b621e 100644 --- a/lib/netns_other.c +++ b/lib/netns_other.c @@ -34,7 +34,7 @@ static inline int ns_compare(const struct ns *ns, const struct ns *ns2); RB_GENERATE(ns_head, ns, entry, ns_compare) -struct ns_head ns_tree = RB_INITIALIZER(&ns_tree); +static struct ns_head ns_tree = RB_INITIALIZER(&ns_tree); static inline int ns_compare(const struct ns *a, const struct ns *b) { diff --git a/lib/nexthop_group.c b/lib/nexthop_group.c index 991843a047..8d2e7bb3fc 100644 --- a/lib/nexthop_group.c +++ b/lib/nexthop_group.c @@ -752,7 +752,7 @@ DEFPY(ecmp_nexthops, ecmp_nexthops_cmd, return CMD_SUCCESS; } -struct cmd_node nexthop_group_node = { +static struct cmd_node nexthop_group_node = { NH_GROUP_NODE, "%s(config-nh-group)# ", 1 diff --git a/lib/ns.h b/lib/ns.h index 1963b8a359..20e0a38e3b 100644 --- a/lib/ns.h +++ b/lib/ns.h @@ -71,8 +71,6 @@ struct ns { RB_HEAD(ns_head, ns); RB_PROTOTYPE(ns_head, ns, entry, ns_compare) -extern struct ns_head ns_tree; - /* * API for managing NETNS. eg from zebra daemon * one want to manage the list of NETNS, etc... diff --git a/lib/routemap.c b/lib/routemap.c index c0e01488b2..14fec0283c 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -221,7 +221,7 @@ struct route_map_match_set_hooks { const char *command, const char *arg); }; -struct route_map_match_set_hooks rmap_match_set_hook; +static struct route_map_match_set_hooks rmap_match_set_hook; /* match interface */ void route_map_match_interface_hook(int (*func)( @@ -623,7 +623,7 @@ struct route_map_list { /* Master list of route map. */ static struct route_map_list route_map_master = {NULL, NULL, NULL, NULL, NULL}; -struct hash *route_map_master_hash = NULL; +static struct hash *route_map_master_hash = NULL; static unsigned int route_map_hash_key_make(const void *p) { @@ -683,7 +683,7 @@ struct route_map_dep_data { }; /* Hashes maintaining dependency between various sublists used by route maps */ -struct hash *route_map_dep_hash[ROUTE_MAP_DEP_MAX]; +static struct hash *route_map_dep_hash[ROUTE_MAP_DEP_MAX]; static unsigned int route_map_dep_hash_make_key(const void *p); static void route_map_clear_all_references(char *rmap_name); diff --git a/lib/systemd.c b/lib/systemd.c index 44db48d006..16fbbff380 100644 --- a/lib/systemd.c +++ b/lib/systemd.c @@ -93,8 +93,8 @@ void systemd_send_stopping(void) /* * How many seconds should we wait between watchdog sends */ -int wsecs = 0; -struct thread_master *systemd_master = NULL; +static int wsecs = 0; +static struct thread_master *systemd_master = NULL; static int systemd_send_watchdog(struct thread *t) { diff --git a/lib/vrf.c b/lib/vrf.c index 2411cc3111..6ca6482e08 100644 --- a/lib/vrf.c +++ b/lib/vrf.c @@ -67,7 +67,7 @@ static char vrf_default_name[VRF_NAMSIZ] = VRF_DEFAULT_NAME_INTERNAL; static int debug_vrf = 0; /* Holding VRF hooks */ -struct vrf_master { +static struct vrf_master { int (*vrf_new_hook)(struct vrf *); int (*vrf_delete_hook)(struct vrf *); int (*vrf_enable_hook)(struct vrf *); @@ -752,7 +752,7 @@ DEFUN (no_vrf, } -struct cmd_node vrf_node = {VRF_NODE, "%s(config-vrf)# ", 1}; +static struct cmd_node vrf_node = {VRF_NODE, "%s(config-vrf)# ", 1}; DEFUN_NOSH (vrf_netns, vrf_netns_cmd, diff --git a/lib/vty.c b/lib/vty.c index c08e5e151a..40da8abcd7 100644 --- a/lib/vty.c +++ b/lib/vty.c @@ -89,7 +89,7 @@ static char *vty_ipv6_accesslist_name = NULL; static vector Vvty_serv_thread; /* Current directory. */ -char vty_cwd[MAXPATHLEN]; +static char vty_cwd[MAXPATHLEN]; /* Login password check. */ static int no_password_check = 0; diff --git a/lib/yang.c b/lib/yang.c index d153f75530..78ea7d0dd0 100644 --- a/lib/yang.c +++ b/lib/yang.c @@ -87,7 +87,7 @@ static inline int yang_module_compare(const struct yang_module *a, } RB_GENERATE(yang_modules, yang_module, entry, yang_module_compare) -struct yang_modules yang_modules = RB_INITIALIZER(&yang_modules); +static struct yang_modules yang_modules = RB_INITIALIZER(&yang_modules); struct yang_module *yang_module_load(const char *module_name) { diff --git a/lib/yang.h b/lib/yang.h index 6892e36019..ae3e782029 100644 --- a/lib/yang.h +++ b/lib/yang.h @@ -114,9 +114,6 @@ typedef int (*yang_iterate_cb)(const struct lys_node *snode, void *arg); /* Global libyang context for native FRR models. */ extern struct ly_ctx *ly_native_ctx; -/* Tree of all loaded YANG modules. */ -extern struct yang_modules yang_modules; - /* * Create a new YANG module and load it using libyang. If the YANG module is not * found in the YANG_MODELS_PATH directory, the program will exit with an error. -- 2.39.5