localize functions where possible
Subsystems (4)
cover localize functions where possible
This is the result of using a script to examine where functions are defined in one file but not used in any other file. Found some dead code in process.
Stephen Hemminger (7):
utils: make local cmdline functions static
libnetlink: drop unused rtnl_talk_iov
bridge: make print_vlan_info static
rt_names: drop unused rtnl_addrprot_a2n
ip: make print_rta_gateway static
xfrm: make xfrm_stat_print_nokeys static
rdma: make rd_attr_check static
bridge/br_common.h | 1 - bridge/vlan.c | 3 ++- include/libnetlink.h | 3 --- include/rt_names.h | 1 - include/utils.h | 3 --- ip/ip_common.h | 2 -- ip/iproute.c | 2 +- ip/xfrm.h | 1 - ip/xfrm_state.c | 2 +- lib/libnetlink.c | 6 ------ lib/rt_names.c | 33 --------------------------------- lib/utils.c | 6 +++--- rdma/rdma.h | 1 - rdma/utils.c | 2 +- 14 files changed, 8 insertions(+), 58 deletions(-)
Signature · 1 line
2.39.2
PATCH 1/7 utils: make local cmdline functions static
No need to expose these parts of command line parsing.
--- include/utils.h | 3 --- lib/utils.c | 6 +++--- 2 files changed, 3 insertions(+), 6 deletions(-)
include/utils.h +0 -3
@@ -139,7 +139,6 @@ int get_addr_rta(inet_prefix *dst, const struct rtattr *rta, int family);int get_addr_ila (__u64 *val,const char *arg);int read_prop (const char *dev,char *prop,long *value); -int get_hex (char c);int get_integer (int *val,const char *arg,int base);int get_unsigned (unsigned *val,const char *arg,int base);int get_time_rtt (unsigned *val,const char *arg,int *raw);
@@ -304,8 +303,6 @@ unsigned int print_name_and_link(const char *fmt,#define ntohll (x) ((1==ntohl(1)) ? (x) : ((uint64_t)ntohl((x) & 0xFFFFFFFF) << 32) | ntohl((x) >> 32))extern int cmdlineno; -ssize_t getcmdline (char **line,size_t *len,FILE *in); -int makeargs (char *line,char *argv[],int maxargs);char *int_to_str (int val,char *buf);int get_guid (__u64 *guid,const char *arg);
lib/utils.c +3 -3
@@ -96,7 +96,7 @@ out:return -1 ; } -int get_hex (char c) +static int get_hex (char c) {if (c >='A' && c <='F' )return c -'A' +10 ;
@@ -1289,7 +1289,7 @@ unsigned int print_name_and_link(const char *fmt,int cmdlineno;/* Like glibc getline but handle continuation lines and comments */ -ssize_t getcmdline (char **linep,size_t *lenp,FILE *in) +static ssize_t getcmdline (char **linep,size_t *lenp,FILE *in) {ssize_t cc;char *cp;
@@ -1336,7 +1336,7 @@ ssize_t getcmdline(char **linep, size_t *lenp, FILE *in) }/* split command line into argument vector */ -int makeargs (char *line,char *argv[],int maxargs) +static int makeargs (char *line,char *argv[],int maxargs) {static const char ws[] =" \t\r\n" ;char *cp = line;
Signature · 1 line
2.39.2
PATCH 2/7 libnetlink: drop unused rtnl_talk_iov
In reply to Stephen HemmingerFunction was defined but not used in current iproute2 code.
--- include/libnetlink.h | 3 --- lib/libnetlink.c | 6 ------ 2 files changed, 9 deletions(-)
include/libnetlink.h +0 -3
@@ -177,9 +177,6 @@ int rtnl_echo_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, int json,int rtnl_talk (struct rtnl_handle *rtnl,struct nlmsghdr *n,struct nlmsghdr **answer) __attribute__((warn_unused_result)); -int rtnl_talk_iov (struct rtnl_handle *rtnl,struct iovec *iovec,size_t iovlen, -struct nlmsghdr **answer) - __attribute__((warn_unused_result));int rtnl_talk_suppress_rtnl_errmsg (struct rtnl_handle *rtnl,struct nlmsghdr *n,struct nlmsghdr **answer) __attribute__((warn_unused_result));
lib/libnetlink.c +0 -6
@@ -1168,12 +1168,6 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n,return __rtnl_talk (rtnl, n, answer, true,NULL ); } -int rtnl_talk_iov (struct rtnl_handle *rtnl,struct iovec *iovec,size_t iovlen, -struct nlmsghdr **answer) -{ -return __rtnl_talk_iov (rtnl, iovec, iovlen, answer, true,NULL ); -} -int rtnl_talk_suppress_rtnl_errmsg (struct rtnl_handle *rtnl,struct nlmsghdr *n,struct nlmsghdr **answer) {
Signature · 1 line
2.39.2
PATCH 3/7 bridge: make print_vlan_info static
In reply to Stephen HemmingerFunction defined and used in only one file.
--- bridge/br_common.h | 1 - bridge/vlan.c | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-)
bridge/br_common.h +0 -1
@@ -6,7 +6,6 @@#define MDB_RTR_RTA (r) \ ((struct rtattr *)(((char *)(r)) + RTA_ALIGN(sizeof(__u32)))) -void print_vlan_info (struct rtattr *tb,int ifindex);int print_linkinfo (struct nlmsghdr *n,void *arg);int print_mdb_mon (struct nlmsghdr *n,void *arg);int print_fdb (struct nlmsghdr *n,void *arg);
bridge/vlan.c +2 -1
@@ -18,6 +18,7 @@static unsigned int filter_index, filter_vlan;static int vlan_rtm_cur_ifidx =-1 ; +static void print_vlan_info (struct rtattr *tb,int ifindex);enum vlan_show_subject {VLAN_SHOW_VLAN ,
@@ -1309,7 +1310,7 @@ static int vlan_global_show(int argc, char **argv)return 0 ; } -void print_vlan_info (struct rtattr *tb,int ifindex) +static void print_vlan_info (struct rtattr *tb,int ifindex) {struct rtattr *i, *list = tb;int rem =RTA_PAYLOAD (list);
Signature · 1 line
2.39.2
Re: [PATCH iproute2 3/7] bridge: make print_vlan_info static
Quoted 33 lines · Stephen Hemminger
Function defined and used in only one file.
Signed-off-by Stephen Hemminger <[email protected]>--- bridge/br_common.h | 1 - bridge/vlan.c | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-)bridge/br_common.h +0
-1@@ -6,7 +6,6 @@#define MDB_RTR_RTA (r) \ ((struct rtattr *)(((char *)(r)) + RTA_ALIGN(sizeof(__u32)))) -void print_vlan_info (struct rtattr *tb,int ifindex);int print_linkinfo (struct nlmsghdr *n,void *arg);int print_mdb_mon (struct nlmsghdr *n,void *arg);int print_fdb (struct nlmsghdr *n,void *arg);bridge/vlan.c +1
-0@@ -18,6 +18,7 @@static unsigned int filter_index, filter_vlan;static int vlan_rtm_cur_ifidx =-1 ; +static void print_vlan_info (struct rtattr *tb,int ifindex);enum vlan_show_subject {VLAN_SHOW_VLAN ,
bridge/vlan.c static int vlan_global_show(int argc, char **argv) · line 1316
Quoted 8 lines
bridge/vlan.c +1
-1@@ -1309,7 +1310,7 @@ static int vlan_global_show(int argc, char **argv)return 0 ; } -void print_vlan_info (struct rtattr *tb,int ifindex) +static void print_vlan_info (struct rtattr *tb,int ifindex) {struct rtattr *i, *list = tb;int rem =RTA_PAYLOAD (list);
Thanks,
PATCH 4/7 rt_names: drop unused rtnl_addrprot_a2n
In reply to Stephen HemmingerThis function is defined but never used in current code.
--- include/rt_names.h | 1 - lib/rt_names.c | 33 --------------------------------- 2 files changed, 34 deletions(-)
include/rt_names.h +0 -1
@@ -14,7 +14,6 @@ const char *rtnl_dsfield_get_name(int id);const char *rtnl_group_n2a (int id,char *buf,int len);int rtnl_rtprot_a2n (__u32 *id,const char *arg); -int rtnl_addrprot_a2n (__u32 *id,const char *arg);int rtnl_rtscope_a2n (__u32 *id,const char *arg);int rtnl_rttable_a2n (__u32 *id,const char *arg);int rtnl_rtrealm_a2n (__u32 *id,const char *arg);
lib/rt_names.c +0 -33
@@ -255,39 +255,6 @@ numeric:return buf; } -int rtnl_addrprot_a2n (__u32 *id,const char *arg) -{ -static char *cache; -static unsigned long res; -char *end; -int i; - -if (cache &&strcmp (cache, arg) ==0 ) { - *id = res; -return 0 ; - } - -if (!rtnl_addrprot_tab_initialized) -rtnl_addrprot_initialize (); - -for (i =0 ; i <256 ; i++) { -if (rtnl_addrprot_tab[i] && -strcmp (rtnl_addrprot_tab[i], arg) ==0 ) { - cache = rtnl_addrprot_tab[i]; - res = i; - *id = res; -return 0 ; - } - } - - res =strtoul (arg, &end,0 ); -if (!end || end == arg || *end || res >255 ) -return -1 ; - *id = res; -return 0 ; -} - -static char *rtnl_rtscope_tab[256 ] = { [RT_SCOPE_UNIVERSE ] ="global" , [RT_SCOPE_NOWHERE ] ="nowhere" ,
Signature · 1 line
2.39.2
PATCH 5/7 ip: make print_rta_gateway static
In reply to Stephen HemmingerFunction only used in one file.
--- ip/ip_common.h | 2 -- ip/iproute.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-)
ip/ip_common.h +0 -2
@@ -226,8 +226,6 @@ void print_num(FILE *fp, unsigned int width, uint64_t count);void print_rt_flags (FILE *fp,unsigned int flags);void print_rta_ifidx (FILE *fp,__u32 ifidx,const char *prefix);void __print_rta_gateway (FILE *fp,unsigned char family,const char *gateway); -void print_rta_gateway (FILE *fp,unsigned char family, -const struct rtattr *rta);void size_columns (unsigned int cols[],unsigned int n, ...);void print_stats64 (FILE *fp,struct rtnl_link_stats64 *s,const struct rtattr *carrier_changes,const char *what);
ip/iproute.c +1 -1
@@ -558,7 +558,7 @@ void __print_rta_gateway(FILE *fp, unsigned char family, const char *gateway) } } -void print_rta_gateway (FILE *fp,unsigned char family,const struct rtattr *rta) +static void print_rta_gateway (FILE *fp,unsigned char family,const struct rtattr *rta) {const char *gateway =format_host_rta (family, rta);
Signature · 1 line
2.39.2
PATCH 6/7 xfrm: make xfrm_stat_print_nokeys static
In reply to Stephen HemmingerThis function is only used in one file.
--- ip/xfrm.h | 1 - ip/xfrm_state.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-)
ip/xfrm.h +0 -1
@@ -90,7 +90,6 @@ struct xfrm_filter {extern struct xfrm_filter filter;int xfrm_state_print (struct nlmsghdr *n,void *arg); -int xfrm_state_print_nokeys (struct nlmsghdr *n,void *arg);int xfrm_policy_print (struct nlmsghdr *n,void *arg);int do_xfrm_state (int argc,char **argv);int do_xfrm_policy (int argc,char **argv);
ip/xfrm_state.c +1 -1
@@ -1027,7 +1027,7 @@ int xfrm_state_print(struct nlmsghdr *n, void *arg)return __do_xfrm_state_print (n, arg, false); } -int xfrm_state_print_nokeys (struct nlmsghdr *n,void *arg) +static int xfrm_state_print_nokeys (struct nlmsghdr *n,void *arg) {return __do_xfrm_state_print (n, arg, true); }
Signature · 1 line
2.39.2
PATCH 7/7 rdma: make rd_attr_check static
In reply to Stephen HemmingerFunction defined and used in only one file.
--- rdma/rdma.h | 1 - rdma/utils.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-)
rdma/rdma.h +0 -1
@@ -131,7 +131,6 @@ int rd_sendrecv_msg(struct rd *rd, unsigned int seq);void rd_prepare_msg (struct rd *rd,uint32_t cmd,uint32_t *seq,uint16_t flags);int rd_dev_init_cb (const struct nlmsghdr *nlh,void *data);int rd_attr_cb (const struct nlattr *attr,void *data); -int rd_attr_check (const struct nlattr *attr,int *typep);/* * Print helpers
rdma/utils.c +1 -1
@@ -475,7 +475,7 @@ static const enum mnl_attr_data_type nldev_policy[RDMA_NLDEV_ATTR_MAX] = { [RDMA_NLDEV_ATTR_RES_RAW] = MNL_TYPE_BINARY, }; -int rd_attr_check (const struct nlattr *attr,int *typep) +static int rd_attr_check (const struct nlattr *attr,int *typep) {int type;
Signature · 1 line
2.39.2