Skip to contentSkip to conversation

Staging: rtl8187se: r8180_core.c: Fix coding style issue

PATCH In review Andrew Miller 5 participants 10 messages Mar 14, 2012 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: rtl8187se: r8180_core.c: Fix coding style issue

Fix long line coding style issue

---
 drivers/staging/rtl8187se/r8180_core.c |   32 ++++++++++++++++++++------------
 1 files changed, 20 insertions(+), 12 deletions(-)
drivers/staging/rtl8187se/r8180_core.c +20 -12
index 04c2391..9ef78f0 100644
@@ -1392,11 +1392,13 @@ void PerformUndecoratedSignalSmoothing8185(struct r8180_priv *priv,
 	priv->bCurCCKPkt = bCckRate;
 
 	if (priv->UndecoratedSmoothedSS >= 0)
-		priv->UndecoratedSmoothedSS = ((priv->UndecoratedSmoothedSS * 5) + (priv->SignalStrength * 10)) / 6;
+		priv->UndecoratedSmoothedSS = ((priv->UndecoratedSmoothedSS * 5) +
+					      (priv->SignalStrength * 10)) / 6;
 	else
 		priv->UndecoratedSmoothedSS = priv->SignalStrength * 10;
 
-	priv->UndercorateSmoothedRxPower = ((priv->UndercorateSmoothedRxPower * 50) + (priv->RxPower * 11)) / 60;
+	priv->UndercorateSmoothedRxPower = ((priv->UndercorateSmoothedRxPower * 50) +
+	                                   (priv->RxPower * 11)) / 60;
 
 	if (bCckRate)
 		priv->CurCCKRSSI = priv->RSSI;
@@ -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);
 		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)) {
 				/* Perform signal smoothing for dynamic
 				 * mechanism on demand. This is different
 				 * with PerformSignalSmoothing8185 in smoothing
@@ -2112,7 +2117,7 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority,
 		/* Use short preamble or not */
 		if (priv->ieee80211->current_network.capability&WLAN_CAPABILITY_SHORT_PREAMBLE)
 			if (priv->plcp_preamble_mode == 1 && rate != 0)	/*  short mode now, not long! */
-			; /* *tail |= (1<<16); */				/* enable short preamble mode. */
+			; /* *tail |= (1<<16); */			/* enable short preamble mode. */
 
 		if (bCTSEnable)
 			*tail |= (1<<18);
@@ -2325,8 +2330,9 @@ void rtl8180_hw_sleep(struct net_device *dev, u32 th, u32 tl)
 		u32 tmp = (tl > rb) ? (tl-rb) : (rb-tl);
 
 		priv->DozePeriodInPast2Sec += jiffies_to_msecs(tmp);
-
-		queue_delayed_work(priv->ieee80211->wq, &priv->ieee80211->hw_wakeup_wq, tmp); /* as tl may be less than rb */
+		
+		/* as tl may be less than rb */
+		queue_delayed_work(priv->ieee80211->wq, &priv->ieee80211->hw_wakeup_wq, tmp);
 	}
 	/* 
 	 * If we suspect the TimerInt is gone beyond tl
@@ -3227,7 +3233,8 @@ void LeisurePSEnter(struct r8180_priv *priv)
 {
 	if (priv->bLeisurePs) {
 		if (priv->ieee80211->ps == IEEE80211_PS_DISABLED)
-			MgntActSet_802_11_PowerSaveMode(priv, IEEE80211_PS_MBCAST|IEEE80211_PS_UNICAST); /* IEEE80211_PS_ENABLE */
+			/* IEEE80211_PS_ENABLE */
+			MgntActSet_802_11_PowerSaveMode(priv, IEEE80211_PS_MBCAST|IEEE80211_PS_UNICAST);
 	}
 }
 
@@ -3299,7 +3306,8 @@ void rtl8180_watch_dog(struct net_device *dev)
 	u16 SlotIndex = 0;
 	u16 i = 0;
 	if (priv->ieee80211->actscanning == false) {
-		if ((priv->ieee80211->iw_mode != IW_MODE_ADHOC) && (priv->ieee80211->state == IEEE80211_NOLINK) && (priv->ieee80211->beinretry == false) && (priv->eRFPowerState == eRfOn))
+		if ((priv->ieee80211->iw_mode != IW_MODE_ADHOC) && (priv->ieee80211->state ==
+		    IEEE80211_NOLINK) && (priv->ieee80211->beinretry == false) && (priv->eRFPowerState == eRfOn))
 			IPSEnter(dev);
 	}
 	/* YJ,add,080828,for link state check */
Signature · 1 line
1.7.7.6
#1 lore raw
Quoted 2 lines · Andrew Miller

Fix long line coding style issue

Hi Andrew.

Please strive for clarity instead of just fixing
random 80 char warnings.

drivers/staging/rtl8187se/r8180_core.c

Quoted 1 line
drivers/staging/rtl8187se/r8180_core.c +0 -0

[]

drivers/staging/rtl8187se/r8180_core.c void rtl8180_rx(struct net_device *dev) · line 1616

Quoted 11 lines
drivers/staging/rtl8187se/r8180_core.c +5 -2
@@ -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 ||

drivers/staging/rtl8187se/r8180_core.c void rtl8180_rx(struct net_device *dev) · line 1625

Quoted 12 lines
drivers/staging/rtl8187se/r8180_core.c +3 -3
 		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)

It might be better to reshuffle the test order too:

			if (IEEE80211_FTYPE_CTL != type &&
			   !bHwError && bCRC && !bICV &&
			    eqMacAddr(priv->ieee80211->current_network.bssid,
				      fc & IEEE80211_FCTL_TODS ? hdr->addr1 :
				      fc & IEEE80211_FCTL_FROMDS ? hdr->addr2 :
				      hdr->addr3))

etc...

#2 lore raw
Quoted 3 lines · Joe Perches
Quoted 2 lines · Andrew Miller

Fix long line coding style issue

Thanks for the review

I think I starting to get the idea of what I need to be looking for.

Quoted 8 lines

Hi Andrew.

Please strive for clarity instead of just fixing
random 80 char warnings.

drivers/staging/rtl8187se/r8180_core.c

Quoted 1 line
drivers/staging/rtl8187se/r8180_core.c +0 -0

[]

Quoted 13 lines

drivers/staging/rtl8187se/r8180_core.c void rtl8180_rx(struct net_device *dev) · line 1616

Quoted 11 lines
drivers/staging/rtl8187se/r8180_core.c +5 -2
@@ -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 ||

I'm not really sure what you mean, do you mean I should change '|' to '||"? like this

           bHwError = (((*(priv->rxringtail)) & (0x00000fff)) == 4080) ||
                      (((*(priv->rxringtail)) & (0x04000000)) != 0) ||
                      (((*(priv->rxringtail)) & (0x08000000)) != 0) ||
                      (((~(*(priv->rxringtail))) & (0x10000000)) != 0) ||
                      (((~(*(priv->rxringtail))) & (0x20000000)) != 0);
Quoted 28 lines

drivers/staging/rtl8187se/r8180_core.c void rtl8180_rx(struct net_device *dev) · line 1625

Quoted 13 lines
drivers/staging/rtl8187se/r8180_core.c +3 -3
 		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)

It might be better to reshuffle the test order too:

Quoted 8 lines
			if (IEEE80211_FTYPE_CTL != type &&
			   !bHwError && bCRC && !bICV &&
			    eqMacAddr(priv->ieee80211->current_network.bssid,
				      fc & IEEE80211_FCTL_TODS ? hdr->addr1 :
				      fc & IEEE80211_FCTL_FROMDS ? hdr->addr2 :
				      hdr->addr3))

etc...

That does look much cleaner, It never occurred to me that I can do that.

Thanks for your help, I'm really trying to do better, I will have this fix up tomorrow for another review.

#3 lore raw
Quoted 20 lines · Andrew Miller
Quoted 7 lines · Joe Perches
Quoted 2 lines · Andrew Miller

Fix long line coding style issue

Please strive for clarity instead of just fixing
random 80 char warnings.

drivers/staging/rtl8187se/r8180_core.c

Quoted 1 line
drivers/staging/rtl8187se/r8180_core.c +0 -0

[]

Quoted 12 lines

drivers/staging/rtl8187se/r8180_core.c void rtl8180_rx(struct net_device *dev) · line 1616

Quoted 11 lines
drivers/staging/rtl8187se/r8180_core.c +5 -2
@@ -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 ||

Quoted 7 lines

I'm not really sure what you mean, do you mean I should change '|' to '||"? like this

           bHwError = (((*(priv->rxringtail)) & (0x00000fff)) == 4080) ||
                      (((*(priv->rxringtail)) & (0x04000000)) != 0) ||
                      (((*(priv->rxringtail)) & (0x08000000)) != 0) ||
                      (((~(*(priv->rxringtail))) & (0x10000000)) != 0) ||
                      (((~(*(priv->rxringtail))) & (0x20000000)) != 0);

Yes.

If this bit of code is especially performance sensitive, there are times when using | instead of || can be an overall speed improvement. I haven't looked at this code before so I don't know what's appropriate here but using || might be more sensible though possibly slower.

Quoted 9 lines
Quoted 8 lines

It might be better to reshuffle the test order too:

			if (IEEE80211_FTYPE_CTL != type &&
			   !bHwError && bCRC && !bICV &&
			    eqMacAddr(priv->ieee80211->current_network.bssid,
				      fc & IEEE80211_FCTL_TODS ? hdr->addr1 :
				      fc & IEEE80211_FCTL_FROMDS ? hdr->addr2 :
				      hdr->addr3))

etc...

That does look much cleaner, It never occurred to me that I can do that.

Feel empowered to make the code better. Do what's right. Don't just correct mindless checkpatch error messages.

cheers, Joe

#4 lore raw

Thanks, you help me alot

If you don't mind me asking a few more question.

Would fixing things like this

- if(x==y)
+ if(x == y)

be worthless?
Changing c++ style comment to c style?
And I should not wory about line being longer the 80 charactor, unless they are just extremely long?

I'm just over half way through my CS degree, so I'm a complete noob. I'm still learning what is not worth spending time on and what is.

Quoted 51 lines · Joe Perches
Quoted 20 lines · Andrew Miller
Quoted 7 lines · Joe Perches
Quoted 2 lines · Andrew Miller

Fix long line coding style issue

Please strive for clarity instead of just fixing
random 80 char warnings.

drivers/staging/rtl8187se/r8180_core.c

Quoted 1 line
drivers/staging/rtl8187se/r8180_core.c +0 -0

[]

Quoted 12 lines

drivers/staging/rtl8187se/r8180_core.c void rtl8180_rx(struct net_device *dev) · line 1616

Quoted 11 lines
drivers/staging/rtl8187se/r8180_core.c +5 -2
@@ -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 ||

Quoted 7 lines

I'm not really sure what you mean, do you mean I should change '|' to '||"? like this

           bHwError = (((*(priv->rxringtail)) & (0x00000fff)) == 4080) ||
                      (((*(priv->rxringtail)) & (0x04000000)) != 0) ||
                      (((*(priv->rxringtail)) & (0x08000000)) != 0) ||
                      (((~(*(priv->rxringtail))) & (0x10000000)) != 0) ||
                      (((~(*(priv->rxringtail))) & (0x20000000)) != 0);

Yes.

If this bit of code is especially performance sensitive, there are times when using | instead of || can be an overall speed improvement. I haven't looked at this code before so I don't know what's appropriate here but using || might be more sensible though possibly slower.

Quoted 9 lines
Quoted 8 lines

It might be better to reshuffle the test order too:

			if (IEEE80211_FTYPE_CTL != type &&
			   !bHwError && bCRC && !bICV &&
			    eqMacAddr(priv->ieee80211->current_network.bssid,
				      fc & IEEE80211_FCTL_TODS ? hdr->addr1 :
				      fc & IEEE80211_FCTL_FROMDS ? hdr->addr2 :
				      hdr->addr3))

etc...

That does look much cleaner, It never occurred to me that I can do that.

Feel empowered to make the code better. Do what's right. Don't just correct mindless checkpatch error messages.

cheers, Joe

#5 lore raw
Quoted 10 lines · Andrew Miller

Thanks, you help me alot

If you don't mind me asking a few more question.

Would fixing things like this

- if(x==y)
+ if(x == y)

be worthless?

I don't work on staging code.

I believe the staging rtl8187se directory could be deleted as there is a working mainline directory for the 8187 (drivers/net/wireless/rtl818x/rtl8187) so you may not actually be adding anything of value.

I don't know if the 8187se is supported by the 8187 code but likely Larry Finger (cc'd) knows better.

maintainer
#7 lore raw
In reply to Andrew Miller
Quoted 10 lines · Andrew Miller

Thanks, you help me alot

If you don't mind me asking a few more question.

Would fixing things like this

- if(x==y)
+ if(x == y)

be worthless?

Yes, as it should really be:

	if (x == y)

:)

Quoted 1 line

Changing c++ style comment to c style?

That's also good.

Quoted 2 lines

And I should not wory about line being longer the 80 charactor, unless they are just extremely long?

If you feel it will read better, than yes, do it.

Quoted 2 lines

I'm just over half way through my CS degree, so I'm a complete noob. I'm still learning what is not worth spending time on and what is.

This is worthwhile, if you want to do this. Cleanups like this are a great place to learn and get involved and become comfortable with the codebase.

Just don't mix different fixes in the same patch.

And don't top post :)

thanks,

greg k-h

#6 lore raw
In reply to Joe Perches
Quoted 14 lines · Joe Perches
Quoted 10 lines · Andrew Miller

Thanks, you help me alot

If you don't mind me asking a few more question.

Would fixing things like this

- if(x==y)
+ if(x == y)

be worthless?

I don't work on staging code.

Quoted 7 lines

I believe the staging rtl8187se directory could be deleted as there is a working mainline directory for the 8187 (drivers/net/wireless/rtl818x/rtl8187) so you may not actually be adding anything of value.

I don't know if the 8187se is supported by the 8187 code but likely Larry Finger (cc'd) knows better.

Driver rtl8187 handles USB devices - the RTL8187SE is PCI based - thus separate drivers are needed. I have done a lot of the conversion of a mac80211-based driver for the RTL8187SE, but ran into a problem where it could transmit small packets, but fail completely for longer ones. While trying to fix that, I needed to work on devices that had no Linux driver, and I have not gotten back to it.

Larry

#8 lore raw
In reply to Joe Perches
Quoted 42 lines · Joe Perches
Quoted 2 lines · Andrew Miller

Fix long line coding style issue

Hi Andrew.

Please strive for clarity instead of just fixing
random 80 char warnings.

drivers/staging/rtl8187se/r8180_core.c

Quoted 1 line
drivers/staging/rtl8187se/r8180_core.c +0 -0

[]

drivers/staging/rtl8187se/r8180_core.c void rtl8180_rx(struct net_device *dev) · line 1616

Quoted 11 lines
drivers/staging/rtl8187se/r8180_core.c +5 -2
@@ -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 ||

drivers/staging/rtl8187se/r8180_core.c void rtl8180_rx(struct net_device *dev) · line 1625

Quoted 12 lines
drivers/staging/rtl8187se/r8180_core.c +3 -3
 		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:

Quoted 8 lines
			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

#9 lore raw
Quoted 18 lines · Ryan Mallon

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)) {
		...
Quoted 4 lines

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 :-).

Yeah, what Ryan said. Clarity is good. You might separate the addr and bssid declarations into 2 lines though...