All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2 00/22] misc cleanups
@ 2018-11-15 22:36 Stephen Hemminger
  2018-11-15 22:36 ` [PATCH iproute2 01/22] lib/ll_addr: whitespace and indent cleanup Stephen Hemminger
                   ` (22 more replies)
  0 siblings, 23 replies; 25+ messages in thread
From: Stephen Hemminger @ 2018-11-15 22:36 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

Code cleanup including:
   * make local functions static
   * drop dead code
   * whitespace code style cleanup

Stephen Hemminger (22):
  lib/ll_addr: whitespace and indent cleanup
  lib/utils: make local functions static
  lib/color: make local functions static
  lib/ll_map: make local function static
  libnetlnk: unused and local functions cleanup
  genl: remove dead code
  bridge: make local variables static
  ip: make flag names const/static
  ipmonitor: make local variable static
  ipxfrm: make local functions static
  tc: drop unused name_to_id function
  tipc: make cmd_find static
  tc/class: make filter variables static
  tc/police: make print_police static
  ss: make local variables static
  tc/pedit: make functions static
  tc/ematch: make local functions static
  tc/util: make local functions static
  tc/meta: make meta_table static and const
  tc/action: make variables static
  tc/pedit: use structure initialization
  rdma: make local functions static

 bridge/bridge.c      |  5 ++--
 bridge/monitor.c     |  2 +-
 genl/ctrl.c          | 71 --------------------------------------------
 genl/genl_utils.h    |  2 --
 include/color.h      |  2 --
 include/libnetlink.h |  7 -----
 include/ll_map.h     |  1 -
 include/names.h      |  1 -
 include/utils.h      |  5 ----
 ip/ipaddress.c       |  2 +-
 ip/ipmonitor.c       |  2 +-
 ip/ipxfrm.c          | 11 +++----
 ip/xfrm.h            |  9 ------
 ip/xfrm_monitor.c    |  2 +-
 lib/color.c          |  6 ++--
 lib/libnetlink.c     | 28 ++---------------
 lib/ll_addr.c        | 24 ++++++++-------
 lib/ll_map.c         |  2 +-
 lib/names.c          | 28 -----------------
 lib/utils.c          | 48 +++++-------------------------
 misc/ss.c            | 28 ++++++++---------
 rdma/rdma.h          | 11 -------
 rdma/utils.c         | 12 ++++----
 tc/em_meta.c         | 12 ++++----
 tc/m_action.c        |  4 +--
 tc/m_ematch.c        | 30 ++-----------------
 tc/m_ematch.h        |  1 -
 tc/m_pedit.c         | 33 +++++++++-----------
 tc/m_pedit.h         | 15 ----------
 tc/m_police.c        | 10 +++++--
 tc/p_eth.c           |  5 ++--
 tc/p_icmp.c          |  5 ++--
 tc/p_ip.c            |  5 ++--
 tc/p_ip6.c           |  5 ++--
 tc/p_tcp.c           |  5 ++--
 tc/p_udp.c           |  5 ++--
 tc/tc_class.c        |  6 ++--
 tc/tc_util.c         | 17 ++---------
 tc/tc_util.h         |  8 -----
 tipc/cmdl.c          |  2 +-
 tipc/cmdl.h          |  2 --
 41 files changed, 110 insertions(+), 369 deletions(-)

-- 
2.17.1

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH iproute2 01/22] lib/ll_addr: whitespace and indent cleanup
  2018-11-15 22:36 [PATCH iproute2 00/22] misc cleanups Stephen Hemminger
@ 2018-11-15 22:36 ` Stephen Hemminger
  2018-11-15 22:36 ` [PATCH iproute2 02/22] lib/utils: make local functions static Stephen Hemminger
                   ` (21 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: Stephen Hemminger @ 2018-11-15 22:36 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

Run old ll_addr through kernel Lindent.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/ll_addr.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/lib/ll_addr.c b/lib/ll_addr.c
index 84de64e2e053..00b562aeda22 100644
--- a/lib/ll_addr.c
+++ b/lib/ll_addr.c
@@ -26,20 +26,20 @@
 #include "rt_names.h"
 #include "utils.h"
 
-
-const char *ll_addr_n2a(const unsigned char *addr, int alen, int type, char *buf, int blen)
+const char *ll_addr_n2a(const unsigned char *addr, int alen, int type,
+			char *buf, int blen)
 {
 	int i;
 	int l;
 
 	if (alen == 4 &&
-	    (type == ARPHRD_TUNNEL || type == ARPHRD_SIT || type == ARPHRD_IPGRE)) {
+	    (type == ARPHRD_TUNNEL || type == ARPHRD_SIT
+	     || type == ARPHRD_IPGRE))
 		return inet_ntop(AF_INET, addr, buf, blen);
-	}
-	if (alen == 16 &&
-	    (type == ARPHRD_TUNNEL6 || type == ARPHRD_IP6GRE)) {
+
+	if (alen == 16 && (type == ARPHRD_TUNNEL6 || type == ARPHRD_IP6GRE))
 		return inet_ntop(AF_INET6, addr, buf, blen);
-	}
+
 	snprintf(buf, blen, "%02x", addr[0]);
 	for (i = 1, l = 2; i < alen && l < blen; i++, l += 3)
 		snprintf(buf + l, blen - l, ":%02x", addr[i]);
@@ -62,7 +62,7 @@ int ll_addr_a2n(char *lladdr, int len, const char *arg)
 	} else {
 		int i;
 
-		for (i=0; i<len; i++) {
+		for (i = 0; i < len; i++) {
 			int temp;
 			char *cp = strchr(arg, ':');
 			if (cp) {
@@ -70,11 +70,13 @@ int ll_addr_a2n(char *lladdr, int len, const char *arg)
 				cp++;
 			}
 			if (sscanf(arg, "%x", &temp) != 1) {
-				fprintf(stderr, "\"%s\" is invalid lladdr.\n", arg);
+				fprintf(stderr, "\"%s\" is invalid lladdr.\n",
+					arg);
 				return -1;
 			}
 			if (temp < 0 || temp > 255) {
-				fprintf(stderr, "\"%s\" is invalid lladdr.\n", arg);
+				fprintf(stderr, "\"%s\" is invalid lladdr.\n",
+					arg);
 				return -1;
 			}
 			lladdr[i] = temp;
@@ -82,6 +84,6 @@ int ll_addr_a2n(char *lladdr, int len, const char *arg)
 				break;
 			arg = cp;
 		}
-		return i+1;
+		return i + 1;
 	}
 }
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH iproute2 02/22] lib/utils: make local functions static
  2018-11-15 22:36 [PATCH iproute2 00/22] misc cleanups Stephen Hemminger
  2018-11-15 22:36 ` [PATCH iproute2 01/22] lib/ll_addr: whitespace and indent cleanup Stephen Hemminger
@ 2018-11-15 22:36 ` Stephen Hemminger
  2018-11-15 22:36 ` [PATCH iproute2 03/22] lib/color: " Stephen Hemminger
                   ` (20 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: Stephen Hemminger @ 2018-11-15 22:36 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

Some of the print/parsing is only used internally.
Drop unused get_s8/get_s16.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 include/utils.h |  5 -----
 lib/utils.c     | 48 +++++++-----------------------------------------
 2 files changed, 7 insertions(+), 46 deletions(-)

diff --git a/include/utils.h b/include/utils.h
index bf6dea23df66..1630dd0b2854 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -157,9 +157,7 @@ int get_u64(__u64 *val, const char *arg, int base);
 int get_u32(__u32 *val, const char *arg, int base);
 int get_s32(__s32 *val, const char *arg, int base);
 int get_u16(__u16 *val, const char *arg, int base);
-int get_s16(__s16 *val, const char *arg, int base);
 int get_u8(__u8 *val, const char *arg, int base);
-int get_s8(__s8 *val, const char *arg, int base);
 int get_be64(__be64 *val, const char *arg, int base);
 int get_be32(__be32 *val, const char *arg, int base);
 int get_be16(__be16 *val, const char *arg, int base);
@@ -172,7 +170,6 @@ __u8 *hexstring_a2n(const char *str, __u8 *buf, int blen, unsigned int *len);
 int addr64_n2a(__u64 addr, char *buff, size_t len);
 
 int af_bit_len(int af);
-int af_byte_len(int af);
 
 const char *format_host_r(int af, int len, const void *addr,
 			       char *buf, int buflen);
@@ -326,8 +323,6 @@ void drop_cap(void);
 
 int get_time(unsigned int *time, const char *str);
 int get_time64(__s64 *time, const char *str);
-void print_time(char *buf, int len, __u32 time);
-void print_time64(char *buf, int len, __s64 time);
 char *sprint_time(__u32 time, char *buf);
 char *sprint_time64(__s64 time, char *buf);
 
diff --git a/lib/utils.c b/lib/utils.c
index 345630d04929..4965a5750880 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -45,6 +45,10 @@ int timestamp_short;
 int pretty;
 const char *_SL_ = "\n";
 
+static int af_byte_len(int af);
+static void print_time(char *buf, int len, __u32 time);
+static void print_time64(char *buf, int len, __s64 time);
+
 int read_prop(const char *dev, char *prop, long *value)
 {
 	char fname[128], buf[80], *endp, *nl;
@@ -426,43 +430,6 @@ int get_s32(__s32 *val, const char *arg, int base)
 	return 0;
 }
 
-int get_s16(__s16 *val, const char *arg, int base)
-{
-	long res;
-	char *ptr;
-
-	if (!arg || !*arg)
-		return -1;
-	res = strtol(arg, &ptr, base);
-	if (!ptr || ptr == arg || *ptr)
-		return -1;
-	if ((res == LONG_MIN || res == LONG_MAX) && errno == ERANGE)
-		return -1;
-	if (res > 0x7FFF || res < -0x8000)
-		return -1;
-
-	*val = res;
-	return 0;
-}
-
-int get_s8(__s8 *val, const char *arg, int base)
-{
-	long res;
-	char *ptr;
-
-	if (!arg || !*arg)
-		return -1;
-	res = strtol(arg, &ptr, base);
-	if (!ptr || ptr == arg || *ptr)
-		return -1;
-	if ((res == LONG_MIN || res == LONG_MAX) && errno == ERANGE)
-		return -1;
-	if (res > 0x7F || res < -0x80)
-		return -1;
-	*val = res;
-	return 0;
-}
-
 int get_be64(__be64 *val, const char *arg, int base)
 {
 	__u64 v;
@@ -708,7 +675,7 @@ int af_bit_len(int af)
 	return 0;
 }
 
-int af_byte_len(int af)
+static int af_byte_len(int af)
 {
 	return af_bit_len(af) / 8;
 }
@@ -1710,8 +1677,7 @@ int get_time(unsigned int *time, const char *str)
 	return 0;
 }
 
-
-void print_time(char *buf, int len, __u32 time)
+static void print_time(char *buf, int len, __u32 time)
 {
 	double tmp = time;
 
@@ -1764,7 +1730,7 @@ int get_time64(__s64 *time, const char *str)
 	return 0;
 }
 
-void print_time64(char *buf, int len, __s64 time)
+static void print_time64(char *buf, int len, __s64 time)
 {
 	double nsec = time;
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH iproute2 03/22] lib/color: make local functions static
  2018-11-15 22:36 [PATCH iproute2 00/22] misc cleanups Stephen Hemminger
  2018-11-15 22:36 ` [PATCH iproute2 01/22] lib/ll_addr: whitespace and indent cleanup Stephen Hemminger
  2018-11-15 22:36 ` [PATCH iproute2 02/22] lib/utils: make local functions static Stephen Hemminger
@ 2018-11-15 22:36 ` Stephen Hemminger
  2018-11-15 22:36 ` [PATCH iproute2 04/22] lib/ll_map: make local function static Stephen Hemminger
                   ` (19 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: Stephen Hemminger @ 2018-11-15 22:36 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

color_enable etc, only used here.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 include/color.h | 2 --
 lib/color.c     | 6 ++++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/color.h b/include/color.h
index e30f28c51c84..17ec56f3d7b4 100644
--- a/include/color.h
+++ b/include/color.h
@@ -20,10 +20,8 @@ enum color_opt {
 	COLOR_OPT_ALWAYS = 2
 };
 
-void enable_color(void);
 bool check_enable_color(int color, int json);
 bool matches_color(const char *arg, int *val);
-void set_color_palette(void);
 int color_fprintf(FILE *fp, enum color_attr attr, const char *fmt, ...);
 enum color_attr ifa_family_color(__u8 ifa_family);
 enum color_attr oper_state_color(__u8 state);
diff --git a/lib/color.c b/lib/color.c
index e5406294dfc4..59976847295c 100644
--- a/lib/color.c
+++ b/lib/color.c
@@ -11,6 +11,8 @@
 #include "color.h"
 #include "utils.h"
 
+static void set_color_palette(void);
+
 enum color {
 	C_RED,
 	C_GREEN,
@@ -73,7 +75,7 @@ static enum color attr_colors_dark[] = {
 static int is_dark_bg;
 static int color_is_enabled;
 
-void enable_color(void)
+static void enable_color(void)
 {
 	color_is_enabled = 1;
 	set_color_palette();
@@ -117,7 +119,7 @@ bool matches_color(const char *arg, int *val)
 	return true;
 }
 
-void set_color_palette(void)
+static void set_color_palette(void)
 {
 	char *p = getenv("COLORFGBG");
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH iproute2 04/22] lib/ll_map: make local function static
  2018-11-15 22:36 [PATCH iproute2 00/22] misc cleanups Stephen Hemminger
                   ` (2 preceding siblings ...)
  2018-11-15 22:36 ` [PATCH iproute2 03/22] lib/color: " Stephen Hemminger
@ 2018-11-15 22:36 ` Stephen Hemminger
  2018-11-15 22:36 ` [PATCH iproute2 05/22] libnetlnk: unused and local functions cleanup Stephen Hemminger
                   ` (18 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: Stephen Hemminger @ 2018-11-15 22:36 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

ll_idx_a2n is only used in ll_map.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 include/ll_map.h | 1 -
 lib/ll_map.c     | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/include/ll_map.h b/include/ll_map.h
index fb708191c22c..511fe00b8567 100644
--- a/include/ll_map.h
+++ b/include/ll_map.h
@@ -12,6 +12,5 @@ int ll_index_to_flags(unsigned idx);
 unsigned namehash(const char *str);
 
 const char *ll_idx_n2a(unsigned int idx);
-unsigned int ll_idx_a2n(const char *name);
 
 #endif /* __LL_MAP_H__ */
diff --git a/lib/ll_map.c b/lib/ll_map.c
index 1b4095a7d873..1ab8ef0758ac 100644
--- a/lib/ll_map.c
+++ b/lib/ll_map.c
@@ -143,7 +143,7 @@ const char *ll_idx_n2a(unsigned int idx)
 	return buf;
 }
 
-unsigned int ll_idx_a2n(const char *name)
+static unsigned int ll_idx_a2n(const char *name)
 {
 	unsigned int idx;
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH iproute2 05/22] libnetlnk: unused and local functions cleanup
  2018-11-15 22:36 [PATCH iproute2 00/22] misc cleanups Stephen Hemminger
                   ` (3 preceding siblings ...)
  2018-11-15 22:36 ` [PATCH iproute2 04/22] lib/ll_map: make local function static Stephen Hemminger
@ 2018-11-15 22:36 ` Stephen Hemminger
  2018-11-15 22:36 ` [PATCH iproute2 06/22] genl: remove dead code Stephen Hemminger
                   ` (17 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: Stephen Hemminger @ 2018-11-15 22:36 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

rntl_talk_extack and parse_rtattr_index not used in current code.
rtnl_dump_filter_l is only used in this file.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 include/libnetlink.h |  7 -------
 lib/libnetlink.c     | 28 ++--------------------------
 2 files changed, 2 insertions(+), 33 deletions(-)

diff --git a/include/libnetlink.h b/include/libnetlink.h
index fa8de093d484..138840d5c892 100644
--- a/include/libnetlink.h
+++ b/include/libnetlink.h
@@ -102,8 +102,6 @@ struct rtnl_dump_filter_arg {
 	__u16 nc_flags;
 };
 
-int rtnl_dump_filter_l(struct rtnl_handle *rth,
-			      const struct rtnl_dump_filter_arg *arg);
 int rtnl_dump_filter_nc(struct rtnl_handle *rth,
 			rtnl_filter_t filter,
 			void *arg, __u16 nc_flags);
@@ -115,9 +113,6 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n,
 int rtnl_talk_iov(struct rtnl_handle *rtnl, struct iovec *iovec, size_t iovlen,
 		  struct nlmsghdr **answer)
 	__attribute__((warn_unused_result));
-int rtnl_talk_extack(struct rtnl_handle *rtnl, struct nlmsghdr *n,
-	      struct nlmsghdr **answer, nl_ext_ack_fn_t errfn)
-	__attribute__((warn_unused_result));
 int rtnl_talk_suppress_rtnl_errmsg(struct rtnl_handle *rtnl, struct nlmsghdr *n,
 				   struct nlmsghdr **answer)
 	__attribute__((warn_unused_result));
@@ -152,8 +147,6 @@ int rta_addattr_l(struct rtattr *rta, int maxlen, int type,
 int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len);
 int parse_rtattr_flags(struct rtattr *tb[], int max, struct rtattr *rta,
 			      int len, unsigned short flags);
-int parse_rtattr_byindex(struct rtattr *tb[], int max,
-			 struct rtattr *rta, int len);
 struct rtattr *parse_rtattr_one(int type, struct rtattr *rta, int len);
 int __parse_rtattr_nested_compat(struct rtattr *tb[], int max, struct rtattr *rta, int len);
 
diff --git a/lib/libnetlink.c b/lib/libnetlink.c
index fe4a7a4b9c71..c0b80ed6fdfb 100644
--- a/lib/libnetlink.c
+++ b/lib/libnetlink.c
@@ -611,8 +611,8 @@ static int rtnl_recvmsg(int fd, struct msghdr *msg, char **answer)
 	return len;
 }
 
-int rtnl_dump_filter_l(struct rtnl_handle *rth,
-		       const struct rtnl_dump_filter_arg *arg)
+static int rtnl_dump_filter_l(struct rtnl_handle *rth,
+			      const struct rtnl_dump_filter_arg *arg)
 {
 	struct sockaddr_nl nladdr;
 	struct iovec iov;
@@ -877,13 +877,6 @@ int rtnl_talk_iov(struct rtnl_handle *rtnl, struct iovec *iovec, size_t iovlen,
 	return __rtnl_talk_iov(rtnl, iovec, iovlen, answer, true, NULL);
 }
 
-int rtnl_talk_extack(struct rtnl_handle *rtnl, struct nlmsghdr *n,
-		     struct nlmsghdr **answer,
-		     nl_ext_ack_fn_t errfn)
-{
-	return __rtnl_talk(rtnl, n, answer, true, errfn);
-}
-
 int rtnl_talk_suppress_rtnl_errmsg(struct rtnl_handle *rtnl, struct nlmsghdr *n,
 				   struct nlmsghdr **answer)
 {
@@ -1242,23 +1235,6 @@ int parse_rtattr_flags(struct rtattr *tb[], int max, struct rtattr *rta,
 	return 0;
 }
 
-int parse_rtattr_byindex(struct rtattr *tb[], int max,
-			 struct rtattr *rta, int len)
-{
-	int i = 0;
-
-	memset(tb, 0, sizeof(struct rtattr *) * max);
-	while (RTA_OK(rta, len)) {
-		if (rta->rta_type <= max && i < max)
-			tb[i++] = rta;
-		rta = RTA_NEXT(rta, len);
-	}
-	if (len)
-		fprintf(stderr, "!!!Deficit %d, rta_len=%d\n",
-			len, rta->rta_len);
-	return i;
-}
-
 struct rtattr *parse_rtattr_one(int type, struct rtattr *rta, int len)
 {
 	while (RTA_OK(rta, len)) {
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH iproute2 06/22] genl: remove dead code
  2018-11-15 22:36 [PATCH iproute2 00/22] misc cleanups Stephen Hemminger
                   ` (4 preceding siblings ...)
  2018-11-15 22:36 ` [PATCH iproute2 05/22] libnetlnk: unused and local functions cleanup Stephen Hemminger
@ 2018-11-15 22:36 ` Stephen Hemminger
  2018-11-15 22:36 ` [PATCH iproute2 07/22] bridge: make local variables static Stephen Hemminger
                   ` (16 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: Stephen Hemminger @ 2018-11-15 22:36 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

The function genl_ctrl_resolve_family is defined but never used
in current code.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 genl/ctrl.c       | 71 -----------------------------------------------
 genl/genl_utils.h |  2 --
 2 files changed, 73 deletions(-)

diff --git a/genl/ctrl.c b/genl/ctrl.c
index 6133336ab435..0fb464b01cfb 100644
--- a/genl/ctrl.c
+++ b/genl/ctrl.c
@@ -38,77 +38,6 @@ static int usage(void)
 	return -1;
 }
 
-int genl_ctrl_resolve_family(const char *family)
-{
-	struct rtnl_handle rth;
-	int ret = 0;
-	struct {
-		struct nlmsghdr         n;
-		struct genlmsghdr	g;
-		char                    buf[4096];
-	} req = {
-		.n.nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN),
-		.n.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK,
-		.n.nlmsg_type = GENL_ID_CTRL,
-		.g.cmd = CTRL_CMD_GETFAMILY,
-	};
-	struct nlmsghdr *nlh = &req.n;
-	struct genlmsghdr *ghdr = &req.g;
-	struct nlmsghdr *answer = NULL;
-
-	if (rtnl_open_byproto(&rth, 0, NETLINK_GENERIC) < 0) {
-		fprintf(stderr, "Cannot open generic netlink socket\n");
-		exit(1);
-	}
-
-	addattr_l(nlh, 128, CTRL_ATTR_FAMILY_NAME, family, strlen(family) + 1);
-
-	if (rtnl_talk(&rth, nlh, &answer) < 0) {
-		fprintf(stderr, "Error talking to the kernel\n");
-		goto errout;
-	}
-
-	{
-		struct rtattr *tb[CTRL_ATTR_MAX + 1];
-		int len = answer->nlmsg_len;
-		struct rtattr *attrs;
-
-		if (answer->nlmsg_type !=  GENL_ID_CTRL) {
-			fprintf(stderr, "Not a controller message, nlmsg_len=%d "
-				"nlmsg_type=0x%x\n", answer->nlmsg_len, answer->nlmsg_type);
-			goto errout;
-		}
-
-		if (ghdr->cmd != CTRL_CMD_NEWFAMILY) {
-			fprintf(stderr, "Unknown controller command %d\n", ghdr->cmd);
-			goto errout;
-		}
-
-		len -= NLMSG_LENGTH(GENL_HDRLEN);
-
-		if (len < 0) {
-			fprintf(stderr, "wrong controller message len %d\n", len);
-			free(answer);
-			return -1;
-		}
-
-		attrs = (struct rtattr *) ((char *) answer + NLMSG_LENGTH(GENL_HDRLEN));
-		parse_rtattr(tb, CTRL_ATTR_MAX, attrs, len);
-
-		if (tb[CTRL_ATTR_FAMILY_ID] == NULL) {
-			fprintf(stderr, "Missing family id TLV\n");
-			goto errout;
-		}
-
-		ret = rta_getattr_u16(tb[CTRL_ATTR_FAMILY_ID]);
-	}
-
-errout:
-	free(answer);
-	rtnl_close(&rth);
-	return ret;
-}
-
 static void print_ctrl_cmd_flags(FILE *fp, __u32 fl)
 {
 	fprintf(fp, "\n\t\tCapabilities (0x%x):\n ", fl);
diff --git a/genl/genl_utils.h b/genl/genl_utils.h
index cc1f3fb76596..a8d433a9574f 100644
--- a/genl/genl_utils.h
+++ b/genl/genl_utils.h
@@ -13,6 +13,4 @@ struct genl_util
 	int	(*print_genlopt)(struct nlmsghdr *n, void *arg);
 };
 
-int genl_ctrl_resolve_family(const char *family);
-
 #endif
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH iproute2 07/22] bridge: make local variables static
  2018-11-15 22:36 [PATCH iproute2 00/22] misc cleanups Stephen Hemminger
                   ` (5 preceding siblings ...)
  2018-11-15 22:36 ` [PATCH iproute2 06/22] genl: remove dead code Stephen Hemminger
@ 2018-11-15 22:36 ` Stephen Hemminger
  2018-11-15 22:36 ` [PATCH iproute2 08/22] ip: make flag names const/static Stephen Hemminger
                   ` (15 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: Stephen Hemminger @ 2018-11-15 22:36 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

enable_color and set_color_palette only used here.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 bridge/bridge.c  | 5 ++---
 bridge/monitor.c | 2 +-
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/bridge/bridge.c b/bridge/bridge.c
index ac4d6a14f510..389f1bd5382b 100644
--- a/bridge/bridge.c
+++ b/bridge/bridge.c
@@ -23,12 +23,11 @@ int preferred_family = AF_UNSPEC;
 int oneline;
 int show_stats;
 int show_details;
-int show_pretty;
-int color;
+static int color;
 int compress_vlans;
 int json;
 int timestamp;
-char *batch_file;
+static const char *batch_file;
 int force;
 
 static void usage(void) __attribute__((noreturn));
diff --git a/bridge/monitor.c b/bridge/monitor.c
index 82bc6b407a06..708a1bd2ccb0 100644
--- a/bridge/monitor.c
+++ b/bridge/monitor.c
@@ -27,7 +27,7 @@
 
 
 static void usage(void) __attribute__((noreturn));
-int prefix_banner;
+static int prefix_banner;
 
 static void usage(void)
 {
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH iproute2 08/22] ip: make flag names const/static
  2018-11-15 22:36 [PATCH iproute2 00/22] misc cleanups Stephen Hemminger
                   ` (6 preceding siblings ...)
  2018-11-15 22:36 ` [PATCH iproute2 07/22] bridge: make local variables static Stephen Hemminger
@ 2018-11-15 22:36 ` Stephen Hemminger
  2018-11-15 22:36 ` [PATCH iproute2 09/22] ipmonitor: make local variable static Stephen Hemminger
                   ` (14 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: Stephen Hemminger @ 2018-11-15 22:36 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

The table of filter flags is only used in ipaddress

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 ip/ipaddress.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index cd8cc76a3473..2671c4e162e3 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -1149,7 +1149,7 @@ static unsigned int get_ifa_flags(struct ifaddrmsg *ifa,
 }
 
 /* Mapping from argument to address flag mask */
-struct {
+static const struct {
 	const char *name;
 	unsigned long value;
 } ifa_flag_names[] = {
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH iproute2 09/22] ipmonitor: make local variable static
  2018-11-15 22:36 [PATCH iproute2 00/22] misc cleanups Stephen Hemminger
                   ` (7 preceding siblings ...)
  2018-11-15 22:36 ` [PATCH iproute2 08/22] ip: make flag names const/static Stephen Hemminger
@ 2018-11-15 22:36 ` Stephen Hemminger
  2018-11-15 22:36 ` [PATCH iproute2 10/22] ipxfrm: make local functions static Stephen Hemminger
                   ` (13 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: Stephen Hemminger @ 2018-11-15 22:36 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

prefix_banner only used in one file.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 ip/ipmonitor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ip/ipmonitor.c b/ip/ipmonitor.c
index 9d5ac2b5e4d2..743632cc5569 100644
--- a/ip/ipmonitor.c
+++ b/ip/ipmonitor.c
@@ -24,7 +24,7 @@
 #include "ip_common.h"
 
 static void usage(void) __attribute__((noreturn));
-int prefix_banner;
+static int prefix_banner;
 int listen_all_nsid;
 
 static void usage(void)
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH iproute2 10/22] ipxfrm: make local functions static
  2018-11-15 22:36 [PATCH iproute2 00/22] misc cleanups Stephen Hemminger
                   ` (8 preceding siblings ...)
  2018-11-15 22:36 ` [PATCH iproute2 09/22] ipmonitor: make local variable static Stephen Hemminger
@ 2018-11-15 22:36 ` Stephen Hemminger
  2018-11-15 22:36 ` [PATCH iproute2 11/22] tc: drop unused name_to_id function Stephen Hemminger
                   ` (12 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: Stephen Hemminger @ 2018-11-15 22:36 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

Make functions only used in ipxfrm.c static.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 ip/ipxfrm.c       | 11 ++++++-----
 ip/xfrm.h         |  9 ---------
 ip/xfrm_monitor.c |  2 +-
 3 files changed, 7 insertions(+), 15 deletions(-)

diff --git a/ip/ipxfrm.c b/ip/ipxfrm.c
index 17ab4abef4be..2dea4e37f209 100644
--- a/ip/ipxfrm.c
+++ b/ip/ipxfrm.c
@@ -186,7 +186,7 @@ const char *strxf_algotype(int type)
 	return str;
 }
 
-const char *strxf_mask8(__u8 mask)
+static const char *strxf_mask8(__u8 mask)
 {
 	static char str[16];
 	const int sn = sizeof(mask) * 8 - 1;
@@ -209,7 +209,7 @@ const char *strxf_mask32(__u32 mask)
 	return str;
 }
 
-const char *strxf_share(__u8 share)
+static const char *strxf_share(__u8 share)
 {
 	static char str[32];
 
@@ -270,7 +270,7 @@ const char *strxf_ptype(__u8 ptype)
 	return str;
 }
 
-void xfrm_id_info_print(xfrm_address_t *saddr, struct xfrm_id *id,
+static void xfrm_id_info_print(xfrm_address_t *saddr, struct xfrm_id *id,
 			__u8 mode, __u32 reqid, __u16 family, int force_spi,
 			FILE *fp, const char *prefix, const char *title)
 {
@@ -337,7 +337,8 @@ static const char *strxf_limit(__u64 limit)
 	return str;
 }
 
-void xfrm_stats_print(struct xfrm_stats *s, FILE *fp, const char *prefix)
+static void xfrm_stats_print(struct xfrm_stats *s, FILE *fp,
+			     const char *prefix)
 {
 	if (prefix)
 		fputs(prefix, fp);
@@ -371,7 +372,7 @@ static const char *strxf_time(__u64 time)
 	return str;
 }
 
-void xfrm_lifetime_print(struct xfrm_lifetime_cfg *cfg,
+static void xfrm_lifetime_print(struct xfrm_lifetime_cfg *cfg,
 			 struct xfrm_lifetime_cur *cur,
 			 FILE *fp, const char *prefix)
 {
diff --git a/ip/xfrm.h b/ip/xfrm.h
index 3b158ad71c13..72390d79cfb5 100644
--- a/ip/xfrm.h
+++ b/ip/xfrm.h
@@ -118,18 +118,9 @@ int xfrm_algotype_getbyname(char *name);
 int xfrm_parse_mark(struct xfrm_mark *mark, int *argcp, char ***argvp);
 const char *strxf_xfrmproto(__u8 proto);
 const char *strxf_algotype(int type);
-const char *strxf_mask8(__u8 mask);
 const char *strxf_mask32(__u32 mask);
-const char *strxf_share(__u8 share);
 const char *strxf_proto(__u8 proto);
 const char *strxf_ptype(__u8 ptype);
-void xfrm_id_info_print(xfrm_address_t *saddr, struct xfrm_id *id,
-			__u8 mode, __u32 reqid, __u16 family, int force_spi,
-			FILE *fp, const char *prefix, const char *title);
-void xfrm_stats_print(struct xfrm_stats *s, FILE *fp, const char *prefix);
-void xfrm_lifetime_print(struct xfrm_lifetime_cfg *cfg,
-			 struct xfrm_lifetime_cur *cur,
-			 FILE *fp, const char *prefix);
 void xfrm_selector_print(struct xfrm_selector *sel, __u16 family,
 			 FILE *fp, const char *prefix);
 void xfrm_xfrma_print(struct rtattr *tb[], __u16 family,
diff --git a/ip/xfrm_monitor.c b/ip/xfrm_monitor.c
index eb07af17cadf..76905ed3f1e1 100644
--- a/ip/xfrm_monitor.c
+++ b/ip/xfrm_monitor.c
@@ -34,7 +34,7 @@
 #include "ip_common.h"
 
 static void usage(void) __attribute__((noreturn));
-int listen_all_nsid;
+static int listen_all_nsid;
 
 static void usage(void)
 {
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH iproute2 11/22] tc: drop unused name_to_id function
  2018-11-15 22:36 [PATCH iproute2 00/22] misc cleanups Stephen Hemminger
                   ` (9 preceding siblings ...)
  2018-11-15 22:36 ` [PATCH iproute2 10/22] ipxfrm: make local functions static Stephen Hemminger
@ 2018-11-15 22:36 ` Stephen Hemminger
  2018-11-15 22:36 ` [PATCH iproute2 12/22] tipc: make cmd_find static Stephen Hemminger
                   ` (11 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: Stephen Hemminger @ 2018-11-15 22:36 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

Not used in current code.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 include/names.h |  1 -
 lib/names.c     | 28 ----------------------------
 2 files changed, 29 deletions(-)

diff --git a/include/names.h b/include/names.h
index 3e5d3b146a23..2fcaacc398d4 100644
--- a/include/names.h
+++ b/include/names.h
@@ -22,6 +22,5 @@ int db_names_load(struct db_names *db, const char *path);
 void db_names_free(struct db_names *db);
 
 char *id_to_name(struct db_names *db, int id, char *name);
-int name_to_id(struct db_names *db, int *id, const char *name);
 
 #endif
diff --git a/lib/names.c b/lib/names.c
index fbd6503f22d4..b46ea7910946 100644
--- a/lib/names.c
+++ b/lib/names.c
@@ -150,31 +150,3 @@ char *id_to_name(struct db_names *db, int id, char *name)
 	snprintf(name, IDNAME_MAX, "%d", id);
 	return NULL;
 }
-
-int name_to_id(struct db_names *db, int *id, const char *name)
-{
-	struct db_entry *entry;
-	int i;
-
-	if (!db)
-		return -1;
-
-	if (db->cached && strcmp(db->cached->name, name) == 0) {
-		*id = db->cached->id;
-		return 0;
-	}
-
-	for (i = 0; i < db->size; i++) {
-		entry = db->hash[i];
-		while (entry && strcmp(entry->name, name))
-			entry = entry->next;
-
-		if (entry) {
-			db->cached = entry;
-			*id = entry->id;
-			return 0;
-		}
-	}
-
-	return -1;
-}
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH iproute2 12/22] tipc: make cmd_find static
  2018-11-15 22:36 [PATCH iproute2 00/22] misc cleanups Stephen Hemminger
                   ` (10 preceding siblings ...)
  2018-11-15 22:36 ` [PATCH iproute2 11/22] tc: drop unused name_to_id function Stephen Hemminger
@ 2018-11-15 22:36 ` Stephen Hemminger
  2018-11-15 22:36 ` [PATCH iproute2 13/22] tc/class: make filter variables static Stephen Hemminger
                   ` (10 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: Stephen Hemminger @ 2018-11-15 22:36 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

Function only used in one file.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 tipc/cmdl.c | 2 +-
 tipc/cmdl.h | 2 --
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/tipc/cmdl.c b/tipc/cmdl.c
index 4a2f4fd92f48..f2f259cc5320 100644
--- a/tipc/cmdl.c
+++ b/tipc/cmdl.c
@@ -17,7 +17,7 @@
 
 #include "cmdl.h"
 
-const struct cmd *find_cmd(const struct cmd *cmds, char *str)
+static const struct cmd *find_cmd(const struct cmd *cmds, char *str)
 {
 	const struct cmd *c;
 	const struct cmd *match = NULL;
diff --git a/tipc/cmdl.h b/tipc/cmdl.h
index d37239f85690..03db359956e6 100644
--- a/tipc/cmdl.h
+++ b/tipc/cmdl.h
@@ -54,6 +54,4 @@ char *shift_cmdl(struct cmdl *cmdl);
 int run_cmd(struct nlmsghdr *nlh, const struct cmd *caller,
 	    const struct cmd *cmds, struct cmdl *cmdl, void *data);
 
-const struct cmd *find_cmd(const struct cmd *cmds, char *str);
-
 #endif
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH iproute2 13/22] tc/class: make filter variables static
  2018-11-15 22:36 [PATCH iproute2 00/22] misc cleanups Stephen Hemminger
                   ` (11 preceding siblings ...)
  2018-11-15 22:36 ` [PATCH iproute2 12/22] tipc: make cmd_find static Stephen Hemminger
@ 2018-11-15 22:36 ` Stephen Hemminger
  2018-11-15 22:36 ` [PATCH iproute2 14/22] tc/police: make print_police static Stephen Hemminger
                   ` (9 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: Stephen Hemminger @ 2018-11-15 22:36 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

Only used in this file.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 tc/tc_class.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tc/tc_class.c b/tc/tc_class.c
index 7e4e17fd7f39..7ac700d7ab31 100644
--- a/tc/tc_class.c
+++ b/tc/tc_class.c
@@ -153,9 +153,9 @@ static int tc_class_modify(int cmd, unsigned int flags, int argc, char **argv)
 	return 0;
 }
 
-int filter_ifindex;
-__u32 filter_qdisc;
-__u32 filter_classid;
+static int filter_ifindex;
+static __u32 filter_qdisc;
+static __u32 filter_classid;
 
 static void graph_node_add(__u32 parent_id, __u32 id, void *data,
 		int len)
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH iproute2 14/22] tc/police: make print_police static
  2018-11-15 22:36 [PATCH iproute2 00/22] misc cleanups Stephen Hemminger
                   ` (12 preceding siblings ...)
  2018-11-15 22:36 ` [PATCH iproute2 13/22] tc/class: make filter variables static Stephen Hemminger
@ 2018-11-15 22:36 ` Stephen Hemminger
  2018-11-15 22:36 ` [PATCH iproute2 15/22] ss: make local variables static Stephen Hemminger
                   ` (8 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: Stephen Hemminger @ 2018-11-15 22:36 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

print_police function only used by m_police.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 tc/m_police.c | 10 +++++++---
 tc/tc_util.h  |  3 ---
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/tc/m_police.c b/tc/m_police.c
index f3b07f7b0439..d645999ba08b 100644
--- a/tc/m_police.c
+++ b/tc/m_police.c
@@ -25,6 +25,10 @@
 #include "utils.h"
 #include "tc_util.h"
 
+static int act_parse_police(struct action_util *a, int *argc_p,
+			    char ***argv_p, int tca_id, struct nlmsghdr *n);
+static int print_police(struct action_util *a, FILE *f, struct rtattr *tb);
+
 struct action_util police_action_util = {
 	.id = "police",
 	.parse_aopt = act_parse_police,
@@ -50,8 +54,8 @@ static void explain1(char *arg)
 	fprintf(stderr, "Illegal \"%s\"\n", arg);
 }
 
-int act_parse_police(struct action_util *a, int *argc_p, char ***argv_p,
-		     int tca_id, struct nlmsghdr *n)
+static int act_parse_police(struct action_util *a, int *argc_p, char ***argv_p,
+			    int tca_id, struct nlmsghdr *n)
 {
 	int argc = *argc_p;
 	char **argv = *argv_p;
@@ -256,7 +260,7 @@ int parse_police(int *argc_p, char ***argv_p, int tca_id, struct nlmsghdr *n)
 	return act_parse_police(NULL, argc_p, argv_p, tca_id, n);
 }
 
-int print_police(struct action_util *a, FILE *f, struct rtattr *arg)
+static int print_police(struct action_util *a, FILE *f, struct rtattr *arg)
 {
 	SPRINT_BUF(b1);
 	SPRINT_BUF(b2);
diff --git a/tc/tc_util.h b/tc/tc_util.h
index 76fd986d6e4c..e22c6da25696 100644
--- a/tc/tc_util.h
+++ b/tc/tc_util.h
@@ -117,9 +117,6 @@ int parse_action_control_slash(int *argc_p, char ***argv_p,
 			       int *result1_p, int *result2_p, bool allow_num);
 void print_action_control(FILE *f, const char *prefix,
 			  int action, const char *suffix);
-int act_parse_police(struct action_util *a, int *argc_p,
-		     char ***argv_p, int tca_id, struct nlmsghdr *n);
-int print_police(struct action_util *a, FILE *f, struct rtattr *tb);
 int police_print_xstats(struct action_util *a, FILE *f, struct rtattr *tb);
 int tc_print_action(FILE *f, const struct rtattr *tb, unsigned short tot_acts);
 int tc_print_ipt(FILE *f, const struct rtattr *tb);
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH iproute2 15/22] ss: make local variables static
  2018-11-15 22:36 [PATCH iproute2 00/22] misc cleanups Stephen Hemminger
                   ` (13 preceding siblings ...)
  2018-11-15 22:36 ` [PATCH iproute2 14/22] tc/police: make print_police static Stephen Hemminger
@ 2018-11-15 22:36 ` Stephen Hemminger
  2018-11-15 22:36 ` [PATCH iproute2 16/22] tc/pedit: make functions static Stephen Hemminger
                   ` (7 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: Stephen Hemminger @ 2018-11-15 22:36 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

Several variables only used in this code.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 misc/ss.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/misc/ss.c b/misc/ss.c
index 4d12fb5d19df..e4d6ae489e79 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -96,20 +96,20 @@ static int security_get_initial_context(char *name,  char **context)
 }
 #endif
 
-int resolve_services = 1;
+static int resolve_services = 1;
 int preferred_family = AF_UNSPEC;
-int show_options;
+static int show_options;
 int show_details;
-int show_users;
-int show_mem;
-int show_tcpinfo;
-int show_bpf;
-int show_proc_ctx;
-int show_sock_ctx;
-int show_header = 1;
-int follow_events;
-int sctp_ino;
-int show_tipcinfo;
+static int show_users;
+static int show_mem;
+static int show_tcpinfo;
+static int show_bpf;
+static int show_proc_ctx;
+static int show_sock_ctx;
+static int show_header = 1;
+static int follow_events;
+static int sctp_ino;
+static int show_tipcinfo;
 
 enum col_id {
 	COL_NETID,
@@ -494,7 +494,7 @@ struct user_ent {
 };
 
 #define USER_ENT_HASH_SIZE	256
-struct user_ent *user_ent_hash[USER_ENT_HASH_SIZE];
+static struct user_ent *user_ent_hash[USER_ENT_HASH_SIZE];
 
 static int user_ent_hashfn(unsigned int ino)
 {
@@ -1404,7 +1404,7 @@ struct scache {
 	const char *proto;
 };
 
-struct scache *rlist;
+static struct scache *rlist;
 
 static void init_service_resolver(void)
 {
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH iproute2 16/22] tc/pedit: make functions static
  2018-11-15 22:36 [PATCH iproute2 00/22] misc cleanups Stephen Hemminger
                   ` (14 preceding siblings ...)
  2018-11-15 22:36 ` [PATCH iproute2 15/22] ss: make local variables static Stephen Hemminger
@ 2018-11-15 22:36 ` Stephen Hemminger
  2018-11-15 22:36 ` [PATCH iproute2 17/22] tc/ematch: make local " Stephen Hemminger
                   ` (6 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: Stephen Hemminger @ 2018-11-15 22:36 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

The parse and pack functions are only used by the pedit routines.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 tc/m_pedit.c | 33 ++++++++++++++-------------------
 tc/m_pedit.h | 15 ---------------
 2 files changed, 14 insertions(+), 34 deletions(-)

diff --git a/tc/m_pedit.c b/tc/m_pedit.c
index 2aeb56d9615f..6f8d078b7d3c 100644
--- a/tc/m_pedit.c
+++ b/tc/m_pedit.c
@@ -118,7 +118,7 @@ noexist:
 	return p;
 }
 
-int pack_key(struct m_pedit_sel *_sel, struct m_pedit_key *tkey)
+static int pack_key(struct m_pedit_sel *_sel, struct m_pedit_key *tkey)
 {
 	struct tc_pedit_sel *sel = &_sel->sel;
 	struct m_pedit_key_ex *keys_ex = _sel->keys_ex;
@@ -155,8 +155,8 @@ int pack_key(struct m_pedit_sel *_sel, struct m_pedit_key *tkey)
 	return 0;
 }
 
-int pack_key32(__u32 retain, struct m_pedit_sel *sel,
-	       struct m_pedit_key *tkey)
+static int pack_key32(__u32 retain, struct m_pedit_sel *sel,
+		      struct m_pedit_key *tkey)
 {
 	if (tkey->off > (tkey->off & ~3)) {
 		fprintf(stderr,
@@ -169,8 +169,8 @@ int pack_key32(__u32 retain, struct m_pedit_sel *sel,
 	return pack_key(sel, tkey);
 }
 
-int pack_key16(__u32 retain, struct m_pedit_sel *sel,
-	       struct m_pedit_key *tkey)
+static int pack_key16(__u32 retain, struct m_pedit_sel *sel,
+		      struct m_pedit_key *tkey)
 {
 	int ind, stride;
 	__u32 m[4] = { 0x0000FFFF, 0xFF0000FF, 0xFFFF0000 };
@@ -197,10 +197,10 @@ int pack_key16(__u32 retain, struct m_pedit_sel *sel,
 		printf("pack_key16: Final val %08x mask %08x\n",
 		       tkey->val, tkey->mask);
 	return pack_key(sel, tkey);
-
 }
 
-int pack_key8(__u32 retain, struct m_pedit_sel *sel, struct m_pedit_key *tkey)
+static int pack_key8(__u32 retain, struct m_pedit_sel *sel,
+		     struct m_pedit_key *tkey)
 {
 	int ind, stride;
 	__u32 m[4] = { 0x00FFFFFF, 0xFF00FFFF, 0xFFFF00FF, 0xFFFFFF00 };
@@ -283,7 +283,7 @@ static int pack_ipv6(struct m_pedit_sel *sel, struct m_pedit_key *tkey,
 	return 0;
 }
 
-int parse_val(int *argc_p, char ***argv_p, __u32 *val, int type)
+static int parse_val(int *argc_p, char ***argv_p, __u32 *val, int type)
 {
 	int argc = *argc_p;
 	char **argv = *argv_p;
@@ -433,8 +433,8 @@ done:
 
 }
 
-int parse_offset(int *argc_p, char ***argv_p, struct m_pedit_sel *sel,
-		 struct m_pedit_key *tkey)
+static int parse_offset(int *argc_p, char ***argv_p, struct m_pedit_sel *sel,
+			struct m_pedit_key *tkey)
 {
 	int off;
 	__u32 len, retain;
@@ -612,8 +612,8 @@ static int pedit_keys_ex_addattr(struct m_pedit_sel *sel, struct nlmsghdr *n)
 	return 0;
 }
 
-int parse_pedit(struct action_util *a, int *argc_p, char ***argv_p, int tca_id,
-		struct nlmsghdr *n)
+static int parse_pedit(struct action_util *a, int *argc_p, char ***argv_p,
+		       int tca_id, struct nlmsghdr *n)
 {
 	struct m_pedit_sel sel = {};
 
@@ -705,7 +705,7 @@ int parse_pedit(struct action_util *a, int *argc_p, char ***argv_p, int tca_id,
 	return 0;
 }
 
-const char *pedit_htype_str[] = {
+static const char * const pedit_htype_str[] = {
 	[TCA_PEDIT_KEY_EX_HDR_TYPE_NETWORK] = "",
 	[TCA_PEDIT_KEY_EX_HDR_TYPE_ETH] = "eth",
 	[TCA_PEDIT_KEY_EX_HDR_TYPE_IP4] = "ipv4",
@@ -730,7 +730,7 @@ static void print_pedit_location(FILE *f,
 	fprintf(f, "%c%d", (int)off  >= 0 ? '+' : '-', abs((int)off));
 }
 
-int print_pedit(struct action_util *au, FILE *f, struct rtattr *arg)
+static int print_pedit(struct action_util *au, FILE *f, struct rtattr *arg)
 {
 	struct tc_pedit_sel *sel;
 	struct rtattr *tb[TCA_PEDIT_MAX + 1];
@@ -826,11 +826,6 @@ int print_pedit(struct action_util *au, FILE *f, struct rtattr *arg)
 	return 0;
 }
 
-int pedit_print_xstats(struct action_util *au, FILE *f, struct rtattr *xstats)
-{
-	return 0;
-}
-
 struct action_util pedit_action_util = {
 	.id = "pedit",
 	.parse_aopt = parse_pedit,
diff --git a/tc/m_pedit.h b/tc/m_pedit.h
index b6b274bd08c7..5d3628a70b99 100644
--- a/tc/m_pedit.h
+++ b/tc/m_pedit.h
@@ -71,22 +71,7 @@ struct m_pedit_util {
 			       struct m_pedit_key *tkey);
 };
 
-int pack_key(struct m_pedit_sel *sel, struct m_pedit_key *tkey);
-int pack_key32(__u32 retain, struct m_pedit_sel *sel,
-	       struct m_pedit_key *tkey);
-int pack_key16(__u32 retain, struct m_pedit_sel *sel,
-	       struct m_pedit_key *tkey);
-int pack_key8(__u32 retain, struct m_pedit_sel *sel,
-		     struct m_pedit_key *tkey);
-int parse_val(int *argc_p, char ***argv_p, __u32 *val, int type);
 int parse_cmd(int *argc_p, char ***argv_p, __u32 len, int type,
 	      __u32 retain,
 	      struct m_pedit_sel *sel, struct m_pedit_key *tkey);
-int parse_offset(int *argc_p, char ***argv_p,
-		 struct m_pedit_sel *sel, struct m_pedit_key *tkey);
-int parse_pedit(struct action_util *a, int *argc_p, char ***argv_p,
-		int tca_id, struct nlmsghdr *n);
-int print_pedit(struct action_util *au, FILE *f, struct rtattr *arg);
-int pedit_print_xstats(struct action_util *au, FILE *f,
-		       struct rtattr *xstats);
 #endif
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH iproute2 17/22] tc/ematch: make local functions static
  2018-11-15 22:36 [PATCH iproute2 00/22] misc cleanups Stephen Hemminger
                   ` (15 preceding siblings ...)
  2018-11-15 22:36 ` [PATCH iproute2 16/22] tc/pedit: make functions static Stephen Hemminger
@ 2018-11-15 22:36 ` Stephen Hemminger
  2018-11-15 22:36 ` [PATCH iproute2 18/22] tc/util: " Stephen Hemminger
                   ` (5 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: Stephen Hemminger @ 2018-11-15 22:36 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

The print handling is only used in tc/m_ematch.c

Remove unused function to print_ematch_tree.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 tc/m_ematch.c | 30 +++---------------------------
 tc/m_ematch.h |  1 -
 2 files changed, 3 insertions(+), 28 deletions(-)

diff --git a/tc/m_ematch.c b/tc/m_ematch.c
index a524b520b276..8840a0dc62a1 100644
--- a/tc/m_ematch.c
+++ b/tc/m_ematch.c
@@ -38,6 +38,8 @@ struct ematch *ematch_root;
 static int begin_argc;
 static char **begin_argv;
 
+static void bstr_print(FILE *fd, const struct bstr *b, int ascii);
+
 static inline void map_warning(int num, char *kind)
 {
 	fprintf(stderr,
@@ -548,7 +550,7 @@ unsigned long bstrtoul(const struct bstr *b)
 	return l;
 }
 
-void bstr_print(FILE *fd, const struct bstr *b, int ascii)
+static void bstr_print(FILE *fd, const struct bstr *b, int ascii)
 {
 	int i;
 	char *s = b->data;
@@ -565,29 +567,3 @@ void bstr_print(FILE *fd, const struct bstr *b, int ascii)
 		fprintf(fd, "\"");
 	}
 }
-
-void print_ematch_tree(const struct ematch *tree)
-{
-	const struct ematch *t;
-
-	for (t = tree; t; t = t->next) {
-		if (t->inverted)
-			printf("NOT ");
-
-		if (t->child) {
-			printf("(");
-			print_ematch_tree(t->child);
-			printf(")");
-		} else {
-			struct bstr *b;
-
-			for (b = t->args; b; b = b->next)
-				printf("%s%s", b->data, b->next ? " " : "");
-		}
-
-		if (t->relation == TCF_EM_REL_AND)
-			printf(" AND ");
-		else if (t->relation == TCF_EM_REL_OR)
-			printf(" OR ");
-	}
-}
diff --git a/tc/m_ematch.h b/tc/m_ematch.h
index 356f2eded7fc..c4443ee22942 100644
--- a/tc/m_ematch.h
+++ b/tc/m_ematch.h
@@ -51,7 +51,6 @@ static inline struct bstr *bstr_next(struct bstr *b)
 }
 
 unsigned long bstrtoul(const struct bstr *b);
-void bstr_print(FILE *fd, const struct bstr *b, int ascii);
 
 struct ematch {
 	struct bstr	*args;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH iproute2 18/22] tc/util: make local functions static
  2018-11-15 22:36 [PATCH iproute2 00/22] misc cleanups Stephen Hemminger
                   ` (16 preceding siblings ...)
  2018-11-15 22:36 ` [PATCH iproute2 17/22] tc/ematch: make local " Stephen Hemminger
@ 2018-11-15 22:36 ` Stephen Hemminger
  2018-11-15 22:36 ` [PATCH iproute2 19/22] tc/meta: make meta_table static and const Stephen Hemminger
                   ` (4 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: Stephen Hemminger @ 2018-11-15 22:36 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

The tc util library parse/print has functions only used locally
(and some dead code removed).

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 tc/tc_util.c | 17 +++--------------
 tc/tc_util.h |  5 -----
 2 files changed, 3 insertions(+), 19 deletions(-)

diff --git a/tc/tc_util.c b/tc/tc_util.c
index a082c73c9350..82856a85170b 100644
--- a/tc/tc_util.c
+++ b/tc/tc_util.c
@@ -190,7 +190,7 @@ static const struct rate_suffix {
 	{ NULL }
 };
 
-int parse_percent_rate(char *rate, const char *str, const char *dev)
+static int parse_percent_rate(char *rate, const char *str, const char *dev)
 {
 	long dev_mbit;
 	int ret;
@@ -409,7 +409,7 @@ void print_devname(enum output_type type, int ifindex)
 			   "dev", "%s ", ifname);
 }
 
-void print_size(char *buf, int len, __u32 sz)
+static void print_size(char *buf, int len, __u32 sz)
 {
 	double tmp = sz;
 
@@ -427,17 +427,6 @@ char *sprint_size(__u32 size, char *buf)
 	return buf;
 }
 
-void print_qdisc_handle(char *buf, int len, __u32 h)
-{
-	snprintf(buf, len, "%x:", TC_H_MAJ(h)>>16);
-}
-
-char *sprint_qdisc_handle(__u32 h, char *buf)
-{
-	print_qdisc_handle(buf, SPRINT_BSIZE-1, h);
-	return buf;
-}
-
 static const char *action_n2a(int action)
 {
 	static char buf[64];
@@ -709,7 +698,7 @@ int get_linklayer(unsigned int *val, const char *arg)
 	return 0;
 }
 
-void print_linklayer(char *buf, int len, unsigned int linklayer)
+static void print_linklayer(char *buf, int len, unsigned int linklayer)
 {
 	switch (linklayer) {
 	case LINKLAYER_UNSPEC:
diff --git a/tc/tc_util.h b/tc/tc_util.h
index e22c6da25696..825fea36a080 100644
--- a/tc/tc_util.h
+++ b/tc/tc_util.h
@@ -73,7 +73,6 @@ const char *get_tc_lib(void);
 struct qdisc_util *get_qdisc_kind(const char *str);
 struct filter_util *get_filter_kind(const char *str);
 
-int parse_percent_rate(char *rate, const char *str, const char *dev);
 int get_qdisc_handle(__u32 *h, const char *str);
 int get_rate(unsigned int *rate, const char *str);
 int get_percent_rate(unsigned int *rate, const char *str, const char *dev);
@@ -84,14 +83,10 @@ int get_size_and_cell(unsigned int *size, int *cell_log, char *str);
 int get_linklayer(unsigned int *val, const char *arg);
 
 void print_rate(char *buf, int len, __u64 rate);
-void print_size(char *buf, int len, __u32 size);
-void print_qdisc_handle(char *buf, int len, __u32 h);
-void print_linklayer(char *buf, int len, unsigned int linklayer);
 void print_devname(enum output_type type, int ifindex);
 
 char *sprint_rate(__u64 rate, char *buf);
 char *sprint_size(__u32 size, char *buf);
-char *sprint_qdisc_handle(__u32 h, char *buf);
 char *sprint_tc_classid(__u32 h, char *buf);
 char *sprint_ticks(__u32 ticks, char *buf);
 char *sprint_linklayer(unsigned int linklayer, char *buf);
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH iproute2 19/22] tc/meta: make meta_table static and const
  2018-11-15 22:36 [PATCH iproute2 00/22] misc cleanups Stephen Hemminger
                   ` (17 preceding siblings ...)
  2018-11-15 22:36 ` [PATCH iproute2 18/22] tc/util: " Stephen Hemminger
@ 2018-11-15 22:36 ` Stephen Hemminger
  2018-11-15 22:36 ` [PATCH iproute2 20/22] tc/action: make variables static Stephen Hemminger
                   ` (3 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: Stephen Hemminger @ 2018-11-15 22:36 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

The mapping table is only used by em_meta.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 tc/em_meta.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tc/em_meta.c b/tc/em_meta.c
index d94fe88d9b2f..2ddc65ed6cb6 100644
--- a/tc/em_meta.c
+++ b/tc/em_meta.c
@@ -38,7 +38,7 @@ static void meta_print_usage(FILE *fd)
 	    "For a list of meta identifiers, use meta(list).\n");
 }
 
-struct meta_entry {
+static const struct meta_entry {
 	int		id;
 	char *kind;
 	char *mask;
@@ -121,7 +121,7 @@ static inline int map_type(char k)
 	return INT_MAX;
 }
 
-static struct meta_entry *lookup_meta_entry(struct bstr *kind)
+static const struct meta_entry *lookup_meta_entry(struct bstr *kind)
 {
 	int i;
 
@@ -133,7 +133,7 @@ static struct meta_entry *lookup_meta_entry(struct bstr *kind)
 	return NULL;
 }
 
-static struct meta_entry *lookup_meta_entry_byid(int id)
+static const struct meta_entry *lookup_meta_entry_byid(int id)
 {
 	int i;
 
@@ -168,8 +168,8 @@ static inline void dump_value(struct nlmsghdr *n, int tlv, unsigned long val,
 static inline int is_compatible(struct tcf_meta_val *what,
 				struct tcf_meta_val *needed)
 {
+	const struct meta_entry *entry;
 	char *p;
-	struct meta_entry *entry;
 
 	entry = lookup_meta_entry_byid(TCF_META_ID(what->kind));
 
@@ -249,7 +249,7 @@ static inline struct bstr *
 parse_object(struct bstr *args, struct bstr *arg, struct tcf_meta_val *obj,
 	     unsigned long *dst, struct tcf_meta_val *left)
 {
-	struct meta_entry *entry;
+	const struct meta_entry *entry;
 	unsigned long num;
 	struct bstr *a;
 
@@ -461,7 +461,7 @@ static int print_object(FILE *fd, struct tcf_meta_val *obj, struct rtattr *rta)
 {
 	int id = TCF_META_ID(obj->kind);
 	int type = TCF_META_TYPE(obj->kind);
-	struct meta_entry *entry;
+	const struct meta_entry *entry;
 
 	if (id == TCF_META_ID_VALUE)
 		return print_value(fd, type, rta);
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH iproute2 20/22] tc/action: make variables static
  2018-11-15 22:36 [PATCH iproute2 00/22] misc cleanups Stephen Hemminger
                   ` (18 preceding siblings ...)
  2018-11-15 22:36 ` [PATCH iproute2 19/22] tc/meta: make meta_table static and const Stephen Hemminger
@ 2018-11-15 22:36 ` Stephen Hemminger
  2018-11-15 22:36 ` [PATCH iproute2 21/22] tc/pedit: use structure initialization Stephen Hemminger
                   ` (2 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: Stephen Hemminger @ 2018-11-15 22:36 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 tc/m_action.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tc/m_action.c b/tc/m_action.c
index e90867fc6c25..d5fd5affe703 100644
--- a/tc/m_action.c
+++ b/tc/m_action.c
@@ -30,9 +30,9 @@
 
 static struct action_util *action_list;
 #ifdef CONFIG_GACT
-int gact_ld; /* f*ckin backward compatibility */
+static int gact_ld; /* f*ckin backward compatibility */
 #endif
-int tab_flush;
+static int tab_flush;
 
 static void act_usage(void)
 {
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH iproute2 21/22] tc/pedit: use structure initialization
  2018-11-15 22:36 [PATCH iproute2 00/22] misc cleanups Stephen Hemminger
                   ` (19 preceding siblings ...)
  2018-11-15 22:36 ` [PATCH iproute2 20/22] tc/action: make variables static Stephen Hemminger
@ 2018-11-15 22:36 ` Stephen Hemminger
  2018-11-15 22:36 ` [PATCH iproute2 22/22] rdma: make local functions static Stephen Hemminger
  2018-11-17 23:19 ` [PATCH iproute2 00/22] misc cleanups David Ahern
  22 siblings, 0 replies; 25+ messages in thread
From: Stephen Hemminger @ 2018-11-15 22:36 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

The pedit callback structure table should be iniatialized using
structure initialization to avoid structure changes problems.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 tc/p_eth.c  | 5 ++---
 tc/p_icmp.c | 5 ++---
 tc/p_ip.c   | 5 ++---
 tc/p_ip6.c  | 5 ++---
 tc/p_tcp.c  | 5 ++---
 tc/p_udp.c  | 5 ++---
 6 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/tc/p_eth.c b/tc/p_eth.c
index 53ce736a1d78..674f9c11202a 100644
--- a/tc/p_eth.c
+++ b/tc/p_eth.c
@@ -68,7 +68,6 @@ done:
 }
 
 struct m_pedit_util p_pedit_eth = {
-	NULL,
-	"eth",
-	parse_eth,
+	.id = "eth",
+	.parse_peopt = parse_eth,
 };
diff --git a/tc/p_icmp.c b/tc/p_icmp.c
index 2c1baf82f7ad..15ce32309e39 100644
--- a/tc/p_icmp.c
+++ b/tc/p_icmp.c
@@ -55,7 +55,6 @@ done:
 }
 
 struct m_pedit_util p_pedit_icmp = {
-	NULL,
-	"icmp",
-	parse_icmp,
+	.id = "icmp",
+	.parse_peopt = parse_icmp,
 };
diff --git a/tc/p_ip.c b/tc/p_ip.c
index e9fd6f834efc..c385ac6dbcaa 100644
--- a/tc/p_ip.c
+++ b/tc/p_ip.c
@@ -156,7 +156,6 @@ done:
 }
 
 struct m_pedit_util p_pedit_ip = {
-	NULL,
-	"ip",
-	parse_ip,
+	.id = "ip",
+	.parse_peopt = parse_ip,
 };
diff --git a/tc/p_ip6.c b/tc/p_ip6.c
index bc45ab70d319..dbfdca42cce7 100644
--- a/tc/p_ip6.c
+++ b/tc/p_ip6.c
@@ -84,7 +84,6 @@ done:
 }
 
 struct m_pedit_util p_pedit_ip6 = {
-	NULL,
-	"ipv6",
-	parse_ip6,
+	.id = "ipv6",
+	.parse_peopt = parse_ip6,
 };
diff --git a/tc/p_tcp.c b/tc/p_tcp.c
index eeb68fcf87b3..d2dbfd719526 100644
--- a/tc/p_tcp.c
+++ b/tc/p_tcp.c
@@ -67,7 +67,6 @@ done:
 	return res;
 }
 struct m_pedit_util p_pedit_tcp = {
-	NULL,
-	"tcp",
-	parse_tcp,
+	.id = "tcp",
+	.parse_peopt = parse_tcp,
 };
diff --git a/tc/p_udp.c b/tc/p_udp.c
index 68c688efd110..bab456de9831 100644
--- a/tc/p_udp.c
+++ b/tc/p_udp.c
@@ -61,7 +61,6 @@ done:
 }
 
 struct m_pedit_util p_pedit_udp = {
-	NULL,
-	"udp",
-	parse_udp,
+	.id = "udp",
+	.parse_peopt = parse_udp,
 };
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH iproute2 22/22] rdma: make local functions static
  2018-11-15 22:36 [PATCH iproute2 00/22] misc cleanups Stephen Hemminger
                   ` (20 preceding siblings ...)
  2018-11-15 22:36 ` [PATCH iproute2 21/22] tc/pedit: use structure initialization Stephen Hemminger
@ 2018-11-15 22:36 ` Stephen Hemminger
  2018-11-20 22:26   ` David Ahern
  2018-11-17 23:19 ` [PATCH iproute2 00/22] misc cleanups David Ahern
  22 siblings, 1 reply; 25+ messages in thread
From: Stephen Hemminger @ 2018-11-15 22:36 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

Several functions only used inside utils.c

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 rdma/rdma.h  | 11 -----------
 rdma/utils.c | 12 ++++++------
 2 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/rdma/rdma.h b/rdma/rdma.h
index c3b7530b6cc7..05c3c69b07fd 100644
--- a/rdma/rdma.h
+++ b/rdma/rdma.h
@@ -74,13 +74,6 @@ struct rd_cmd {
 	int (*func)(struct rd *rd);
 };
 
-/*
- * Parser interface
- */
-bool rd_no_arg(struct rd *rd);
-void rd_arg_inc(struct rd *rd);
-
-char *rd_argv(struct rd *rd);
 
 /*
  * Commands interface
@@ -95,8 +88,6 @@ void rd_free(struct rd *rd);
 int rd_set_arg_to_devname(struct rd *rd);
 int rd_argc(struct rd *rd);
 
-int strcmpx(const char *str1, const char *str2);
-
 /*
  * Device manipulation
  */
@@ -117,14 +108,12 @@ int rd_recv_msg(struct rd *rd, mnl_cb_t callback, void *data, uint32_t 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
  */
 void print_driver_table(struct rd *rd, struct nlattr *tb);
 void newline(struct rd *rd);
-void newline_indent(struct rd *rd);
 #define MAX_LINE_LENGTH 80
 
 #endif /* _RDMA_TOOL_H_ */
diff --git a/rdma/utils.c b/rdma/utils.c
index 4840bf226d54..1a0cf56800d4 100644
--- a/rdma/utils.c
+++ b/rdma/utils.c
@@ -18,14 +18,14 @@ int rd_argc(struct rd *rd)
 	return rd->argc;
 }
 
-char *rd_argv(struct rd *rd)
+static char *rd_argv(struct rd *rd)
 {
 	if (!rd_argc(rd))
 		return NULL;
 	return *rd->argv;
 }
 
-int strcmpx(const char *str1, const char *str2)
+static int strcmpx(const char *str1, const char *str2)
 {
 	if (strlen(str1) > strlen(str2))
 		return -1;
@@ -39,7 +39,7 @@ static bool rd_argv_match(struct rd *rd, const char *pattern)
 	return strcmpx(rd_argv(rd), pattern) == 0;
 }
 
-void rd_arg_inc(struct rd *rd)
+static void rd_arg_inc(struct rd *rd)
 {
 	if (!rd_argc(rd))
 		return;
@@ -47,7 +47,7 @@ void rd_arg_inc(struct rd *rd)
 	rd->argv++;
 }
 
-bool rd_no_arg(struct rd *rd)
+static bool rd_no_arg(struct rd *rd)
 {
 	return rd_argc(rd) == 0;
 }
@@ -404,7 +404,7 @@ static const enum mnl_attr_data_type nldev_policy[RDMA_NLDEV_ATTR_MAX] = {
 	[RDMA_NLDEV_ATTR_DRIVER_U64] = MNL_TYPE_U64,
 };
 
-int rd_attr_check(const struct nlattr *attr, int *typep)
+static int rd_attr_check(const struct nlattr *attr, int *typep)
 {
 	int type;
 
@@ -696,7 +696,7 @@ void newline(struct rd *rd)
 		pr_out("\n");
 }
 
-void newline_indent(struct rd *rd)
+static void newline_indent(struct rd *rd)
 {
 	newline(rd);
 	if (!rd->json_output)
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* Re: [PATCH iproute2 00/22] misc cleanups
  2018-11-15 22:36 [PATCH iproute2 00/22] misc cleanups Stephen Hemminger
                   ` (21 preceding siblings ...)
  2018-11-15 22:36 ` [PATCH iproute2 22/22] rdma: make local functions static Stephen Hemminger
@ 2018-11-17 23:19 ` David Ahern
  22 siblings, 0 replies; 25+ messages in thread
From: David Ahern @ 2018-11-17 23:19 UTC (permalink / raw)
  To: Stephen Hemminger, netdev

On 11/15/18 3:36 PM, Stephen Hemminger wrote:
> Code cleanup including:
>    * make local functions static
>    * drop dead code
>    * whitespace code style cleanup
> 

Hi Stephen:

You did not mark these for -next but that is typically where cleanups
go. What is your intention?

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH iproute2 22/22] rdma: make local functions static
  2018-11-15 22:36 ` [PATCH iproute2 22/22] rdma: make local functions static Stephen Hemminger
@ 2018-11-20 22:26   ` David Ahern
  0 siblings, 0 replies; 25+ messages in thread
From: David Ahern @ 2018-11-20 22:26 UTC (permalink / raw)
  To: Stephen Hemminger, netdev

On 11/15/18 3:36 PM, Stephen Hemminger wrote:
> Several functions only used inside utils.c
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  rdma/rdma.h  | 11 -----------
>  rdma/utils.c | 12 ++++++------
>  2 files changed, 6 insertions(+), 17 deletions(-)
> 

this patch breaks builds for me on Debian stretch:

rdma
    CC       rdma.o
    CC       utils.o
    CC       dev.o
    CC       link.o
dev.c: In function 'dev_set_name':
dev.c:248:6: warning: implicit declaration of function 'rd_no_arg'
[-Wimplicit-function-declaration]
  if (rd_no_arg(rd)) {
      ^~~~~~~~~
dev.c:256:55: warning: implicit declaration of function 'rd_argv'
[-Wimplicit-function-declaration]
  mnl_attr_put_strz(rd->nlh, RDMA_NLDEV_ATTR_DEV_NAME, rd_argv(rd));
                                                       ^~~~~~~
dev.c:256:55: warning: passing argument 3 of 'mnl_attr_put_strz' makes
pointer from integer without a cast [-Wint-conversion]
In file included from rdma.h:19:0,
                 from dev.c:12:
/usr/include/libmnl/libmnl.h:103:13: note: expected 'const char *' but
argument is of type 'int'
 extern void mnl_attr_put_strz(struct nlmsghdr *nlh, uint16_t type,
const char *data);


Reverting the patch fixes it.

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2018-11-21  8:57 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-15 22:36 [PATCH iproute2 00/22] misc cleanups Stephen Hemminger
2018-11-15 22:36 ` [PATCH iproute2 01/22] lib/ll_addr: whitespace and indent cleanup Stephen Hemminger
2018-11-15 22:36 ` [PATCH iproute2 02/22] lib/utils: make local functions static Stephen Hemminger
2018-11-15 22:36 ` [PATCH iproute2 03/22] lib/color: " Stephen Hemminger
2018-11-15 22:36 ` [PATCH iproute2 04/22] lib/ll_map: make local function static Stephen Hemminger
2018-11-15 22:36 ` [PATCH iproute2 05/22] libnetlnk: unused and local functions cleanup Stephen Hemminger
2018-11-15 22:36 ` [PATCH iproute2 06/22] genl: remove dead code Stephen Hemminger
2018-11-15 22:36 ` [PATCH iproute2 07/22] bridge: make local variables static Stephen Hemminger
2018-11-15 22:36 ` [PATCH iproute2 08/22] ip: make flag names const/static Stephen Hemminger
2018-11-15 22:36 ` [PATCH iproute2 09/22] ipmonitor: make local variable static Stephen Hemminger
2018-11-15 22:36 ` [PATCH iproute2 10/22] ipxfrm: make local functions static Stephen Hemminger
2018-11-15 22:36 ` [PATCH iproute2 11/22] tc: drop unused name_to_id function Stephen Hemminger
2018-11-15 22:36 ` [PATCH iproute2 12/22] tipc: make cmd_find static Stephen Hemminger
2018-11-15 22:36 ` [PATCH iproute2 13/22] tc/class: make filter variables static Stephen Hemminger
2018-11-15 22:36 ` [PATCH iproute2 14/22] tc/police: make print_police static Stephen Hemminger
2018-11-15 22:36 ` [PATCH iproute2 15/22] ss: make local variables static Stephen Hemminger
2018-11-15 22:36 ` [PATCH iproute2 16/22] tc/pedit: make functions static Stephen Hemminger
2018-11-15 22:36 ` [PATCH iproute2 17/22] tc/ematch: make local " Stephen Hemminger
2018-11-15 22:36 ` [PATCH iproute2 18/22] tc/util: " Stephen Hemminger
2018-11-15 22:36 ` [PATCH iproute2 19/22] tc/meta: make meta_table static and const Stephen Hemminger
2018-11-15 22:36 ` [PATCH iproute2 20/22] tc/action: make variables static Stephen Hemminger
2018-11-15 22:36 ` [PATCH iproute2 21/22] tc/pedit: use structure initialization Stephen Hemminger
2018-11-15 22:36 ` [PATCH iproute2 22/22] rdma: make local functions static Stephen Hemminger
2018-11-20 22:26   ` David Ahern
2018-11-17 23:19 ` [PATCH iproute2 00/22] misc cleanups David Ahern

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.