[PATCH] Fix line too long warning

2017-10-28 Thread Kien Ha
>From fc52a98aca0c033f2c03fdc7e8f83ae49625675a Mon Sep 17 00:00:00 2001
From: Kien Ha 
Date: Fri, 27 Oct 2017 14:07:55 -0400
Subject: [PATCH] Fix line too long warning

Signed-off-by: Kien Ha 
---
 drivers/staging/rtlwifi/base.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/rtlwifi/base.c b/drivers/staging/rtlwifi/base.c
index b88b0e8edd3d..bbc80f976e12 100644
--- a/drivers/staging/rtlwifi/base.c
+++ b/drivers/staging/rtlwifi/base.c
@@ -1283,7 +1283,8 @@ void rtl_get_tcb_desc(struct ieee80211_hw *hw,
} else {
if (rtlmac->mode == WIRELESS_MODE_B) {
tcb_desc->hw_rate =
-   
rtlpriv->cfg->maps[RTL_RC_CCK_RATE11M];
+   rtlpriv->cfg->maps[
+   RTL_RC_CCK_RATE11M];
} else {
tcb_desc->hw_rate =

rtlpriv->cfg->maps[RTL_RC_OFDM_RATE54M];
-- 
2.14.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] Fix line too long warning

2017-10-29 Thread Kien Ha
>From dbe17bd47c0e76372a5ca391543dc15ddb35c9dd Mon Sep 17 00:00:00 2001
From: Kien Ha 
Date: Fri, 27 Oct 2017 14:07:55 -0400
Subject: [PATCH v2] Fix line too long warning

Signed-off-by: Kien Ha 
---
 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_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 =
+   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];
}
 
if (is_multicast_ether_addr(hdr->addr1))
-- 
2.14.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] Fix line too long warning

2017-10-29 Thread Kien Ha
On Sun, 2017-10-29 at 18:54 +0300, Yury Norov wrote:
> Hi Kien,
> 
> On Sat, Oct 28, 2017 at 10:46:13PM -0400, Kien Ha wrote:
> > > From fc52a98aca0c033f2c03fdc7e8f83ae49625675a Mon Sep 17 00:00:00
> > > 2001
> > 
> > From: Kien Ha 
> > Date: Fri, 27 Oct 2017 14:07:55 -0400
> > Subject: [PATCH] Fix line too long warning
> > 
> > Signed-off-by: Kien Ha 
> > ---
> >  drivers/staging/rtlwifi/base.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/staging/rtlwifi/base.c
> > b/drivers/staging/rtlwifi/base.c
> > index b88b0e8edd3d..bbc80f976e12 100644
> > --- a/drivers/staging/rtlwifi/base.c
> > +++ b/drivers/staging/rtlwifi/base.c
> > @@ -1283,7 +1283,8 @@ void rtl_get_tcb_desc(struct ieee80211_hw
> > *hw,
> > } else {
> > if (rtlmac->mode ==
> > WIRELESS_MODE_B) {
> > tcb_desc->hw_rate
> > =
> > -   rtlpriv->cfg-
> > >maps[RTL_RC_CCK_RATE11M];
> > +   rtlpriv->cfg-
> > >maps[
> > +   RTL_RC_CCK_RAT
> > E11M];
> 
> At first, if you fix this, you should also fix similar problem 3
> lines
> below, right?
> 
> > } else {
> > tcb_desc->hw_rate
> > =
> > rtlpriv->cfg-
> > >maps[RTL_RC_OFDM_RATE54M];
> 
> At second, and most important, refer Documentation/process/coding-
> style.rst:
> Now, some people will claim that having 8-character indentations
> makes
> the code move too far to the right, and makes it hard to read on a 
> 80-character terminal screen.  The answer to that is that if you
> need 
> more than 3 levels of indentation, you're screwed anyway, and should
> fix
> your program.
> 
> The real problem here is not "line too long", but "indentation level
> too
> big" - 5. And it worth to address real problem.
> 
> Yury

Thank you for taking some of your time to review my patch, providing
valuable feedback and pointing me in the right direction Joe and Yury.
I submitted another patch with improved code based on your
suggestions.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] staging: rtlwifi: Fix line too long warning

2017-10-30 Thread Kien Ha
>From aa0f4ae8c325545b1fd794d6bbf8c4d2f64e2ec2 Mon Sep 17 00:00:00 2001
From: Kien Ha 
Date: Fri, 27 Oct 2017 14:07:55 -0400
Subject: [PATCH v2] staging: rtlwifi: Fix line too long warning

Made nested if else statement more concise to help conform to coding
style.

Signed-off-by: Kien Ha 
---
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_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 =
+   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];
}
 
if (is_multicast_ether_addr(hdr->addr1))
-- 
2.14.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2] staging: rtlwifi: Fix line too long warning

2017-11-02 Thread Kien Ha
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 
> > 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 
> > ---
> > 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 =
-