*: generously apply const

const const const your boat, merrily down the stream...

Signed-off-by: David Lamparter <equinox@diac24.net>
This commit is contained in:
David Lamparter 2019-11-20 17:26:59 +01:00
parent 0d8c7a26a1
commit 2b64873d24
64 changed files with 191 additions and 171 deletions

View File

@ -74,7 +74,7 @@ unsigned char protocol_group[16]; /* babel's link-local multicast address */
int protocol_port; /* babel's port */ int protocol_port; /* babel's port */
int protocol_socket = -1; /* socket: communicate with others babeld */ 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 char *babel_vty_addr = NULL;
static int babel_vty_port = BABEL_VTY_PORT; static int babel_vty_port = BABEL_VTY_PORT;

View File

@ -39,7 +39,7 @@ void babelz_zebra_init(void);
struct zclient *zclient; struct zclient *zclient;
/* Debug types */ /* Debug types */
static struct { static const struct {
int type; int type;
int str_min_len; int str_min_len;
const char *str; const char *str;

View File

@ -399,8 +399,8 @@ struct bfd_global {
struct zebra_privs_t bfdd_privs; struct zebra_privs_t bfdd_privs;
}; };
extern struct bfd_global bglobal; extern struct bfd_global bglobal;
extern struct bfd_diag_str_list diag_list[]; extern const struct bfd_diag_str_list diag_list[];
extern struct bfd_state_str_list state_list[]; extern const struct bfd_state_str_list state_list[];
void socket_close(int *s); void socket_close(int *s);

View File

@ -122,7 +122,7 @@ FRR_DAEMON_INFO(bfdd, BFD, .vty_port = 2617,
.n_yang_modules = array_size(bfdd_yang_modules)) .n_yang_modules = array_size(bfdd_yang_modules))
#define OPTION_CTLSOCK 1001 #define OPTION_CTLSOCK 1001
static struct option longopts[] = { static const struct option longopts[] = {
{"bfdctl", required_argument, NULL, OPTION_CTLSOCK}, {"bfdctl", required_argument, NULL, OPTION_CTLSOCK},
{0} {0}
}; };
@ -133,7 +133,7 @@ static struct option longopts[] = {
*/ */
struct bfd_global bglobal; 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 = "control-expired", .type = BD_CONTROL_EXPIRED},
{.str = "echo-failed", .type = BD_ECHO_FAILED}, {.str = "echo-failed", .type = BD_ECHO_FAILED},
{.str = "neighbor-down", .type = BD_NEIGHBOR_DOWN}, {.str = "neighbor-down", .type = BD_NEIGHBOR_DOWN},
@ -145,7 +145,7 @@ struct bfd_diag_str_list diag_list[] = {
{.str = NULL}, {.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 = "admin-down", .type = PTM_BFD_ADM_DOWN},
{.str = "down", .type = PTM_BFD_DOWN}, {.str = "down", .type = PTM_BFD_DOWN},
{.str = "init", .type = PTM_BFD_INIT}, {.str = "init", .type = PTM_BFD_INIT},

View File

@ -24,7 +24,7 @@
#include "bgp_addpath.h" #include "bgp_addpath.h"
#include "bgp_route.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", .config_name = "addpath-tx-all-paths",
.human_name = "All", .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", .config_name = "addpath-tx-unknown",
.human_name = "Unknown-Addpath-Strategy", .human_name = "Unknown-Addpath-Strategy",
.human_description = "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 * Returns a structure full of strings associated with an addpath type. Will
* never return null. * never return null.
*/ */
struct bgp_addpath_strategy_names * const struct bgp_addpath_strategy_names *
bgp_addpath_names(enum bgp_addpath_strat strat) bgp_addpath_names(enum bgp_addpath_strat strat)
{ {
if (strat < BGP_ADDPATH_MAX) if (strat < BGP_ADDPATH_MAX)

View File

@ -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, 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_info_data *d);
struct bgp_addpath_strategy_names * const struct bgp_addpath_strategy_names *
bgp_addpath_names(enum bgp_addpath_strat strat); bgp_addpath_names(enum bgp_addpath_strat strat);
int bgp_addpath_dmed_required(int strategy); int bgp_addpath_dmed_required(int strategy);

View File

@ -102,8 +102,10 @@ static void assegment_data_free(as_t *asdata)
XFREE(MTYPE_AS_SEG_DATA, asdata); XFREE(MTYPE_AS_SEG_DATA, asdata);
} }
const char *aspath_segment_type_str[] = {"as-invalid", "as-set", "as-sequence", const char *const aspath_segment_type_str[] = {
"as-confed-sequence", "as-confed-set"}; "as-invalid", "as-set", "as-sequence", "as-confed-sequence",
"as-confed-set"
};
/* Get a new segment. Note that 0 is an allowed length, /* Get a new segment. Note that 0 is an allowed length,
* and will result in a segment with no allocated data segment. * and will result in a segment with no allocated data segment.

View File

@ -101,7 +101,7 @@ const struct message bgp_status_msg[] = {{Idle, "Idle"},
{0}}; {0}};
/* BGP message type string. */ /* 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", "NOTIFICATION", "KEEPALIVE", "ROUTE-REFRESH",
"CAPABILITY"}; "CAPABILITY"};
@ -169,8 +169,8 @@ static const struct message bgp_notify_capability_msg[] = {
{0}}; {0}};
/* Origin strings. */ /* Origin strings. */
const char *bgp_origin_str[] = {"i", "e", "?"}; const char *const bgp_origin_str[] = {"i", "e", "?"};
const char *bgp_origin_long_str[] = {"IGP", "EGP", "incomplete"}; const char *const bgp_origin_long_str[] = {"IGP", "EGP", "incomplete"};
static int bgp_debug_print_evpn_prefix(struct vty *vty, const char *desc, static int bgp_debug_print_evpn_prefix(struct vty *vty, const char *desc,
struct prefix *p); struct prefix *p);

View File

@ -151,8 +151,7 @@ struct bgp_debug_filter {
#define BGP_DEBUG(a, b) (term_bgp_debug_ ## a & BGP_DEBUG_ ## b) #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) #define CONF_BGP_DEBUG(a, b) (conf_bgp_debug_ ## a & BGP_DEBUG_ ## b)
extern const char *bgp_type_str[]; extern const char *const bgp_type_str[];
extern const char *pmsi_tnltype_str[];
extern int bgp_dump_attr(struct attr *, char *, size_t); extern int bgp_dump_attr(struct attr *, char *, size_t);
extern int bgp_debug_peer_updout_enabled(char *host); extern int bgp_debug_peer_updout_enabled(char *host);

View File

@ -62,7 +62,7 @@ DEFINE_HOOK(peer_status_changed, (struct peer * peer), (peer))
/* Definition of display strings corresponding to FSM events. This should be /* Definition of display strings corresponding to FSM events. This should be
* kept consistent with the events defined in bgpd.h * kept consistent with the events defined in bgpd.h
*/ */
static const char *bgp_event_str[] = { static const char *const bgp_event_str[] = {
NULL, NULL,
"BGP_Start", "BGP_Start",
"BGP_Stop", "BGP_Stop",
@ -522,7 +522,7 @@ int bgp_routeadv_timer(struct thread *thread)
} }
/* BGP Peer Down Cause */ /* BGP Peer Down Cause */
const char *peer_down_str[] = {"", const char *const peer_down_str[] = {"",
"Router ID changed", "Router ID changed",
"Remote AS changed", "Remote AS changed",
"Local AS change", "Local AS change",

View File

@ -64,7 +64,7 @@ extern int bgp_stop(struct peer *peer);
extern void bgp_timer_set(struct peer *); extern void bgp_timer_set(struct peer *);
extern int bgp_routeadv_timer(struct thread *); extern int bgp_routeadv_timer(struct thread *);
extern void bgp_fsm_change_status(struct peer *peer, int status); 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_update_delay_end(struct bgp *);
extern void bgp_maxmed_update(struct bgp *); extern void bgp_maxmed_update(struct bgp *);
extern int bgp_maxmed_onstartup_configured(struct bgp *); extern int bgp_maxmed_onstartup_configured(struct bgp *);

View File

@ -508,7 +508,7 @@ static bool validate_header(struct peer *peer)
uint8_t type; uint8_t type;
struct ringbuf *pkt = peer->ibuf_work; 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,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
uint8_t m_rx[BGP_MARKER_SIZE] = {0x00}; uint8_t m_rx[BGP_MARKER_SIZE] = {0x00};

View File

@ -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 ka = {0}; // peer->v_keepalive as a timeval
static struct timeval diff; // ka - elapsed 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, uint32_t v_ka = atomic_load_explicit(&pkat->peer->v_keepalive,
memory_order_relaxed); memory_order_relaxed);

View File

@ -10600,7 +10600,7 @@ enum bgp_stats {
BGP_STATS_MAX, BGP_STATS_MAX,
}; };
static const char *table_stats_strs[] = { static const char *const table_stats_strs[] = {
[BGP_STATS_PREFIXES] = "Total Prefixes", [BGP_STATS_PREFIXES] = "Total Prefixes",
[BGP_STATS_TOTPLEN] = "Average prefix length", [BGP_STATS_TOTPLEN] = "Average prefix length",
[BGP_STATS_RIB] = "Total Advertisements", [BGP_STATS_RIB] = "Total Advertisements",
@ -10858,7 +10858,7 @@ enum bgp_pcounts {
PCOUNT_MAX, PCOUNT_MAX,
}; };
static const char *pcount_strs[] = { static const char *const pcount_strs[] = {
[PCOUNT_ADJ_IN] = "Adj-in", [PCOUNT_ADJ_IN] = "Adj-in",
[PCOUNT_DAMPED] = "Damped", [PCOUNT_DAMPED] = "Damped",
[PCOUNT_REMOVED] = "Removed", [PCOUNT_REMOVED] = "Removed",

View File

@ -127,8 +127,8 @@ void rfapiRprefixApplyMask(struct rfapi_ip_prefix *rprefix)
int index; int index;
int offset; int offset;
static uint8_t maskbit[] = {0x00, 0x80, 0xc0, 0xe0, 0xf0, static const uint8_t maskbit[] = {0x00, 0x80, 0xc0, 0xe0, 0xf0,
0xf8, 0xfc, 0xfe, 0xff}; 0xf8, 0xfc, 0xfe, 0xff};
switch (rprefix->prefix.addr_family) { switch (rprefix->prefix.addr_family) {
case AF_INET: case AF_INET:

View File

@ -38,7 +38,7 @@ struct vnc_debug {
const char *name; const char *name;
}; };
struct vnc_debug vncdebug[] = { static const struct vnc_debug vncdebug[] = {
{VNC_DEBUG_RFAPI_QUERY, "rfapi-query"}, {VNC_DEBUG_RFAPI_QUERY, "rfapi-query"},
{VNC_DEBUG_IMPORT_BI_ATTACH, "import-bi-attach"}, {VNC_DEBUG_IMPORT_BI_ATTACH, "import-bi-attach"},
{VNC_DEBUG_IMPORT_DEL_REMOTE, "import-del-remote"}, {VNC_DEBUG_IMPORT_DEL_REMOTE, "import-del-remote"},

View File

@ -110,7 +110,7 @@ int eigrp_fsm_event_qact(struct eigrp_fsm_action_message *);
* NSM[actual/starting state][occurred event].func * NSM[actual/starting state][occurred event].func
* Functions are should be executed within separate thread. * Functions are should be executed within separate thread.
*/ */
struct { const struct {
int (*func)(struct eigrp_fsm_action_message *); int (*func)(struct eigrp_fsm_action_message *);
} NSM[EIGRP_FSM_STATE_MAX][EIGRP_FSM_EVENT_MAX] = { } NSM[EIGRP_FSM_STATE_MAX][EIGRP_FSM_EVENT_MAX] = {
{ {

View File

@ -65,10 +65,13 @@ uint8_t *readbuff = NULL;
* ISO 10589 - 8.4.8 * ISO 10589 - 8.4.8
*/ */
uint8_t ALL_L1_ISS[6] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x14}; static const uint8_t ALL_L1_ISS[6] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x14};
uint8_t ALL_L2_ISS[6] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x15}; static const uint8_t ALL_L2_ISS[6] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x15};
uint8_t ALL_ISS[6] = {0x09, 0x00, 0x2B, 0x00, 0x00, 0x05}; #if 0
uint8_t ALL_ESS[6] = {0x09, 0x00, 0x2B, 0x00, 0x00, 0x04}; /* 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]; static char sock_buff[8192];

View File

@ -50,12 +50,12 @@
extern struct isis *isis; 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"}; "C_STATE_CONF", "C_STATE_UP"};
#define STATE2STR(S) csm_statestr[S] #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", "NO_STATE", "ISIS_ENABLE", "IF_UP_FROM_Z",
"ISIS_DISABLE", "IF_DOWN_FROM_Z", "ISIS_DISABLE", "IF_DOWN_FROM_Z",
}; };

View File

@ -54,10 +54,13 @@ static t_uscalar_t dlpi_ctl[1024]; /* DLPI control messages */
* ISO 10589 - 8.4.8 * ISO 10589 - 8.4.8
*/ */
uint8_t ALL_L1_ISS[6] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x14}; static const uint8_t ALL_L1_ISS[6] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x14};
uint8_t ALL_L2_ISS[6] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x15}; static const uint8_t ALL_L2_ISS[6] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x15};
uint8_t ALL_ISS[6] = {0x09, 0x00, 0x2B, 0x00, 0x00, 0x05}; static const uint8_t ALL_ISS[6] = {0x09, 0x00, 0x2B, 0x00, 0x00, 0x05};
uint8_t ALL_ESS[6] = {0x09, 0x00, 0x2B, 0x00, 0x00, 0x04}; #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]; static uint8_t sock_buff[8192];

View File

@ -45,7 +45,7 @@
#include "privs.h" #include "privs.h"
/* tcpdump -i eth0 'isis' -dd */ /* 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 /* NB: we're in SOCK_DGRAM, so src/dst mac + length are stripped
* off! * off!
* (OTOH it's a bit more lower-layer agnostic and might work * (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}, {0x6, 0, 0, 0x00040000}, {0x6, 0, 0, 0x00000000},
}; };
static struct sock_fprog bpf = { static const struct sock_fprog bpf = {
.len = array_size(isisfilter), .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 * ISO 10589 - 8.4.8
*/ */
uint8_t ALL_L1_ISS[6] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x14}; static const uint8_t ALL_L1_ISS[6] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x14};
uint8_t ALL_L2_ISS[6] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x15}; static const uint8_t ALL_L2_ISS[6] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x15};
uint8_t ALL_ISS[6] = {0x09, 0x00, 0x2B, 0x00, 0x00, 0x05}; static const 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_ESS[6] = {0x09, 0x00, 0x2B, 0x00, 0x00, 0x04};
static uint8_t discard_buff[8192]; static uint8_t discard_buff[8192];

View File

@ -60,8 +60,6 @@
#include "isisd/isis_te.h" #include "isisd/isis_te.h"
#include "isisd/isis_zebra.h" #include "isisd/isis_zebra.h"
const char *mode2text[] = {"Disable", "Area", "AS", "Emulate"};
/*------------------------------------------------------------------------* /*------------------------------------------------------------------------*
* Followings are control functions for MPLS-TE parameters management. * Followings are control functions for MPLS-TE parameters management.
*------------------------------------------------------------------------*/ *------------------------------------------------------------------------*/

View File

@ -88,7 +88,7 @@ struct pack_order_entry {
.what_to_pack = offsetof(struct isis_tlvs, w), \ .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(OLDSTYLE_REACH, ISIS_ITEMS, oldstyle_reach),
PACK_ENTRY(LAN_NEIGHBORS, ISIS_ITEMS, lan_neighbor), PACK_ENTRY(LAN_NEIGHBORS, ISIS_ITEMS, lan_neighbor),
PACK_ENTRY(LSP_ENTRY, ISIS_ITEMS, lsp_entries), 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 /* This is a forward definition. The table is actually initialized
* in at the bottom. */ * 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. */ /* 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, static int pack_items_(uint16_t mtid, enum isis_tlv_context context,
enum isis_tlv_type type, struct isis_item_list *items, enum isis_tlv_type type, struct isis_item_list *items,
struct stream *s, struct isis_tlvs **fragment_tlvs, 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 isis_tlvs *(*new_fragment)(struct list *l),
struct list *new_fragment_arg); struct list *new_fragment_arg);
#define pack_items(...) pack_items_(ISIS_MT_IPV4_UNICAST, __VA_ARGS__) #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, static int pack_item(enum isis_tlv_context context, enum isis_tlv_type type,
struct isis_item *i, struct stream *s, struct isis_item *i, struct stream *s,
struct isis_tlvs **fragment_tlvs, 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]; 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; 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_tlvs *fragment_tlvs, uint16_t mtid)
{ {
struct isis_item_list *l; 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, static int pack_items_(uint16_t mtid, enum isis_tlv_context context,
enum isis_tlv_type type, struct isis_item_list *items, enum isis_tlv_type type, struct isis_item_list *items,
struct stream *s, struct isis_tlvs **fragment_tlvs, 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 isis_tlvs *(*new_fragment)(struct list *l),
struct list *new_fragment_arg) 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, 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_mt_item_list *m, struct stream *s,
struct isis_tlvs **fragment_tlvs, 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 isis_tlvs *(*new_fragment)(struct list *l),
struct list *new_fragment_arg) 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 *tlvs, struct stream *stream,
struct isis_tlvs **fragment_tlvs, struct isis_tlvs **fragment_tlvs,
struct isis_tlvs *(*new_fragment)(struct list *l), 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"); ITEM_SUBTLV_OPS(prefix_sid, "Sub-TLV 3 SR Prefix-SID");
SUBTLV_OPS(ipv6_source_prefix, "Sub-TLV 22 IPv6 Source Prefix"); 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_CONTEXT_LSP] = {
[ISIS_TLV_AREA_ADDRESSES] = &tlv_area_address_ops, [ISIS_TLV_AREA_ADDRESSES] = &tlv_area_address_ops,
[ISIS_TLV_OLDSTYLE_REACH] = &tlv_oldstyle_reach_ops, [ISIS_TLV_OLDSTYLE_REACH] = &tlv_oldstyle_reach_ops,

View File

@ -120,7 +120,7 @@ char ctl_sock_path[MAXPATHLEN];
/* LDPd options. */ /* LDPd options. */
#define OPTION_CTLSOCK 1001 #define OPTION_CTLSOCK 1001
static struct option longopts[] = static const struct option longopts[] =
{ {
{ "ctl_socket", required_argument, NULL, OPTION_CTLSOCK}, { "ctl_socket", required_argument, NULL, OPTION_CTLSOCK},
{ "instance", required_argument, NULL, 'n'}, { "instance", required_argument, NULL, 'n'},

View File

@ -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(nbr_pid_head, nbr, pid_tree, nbr_pid_compare)
RB_GENERATE(nbrp_head, nbr_params, entry, nbr_params_compare) RB_GENERATE(nbrp_head, nbr_params, entry, nbr_params_compare)
struct { const struct {
int state; int state;
enum nbr_event event; enum nbr_event event;
enum nbr_action action; enum nbr_action action;

View File

@ -39,7 +39,7 @@ static int fpt_halt(struct frr_pthread *fpt, void **res);
static void frr_pthread_destroy_nolock(struct frr_pthread *fpt); static void frr_pthread_destroy_nolock(struct frr_pthread *fpt);
/* default frr_pthread attributes */ /* default frr_pthread attributes */
struct frr_pthread_attr frr_pthread_attr_default = { const struct frr_pthread_attr frr_pthread_attr_default = {
.start = fpt_run, .start = fpt_run,
.stop = fpt_halt, .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) const char *name, const char *os_name)
{ {
struct frr_pthread *fpt = NULL; struct frr_pthread *fpt = NULL;

View File

@ -99,7 +99,7 @@ struct frr_pthread {
char os_name[OS_THREAD_NAMELEN]; 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. * 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, * @param os_name - 16 characters (including '\0') thread name to set in os,
* @return the created frr_pthread upon success, or NULL upon failure * @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); const char *name, const char *os_name);
/* /*

View File

@ -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) const char *nexthop_type_to_str(enum nexthop_types_t nh_type)
{ {
static const char *desc[] = { static const char *const desc[] = {
"none", "Directly connected", "none", "Directly connected",
"IPv4 nexthop", "IPv4 nexthop with ifindex", "IPv4 nexthop", "IPv4 nexthop with ifindex",
"IPv6 nexthop", "IPv6 nexthop with ifindex", "IPv6 nexthop", "IPv6 nexthop with ifindex",

View File

@ -124,7 +124,7 @@ void printfrr_ext_reg(const struct printfrr_ext *);
#define printfrr_ext_autoreg_p(matchs, print_fn) \ #define printfrr_ext_autoreg_p(matchs, print_fn) \
static ssize_t print_fn(char *, size_t, const char *, int, \ static ssize_t print_fn(char *, size_t, const char *, int, \
const void *); \ const void *); \
static struct printfrr_ext _printext_##print_fn = { \ static const struct printfrr_ext _printext_##print_fn = { \
.match = matchs, \ .match = matchs, \
.print_ptr = print_fn, \ .print_ptr = print_fn, \
}; \ }; \
@ -136,7 +136,7 @@ void printfrr_ext_reg(const struct printfrr_ext *);
#define printfrr_ext_autoreg_i(matchs, print_fn) \ #define printfrr_ext_autoreg_i(matchs, print_fn) \
static ssize_t print_fn(char *, size_t, const char *, int, uintmax_t); \ 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, \ .match = matchs, \
.print_int = print_fn, \ .print_int = print_fn, \
}; \ }; \

View File

@ -45,7 +45,7 @@ struct route_table;
* Function vector that can be used by a client to customize the * Function vector that can be used by a client to customize the
* behavior of one or more route tables. * 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)( typedef struct route_node *(*route_table_create_node_func_t)(
route_table_delegate_t *, struct route_table *); route_table_delegate_t *, struct route_table *);

View File

@ -27,7 +27,7 @@
DEFINE_MTYPE_STATIC(LIB, TTABLE, "ASCII table") DEFINE_MTYPE_STATIC(LIB, TTABLE, "ASCII table")
/* clang-format off */ /* clang-format off */
struct ttable_style ttable_styles[] = { const struct ttable_style ttable_styles[] = {
{ // default ascii { // default ascii
.corner = '+', .corner = '+',
.rownums_on = false, .rownums_on = false,
@ -99,7 +99,7 @@ void ttable_del(struct ttable *tt)
XFREE(MTYPE_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; struct ttable *tt;

View File

@ -80,7 +80,7 @@ struct ttable {
#define TTSTYLE_ASCII 0 #define TTSTYLE_ASCII 0
#define TTSTYLE_BLANK 1 #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: * 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 * @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. * Deletes a table and releases all associated resources.

View File

@ -66,7 +66,7 @@ DECLARE_HEAP(thread_timer_list, struct thread, timeritem,
#define AWAKEN(m) \ #define AWAKEN(m) \
do { \ do { \
static unsigned char wakebyte = 0x01; \ const unsigned char wakebyte = 0x01; \
write(m->io_pipe[1], &wakebyte, 1); \ write(m->io_pipe[1], &wakebyte, 1); \
} while (0); } while (0);

View File

@ -657,7 +657,7 @@ enum packet_type_t {
PACKET_INDICATION, PACKET_INDICATION,
}; };
static struct { static const struct {
enum packet_type_t type; enum packet_type_t type;
const char *name; const char *name;
void (*handler)(struct nhrp_packet_parser *); void (*handler)(struct nhrp_packet_parser *);

View File

@ -1420,7 +1420,7 @@ void install_element_ospf6_debug_abr(void)
install_element(CONFIG_NODE, &no_debug_ospf6_abr_cmd); 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_type = OSPF6_LSTYPE_INTER_PREFIX,
.lh_name = "Inter-Prefix", .lh_name = "Inter-Prefix",
.lh_short_name = "IAP", .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_get_prefix_str = ospf6_inter_area_prefix_lsa_get_prefix_str,
.lh_debug = 0}; .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_type = OSPF6_LSTYPE_INTER_ROUTER,
.lh_name = "Inter-Router", .lh_name = "Inter-Router",
.lh_short_name = "IAR", .lh_short_name = "IAR",

View File

@ -52,7 +52,7 @@ DEFINE_HOOK(ospf6_interface_change,
unsigned char conf_debug_ospf6_interface = 0; 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", "None", "Down", "Loopback", "Waiting", "PointToPoint",
"DROther", "BDR", "DR", NULL}; "DROther", "BDR", "DR", NULL};

View File

@ -148,7 +148,7 @@ DECLARE_QOBJ_TYPE(ospf6_interface)
#define OSPF6_INTERFACE_DR 7 #define OSPF6_INTERFACE_DR 7
#define OSPF6_INTERFACE_MAX 8 #define OSPF6_INTERFACE_MAX 8
extern const char *ospf6_interface_state_str[]; extern const char *const ospf6_interface_state_str[];
/* flags */ /* flags */
#define OSPF6_INTERFACE_DISABLE 0x01 #define OSPF6_INTERFACE_DISABLE 0x01

View File

@ -2232,31 +2232,31 @@ void ospf6_intra_brouter_calculation(struct ospf6_area *oa)
__PRETTY_FUNCTION__, oa->name); __PRETTY_FUNCTION__, oa->name);
} }
struct ospf6_lsa_handler router_handler = {.lh_type = OSPF6_LSTYPE_ROUTER, static const struct ospf6_lsa_handler router_handler = {
.lh_name = "Router", .lh_type = OSPF6_LSTYPE_ROUTER,
.lh_short_name = "Rtr", .lh_name = "Router",
.lh_show = ospf6_router_lsa_show, .lh_short_name = "Rtr",
.lh_get_prefix_str = .lh_show = ospf6_router_lsa_show,
ospf6_router_lsa_get_nbr_id, .lh_get_prefix_str = ospf6_router_lsa_get_nbr_id,
.lh_debug = 0}; .lh_debug = 0};
struct ospf6_lsa_handler network_handler = {.lh_type = OSPF6_LSTYPE_NETWORK, static const struct ospf6_lsa_handler network_handler = {
.lh_name = "Network", .lh_type = OSPF6_LSTYPE_NETWORK,
.lh_short_name = "Net", .lh_name = "Network",
.lh_show = ospf6_network_lsa_show, .lh_short_name = "Net",
.lh_get_prefix_str = .lh_show = ospf6_network_lsa_show,
ospf6_network_lsa_get_ar_id, .lh_get_prefix_str = ospf6_network_lsa_get_ar_id,
.lh_debug = 0}; .lh_debug = 0};
struct ospf6_lsa_handler link_handler = {.lh_type = OSPF6_LSTYPE_LINK, static const struct ospf6_lsa_handler link_handler = {
.lh_name = "Link", .lh_type = OSPF6_LSTYPE_LINK,
.lh_short_name = "Lnk", .lh_name = "Link",
.lh_show = ospf6_link_lsa_show, .lh_short_name = "Lnk",
.lh_get_prefix_str = .lh_show = ospf6_link_lsa_show,
ospf6_link_lsa_get_prefix_str, .lh_get_prefix_str = ospf6_link_lsa_get_prefix_str,
.lh_debug = 0}; .lh_debug = 0};
struct ospf6_lsa_handler intra_prefix_handler = { static const struct ospf6_lsa_handler intra_prefix_handler = {
.lh_type = OSPF6_LSTYPE_INTRA_PREFIX, .lh_type = OSPF6_LSTYPE_INTRA_PREFIX,
.lh_name = "Intra-Prefix", .lh_name = "Intra-Prefix",
.lh_short_name = "INP", .lh_short_name = "INP",

View File

@ -51,10 +51,16 @@ DEFINE_HOOK(ospf6_neighbor_change,
unsigned char conf_debug_ospf6_neighbor = 0; 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", "None", "Down", "Attempt", "Init", "Twoway",
"ExStart", "ExChange", "Loading", "Full", NULL}; "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) int ospf6_neighbor_cmp(void *va, void *vb)
{ {
struct ospf6_neighbor *ona = (struct ospf6_neighbor *)va; struct ospf6_neighbor *ona = (struct ospf6_neighbor *)va;

View File

@ -123,11 +123,7 @@ struct ospf6_neighbor {
#define OSPF6_NEIGHBOR_EVENT_INACTIVITY_TIMER 10 #define OSPF6_NEIGHBOR_EVENT_INACTIVITY_TIMER 10
#define OSPF6_NEIGHBOR_EVENT_MAX_EVENT 11 #define OSPF6_NEIGHBOR_EVENT_MAX_EVENT 11
static const char *ospf6_neighbor_event_str[] = { extern const char *const ospf6_neighbor_event_str[];
"NoEvent", "HelloReceived", "2-WayReceived", "NegotiationDone",
"ExchangeDone", "LoadingDone", "AdjOK?", "SeqNumberMismatch",
"BadLSReq", "1-WayReceived", "InactivityTimer",
};
static inline const char *ospf6_neighbor_event_string(int event) 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; return OSPF6_NEIGHBOR_UNKNOWN_EVENT_STRING;
} }
extern const char *ospf6_neighbor_state_str[]; extern const char *const ospf6_neighbor_state_str[];
/* Function Prototypes */ /* Function Prototypes */

View File

@ -147,19 +147,19 @@ void ospf6_linkstate_prefix2str(struct prefix *prefix, char *buf, int size)
} }
/* Global strings for logging */ /* 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", "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", "?", "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", "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", "??", "IA", "IE", "E1", "E2",
}; };

View File

@ -215,8 +215,8 @@ struct ospf6_route_table {
#define OSPF6_ROUTE_TABLE_CREATE(s, t) \ #define OSPF6_ROUTE_TABLE_CREATE(s, t) \
ospf6_route_table_create(OSPF6_SCOPE_TYPE_##s, OSPF6_TABLE_TYPE_##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 *const 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_substr[OSPF6_DEST_TYPE_MAX];
#define OSPF6_DEST_TYPE_NAME(x) \ #define OSPF6_DEST_TYPE_NAME(x) \
(0 < (x) && (x) < OSPF6_DEST_TYPE_MAX ? ospf6_dest_type_str[(x)] \ (0 < (x) && (x) < OSPF6_DEST_TYPE_MAX ? ospf6_dest_type_str[(x)] \
: ospf6_dest_type_str[0]) : 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)] \ (0 < (x) && (x) < OSPF6_DEST_TYPE_MAX ? ospf6_dest_type_substr[(x)] \
: ospf6_dest_type_substr[0]) : ospf6_dest_type_substr[0])
extern const char *ospf6_path_type_str[OSPF6_PATH_TYPE_MAX]; extern const char *const 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_substr[OSPF6_PATH_TYPE_MAX];
#define OSPF6_PATH_TYPE_NAME(x) \ #define OSPF6_PATH_TYPE_NAME(x) \
(0 < (x) && (x) < OSPF6_PATH_TYPE_MAX ? ospf6_path_type_str[(x)] \ (0 < (x) && (x) < OSPF6_PATH_TYPE_MAX ? ospf6_path_type_str[(x)] \
: ospf6_path_type_str[0]) : ospf6_path_type_str[0])

View File

@ -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*", "R+", "R-", "N+", "N-", "L+", "L-", "R*", "N*",
}; };

View File

@ -418,7 +418,7 @@ static int ism_ignore(struct ospf_interface *oi)
} }
/* Interface State Machine */ /* Interface State Machine */
struct { const struct {
int (*func)(struct ospf_interface *); int (*func)(struct ospf_interface *);
int next_state; int next_state;
} ISM[OSPF_ISM_STATE_MAX][OSPF_ISM_EVENT_MAX] = { } 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", "NoEvent", "InterfaceUp", "WaitTimer", "BackupSeen",
"NeighborChange", "LoopInd", "UnLoopInd", "InterfaceDown", "NeighborChange", "LoopInd", "UnLoopInd", "InterfaceDown",
}; };

View File

@ -290,7 +290,7 @@ void ospf_lsa_data_free(struct lsa_header *lsah)
const char *dump_lsa_key(struct ospf_lsa *lsa) 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; struct lsa_header *lsah;
if (lsa != NULL && (lsah = lsa->data) != NULL) { if (lsa != NULL && (lsah = lsa->data) != NULL) {

View File

@ -72,9 +72,11 @@ struct zebra_privs_t ospfd_privs = {
.cap_num_i = 0}; .cap_num_i = 0};
/* OSPFd options. */ /* OSPFd options. */
struct option longopts[] = {{"instance", required_argument, NULL, 'n'}, const struct option longopts[] = {
{"apiserver", no_argument, NULL, 'a'}, {"instance", required_argument, NULL, 'n'},
{0}}; {"apiserver", no_argument, NULL, 'a'},
{0}
};
/* OSPFd program name */ /* OSPFd program name */

View File

@ -399,7 +399,7 @@ static int nsm_kill_nbr(struct ospf_neighbor *nbr)
} }
/* Neighbor State Machine */ /* Neighbor State Machine */
struct { const struct {
int (*func)(struct ospf_neighbor *); int (*func)(struct ospf_neighbor *);
int next_state; int next_state;
} NSM[OSPF_NSM_STATE_MAX][OSPF_NSM_EVENT_MAX] = { } 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", "NoEvent", "PacketReceived", "Start",
"2-WayReceived", "NegotiationDone", "ExchangeDone", "2-WayReceived", "NegotiationDone", "ExchangeDone",
"BadLSReq", "LoadingDone", "AdjOK?", "BadLSReq", "LoadingDone", "AdjOK?",

View File

@ -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"); zlog_debug("ospf_intra_add_stub(): Stop");
} }
const char *ospf_path_type_str[] = {"unknown-type", "intra-area", "inter-area", static const char *const ospf_path_type_str[] = {
"type1-external", "type2-external"}; "unknown-type", "intra-area", "inter-area", "type1-external",
"type2-external"
};
void ospf_route_table_dump(struct route_table *rt) void ospf_route_table_dump(struct route_table *rt)
{ {

View File

@ -69,7 +69,7 @@
*/ */
struct ospf_mpls_te OspfMplsTE; 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. * Followings are initialize/terminate functions for MPLS-TE handling.

View File

@ -53,7 +53,7 @@
#include "ospfd/ospf_dump.h" #include "ospfd/ospf_dump.h"
#include "ospfd/ospf_bfd.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", "Null", "POINTOPOINT", "BROADCAST", "NBMA", "POINTOMULTIPOINT",
"VIRTUALLINK", "LOOPBACK"}; "VIRTUALLINK", "LOOPBACK"};
@ -2622,11 +2622,14 @@ ALIAS(no_ospf_write_multiplier, no_write_multiplier_cmd,
"Write multiplier\n" "Write multiplier\n"
"Maximum number of interface serviced per write\n") "Maximum number of interface serviced per write\n")
const char *ospf_abr_type_descr_str[] = {"Unknown", "Standard (RFC2328)", static const char *const ospf_abr_type_descr_str[] = {
"Alternative IBM", "Alternative Cisco", "Unknown", "Standard (RFC2328)", "Alternative IBM",
"Alternative Shortcut"}; "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, static void show_ip_ospf_area(struct vty *vty, struct ospf_area *area,
json_object *json_areas, bool use_json) 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; return 0;
} }
static const char *show_database_desc[] = { static const char *const show_database_desc[] = {
"unknown", "unknown",
"Router Link States", "Router Link States",
"Net Link States", "Net Link States",
@ -5782,7 +5785,7 @@ static const char *show_database_desc[] = {
"AS-external Opaque-LSA", "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 Link count",
"Link ID ADV Router Age Seq# CkSum", "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)); vty_out(vty, " Length: %d\n\n", ntohs(lsa->data->length));
} }
const char *link_type_desc[] = { static const char *const link_type_desc[] = {
"(null)", "(null)",
"another Router (point-to-point)", "another Router (point-to-point)",
"a Transit Network", "a Transit Network",
@ -5842,12 +5845,12 @@ const char *link_type_desc[] = {
"a Virtual Link", "a Virtual Link",
}; };
const char *link_id_desc[] = { static const char *const link_id_desc[] = {
"(null)", "Neighboring Router ID", "Designated Router address", "(null)", "Neighboring Router ID", "Designated Router address",
"Net", "Neighboring Router ID", "Net", "Neighboring Router ID",
}; };
const char *link_data_desc[] = { static const char *const link_data_desc[] = {
"(null)", "Router Interface address", "Router Interface address", "(null)", "Router Interface address", "Router Interface address",
"Network Mask", "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; return 0;
} }
int (*show_function[])(struct vty *, struct ospf_lsa *) = { int (*const show_function[])(struct vty *, struct ospf_lsa *) = {
NULL, NULL,
show_router_lsa_detail, show_router_lsa_detail,
show_network_lsa_detail, show_network_lsa_detail,
@ -9646,7 +9649,7 @@ DEFUN (show_ip_ospf_vrfs,
struct ospf *ospf = NULL; struct ospf *ospf = NULL;
struct listnode *node = NULL; struct listnode *node = NULL;
int count = 0; int count = 0;
static char header[] = "Name Id RouterId "; static const char header[] = "Name Id RouterId ";
if (uj) { if (uj) {
json = json_object_new_object(); json = json_object_new_object();
@ -9703,16 +9706,23 @@ DEFUN (show_ip_ospf_vrfs,
return CMD_SUCCESS; return CMD_SUCCESS;
} }
const char *ospf_abr_type_str[] = {"unknown", "standard", "ibm", "cisco", static const char *const ospf_abr_type_str[] = {
"shortcut"}; "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. */ static const char *const ospf_int_type_str[] = {
"point-to-point", "broadcast", "unknown", /* should never be used. */
"non-broadcast", "point-to-multipoint", "point-to-point",
"virtual-link", /* should never be used. */ "broadcast",
"loopback"}; "non-broadcast",
"point-to-multipoint",
"virtual-link", /* should never be used. */
"loopback"
};
static int config_write_interface_one(struct vty *vty, struct vrf *vrf) static int config_write_interface_one(struct vty *vty, struct vrf *vrf)
{ {

View File

@ -145,7 +145,7 @@ static void pbr_map_pbrms_uninstall(struct pbr_map_sequence *pbrms)
pbr_map_pbrms_update_common(pbrms, false); 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", "Invalid NH-group", "Invalid NH", "No Nexthops",
"Both NH and NH-Group", "Invalid Src or Dst", "Invalid VRF", "Both NH and NH-Group", "Invalid Src or Dst", "Invalid VRF",
"Deleting Sequence", "Deleting Sequence",

View File

@ -147,7 +147,7 @@ static int pim_mroute_set(struct pim_instance *pim, int enable)
return 0; return 0;
} }
static const char *igmpmsgtype2str[IGMPMSG_WRVIFWHOLE + 1] = { static const char *const igmpmsgtype2str[IGMPMSG_WRVIFWHOLE + 1] = {
"<unknown_upcall?>", "NOCACHE", "WRONGVIF", "WHOLEPKT", "WRVIFWHOLE"}; "<unknown_upcall?>", "NOCACHE", "WRONGVIF", "WHOLEPKT", "WRVIFWHOLE"};
static int pim_mroute_msg_nocache(int fd, struct interface *ifp, static int pim_mroute_msg_nocache(int fd, struct interface *ifp,

View File

@ -50,13 +50,13 @@ int vrrp_autoconfig_version;
struct vrrp_defaults vd; struct vrrp_defaults vd;
const char *vrrp_state_names[3] = { const char *const vrrp_state_names[3] = {
[VRRP_STATE_INITIALIZE] = "Initialize", [VRRP_STATE_INITIALIZE] = "Initialize",
[VRRP_STATE_MASTER] = "Master", [VRRP_STATE_MASTER] = "Master",
[VRRP_STATE_BACKUP] = "Backup", [VRRP_STATE_BACKUP] = "Backup",
}; };
const char *vrrp_event_names[2] = { static const char *const vrrp_event_names[2] = {
[VRRP_EVENT_STARTUP] = "Startup", [VRRP_EVENT_STARTUP] = "Startup",
[VRRP_EVENT_SHUTDOWN] = "Shutdown", [VRRP_EVENT_SHUTDOWN] = "Shutdown",
}; };
@ -1414,7 +1414,7 @@ static void vrrp_change_state_initialize(struct vrrp_router *r)
vrrp_zebra_radv_set(r, false); 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_MASTER] = vrrp_change_state_master,
[VRRP_STATE_BACKUP] = vrrp_change_state_backup, [VRRP_STATE_BACKUP] = vrrp_change_state_backup,
[VRRP_STATE_INITIALIZE] = vrrp_change_state_initialize, [VRRP_STATE_INITIALIZE] = vrrp_change_state_initialize,
@ -1639,7 +1639,7 @@ static int vrrp_shutdown(struct vrrp_router *r)
return 0; 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_STARTUP] = vrrp_startup,
[VRRP_EVENT_SHUTDOWN] = vrrp_shutdown, [VRRP_EVENT_SHUTDOWN] = vrrp_shutdown,
}; };

View File

@ -465,8 +465,7 @@ int vrrp_del_ipv6(struct vrrp_vrouter *vr, struct in6_addr v6);
#define VRRP_EVENT_STARTUP 0 #define VRRP_EVENT_STARTUP 0
#define VRRP_EVENT_SHUTDOWN 1 #define VRRP_EVENT_SHUTDOWN 1
extern const char *vrrp_state_names[3]; extern const char *const vrrp_state_names[3];
extern const char *vrrp_event_names[2];
/* /*
* This hook called whenever the state of a Virtual Router changes, after the * This hook called whenever the state of a Virtual Router changes, after the

View File

@ -33,7 +33,7 @@
DEFINE_MTYPE_STATIC(VRRPD, VRRP_PKT, "VRRP packet") DEFINE_MTYPE_STATIC(VRRPD, VRRP_PKT, "VRRP packet")
/* clang-format off */ /* clang-format off */
const char *vrrp_packet_names[16] = { static const char *const vrrp_packet_names[16] = {
[0] = "Unknown", [0] = "Unknown",
[VRRP_TYPE_ADVERTISEMENT] = "ADVERTISEMENT", [VRRP_TYPE_ADVERTISEMENT] = "ADVERTISEMENT",
[2] = "Unknown", [2] = "Unknown",

View File

@ -28,8 +28,6 @@
#define VRRP_TYPE_ADVERTISEMENT 1 #define VRRP_TYPE_ADVERTISEMENT 1
extern const char *vrrp_packet_names[16];
/* /*
* Shared header for VRRPv2/v3 packets. * Shared header for VRRPv2/v3 packets.
*/ */

View File

@ -76,7 +76,7 @@ typedef enum {
PHASE_WAITING_ZEBRA_UP PHASE_WAITING_ZEBRA_UP
} restart_phase_t; } restart_phase_t;
static const char *phase_str[] = { static const char *const phase_str[] = {
"Idle", "Idle",
"Startup", "Startup",
"Stop jobs running", "Stop jobs running",
@ -144,7 +144,7 @@ typedef enum {
#define IS_UP(DMN) \ #define IS_UP(DMN) \
(((DMN)->state == DAEMON_UP) || ((DMN)->state == DAEMON_UNRESPONSIVE)) (((DMN)->state == DAEMON_UP) || ((DMN)->state == DAEMON_UNRESPONSIVE))
static const char *state_str[] = { static const char *const state_str[] = {
"Init", "Down", "Connecting", "Up", "Unresponsive", "Init", "Down", "Connecting", "Up", "Unresponsive",
}; };

View File

@ -30,7 +30,7 @@
extern struct zebra_privs_t zserv_privs; 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) 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/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) int ipforward_on(void)
{ {
@ -114,7 +114,8 @@ int ipforward_off(void)
return ipforward(); 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) int ipforward_ipv6(void)
{ {

View File

@ -84,7 +84,7 @@ uint32_t nl_rcvbufsize = 4194304;
#define OPTION_V6_RR_SEMANTICS 2000 #define OPTION_V6_RR_SEMANTICS 2000
/* Command line options. */ /* Command line options. */
struct option longopts[] = { const struct option longopts[] = {
{"batch", no_argument, NULL, 'b'}, {"batch", no_argument, NULL, 'b'},
{"allow_delete", no_argument, NULL, 'a'}, {"allow_delete", no_argument, NULL, 'a'},
{"keep_kernel", no_argument, NULL, 'k'}, {"keep_kernel", no_argument, NULL, 'k'},

View File

@ -83,8 +83,8 @@ struct gw_family_t {
union g_addr gate; union g_addr gate;
}; };
char ipv4_ll_buf[16] = "169.254.0.1"; static const char ipv4_ll_buf[16] = "169.254.0.1";
struct in_addr ipv4_ll; static struct in_addr ipv4_ll;
/* /*
* The ipv4_ll data structure is used for all 5549 * The ipv4_ll data structure is used for all 5549

View File

@ -72,7 +72,9 @@ DEFINE_MTYPE_STATIC(ZEBRA, RTADV_DNSSL, "Router Advertisement DNSSL")
/* Order is intentional. Matches RFC4191. This array is also used for /* Order is intentional. Matches RFC4191. This array is also used for
command matching, so only modify with care. */ 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 { enum rtadv_event {
RTADV_START, RTADV_START,

View File

@ -131,8 +131,6 @@ struct nd_opt_dnssl { /* DNS search list option [RFC8106 5.2] */
} __attribute__((__packed__)); } __attribute__((__packed__));
#endif #endif
extern const char *rtadv_pref_strs[];
#endif /* HAVE_RTADV */ #endif /* HAVE_RTADV */
typedef enum { typedef enum {

View File

@ -1022,7 +1022,7 @@ static int zsend_table_manager_connect_response(struct zserv *client,
/* Inbound message handling ------------------------------------------------ */ /* Inbound message handling ------------------------------------------------ */
int cmd2type[] = { const int cmd2type[] = {
[ZEBRA_NEXTHOP_REGISTER] = RNH_NEXTHOP_TYPE, [ZEBRA_NEXTHOP_REGISTER] = RNH_NEXTHOP_TYPE,
[ZEBRA_NEXTHOP_UNREGISTER] = RNH_NEXTHOP_TYPE, [ZEBRA_NEXTHOP_UNREGISTER] = RNH_NEXTHOP_TYPE,
[ZEBRA_IMPORT_ROUTE_REGISTER] = RNH_IMPORT_CHECK_TYPE, [ZEBRA_IMPORT_ROUTE_REGISTER] = RNH_IMPORT_CHECK_TYPE,
@ -2485,7 +2485,7 @@ stream_failure:
return; 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_ADD] = zread_router_id_add,
[ZEBRA_ROUTER_ID_DELETE] = zread_router_id_delete, [ZEBRA_ROUTER_ID_DELETE] = zread_router_id_delete,
[ZEBRA_INTERFACE_ADD] = zread_interface_add, [ZEBRA_INTERFACE_ADD] = zread_interface_add,

View File

@ -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 * Array that helps us go over all AFI/SAFI combinations via one
* index. * index.
*/ */
static struct { static const struct {
afi_t afi; afi_t afi;
safi_t safi; safi_t safi;
} afi_safis[] = { } afi_safis[] = {