From patchwork Sun Nov 6 17:55:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepak R Varma X-Patchwork-Id: 16166 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1614442wru; Sun, 6 Nov 2022 10:11:29 -0800 (PST) X-Google-Smtp-Source: AMsMyM6RkbOnAzAorR5razpHrhTl+6XBCMu6g5NFiVQHw4rFr0/bGpyMwuid4F/7MFC41nDbHSa8 X-Received: by 2002:aa7:df94:0:b0:461:aff8:d3e1 with SMTP id b20-20020aa7df94000000b00461aff8d3e1mr46955113edy.10.1667758289126; Sun, 06 Nov 2022 10:11:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667758289; cv=none; d=google.com; s=arc-20160816; b=RaDrs2kxYfjPGQBm0Ku054f7NTYhLxS5l2bQ6Dw0yaW5Uya7cUyQUt/UrO0nfbZpfG kLykhrdEVNW74YpaEITA4pgnSfOmbO7OlYF6Oe3exwBVIdR/7OGgcmg9IecH8Ixte7r5 NIRYQ94cQWJ6KY3zeeWq/nHbRonzS/ygXttlAAhsIc8a4YUC8kQM1SrKA5VyHJqDDu4o L2TT3KZjjAciwVHKJ2v5Df/IZKQD49QVB5Bifk2k6II1KwFOwIZaeJgvyZ9b5v6EOZXi f8R4RKbRP1dUH1i+7GNWO3d8bjRohtVMjSRzuwGW+zZtH97xjOx+lErtfx4j1KLduvFn jwAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:to:from:date:dkim-signature; bh=2Pn7K1W8yF6YSgiFpCemdH4M8yaDa9uVQAyC2nfWFvQ=; b=JoBGexkFFMpRITo9fI8u9qT+cu7sBm5+ngeHo0OYLp8PjLfVg8U0s/DCgXp6K8n97t P20kKsrv/PDr9HBhJKf1b5E/bttRswdEzUbPouXhYP8Lus81pJA78Ucvd0m8NT9QgHHv /JkFKiyJUAtdP764n0PWsjvMHfU0MvYXVzCX0aF2FFvX18CCLk1T38rYe6huEGKC5r84 B3jlw3u194iY8BnWGVy/ikFU2xDYkA4qOgHRPsPOWX8de3w4tyd+SsNGHLLoINKVVQXn IhWRW47KZB5WOQpUrr/Lc4wpvm34vWKsEW/7JYH6Pw1dZ7CnzCKPoydtKYQS0o/KbhhD 6GJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=WOqBr3xn; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nd19-20020a170907629300b0078db6f56d51si6986532ejc.808.2022.11.06.10.10.58; Sun, 06 Nov 2022 10:11:29 -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=fail header.i=@mailo.com header.s=mailo header.b=WOqBr3xn; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229991AbiKFRz4 (ORCPT + 99 others); Sun, 6 Nov 2022 12:55:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229984AbiKFRzy (ORCPT ); Sun, 6 Nov 2022 12:55:54 -0500 Received: from msg-2.mailo.com (msg-2.mailo.com [213.182.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 664C3643F for ; Sun, 6 Nov 2022 09:55:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1667757342; bh=z+5A15Rnb2tsOBvm60vdD60D90+vivHwvYlePj43mGs=; h=X-EA-Auth:Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:In-Reply-To; b=WOqBr3xn4x0+e9Ln11MMxhE29LTiUrB4/xr3vIbegXdAV5mD8zmoA/trRtkQZZ3xY t57Bx7IU8RZcVVQdEo9H5T/SgJP25XJJ7/q91J8+K5Fln1PDmGXDHCOwyIuzddh/gm +3eTfy7pKKcE+sAcyyXaDqijfUhVu/baOyEM24Pg= Received: by b-6.in.mailobj.net [192.168.90.16] with ESMTP via ip-206.mailobj.net [213.182.55.206] Sun, 6 Nov 2022 18:55:42 +0100 (CET) X-EA-Auth: 2x8xCTGx8/XRKTESQemLJuUZXOoDmAPsE3NgmIDJXOBna1ts0EXAIhsOnjXG1c0AM3zj65wIeK7rTTQNwqdHJHN9zFqHRm1m Date: Sun, 6 Nov 2022 23:25:37 +0530 From: Deepak R Varma To: Larry Finger , Phillip Potter , Pavel Skripkin , Greg Kroah-Hartman , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] staging: r8188eu: simplify complex pointer casting Message-ID: <1428580d09a9916899209c9278dca40ee2d297d3.1667755987.git.drv@mailo.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748771316016902554?= X-GMAIL-MSGID: =?utf-8?q?1748771316016902554?= 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 Signed-off-by: Deepak R Varma --- Changes in v2: 1. Separate the change associated with variable cookie in a separate patch. Now in patch 2 of this set. Suggested by gregkh@linuxfoundation.org 2. Correct variable ordering. Code cimplified to match current style. Feedback from gregkh@linuxfoundation.org. drivers/staging/r8188eu/core/rtw_br_ext.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) -- 2.34.1 diff --git a/drivers/staging/r8188eu/core/rtw_br_ext.c b/drivers/staging/r8188eu/core/rtw_br_ext.c index a23f7df373ed..4deaa7e352a3 100644 --- a/drivers/staging/r8188eu/core/rtw_br_ext.c +++ b/drivers/staging/r8188eu/core/rtw_br_ext.c @@ -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 */ From patchwork Sun Nov 6 17:57:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepak R Varma X-Patchwork-Id: 16167 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1614802wru; Sun, 6 Nov 2022 10:12:26 -0800 (PST) X-Google-Smtp-Source: AMsMyM6lG1C7X66u0+Gg1cznJa0+8A0wMq36RBE53wNp9+kasnjPV25LavfEdvi7g2Uk+AjaoFXC X-Received: by 2002:a17:907:60d4:b0:79e:8082:132d with SMTP id hv20-20020a17090760d400b0079e8082132dmr45107443ejc.9.1667758345852; Sun, 06 Nov 2022 10:12:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667758345; cv=none; d=google.com; s=arc-20160816; b=zng/X2toeLUnV4Ka8kxoDjxYXMm6u0o447jddI41QTgCFynkI2FuDxcjQaW+7knUeB xUZQqa78TTrviFxQSgdyD6kwyw2LuVWGyrrHvQ3JIpPSj1qHLROUFCinMe2Qy+N/rFmP smL02CeP57Ot9XagQv2PgtuHNv7KF0xYg+kO0wVvhzmDucB/a7Ml5/NYmChx/tw7SVq/ bGD22pQCPLk5upOhVF9efNvu09m678LLwudqhH1y84jNgiwbhTCsw7p34Whj1sR5V8xd wK6LlHl5x2Z01SWl07rlNkEFGpUX4IXiAV4jf8xDrpc3xVtPW3dj7tr9DQxLckHgOFg7 w8qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:to:from:date:dkim-signature; bh=Pt0Pmiv6UrToGYx91FvKZtfACFPnq1d8+5X3k5nLkfY=; b=acMTc0wQMVl7copox5Uga0uvksH+fTKds7F28LtMgfm1ZjVv4sBLF1ZCnUSCGCa35y JpAXraet4ksx6JRUmPBKwt+hNxp4/lre3psWyp3b3MKovTrmxBo9K3qLTZeEFjYrOpom GXbUXsnHfddnwUVMzGVdODq5/ajQcn2wR2zQO0bAntvqSassCg9HawajjTrKViv/eQTf rr9z6wDfanROJEogPb4Qiez/ZZ+Z4PjFZHh3sfe+kr664KogB11PTlj2y0sJUaLif887 L8gMjSfXfWnp73/vTW966U4a+LWAddE1AVFoaqHKrs1wAD3fyNMKWh9eIbkrPGl46cyX t1aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=OL7ufRjr; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s6-20020a170906bc4600b0078de44dd61fsi5134004ejv.990.2022.11.06.10.12.00; Sun, 06 Nov 2022 10:12:25 -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=fail header.i=@mailo.com header.s=mailo header.b=OL7ufRjr; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230487AbiKFR5b (ORCPT + 99 others); Sun, 6 Nov 2022 12:57:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229947AbiKFR53 (ORCPT ); Sun, 6 Nov 2022 12:57:29 -0500 Received: from msg-4.mailo.com (msg-4.mailo.com [213.182.54.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9503CA47B for ; Sun, 6 Nov 2022 09:57:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1667757437; bh=R2B3fDOf8MX2Y8ck45wyaW6ET1XIPeT3gTlhsiet+a0=; h=X-EA-Auth:Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:In-Reply-To; b=OL7ufRjrqdeP0G1yvdffp4NMSdM3GSaBaZRgp/o00sW0AO/j+DRvRZ6wvdT0bocUQ oIJNDJgOMwX8l4SVpMiIRVE2nSSxtCuNOVtywVwL08c3enooTUYD6fS8auB2BeZ5JR qvu87pjIHTUI60Ku+CcAxNV+2tFkW0auTo7W15uE= Received: by b-1.in.mailobj.net [192.168.90.11] with ESMTP via ip-206.mailobj.net [213.182.55.206] Sun, 6 Nov 2022 18:57:17 +0100 (CET) X-EA-Auth: H+PFsFexCiXLjRkugddMC6Rj+rM8J/vUcqx6NmA7KTpCi4zjSKKgYqed5BGoIC0zRxd70x6CFipLp5SQm7lSvF7LPucpg5Ke Date: Sun, 6 Nov 2022 23:27:12 +0530 From: Deepak R Varma To: Larry Finger , Phillip Potter , Pavel Skripkin , Greg Kroah-Hartman , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] staging: r8188eu: remove unnecessary casting Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748771375228934201?= X-GMAIL-MSGID: =?utf-8?q?1748771375228934201?= The dhcpMessage struct member variable "cookie" is already declared to be of type __be32. There is no need to cast it again as __be32. Signed-off-by: Deepak R Varma --- Changes in v2: 1. Change associated with variable cookie separated into this patch. Feedback from gregkh@linuxfoundation.org. drivers/staging/r8188eu/core/rtw_br_ext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.34.1 diff --git a/drivers/staging/r8188eu/core/rtw_br_ext.c b/drivers/staging/r8188eu/core/rtw_br_ext.c index 4deaa7e352a3..a7c67014dde0 100644 --- a/drivers/staging/r8188eu/core/rtw_br_ext.c +++ b/drivers/staging/r8188eu/core/rtw_br_ext.c @@ -615,7 +615,7 @@ void dhcp_flag_bcast(struct adapter *priv, struct sk_buff *skb) if ((udph->source == htons(CLIENT_PORT)) && (udph->dest == htons(SERVER_PORT))) { /* DHCP request */ struct dhcpMessage *dhcph = (void *)udph + sizeof(struct udphdr); - u32 cookie = be32_to_cpu((__be32)dhcph->cookie); + u32 cookie = be32_to_cpu(dhcph->cookie); if (cookie == DHCP_MAGIC) { /* match magic word */ if (!(dhcph->flags & htons(BROADCAST_FLAG))) {