From: Ryan Mallon <rmallon@gmail.com>
To: Joe Perches <joe@perches.com>
Cc: Andrew Miller <amiller@amilx.com>,
gregkh@linuxfoundation.org, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Staging: rtl8187se: r8180_core.c: Fix coding style issue
Date: Wed, 14 Mar 2012 15:18:10 +1100 [thread overview]
Message-ID: <4F601C02.8070909@gmail.com> (raw)
In-Reply-To: <1331688836.27389.13.camel@joe2Laptop>
On 14/03/12 12:33, Joe Perches wrote:
> On Tue, 2012-03-13 at 20:58 -0400, Andrew Miller wrote:
>> Fix long line coding style issue
>> Signed-off-by: Andrew Miller <amiller@amilx.com>
>
> Hi Andrew.
>
> Please strive for clarity instead of just fixing
> random 80 char warnings.
>
>> diff --git a/drivers/staging/rtl8187se/r8180_core.c b/drivers/staging/rtl8187se/r8180_core.c
> []
>> @@ -1607,17 +1609,20 @@ void rtl8180_rx(struct net_device *dev)
>> /* printk("==========================>rx : RXAGC is %d,signalstrength is %d\n",RXAGC,stats.signalstrength); */
>> stats.rssi = priv->wstats.qual.qual = priv->SignalQuality;
>> stats.noise = priv->wstats.qual.noise = 100 - priv->wstats.qual.qual;
>> - bHwError = (((*(priv->rxringtail)) & (0x00000fff)) == 4080) | (((*(priv->rxringtail)) & (0x04000000)) != 0)
>> - | (((*(priv->rxringtail)) & (0x08000000)) != 0) | (((~(*(priv->rxringtail))) & (0x10000000)) != 0) | (((~(*(priv->rxringtail))) & (0x20000000)) != 0);
>> + bHwError = (((*(priv->rxringtail)) & (0x00000fff)) == 4080) |
>> + (((*(priv->rxringtail)) & (0x04000000)) != 0) |
>> + (((*(priv->rxringtail)) & (0x08000000)) != 0) |
>> + (((~(*(priv->rxringtail))) & (0x10000000)) != 0) |
>> + (((~(*(priv->rxringtail))) & (0x20000000)) != 0);
>
> Likely these | uses should be ||
>
>> bCRC = ((*(priv->rxringtail)) & (0x00002000)) >> 13;
>> bICV = ((*(priv->rxringtail)) & (0x00001000)) >> 12;
>> hdr = (struct ieee80211_hdr_4addr *)priv->rxbuffer->buf;
>> fc = le16_to_cpu(hdr->frame_ctl);
>> type = WLAN_FC_GET_TYPE(fc);
>>
>> - if ((IEEE80211_FTYPE_CTL != type) &&
>> - (eqMacAddr(priv->ieee80211->current_network.bssid, (fc & IEEE80211_FCTL_TODS) ? hdr->addr1 : (fc & IEEE80211_FCTL_FROMDS) ? hdr->addr2 : hdr->addr3))
>> - && (!bHwError) && (!bCRC) && (!bICV)) {
>> + if ((IEEE80211_FTYPE_CTL != type) && (eqMacAddr(priv->ieee80211->current_network.bssid,
>> + (fc & IEEE80211_FCTL_TODS) ? hdr->addr1 : (fc & IEEE80211_FCTL_FROMDS) ? hdr->addr2 : hdr->addr3))
>> + && (!bHwError) && (!bCRC) && (!bICV)) {
>
> This is difficult to read and could be better written
> removing unnecessary parentheses and making the egMacAddr
> clearer as a function/macro call:
>
> if (IEEE80211_FTYPE_CTL != type &&
> eqMacAddr(priv->ieee80211->current_network.bssid,
> fc & IEEE80211_FCTL_TODS ? hdr->addr1 :
> fc & IEEE80211_FCTL_FROMDS ? hdr->addr2 :
> hdr->addr3) &&
> !bHwError &&
> !bCRC &&
> !bICV)
That's still pretty nasty. Eight lines for an if expression! It took me
a couple of glances to realise that there were only two arguments to
eqMacAddr. If you add some temporary variables then you can make the
code a lot more sane, without making it overly verbose:
u8 *addr, *bssid = priv->ieee80211->current_network.bssid;
if (fc & IEEE80211_FCTL_TODS)
addr = hdr->addr1;
else if (fc & IEEE80211_FCTL_FROMDS)
addr = hdr->addr2;
else
addr = hdr->addr3;
if (!bHwError && !bCRC && !bICV &&
type != IEEE80211_FTYPE_CTL && eqMacAddr(bssid, addr)) {
...
Also note that the whole if block is indented one too many tab stops.
Would be best to fix that in a separate patch though. If you fix that
first, then you will have more horizontal space to re-organise the
expression inside the if :-).
~Ryan
next prev parent reply other threads:[~2012-03-14 4:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-14 0:58 [PATCH] Staging: rtl8187se: r8180_core.c: Fix coding style issue Andrew Miller
2012-03-14 1:33 ` Joe Perches
2012-03-14 1:49 ` Andrew Miller
2012-03-14 2:12 ` Joe Perches
2012-03-14 2:33 ` Andrew Miller
2012-03-14 2:46 ` Joe Perches
2012-03-14 3:09 ` Larry Finger
2012-03-14 2:54 ` Greg KH
2012-03-14 4:18 ` Ryan Mallon [this message]
2012-03-14 4:49 ` Joe Perches
-- strict thread matches above, loose matches on Subject: below --
2012-03-11 4:32 Andrew Miller
2012-03-13 22:42 ` Greg KH
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=4F601C02.8070909@gmail.com \
--to=rmallon@gmail.com \
--cc=amiller@amilx.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=joe@perches.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox