netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: "David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Michael Jamet <michael.jamet@intel.com>,
	Yehezkel Bernat <YehezkelShB@gmail.com>,
	netdev@vger.kernel.org
Subject: Re: [PATCH 1/2] net: thunderbolt: Fix sparse warnings
Date: Wed, 5 Apr 2023 12:52:24 +0300	[thread overview]
Message-ID: <20230405095224.GT33314@black.fi.intel.com> (raw)
In-Reply-To: <ZC01N8tU9SN70GDh@smile.fi.intel.com>

Hi Andy,

On Wed, Apr 05, 2023 at 11:45:43AM +0300, Andy Shevchenko wrote:
> On Tue, Apr 04, 2023 at 08:36:35AM +0300, Mika Westerberg wrote:
> > Fixes the following warnings when the driver is built with sparse
> > checks enabled:
> 
> > drivers/net/thunderbolt/main.c:767:47: warning: restricted __le32 degrades to integer
> > drivers/net/thunderbolt/main.c:775:47: warning: restricted __le16 degrades to integer
> > drivers/net/thunderbolt/main.c:776:44: warning: restricted __le16 degrades to integer
> > drivers/net/thunderbolt/main.c:876:40: warning: incorrect type in assignment (different base types)
> > drivers/net/thunderbolt/main.c:876:40:    expected restricted __le32 [usertype] frame_size
> > drivers/net/thunderbolt/main.c:876:40:    got unsigned int [assigned] [usertype] frame_size
> > drivers/net/thunderbolt/main.c:877:41: warning: incorrect type in assignment (different base types)
> > drivers/net/thunderbolt/main.c:877:41:    expected restricted __le32 [usertype] frame_count
> > drivers/net/thunderbolt/main.c:877:41:    got unsigned int [usertype]
> > drivers/net/thunderbolt/main.c:878:41: warning: incorrect type in assignment (different base types)
> > drivers/net/thunderbolt/main.c:878:41:    expected restricted __le16 [usertype] frame_index
> > drivers/net/thunderbolt/main.c:878:41:    got unsigned short [usertype]
> > drivers/net/thunderbolt/main.c:879:38: warning: incorrect type in assignment (different base types)
> > drivers/net/thunderbolt/main.c:879:38:    expected restricted __le16 [usertype] frame_id
> > drivers/net/thunderbolt/main.c:879:38:    got unsigned short [usertype]
> > drivers/net/thunderbolt/main.c:880:62: warning: restricted __le32 degrades to integer
> > drivers/net/thunderbolt/main.c:880:35: warning: restricted __le16 degrades to integer
> > drivers/net/thunderbolt/main.c:993:23: warning: incorrect type in initializer (different base types)
> > drivers/net/thunderbolt/main.c:993:23:    expected restricted __wsum [usertype] wsum
> > drivers/net/thunderbolt/main.c:993:23:    got restricted __be32 [usertype]
> 
> You can drop the whole part with file name and line numbers to make the above
> neater.

I guess it is good to leave the filename, there like this, no?

main.c:993:23:    expected restricted __wsum [usertype] wsum
main.c:993:23:    got restricted __be32 [usertype]

> > No functional changes intended.
> > 
> > Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> > ---
> >  drivers/net/thunderbolt/main.c | 21 ++++++++++++---------
> >  1 file changed, 12 insertions(+), 9 deletions(-)
> > 
> > diff --git a/drivers/net/thunderbolt/main.c b/drivers/net/thunderbolt/main.c
> > index 26ef3706445e..6a43ced74881 100644
> > --- a/drivers/net/thunderbolt/main.c
> > +++ b/drivers/net/thunderbolt/main.c
> > @@ -764,7 +764,7 @@ static bool tbnet_check_frame(struct tbnet *net, const struct tbnet_frame *tf,
> >  	 */
> >  	if (net->skb && net->rx_hdr.frame_count) {
> >  		/* Check the frame count fits the count field */
> > -		if (frame_count != net->rx_hdr.frame_count) {
> > +		if (frame_count != le32_to_cpu(net->rx_hdr.frame_count)) {
> >  			net->stats.rx_length_errors++;
> >  			return false;
> >  		}
> > @@ -772,8 +772,8 @@ static bool tbnet_check_frame(struct tbnet *net, const struct tbnet_frame *tf,
> >  		/* Check the frame identifiers are incremented correctly,
> >  		 * and id is matching.
> >  		 */
> > -		if (frame_index != net->rx_hdr.frame_index + 1 ||
> > -		    frame_id != net->rx_hdr.frame_id) {
> > +		if (frame_index != le16_to_cpu(net->rx_hdr.frame_index) + 1 ||
> > +		    frame_id != le16_to_cpu(net->rx_hdr.frame_id)) {
> >  			net->stats.rx_missed_errors++;
> >  			return false;
> >  		}
> > @@ -873,11 +873,12 @@ static int tbnet_poll(struct napi_struct *napi, int budget)
> >  					TBNET_RX_PAGE_SIZE - hdr_size);
> >  		}
> >  
> > -		net->rx_hdr.frame_size = frame_size;
> > -		net->rx_hdr.frame_count = le32_to_cpu(hdr->frame_count);
> > -		net->rx_hdr.frame_index = le16_to_cpu(hdr->frame_index);
> > -		net->rx_hdr.frame_id = le16_to_cpu(hdr->frame_id);
> > -		last = net->rx_hdr.frame_index == net->rx_hdr.frame_count - 1;
> > +		net->rx_hdr.frame_size = hdr->frame_size;
> > +		net->rx_hdr.frame_count = hdr->frame_count;
> > +		net->rx_hdr.frame_index = hdr->frame_index;
> > +		net->rx_hdr.frame_id = hdr->frame_id;
> > +		last = le16_to_cpu(net->rx_hdr.frame_index) ==
> > +		       le32_to_cpu(net->rx_hdr.frame_count) - 1;
> >  
> >  		rx_packets++;
> >  		net->stats.rx_bytes += frame_size;
> > @@ -990,8 +991,10 @@ static bool tbnet_xmit_csum_and_map(struct tbnet *net, struct sk_buff *skb,
> >  {
> >  	struct thunderbolt_ip_frame_header *hdr = page_address(frames[0]->page);
> >  	struct device *dma_dev = tb_ring_dma_device(net->tx_ring.ring);
> > -	__wsum wsum = htonl(skb->len - skb_transport_offset(skb));
> >  	unsigned int i, len, offset = skb_transport_offset(skb);
> > +	/* Remove payload length from checksum */
> > +	u32 paylen = skb->len - skb_transport_offset(skb);
> > +	__wsum wsum = (__force __wsum)htonl(paylen);
> >  	__be16 protocol = skb->protocol;
> >  	void *data = skb->data;
> >  	void *dest = hdr + 1;
> 
> I would split wsum fix from the above as they are of different nature.

How they are different? The complain is pretty much the same for all
these AFAICT:

expected restricted xxx [usertype] yyy
got restricted zzz [usertype]

  reply	other threads:[~2023-04-05  9:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-04  5:36 [PATCH 0/2] net: thunderbolt: Fix for sparse warnings and typo Mika Westerberg
2023-04-04  5:36 ` [PATCH 1/2] net: thunderbolt: Fix sparse warnings Mika Westerberg
2023-04-04 19:37   ` Simon Horman
2023-04-05  8:45   ` Andy Shevchenko
2023-04-05  9:52     ` Mika Westerberg [this message]
2023-04-05 10:42       ` Andy Shevchenko
2023-04-05 12:28         ` Mika Westerberg
2023-04-04  5:36 ` [PATCH 2/2] net: thunderbolt: Fix typo in comment Mika Westerberg
2023-04-04 19:25   ` Simon Horman
2023-04-05  8:46 ` [PATCH 0/2] net: thunderbolt: Fix for sparse warnings and typo Andy Shevchenko

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=20230405095224.GT33314@black.fi.intel.com \
    --to=mika.westerberg@linux.intel.com \
    --cc=YehezkelShB@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=michael.jamet@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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).