staging: rtl8192u: Remove ternary operator
PATCH v3 1/1 staging: rtl8192u: Remove ternary operator
Relational and logical operators evaluate to either true or false. Lines with ternary operators were found using coccinelle script. In a few cases using logical && operator would suffice. Hence those were changed to improve readability.
Coccinelle Script:
@r@
expression A,B;
symbol true,false;
binary operator b = {==,!=,&&,||,>=,<=,>,<};
@@
- (A b B) ? true : false
+ A b B
----
Changes in v3:
- Converted ? operator to &&.
Changes in v2:
- Converted ? operator to if else statements.
--- drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +4 -4
@@ -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 ); pHTInfo->bCurShortGI40MHz= - ((pHTInfo->bRegShortGI40MHz)?((pPeerHTCap->ShortGI40Mhz==1 )?true:false):false); + pHTInfo->bRegShortGI40MHz && (pPeerHTCap->ShortGI40Mhz ==1 );// // 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 );//
Signature · 1 line
2.7.4
Quoted 29 lines · Gargi Sharma
Relational and logical operators evaluate to either true or false. Lines with ternary operators were found using coccinelle script. In a few cases using logical && operator would suffice. Hence those were changed to improve readability.
Coccinelle Script:
@r@
expression A,B;
symbol true,false;
binary operator b = {==,!=,&&,||,>=,<=,>,<};
@@
- (A b B) ? true : false
+ A b BSigned-off-by Gargi Sharma <[email protected]>----
Changes in v3:
- Converted ? operator to &&.
Changes in v2:
- Converted ? operator to if else statements.--- drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +0
-0
drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c void HTOnAssocRsp(struct ieee80211_device *ieee) · line 980
Quoted 5 lines
drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +1
-1@@ -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 );
This appears to be one character too long. Since these statements are all similar and you have a newline in the others, you could put a newline for this one too.
drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c void HTOnAssocRsp(struct ieee80211_device *ieee) · line 989
Quoted 11 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 ); pHTInfo->bCurShortGI40MHz= - ((pHTInfo->bRegShortGI40MHz)?((pPeerHTCap->ShortGI40Mhz==1 )?true:false):false); + pHTInfo->bRegShortGI40MHz && (pPeerHTCap->ShortGI40Mhz ==1 );
It would be nice to straighten up the assignment overall and add a space before the =.
julia
Quoted 21 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 );// --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/1487567108-6362-1-git-send-email-gs051095%40gmail.com.
For more options, visit https://groups.google.com/d/optout.