]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
netpoll: Improve code clarity with explicit struct size calculations
authorBreno Leitao <leitao@debian.org>
Wed, 2 Jul 2025 10:06:33 +0000 (03:06 -0700)
committerJakub Kicinski <kuba@kernel.org>
Tue, 8 Jul 2025 01:52:55 +0000 (18:52 -0700)
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>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20250702-netpoll_untagle_ip-v2-1-13cf3db24e2b@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/netpoll.c

index 54f9d505895f6dcf665d43a7fb817f7a0e33f73b..ac0ae9630654a57dd43839126bd635fb5282b2f2 100644 (file)
@@ -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);