* [PATCH net-next] net: silence sparse endianness warnings in checksums
@ 2015-02-06 14:43 Sabrina Dubroca
2015-02-09 0:30 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Sabrina Dubroca @ 2015-02-06 14:43 UTC (permalink / raw)
To: davem; +Cc: netdev, eric.dumazet, therbert, Sabrina Dubroca
In __skb_checksum_validate_complete and its callers, we only test that
the return value is non-zero, so it's safe to __force the type.
Callers of gso_make_checksum pass a __sum16, use that.
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
---
include/linux/skbuff.h | 8 ++++----
net/ipv4/udp.c | 4 ++--
net/ipv6/ip6_checksum.c | 4 ++--
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 111e665455c3..7b35b4884f58 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -3019,7 +3019,7 @@ static inline __sum16 __skb_checksum_validate_complete(struct sk_buff *skb,
}
} else if (skb->csum_bad) {
/* ip_summed == CHECKSUM_NONE in this case */
- return 1;
+ return (__force __sum16) 1;
}
skb->csum = psum;
@@ -3308,15 +3308,15 @@ static inline int gso_pskb_expand_head(struct sk_buff *skb, int extra)
* is in the res argument (i.e. normally zero or ~ of checksum of a pseudo
* header.
*/
-static inline __sum16 gso_make_checksum(struct sk_buff *skb, __wsum res)
+static inline __sum16 gso_make_checksum(struct sk_buff *skb, __sum16 res)
{
int plen = SKB_GSO_CB(skb)->csum_start - skb_headroom(skb) -
skb_transport_offset(skb);
- __u16 csum;
+ __sum16 csum;
csum = csum_fold(csum_partial(skb_transport_header(skb),
plen, skb->csum));
- skb->csum = res;
+ skb->csum = (__force __wsum) res;
SKB_GSO_CB(skb)->csum_start -= plen;
return csum;
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 97ef1f8b7be8..1f1ff4eaa34b 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1738,8 +1738,8 @@ static inline int udp4_csum_init(struct sk_buff *skb, struct udphdr *uh,
return err;
}
- return skb_checksum_init_zero_check(skb, proto, uh->check,
- inet_compute_pseudo);
+ return (__force int)skb_checksum_init_zero_check(skb, proto, uh->check,
+ inet_compute_pseudo);
}
/*
diff --git a/net/ipv6/ip6_checksum.c b/net/ipv6/ip6_checksum.c
index 9a4d7322fb22..9a1c766a84f0 100644
--- a/net/ipv6/ip6_checksum.c
+++ b/net/ipv6/ip6_checksum.c
@@ -80,8 +80,8 @@ int udp6_csum_init(struct sk_buff *skb, struct udphdr *uh, int proto)
* for the UDP packet we'll check if that socket allows zero checksum
* for IPv6 (set by socket option).
*/
- return skb_checksum_init_zero_check(skb, proto, uh->check,
- ip6_compute_pseudo);
+ return (__force int)skb_checksum_init_zero_check(skb, proto, uh->check,
+ ip6_compute_pseudo);
}
EXPORT_SYMBOL(udp6_csum_init);
--
2.3.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] net: silence sparse endianness warnings in checksums
2015-02-06 14:43 [PATCH net-next] net: silence sparse endianness warnings in checksums Sabrina Dubroca
@ 2015-02-09 0:30 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2015-02-09 0:30 UTC (permalink / raw)
To: sd; +Cc: netdev, eric.dumazet, therbert
From: Sabrina Dubroca <sd@queasysnail.net>
Date: Fri, 6 Feb 2015 15:43:52 +0100
> In __skb_checksum_validate_complete and its callers, we only test that
> the return value is non-zero, so it's safe to __force the type.
>
> Callers of gso_make_checksum pass a __sum16, use that.
>
> Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
I don't like this, you're just moving the casts from one place to
another.
These functions are a mess, they are combining one thing (returning
the final csum value) with another thing (non-zero return has some
boolean meaning).
These issues should be explicitly accomodated rather than papered
around.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-02-09 0:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-06 14:43 [PATCH net-next] net: silence sparse endianness warnings in checksums Sabrina Dubroca
2015-02-09 0:30 ` David Miller
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).