public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
From: Deepak R Varma <drv@mailo.com>
To: Joe Perches <joe@perches.com>
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
Date: Sat, 5 Nov 2022 20:30:23 +0530	[thread overview]
Message-ID: <Y2Z6h4CvyujWBkZJ@qemulion> (raw)
In-Reply-To: <49002a284dd29b8f784b52cb1527e687183ca175.camel@perches.com>

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;
>



  parent reply	other threads:[~2022-11-05 15:00 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-17 13:20 [PATCH 0/4] staging: r8188eu: trivial code cleanup patches Deepak R Varma
2022-10-17 13:21 ` [PATCH 1/4] staging: r8188eu: use Linux kernel variable naming convention Deepak R Varma
2022-10-17 13:56   ` Julia Lawall
2022-10-17 14:12     ` Deepak R Varma
2022-10-17 13:23 ` [PATCH 3/4] staging: r8188eu: remove {} for single statement blocks Deepak R Varma
2022-10-17 13:57   ` Julia Lawall
2022-10-17 14:13     ` Deepak R Varma
2022-10-17 13:24 ` [PATCH 4/4] staging: r8188eu: use htons macro instead of __constant_htons Deepak R Varma
2022-10-19  6:08   ` Joe Perches
2022-10-19  9:27     ` Deepak R Varma
2022-11-05 15:00     ` Deepak R Varma [this message]
2022-10-17 13:26 ` [PATCH 2/4] staging: r8188eu: reformat long computation lines Deepak R Varma
2022-10-17 13:22   ` Deepak R Varma
2022-10-17 14:09   ` Greg KH
2022-10-17 14:10     ` Deepak R Varma
2022-10-17 14:52       ` Greg KH
2022-10-18 11:21     ` David Laight
2022-10-18 12:42       ` Deepak R Varma
2022-10-19  5:43         ` Joe Perches
2022-10-19  6:17           ` Deepak R Varma
2022-10-19  6:38             ` Joe Perches
2022-10-19  6:44               ` Deepak R Varma
2022-10-19  9:02                 ` Deepak R Varma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y2Z6h4CvyujWBkZJ@qemulion \
    --to=drv@mailo.com \
    --cc=Larry.Finger@lwfinger.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=joe@perches.com \
    --cc=kumarpraveen@linux.microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=outreachy@lists.linux.dev \
    --cc=paskripkin@gmail.com \
    --cc=phil@philpotter.co.uk \
    --cc=saurabh.truth@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox