staging: r8188eu: simplify complex pointer casting
authorDeepak R Varma <drv@mailo.com>
Sun, 6 Nov 2022 17:55:37 +0000 (23:25 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 8 Nov 2022 15:29:46 +0000 (16:29 +0100)
Pointers to structures udphdr and dhcpMessage are derived by casting
adjacent pointers with size_t. Such typecast of pointer using size_t
is not preferred. The code looks complex and delicate. Simplify such
casting by utilizing generic "void *" casting.

Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Deepak R Varma <drv@mailo.com>
Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> # Edimax N150
Link: https://lore.kernel.org/r/1428580d09a9916899209c9278dca40ee2d297d3.1667755987.git.drv@mailo.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/r8188eu/core/rtw_br_ext.c

index a23f7df373ede94e9498361ca6a7fed0e6307465..4deaa7e352a34be7a106fe2d18f3815c0ef5ffec 100644 (file)
@@ -610,12 +610,11 @@ void dhcp_flag_bcast(struct adapter *priv, struct sk_buff *skb)
                        struct iphdr *iph = (struct iphdr *)(skb->data + ETH_HLEN);
 
                        if (iph->protocol == IPPROTO_UDP) { /*  UDP */
-                               struct udphdr *udph = (struct udphdr *)((size_t)iph + (iph->ihl << 2));
+                               struct udphdr *udph = (void *)iph + (iph->ihl << 2);
 
                                if ((udph->source == htons(CLIENT_PORT)) &&
                                    (udph->dest == htons(SERVER_PORT))) { /*  DHCP request */
-                                       struct dhcpMessage *dhcph =
-                                               (struct dhcpMessage *)((size_t)udph + sizeof(struct udphdr));
+                                       struct dhcpMessage *dhcph = (void *)udph + sizeof(struct udphdr);
                                        u32 cookie = be32_to_cpu((__be32)dhcph->cookie);
 
                                        if (cookie == DHCP_MAGIC) { /*  match magic word */