Skip to content

Commit af2697a

Browse files
lxindavem330
authored andcommitted
sctp: force the params with right types for sctp csum apis
Now sctp_csum_xxx doesn't really match the param types of these common csum apis. As sctp_csum_xxx is defined in sctp/checksum.h, many sparse errors occur when make C=2 not only with M=net/sctp but also with other modules that include this header file. This patch is to force them fit in csum apis with the right types. Fixes: e6d8b64 ("net: sctp: fix and consolidate SCTP checksumming code") Signed-off-by: Xin Long <[email protected]> Acked-by: Marcelo Ricardo Leitner <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 08f4607 commit af2697a

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

include/net/sctp/checksum.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,31 +48,32 @@ static inline __wsum sctp_csum_update(const void *buff, int len, __wsum sum)
4848
/* This uses the crypto implementation of crc32c, which is either
4949
* implemented w/ hardware support or resolves to __crc32c_le().
5050
*/
51-
return crc32c(sum, buff, len);
51+
return (__force __wsum)crc32c((__force __u32)sum, buff, len);
5252
}
5353

5454
static inline __wsum sctp_csum_combine(__wsum csum, __wsum csum2,
5555
int offset, int len)
5656
{
57-
return __crc32c_le_combine(csum, csum2, len);
57+
return (__force __wsum)__crc32c_le_combine((__force __u32)csum,
58+
(__force __u32)csum2, len);
5859
}
5960

6061
static inline __le32 sctp_compute_cksum(const struct sk_buff *skb,
6162
unsigned int offset)
6263
{
6364
struct sctphdr *sh = sctp_hdr(skb);
64-
__le32 ret, old = sh->checksum;
6565
const struct skb_checksum_ops ops = {
6666
.update = sctp_csum_update,
6767
.combine = sctp_csum_combine,
6868
};
69+
__le32 old = sh->checksum;
70+
__wsum new;
6971

7072
sh->checksum = 0;
71-
ret = cpu_to_le32(~__skb_checksum(skb, offset, skb->len - offset,
72-
~(__u32)0, &ops));
73+
new = ~__skb_checksum(skb, offset, skb->len - offset, ~(__wsum)0, &ops);
7374
sh->checksum = old;
7475

75-
return ret;
76+
return cpu_to_le32((__force __u32)new);
7677
}
7778

7879
#endif /* __sctp_checksum_h__ */

0 commit comments

Comments
 (0)