Commit 077b393d authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

net: fix sparse endianness warnings on sock_common

# make C=2 CF=-D__CHECK_ENDIAN__ net/ipv4/inet_hashtables.o
...
net/ipv4/inet_hashtables.c:242:7: warning: restricted __portpair degrades to integer
net/ipv4/inet_hashtables.c:242:7: warning: restricted __addrpair degrades to integer
...

Move __portpair/__addrpair from include/net/inet_hashtables.h
to include/net/sock.h where we need them in struct sock_common
Reported-by: default avatarFengguang Wu <fengguang.wu@intel.com>
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Cc: Ling Ma <ling.ma.program@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 049b467d
...@@ -277,7 +277,6 @@ static inline struct sock *inet_lookup_listener(struct net *net, ...@@ -277,7 +277,6 @@ static inline struct sock *inet_lookup_listener(struct net *net,
On 64bit targets we combine comparisons with pair of adjacent __be32 On 64bit targets we combine comparisons with pair of adjacent __be32
fields in the same way. fields in the same way.
*/ */
typedef __u32 __bitwise __portpair;
#ifdef __BIG_ENDIAN #ifdef __BIG_ENDIAN
#define INET_COMBINED_PORTS(__sport, __dport) \ #define INET_COMBINED_PORTS(__sport, __dport) \
((__force __portpair)(((__force __u32)(__be16)(__sport) << 16) | (__u32)(__dport))) ((__force __portpair)(((__force __u32)(__be16)(__sport) << 16) | (__u32)(__dport)))
...@@ -287,7 +286,6 @@ typedef __u32 __bitwise __portpair; ...@@ -287,7 +286,6 @@ typedef __u32 __bitwise __portpair;
#endif #endif
#if (BITS_PER_LONG == 64) #if (BITS_PER_LONG == 64)
typedef __u64 __bitwise __addrpair;
#ifdef __BIG_ENDIAN #ifdef __BIG_ENDIAN
#define INET_ADDR_COOKIE(__name, __saddr, __daddr) \ #define INET_ADDR_COOKIE(__name, __saddr, __daddr) \
const __addrpair __name = (__force __addrpair) ( \ const __addrpair __name = (__force __addrpair) ( \
......
...@@ -126,6 +126,9 @@ struct sock; ...@@ -126,6 +126,9 @@ struct sock;
struct proto; struct proto;
struct net; struct net;
typedef __u32 __bitwise __portpair;
typedef __u64 __bitwise __addrpair;
/** /**
* struct sock_common - minimal network layer representation of sockets * struct sock_common - minimal network layer representation of sockets
* @skc_daddr: Foreign IPv4 addr * @skc_daddr: Foreign IPv4 addr
...@@ -155,7 +158,7 @@ struct sock_common { ...@@ -155,7 +158,7 @@ struct sock_common {
* address on 64bit arches : cf INET_MATCH() and INET_TW_MATCH() * address on 64bit arches : cf INET_MATCH() and INET_TW_MATCH()
*/ */
union { union {
unsigned long skc_addrpair; __addrpair skc_addrpair;
struct { struct {
__be32 skc_daddr; __be32 skc_daddr;
__be32 skc_rcv_saddr; __be32 skc_rcv_saddr;
...@@ -167,7 +170,7 @@ struct sock_common { ...@@ -167,7 +170,7 @@ struct sock_common {
}; };
/* skc_dport && skc_num must be grouped as well */ /* skc_dport && skc_num must be grouped as well */
union { union {
u32 skc_portpair; __portpair skc_portpair;
struct { struct {
__be16 skc_dport; __be16 skc_dport;
__u16 skc_num; __u16 skc_num;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment