mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jes Sorensen <jes.sorensen@gmail.com>
To: Bhumika Goyal <bhumirks@gmail.com>,
	outreachy-kernel@googlegroups.com, gregkh@linuxfoundation.org,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: Remove ternary operator
Date: Mon, 12 Sep 2016 10:44:13 -0400	[thread overview]
Message-ID: <32230433-289b-b787-9a7a-9a897bf2f93c@gmail.com> (raw)
In-Reply-To: <1473688681-14479-1-git-send-email-bhumirks@gmail.com>

On 09/12/16 09:58, Bhumika Goyal wrote:
> Relational and logical operators evaluate to either true or false.
> Explicit conversion is not needed so remove the ternary operator.
> Done using coccinelle:
> 
> @r@
> expression A,B;
> symbol true,false;
> binary operator b = {==,!=,&&,||,>=,<=,>,<};
> @@
> - (A b B) ? true : false
> + A b B
> 
> Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
> ---
>  drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 8 ++++----
>  drivers/staging/rtl8188eu/hal/phy.c           | 2 +-
>  drivers/staging/rtl8188eu/hal/rtl8188e_dm.c   | 3 ++-
>  3 files changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
> index 9544e55..b43f57be 100644
> --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
> +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
> @@ -705,7 +705,7 @@ static int issue_probereq_ex(struct adapter *padapter,
>  	unsigned long start = jiffies;
>  
>  	do {
> -		ret = issue_probereq(padapter, pssid, da, wait_ms > 0 ? true : false);
> +		ret = issue_probereq(padapter, pssid, da, wait_ms > 0);
>  
>  		i++;
>  
> @@ -1293,7 +1293,7 @@ int issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int pow
>  		da = pnetwork->MacAddress;
>  
>  	do {
> -		ret = _issue_nulldata(padapter, da, power_mode, wait_ms > 0 ? true : false);
> +		ret = _issue_nulldata(padapter, da, power_mode, wait_ms > 0);
>  
>  		i++;
>  
> @@ -1420,7 +1420,7 @@ int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 tid, int
>  		da = pnetwork->MacAddress;
>  
>  	do {
> -		ret = _issue_qos_nulldata(padapter, da, tid, wait_ms > 0 ? true : false);
> +		ret = _issue_qos_nulldata(padapter, da, tid, wait_ms > 0);
>  
>  		i++;
>  
> @@ -1527,7 +1527,7 @@ static int issue_deauth_ex(struct adapter *padapter, u8 *da,
>  	unsigned long start = jiffies;
>  
>  	do {
> -		ret = _issue_deauth(padapter, da, reason, wait_ms > 0 ? true : false);
> +		ret = _issue_deauth(padapter, da, reason, wait_ms > 0);
>  
>  		i++;

While this part of the patch is technically correct, I would argue it
doesn't improve the code. It would make the code more readable to pass
in the wait_ms value and then have the decision made based on that in
the called function.

Cheers,
Jes

  reply	other threads:[~2016-09-12 14:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-12 13:58 Bhumika Goyal
2016-09-12 14:44 ` Jes Sorensen [this message]
2016-09-12 16:51   ` [Outreachy kernel] " Bhumika Goyal

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=32230433-289b-b787-9a7a-9a897bf2f93c@gmail.com \
    --to=jes.sorensen@gmail.com \
    --cc=bhumirks@gmail.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --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 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®