All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Andrew Lunn <andrew@lunn.ch>
Cc: netdev <netdev@vger.kernel.org>, Nicolas Pitre <nico@fluxnic.net>,
	David Laight <David.Laight@ACULAB.COM>,
	Lee Jones <lee.jones@linaro.org>
Subject: Re: [PATCH net-next v2 6/7] drivers: net: smc911x: Fix cast from pointer to integer of different size
Date: Thu, 5 Nov 2020 14:47:11 -0800	[thread overview]
Message-ID: <20201105144711.40a2f8f6@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> (raw)
In-Reply-To: <20201104154858.1247725-7-andrew@lunn.ch>

On Wed,  4 Nov 2020 16:48:57 +0100 Andrew Lunn wrote:
> -	buf = (char*)((u32)skb->data & ~0x3);
> -	len = (skb->len + 3 + ((u32)skb->data & 3)) & ~0x3;
> -	cmdA = (((u32)skb->data & 0x3) << 16) |
> +	offset = (unsigned long)skb->data & 3;
> +	buf = skb->data - offset;
> +	len = skb->len + offset;
> +	cmdA = (offset << 16) |

The len calculation is wrong, you trusted people on the mailing list 
too much ;)

This is better:

-	len = (skb->len + 3 + ((u32)skb->data & 3)) & ~0x3;
+	len = round_up(skb->len, 4);

You can also do PTR_ALIGN_DOWN() for the skb->data if you want.
And give the same treatment to the other side of the #if statement.

  reply	other threads:[~2020-11-05 22:47 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-04 15:48 [PATCH net-next v2 0/7] smsc W=1 warning fixes Andrew Lunn
2020-11-04 15:48 ` [PATCH net-next v2 1/7] drivers: net: smc91x: Fix set but unused W=1 warning Andrew Lunn
2020-11-05 22:37   ` Jakub Kicinski
2020-11-06  8:48     ` David Laight
2020-11-06 17:42       ` Jakub Kicinski
2020-11-04 15:48 ` [PATCH net-next v2 2/7] drivers: net: smc91x: Fix missing kerneldoc reported by W=1 Andrew Lunn
2020-11-04 15:48 ` [PATCH net-next v2 3/7] drivers: net: smc911x: Work around set but unused status Andrew Lunn
2020-11-04 15:48 ` [PATCH net-next v2 4/7] drivers: net: smc911x: Fix set but unused status because of DBG macro Andrew Lunn
2020-11-04 15:48 ` [PATCH net-next v2 5/7] drivers: net: smc911x: Fix passing wrong number of parameters to DBG() macro Andrew Lunn
2020-11-04 15:48 ` [PATCH net-next v2 6/7] drivers: net: smc911x: Fix cast from pointer to integer of different size Andrew Lunn
2020-11-05 22:47   ` Jakub Kicinski [this message]
2020-11-06  8:44     ` David Laight
2020-11-06 15:05       ` Nicolas Pitre
2020-11-06 15:29         ` David Laight
2020-11-06 15:47           ` Nicolas Pitre
2020-11-04 15:48 ` [PATCH net-next v2 7/7] drivers: net: smsc: Add COMPILE_TEST support Andrew Lunn

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=20201105144711.40a2f8f6@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com \
    --to=kuba@kernel.org \
    --cc=David.Laight@ACULAB.COM \
    --cc=andrew@lunn.ch \
    --cc=lee.jones@linaro.org \
    --cc=netdev@vger.kernel.org \
    --cc=nico@fluxnic.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.