]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ss: Turn generic_proc_open() wrappers into macros
authorPhil Sutter <phil@nwl.cc>
Fri, 2 Dec 2016 10:39:52 +0000 (11:39 +0100)
committerStephen Hemminger <stephen@networkplumber.org>
Fri, 2 Dec 2016 22:07:46 +0000 (14:07 -0800)
Signed-off-by: Phil Sutter <phil@nwl.cc>
misc/ss.c

index 54b82cc8233af96535e346c3b7ba16e4a0bee860..2e18be20385dfd9b6bcf9e05d2b558e24882c951 100644 (file)
--- 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;