mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Luis de Bethencourt <luis@debethencourt.com>
To: Frans Klaver <fransklaver@gmail.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Antoine Schweitzer-Chaput <antoine@schweitzer-chaput.fr>,
	Cristina Opriceana <cristina.opriceana@gmail.com>,
	Aya Mahfouz <mahfouz.saif.elyazal@gmail.com>,
	Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>,
	Koray Gulcu <koray.gulcu@ozu.edu.tr>,
	Greg Donald <gdonald@gmail.com>,
	Lorenzo Stoakes <lstoakes@gmail.com>,
	Ebru Akagunduz <ebru.akagunduz@gmail.com>,
	Karthik Nayak <karthik.188@gmail.com>,
	devel@driverdev.osuosl.org
Subject: Re: [PATCH] staging: rtl8192u: bool tests don't need comparisons
Date: Tue, 23 Jun 2015 15:21:23 +0200	[thread overview]
Message-ID: <20150623132123.GA2225@goodgumbo.baconseed.org> (raw)
In-Reply-To: <CAH6sp9MCKLp2qgA4T=uAti2jzhASni0UbMdnMGhXpmTyfFNMVQ@mail.gmail.com>

On Tue, Jun 23, 2015 at 03:04:32PM +0200, Frans Klaver wrote:
> On Tue, Jun 23, 2015 at 2:52 PM, Luis de Bethencourt
> <luis@debethencourt.com> wrote:
> > Remove explicit true/false comparations to bool variables.
> >
> > Signed-off-by: Luis de Bethencourt <luis@debethencourt.com>
> > ---
> >  drivers/staging/rtl8192u/r8192U_core.c |  7 ++++---
> >  drivers/staging/rtl8192u/r8192U_dm.c   | 21 +++++++++++----------
> >  2 files changed, 15 insertions(+), 13 deletions(-)
> >
> > diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
> > index a4795af..c53d670 100644
> > --- a/drivers/staging/rtl8192u/r8192U_core.c
> > +++ b/drivers/staging/rtl8192u/r8192U_core.c
> > @@ -2047,7 +2047,7 @@ static bool GetHalfNmodeSupportByAPs819xUsb(struct net_device *dev)
> >         struct r8192_priv *priv = ieee80211_priv(dev);
> >         struct ieee80211_device *ieee = priv->ieee80211;
> >
> > -       if (ieee->bHalfWirelessN24GMode == true)
> > +       if (ieee->bHalfWirelessN24GMode)
> >                 Reval = true;
> >         else
> >                 Reval =  false;
> > @@ -2762,7 +2762,7 @@ static bool rtl8192_adapter_start(struct net_device *dev)
> >         //
> >  #ifdef TO_DO_LIST
> >         if (Adapter->ResetProgress == RESET_TYPE_NORESET) {
> > -               if (pMgntInfo->RegRfOff == true) { /* User disable RF via registry. */
> > +               if (pMgntInfo->RegRfOff) { /* User disable RF via registry. */
> >                         RT_TRACE((COMP_INIT|COMP_RF), DBG_LOUD, ("InitializeAdapter819xUsb(): Turn off RF for RegRfOff ----------\n"));
> >                         MgntActSet_RF_State(Adapter, eRfOff, RF_CHANGE_BY_SW);
> >                         // Those actions will be discard in MgntActSet_RF_State because of the same state
> > @@ -4406,7 +4406,8 @@ static void query_rxdesc_status(struct sk_buff *skb,
> >         /* RTL8190 set this bit to indicate that Hw does not decrypt packet */
> >         stats->Decrypted = !desc->SWDec;
> >
> > -       if ((priv->ieee80211->pHTInfo->bCurrentHTSupport == true) && (priv->ieee80211->pairwise_key_type == KEY_TYPE_CCMP))
> > +       if ((priv->ieee80211->pHTInfo->bCurrentHTSupport) &&
> > +           (priv->ieee80211->pairwise_key_type == KEY_TYPE_CCMP))
> >                 stats->bHwError = false;
> >         else
> >                 stats->bHwError = stats->bCRC|stats->bICV;
> > diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c
> > index 12dd19e..9946615 100644
> > --- a/drivers/staging/rtl8192u/r8192U_dm.c
> > +++ b/drivers/staging/rtl8192u/r8192U_dm.c
> > @@ -438,7 +438,7 @@ static void dm_bandwidth_autoswitch(struct net_device *dev)
> >
> >         if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 || !priv->ieee80211->bandwidth_auto_switch.bautoswitch_enable)
> >                 return;
> > -       if (priv->ieee80211->bandwidth_auto_switch.bforced_tx20Mhz == false) { /* If send packets in 40 Mhz in 20/40 */
> > +       if (!priv->ieee80211->bandwidth_auto_switch.bforced_tx20Mhz) { /* If send packets in 40 Mhz in 20/40 */
> >                 if (priv->undecorated_smoothed_pwdb <= priv->ieee80211->bandwidth_auto_switch.threshold_40Mhzto20Mhz)
> >                         priv->ieee80211->bandwidth_auto_switch.bforced_tx20Mhz = true;
> >         } else { /* in force send packets in 20 Mhz in 20/40 */
> > @@ -563,7 +563,7 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev)
> >                                         break;
> >                                 }
> >                         }
> > -                       if (viviflag == true) {
> > +                       if (viviflag) {
> >                                 write_nic_byte(dev, 0x1ba, 0);
> >                                 viviflag = false;
> >                                 RT_TRACE(COMP_POWER_TRACKING, "we filtered the data\n");
> > @@ -766,7 +766,7 @@ void dm_txpower_trackingcallback(struct work_struct *work)
> >         struct r8192_priv *priv = container_of(dwork, struct r8192_priv, txpower_tracking_wq);
> >         struct net_device *dev = priv->ieee80211->dev;
> >
> > -       if (priv->bDcut == true)
> > +       if (priv->bDcut)
> >                 dm_TXPowerTrackingCallback_TSSI(dev);
> >         else
> >                 dm_TXPowerTrackingCallback_ThermalMeter(dev);
> > @@ -1301,7 +1301,7 @@ void dm_initialize_txpower_tracking(struct net_device *dev)
> >  {
> >         struct r8192_priv *priv = ieee80211_priv(dev);
> >
> > -       if (priv->bDcut == true)
> > +       if (priv->bDcut)
> >                 dm_InitializeTXPowerTracking_TSSI(dev);
> >         else
> >                 dm_InitializeTXPowerTracking_ThermalMeter(dev);
> > @@ -1357,7 +1357,7 @@ static void dm_check_txpower_tracking(struct net_device *dev)
> >  #ifdef RTL8190P
> >         dm_CheckTXPowerTracking_TSSI(dev);
> >  #else
> > -       if (priv->bDcut == true)
> > +       if (priv->bDcut)
> >                 dm_CheckTXPowerTracking_TSSI(dev);
> >         else
> >                 dm_CheckTXPowerTracking_ThermalMeter(dev);
> > @@ -1467,7 +1467,7 @@ void dm_cck_txpower_adjust(struct net_device *dev, bool binch14)
> >  {      /*  dm_CCKTxPowerAdjust */
> >         struct r8192_priv *priv = ieee80211_priv(dev);
> >
> > -       if (priv->bDcut == true)
> > +       if (priv->bDcut)
> >                 dm_CCKTxPowerAdjust_TSSI(dev, binch14);
> >         else
> >                 dm_CCKTxPowerAdjust_ThermalMeter(dev, binch14);
> > @@ -1731,7 +1731,7 @@ static void dm_dig_init(struct net_device *dev)
> >   *---------------------------------------------------------------------------*/
> >  static void dm_ctrl_initgain_byrssi(struct net_device *dev)
> >  {
> > -       if (dm_digtable.dig_enable_flag == false)
> > +       if (!dm_digtable.dig_enable_flag)
> >                 return;
> >
> >         if (dm_digtable.dig_algorithm == DIG_ALGO_BY_FALSE_ALARM)
> > @@ -1750,7 +1750,7 @@ static void dm_ctrl_initgain_byrssi_by_driverrssi(
> >         u8 i;
> >         static u8       fw_dig;
> >
> > -       if (dm_digtable.dig_enable_flag == false)
> > +       if (!dm_digtable.dig_enable_flag)
> >                 return;
> >
> >         /*DbgPrint("Dig by Sw Rssi\n");*/
> > @@ -1792,7 +1792,7 @@ static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm(
> >         static u32 reset_cnt;
> >         u8 i;
> >
> > -       if (dm_digtable.dig_enable_flag == false)
> > +       if (!dm_digtable.dig_enable_flag)
> >                 return;
> >
> >         if (dm_digtable.dig_algorithm_switch) {
> > @@ -3062,7 +3062,8 @@ static void dm_dynamic_txpower(struct net_device *dev)
> >                         priv->bDynamicTxLowPower = false;
> >                 } else {
> >                         /* high power state check */
> > -                       if (priv->undecorated_smoothed_pwdb < txlowpower_threshold && priv->bDynamicTxHighPower == true)
> > +                       if (priv->undecorated_smoothed_pwdb <
> > +                           txlowpower_threshold && priv->bDynamicTxHighPower)
> >                                 priv->bDynamicTxHighPower = false;
> 
> Oh, this has a misleading air hanging over it. It focuses the eyes on
> "txlowpower_threshold && priv->bDynamicTxHighPower", while that
> probably isn't the intent.
> 
> Frans

I agree, and wasn't sure what the best way to deal with was.

The following doesn't mislead but goes above 80 characters.
			if (priv->undecorated_smoothed_pwdb < txlowpower_threshold &&
			    priv->bDynamicTxHighPower == true)

It is better than the original but it doesn't completely fix it.

If this is a better compromise I can update the patch.

Thanks,
Luis

  reply	other threads:[~2015-06-23 13:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-23 12:52 Luis de Bethencourt
2015-06-23 12:56 ` Frans Klaver
2015-06-23 13:05   ` Luis de Bethencourt
2015-06-23 13:04 ` Frans Klaver
2015-06-23 13:21   ` Luis de Bethencourt [this message]
2015-06-23 13:37     ` Frans Klaver
2015-06-23 13:59       ` Luis de Bethencourt
2015-06-23 13:59         ` Frans Klaver
2015-06-23 14:19           ` Luis de Bethencourt

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=20150623132123.GA2225@goodgumbo.baconseed.org \
    --to=luis@debethencourt.com \
    --cc=antoine@schweitzer-chaput.fr \
    --cc=cristina.opriceana@gmail.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=ebru.akagunduz@gmail.com \
    --cc=fransklaver@gmail.com \
    --cc=gdonald@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=karthik.188@gmail.com \
    --cc=koray.gulcu@ozu.edu.tr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lstoakes@gmail.com \
    --cc=mahfouz.saif.elyazal@gmail.com \
    --cc=rickard_strandqvist@spectrumdigital.se \
    /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®