* [PATCH iproute2 0/7] localize functions where possible
@ 2023-06-01 17:21 Stephen Hemminger
2023-06-01 17:21 ` [PATCH iproute2 1/7] utils: make local cmdline functions static Stephen Hemminger
` (6 more replies)
0 siblings, 7 replies; 9+ messages in thread
From: Stephen Hemminger @ 2023-06-01 17:21 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger
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(-)
--
2.39.2
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH iproute2 1/7] utils: make local cmdline functions static
2023-06-01 17:21 [PATCH iproute2 0/7] localize functions where possible Stephen Hemminger
@ 2023-06-01 17:21 ` Stephen Hemminger
2023-06-01 17:21 ` [PATCH iproute2 2/7] libnetlink: drop unused rtnl_talk_iov Stephen Hemminger
` (5 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Stephen Hemminger @ 2023-06-01 17:21 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger
No need to expose these parts of command line parsing.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
include/utils.h | 3 ---
lib/utils.c | 6 +++---
2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/include/utils.h b/include/utils.h
index 0f1b3bef34d8..0b5d86a26488 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -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);
diff --git a/lib/utils.c b/lib/utils.c
index 8dc302bdfe02..01f3a5f7e4ea 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -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;
--
2.39.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH iproute2 2/7] libnetlink: drop unused rtnl_talk_iov
2023-06-01 17:21 [PATCH iproute2 0/7] localize functions where possible Stephen Hemminger
2023-06-01 17:21 ` [PATCH iproute2 1/7] utils: make local cmdline functions static Stephen Hemminger
@ 2023-06-01 17:21 ` Stephen Hemminger
2023-06-01 17:21 ` [PATCH iproute2 3/7] bridge: make print_vlan_info static Stephen Hemminger
` (4 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Stephen Hemminger @ 2023-06-01 17:21 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger
Function was defined but not used in current iproute2 code.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
include/libnetlink.h | 3 ---
lib/libnetlink.c | 6 ------
2 files changed, 9 deletions(-)
diff --git a/include/libnetlink.h b/include/libnetlink.h
index c91a22314548..39ed87a7976e 100644
--- a/include/libnetlink.h
+++ b/include/libnetlink.h
@@ -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));
diff --git a/lib/libnetlink.c b/lib/libnetlink.c
index 68360b0f4c96..7edcd28569fd 100644
--- a/lib/libnetlink.c
+++ b/lib/libnetlink.c
@@ -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)
{
--
2.39.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH iproute2 3/7] bridge: make print_vlan_info static
2023-06-01 17:21 [PATCH iproute2 0/7] localize functions where possible Stephen Hemminger
2023-06-01 17:21 ` [PATCH iproute2 1/7] utils: make local cmdline functions static Stephen Hemminger
2023-06-01 17:21 ` [PATCH iproute2 2/7] libnetlink: drop unused rtnl_talk_iov Stephen Hemminger
@ 2023-06-01 17:21 ` Stephen Hemminger
2023-06-01 17:25 ` Nikolay Aleksandrov
2023-06-01 17:21 ` [PATCH iproute2 4/7] rt_names: drop unused rtnl_addrprot_a2n Stephen Hemminger
` (3 subsequent siblings)
6 siblings, 1 reply; 9+ messages in thread
From: Stephen Hemminger @ 2023-06-01 17:21 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger, Roopa Prabhu, Nikolay Aleksandrov, bridge
Function defined and used in only one file.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
bridge/br_common.h | 1 -
bridge/vlan.c | 3 ++-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/bridge/br_common.h b/bridge/br_common.h
index 1bdee65844c1..704e76b0acb2 100644
--- a/bridge/br_common.h
+++ b/bridge/br_common.h
@@ -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);
diff --git a/bridge/vlan.c b/bridge/vlan.c
index 5b304ea94224..dfc62f83a5df 100644
--- a/bridge/vlan.c
+++ b/bridge/vlan.c
@@ -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);
--
2.39.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH iproute2 4/7] rt_names: drop unused rtnl_addrprot_a2n
2023-06-01 17:21 [PATCH iproute2 0/7] localize functions where possible Stephen Hemminger
` (2 preceding siblings ...)
2023-06-01 17:21 ` [PATCH iproute2 3/7] bridge: make print_vlan_info static Stephen Hemminger
@ 2023-06-01 17:21 ` Stephen Hemminger
2023-06-01 17:21 ` [PATCH iproute2 5/7] ip: make print_rta_gateway static Stephen Hemminger
` (2 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Stephen Hemminger @ 2023-06-01 17:21 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger
This function is defined but never used in current code.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
include/rt_names.h | 1 -
lib/rt_names.c | 33 ---------------------------------
2 files changed, 34 deletions(-)
diff --git a/include/rt_names.h b/include/rt_names.h
index e96d80f30554..9003e67785b3 100644
--- a/include/rt_names.h
+++ b/include/rt_names.h
@@ -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);
diff --git a/lib/rt_names.c b/lib/rt_names.c
index 51d11fd056b1..8af3bca3245b 100644
--- a/lib/rt_names.c
+++ b/lib/rt_names.c
@@ -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",
--
2.39.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH iproute2 5/7] ip: make print_rta_gateway static
2023-06-01 17:21 [PATCH iproute2 0/7] localize functions where possible Stephen Hemminger
` (3 preceding siblings ...)
2023-06-01 17:21 ` [PATCH iproute2 4/7] rt_names: drop unused rtnl_addrprot_a2n Stephen Hemminger
@ 2023-06-01 17:21 ` Stephen Hemminger
2023-06-01 17:21 ` [PATCH iproute2 6/7] xfrm: make xfrm_stat_print_nokeys static Stephen Hemminger
2023-06-01 17:21 ` [PATCH iproute2 7/7] rdma: make rd_attr_check static Stephen Hemminger
6 siblings, 0 replies; 9+ messages in thread
From: Stephen Hemminger @ 2023-06-01 17:21 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger
Function only used in one file.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
ip/ip_common.h | 2 --
ip/iproute.c | 2 +-
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/ip/ip_common.h b/ip/ip_common.h
index 4a20ec3cba62..b65c2b41dc87 100644
--- a/ip/ip_common.h
+++ b/ip/ip_common.h
@@ -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);
diff --git a/ip/iproute.c b/ip/iproute.c
index 7909c4a210cc..fdf1f9a9dd0a 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -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);
--
2.39.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH iproute2 6/7] xfrm: make xfrm_stat_print_nokeys static
2023-06-01 17:21 [PATCH iproute2 0/7] localize functions where possible Stephen Hemminger
` (4 preceding siblings ...)
2023-06-01 17:21 ` [PATCH iproute2 5/7] ip: make print_rta_gateway static Stephen Hemminger
@ 2023-06-01 17:21 ` Stephen Hemminger
2023-06-01 17:21 ` [PATCH iproute2 7/7] rdma: make rd_attr_check static Stephen Hemminger
6 siblings, 0 replies; 9+ messages in thread
From: Stephen Hemminger @ 2023-06-01 17:21 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger
This function is only used in one file.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
ip/xfrm.h | 1 -
ip/xfrm_state.c | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/ip/xfrm.h b/ip/xfrm.h
index 33c42730375d..5238fc8b2b88 100644
--- a/ip/xfrm.h
+++ b/ip/xfrm.h
@@ -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);
diff --git a/ip/xfrm_state.c b/ip/xfrm_state.c
index aa0dce072dff..a7b3d0e14156 100644
--- a/ip/xfrm_state.c
+++ b/ip/xfrm_state.c
@@ -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);
}
--
2.39.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH iproute2 7/7] rdma: make rd_attr_check static
2023-06-01 17:21 [PATCH iproute2 0/7] localize functions where possible Stephen Hemminger
` (5 preceding siblings ...)
2023-06-01 17:21 ` [PATCH iproute2 6/7] xfrm: make xfrm_stat_print_nokeys static Stephen Hemminger
@ 2023-06-01 17:21 ` Stephen Hemminger
6 siblings, 0 replies; 9+ messages in thread
From: Stephen Hemminger @ 2023-06-01 17:21 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger, Leon Romanovsky
Function defined and used in only one file.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
rdma/rdma.h | 1 -
rdma/utils.c | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/rdma/rdma.h b/rdma/rdma.h
index 8b421db807a6..0bf77f4dcf9e 100644
--- a/rdma/rdma.h
+++ b/rdma/rdma.h
@@ -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
diff --git a/rdma/utils.c b/rdma/utils.c
index a33ff420f8cb..8a091c05e0a2 100644
--- a/rdma/utils.c
+++ b/rdma/utils.c
@@ -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;
--
2.39.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH iproute2 3/7] bridge: make print_vlan_info static
2023-06-01 17:21 ` [PATCH iproute2 3/7] bridge: make print_vlan_info static Stephen Hemminger
@ 2023-06-01 17:25 ` Nikolay Aleksandrov
0 siblings, 0 replies; 9+ messages in thread
From: Nikolay Aleksandrov @ 2023-06-01 17:25 UTC (permalink / raw)
To: Stephen Hemminger, netdev; +Cc: Roopa Prabhu, bridge
On 01/06/2023 20:21, Stephen Hemminger wrote:
> Function defined and used in only one file.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
> bridge/br_common.h | 1 -
> bridge/vlan.c | 3 ++-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/bridge/br_common.h b/bridge/br_common.h
> index 1bdee65844c1..704e76b0acb2 100644
> --- a/bridge/br_common.h
> +++ b/bridge/br_common.h
> @@ -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);
> diff --git a/bridge/vlan.c b/bridge/vlan.c
> index 5b304ea94224..dfc62f83a5df 100644
> --- a/bridge/vlan.c
> +++ b/bridge/vlan.c
> @@ -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);
Thanks,
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2023-06-01 17:25 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-01 17:21 [PATCH iproute2 0/7] localize functions where possible Stephen Hemminger
2023-06-01 17:21 ` [PATCH iproute2 1/7] utils: make local cmdline functions static Stephen Hemminger
2023-06-01 17:21 ` [PATCH iproute2 2/7] libnetlink: drop unused rtnl_talk_iov Stephen Hemminger
2023-06-01 17:21 ` [PATCH iproute2 3/7] bridge: make print_vlan_info static Stephen Hemminger
2023-06-01 17:25 ` Nikolay Aleksandrov
2023-06-01 17:21 ` [PATCH iproute2 4/7] rt_names: drop unused rtnl_addrprot_a2n Stephen Hemminger
2023-06-01 17:21 ` [PATCH iproute2 5/7] ip: make print_rta_gateway static Stephen Hemminger
2023-06-01 17:21 ` [PATCH iproute2 6/7] xfrm: make xfrm_stat_print_nokeys static Stephen Hemminger
2023-06-01 17:21 ` [PATCH iproute2 7/7] rdma: make rd_attr_check static Stephen Hemminger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).