netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: netdev@vger.kernel.org
Subject: [iproute PATCH v2 08/18] ss: Turn generic_proc_open() wrappers into macros
Date: Fri,  2 Dec 2016 11:39:52 +0100	[thread overview]
Message-ID: <20161202104002.17310-9-phil@nwl.cc> (raw)
In-Reply-To: <20161202104002.17310-1-phil@nwl.cc>

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 misc/ss.c | 89 ++++++++++++++-------------------------------------------------
 1 file changed, 19 insertions(+), 70 deletions(-)

diff --git a/misc/ss.c b/misc/ss.c
index ad38eb97b0055..71040a82ca6b1 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -327,76 +327,25 @@ static FILE *generic_proc_open(const char *env, const char *name)
 
 	return fopen(p, "r");
 }
-
-static FILE *net_tcp_open(void)
-{
-	return generic_proc_open("PROC_NET_TCP", "net/tcp");
-}
-
-static FILE *net_tcp6_open(void)
-{
-	return generic_proc_open("PROC_NET_TCP6", "net/tcp6");
-}
-
-static FILE *net_udp_open(void)
-{
-	return generic_proc_open("PROC_NET_UDP", "net/udp");
-}
-
-static FILE *net_udp6_open(void)
-{
-	return generic_proc_open("PROC_NET_UDP6", "net/udp6");
-}
-
-static FILE *net_raw_open(void)
-{
-	return generic_proc_open("PROC_NET_RAW", "net/raw");
-}
-
-static FILE *net_raw6_open(void)
-{
-	return generic_proc_open("PROC_NET_RAW6", "net/raw6");
-}
-
-static FILE *net_unix_open(void)
-{
-	return generic_proc_open("PROC_NET_UNIX", "net/unix");
-}
-
-static FILE *net_packet_open(void)
-{
-	return generic_proc_open("PROC_NET_PACKET", "net/packet");
-}
-
-static FILE *net_netlink_open(void)
-{
-	return generic_proc_open("PROC_NET_NETLINK", "net/netlink");
-}
-
-static FILE *slabinfo_open(void)
-{
-	return generic_proc_open("PROC_SLABINFO", "slabinfo");
-}
-
-static FILE *net_sockstat_open(void)
-{
-	return generic_proc_open("PROC_NET_SOCKSTAT", "net/sockstat");
-}
-
-static FILE *net_sockstat6_open(void)
-{
-	return generic_proc_open("PROC_NET_SOCKSTAT6", "net/sockstat6");
-}
-
-static FILE *net_snmp_open(void)
-{
-	return generic_proc_open("PROC_NET_SNMP", "net/snmp");
-}
-
-static FILE *ephemeral_ports_open(void)
-{
-	return generic_proc_open("PROC_IP_LOCAL_PORT_RANGE", "sys/net/ipv4/ip_local_port_range");
-}
+#define net_tcp_open()		generic_proc_open("PROC_NET_TCP", "net/tcp")
+#define net_tcp6_open()		generic_proc_open("PROC_NET_TCP6", "net/tcp6")
+#define net_udp_open()		generic_proc_open("PROC_NET_UDP", "net/udp")
+#define net_udp6_open()		generic_proc_open("PROC_NET_UDP6", "net/udp6")
+#define net_raw_open()		generic_proc_open("PROC_NET_RAW", "net/raw")
+#define net_raw6_open()		generic_proc_open("PROC_NET_RAW6", "net/raw6")
+#define net_unix_open()		generic_proc_open("PROC_NET_UNIX", "net/unix")
+#define net_packet_open()	generic_proc_open("PROC_NET_PACKET", \
+							"net/packet")
+#define net_netlink_open()	generic_proc_open("PROC_NET_NETLINK", \
+							"net/netlink")
+#define slabinfo_open()		generic_proc_open("PROC_SLABINFO", "slabinfo")
+#define net_sockstat_open()	generic_proc_open("PROC_NET_SOCKSTAT", \
+							"net/sockstat")
+#define net_sockstat6_open()	generic_proc_open("PROC_NET_SOCKSTAT6", \
+							"net/sockstat6")
+#define net_snmp_open()		generic_proc_open("PROC_NET_SNMP", "net/snmp")
+#define ephemeral_ports_open()	generic_proc_open("PROC_IP_LOCAL_PORT_RANGE", \
+					"sys/net/ipv4/ip_local_port_range")
 
 struct user_ent {
 	struct user_ent	*next;
-- 
2.10.0

  parent reply	other threads:[~2016-12-02 10:41 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-02 10:39 [iproute PATCH v2 00/18] ss: Minor code review Phil Sutter
2016-12-02 10:39 ` [iproute PATCH v2 01/18] ss: Mark fall through in arg parsing switch() Phil Sutter
2016-12-02 10:39 ` [iproute PATCH v2 02/18] ss: Drop empty lines in UDP output Phil Sutter
2016-12-02 10:39 ` [iproute PATCH v2 03/18] ss: Add missing tab when printing UNIX details Phil Sutter
2016-12-02 10:39 ` [iproute PATCH v2 04/18] ss: Use sockstat->type in all socket types Phil Sutter
2016-12-02 10:39 ` [iproute PATCH v2 05/18] ss: introduce proc_ctx_print() Phil Sutter
2016-12-02 10:39 ` [iproute PATCH v2 06/18] ss: Drop list traversal from unix_stats_print() Phil Sutter
2016-12-02 10:39 ` [iproute PATCH v2 07/18] ss: Eliminate unix_use_proc() Phil Sutter
2016-12-02 10:39 ` Phil Sutter [this message]
2016-12-05 17:02   ` [iproute PATCH v2 08/18] ss: Turn generic_proc_open() wrappers into macros David Laight
2016-12-05 17:24     ` Phil Sutter
2016-12-02 10:39 ` [iproute PATCH v2 09/18] ss: Make tmr_name local to tcp_timer_print() Phil Sutter
2016-12-02 10:39 ` [iproute PATCH v2 10/18] ss: Make user_ent_hash_build_init local to user_ent_hash_build() Phil Sutter
2016-12-02 10:39 ` [iproute PATCH v2 11/18] ss: Make some variables function-local Phil Sutter
2016-12-02 10:39 ` [iproute PATCH v2 12/18] ss: Make slabstat_ids local to get_slabstat() Phil Sutter
2016-12-02 10:39 ` [iproute PATCH v2 13/18] ss: Get rid of useless goto in handle_follow_request() Phil Sutter
2016-12-02 10:39 ` [iproute PATCH v2 14/18] ss: Get rid of single-fielded struct snmpstat Phil Sutter
2016-12-02 10:39 ` [iproute PATCH v2 15/18] ss: Make unix_state_map local to unix_show() Phil Sutter
2016-12-02 10:40 ` [iproute PATCH v2 16/18] ss: Make sstate_name local to sock_state_print() Phil Sutter
2016-12-02 10:40 ` [iproute PATCH v2 17/18] ss: Make sstate_namel local to scan_state() Phil Sutter
2016-12-02 10:40 ` [iproute PATCH v2 18/18] ss: unix_show: No need to initialize members of calloc'ed structs Phil Sutter
2016-12-02 22:09 ` [iproute PATCH v2 00/18] ss: Minor code review Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161202104002.17310-9-phil@nwl.cc \
    --to=phil@nwl.cc \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).