mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Vatsala Narang <vatsalanarang@gmail.com>, gregkh@linuxfoundation.org
Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
	Julia.Lawall@lip6.fr
Subject: Re: [PATCH] staging: rtl8192u: ieee80211: Replace bit shifting with BIT macro
Date: Thu, 25 Apr 2019 17:11:31 -0500	[thread overview]
Message-ID: <c118ed83-2dbb-af38-4e6a-20a74ad2905a@embeddedor.com> (raw)
In-Reply-To: <20190425183320.23962-1-vatsalanarang@gmail.com>

Hi Vatsala,

On 4/25/19 1:33 PM, Vatsala Narang wrote:
> Challenge suggested by coccinelle.
> 

I think you mean *change*.

See more comments below...


> Replace bit shifting on 1 with the BIT(x) macro.
> Coccinelle script:
> 
> @@
> expression c;
> @@
> 
> -(1 << c)
> +BIT(c)
> 
> Signed-off-by: Vatsala Narang <vatsalanarang@gmail.com>
> ---
>  drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
> index fa59c712c74b..c44662f03a6b 100644
> --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
> +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
> @@ -86,7 +86,7 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee,
>  	/* Add the protocol name */
>  	iwe.cmd = SIOCGIWNAME;
>  	for(i=0; i<ARRAY_SIZE(ieee80211_modes); i++) {
> -		if(network->mode&(1<<i)) {
> +		if(network->mode&BIT(i)) {

A space is required before the open parenthesis: 'if ('.  Also, add
spaces around operators, in this case around '&'.

>  			sprintf(pname,ieee80211_modes[i].mode_string,ieee80211_modes[i].mode_size);
>  			pname +=ieee80211_modes[i].mode_size;
>  		}
> @@ -394,7 +394,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
>  		sec.key_sizes[key] = len;
>  		(*crypt)->ops->set_key(sec.keys[key], len, NULL,
>  				       (*crypt)->priv);
> -		sec.flags |= (1 << key);
> +		sec.flags |= BIT(key);
>  		/* This ensures a key will be activated if no key is
>  		 * explicitely set */

You could send a separate patch to fix the typo in the above
comment: explicitely -> explicitly.

I encourage you to adopt the practice of running checkpatch.pl
on your patches before submitting them.

Thanks
--
Gustavo

>  		if (key == sec.active_key)
> @@ -415,7 +415,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
>  			(*crypt)->ops->set_key(sec.keys[key], 13, NULL,
>  					       (*crypt)->priv);
>  			sec.key_sizes[key] = 13;
> -			sec.flags |= (1 << key);
> +			sec.flags |= BIT(key);
>  		}
>  
>  		/* No key data - just set the default TX key index */
> @@ -636,7 +636,7 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee,
>  	if (ext->alg != IW_ENCODE_ALG_NONE) {
>  		//memcpy(sec.keys[idx], ext->key, ext->key_len);
>  		sec.key_sizes[idx] = ext->key_len;
> -		sec.flags |= (1 << idx);
> +		sec.flags |= BIT(idx);
>  		if (ext->alg == IW_ENCODE_ALG_WEP) {
>  		      //  sec.encode_alg[idx] = SEC_ALG_WEP;
>  			sec.flags |= SEC_LEVEL;
> 

      reply	other threads:[~2019-04-25 22:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-25 18:33 Vatsala Narang
2019-04-25 22:11 ` Gustavo A. R. Silva [this message]

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=c118ed83-2dbb-af38-4e6a-20a74ad2905a@embeddedor.com \
    --to=gustavo@embeddedor.com \
    --cc=Julia.Lawall@lip6.fr \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vatsalanarang@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

all inboxes | Powered by JetHome®