netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
To: Xin Long <lucien.xin@gmail.com>
Cc: network dev <netdev@vger.kernel.org>,
	linux-sctp@vger.kernel.org, davem@davemloft.net,
	Neil Horman <nhorman@tuxdriver.com>,
	Vlad Yasevich <vyasevich@gmail.com>
Subject: Re: [PATCH net 2/3] sctp: force the params with right types for sctp csum apis
Date: Mon, 27 Nov 2017 10:32:49 -0200	[thread overview]
Message-ID: <20171127123248.GE3473@localhost.localdomain> (raw)
In-Reply-To: <b6a18a03feb2b815d75482e266cb5e4603bb8132.1511698478.git.lucien.xin@gmail.com>

On Sun, Nov 26, 2017 at 08:16:07PM +0800, Xin Long wrote:
> 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: e6d8b64b34aa ("net: sctp: fix and consolidate SCTP checksumming code")
> Signed-off-by: Xin Long <lucien.xin@gmail.com>

Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>

> ---
>  include/net/sctp/checksum.h | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/include/net/sctp/checksum.h b/include/net/sctp/checksum.h
> index 4a5b9a3..32ee65a 100644
> --- a/include/net/sctp/checksum.h
> +++ b/include/net/sctp/checksum.h
> @@ -48,31 +48,32 @@ static inline __wsum sctp_csum_update(const void *buff, int len, __wsum sum)
>  	/* This uses the crypto implementation of crc32c, which is either
>  	 * implemented w/ hardware support or resolves to __crc32c_le().
>  	 */
> -	return crc32c(sum, buff, len);
> +	return (__force __wsum)crc32c((__force __u32)sum, buff, len);
>  }
>  
>  static inline __wsum sctp_csum_combine(__wsum csum, __wsum csum2,
>  				       int offset, int len)
>  {
> -	return __crc32c_le_combine(csum, csum2, len);
> +	return (__force __wsum)__crc32c_le_combine((__force __u32)csum,
> +						   (__force __u32)csum2, len);
>  }
>  
>  static inline __le32 sctp_compute_cksum(const struct sk_buff *skb,
>  					unsigned int offset)
>  {
>  	struct sctphdr *sh = sctp_hdr(skb);
> -        __le32 ret, old = sh->checksum;
>  	const struct skb_checksum_ops ops = {
>  		.update  = sctp_csum_update,
>  		.combine = sctp_csum_combine,
>  	};
> +	__le32 old = sh->checksum;
> +	__wsum new;
>  
>  	sh->checksum = 0;
> -	ret = cpu_to_le32(~__skb_checksum(skb, offset, skb->len - offset,
> -					  ~(__u32)0, &ops));
> +	new = ~__skb_checksum(skb, offset, skb->len - offset, ~(__wsum)0, &ops);
>  	sh->checksum = old;
>  
> -	return ret;
> +	return cpu_to_le32((__force __u32)new);
>  }
>  
>  #endif /* __sctp_checksum_h__ */
> -- 
> 2.1.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

  parent reply	other threads:[~2017-11-27 12:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-26 12:16 [PATCH net 0/3] sctp: fix some other sparse errors Xin Long
2017-11-26 12:16 ` [PATCH net 1/3] sctp: force SCTP_ERROR_INV_STRM with __u32 when calling sctp_chunk_fail Xin Long
2017-11-26 12:16   ` [PATCH net 2/3] sctp: force the params with right types for sctp csum apis Xin Long
2017-11-26 12:16     ` [PATCH net 3/3] sctp: remove extern from stream sched Xin Long
2017-11-27 12:41       ` Marcelo Ricardo Leitner
2017-11-27 12:32     ` Marcelo Ricardo Leitner [this message]
2017-11-27 12:32   ` [PATCH net 1/3] sctp: force SCTP_ERROR_INV_STRM with __u32 when calling sctp_chunk_fail Marcelo Ricardo Leitner
2017-11-27 14:00 ` [PATCH net 0/3] sctp: fix some other sparse errors Neil Horman
2017-11-28 16:00 ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171127123248.GE3473@localhost.localdomain \
    --to=marcelo.leitner@gmail.com \
    --cc=davem@davemloft.net \
    --cc=linux-sctp@vger.kernel.org \
    --cc=lucien.xin@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@tuxdriver.com \
    --cc=vyasevich@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).