Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp489062rwb; Sun, 6 Nov 2022 08:54:32 -0800 (PST) X-Google-Smtp-Source: AMsMyM51bKlQlrAwBFC+EqQmiNWBDBeh5UUmTevbXckKDw+MsLV7FY3DkcbMnHEHZ1aUyBc94CpF X-Received: by 2002:a05:6402:164d:b0:464:4ac8:d269 with SMTP id s13-20020a056402164d00b004644ac8d269mr17304555edx.394.1667753671808; Sun, 06 Nov 2022 08:54:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667753671; cv=none; d=google.com; s=arc-20160816; b=JdOD4pgDbd95GRdMa2s/iuiYJAYeKca+cCJN2WQT48EpvBSkg/MDEYDnhUaCRBWZ1p WNgTfQskLicGPqr3xKK8F+iAGzyeF1H5BcxCEqKY3BQha/CBI1g0jS2skxHozsI6RvZY x8j7gSSeoISD2eIcADHeAwPrJKczwmrMfsFGpumopYiQcM84bVaTabns/kwn9rPZaXCI Eldu+S31MrIiBMezNyjJIlMVNQrqfbqrzGNgeCodfdN97ilOgeo10p069pwv0WkwrDM2 jVnu00N78eEAF0iQoAbILOAlOW2OyGU/sqg1CiaprLPubeHaALMRUwxyP80IGZp6oQ6x +sVw== 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:cc:to:from:date:dkim-signature; bh=W/tTqBdHv5bmd8XS08mL8mD4iQu+eEPZRVYmlDRLUOA=; b=zRK8Z4pVjGGgqkgwUukISXVkwsfPIJwDYwcdGfwisq8bnMRKHTXQJmaqCUqOSSPGFm 0RWT2Ru2Jt9nnXrKTonb7X2h53Hna2hTWCtTTHCK1trRtOdIawQjDkASy9bDjM+7Sbm7 5kWPpuMYvT43BrH33waSLWqQDsrBH4WvT1Jo1uhZUpWzT9xUOglGwfOzQ8Kkp+uSxpMv SGbcWZ4bprl9nB1BDshaXUX6F47yDEIN1nSZdGPpKiCdVLLrl3NsipPKZMJjM1kq+ZKc +oG5VexVsxUnTm+KUhJ5sQhWtzT9MPBMKwkR45QU+oq7CL+28YFE/ba4JfsbGZr9HbiK u07g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oXfcaR5U; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y11-20020a056402170b00b0046154f0f866si6084571edu.159.2022.11.06.08.54.07; Sun, 06 Nov 2022 08:54:31 -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=@linuxfoundation.org header.s=korg header.b=oXfcaR5U; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230074AbiKFQnq (ORCPT + 96 others); Sun, 6 Nov 2022 11:43:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229820AbiKFQno (ORCPT ); Sun, 6 Nov 2022 11:43:44 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2384BE3C for ; Sun, 6 Nov 2022 08:43:43 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 74D3FB8013C for ; Sun, 6 Nov 2022 16:43:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0D12C433D6; Sun, 6 Nov 2022 16:43:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1667753021; bh=DqJbdByfgSiyjE2Pg/kYXTeQpByNVtD3R7IyUGu7NI8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=oXfcaR5U1UBwAhBQoQneNSLTnbLUog92sEGazVO3NzIDrcdYW7XQdbhtGKk4aZMAg 2Uq2RgOspL25y1sC/yGUmRuP7Exs6G+tptAP5ts3E7PfP1dW98AQWjMdOH69MnLLEu IqJsl0X4U9V/8i7SQsiA3fdIo8ugQ2WJ5klP5P+o= Date: Sun, 6 Nov 2022 17:43:38 +0100 From: Greg Kroah-Hartman To: Deepak R Varma Cc: Larry Finger , Phillip Potter , Pavel Skripkin , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH] staging: r8188eu: simplify complex pointer casting Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Sun, Nov 06, 2022 at 01:56:01PM +0530, 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". Wait, why is that unecessary? And why is that part of this change, that should be a separate one, so that it can be reverted when it's found to be buggy :) > > 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; Why reorder these variables? > + > + dhcph = (void *)udph + sizeof(struct udphdr); > + cookie = be32_to_cpu(dhcph->cookie); The cookie change should be separate please. thanks, greg k-h