From: Simon Horman <simon.horman@corigine.com>
To: Ben Dooks <ben.dooks@codethink.co.uk>
Cc: netdev@vger.kernel.org, pabeni@redhat.com, kuba@kernel.org,
edumazet@google.com, davem@davemloft.net,
linux-kernel@vger.kernel.org, claudiu.beznea@microchip.com,
nicolas.ferre@microchip.com
Subject: Re: [PATCH 3/3] net: macb: fix __be32 warnings in debug code
Date: Thu, 22 Jun 2023 17:44:34 +0200 [thread overview]
Message-ID: <ZJRsYtU4qPZ0h1xp@corigine.com> (raw)
In-Reply-To: <20230622130507.606713-4-ben.dooks@codethink.co.uk>
On Thu, Jun 22, 2023 at 02:05:07PM +0100, Ben Dooks wrote:
> The netdev_dbg() calls in gem_add_flow_filter() and gem_del_flow_filter()
> call ntohl() on the ipv4 addresses, which will put them into the host order
> but not the right type (returns a __be32, not an u32 as would be expected).
>
> Chaning the htonl() to nthol() should still do the right conversion, return
> the correct u32 type and should not change any functional to remove the
> following sparse warnings:
>
> drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: incorrect type in argument 1 (different base types)
> drivers/net/ethernet/cadence/macb_main.c:3568:9: expected unsigned int [usertype] val
> drivers/net/ethernet/cadence/macb_main.c:3568:9: got restricted __be32 [usertype] ip4src
> drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: cast from restricted __be32
> drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: cast from restricted __be32
> drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: cast from restricted __be32
> drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: cast from restricted __be32
> drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: incorrect type in argument 1 (different base types)
> drivers/net/ethernet/cadence/macb_main.c:3568:9: expected unsigned int [usertype] val
> drivers/net/ethernet/cadence/macb_main.c:3568:9: got restricted __be32 [usertype] ip4dst
> drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: cast from restricted __be32
> drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: cast from restricted __be32
> drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: cast from restricted __be32
> drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: cast from restricted __be32
> d
> drivers/net/ethernet/cadence/macb_main.c:3622:25: warning: incorrect type in argument 1 (different base types)
> drivers/net/ethernet/cadence/macb_main.c:3622:25: expected unsigned int [usertype] val
> drivers/net/ethernet/cadence/macb_main.c:3622:25: got restricted __be32 [usertype] ip4src
> drivers/net/ethernet/cadence/macb_main.c:3622:25: warning: cast from restricted __be32
> drivers/net/ethernet/cadence/macb_main.c:3622:25: warning: cast from restricted __be32
> drivers/net/ethernet/cadence/macb_main.c:3622:25: warning: cast from restricted __be32
> drivers/net/ethernet/cadence/macb_main.c:3622:25: warning: cast from restricted __be32
> drivers/net/ethernet/cadence/macb_main.c:3622:25: warning: incorrect type in argument 1 (different base types)
> drivers/net/ethernet/cadence/macb_main.c:3622:25: expected unsigned int [usertype] val
> drivers/net/ethernet/cadence/macb_main.c:3622:25: got restricted __be32 [usertype] ip4dst
> drivers/net/ethernet/cadence/macb_main.c:3622:25: warning: cast from restricted __be32
> drivers/net/ethernet/cadence/macb_main.c:3622:25: warning: cast from restricted __be32
> drivers/net/ethernet/cadence/macb_main.c:3622:25: warning: cast from restricted __be32
> drivers/net/ethernet/cadence/macb_main.c:3622:25: warning: cast from restricted __be32
>
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Hi Ben,
this code-change looks good to me, but I have a few minor nits for your
consideration.
1. Please specify the target tree, in this case net-next, for patch sets
for Networking code.
Subject: [PATCH net-next ...] ...
2. It might be nicer to write '.../macb_main.c' or similar,
rather tha nthe full path, in the patch description.
3. checkpatch --codespell says: 'Chaning' -> 'Chaining'
> ---
> drivers/net/ethernet/cadence/macb_main.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> index 56e202b74bd7..59a90c2b307f 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -3568,8 +3568,8 @@ static int gem_add_flow_filter(struct net_device *netdev,
> netdev_dbg(netdev,
> "Adding flow filter entry,type=%u,queue=%u,loc=%u,src=%08X,dst=%08X,ps=%u,pd=%u\n",
> fs->flow_type, (int)fs->ring_cookie, fs->location,
> - htonl(fs->h_u.tcp_ip4_spec.ip4src),
> - htonl(fs->h_u.tcp_ip4_spec.ip4dst),
> + ntohl(fs->h_u.tcp_ip4_spec.ip4src),
> + ntohl(fs->h_u.tcp_ip4_spec.ip4dst),
> be16_to_cpu(fs->h_u.tcp_ip4_spec.psrc),
> be16_to_cpu(fs->h_u.tcp_ip4_spec.pdst));
>
> @@ -3622,8 +3622,8 @@ static int gem_del_flow_filter(struct net_device *netdev,
> netdev_dbg(netdev,
> "Deleting flow filter entry,type=%u,queue=%u,loc=%u,src=%08X,dst=%08X,ps=%u,pd=%u\n",
> fs->flow_type, (int)fs->ring_cookie, fs->location,
> - htonl(fs->h_u.tcp_ip4_spec.ip4src),
> - htonl(fs->h_u.tcp_ip4_spec.ip4dst),
> + ntohl(fs->h_u.tcp_ip4_spec.ip4src),
> + ntohl(fs->h_u.tcp_ip4_spec.ip4dst),
> be16_to_cpu(fs->h_u.tcp_ip4_spec.psrc),
> be16_to_cpu(fs->h_u.tcp_ip4_spec.pdst));
>
> --
> 2.40.1
>
>
next prev parent reply other threads:[~2023-06-22 15:45 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-22 13:05 net: macb: sparse warning fixes Ben Dooks
2023-06-22 13:05 ` [PATCH 1/3] net: macb: check constant to define and fix __be32 warnings Ben Dooks
2023-06-22 15:49 ` Simon Horman
2023-06-23 9:40 ` Ben Dooks
2023-06-23 11:02 ` Simon Horman
2023-06-22 13:05 ` [PATCH 2/3] net: macb: add port constant to fix __be16 warnings Ben Dooks
2023-06-22 13:05 ` [PATCH 3/3] net: macb: fix __be32 warnings in debug code Ben Dooks
2023-06-22 15:44 ` Simon Horman [this message]
2023-06-23 9:43 ` Ben Dooks
2023-06-23 11:01 ` Simon Horman
2023-06-23 13:16 ` net: macb: sparse warning fixes Nicolas Ferre
2023-06-23 15:38 ` Andrew Lunn
2023-06-23 15:42 ` Nicolas Ferre
2023-07-03 8:10 ` Ben Dooks
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=ZJRsYtU4qPZ0h1xp@corigine.com \
--to=simon.horman@corigine.com \
--cc=ben.dooks@codethink.co.uk \
--cc=claudiu.beznea@microchip.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
--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).