All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@lip6.fr>
To: Gargi Sharma <gs051095@gmail.com>
Cc: outreachy-kernel@googlegroups.com, gregkh@linuxfoundation.org
Subject: Re: [Outreachy kernel] [PATCH v3] staging: rtl8192u: Remove ternary operator
Date: Mon, 20 Feb 2017 07:44:41 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.20.1702200742300.2222@hadrien> (raw)
In-Reply-To: <1487567108-6362-1-git-send-email-gs051095@gmail.com>



On Mon, 20 Feb 2017, Gargi Sharma wrote:

> Relational and logical operators evaluate to either true or false.
> Lines with ternary operators were found using coccinelle script. In a
> few cases using logical && operator would suffice. Hence those were
> changed to improve readability.
>
> Coccinelle Script:
> @r@
> expression A,B;
> symbol true,false;
> binary operator b = {==,!=,&&,||,>=,<=,>,<};
> @@
> - (A b B) ? true : false
> + A b B
>
> Signed-off-by: Gargi Sharma <gs051095@gmail.com>
> ----
> Changes in v3:
>         - Converted ? operator to &&.
> Changes in v2:
>         - Converted ? operator to if else statements.
> ---
>  drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c
> index c27397b..1fbee3c 100644
> --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c
> +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c
> @@ -977,16 +977,16 @@ void HTOnAssocRsp(struct ieee80211_device *ieee)
>  	HTSetConnectBwMode(ieee, (HT_CHANNEL_WIDTH)(pPeerHTCap->ChlWidth), (HT_EXTCHNL_OFFSET)(pPeerHTInfo->ExtChlOffset));
>
>  //	if (pHTInfo->bCurBW40MHz)
> -		pHTInfo->bCurTxBW40MHz = ((pPeerHTInfo->RecommemdedTxWidth == 1)?true:false);
> +		pHTInfo->bCurTxBW40MHz = (pPeerHTInfo->RecommemdedTxWidth == 1);

This appears to be one character too long.  Since these statements are all
similar and you have a newline in the others, you could put a newline for
this one too.

>
>  	//
>  	// Update short GI/ long GI setting
>  	//
>  	// TODO:
>  	pHTInfo->bCurShortGI20MHz=
> -		((pHTInfo->bRegShortGI20MHz)?((pPeerHTCap->ShortGI20Mhz==1)?true:false):false);
> +		pHTInfo->bRegShortGI20MHz && (pPeerHTCap->ShortGI20Mhz == 1);
>  	pHTInfo->bCurShortGI40MHz=
> -		((pHTInfo->bRegShortGI40MHz)?((pPeerHTCap->ShortGI40Mhz==1)?true:false):false);
> +		pHTInfo->bRegShortGI40MHz && (pPeerHTCap->ShortGI40Mhz == 1);

It would be nice to straighten up the assignment overall and add a space
before the =.

julia

>  	//
>  	// Config TX STBC setting
> @@ -998,7 +998,7 @@ void HTOnAssocRsp(struct ieee80211_device *ieee)
>  	//
>  	// TODO:
>  	pHTInfo->bCurSuppCCK =
> -		((pHTInfo->bRegSuppCCK)?((pPeerHTCap->DssCCk==1)?true:false):false);
> +		pHTInfo->bRegSuppCCK && (pPeerHTCap->DssCCk == 1);
>
>
>  	//
> --
> 2.7.4
>
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1487567108-6362-1-git-send-email-gs051095%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>


      reply	other threads:[~2017-02-20  6:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-20  5:05 [PATCH v3] staging: rtl8192u: Remove ternary operator Gargi Sharma
2017-02-20  6:44 ` Julia Lawall [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=alpine.DEB.2.20.1702200742300.2222@hadrien \
    --to=julia.lawall@lip6.fr \
    --cc=gregkh@linuxfoundation.org \
    --cc=gs051095@gmail.com \
    --cc=outreachy-kernel@googlegroups.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.