提交 6a6b0b99 编写于 作者: M Mat Martineau 提交者: David S. Miller

tcp: Avoid preprocessor directives in tracepoint macro args

Using a preprocessor directive to check for CONFIG_IPV6 in the middle of
a DECLARE_EVENT_CLASS macro's arg list causes sparse to report a series
of errors:

./include/trace/events/tcp.h:68:1: error: directive in argument list
./include/trace/events/tcp.h:75:1: error: directive in argument list
./include/trace/events/tcp.h:144:1: error: directive in argument list
./include/trace/events/tcp.h:151:1: error: directive in argument list
./include/trace/events/tcp.h:216:1: error: directive in argument list
./include/trace/events/tcp.h:223:1: error: directive in argument list
./include/trace/events/tcp.h:274:1: error: directive in argument list
./include/trace/events/tcp.h:281:1: error: directive in argument list

Once sparse finds an error, it stops printing warnings for the file it
is checking. This masks any sparse warnings that would normally be
reported for the core TCP code.

Instead, handle the preprocessor conditionals in a couple of auxiliary
macros. This also has the benefit of reducing duplicate code.

Cc: David Ahern <dsahern@gmail.com>
Signed-off-by: NMat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 3a33a19b
...@@ -25,6 +25,35 @@ ...@@ -25,6 +25,35 @@
tcp_state_name(TCP_CLOSING), \ tcp_state_name(TCP_CLOSING), \
tcp_state_name(TCP_NEW_SYN_RECV)) tcp_state_name(TCP_NEW_SYN_RECV))
#define TP_STORE_V4MAPPED(__entry, saddr, daddr) \
do { \
struct in6_addr *pin6; \
\
pin6 = (struct in6_addr *)__entry->saddr_v6; \
ipv6_addr_set_v4mapped(saddr, pin6); \
pin6 = (struct in6_addr *)__entry->daddr_v6; \
ipv6_addr_set_v4mapped(daddr, pin6); \
} while (0)
#if IS_ENABLED(CONFIG_IPV6)
#define TP_STORE_ADDRS(__entry, saddr, daddr, saddr6, daddr6) \
do { \
if (sk->sk_family == AF_INET6) { \
struct in6_addr *pin6; \
\
pin6 = (struct in6_addr *)__entry->saddr_v6; \
*pin6 = saddr6; \
pin6 = (struct in6_addr *)__entry->daddr_v6; \
*pin6 = daddr6; \
} else { \
TP_STORE_V4MAPPED(__entry, saddr, daddr); \
} \
} while (0)
#else
#define TP_STORE_ADDRS(__entry, saddr, daddr, saddr6, daddr6) \
TP_STORE_V4MAPPED(__entry, saddr, daddr)
#endif
/* /*
* tcp event with arguments sk and skb * tcp event with arguments sk and skb
* *
...@@ -50,7 +79,6 @@ DECLARE_EVENT_CLASS(tcp_event_sk_skb, ...@@ -50,7 +79,6 @@ DECLARE_EVENT_CLASS(tcp_event_sk_skb,
TP_fast_assign( TP_fast_assign(
struct inet_sock *inet = inet_sk(sk); struct inet_sock *inet = inet_sk(sk);
struct in6_addr *pin6;
__be32 *p32; __be32 *p32;
__entry->skbaddr = skb; __entry->skbaddr = skb;
...@@ -65,20 +93,8 @@ DECLARE_EVENT_CLASS(tcp_event_sk_skb, ...@@ -65,20 +93,8 @@ DECLARE_EVENT_CLASS(tcp_event_sk_skb,
p32 = (__be32 *) __entry->daddr; p32 = (__be32 *) __entry->daddr;
*p32 = inet->inet_daddr; *p32 = inet->inet_daddr;
#if IS_ENABLED(CONFIG_IPV6) TP_STORE_ADDRS(__entry, inet->inet_saddr, inet->inet_daddr,
if (sk->sk_family == AF_INET6) { sk->sk_v6_rcv_saddr, sk->sk_v6_daddr);
pin6 = (struct in6_addr *)__entry->saddr_v6;
*pin6 = sk->sk_v6_rcv_saddr;
pin6 = (struct in6_addr *)__entry->daddr_v6;
*pin6 = sk->sk_v6_daddr;
} else
#endif
{
pin6 = (struct in6_addr *)__entry->saddr_v6;
ipv6_addr_set_v4mapped(inet->inet_saddr, pin6);
pin6 = (struct in6_addr *)__entry->daddr_v6;
ipv6_addr_set_v4mapped(inet->inet_daddr, pin6);
}
), ),
TP_printk("sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c", TP_printk("sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c",
...@@ -127,7 +143,6 @@ DECLARE_EVENT_CLASS(tcp_event_sk, ...@@ -127,7 +143,6 @@ DECLARE_EVENT_CLASS(tcp_event_sk,
TP_fast_assign( TP_fast_assign(
struct inet_sock *inet = inet_sk(sk); struct inet_sock *inet = inet_sk(sk);
struct in6_addr *pin6;
__be32 *p32; __be32 *p32;
__entry->skaddr = sk; __entry->skaddr = sk;
...@@ -141,20 +156,8 @@ DECLARE_EVENT_CLASS(tcp_event_sk, ...@@ -141,20 +156,8 @@ DECLARE_EVENT_CLASS(tcp_event_sk,
p32 = (__be32 *) __entry->daddr; p32 = (__be32 *) __entry->daddr;
*p32 = inet->inet_daddr; *p32 = inet->inet_daddr;
#if IS_ENABLED(CONFIG_IPV6) TP_STORE_ADDRS(__entry, inet->inet_saddr, inet->inet_daddr,
if (sk->sk_family == AF_INET6) { sk->sk_v6_rcv_saddr, sk->sk_v6_daddr);
pin6 = (struct in6_addr *)__entry->saddr_v6;
*pin6 = sk->sk_v6_rcv_saddr;
pin6 = (struct in6_addr *)__entry->daddr_v6;
*pin6 = sk->sk_v6_daddr;
} else
#endif
{
pin6 = (struct in6_addr *)__entry->saddr_v6;
ipv6_addr_set_v4mapped(inet->inet_saddr, pin6);
pin6 = (struct in6_addr *)__entry->daddr_v6;
ipv6_addr_set_v4mapped(inet->inet_daddr, pin6);
}
), ),
TP_printk("sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c", TP_printk("sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c",
...@@ -197,7 +200,6 @@ TRACE_EVENT(tcp_set_state, ...@@ -197,7 +200,6 @@ TRACE_EVENT(tcp_set_state,
TP_fast_assign( TP_fast_assign(
struct inet_sock *inet = inet_sk(sk); struct inet_sock *inet = inet_sk(sk);
struct in6_addr *pin6;
__be32 *p32; __be32 *p32;
__entry->skaddr = sk; __entry->skaddr = sk;
...@@ -213,20 +215,8 @@ TRACE_EVENT(tcp_set_state, ...@@ -213,20 +215,8 @@ TRACE_EVENT(tcp_set_state,
p32 = (__be32 *) __entry->daddr; p32 = (__be32 *) __entry->daddr;
*p32 = inet->inet_daddr; *p32 = inet->inet_daddr;
#if IS_ENABLED(CONFIG_IPV6) TP_STORE_ADDRS(__entry, inet->inet_saddr, inet->inet_daddr,
if (sk->sk_family == AF_INET6) { sk->sk_v6_rcv_saddr, sk->sk_v6_daddr);
pin6 = (struct in6_addr *)__entry->saddr_v6;
*pin6 = sk->sk_v6_rcv_saddr;
pin6 = (struct in6_addr *)__entry->daddr_v6;
*pin6 = sk->sk_v6_daddr;
} else
#endif
{
pin6 = (struct in6_addr *)__entry->saddr_v6;
ipv6_addr_set_v4mapped(inet->inet_saddr, pin6);
pin6 = (struct in6_addr *)__entry->daddr_v6;
ipv6_addr_set_v4mapped(inet->inet_daddr, pin6);
}
), ),
TP_printk("sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c oldstate=%s newstate=%s", TP_printk("sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c oldstate=%s newstate=%s",
...@@ -256,7 +246,6 @@ TRACE_EVENT(tcp_retransmit_synack, ...@@ -256,7 +246,6 @@ TRACE_EVENT(tcp_retransmit_synack,
TP_fast_assign( TP_fast_assign(
struct inet_request_sock *ireq = inet_rsk(req); struct inet_request_sock *ireq = inet_rsk(req);
struct in6_addr *pin6;
__be32 *p32; __be32 *p32;
__entry->skaddr = sk; __entry->skaddr = sk;
...@@ -271,20 +260,8 @@ TRACE_EVENT(tcp_retransmit_synack, ...@@ -271,20 +260,8 @@ TRACE_EVENT(tcp_retransmit_synack,
p32 = (__be32 *) __entry->daddr; p32 = (__be32 *) __entry->daddr;
*p32 = ireq->ir_rmt_addr; *p32 = ireq->ir_rmt_addr;
#if IS_ENABLED(CONFIG_IPV6) TP_STORE_ADDRS(__entry, ireq->ir_loc_addr, ireq->ir_rmt_addr,
if (sk->sk_family == AF_INET6) { ireq->ir_v6_loc_addr, ireq->ir_v6_rmt_addr);
pin6 = (struct in6_addr *)__entry->saddr_v6;
*pin6 = ireq->ir_v6_loc_addr;
pin6 = (struct in6_addr *)__entry->daddr_v6;
*pin6 = ireq->ir_v6_rmt_addr;
} else
#endif
{
pin6 = (struct in6_addr *)__entry->saddr_v6;
ipv6_addr_set_v4mapped(ireq->ir_loc_addr, pin6);
pin6 = (struct in6_addr *)__entry->daddr_v6;
ipv6_addr_set_v4mapped(ireq->ir_rmt_addr, pin6);
}
), ),
TP_printk("sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c", TP_printk("sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册