linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Breno Leitao <leitao@debian.org>
To: "David S. Miller" <davem@davemloft.net>,
	 Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
	 Andrew Lunn <andrew+netdev@lunn.ch>,
	Shuah Khan <shuah@kernel.org>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	 linux-kselftest@vger.kernel.org,
	Breno Leitao <leitao@debian.org>,
	 gustavold@gmail.com
Subject: [PATCH net-next 1/7] netpoll: Improve code clarity with explicit struct size calculations
Date: Fri, 27 Jun 2025 10:55:47 -0700	[thread overview]
Message-ID: <20250627-netpoll_untagle_ip-v1-1-61a21692f84a@debian.org> (raw)
In-Reply-To: <20250627-netpoll_untagle_ip-v1-0-61a21692f84a@debian.org>

Replace pointer-dereference sizeof() operations with explicit struct names
for improved readability and maintainability. This change:

1. Replaces `sizeof(*udph)` with `sizeof(struct udphdr)`
2. Replaces `sizeof(*ip6h)` with `sizeof(struct ipv6hdr)`
3. Replaces `sizeof(*iph)` with `sizeof(struct iphdr)`

This will make it easy to move code in the upcoming patches.

No functional changes are introduced by this patch.

Signed-off-by: Breno Leitao <leitao@debian.org>
---
 net/core/netpoll.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 54f9d505895f6..ac0ae9630654a 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -402,11 +402,11 @@ int netpoll_send_udp(struct netpoll *np, const char *msg, int len)
 	if (!IS_ENABLED(CONFIG_PREEMPT_RT))
 		WARN_ON_ONCE(!irqs_disabled());
 
-	udp_len = len + sizeof(*udph);
+	udp_len = len + sizeof(struct udphdr);
 	if (np->ipv6)
-		ip_len = udp_len + sizeof(*ip6h);
+		ip_len = udp_len + sizeof(struct ipv6hdr);
 	else
-		ip_len = udp_len + sizeof(*iph);
+		ip_len = udp_len + sizeof(struct iphdr);
 
 	total_len = ip_len + LL_RESERVED_SPACE(np->dev);
 
@@ -418,7 +418,7 @@ int netpoll_send_udp(struct netpoll *np, const char *msg, int len)
 	skb_copy_to_linear_data(skb, msg, len);
 	skb_put(skb, len);
 
-	skb_push(skb, sizeof(*udph));
+	skb_push(skb, sizeof(struct udphdr));
 	skb_reset_transport_header(skb);
 	udph = udp_hdr(skb);
 	udph->source = htons(np->local_port);
@@ -434,7 +434,7 @@ int netpoll_send_udp(struct netpoll *np, const char *msg, int len)
 		if (udph->check == 0)
 			udph->check = CSUM_MANGLED_0;
 
-		skb_push(skb, sizeof(*ip6h));
+		skb_push(skb, sizeof(struct ipv6hdr));
 		skb_reset_network_header(skb);
 		ip6h = ipv6_hdr(skb);
 
@@ -461,7 +461,7 @@ int netpoll_send_udp(struct netpoll *np, const char *msg, int len)
 		if (udph->check == 0)
 			udph->check = CSUM_MANGLED_0;
 
-		skb_push(skb, sizeof(*iph));
+		skb_push(skb, sizeof(struct iphdr));
 		skb_reset_network_header(skb);
 		iph = ip_hdr(skb);
 

-- 
2.47.1


  reply	other threads:[~2025-06-27 17:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-27 17:55 [PATCH net-next 0/7] netpoll: Factor out functions from netpoll_send_udp() and add ipv6 selftest Breno Leitao
2025-06-27 17:55 ` Breno Leitao [this message]
2025-06-27 17:55 ` [PATCH net-next 2/7] netpoll: factor out UDP checksum calculation into helper Breno Leitao
2025-06-27 17:55 ` [PATCH net-next 3/7] netpoll: factor out IPv6 header setup into push_ipv6() helper Breno Leitao
2025-06-27 17:55 ` [PATCH net-next 4/7] netpoll: factor out IPv4 header setup into push_ipv4() helper Breno Leitao
2025-06-27 17:55 ` [PATCH net-next 5/7] netpoll: factor out UDP header setup into push_udp() helper Breno Leitao
2025-06-27 17:55 ` [PATCH net-next 6/7] netpoll: move Ethernet setup to push_eth() helper Breno Leitao
2025-07-02  0:53   ` Jakub Kicinski
2025-07-02  9:25     ` Breno Leitao
2025-06-27 17:55 ` [PATCH net-next 7/7] selftests: net: Add IPv6 support to netconsole basic tests Breno Leitao

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=20250627-netpoll_untagle_ip-v1-1-61a21692f84a@debian.org \
    --to=leitao@debian.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gustavold@gmail.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@kernel.org \
    /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).