netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: macb: fixup sparse warnings on __be16 ports
@ 2022-07-14  8:43 Ben Dooks
  2022-07-14 23:43 ` Jakub Kicinski
  0 siblings, 1 reply; 3+ messages in thread
From: Ben Dooks @ 2022-07-14  8:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Sudip Mukherjee, Jude Onyenegecha, Nicolas Ferre, Claudiu Beznea,
	David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	netdev, Ben Dooks

The port fields in the ethool flow structures are defined
to be __be16 types, so sparse is showing issues where these
are being passed to htons(). Fix these warnings by passing
them to be16_to_cpu() instead.

These are being used in netdev_dbg() so should only effect
anyone doing debug.

Fixes the following sparse warnings:

drivers/net/ethernet/cadence/macb_main.c:3366:9: warning: cast from restricted __be16
drivers/net/ethernet/cadence/macb_main.c:3366:9: warning: cast from restricted __be16
drivers/net/ethernet/cadence/macb_main.c:3366:9: warning: cast from restricted __be16
drivers/net/ethernet/cadence/macb_main.c:3419:25: warning: cast from restricted __be16
drivers/net/ethernet/cadence/macb_main.c:3419:25: warning: cast from restricted __be16
drivers/net/ethernet/cadence/macb_main.c:3419:25: warning: cast from restricted __be16
drivers/net/ethernet/cadence/macb_main.c:3419:25: warning: cast from restricted __be16

Signed-off-by: Ben Dooks <ben.dooks@sifive.com>

--
Note, given the IP is also being passed ot htons() should
this either be changed to be32_to_cpu() or better passed
as a pointre and the %pI4 be used to print it.
---
 drivers/net/ethernet/cadence/macb_main.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index d89098f4ede8..f38b924e393b 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -3482,7 +3482,8 @@ static int gem_add_flow_filter(struct net_device *netdev,
 			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),
-			htons(fs->h_u.tcp_ip4_spec.psrc), htons(fs->h_u.tcp_ip4_spec.pdst));
+		        be16_to_cpu(fs->h_u.tcp_ip4_spec.psrc),
+		        be16_to_cpu(fs->h_u.tcp_ip4_spec.pdst));
 
 	spin_lock_irqsave(&bp->rx_fs_lock, flags);
 
@@ -3535,8 +3536,8 @@ static int gem_del_flow_filter(struct net_device *netdev,
 					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),
-					htons(fs->h_u.tcp_ip4_spec.psrc),
-					htons(fs->h_u.tcp_ip4_spec.pdst));
+					be16_to_cpu(fs->h_u.tcp_ip4_spec.psrc),
+					be16_to_cpu(fs->h_u.tcp_ip4_spec.pdst));
 
 			gem_writel_n(bp, SCRT2, fs->location, 0);
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: macb: fixup sparse warnings on __be16 ports
  2022-07-14  8:43 [PATCH] net: macb: fixup sparse warnings on __be16 ports Ben Dooks
@ 2022-07-14 23:43 ` Jakub Kicinski
  2022-07-15 17:33   ` Ben Dooks
  0 siblings, 1 reply; 3+ messages in thread
From: Jakub Kicinski @ 2022-07-14 23:43 UTC (permalink / raw)
  To: Ben Dooks
  Cc: linux-kernel, Sudip Mukherjee, Jude Onyenegecha, Nicolas Ferre,
	Claudiu Beznea, David S . Miller, Eric Dumazet, Paolo Abeni,
	netdev

On Thu, 14 Jul 2022 09:43:05 +0100 Ben Dooks wrote:
> -			htons(fs->h_u.tcp_ip4_spec.psrc), htons(fs->h_u.tcp_ip4_spec.pdst));
> +		        be16_to_cpu(fs->h_u.tcp_ip4_spec.psrc),
> +		        be16_to_cpu(fs->h_u.tcp_ip4_spec.pdst));

There are some spaces on this line, please use tabs,
checkpatch will be able to help you validate.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: macb: fixup sparse warnings on __be16 ports
  2022-07-14 23:43 ` Jakub Kicinski
@ 2022-07-15 17:33   ` Ben Dooks
  0 siblings, 0 replies; 3+ messages in thread
From: Ben Dooks @ 2022-07-15 17:33 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: linux-kernel, Sudip Mukherjee, Jude Onyenegecha, Nicolas Ferre,
	Claudiu Beznea, David S . Miller, Eric Dumazet, Paolo Abeni,
	netdev

On 15/07/2022 00:43, Jakub Kicinski wrote:
> On Thu, 14 Jul 2022 09:43:05 +0100 Ben Dooks wrote:
>> -			htons(fs->h_u.tcp_ip4_spec.psrc), htons(fs->h_u.tcp_ip4_spec.pdst));
>> +		        be16_to_cpu(fs->h_u.tcp_ip4_spec.psrc),
>> +		        be16_to_cpu(fs->h_u.tcp_ip4_spec.pdst));
> 
> There are some spaces on this line, please use tabs,
> checkpatch will be able to help you validate.

Thank you, didn't spot an issue with my editor config.
Sent v2 patch

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-07-15 17:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-14  8:43 [PATCH] net: macb: fixup sparse warnings on __be16 ports Ben Dooks
2022-07-14 23:43 ` Jakub Kicinski
2022-07-15 17:33   ` Ben Dooks

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).