Skip to contentSkip to conversation

staging: rtl8192u: Remove ternary operator

PATCH In review Gargi Sharma 2 participants 4 messages Feb 19, 2017 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: rtl8192u: Remove ternary operator

Relational and logical operators evaluate to either true or false. Explicit conversion is not needed so remove the ternary operator. Done using coccinelle:

@r@
expression A,B;
symbol true,false;
binary operator b = {==,!=,&&,||,>=,<=,>,<};
@@
- (A b B) ? true : false
+ A b B

---
 drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +4 -4
index c27397b..8faa3d6 100644
@@ -977,16 +977,16 @@ void HTOnAssocRsp(struct ieee80211_device *ieee)
 	HTSetConnectBwMode(ieee, (HT_CHANNEL_WIDTH)(pPeerHTCap->ChlWidth), (HT_EXTCHNL_OFFSET)(pPeerHTInfo->ExtChlOffset));
 
 //	if (pHTInfo->bCurBW40MHz)
-		pHTInfo->bCurTxBW40MHz = ((pPeerHTInfo->RecommemdedTxWidth == 1)?true:false);
+		pHTInfo->bCurTxBW40MHz = (pPeerHTInfo->RecommemdedTxWidth == 1);
 
 	//
 	// Update short GI/ long GI setting
 	//
 	// TODO:
 	pHTInfo->bCurShortGI20MHz=
-		((pHTInfo->bRegShortGI20MHz)?((pPeerHTCap->ShortGI20Mhz==1)?true:false):false);
+		((pHTInfo->bRegShortGI20MHz)?(pPeerHTCap->ShortGI20Mhz == 1):false);
 	pHTInfo->bCurShortGI40MHz=
-		((pHTInfo->bRegShortGI40MHz)?((pPeerHTCap->ShortGI40Mhz==1)?true:false):false);
+		((pHTInfo->bRegShortGI40MHz)?(pPeerHTCap->ShortGI40Mhz == 1):false);
 
 	//
 	// Config TX STBC setting
@@ -998,7 +998,7 @@ void HTOnAssocRsp(struct ieee80211_device *ieee)
 	//
 	// TODO:
 	pHTInfo->bCurSuppCCK =
-		((pHTInfo->bRegSuppCCK)?((pPeerHTCap->DssCCk==1)?true:false):false);
+		((pHTInfo->bRegSuppCCK)?(pPeerHTCap->DssCCk == 1):false);
 
 
 	//
Signature · 1 line
2.7.4
#1 lore raw
Quoted 28 lines · Gargi Sharma

Relational and logical operators evaluate to either true or false. Explicit conversion is not needed so remove the ternary operator. Done using coccinelle:

@r@
expression A,B;
symbol true,false;
binary operator b = {==,!=,&&,||,>=,<=,>,<};
@@
- (A b B) ? true : false
+ A b B

---
 drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +1 -1
index c27397b..8faa3d6 100644
@@ -977,16 +977,16 @@ void HTOnAssocRsp(struct ieee80211_device *ieee)
 	HTSetConnectBwMode(ieee, (HT_CHANNEL_WIDTH)(pPeerHTCap->ChlWidth), (HT_EXTCHNL_OFFSET)(pPeerHTInfo->ExtChlOffset));
 
 //	if (pHTInfo->bCurBW40MHz)
-		pHTInfo->bCurTxBW40MHz = ((pPeerHTInfo->RecommemdedTxWidth == 1)?true:false);
+		pHTInfo->bCurTxBW40MHz = (pPeerHTInfo->RecommemdedTxWidth == 1);
 

drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c void HTOnAssocRsp(struct ieee80211_device *ieee) · line 989

Quoted 10 lines
drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +2 -2
 	//
 	// Update short GI/ long GI setting
 	//
 	// TODO:
 	pHTInfo->bCurShortGI20MHz=
-		((pHTInfo->bRegShortGI20MHz)?((pPeerHTCap->ShortGI20Mhz==1)?true:false):false);
+		((pHTInfo->bRegShortGI20MHz)?(pPeerHTCap->ShortGI20Mhz == 1):false);
 	pHTInfo->bCurShortGI40MHz=
-		((pHTInfo->bRegShortGI40MHz)?((pPeerHTCap->ShortGI40Mhz==1)?true:false):false);
+		((pHTInfo->bRegShortGI40MHz)?(pPeerHTCap->ShortGI40Mhz == 1):false);

Maybe an if would be better in cases like this where there is still something to test.

julia

Quoted 22 lines
drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +1 -2
 	//
 	// Config TX STBC setting
@@ -998,7 +998,7 @@ void HTOnAssocRsp(struct ieee80211_device *ieee)
 	//
 	// TODO:
 	pHTInfo->bCurSuppCCK =
-		((pHTInfo->bRegSuppCCK)?((pPeerHTCap->DssCCk==1)?true:false):false);
+		((pHTInfo->bRegSuppCCK)?(pPeerHTCap->DssCCk == 1):false);
 
 
 	//
--

2.7.4

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1487530938-17297-1-git-send-email-gs051095%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw
Quoted 2 lines

Maybe an if would be better in cases like this where there is still something to test.

So I should replace the ? operator with an if statement for better readability?

thanks,
gargi

Quoted 11 lines

julia

drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c void HTOnAssocRsp(struct ieee80211_device *ieee) · line 1001

Quoted 8 lines
      //
      // Config TX STBC setting
drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +0 -1
@@ -998,7 +998,7 @@ void HTOnAssocRsp(struct ieee80211_device *ieee)
      //
      // TODO:
      pHTInfo->bCurSuppCCK =
-             ((pHTInfo->bRegSuppCCK)?((pPee

rHTCap->DssCCk==1)?true:false):false);

Quoted 9 lines
Quoted 9 lines
drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +1 -1
+             ((pHTInfo->bRegSuppCCK)?(pPeerHTCap->DssCCk == 1):false);
 
 
      //
--

2.7.4

--
You received this message because you are subscribed to the Google

Groups "outreachy-kernel" group.

Quoted 1 line
Quoted 1 line

To unsubscribe from this group and stop receiving emails from it, send

an email to [email protected].

Quoted 2 lines
Quoted 2 lines

To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/ms

gid/outreachy-kernel/1487530938-17297-1-git-send-email-gs051095%40gmail.com.

Quoted 2 lines
Quoted 2 lines

For more options, visit https://groups.google.com/d/optout.

#3 lore raw
Quoted 5 lines · Gargi Sharma
Quoted 3 lines

Maybe an if would be better in cases like this where there is still something to test.

So I should replace the ? operator with an if statement for better readability?

I don't know if it is a hard and fast rule, but here where the lines are too long (and the variable names are too long also :), I think that an if would look nicer.

julia

Quoted 34 lines

thanks,
gargi

Quoted 11 lines

julia

Quoted 8 lines

ᅵ ᅵ ᅵ //
ᅵ ᅵ ᅵ // Config TX STBC setting

(quoted diff) +0 -0
@@ -998,7 +998,7 @@ void HTOnAssocRsp(struct ieee80211_device *ieee)

ᅵ ᅵ ᅵ //
ᅵ ᅵ ᅵ // TODO:
ᅵ ᅵ ᅵ pHTInfo->bCurSuppCCK =
- ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ

((pHTInfo->bRegSuppCCK)?((pPeerHTCap->DssCCk==1)?true:false):false);

Quoted 9 lines
Quoted 9 lines

+ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ((pHTInfo->bRegSuppCCK)?(pPeerHTCap->DssCCk == 1):false);

ᅵ ᅵ ᅵ //
--
2.7.4

--
You received this message because you are subscribed to the Google

Groups "outreachy-kernel" group.

Quoted 1 line
Quoted 1 line

To unsubscribe from this group and stop receiving emails from it, send

an email to [email protected].

Quoted 2 lines
Quoted 2 lines

To post to this group, send email to [email protected].
To view this discussion on the web visithttps://groups.google.com/d/msgid/outreachy-kernel/1487530938-17297-1-git-s

end-email-gs051095%40gmail.com.

Quoted 2 lines
Quoted 2 lines

For more options, visit https://groups.google.com/d/optout.