From cf5577d280b59411ff77da727812465a4a01f4d7 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Wed, 17 Nov 2010 16:09:08 +0100 Subject: constify struct trans_tbl --- include/netlink-local.h | 8 ++++---- lib/addr.c | 2 +- lib/genl/family.c | 2 +- lib/msg.c | 2 +- lib/netfilter/ct_obj.c | 6 +++--- lib/netfilter/log_obj.c | 6 +++--- lib/netfilter/netfilter.c | 4 ++-- lib/netfilter/queue_msg_obj.c | 2 +- lib/netfilter/queue_obj.c | 4 ++-- lib/route/addr.c | 4 ++-- lib/route/cls/ematch/meta.c | 4 ++-- lib/route/cls/police.c | 2 +- lib/route/link.c | 10 +++++----- lib/route/link/inet.c | 2 +- lib/route/link/inet6.c | 4 ++-- lib/route/link/vlan.c | 2 +- lib/route/neigh.c | 6 +++--- lib/route/nexthop.c | 2 +- lib/route/route_obj.c | 2 +- lib/route/route_utils.c | 2 +- lib/route/rtnl.c | 4 ++-- lib/route/rule.c | 2 +- lib/route/sch/cbq.c | 2 +- lib/route/sch/prio.c | 2 +- lib/utils.c | 16 ++++++++-------- 25 files changed, 51 insertions(+), 51 deletions(-) diff --git a/include/netlink-local.h b/include/netlink-local.h index fbcf961..32e8302 100644 --- a/include/netlink-local.h +++ b/include/netlink-local.h @@ -94,14 +94,14 @@ extern int __nl_read_num_str_file(const char *path, extern int __trans_list_add(int, const char *, struct nl_list_head *); extern void __trans_list_clear(struct nl_list_head *); -extern char *__type2str(int, char *, size_t, struct trans_tbl *, size_t); -extern int __str2type(const char *, struct trans_tbl *, size_t); +extern char *__type2str(int, char *, size_t, const struct trans_tbl *, size_t); +extern int __str2type(const char *, const struct trans_tbl *, size_t); extern char *__list_type2str(int, char *, size_t, struct nl_list_head *); extern int __list_str2type(const char *, struct nl_list_head *); -extern char *__flags2str(int, char *, size_t, struct trans_tbl *, size_t); -extern int __str2flags(const char *, struct trans_tbl *, size_t); +extern char *__flags2str(int, char *, size_t, const struct trans_tbl *, size_t); +extern int __str2flags(const char *, const struct trans_tbl *, size_t); extern void dump_from_ops(struct nl_object *, struct nl_dump_params *); diff --git a/lib/addr.c b/lib/addr.c index 822821d..5f2402b 100644 --- a/lib/addr.c +++ b/lib/addr.c @@ -881,7 +881,7 @@ prefix: * @{ */ -static struct trans_tbl afs[] = { +static const struct trans_tbl afs[] = { __ADD(AF_UNSPEC,unspec) __ADD(AF_UNIX,unix) __ADD(AF_LOCAL,local) diff --git a/lib/genl/family.c b/lib/genl/family.c index 687f4b1..ebeebcb 100644 --- a/lib/genl/family.c +++ b/lib/genl/family.c @@ -95,7 +95,7 @@ static void family_dump_line(struct nl_object *obj, struct nl_dump_params *p) family->gf_id, family->gf_name, family->gf_version); } -static struct trans_tbl ops_flags[] = { +static const struct trans_tbl ops_flags[] = { __ADD(GENL_ADMIN_PERM, admin-perm) __ADD(GENL_CMD_CAP_DO, has-doit) __ADD(GENL_CMD_CAP_DUMP, has-dump) diff --git a/lib/msg.c b/lib/msg.c index 615decf..f6d1ee4 100644 --- a/lib/msg.c +++ b/lib/msg.c @@ -744,7 +744,7 @@ struct ucred *nlmsg_get_creds(struct nl_msg *msg) * @{ */ -static struct trans_tbl nl_msgtypes[] = { +static const struct trans_tbl nl_msgtypes[] = { __ADD(NLMSG_NOOP,NOOP) __ADD(NLMSG_ERROR,ERROR) __ADD(NLMSG_DONE,DONE) diff --git a/lib/netfilter/ct_obj.c b/lib/netfilter/ct_obj.c index ae14c0d..c205427 100644 --- a/lib/netfilter/ct_obj.c +++ b/lib/netfilter/ct_obj.c @@ -323,7 +323,7 @@ static int ct_compare(struct nl_object *_a, struct nl_object *_b, return diff; } -static struct trans_tbl ct_attrs[] = { +static const struct trans_tbl ct_attrs[] = { __ADD(CT_ATTR_FAMILY, family) __ADD(CT_ATTR_PROTO, proto) __ADD(CT_ATTR_TCP_STATE, tcpstate) @@ -430,7 +430,7 @@ uint8_t nfnl_ct_get_tcp_state(const struct nfnl_ct *ct) return ct->ct_protoinfo.tcp.state; } -static struct trans_tbl tcp_states[] = { +static const struct trans_tbl tcp_states[] = { __ADD(TCP_CONNTRACK_NONE,NONE) __ADD(TCP_CONNTRACK_SYN_SENT,SYN_SENT) __ADD(TCP_CONNTRACK_SYN_RECV,SYN_RECV) @@ -472,7 +472,7 @@ uint32_t nfnl_ct_get_status(const struct nfnl_ct *ct) return ct->ct_status; } -static struct trans_tbl status_flags[] = { +static const struct trans_tbl status_flags[] = { __ADD(IPS_EXPECTED, expected) __ADD(IPS_SEEN_REPLY, seen_reply) __ADD(IPS_ASSURED, assured) diff --git a/lib/netfilter/log_obj.c b/lib/netfilter/log_obj.c index ff2b63a..43c4a06 100644 --- a/lib/netfilter/log_obj.c +++ b/lib/netfilter/log_obj.c @@ -56,7 +56,7 @@ static void nfnl_log_dump(struct nl_object *a, struct nl_dump_params *p) nl_dump(p, "\n"); } -static struct trans_tbl copy_modes[] = { +static const struct trans_tbl copy_modes[] = { __ADD(NFNL_LOG_COPY_NONE, none) __ADD(NFNL_LOG_COPY_META, meta) __ADD(NFNL_LOG_COPY_PACKET, packet) @@ -214,7 +214,7 @@ void nfnl_log_unset_flags(struct nfnl_log *log, unsigned int flags) log->log_flag_mask |= flags; } -static struct trans_tbl log_flags[] = { +static const struct trans_tbl log_flags[] = { __ADD(NFNL_LOG_FLAG_SEQ, seq) __ADD(NFNL_LOG_FLAG_SEQ_GLOBAL, seq_global) }; @@ -254,7 +254,7 @@ static int nfnl_log_compare(struct nl_object *_a, struct nl_object *_b, return diff; } -static struct trans_tbl nfnl_log_attrs[] = { +static const struct trans_tbl nfnl_log_attrs[] = { __ADD(LOG_ATTR_GROUP, group) __ADD(LOG_ATTR_COPY_MODE, copy_mode) __ADD(LOG_ATTR_COPY_RANGE, copy_range) diff --git a/lib/netfilter/netfilter.c b/lib/netfilter/netfilter.c index f88b355..addecd7 100644 --- a/lib/netfilter/netfilter.c +++ b/lib/netfilter/netfilter.c @@ -13,7 +13,7 @@ #include #include -static struct trans_tbl nfnl_verdicts[] = { +static const struct trans_tbl nfnl_verdicts[] = { __ADD(NF_DROP, NF_DROP) __ADD(NF_ACCEPT, NF_ACCEPT) __ADD(NF_STOLEN, NF_STOLEN) @@ -33,7 +33,7 @@ unsigned int nfnl_str2verdict(const char *name) return __str2type(name, nfnl_verdicts, ARRAY_SIZE(nfnl_verdicts)); } -static struct trans_tbl nfnl_inet_hooks[] = { +static const struct trans_tbl nfnl_inet_hooks[] = { __ADD(NF_INET_PRE_ROUTING, NF_INET_PREROUTING) __ADD(NF_INET_LOCAL_IN, NF_INET_LOCAL_IN) __ADD(NF_INET_FORWARD, NF_INET_FORWARD) diff --git a/lib/netfilter/queue_msg_obj.c b/lib/netfilter/queue_msg_obj.c index 97813e8..33305ed 100644 --- a/lib/netfilter/queue_msg_obj.c +++ b/lib/netfilter/queue_msg_obj.c @@ -451,7 +451,7 @@ unsigned int nfnl_queue_msg_get_verdict(const struct nfnl_queue_msg *msg) return msg->queue_msg_verdict; } -static struct trans_tbl nfnl_queue_msg_attrs[] = { +static const struct trans_tbl nfnl_queue_msg_attrs[] = { __ADD(QUEUE_MSG_ATTR_GROUP, group) __ADD(QUEUE_MSG_ATTR_FAMILY, family) __ADD(QUEUE_MSG_ATTR_PACKETID, packetid) diff --git a/lib/netfilter/queue_obj.c b/lib/netfilter/queue_obj.c index ee03836..05a9cb8 100644 --- a/lib/netfilter/queue_obj.c +++ b/lib/netfilter/queue_obj.c @@ -52,7 +52,7 @@ static void nfnl_queue_dump(struct nl_object *a, struct nl_dump_params *p) nl_dump(p, "\n"); } -static struct trans_tbl copy_modes[] = { +static const struct trans_tbl copy_modes[] = { __ADD(NFNL_QUEUE_COPY_NONE, none) __ADD(NFNL_QUEUE_COPY_META, meta) __ADD(NFNL_QUEUE_COPY_PACKET, packet) @@ -184,7 +184,7 @@ static int nfnl_queue_compare(struct nl_object *_a, struct nl_object *_b, return diff; } -static struct trans_tbl nfnl_queue_attrs[] = { +static const struct trans_tbl nfnl_queue_attrs[] = { __ADD(QUEUE_ATTR_GROUP, group) __ADD(QUEUE_ATTR_MAXLEN, maxlen) __ADD(QUEUE_ATTR_COPY_MODE, copy_mode) diff --git a/lib/route/addr.c b/lib/route/addr.c index b170a50..b367883 100644 --- a/lib/route/addr.c +++ b/lib/route/addr.c @@ -431,7 +431,7 @@ static int addr_compare(struct nl_object *_a, struct nl_object *_b, return diff; } -static struct trans_tbl addr_attrs[] = { +static const struct trans_tbl addr_attrs[] = { __ADD(ADDR_ATTR_FAMILY, family) __ADD(ADDR_ATTR_PREFIXLEN, prefixlen) __ADD(ADDR_ATTR_FLAGS, flags) @@ -902,7 +902,7 @@ uint32_t rtnl_addr_get_last_update_time(struct rtnl_addr *addr) * @{ */ -static struct trans_tbl addr_flags[] = { +static const struct trans_tbl addr_flags[] = { __ADD(IFA_F_SECONDARY, secondary) __ADD(IFA_F_NODAD, nodad) __ADD(IFA_F_OPTIMISTIC, optimistic) diff --git a/lib/route/cls/ematch/meta.c b/lib/route/cls/ematch/meta.c index eeddc17..11f87d6 100644 --- a/lib/route/cls/ematch/meta.c +++ b/lib/route/cls/ematch/meta.c @@ -164,7 +164,7 @@ static int meta_parse(struct rtnl_ematch *e, void *data, size_t len) return 0; } -static struct trans_tbl meta_int[] = { +static const struct trans_tbl meta_int[] = { __ADD(TCF_META_ID_RANDOM, random) __ADD(TCF_META_ID_LOADAVG_0, loadavg_0) __ADD(TCF_META_ID_LOADAVG_1, loadavg_1) @@ -217,7 +217,7 @@ static char *int_id2str(int id, char *buf, size_t size) return __type2str(id, buf, size, meta_int, ARRAY_SIZE(meta_int)); } -static struct trans_tbl meta_var[] = { +static const struct trans_tbl meta_var[] = { __ADD(TCF_META_ID_DEV,devname) __ADD(TCF_META_ID_SK_BOUND_IF,sk_bound_if) }; diff --git a/lib/route/cls/police.c b/lib/route/cls/police.c index 051c6b2..f2cd45a 100644 --- a/lib/route/cls/police.c +++ b/lib/route/cls/police.c @@ -23,7 +23,7 @@ * @{ */ -static struct trans_tbl police_types[] = { +static const struct trans_tbl police_types[] = { __ADD(TC_POLICE_UNSPEC,unspec) __ADD(TC_POLICE_OK,ok) __ADD(TC_POLICE_RECLASSIFY,reclassify) diff --git a/lib/route/link.c b/lib/route/link.c index 75b70c3..c583917 100644 --- a/lib/route/link.c +++ b/lib/route/link.c @@ -886,7 +886,7 @@ static int link_compare(struct nl_object *_a, struct nl_object *_b, return diff; } -static struct trans_tbl link_attrs[] = { +static const struct trans_tbl link_attrs[] = { __ADD(LINK_ATTR_MTU, mtu) __ADD(LINK_ATTR_LINK, link) __ADD(LINK_ATTR_TXQLEN, txqlen) @@ -1223,7 +1223,7 @@ int rtnl_link_name2i(struct nl_cache *cache, const char *name) * @{ */ -static struct trans_tbl link_flags[] = { +static const struct trans_tbl link_flags[] = { __ADD(IFF_LOOPBACK, loopback) __ADD(IFF_BROADCAST, broadcast) __ADD(IFF_POINTOPOINT, pointopoint) @@ -1263,7 +1263,7 @@ int rtnl_link_str2flags(const char *name) * @{ */ -static struct trans_tbl link_stats[] = { +static const struct trans_tbl link_stats[] = { __ADD(RTNL_LINK_RX_PACKETS, rx_packets) __ADD(RTNL_LINK_TX_PACKETS, tx_packets) __ADD(RTNL_LINK_RX_BYTES, rx_bytes) @@ -1340,7 +1340,7 @@ int rtnl_link_str2stat(const char *name) * @{ */ -static struct trans_tbl link_operstates[] = { +static const struct trans_tbl link_operstates[] = { __ADD(IF_OPER_UNKNOWN, unknown) __ADD(IF_OPER_NOTPRESENT, notpresent) __ADD(IF_OPER_DOWN, down) @@ -1369,7 +1369,7 @@ int rtnl_link_str2operstate(const char *name) * @{ */ -static struct trans_tbl link_modes[] = { +static const struct trans_tbl link_modes[] = { __ADD(IF_LINK_MODE_DEFAULT, default) __ADD(IF_LINK_MODE_DORMANT, dormant) }; diff --git a/lib/route/link/inet.c b/lib/route/link/inet.c index 68afa45..9a82a8b 100644 --- a/lib/route/link/inet.c +++ b/lib/route/link/inet.c @@ -132,7 +132,7 @@ nla_put_failure: return -NLE_MSGSIZE; } -static struct trans_tbl inet_devconf[] = { +static const struct trans_tbl inet_devconf[] = { __ADD(IPV4_DEVCONF_FORWARDING, forwarding) __ADD(IPV4_DEVCONF_MC_FORWARDING, mc_forwarding) __ADD(IPV4_DEVCONF_PROXY_ARP, proxy_arp) diff --git a/lib/route/link/inet6.c b/lib/route/link/inet6.c index 80b5c41..cca308f 100644 --- a/lib/route/link/inet6.c +++ b/lib/route/link/inet6.c @@ -98,7 +98,7 @@ static int inet6_parse_protinfo(struct rtnl_link *link, struct nlattr *attr, #define IF_RS_SENT 0x10 #define IF_READY 0x80000000 -static struct trans_tbl inet6_flags[] = { +static const struct trans_tbl inet6_flags[] = { __ADD(IF_RA_OTHERCONF, ra_otherconf) __ADD(IF_RA_MANAGED, ra_managed) __ADD(IF_RA_RCVD, ra_rcvd) @@ -112,7 +112,7 @@ static char *inet6_flags2str(int flags, char *buf, size_t len) ARRAY_SIZE(inet6_flags)); } -static struct trans_tbl inet6_devconf[] = { +static const struct trans_tbl inet6_devconf[] = { __ADD(DEVCONF_FORWARDING, forwarding) __ADD(DEVCONF_HOPLIMIT, hoplimit) __ADD(DEVCONF_MTU6, mtu6) diff --git a/lib/route/link/vlan.c b/lib/route/link/vlan.c index da3ae49..f8fdc1c 100644 --- a/lib/route/link/vlan.c +++ b/lib/route/link/vlan.c @@ -47,7 +47,7 @@ struct vlan_info }; /** @endcond */ -static struct trans_tbl vlan_flags[] = { +static const struct trans_tbl vlan_flags[] = { __ADD(VLAN_FLAG_REORDER_HDR, reorder_hdr) }; diff --git a/lib/route/neigh.c b/lib/route/neigh.c index a8ebfd5..aa19faa 100644 --- a/lib/route/neigh.c +++ b/lib/route/neigh.c @@ -227,7 +227,7 @@ static int neigh_compare(struct nl_object *_a, struct nl_object *_b, return diff; } -static struct trans_tbl neigh_attrs[] = { +static const struct trans_tbl neigh_attrs[] = { __ADD(NEIGH_ATTR_FLAGS, flags) __ADD(NEIGH_ATTR_STATE, state) __ADD(NEIGH_ATTR_LLADDR, lladdr) @@ -611,7 +611,7 @@ int rtnl_neigh_delete(struct nl_sock *sk, struct rtnl_neigh *neigh, * @{ */ -static struct trans_tbl neigh_states[] = { +static const struct trans_tbl neigh_states[] = { __ADD(NUD_INCOMPLETE, incomplete) __ADD(NUD_REACHABLE, reachable) __ADD(NUD_STALE, stale) @@ -640,7 +640,7 @@ int rtnl_neigh_str2state(const char *name) * @{ */ -static struct trans_tbl neigh_flags[] = { +static const struct trans_tbl neigh_flags[] = { __ADD(NTF_USE, use) __ADD(NTF_PROXY, proxy) __ADD(NTF_ROUTER, router) diff --git a/lib/route/nexthop.c b/lib/route/nexthop.c index 44c31a7..48cbfcf 100644 --- a/lib/route/nexthop.c +++ b/lib/route/nexthop.c @@ -269,7 +269,7 @@ uint32_t rtnl_route_nh_get_realms(struct rtnl_nexthop *nh) * @{ */ -static struct trans_tbl nh_flags[] = { +static const struct trans_tbl nh_flags[] = { __ADD(RTNH_F_DEAD, dead) __ADD(RTNH_F_PERVASIVE, pervasive) __ADD(RTNH_F_ONLINK, onlink) diff --git a/lib/route/route_obj.c b/lib/route/route_obj.c index c3d7de5..2cbe2ae 100644 --- a/lib/route/route_obj.c +++ b/lib/route/route_obj.c @@ -390,7 +390,7 @@ nh_mismatch: #undef ROUTE_DIFF } -static struct trans_tbl route_attrs[] = { +static const struct trans_tbl route_attrs[] = { __ADD(ROUTE_ATTR_FAMILY, family) __ADD(ROUTE_ATTR_TOS, tos) __ADD(ROUTE_ATTR_TABLE, table) diff --git a/lib/route/route_utils.c b/lib/route/route_utils.c index 9fc8cf7..8b73f2b 100644 --- a/lib/route/route_utils.c +++ b/lib/route/route_utils.c @@ -139,7 +139,7 @@ int rtnl_route_str2proto(const char *name) * @{ */ -static struct trans_tbl route_metrices[] = { +static const struct trans_tbl route_metrices[] = { __ADD(RTAX_UNSPEC, unspec) __ADD(RTAX_LOCK, lock) __ADD(RTAX_MTU, mtu) diff --git a/lib/route/rtnl.c b/lib/route/rtnl.c index 2533674..26d1f67 100644 --- a/lib/route/rtnl.c +++ b/lib/route/rtnl.c @@ -52,7 +52,7 @@ int nl_rtgen_request(struct nl_sock *sk, int type, int family, int flags) * @{ */ -static struct trans_tbl rtntypes[] = { +static const struct trans_tbl rtntypes[] = { __ADD(RTN_UNSPEC,unspec) __ADD(RTN_UNICAST,unicast) __ADD(RTN_LOCAL,local) @@ -84,7 +84,7 @@ int nl_str2rtntype(const char *name) * @{ */ -static struct trans_tbl scopes[] = { +static const struct trans_tbl scopes[] = { __ADD(255,nowhere) __ADD(254,host) __ADD(253,link) diff --git a/lib/route/rule.c b/lib/route/rule.c index dfe1d66..36672d3 100644 --- a/lib/route/rule.c +++ b/lib/route/rule.c @@ -273,7 +273,7 @@ static int rule_compare(struct nl_object *_a, struct nl_object *_b, return diff; } -static struct trans_tbl rule_attrs[] = { +static const struct trans_tbl rule_attrs[] = { __ADD(RULE_ATTR_FAMILY, family) __ADD(RULE_ATTR_TABLE, table) __ADD(RULE_ATTR_ACTION, action) diff --git a/lib/route/sch/cbq.c b/lib/route/sch/cbq.c index 0df4aa0..989745c 100644 --- a/lib/route/sch/cbq.c +++ b/lib/route/sch/cbq.c @@ -28,7 +28,7 @@ * @{ */ -static struct trans_tbl ovl_strategies[] = { +static const struct trans_tbl ovl_strategies[] = { __ADD(TC_CBQ_OVL_CLASSIC,classic) __ADD(TC_CBQ_OVL_DELAY,delay) __ADD(TC_CBQ_OVL_LOWPRIO,lowprio) diff --git a/lib/route/sch/prio.c b/lib/route/sch/prio.c index 4c9ebcf..e08e117 100644 --- a/lib/route/sch/prio.c +++ b/lib/route/sch/prio.c @@ -248,7 +248,7 @@ uint8_t *rtnl_qdisc_prio_get_priomap(struct rtnl_qdisc *qdisc) * @{ */ -static struct trans_tbl prios[] = { +static const struct trans_tbl prios[] = { __ADD(TC_PRIO_BESTEFFORT,besteffort) __ADD(TC_PRIO_FILLER,filler) __ADD(TC_PRIO_BULK,bulk) diff --git a/lib/utils.c b/lib/utils.c index 015cd6a..8756318 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -490,7 +490,7 @@ char * nl_msec2str(uint64_t msec, char *buf, size_t len) * @{ */ -static struct trans_tbl nlfamilies[] = { +static const struct trans_tbl nlfamilies[] = { __ADD(NETLINK_ROUTE,route) __ADD(NETLINK_USERSOCK,usersock) __ADD(NETLINK_FIREWALL,firewall) @@ -531,7 +531,7 @@ int nl_str2nlfamily(const char *name) * @{ */ -static struct trans_tbl llprotos[] = { +static const struct trans_tbl llprotos[] = { {0, "generic"}, __ADD(ARPHRD_ETHER,ether) __ADD(ARPHRD_EETHER,eether) @@ -628,7 +628,7 @@ int nl_str2llproto(const char *name) * @{ */ -static struct trans_tbl ether_protos[] = { +static const struct trans_tbl ether_protos[] = { __ADD(ETH_P_LOOP,loop) __ADD(ETH_P_PUP,pup) __ADD(ETH_P_PUPAT,pupat) @@ -861,8 +861,8 @@ void __trans_list_clear(struct nl_list_head *head) } } -char *__type2str(int type, char *buf, size_t len, struct trans_tbl *tbl, - size_t tbl_len) +char *__type2str(int type, char *buf, size_t len, + const struct trans_tbl *tbl, size_t tbl_len) { int i; for (i = 0; i < tbl_len; i++) { @@ -893,7 +893,7 @@ char *__list_type2str(int type, char *buf, size_t len, } char *__flags2str(int flags, char *buf, size_t len, - struct trans_tbl *tbl, size_t tbl_len) + const struct trans_tbl *tbl, size_t tbl_len) { int i; int tmp = flags; @@ -912,7 +912,7 @@ char *__flags2str(int flags, char *buf, size_t len, return buf; } -int __str2type(const char *buf, struct trans_tbl *tbl, size_t tbl_len) +int __str2type(const char *buf, const struct trans_tbl *tbl, size_t tbl_len) { unsigned long l; char *end; @@ -953,7 +953,7 @@ int __list_str2type(const char *buf, struct nl_list_head *head) return (int) l; } -int __str2flags(const char *buf, struct trans_tbl *tbl, size_t tbl_len) +int __str2flags(const char *buf, const struct trans_tbl *tbl, size_t tbl_len) { int i, flags = 0, len; char *p = (char *) buf, *t; -- cgit v1.2.1