Received: by 2002:a05:6358:16cd:b0:dc:6189:e246 with SMTP id r13csp2611142rwl; Sat, 5 Nov 2022 09:03:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5ib0D/POk9o2yOKGh1w3p7aKHBo7nOIcFJYcy3TESHlfJ8Oqn3XTBaClpUIuC4wj0rrOLQ X-Received: by 2002:a17:90a:304b:b0:213:d60f:7fc6 with SMTP id q11-20020a17090a304b00b00213d60f7fc6mr33523269pjl.92.1667664186853; Sat, 05 Nov 2022 09:03:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667664186; cv=none; d=google.com; s=arc-20160816; b=g0yQj8JApSO+7HhpwAHlvpQaSxLulDNMenPurhhAfcyJIKx1dJFiAtWcd+vXTkgxaS mWxojk1QNnZ8sCxLMN+5IIfkjU3F4KQEGTJ6GRJm1ZJvwiGOSrNcafzyuT/cee1LJg6L rOMaZ3PbsjBGEtgJM5ygtSun5o4a3AJPDIPQOf1uPhFk310LGQAIHoMn15kqdhMvOTAx 6rrem1P02/guGSG2H6tNkT3b+Q7FcwohWl2EEFaMIoj7xXcSM+QWqu4zXhme6T0gH0VW nzAuLBgjPIBC1zfijpAx1trGxoto6IL5sCK91edDX1T2426d93zPQsThOGfUsQ4yJRsQ k+Zw== 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=hWgV31WskvFA29JyR4e6JJUn89ia0gjoV5ZOx6norJo=; b=kxgZwl3hBnarF3OCOHKYztS1+j6CpWYfFKjvh+SiyQTm1qBg2j0yXc51EM/f0EG7VL mhmAgcFlXa7PPFM0BuVuVP+TFZ/s4yFyE/57cHCoOEcfgl7K0gsiMdcUCW6GAsWHZ38b DFWmKHQMIgnJuFkoBGFQEBw8ctmpyElBUm7J1+8RwKMW7xnro6OSuKL9LRnt3ue6qo4c IQo3/lzvRNUtdBJXUG/btnwgoxdABaCzbnYTTHR8Ce+CCeK4VmL2Qf1Z7bLOanB0/QNd qkgn3vwJWXNcgYPxi2nu6EV4UBMwbw6n5uyFENyFANbi1bhXDUbb/0Pz9y1DJGdgMwnK xk6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=SaM3qw62; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b15-20020a056a000a8f00b0056bb3281494si3548588pfl.138.2022.11.05.09.02.53; Sat, 05 Nov 2022 09:03:06 -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; dkim=fail header.i=@mailo.com header.s=mailo header.b=SaM3qw62; 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 S229789AbiKEPAu (ORCPT + 97 others); Sat, 5 Nov 2022 11:00:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229517AbiKEPAs (ORCPT ); Sat, 5 Nov 2022 11:00:48 -0400 Received: from msg-1.mailo.com (msg-1.mailo.com [213.182.54.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 705881055E for ; Sat, 5 Nov 2022 08:00:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1667660429; bh=SnaBD66+CDHSlpPtuF40RHI1mG87+sDwbq0pZrPokVI=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:In-Reply-To; b=SaM3qw62sNKSPLVw3W8/5Mo6O0x8ak/rEIg+H1t/AOZyhGH/WMY6jOrPYAjCjKRCa 2PPhTee+IZzSthyj9UQ2dEPFftCaP/ROIMzhHAhYPmbzrM+k7tzRuSuD1pKg0LY9qy cmiosiGGTgw+JNvXwyps57p/83YSJhVGKuFsR0B8= Received: by b-4.in.mailobj.net [192.168.90.14] with ESMTP via ip-206.mailobj.net [213.182.55.206] Sat, 5 Nov 2022 16:00:29 +0100 (CET) X-EA-Auth: dqXraEsnrkDTnyc+sL0q+zBlgL4eFjGhqqaFty33MJVnZelEYPwmFbVVYEeqin6Y/jkgf9lQARR1KDVbywxfvoN0e1IkOeGp Date: Sat, 5 Nov 2022 20:30:23 +0530 From: Deepak R Varma To: Joe Perches Cc: 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, kumarpraveen@linux.microsoft.com, saurabh.truth@gmail.com Subject: Re: [PATCH 4/4] staging: r8188eu: use htons macro instead of __constant_htons Message-ID: References: <595559852924cc1b58778659d2dbca8e263ee9d8.1666011479.git.drv@mailo.com> <49002a284dd29b8f784b52cb1527e687183ca175.camel@perches.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <49002a284dd29b8f784b52cb1527e687183ca175.camel@perches.com> 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 On Tue, Oct 18, 2022 at 11:08:06PM -0700, Joe Perches wrote: > 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. Hello Joe, Other thank looking ugly, is there any impact / risk associated with such casting? I tried to look for the reasons myself but did not find anything relevant or to the point. Thank you, ./drv > > 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; >