Received: by 2002:a05:6358:16cd:b0:dc:6189:e246 with SMTP id r13csp3568744rwl; Sun, 6 Nov 2022 01:02:57 -0800 (PST) X-Google-Smtp-Source: AMsMyM6/qISHQwo3/KQiFAMfQCJtxmUK9+dcMD2Z+6Tc7qD2Gw9TN0K+zaJ77Qrvh2dnpl8ofLec X-Received: by 2002:a17:907:a429:b0:7a6:a48b:5e52 with SMTP id sg41-20020a170907a42900b007a6a48b5e52mr41827885ejc.411.1667725377197; Sun, 06 Nov 2022 01:02:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667725377; cv=none; d=google.com; s=arc-20160816; b=xnvn6Pd/NSG6dRe7xDuNSzUvqpPmiYfx5eQNJrqERJ82BRSR9qsJF0Z9TE9xq9wEhB VpE/5gKJXPtfwl58A3rjJ9XCe0NODammGy19w/RiBCROJThTIc+8TjLpDvdg4MIRpWoC kFGfrwsrnSx7t4k//4qhEEqAR7pLmwJdQFpACQ5zX42adsSWcf/OHZCBEyG/+3XnIJTy T+edNql68g1b6LZgbVWRIiKh7l/lsy3mdi84q2t24QdzpiP+KnGQBdc9RjK5bJFxTD/g be15el9EQs7gQ+/uSd+pEH6zmyN+kYc7T/pyrL+YdnZtXIeZKDYjiMvIvZBLPIIPC9dv IYQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=Q8VESBKh1KMoZOvtg0ZXq27EnrJxCWZC/qS4aZqyj6E=; b=gtSLsJ6UYRrCCy3x+Wlt1BSQvYti+XaTaIXeQK06cIVgX8Ty6D5qUQUpYSsT+NJWSG NQzFZj47vaTOzfw6+mmKHKWA+WMixbOEbu+Yo3A9PPzGSdOayAEZy4S1ygKC8y5TwpVX EnIITTbgD/gAT24fJhm91qKg3tgtIy7SftCki0Neoun+7i2tgTvg0scOJxMCWZLCv8hc kpnbtzjU/0Ll/SUP75T7f4Xf6LuLYXn9KYN5n20URaGAaEUyRKWiiSPuZkzvh9NEtWOq a6tucRxwL3nq3QLQdN1xawhwJZRyWhb8Z4M+STu1GLNlT00/73PplnLLCOI/64ELQ/B5 Fv5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ckK656tM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sa7-20020a1709076d0700b0078dec48d442si5395194ejc.680.2022.11.06.01.02.33; Sun, 06 Nov 2022 01:02:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ckK656tM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229614AbiKFIf6 (ORCPT + 97 others); Sun, 6 Nov 2022 03:35:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229525AbiKFIf4 (ORCPT ); Sun, 6 Nov 2022 03:35:56 -0500 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2993BD139 for ; Sun, 6 Nov 2022 01:35:55 -0700 (PDT) Received: by mail-ed1-x535.google.com with SMTP id f7so13258333edc.6 for ; Sun, 06 Nov 2022 01:35:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=Q8VESBKh1KMoZOvtg0ZXq27EnrJxCWZC/qS4aZqyj6E=; b=ckK656tMCZn6XdNyIdpwTuvuc78qcLTit148z0817frs3Lu9U8ibpVJOHuwzuhKteo KISbgXg6rdFNPl7WKZMr76PxqxzBTQSCcOYHeXz0g7Gmbo7cocxbefWpjjLPxUdIA9+z U6pal+7Wo9FJjtgwgXDQRf5ju2KXZ+7KILzbFoWL2j+W8ftA0sFd8QVT7lZJxPh1/pXP ubC67zvY85c1uf0+5fOhJG7IteFg2gRmIHY/ru2pwUYuv1NfyON+cRg7xiXHiB4YSy6H 9L7vkIf1QxylvC+9MTHKE+bZ180Y7lFbfWceDY/QEQJX5B135Z7oUEl43cb7iAW7Vz9Q lCqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Q8VESBKh1KMoZOvtg0ZXq27EnrJxCWZC/qS4aZqyj6E=; b=w1OIJ1YOfb4bAoviDlkXrBxte1cGwsn+/f9RavnA6UpW0kNJU0kUMfkHTMa/xBOzS5 tnI6EDZKIu798SBZgceRo5GdafMAbr3vjrEHU8G1njylGEp11b4ecdMatYrQ95W3eCZ8 KeEf94f/+D4AY0FexusLdawX+iuq0Q99Qr6d4BYyzHk/qvCZD+tVwlh8nXNAYKw6lNNH LST/TTYD6/vdq8Oed7NM2WRkpMEaJ1l1Qa7yq6VVwaLKrktLh8p3CZwmFc6S3iqHEYrs Wqkhn5gTfa+ctCeUi8MKgcfpmKQQnnx99eeBN9akOjH15tlLntT6A2oVZxwKW69DpLbw iMuA== X-Gm-Message-State: ACrzQf2gTtCbDYLz1jKSiQYIK1d4mVgm+wmy4hSXx4+od5RF0qwWXpqn d/s0IxtpkAyYNO70IjGsP6J+fTecWgQ= X-Received: by 2002:aa7:cf0b:0:b0:461:2271:8559 with SMTP id a11-20020aa7cf0b000000b0046122718559mr44462387edy.92.1667723753732; Sun, 06 Nov 2022 01:35:53 -0700 (PDT) Received: from [192.168.1.100] (p54a07888.dip0.t-ipconnect.de. [84.160.120.136]) by smtp.gmail.com with ESMTPSA id i28-20020a1709067a5c00b00781dbdb292asm1858629ejo.155.2022.11.06.01.35.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 06 Nov 2022 01:35:53 -0700 (PDT) Message-ID: Date: Sun, 6 Nov 2022 09:35:51 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH] staging: r8188eu: simplify complex pointer casting Content-Language: en-US To: Deepak R Varma , Larry Finger , Phillip Potter , Pavel Skripkin , Greg Kroah-Hartman , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org References: From: Philipp Hortmann In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/6/22 09:26, Deepak R Varma wrote: > 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. > While at this change, remove the unnecessary __be32 casting for member > variable "cookie". > > Suggested-by: Joe Perches > Signed-off-by: Deepak R Varma > --- > drivers/staging/r8188eu/core/rtw_br_ext.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/drivers/staging/r8188eu/core/rtw_br_ext.c b/drivers/staging/r8188eu/core/rtw_br_ext.c > index a23f7df373ed..e9b0906d0d74 100644 > --- a/drivers/staging/r8188eu/core/rtw_br_ext.c > +++ b/drivers/staging/r8188eu/core/rtw_br_ext.c > @@ -610,13 +610,15 @@ 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)); > - u32 cookie = be32_to_cpu((__be32)dhcph->cookie); > + u32 cookie; > + struct dhcpMessage *dhcph; > + > + dhcph = (void *)udph + sizeof(struct udphdr); > + cookie = be32_to_cpu(dhcph->cookie); > > if (cookie == DHCP_MAGIC) { /* match magic word */ > if (!(dhcph->flags & htons(BROADCAST_FLAG))) { > -- > 2.34.1 > > > > Tested-by: Philipp Hortmann # Edimax N150