Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp592786rwi; Tue, 18 Oct 2022 23:41:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Vn3VOgHKyINRQWeY0k3z59RVTvriUcL/shKW1z1ouoB/5O7Darw+xArphXZ5fecKmAY+s X-Received: by 2002:a17:907:a044:b0:78d:b569:b891 with SMTP id gz4-20020a170907a04400b0078db569b891mr5275078ejc.224.1666161687783; Tue, 18 Oct 2022 23:41:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666161687; cv=none; d=google.com; s=arc-20160816; b=c8Tq+OoaBSDWUC9DM79TfJO+ygk5wvR96msNd9iAK/ElunZBsiybC5jUx/49mPZbK8 b80Lrjlq7YBcW+vWjR3yTEtPTDWdk7vcIqZlugqS4x8OUvQJ+jHPewxTitdZAeBGknuZ D6HMJ66vtGgTkKsoJ8/5eV8RmK4cES7/9w18xAbyfY0dgLUAWsw6HCPoZPuvRCahmfEm 6DhPbYO9tylj19jo97X5aZ6A1LOCyQWOVM+iRDhZqDybp+yyJG8H/En2y+nk1eKEngyo GT/wsuD2sSLjY6v+jJIw4Otj7TnTJIr2yVYzTdrmken59R9wjB1bfv2s2QmFKXgBFGgm v9zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id; bh=f3v2X5AzYTHHPG+e459S6Qe68NRoKveWM2UZMKOprUY=; b=KHxdsPpQZ4xacdzaeptWDdU3MJQEqQjgTjXoSe1gqBPJYkiuiSjkNk7LkXoE22HcXD fwmrnQgago8GcWp+4gn/immeg+TWGQcRBRexr+bMt/2qw0Lf3zt/uEuyvyFyqvIH5lvL Tzh7sAScRK2+ZzHijxz32APJojC1yTK0AvfGRsQktVA+iW8H0kaQmDROsbPCH5E58AMB jQ/px5q3pShqzHmyGE4AdRSm2HrKzch6HzeyENowXgDrI2yKulmwc9QjB3xOvub5FPSN fNHaQNPYZtwu613/ER3B0K4ctum8/oBFjze73EjwtuLaKiPdH8q4GqHYTrHp7zji5564 ykWg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gg16-20020a170906e29000b007835897050esi11960825ejb.404.2022.10.18.23.41.02; Tue, 18 Oct 2022 23:41:27 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229559AbiJSGIR convert rfc822-to-8bit (ORCPT + 99 others); Wed, 19 Oct 2022 02:08:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229760AbiJSGIO (ORCPT ); Wed, 19 Oct 2022 02:08:14 -0400 Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9DC76583F for ; Tue, 18 Oct 2022 23:08:13 -0700 (PDT) Received: from omf20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id B05CFA054E; Wed, 19 Oct 2022 06:08:11 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf20.hostedemail.com (Postfix) with ESMTPA id E84DB2002D; Wed, 19 Oct 2022 06:07:54 +0000 (UTC) Message-ID: <49002a284dd29b8f784b52cb1527e687183ca175.camel@perches.com> Subject: Re: [PATCH 4/4] staging: r8188eu: use htons macro instead of __constant_htons From: Joe Perches To: Deepak R Varma , outreachy@lists.linux.dev, Larry.Finger@lwfinger.net, phil@philpotter.co.uk, paskripkin@gmail.com, gregkh@linuxfoundation.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Cc: kumarpraveen@linux.microsoft.com, saurabh.truth@gmail.com Date: Tue, 18 Oct 2022 23:08:06 -0700 In-Reply-To: <595559852924cc1b58778659d2dbca8e263ee9d8.1666011479.git.drv@mailo.com> References: <595559852924cc1b58778659d2dbca8e263ee9d8.1666011479.git.drv@mailo.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8BIT User-Agent: Evolution 3.44.4 (3.44.4-2.fc36) MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_NONE,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Stat-Signature: i8uc1r887uq5cmy39ehk47npqnomphsr X-Rspamd-Server: rspamout03 X-Rspamd-Queue-Id: E84DB2002D X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX1/kSBruECZdtofFGtexfl+pATe3DPBkCf0= X-HE-Tag: 1666159674-263680 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 Mon, 2022-10-17 at 18:54 +0530, Deepak R Varma wrote: > Macro "htons" is more efficiant and clearer. It should be used for > constants instead of the __contast_htons macro. Resolves following typo: __constant_htons > checkpatch script complaint: > WARNING: __constant_htons should be htons [] > diff --git a/drivers/staging/r8188eu/core/rtw_br_ext.c b/drivers/staging/r8188eu/core/rtw_br_ext.c [] > @@ -612,14 +612,14 @@ void dhcp_flag_bcast(struct adapter *priv, struct sk_buff *skb) > if (!priv->ethBrExtInfo.dhcp_bcst_disable) { > __be16 protocol = *((__be16 *)(skb->data + 2 * ETH_ALEN)); > > - if (protocol == __constant_htons(ETH_P_IP)) { /* IP */ > + if (protocol == htons(ETH_P_IP)) { /* IP */ > 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)); > > - if ((udph->source == __constant_htons(CLIENT_PORT)) && > - (udph->dest == __constant_htons(SERVER_PORT))) { /* DHCP request */ > + if ((udph->source == htons(CLIENT_PORT)) && > + (udph->dest == htons(SERVER_PORT))) { /* DHCP request */ OK, this bit seems fine > struct dhcpMessage *dhcph = > (struct dhcpMessage *)((size_t)udph + sizeof(struct udphdr)); IMO: this existing code however is ugly. Casting a pointer to a size_t isn't great. Perhaps: struct dhcpMessage *dhcp; dhcp = (void *)udhp + sizeof(struct udphdr); in a separate patch. > u32 cookie = be32_to_cpu((__be32)dhcph->cookie); And dhcph->cookie already is a __be32 so the cast is pointless. drivers/staging/r8188eu/core/rtw_br_ext.c-598- __be32 cookie;