All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kien Ha <kienha9922@gmail.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] staging: rtlwifi: Fix line too long warning
Date: Thu, 02 Nov 2017 14:51:40 -0400	[thread overview]
Message-ID: <1509648700.1011.11.camel@gmail.com> (raw)
In-Reply-To: <20171101164723.GA9034@kroah.com>

On Wed, 2017-11-01 at 17:47 +0100, Greg KH wrote:
> On Tue, Oct 31, 2017 at 12:48:04AM -0400, Kien Ha wrote:
> > > From aa0f4ae8c325545b1fd794d6bbf8c4d2f64e2ec2 Mon Sep 17 00:00:00
> > > 2001
> > 
> > From: Kien Ha <kienha9922@gmail.com>
> > Date: Fri, 27 Oct 2017 14:07:55 -0400
> > Subject: [PATCH v2] staging: rtlwifi: Fix line too long warning
> 
> Why is all of this here in the "changelog body" of the patch?
Noted. And thanks!
> 
> > 
> > Made nested if else statement more concise to help conform to
> > coding
> > style.
> > 
> > Signed-off-by: Kien Ha <kienha9922@gmail.com>
> > ---
> > Changes in v2:
> > - Improve block of code to be more concise
> > 
> >  drivers/staging/rtlwifi/base.c | 25 ++++++++-----------------
> >  1 file changed, 8 insertions(+), 17 deletions(-)
> > 
> > diff --git a/drivers/staging/rtlwifi/base.c
> > b/drivers/staging/rtlwifi/base.c
> > index b88b0e8edd3d..fdd1ab1e38c5 100644
> > --- a/drivers/staging/rtlwifi/base.c
> > +++ b/drivers/staging/rtlwifi/base.c
> > @@ -1273,23 +1273,14 @@ void rtl_get_tcb_desc(struct ieee80211_hw
> > *hw,
> >  			 * and N rate will all be controlled by FW
> >  			 * when tcb_desc->use_driver_rate = false
> >  			 */
> > -			if (sta && sta->vht_cap.vht_supported) {
> > -				tcb_desc->hw_rate =
> > -				_rtl_get_vht_highest_n_rate(hw,
> > sta);
> > -			} else {
> > -				if (sta && (sta-
> > >ht_cap.ht_supported)) {
> > -					tcb_desc->hw_rate =
> > -					    _rtl_get_highest_n_rat
> > e(hw, sta);
> > -				} else {
> > -					if (rtlmac->mode ==
> > WIRELESS_MODE_B) {
> > -						tcb_desc->hw_rate
> > =
> > -						    rtlpriv->cfg-
> > >maps[RTL_RC_CCK_RATE11M];
> > -					} else {
> > -						tcb_desc->hw_rate
> > =
> > -						    rtlpriv->cfg-
> > >maps[RTL_RC_OFDM_RATE54M];
> > -					}
> > -				}
> > -			}
> > +			tcb_desc->hw_rate =
> > +				sta && sta->vht_cap.vht_supported
> > ?
> > +					rtl_get_vht_highest_n_rate
> > (hw, sta) :
> > +				sta && sta->ht_cap.ht_supported ?
> > +					_rtl_get_highest_n_rate(hw
> > , sta) :
> > +				rtlmac->mode == WIRELESS_MODE_B ?
> > +					rtlpriv->cfg-
> > >maps[RTL_RC_CCK_RATE11M] :
> > +					rtlpriv->cfg-
> > >maps[RTL_RC_OFDM_RATE54M];
> 
> That's horrible to read, can you understand it?
> 
> I hate ? : logic, please write code for people to read, not
> compilers.

I agree, I find it difficult to read. I'm wondering, is it
necessary to have these nested if and else statements? Sorry
if it isn't terribly obvious at a glance since I'm writing this
while in class. Maybe something like the code snippet below
would be better.

 			if (sta && sta->vht_cap.vht_supported) {
 				tcb_desc->hw_rate =
-				_rtl_get_vht_highest_n_rate(hw, sta);
+					_rtl_get_vht_highest_n_rate(hw, sta);
+			} else if (sta && sta->ht_cap.ht_supported) {
+				tcb_desc->hw_rate =
+					_rtl_get_highest_n_rate(hw, sta);
+			} else if (rtlmac->mode == WIRELESS_MODE_B) {
+				tcb_desc->hw_rate =
+					rtlpriv->cfg->maps[RTL_RC_CCK_RATE11M];
 			} else {
-				if (sta && (sta->ht_cap.ht_supported)) {
-					tcb_desc->hw_rate =
-					    _rtl_get_highest_n_rate(hw, sta);
-				} else {
-					if (rtlmac->mode == WIRELESS_MODE_B) {
-						tcb_desc->hw_rate =
-						    rtlpriv->cfg->maps[RTL_RC_CCK_RATE11M];
-					} else {
-						tcb_desc->hw_rate =
-						    rtlpriv->cfg->maps[RTL_RC_OFDM_RATE54M];
-					}
-				}
+				tcb_desc_hw_rate =
+					rtlpriv->cfg->maps[RTL_RC_OFDM_RATE54M];
 			}
 		}

Thanks,
Kien Ha

  reply	other threads:[~2017-11-02 18:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-29 17:12 [PATCH v2] Fix line too long warning Kien Ha
2017-10-30 12:02 ` Dan Carpenter
2017-10-31  4:48   ` [PATCH v2] staging: rtlwifi: " Kien Ha
2017-11-01 16:47     ` Greg KH
2017-11-02 18:51       ` Kien Ha [this message]
2017-11-01  8:06 ` [PATCH v2] " kbuild test robot

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=1509648700.1011.11.camel@gmail.com \
    --to=kienha9922@gmail.com \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /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.