diff options
64 files changed, 194 insertions, 174 deletions
diff --git a/babeld/babel_main.c b/babeld/babel_main.c index bb3378f4f..6f4b905c1 100644 --- a/babeld/babel_main.c +++ b/babeld/babel_main.c @@ -74,7 +74,7 @@ unsigned char protocol_group[16]; /* babel's link-local multicast address */ int protocol_port; /* babel's port */ int protocol_socket = -1; /* socket: communicate with others babeld */ -static char babel_config_default[] = SYSCONFDIR BABEL_DEFAULT_CONFIG; +static const char babel_config_default[] = SYSCONFDIR BABEL_DEFAULT_CONFIG; static char *babel_vty_addr = NULL; static int babel_vty_port = BABEL_VTY_PORT; diff --git a/babeld/babel_zebra.c b/babeld/babel_zebra.c index 5a336df7b..86f8bc721 100644 --- a/babeld/babel_zebra.c +++ b/babeld/babel_zebra.c @@ -39,7 +39,7 @@ void babelz_zebra_init(void); struct zclient *zclient; /* Debug types */ -static struct { +static const struct { int type; int str_min_len; const char *str; diff --git a/bfdd/bfd.h b/bfdd/bfd.h index eddfde62f..ac413cafc 100644 --- a/bfdd/bfd.h +++ b/bfdd/bfd.h @@ -399,8 +399,8 @@ struct bfd_global { struct zebra_privs_t bfdd_privs; }; extern struct bfd_global bglobal; -extern struct bfd_diag_str_list diag_list[]; -extern struct bfd_state_str_list state_list[]; +extern const struct bfd_diag_str_list diag_list[]; +extern const struct bfd_state_str_list state_list[]; void socket_close(int *s); diff --git a/bfdd/bfdd.c b/bfdd/bfdd.c index a9528646d..341edbe5c 100644 --- a/bfdd/bfdd.c +++ b/bfdd/bfdd.c @@ -122,7 +122,7 @@ FRR_DAEMON_INFO(bfdd, BFD, .vty_port = 2617, .n_yang_modules = array_size(bfdd_yang_modules)) #define OPTION_CTLSOCK 1001 -static struct option longopts[] = { +static const struct option longopts[] = { {"bfdctl", required_argument, NULL, OPTION_CTLSOCK}, {0} }; @@ -133,7 +133,7 @@ static struct option longopts[] = { */ struct bfd_global bglobal; -struct bfd_diag_str_list diag_list[] = { +const struct bfd_diag_str_list diag_list[] = { {.str = "control-expired", .type = BD_CONTROL_EXPIRED}, {.str = "echo-failed", .type = BD_ECHO_FAILED}, {.str = "neighbor-down", .type = BD_NEIGHBOR_DOWN}, @@ -145,7 +145,7 @@ struct bfd_diag_str_list diag_list[] = { {.str = NULL}, }; -struct bfd_state_str_list state_list[] = { +const struct bfd_state_str_list state_list[] = { {.str = "admin-down", .type = PTM_BFD_ADM_DOWN}, {.str = "down", .type = PTM_BFD_DOWN}, {.str = "init", .type = PTM_BFD_INIT}, diff --git a/bgpd/bgp_addpath.c b/bgpd/bgp_addpath.c index cf51960b7..e7e7c3cc1 100644 --- a/bgpd/bgp_addpath.c +++ b/bgpd/bgp_addpath.c @@ -24,7 +24,7 @@ #include "bgp_addpath.h" #include "bgp_route.h" -static struct bgp_addpath_strategy_names strat_names[BGP_ADDPATH_MAX] = { +static const struct bgp_addpath_strategy_names strat_names[BGP_ADDPATH_MAX] = { { .config_name = "addpath-tx-all-paths", .human_name = "All", @@ -41,7 +41,7 @@ static struct bgp_addpath_strategy_names strat_names[BGP_ADDPATH_MAX] = { } }; -static struct bgp_addpath_strategy_names unknown_names = { +static const struct bgp_addpath_strategy_names unknown_names = { .config_name = "addpath-tx-unknown", .human_name = "Unknown-Addpath-Strategy", .human_description = "Unknown Addpath Strategy", @@ -53,7 +53,7 @@ static struct bgp_addpath_strategy_names unknown_names = { * Returns a structure full of strings associated with an addpath type. Will * never return null. */ -struct bgp_addpath_strategy_names * +const struct bgp_addpath_strategy_names * bgp_addpath_names(enum bgp_addpath_strat strat) { if (strat < BGP_ADDPATH_MAX) diff --git a/bgpd/bgp_addpath.h b/bgpd/bgp_addpath.h index c0c182791..786873a00 100644 --- a/bgpd/bgp_addpath.h +++ b/bgpd/bgp_addpath.h @@ -48,7 +48,7 @@ int bgp_addpath_info_has_ids(struct bgp_addpath_info_data *d); uint32_t bgp_addpath_id_for_peer(struct peer *peer, afi_t afi, safi_t safi, struct bgp_addpath_info_data *d); -struct bgp_addpath_strategy_names * +const struct bgp_addpath_strategy_names * bgp_addpath_names(enum bgp_addpath_strat strat); int bgp_addpath_dmed_required(int strategy); diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c index 4257b601f..5fa773c95 100644 --- a/bgpd/bgp_aspath.c +++ b/bgpd/bgp_aspath.c @@ -102,8 +102,10 @@ static void assegment_data_free(as_t *asdata) XFREE(MTYPE_AS_SEG_DATA, asdata); } -const char *aspath_segment_type_str[] = {"as-invalid", "as-set", "as-sequence", - "as-confed-sequence", "as-confed-set"}; +const char *const aspath_segment_type_str[] = { + "as-invalid", "as-set", "as-sequence", "as-confed-sequence", + "as-confed-set" +}; /* Get a new segment. Note that 0 is an allowed length, * and will result in a segment with no allocated data segment. diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c index 0e4c3a3e1..f716c4f30 100644 --- a/bgpd/bgp_debug.c +++ b/bgpd/bgp_debug.c @@ -101,7 +101,7 @@ const struct message bgp_status_msg[] = {{Idle, "Idle"}, {0}}; /* BGP message type string. */ -const char *bgp_type_str[] = {NULL, "OPEN", "UPDATE", +const char *const bgp_type_str[] = {NULL, "OPEN", "UPDATE", "NOTIFICATION", "KEEPALIVE", "ROUTE-REFRESH", "CAPABILITY"}; @@ -169,8 +169,8 @@ static const struct message bgp_notify_capability_msg[] = { {0}}; /* Origin strings. */ -const char *bgp_origin_str[] = {"i", "e", "?"}; -const char *bgp_origin_long_str[] = {"IGP", "EGP", "incomplete"}; +const char *const bgp_origin_str[] = {"i", "e", "?"}; +const char *const bgp_origin_long_str[] = {"IGP", "EGP", "incomplete"}; static int bgp_debug_print_evpn_prefix(struct vty *vty, const char *desc, struct prefix *p); diff --git a/bgpd/bgp_debug.h b/bgpd/bgp_debug.h index e05da3764..e1072c3df 100644 --- a/bgpd/bgp_debug.h +++ b/bgpd/bgp_debug.h @@ -151,8 +151,7 @@ struct bgp_debug_filter { #define BGP_DEBUG(a, b) (term_bgp_debug_ ## a & BGP_DEBUG_ ## b) #define CONF_BGP_DEBUG(a, b) (conf_bgp_debug_ ## a & BGP_DEBUG_ ## b) -extern const char *bgp_type_str[]; -extern const char *pmsi_tnltype_str[]; +extern const char *const bgp_type_str[]; extern int bgp_dump_attr(struct attr *, char *, size_t); extern int bgp_debug_peer_updout_enabled(char *host); diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index 1e5883814..6460ff76f 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -62,7 +62,7 @@ DEFINE_HOOK(peer_status_changed, (struct peer * peer), (peer)) /* Definition of display strings corresponding to FSM events. This should be * kept consistent with the events defined in bgpd.h */ -static const char *bgp_event_str[] = { +static const char *const bgp_event_str[] = { NULL, "BGP_Start", "BGP_Stop", @@ -522,7 +522,7 @@ int bgp_routeadv_timer(struct thread *thread) } /* BGP Peer Down Cause */ -const char *peer_down_str[] = {"", +const char *const peer_down_str[] = {"", "Router ID changed", "Remote AS changed", "Local AS change", diff --git a/bgpd/bgp_fsm.h b/bgpd/bgp_fsm.h index 9d0500ae2..6f955c71b 100644 --- a/bgpd/bgp_fsm.h +++ b/bgpd/bgp_fsm.h @@ -64,7 +64,7 @@ extern int bgp_stop(struct peer *peer); extern void bgp_timer_set(struct peer *); extern int bgp_routeadv_timer(struct thread *); extern void bgp_fsm_change_status(struct peer *peer, int status); -extern const char *peer_down_str[]; +extern const char *const peer_down_str[]; extern void bgp_update_delay_end(struct bgp *); extern void bgp_maxmed_update(struct bgp *); extern int bgp_maxmed_onstartup_configured(struct bgp *); diff --git a/bgpd/bgp_io.c b/bgpd/bgp_io.c index 9e1c89b71..fed34e5b6 100644 --- a/bgpd/bgp_io.c +++ b/bgpd/bgp_io.c @@ -508,7 +508,7 @@ static bool validate_header(struct peer *peer) uint8_t type; struct ringbuf *pkt = peer->ibuf_work; - static uint8_t m_correct[BGP_MARKER_SIZE] = { + static const uint8_t m_correct[BGP_MARKER_SIZE] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; uint8_t m_rx[BGP_MARKER_SIZE] = {0x00}; diff --git a/bgpd/bgp_keepalives.c b/bgpd/bgp_keepalives.c index 3a49e8bc0..3a5adae87 100644 --- a/bgpd/bgp_keepalives.c +++ b/bgpd/bgp_keepalives.c @@ -95,7 +95,7 @@ static void peer_process(struct hash_bucket *hb, void *arg) static struct timeval ka = {0}; // peer->v_keepalive as a timeval static struct timeval diff; // ka - elapsed - static struct timeval tolerance = {0, 100000}; + static const struct timeval tolerance = {0, 100000}; uint32_t v_ka = atomic_load_explicit(&pkat->peer->v_keepalive, memory_order_relaxed); diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index f1bd4c77d..3f4ddef9f 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -10600,7 +10600,7 @@ enum bgp_stats { BGP_STATS_MAX, }; -static const char *table_stats_strs[] = { +static const char *const table_stats_strs[] = { [BGP_STATS_PREFIXES] = "Total Prefixes", [BGP_STATS_TOTPLEN] = "Average prefix length", [BGP_STATS_RIB] = "Total Advertisements", @@ -10858,7 +10858,7 @@ enum bgp_pcounts { PCOUNT_MAX, }; -static const char *pcount_strs[] = { +static const char *const pcount_strs[] = { [PCOUNT_ADJ_IN] = "Adj-in", [PCOUNT_DAMPED] = "Damped", [PCOUNT_REMOVED] = "Removed", diff --git a/bgpd/rfapi/rfapi_vty.c b/bgpd/rfapi/rfapi_vty.c index 4fa64075c..5ad822211 100644 --- a/bgpd/rfapi/rfapi_vty.c +++ b/bgpd/rfapi/rfapi_vty.c @@ -127,8 +127,8 @@ void rfapiRprefixApplyMask(struct rfapi_ip_prefix *rprefix) int index; int offset; - static uint8_t maskbit[] = {0x00, 0x80, 0xc0, 0xe0, 0xf0, - 0xf8, 0xfc, 0xfe, 0xff}; + static const uint8_t maskbit[] = {0x00, 0x80, 0xc0, 0xe0, 0xf0, + 0xf8, 0xfc, 0xfe, 0xff}; switch (rprefix->prefix.addr_family) { case AF_INET: diff --git a/bgpd/rfapi/vnc_debug.c b/bgpd/rfapi/vnc_debug.c index 7cac7ac7a..2c5e18832 100644 --- a/bgpd/rfapi/vnc_debug.c +++ b/bgpd/rfapi/vnc_debug.c @@ -38,7 +38,7 @@ struct vnc_debug { const char *name; }; -struct vnc_debug vncdebug[] = { +static const struct vnc_debug vncdebug[] = { {VNC_DEBUG_RFAPI_QUERY, "rfapi-query"}, {VNC_DEBUG_IMPORT_BI_ATTACH, "import-bi-attach"}, {VNC_DEBUG_IMPORT_DEL_REMOTE, "import-del-remote"}, diff --git a/eigrpd/eigrp_fsm.c b/eigrpd/eigrp_fsm.c index cc6d47f48..e43eca0e0 100644 --- a/eigrpd/eigrp_fsm.c +++ b/eigrpd/eigrp_fsm.c @@ -110,7 +110,7 @@ int eigrp_fsm_event_qact(struct eigrp_fsm_action_message *); * NSM[actual/starting state][occurred event].func * Functions are should be executed within separate thread. */ -struct { +const struct { int (*func)(struct eigrp_fsm_action_message *); } NSM[EIGRP_FSM_STATE_MAX][EIGRP_FSM_EVENT_MAX] = { { diff --git a/isisd/isis_bpf.c b/isisd/isis_bpf.c index d6b85b2fa..e916a5088 100644 --- a/isisd/isis_bpf.c +++ b/isisd/isis_bpf.c @@ -65,10 +65,13 @@ uint8_t *readbuff = NULL; * ISO 10589 - 8.4.8 */ -uint8_t ALL_L1_ISS[6] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x14}; -uint8_t ALL_L2_ISS[6] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x15}; -uint8_t ALL_ISS[6] = {0x09, 0x00, 0x2B, 0x00, 0x00, 0x05}; -uint8_t ALL_ESS[6] = {0x09, 0x00, 0x2B, 0x00, 0x00, 0x04}; +static const uint8_t ALL_L1_ISS[6] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x14}; +static const uint8_t ALL_L2_ISS[6] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x15}; +#if 0 +/* missing support for P2P-over-LAN / ES-IS on BSD */ +static const uint8_t ALL_ISS[6] = {0x09, 0x00, 0x2B, 0x00, 0x00, 0x05}; +static const uint8_t ALL_ESS[6] = {0x09, 0x00, 0x2B, 0x00, 0x00, 0x04}; +#endif static char sock_buff[8192]; diff --git a/isisd/isis_csm.c b/isisd/isis_csm.c index 88676dd99..9202ed5a8 100644 --- a/isisd/isis_csm.c +++ b/isisd/isis_csm.c @@ -50,12 +50,12 @@ extern struct isis *isis; -static const char *csm_statestr[] = {"C_STATE_NA", "C_STATE_INIT", +static const char *const csm_statestr[] = {"C_STATE_NA", "C_STATE_INIT", "C_STATE_CONF", "C_STATE_UP"}; #define STATE2STR(S) csm_statestr[S] -static const char *csm_eventstr[] = { +static const char *const csm_eventstr[] = { "NO_STATE", "ISIS_ENABLE", "IF_UP_FROM_Z", "ISIS_DISABLE", "IF_DOWN_FROM_Z", }; diff --git a/isisd/isis_dlpi.c b/isisd/isis_dlpi.c index 7d3dfcb01..ea16f4af7 100644 --- a/isisd/isis_dlpi.c +++ b/isisd/isis_dlpi.c @@ -54,10 +54,13 @@ static t_uscalar_t dlpi_ctl[1024]; /* DLPI control messages */ * ISO 10589 - 8.4.8 */ -uint8_t ALL_L1_ISS[6] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x14}; -uint8_t ALL_L2_ISS[6] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x15}; -uint8_t ALL_ISS[6] = {0x09, 0x00, 0x2B, 0x00, 0x00, 0x05}; -uint8_t ALL_ESS[6] = {0x09, 0x00, 0x2B, 0x00, 0x00, 0x04}; +static const uint8_t ALL_L1_ISS[6] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x14}; +static const uint8_t ALL_L2_ISS[6] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x15}; +static const uint8_t ALL_ISS[6] = {0x09, 0x00, 0x2B, 0x00, 0x00, 0x05}; +#if 0 +/* missing support for ES-IS on Solaris */ +static const uint8_t ALL_ESS[6] = {0x09, 0x00, 0x2B, 0x00, 0x00, 0x04}; +#endif static uint8_t sock_buff[8192]; diff --git a/isisd/isis_pfpacket.c b/isisd/isis_pfpacket.c index 69ac3fc55..28a1488c3 100644 --- a/isisd/isis_pfpacket.c +++ b/isisd/isis_pfpacket.c @@ -45,7 +45,7 @@ #include "privs.h" /* tcpdump -i eth0 'isis' -dd */ -static struct sock_filter isisfilter[] = { +static const struct sock_filter isisfilter[] = { /* NB: we're in SOCK_DGRAM, so src/dst mac + length are stripped * off! * (OTOH it's a bit more lower-layer agnostic and might work @@ -57,9 +57,9 @@ static struct sock_filter isisfilter[] = { {0x6, 0, 0, 0x00040000}, {0x6, 0, 0, 0x00000000}, }; -static struct sock_fprog bpf = { +static const struct sock_fprog bpf = { .len = array_size(isisfilter), - .filter = isisfilter, + .filter = (struct sock_filter *)isisfilter, }; /* @@ -67,10 +67,10 @@ static struct sock_fprog bpf = { * ISO 10589 - 8.4.8 */ -uint8_t ALL_L1_ISS[6] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x14}; -uint8_t ALL_L2_ISS[6] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x15}; -uint8_t ALL_ISS[6] = {0x09, 0x00, 0x2B, 0x00, 0x00, 0x05}; -uint8_t ALL_ESS[6] = {0x09, 0x00, 0x2B, 0x00, 0x00, 0x04}; +static const uint8_t ALL_L1_ISS[6] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x14}; +static const uint8_t ALL_L2_ISS[6] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x15}; +static const uint8_t ALL_ISS[6] = {0x09, 0x00, 0x2B, 0x00, 0x00, 0x05}; +static const uint8_t ALL_ESS[6] = {0x09, 0x00, 0x2B, 0x00, 0x00, 0x04}; static uint8_t discard_buff[8192]; diff --git a/isisd/isis_te.c b/isisd/isis_te.c index 9871d2bcb..133707d61 100644 --- a/isisd/isis_te.c +++ b/isisd/isis_te.c @@ -60,8 +60,6 @@ #include "isisd/isis_te.h" #include "isisd/isis_zebra.h" -const char *mode2text[] = {"Disable", "Area", "AS", "Emulate"}; - /*------------------------------------------------------------------------* * Followings are control functions for MPLS-TE parameters management. *------------------------------------------------------------------------*/ diff --git a/isisd/isis_tlvs.c b/isisd/isis_tlvs.c index 442442152..df6280e5c 100644 --- a/isisd/isis_tlvs.c +++ b/isisd/isis_tlvs.c @@ -88,7 +88,7 @@ struct pack_order_entry { .what_to_pack = offsetof(struct isis_tlvs, w), \ } -static struct pack_order_entry pack_order[] = { +static const struct pack_order_entry pack_order[] = { PACK_ENTRY(OLDSTYLE_REACH, ISIS_ITEMS, oldstyle_reach), PACK_ENTRY(LAN_NEIGHBORS, ISIS_ITEMS, lan_neighbor), PACK_ENTRY(LSP_ENTRY, ISIS_ITEMS, lsp_entries), @@ -106,7 +106,7 @@ static struct pack_order_entry pack_order[] = { /* This is a forward definition. The table is actually initialized * in at the bottom. */ -static const struct tlv_ops *tlv_table[ISIS_CONTEXT_MAX][ISIS_TLV_MAX]; +static const struct tlv_ops *const tlv_table[ISIS_CONTEXT_MAX][ISIS_TLV_MAX]; /* End of _ops forward definition. */ @@ -1003,7 +1003,7 @@ static void free_items(enum isis_tlv_context context, enum isis_tlv_type type, static int pack_items_(uint16_t mtid, enum isis_tlv_context context, enum isis_tlv_type type, struct isis_item_list *items, struct stream *s, struct isis_tlvs **fragment_tlvs, - struct pack_order_entry *pe, + const struct pack_order_entry *pe, struct isis_tlvs *(*new_fragment)(struct list *l), struct list *new_fragment_arg); #define pack_items(...) pack_items_(ISIS_MT_IPV4_UNICAST, __VA_ARGS__) @@ -3095,7 +3095,7 @@ static void free_items(enum isis_tlv_context context, enum isis_tlv_type type, static int pack_item(enum isis_tlv_context context, enum isis_tlv_type type, struct isis_item *i, struct stream *s, struct isis_tlvs **fragment_tlvs, - struct pack_order_entry *pe, uint16_t mtid) + const struct pack_order_entry *pe, uint16_t mtid) { const struct tlv_ops *ops = tlv_table[context][type]; @@ -3107,7 +3107,8 @@ static int pack_item(enum isis_tlv_context context, enum isis_tlv_type type, return 1; } -static void add_item_to_fragment(struct isis_item *i, struct pack_order_entry *pe, +static void add_item_to_fragment(struct isis_item *i, + const struct pack_order_entry *pe, struct isis_tlvs *fragment_tlvs, uint16_t mtid) { struct isis_item_list *l; @@ -3126,7 +3127,7 @@ static void add_item_to_fragment(struct isis_item *i, struct pack_order_entry *p static int pack_items_(uint16_t mtid, enum isis_tlv_context context, enum isis_tlv_type type, struct isis_item_list *items, struct stream *s, struct isis_tlvs **fragment_tlvs, - struct pack_order_entry *pe, + const struct pack_order_entry *pe, struct isis_tlvs *(*new_fragment)(struct list *l), struct list *new_fragment_arg) { @@ -3401,7 +3402,7 @@ static void format_mt_items(enum isis_tlv_context context, static int pack_mt_items(enum isis_tlv_context context, enum isis_tlv_type type, struct isis_mt_item_list *m, struct stream *s, struct isis_tlvs **fragment_tlvs, - struct pack_order_entry *pe, + const struct pack_order_entry *pe, struct isis_tlvs *(*new_fragment)(struct list *l), struct list *new_fragment_arg) { @@ -3734,7 +3735,7 @@ static void update_auth(struct isis_tlvs *tlvs, struct stream *s, bool is_lsp) } } -static int handle_pack_entry(struct pack_order_entry *pe, +static int handle_pack_entry(const struct pack_order_entry *pe, struct isis_tlvs *tlvs, struct stream *stream, struct isis_tlvs **fragment_tlvs, struct isis_tlvs *(*new_fragment)(struct list *l), @@ -4079,7 +4080,7 @@ TLV_OPS(router_cap, "TLV 242 Router Capability"); ITEM_SUBTLV_OPS(prefix_sid, "Sub-TLV 3 SR Prefix-SID"); SUBTLV_OPS(ipv6_source_prefix, "Sub-TLV 22 IPv6 Source Prefix"); -static const struct tlv_ops *tlv_table[ISIS_CONTEXT_MAX][ISIS_TLV_MAX] = { +static const struct tlv_ops *const tlv_table[ISIS_CONTEXT_MAX][ISIS_TLV_MAX] = { [ISIS_CONTEXT_LSP] = { [ISIS_TLV_AREA_ADDRESSES] = &tlv_area_address_ops, [ISIS_TLV_OLDSTYLE_REACH] = &tlv_oldstyle_reach_ops, diff --git a/ldpd/ldpd.c b/ldpd/ldpd.c index 533fc9ac8..dcbcf8ce5 100644 --- a/ldpd/ldpd.c +++ b/ldpd/ldpd.c @@ -120,7 +120,7 @@ char ctl_sock_path[MAXPATHLEN]; /* LDPd options. */ #define OPTION_CTLSOCK 1001 -static struct option longopts[] = +static const struct option longopts[] = { { "ctl_socket", required_argument, NULL, OPTION_CTLSOCK}, { "instance", required_argument, NULL, 'n'}, diff --git a/ldpd/neighbor.c b/ldpd/neighbor.c index 78a6131ca..ae51490c0 100644 --- a/ldpd/neighbor.c +++ b/ldpd/neighbor.c @@ -49,7 +49,7 @@ RB_GENERATE(nbr_addr_head, nbr, addr_tree, nbr_addr_compare) RB_GENERATE(nbr_pid_head, nbr, pid_tree, nbr_pid_compare) RB_GENERATE(nbrp_head, nbr_params, entry, nbr_params_compare) -struct { +const struct { int state; enum nbr_event event; enum nbr_action action; diff --git a/lib/frr_pthread.c b/lib/frr_pthread.c index 5c71fac10..55f0b55ed 100644 --- a/lib/frr_pthread.c +++ b/lib/frr_pthread.c @@ -39,7 +39,7 @@ static int fpt_halt(struct frr_pthread *fpt, void **res); static void frr_pthread_destroy_nolock(struct frr_pthread *fpt); /* default frr_pthread attributes */ -struct frr_pthread_attr frr_pthread_attr_default = { +const struct frr_pthread_attr frr_pthread_attr_default = { .start = fpt_run, .stop = fpt_halt, }; @@ -74,7 +74,7 @@ void frr_pthread_finish(void) } } -struct frr_pthread *frr_pthread_new(struct frr_pthread_attr *attr, +struct frr_pthread *frr_pthread_new(const struct frr_pthread_attr *attr, const char *name, const char *os_name) { struct frr_pthread *fpt = NULL; diff --git a/lib/frr_pthread.h b/lib/frr_pthread.h index f70c8a0db..89519abae 100644 --- a/lib/frr_pthread.h +++ b/lib/frr_pthread.h @@ -99,7 +99,7 @@ struct frr_pthread { char os_name[OS_THREAD_NAMELEN]; }; -extern struct frr_pthread_attr frr_pthread_attr_default; +extern const struct frr_pthread_attr frr_pthread_attr_default; /* * Initializes this module. @@ -133,7 +133,7 @@ void frr_pthread_finish(void); * @param os_name - 16 characters (including '\0') thread name to set in os, * @return the created frr_pthread upon success, or NULL upon failure */ -struct frr_pthread *frr_pthread_new(struct frr_pthread_attr *attr, +struct frr_pthread *frr_pthread_new(const struct frr_pthread_attr *attr, const char *name, const char *os_name); /* diff --git a/lib/nexthop.c b/lib/nexthop.c index 73c2de0cd..d05fa8e6d 100644 --- a/lib/nexthop.c +++ b/lib/nexthop.c @@ -200,7 +200,7 @@ int nexthop_same_firsthop(struct nexthop *next1, struct nexthop *next2) */ const char *nexthop_type_to_str(enum nexthop_types_t nh_type) { - static const char *desc[] = { + static const char *const desc[] = { "none", "Directly connected", "IPv4 nexthop", "IPv4 nexthop with ifindex", "IPv6 nexthop", "IPv6 nexthop with ifindex", diff --git a/lib/printfrr.h b/lib/printfrr.h index 95dace702..f9584bcac 100644 --- a/lib/printfrr.h +++ b/lib/printfrr.h @@ -124,7 +124,7 @@ void printfrr_ext_reg(const struct printfrr_ext *); #define printfrr_ext_autoreg_p(matchs, print_fn) \ static ssize_t print_fn(char *, size_t, const char *, int, \ const void *); \ - static struct printfrr_ext _printext_##print_fn = { \ + static const struct printfrr_ext _printext_##print_fn = { \ .match = matchs, \ .print_ptr = print_fn, \ }; \ @@ -136,7 +136,7 @@ void printfrr_ext_reg(const struct printfrr_ext *); #define printfrr_ext_autoreg_i(matchs, print_fn) \ static ssize_t print_fn(char *, size_t, const char *, int, uintmax_t); \ - static struct printfrr_ext _printext_##print_fn = { \ + static const struct printfrr_ext _printext_##print_fn = { \ .match = matchs, \ .print_int = print_fn, \ }; \ diff --git a/lib/table.h b/lib/table.h index 7a69c1664..7743d5168 100644 --- a/lib/table.h +++ b/lib/table.h @@ -45,7 +45,7 @@ struct route_table; * Function vector that can be used by a client to customize the * behavior of one or more route tables. */ -typedef struct route_table_delegate_t_ route_table_delegate_t; +typedef const struct route_table_delegate_t_ route_table_delegate_t; typedef struct route_node *(*route_table_create_node_func_t)( route_table_delegate_t *, struct route_table *); diff --git a/lib/termtable.c b/lib/termtable.c index b59c1118f..b22a1ad38 100644 --- a/lib/termtable.c +++ b/lib/termtable.c @@ -27,7 +27,7 @@ DEFINE_MTYPE_STATIC(LIB, TTABLE, "ASCII table") /* clang-format off */ -struct ttable_style ttable_styles[] = { +const struct ttable_style ttable_styles[] = { { // default ascii .corner = '+', .rownums_on = false, @@ -99,7 +99,7 @@ void ttable_del(struct ttable *tt) XFREE(MTYPE_TTABLE, tt); } -struct ttable *ttable_new(struct ttable_style *style) +struct ttable *ttable_new(const struct ttable_style *style) { struct ttable *tt; diff --git a/lib/termtable.h b/lib/termtable.h index 4f7c595ce..698cc7346 100644 --- a/lib/termtable.h +++ b/lib/termtable.h @@ -80,7 +80,7 @@ struct ttable { #define TTSTYLE_ASCII 0 #define TTSTYLE_BLANK 1 -extern struct ttable_style ttable_styles[2]; +extern const struct ttable_style ttable_styles[2]; /** * Creates a new table with the default style, which looks like this: @@ -95,7 +95,7 @@ extern struct ttable_style ttable_styles[2]; * * @return the created table */ -struct ttable *ttable_new(struct ttable_style *tts); +struct ttable *ttable_new(const struct ttable_style *tts); /** * Deletes a table and releases all associated resources. diff --git a/lib/thread.c b/lib/thread.c index 649fe500c..651d26dfb 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -66,7 +66,7 @@ DECLARE_HEAP(thread_timer_list, struct thread, timeritem, #define AWAKEN(m) \ do { \ - static unsigned char wakebyte = 0x01; \ + const unsigned char wakebyte = 0x01; \ write(m->io_pipe[1], &wakebyte, 1); \ } while (0); diff --git a/nhrpd/nhrp_peer.c b/nhrpd/nhrp_peer.c index ca309f250..3a74b7569 100644 --- a/nhrpd/nhrp_peer.c +++ b/nhrpd/nhrp_peer.c @@ -657,7 +657,7 @@ enum packet_type_t { PACKET_INDICATION, }; -static struct { +static const struct { enum packet_type_t type; const char *name; void (*handler)(struct nhrp_packet_parser *); diff --git a/ospf6d/ospf6_abr.c b/ospf6d/ospf6_abr.c index 0ce53143b..ff82bb179 100644 --- a/ospf6d/ospf6_abr.c +++ b/ospf6d/ospf6_abr.c @@ -1420,7 +1420,7 @@ void install_element_ospf6_debug_abr(void) install_element(CONFIG_NODE, &no_debug_ospf6_abr_cmd); } -struct ospf6_lsa_handler inter_prefix_handler = { +static const struct ospf6_lsa_handler inter_prefix_handler = { .lh_type = OSPF6_LSTYPE_INTER_PREFIX, .lh_name = "Inter-Prefix", .lh_short_name = "IAP", @@ -1428,7 +1428,7 @@ struct ospf6_lsa_handler inter_prefix_handler = { .lh_get_prefix_str = ospf6_inter_area_prefix_lsa_get_prefix_str, .lh_debug = 0}; -struct ospf6_lsa_handler inter_router_handler = { +static const struct ospf6_lsa_handler inter_router_handler = { .lh_type = OSPF6_LSTYPE_INTER_ROUTER, .lh_name = "Inter-Router", .lh_short_name = "IAR", diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c index a56ba0a69..93265afc4 100644 --- a/ospf6d/ospf6_interface.c +++ b/ospf6d/ospf6_interface.c @@ -52,7 +52,7 @@ DEFINE_HOOK(ospf6_interface_change, unsigned char conf_debug_ospf6_interface = 0; -const char *ospf6_interface_state_str[] = { +const char *const ospf6_interface_state_str[] = { "None", "Down", "Loopback", "Waiting", "PointToPoint", "DROther", "BDR", "DR", NULL}; diff --git a/ospf6d/ospf6_interface.h b/ospf6d/ospf6_interface.h index 53a8910f4..05ba698a1 100644 --- a/ospf6d/ospf6_interface.h +++ b/ospf6d/ospf6_interface.h @@ -148,7 +148,7 @@ DECLARE_QOBJ_TYPE(ospf6_interface) #define OSPF6_INTERFACE_DR 7 #define OSPF6_INTERFACE_MAX 8 -extern const char *ospf6_interface_state_str[]; +extern const char *const ospf6_interface_state_str[]; /* flags */ #define OSPF6_INTERFACE_DISABLE 0x01 diff --git a/ospf6d/ospf6_intra.c b/ospf6d/ospf6_intra.c index 7ae7d682b..0fde997a2 100644 --- a/ospf6d/ospf6_intra.c +++ b/ospf6d/ospf6_intra.c @@ -2232,31 +2232,31 @@ void ospf6_intra_brouter_calculation(struct ospf6_area *oa) __PRETTY_FUNCTION__, oa->name); } -struct ospf6_lsa_handler router_handler = {.lh_type = OSPF6_LSTYPE_ROUTER, - .lh_name = "Router", - .lh_short_name = "Rtr", - .lh_show = ospf6_router_lsa_show, - .lh_get_prefix_str = - ospf6_router_lsa_get_nbr_id, - .lh_debug = 0}; - -struct ospf6_lsa_handler network_handler = {.lh_type = OSPF6_LSTYPE_NETWORK, - .lh_name = "Network", - .lh_short_name = "Net", - .lh_show = ospf6_network_lsa_show, - .lh_get_prefix_str = - ospf6_network_lsa_get_ar_id, - .lh_debug = 0}; - -struct ospf6_lsa_handler link_handler = {.lh_type = OSPF6_LSTYPE_LINK, - .lh_name = "Link", - .lh_short_name = "Lnk", - .lh_show = ospf6_link_lsa_show, - .lh_get_prefix_str = - ospf6_link_lsa_get_prefix_str, - .lh_debug = 0}; - -struct ospf6_lsa_handler intra_prefix_handler = { +static const struct ospf6_lsa_handler router_handler = { + .lh_type = OSPF6_LSTYPE_ROUTER, + .lh_name = "Router", + .lh_short_name = "Rtr", + .lh_show = ospf6_router_lsa_show, + .lh_get_prefix_str = ospf6_router_lsa_get_nbr_id, + .lh_debug = 0}; + +static const struct ospf6_lsa_handler network_handler = { + .lh_type = OSPF6_LSTYPE_NETWORK, + .lh_name = "Network", + .lh_short_name = "Net", + .lh_show = ospf6_network_lsa_show, + .lh_get_prefix_str = ospf6_network_lsa_get_ar_id, + .lh_debug = 0}; + +static const struct ospf6_lsa_handler link_handler = { + .lh_type = OSPF6_LSTYPE_LINK, + .lh_name = "Link", + .lh_short_name = "Lnk", + .lh_show = ospf6_link_lsa_show, + .lh_get_prefix_str = ospf6_link_lsa_get_prefix_str, + .lh_debug = 0}; + +static const struct ospf6_lsa_handler intra_prefix_handler = { .lh_type = OSPF6_LSTYPE_INTRA_PREFIX, .lh_name = "Intra-Prefix", .lh_short_name = "INP", diff --git a/ospf6d/ospf6_neighbor.c b/ospf6d/ospf6_neighbor.c index 4318db522..1e90d4b9b 100644 --- a/ospf6d/ospf6_neighbor.c +++ b/ospf6d/ospf6_neighbor.c @@ -51,10 +51,16 @@ DEFINE_HOOK(ospf6_neighbor_change, unsigned char conf_debug_ospf6_neighbor = 0; -const char *ospf6_neighbor_state_str[] = { +const char *const ospf6_neighbor_state_str[] = { "None", "Down", "Attempt", "Init", "Twoway", "ExStart", "ExChange", "Loading", "Full", NULL}; +const char *const ospf6_neighbor_event_str[] = { + "NoEvent", "HelloReceived", "2-WayReceived", "NegotiationDone", + "ExchangeDone", "LoadingDone", "AdjOK?", "SeqNumberMismatch", + "BadLSReq", "1-WayReceived", "InactivityTimer", +}; + int ospf6_neighbor_cmp(void *va, void *vb) { struct ospf6_neighbor *ona = (struct ospf6_neighbor *)va; diff --git a/ospf6d/ospf6_neighbor.h b/ospf6d/ospf6_neighbor.h index 840683cc2..e221e9d82 100644 --- a/ospf6d/ospf6_neighbor.h +++ b/ospf6d/ospf6_neighbor.h @@ -123,11 +123,7 @@ struct ospf6_neighbor { #define OSPF6_NEIGHBOR_EVENT_INACTIVITY_TIMER 10 #define OSPF6_NEIGHBOR_EVENT_MAX_EVENT 11 -static const char *ospf6_neighbor_event_str[] = { - "NoEvent", "HelloReceived", "2-WayReceived", "NegotiationDone", - "ExchangeDone", "LoadingDone", "AdjOK?", "SeqNumberMismatch", - "BadLSReq", "1-WayReceived", "InactivityTimer", -}; +extern const char *const ospf6_neighbor_event_str[]; static inline const char *ospf6_neighbor_event_string(int event) { @@ -138,7 +134,7 @@ static inline const char *ospf6_neighbor_event_string(int event) return OSPF6_NEIGHBOR_UNKNOWN_EVENT_STRING; } -extern const char *ospf6_neighbor_state_str[]; +extern const char *const ospf6_neighbor_state_str[]; /* Function Prototypes */ diff --git a/ospf6d/ospf6_route.c b/ospf6d/ospf6_route.c index 441a6f367..28b15769d 100644 --- a/ospf6d/ospf6_route.c +++ b/ospf6d/ospf6_route.c @@ -147,19 +147,19 @@ void ospf6_linkstate_prefix2str(struct prefix *prefix, char *buf, int size) } /* Global strings for logging */ -const char *ospf6_dest_type_str[OSPF6_DEST_TYPE_MAX] = { +const char *const ospf6_dest_type_str[OSPF6_DEST_TYPE_MAX] = { "Unknown", "Router", "Network", "Discard", "Linkstate", "AddressRange", }; -const char *ospf6_dest_type_substr[OSPF6_DEST_TYPE_MAX] = { +const char *const ospf6_dest_type_substr[OSPF6_DEST_TYPE_MAX] = { "?", "R", "N", "D", "L", "A", }; -const char *ospf6_path_type_str[OSPF6_PATH_TYPE_MAX] = { +const char *const ospf6_path_type_str[OSPF6_PATH_TYPE_MAX] = { "Unknown", "Intra-Area", "Inter-Area", "External-1", "External-2", }; -const char *ospf6_path_type_substr[OSPF6_PATH_TYPE_MAX] = { +const char *const ospf6_path_type_substr[OSPF6_PATH_TYPE_MAX] = { "??", "IA", "IE", "E1", "E2", }; diff --git a/ospf6d/ospf6_route.h b/ospf6d/ospf6_route.h index 02002533e..13b01a348 100644 --- a/ospf6d/ospf6_route.h +++ b/ospf6d/ospf6_route.h @@ -215,8 +215,8 @@ struct ospf6_route_table { #define OSPF6_ROUTE_TABLE_CREATE(s, t) \ ospf6_route_table_create(OSPF6_SCOPE_TYPE_##s, OSPF6_TABLE_TYPE_##t) -extern const char *ospf6_dest_type_str[OSPF6_DEST_TYPE_MAX]; -extern const char *ospf6_dest_type_substr[OSPF6_DEST_TYPE_MAX]; +extern const char *const ospf6_dest_type_str[OSPF6_DEST_TYPE_MAX]; +extern const char *const ospf6_dest_type_substr[OSPF6_DEST_TYPE_MAX]; #define OSPF6_DEST_TYPE_NAME(x) \ (0 < (x) && (x) < OSPF6_DEST_TYPE_MAX ? ospf6_dest_type_str[(x)] \ : ospf6_dest_type_str[0]) @@ -224,8 +224,8 @@ extern const char *ospf6_dest_type_substr[OSPF6_DEST_TYPE_MAX]; (0 < (x) && (x) < OSPF6_DEST_TYPE_MAX ? ospf6_dest_type_substr[(x)] \ : ospf6_dest_type_substr[0]) -extern const char *ospf6_path_type_str[OSPF6_PATH_TYPE_MAX]; -extern const char *ospf6_path_type_substr[OSPF6_PATH_TYPE_MAX]; +extern const char *const ospf6_path_type_str[OSPF6_PATH_TYPE_MAX]; +extern const char *const ospf6_path_type_substr[OSPF6_PATH_TYPE_MAX]; #define OSPF6_PATH_TYPE_NAME(x) \ (0 < (x) && (x) < OSPF6_PATH_TYPE_MAX ? ospf6_path_type_str[(x)] \ : ospf6_path_type_str[0]) diff --git a/ospf6d/ospf6_spf.c b/ospf6d/ospf6_spf.c index aa4a99517..966ef4482 100644 --- a/ospf6d/ospf6_spf.c +++ b/ospf6d/ospf6_spf.c @@ -435,7 +435,7 @@ void ospf6_spf_table_finish(struct ospf6_route_table *result_table) } } -static const char *ospf6_spf_reason_str[] = { +static const char *const ospf6_spf_reason_str[] = { "R+", "R-", "N+", "N-", "L+", "L-", "R*", "N*", }; diff --git a/ospfd/ospf_ism.c b/ospfd/ospf_ism.c index 419081fe5..e394b6f47 100644 --- a/ospfd/ospf_ism.c +++ b/ospfd/ospf_ism.c @@ -418,7 +418,7 @@ static int ism_ignore(struct ospf_interface *oi) } /* Interface State Machine */ -struct { +const struct { int (*func)(struct ospf_interface *); int next_state; } ISM[OSPF_ISM_STATE_MAX][OSPF_ISM_EVENT_MAX] = { @@ -512,7 +512,7 @@ struct { }, }; -static const char *ospf_ism_event_str[] = { +static const char *const ospf_ism_event_str[] = { "NoEvent", "InterfaceUp", "WaitTimer", "BackupSeen", "NeighborChange", "LoopInd", "UnLoopInd", "InterfaceDown", }; diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c index 3e3f28802..6eec87c93 100644 --- a/ospfd/ospf_lsa.c +++ b/ospfd/ospf_lsa.c @@ -290,7 +290,7 @@ void ospf_lsa_data_free(struct lsa_header *lsah) const char *dump_lsa_key(struct ospf_lsa *lsa) { - static char buf[] = {"Type255,id(255.255.255.255),ar(255.255.255.255)"}; + static char buf[sizeof("Type255,id(255.255.255.255),ar(255.255.255.255)")+1]; struct lsa_header *lsah; if (lsa != NULL && (lsah = lsa->data) != NULL) { diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c index f6cd0fc83..a542b4da8 100644 --- a/ospfd/ospf_main.c +++ b/ospfd/ospf_main.c @@ -72,9 +72,11 @@ struct zebra_privs_t ospfd_privs = { .cap_num_i = 0}; /* OSPFd options. */ -struct option longopts[] = {{"instance", required_argument, NULL, 'n'}, - {"apiserver", no_argument, NULL, 'a'}, - {0}}; +const struct option longopts[] = { + {"instance", required_argument, NULL, 'n'}, + {"apiserver", no_argument, NULL, 'a'}, + {0} +}; /* OSPFd program name */ diff --git a/ospfd/ospf_nsm.c b/ospfd/ospf_nsm.c index 9f6be3cbc..0fc2cd60f 100644 --- a/ospfd/ospf_nsm.c +++ b/ospfd/ospf_nsm.c @@ -399,7 +399,7 @@ static int nsm_kill_nbr(struct ospf_neighbor *nbr) } /* Neighbor State Machine */ -struct { +const struct { int (*func)(struct ospf_neighbor *); int next_state; } NSM[OSPF_NSM_STATE_MAX][OSPF_NSM_EVENT_MAX] = { @@ -575,7 +575,7 @@ struct { }, }; -static const char *ospf_nsm_event_str[] = { +static const char *const ospf_nsm_event_str[] = { "NoEvent", "PacketReceived", "Start", "2-WayReceived", "NegotiationDone", "ExchangeDone", "BadLSReq", "LoadingDone", "AdjOK?", diff --git a/ospfd/ospf_route.c b/ospfd/ospf_route.c index da83c1dda..6cabc0c98 100644 --- a/ospfd/ospf_route.c +++ b/ospfd/ospf_route.c @@ -622,8 +622,10 @@ void ospf_intra_add_stub(struct route_table *rt, struct router_lsa_link *link, zlog_debug("ospf_intra_add_stub(): Stop"); } -const char *ospf_path_type_str[] = {"unknown-type", "intra-area", "inter-area", - "type1-external", "type2-external"}; +static const char *const ospf_path_type_str[] = { + "unknown-type", "intra-area", "inter-area", "type1-external", + "type2-external" +}; void ospf_route_table_dump(struct route_table *rt) { diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c index e68363663..8da99843e 100644 --- a/ospfd/ospf_te.c +++ b/ospfd/ospf_te.c @@ -69,7 +69,7 @@ */ struct ospf_mpls_te OspfMplsTE; -const char *mode2text[] = {"Off", "AS", "Area"}; +static const char *const mode2text[] = {"Off", "AS", "Area"}; /*------------------------------------------------------------------------* * Followings are initialize/terminate functions for MPLS-TE handling. diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index d11c34f24..4c97615ed 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -53,7 +53,7 @@ #include "ospfd/ospf_dump.h" #include "ospfd/ospf_bfd.h" -static const char *ospf_network_type_str[] = { +static const char *const ospf_network_type_str[] = { "Null", "POINTOPOINT", "BROADCAST", "NBMA", "POINTOMULTIPOINT", "VIRTUALLINK", "LOOPBACK"}; @@ -2622,11 +2622,14 @@ ALIAS(no_ospf_write_multiplier, no_write_multiplier_cmd, "Write multiplier\n" "Maximum number of interface serviced per write\n") -const char *ospf_abr_type_descr_str[] = {"Unknown", "Standard (RFC2328)", - "Alternative IBM", "Alternative Cisco", - "Alternative Shortcut"}; +static const char *const ospf_abr_type_descr_str[] = { + "Unknown", "Standard (RFC2328)", "Alternative IBM", + "Alternative Cisco", "Alternative Shortcut" +}; -const char *ospf_shortcut_mode_descr_str[] = {"Default", "Enabled", "Disabled"}; +static const char *const ospf_shortcut_mode_descr_str[] = { + "Default", "Enabled", "Disabled" +}; static void show_ip_ospf_area(struct vty *vty, struct ospf_area *area, json_object *json_areas, bool use_json) @@ -5767,7 +5770,7 @@ static int show_lsa_summary(struct vty *vty, struct ospf_lsa *lsa, int self) return 0; } -static const char *show_database_desc[] = { +static const char *const show_database_desc[] = { "unknown", "Router Link States", "Net Link States", @@ -5782,7 +5785,7 @@ static const char *show_database_desc[] = { "AS-external Opaque-LSA", }; -static const char *show_database_header[] = { +static const char *const show_database_header[] = { "", "Link ID ADV Router Age Seq# CkSum Link count", "Link ID ADV Router Age Seq# CkSum", @@ -5834,7 +5837,7 @@ static void show_ip_ospf_database_header(struct vty *vty, struct ospf_lsa *lsa) vty_out(vty, " Length: %d\n\n", ntohs(lsa->data->length)); } -const char *link_type_desc[] = { +static const char *const link_type_desc[] = { "(null)", "another Router (point-to-point)", "a Transit Network", @@ -5842,12 +5845,12 @@ const char *link_type_desc[] = { "a Virtual Link", }; -const char *link_id_desc[] = { +static const char *const link_id_desc[] = { "(null)", "Neighboring Router ID", "Designated Router address", "Net", "Neighboring Router ID", }; -const char *link_data_desc[] = { +static const char *const link_data_desc[] = { "(null)", "Router Interface address", "Router Interface address", "Network Mask", "Router Interface address", }; @@ -6047,7 +6050,7 @@ static int show_opaque_lsa_detail(struct vty *vty, struct ospf_lsa *lsa) return 0; } -int (*show_function[])(struct vty *, struct ospf_lsa *) = { +int (*const show_function[])(struct vty *, struct ospf_lsa *) = { NULL, show_router_lsa_detail, show_network_lsa_detail, @@ -9646,7 +9649,7 @@ DEFUN (show_ip_ospf_vrfs, struct ospf *ospf = NULL; struct listnode *node = NULL; int count = 0; - static char header[] = "Name Id RouterId "; + static const char header[] = "Name Id RouterId "; if (uj) { json = json_object_new_object(); @@ -9703,16 +9706,23 @@ DEFUN (show_ip_ospf_vrfs, return CMD_SUCCESS; } -const char *ospf_abr_type_str[] = {"unknown", "standard", "ibm", "cisco", - "shortcut"}; +static const char *const ospf_abr_type_str[] = { + "unknown", "standard", "ibm", "cisco", "shortcut" +}; -const char *ospf_shortcut_mode_str[] = {"default", "enable", "disable"}; +static const char *const ospf_shortcut_mode_str[] = { + "default", "enable", "disable" +}; -const char *ospf_int_type_str[] = {"unknown", /* should never be used. */ - "point-to-point", "broadcast", - "non-broadcast", "point-to-multipoint", - "virtual-link", /* should never be used. */ - "loopback"}; +static const char *const ospf_int_type_str[] = { + "unknown", /* should never be used. */ + "point-to-point", + "broadcast", + "non-broadcast", + "point-to-multipoint", + "virtual-link", /* should never be used. */ + "loopback" +}; static int config_write_interface_one(struct vty *vty, struct vrf *vrf) { diff --git a/pbrd/pbr_map.c b/pbrd/pbr_map.c index 4df0c790b..7e34066b4 100644 --- a/pbrd/pbr_map.c +++ b/pbrd/pbr_map.c @@ -145,7 +145,7 @@ static void pbr_map_pbrms_uninstall(struct pbr_map_sequence *pbrms) pbr_map_pbrms_update_common(pbrms, false); } -static const char *pbr_map_reason_str[] = { +static const char *const pbr_map_reason_str[] = { "Invalid NH-group", "Invalid NH", "No Nexthops", "Both NH and NH-Group", "Invalid Src or Dst", "Invalid VRF", "Deleting Sequence", diff --git a/pimd/pim_mroute.c b/pimd/pim_mroute.c index ec06cd734..2859d26eb 100644 --- a/pimd/pim_mroute.c +++ b/pimd/pim_mroute.c @@ -147,7 +147,7 @@ static int pim_mroute_set(struct pim_instance *pim, int enable) return 0; } -static const char *igmpmsgtype2str[IGMPMSG_WRVIFWHOLE + 1] = { +static const char *const igmpmsgtype2str[IGMPMSG_WRVIFWHOLE + 1] = { "<unknown_upcall?>", "NOCACHE", "WRONGVIF", "WHOLEPKT", "WRVIFWHOLE"}; static int pim_mroute_msg_nocache(int fd, struct interface *ifp, diff --git a/vrrpd/vrrp.c b/vrrpd/vrrp.c index eed0e8a31..42bb154f9 100644 --- a/vrrpd/vrrp.c +++ b/vrrpd/vrrp.c @@ -50,13 +50,13 @@ int vrrp_autoconfig_version; struct vrrp_defaults vd; -const char *vrrp_state_names[3] = { +const char *const vrrp_state_names[3] = { [VRRP_STATE_INITIALIZE] = "Initialize", [VRRP_STATE_MASTER] = "Master", [VRRP_STATE_BACKUP] = "Backup", }; -const char *vrrp_event_names[2] = { +static const char *const vrrp_event_names[2] = { [VRRP_EVENT_STARTUP] = "Startup", [VRRP_EVENT_SHUTDOWN] = "Shutdown", }; @@ -1414,7 +1414,7 @@ static void vrrp_change_state_initialize(struct vrrp_router *r) vrrp_zebra_radv_set(r, false); } -void (*vrrp_change_state_handlers[])(struct vrrp_router *vr) = { +void (*const vrrp_change_state_handlers[])(struct vrrp_router *vr) = { [VRRP_STATE_MASTER] = vrrp_change_state_master, [VRRP_STATE_BACKUP] = vrrp_change_state_backup, [VRRP_STATE_INITIALIZE] = vrrp_change_state_initialize, @@ -1639,7 +1639,7 @@ static int vrrp_shutdown(struct vrrp_router *r) return 0; } -static int (*vrrp_event_handlers[])(struct vrrp_router *r) = { +static int (*const vrrp_event_handlers[])(struct vrrp_router *r) = { [VRRP_EVENT_STARTUP] = vrrp_startup, [VRRP_EVENT_SHUTDOWN] = vrrp_shutdown, }; diff --git a/vrrpd/vrrp.h b/vrrpd/vrrp.h index 5d355d04b..79283bbb1 100644 --- a/vrrpd/vrrp.h +++ b/vrrpd/vrrp.h @@ -465,8 +465,7 @@ int vrrp_del_ipv6(struct vrrp_vrouter *vr, struct in6_addr v6); #define VRRP_EVENT_STARTUP 0 #define VRRP_EVENT_SHUTDOWN 1 -extern const char *vrrp_state_names[3]; -extern const char *vrrp_event_names[2]; +extern const char *const vrrp_state_names[3]; /* * This hook called whenever the state of a Virtual Router changes, after the diff --git a/vrrpd/vrrp_packet.c b/vrrpd/vrrp_packet.c index 461310c1e..e4fee2d79 100644 --- a/vrrpd/vrrp_packet.c +++ b/vrrpd/vrrp_packet.c @@ -33,7 +33,7 @@ DEFINE_MTYPE_STATIC(VRRPD, VRRP_PKT, "VRRP packet") /* clang-format off */ -const char *vrrp_packet_names[16] = { +static const char *const vrrp_packet_names[16] = { [0] = "Unknown", [VRRP_TYPE_ADVERTISEMENT] = "ADVERTISEMENT", [2] = "Unknown", diff --git a/vrrpd/vrrp_packet.h b/vrrpd/vrrp_packet.h index c2ce22f00..082935f08 100644 --- a/vrrpd/vrrp_packet.h +++ b/vrrpd/vrrp_packet.h @@ -28,8 +28,6 @@ #define VRRP_TYPE_ADVERTISEMENT 1 -extern const char *vrrp_packet_names[16]; - /* * Shared header for VRRPv2/v3 packets. */ diff --git a/watchfrr/watchfrr.c b/watchfrr/watchfrr.c index ea5965582..4e8502107 100644 --- a/watchfrr/watchfrr.c +++ b/watchfrr/watchfrr.c @@ -76,7 +76,7 @@ typedef enum { PHASE_WAITING_ZEBRA_UP } restart_phase_t; -static const char *phase_str[] = { +static const char *const phase_str[] = { "Idle", "Startup", "Stop jobs running", @@ -144,7 +144,7 @@ typedef enum { #define IS_UP(DMN) \ (((DMN)->state == DAEMON_UP) || ((DMN)->state == DAEMON_UNRESPONSIVE)) -static const char *state_str[] = { +static const char *const state_str[] = { "Init", "Down", "Connecting", "Up", "Unresponsive", }; diff --git a/zebra/ipforward_proc.c b/zebra/ipforward_proc.c index 709d2176a..226f72293 100644 --- a/zebra/ipforward_proc.c +++ b/zebra/ipforward_proc.c @@ -30,7 +30,7 @@ extern struct zebra_privs_t zserv_privs; -char proc_net_snmp[] = "/proc/net/snmp"; +static const char proc_net_snmp[] = "/proc/net/snmp"; static void dropline(FILE *fp) { @@ -70,7 +70,7 @@ int ipforward(void) } /* char proc_ipv4_forwarding[] = "/proc/sys/net/ipv4/conf/all/forwarding"; */ -char proc_ipv4_forwarding[] = "/proc/sys/net/ipv4/ip_forward"; +static const char proc_ipv4_forwarding[] = "/proc/sys/net/ipv4/ip_forward"; int ipforward_on(void) { @@ -114,7 +114,8 @@ int ipforward_off(void) return ipforward(); } -char proc_ipv6_forwarding[] = "/proc/sys/net/ipv6/conf/all/forwarding"; +static const char proc_ipv6_forwarding[] = + "/proc/sys/net/ipv6/conf/all/forwarding"; int ipforward_ipv6(void) { diff --git a/zebra/main.c b/zebra/main.c index 838ad1cdf..731c4e161 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -84,7 +84,7 @@ uint32_t nl_rcvbufsize = 4194304; #define OPTION_V6_RR_SEMANTICS 2000 /* Command line options. */ -struct option longopts[] = { +const struct option longopts[] = { {"batch", no_argument, NULL, 'b'}, {"allow_delete", no_argument, NULL, 'a'}, {"keep_kernel", no_argument, NULL, 'k'}, diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index c9a9a81b1..5e328b827 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -83,8 +83,8 @@ struct gw_family_t { union g_addr gate; }; -char ipv4_ll_buf[16] = "169.254.0.1"; -struct in_addr ipv4_ll; +static const char ipv4_ll_buf[16] = "169.254.0.1"; +static struct in_addr ipv4_ll; /* * The ipv4_ll data structure is used for all 5549 diff --git a/zebra/rtadv.c b/zebra/rtadv.c index f51c199f6..0adf654aa 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -72,7 +72,9 @@ DEFINE_MTYPE_STATIC(ZEBRA, RTADV_DNSSL, "Router Advertisement DNSSL") /* Order is intentional. Matches RFC4191. This array is also used for command matching, so only modify with care. */ -const char *rtadv_pref_strs[] = {"medium", "high", "INVALID", "low", 0}; +static const char *const rtadv_pref_strs[] = { + "medium", "high", "INVALID", "low", 0 +}; enum rtadv_event { RTADV_START, diff --git a/zebra/rtadv.h b/zebra/rtadv.h index f9bd2b1d3..409959d08 100644 --- a/zebra/rtadv.h +++ b/zebra/rtadv.h @@ -131,8 +131,6 @@ struct nd_opt_dnssl { /* DNS search list option [RFC8106 5.2] */ } __attribute__((__packed__)); #endif -extern const char *rtadv_pref_strs[]; - #endif /* HAVE_RTADV */ typedef enum { diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index e809d2ad3..86f41e807 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -1022,7 +1022,7 @@ static int zsend_table_manager_connect_response(struct zserv *client, /* Inbound message handling ------------------------------------------------ */ -int cmd2type[] = { +const int cmd2type[] = { [ZEBRA_NEXTHOP_REGISTER] = RNH_NEXTHOP_TYPE, [ZEBRA_NEXTHOP_UNREGISTER] = RNH_NEXTHOP_TYPE, [ZEBRA_IMPORT_ROUTE_REGISTER] = RNH_IMPORT_CHECK_TYPE, @@ -2485,7 +2485,7 @@ stream_failure: return; } -void (*zserv_handlers[])(ZAPI_HANDLER_ARGS) = { +void (*const zserv_handlers[])(ZAPI_HANDLER_ARGS) = { [ZEBRA_ROUTER_ID_ADD] = zread_router_id_add, [ZEBRA_ROUTER_ID_DELETE] = zread_router_id_delete, [ZEBRA_INTERFACE_ADD] = zread_interface_add, diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 781963793..605311769 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -3639,7 +3639,7 @@ struct route_table *rib_tables_iter_next(rib_tables_iter_t *iter) * Array that helps us go over all AFI/SAFI combinations via one * index. */ - static struct { + static const struct { afi_t afi; safi_t safi; } afi_safis[] = { |