[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1509290382.26592.7.camel@perches.com>
Date: Sun, 29 Oct 2017 08:19:42 -0700
From: Joe Perches <joe@...ches.com>
To: Kien Ha <kienha9922@...il.com>, linux-kernel@...r.kernel.org,
devel@...verdev.osuosl.org
Subject: Re: [PATCH] Fix line too long warning
On Sat, 2017-10-28 at 22:46 -0400, Kien Ha wrote:
> From fc52a98aca0c033f2c03fdc7e8f83ae49625675a Mon Sep 17 00:00:00 2001
> From: Kien Ha <kienha9922@...il.com>
> Date: Fri, 27 Oct 2017 14:07:55 -0400
> Subject: [PATCH] Fix line too long warning
>
> Signed-off-by: Kien Ha <kienha9922@...il.com>
Hi.
Instead of merely shutting up checkpatch warnings,
always try to improve the code instead.
Look at the flow of this cascaded if / else { if
and transform it to a simpler if ... else if ... else if ...
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];
}
}
}
This block could be
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];
which seems easier to read.
Powered by blists - more mailing lists