staging: rtl8723bs: core: Refactor nested if-else
PATCH 1/1 staging: rtl8723bs: core: Refactor nested if-else
Refactor nested if else by combining nested if into a single if condition and removing unnecessary else conditionals which leads to removing unnecessary tabs .There is no change in logic of new code. checkpatch warning : Too many leading tabs - consider code refactoring
--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 65 ++++++++----------- 1 file changed, 26 insertions(+), 39 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +26 -39
@@ -1192,46 +1192,33 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) p = pframe +WLAN_HDR_A3_LEN + ie_offset; ie_len =0 ;for (;;) { p =rtw_get_ie (p,WLAN_EID_VENDOR_SPECIFIC , &ie_len, pkt_len -WLAN_HDR_A3_LEN - ie_offset); -if (p) { -if (!memcmp (p+2 ,WMM_IE ,6 )) { - - pstat->flags |=WLAN_STA_WME ; - - pstat->qos_option =1 ; - pstat->qos_info = *(p+8 ); - - pstat->max_sp_len = (pstat->qos_info>>5 )&0x3 ; - -if ((pstat->qos_info&0xf ) !=0xf ) - pstat->has_legacy_ac = true; -else - pstat->has_legacy_ac = false; - -if (pstat->qos_info&0xf ) { -if (pstat->qos_info&BIT (0 )) - pstat->uapsd_vo =BIT (0 )|BIT (1 ); -else - pstat->uapsd_vo =0 ; - -if (pstat->qos_info&BIT (1 )) - pstat->uapsd_vi =BIT (0 )|BIT (1 ); -else - pstat->uapsd_vi =0 ; - -if (pstat->qos_info&BIT (2 )) - pstat->uapsd_bk =BIT (0 )|BIT (1 ); -else - pstat->uapsd_bk =0 ; - -if (pstat->qos_info&BIT (3 )) - pstat->uapsd_be =BIT (0 )|BIT (1 ); -else - pstat->uapsd_be =0 ; - - } - -break ; +if (p && !memcmp (p+2 ,WMM_IE ,6 )) { + pstat->flags |=WLAN_STA_WME ; + pstat->qos_option =1 ; + pstat->qos_info = *(p+8 ); + pstat->max_sp_len = (pstat->qos_info>>5 )&0x3 ; + pstat->has_legacy_ac = false; +if ((pstat->qos_info&0xf ) !=0xf ) + pstat->has_legacy_ac = true; + + pstat->uapsd_vo =0 ; +if (pstat->qos_info&0xf ) { +if (pstat->qos_info&BIT (0 )) + pstat->uapsd_vo =BIT (0 )|BIT (1 ); + + pstat->uapsd_vi =0 ; +if (pstat->qos_info&BIT (1 )) + pstat->uapsd_vi =BIT (0 )|BIT (1 ); + + pstat->uapsd_bk =0 ; +if (pstat->qos_info&BIT (2 )) + pstat->uapsd_bk =BIT (0 )|BIT (1 ); + + pstat->uapsd_be =0 ; +if (pstat->qos_info&BIT (3 )) + pstat->uapsd_be =BIT (0 )|BIT (1 ); } +break ; }else {break ; }
Signature · 1 line
2.25.1
Greg KH
maintainerQuoted 1 line · Kushal Kothari
Refactor nested if else by combining nested if into a single if condition and removing unnecessary else conditionals which leads to removing unnecessary tabs .There is no change in logic of new code.
Very long line, please break it up at 72 columns.
And your space around the '.' is odd :(
Quoted 1 line
checkpatch warning : Too many leading tabs - consider code refactoring
What does this mean?
Quoted 6 lines
Signed-off-by Kushal Kothari <[email protected]>--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 65 ++++++++----------- 1 file changed, 26 insertions(+), 39 deletions(-)
thanks,
greg k-h
Quoted 3 lines
Very long line, please break it up at 72 columns.
And your space around the '.' is odd :(
Yes,fixing it.
Quoted 3 lines
Quoted 1 line
checkpatch warning : Too many leading tabs - consider code refactoring
What does this mean?
Asking about the warning ,correct?
The current code is using very deep indentations (which can be avoided) and due to this there are many leading tabs. So the checkpatch.pl warns of "Too many leading tabs - consider code refactoring"
<http://checkpatch.pl>
Quoted 24 lines · Greg KH
Quoted 1 line · Kushal Kothari
Refactor nested if else by combining nested if into a single if
condition and removing unnecessary else conditionals which leads to removing unnecessary tabs .There is no change in logic of new code.
Very long line, please break it up at 72 columns.
And your space around the '.' is odd :(
Quoted 1 line
checkpatch warning : Too many leading tabs - consider code refactoring
What does this mean?
Quoted 6 lines
Signed-off-by Kushal Kothari <[email protected]>--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 65 ++++++++----------- 1 file changed, 26 insertions(+), 39 deletions(-)thanks,
greg k-h
Quoted 6 lines · CEST kushal kothari
Quoted 3 lines
Very long line, please break it up at 72 columns.
And your space around the '.' is odd :(
Yes,fixing it.
^^^^^^^^^^^^^^^^^^^^
You are still using spaces the wrong way :)
English, as well as all natural languages that use Latin characters, use punctuation and a strict style that dictates how to use the spaces around it. Please read correctly written English texts, learn and use conventions
Thanks,
Fabio
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
checkpatch warning : Too many leading tabs - consider code refactoring
What does this mean?
Asking about the warning ,correct?
The current code is using very deep indentations (which can be avoided) and due to this there are many leading tabs. So the checkpatch.pl warns of
"Too
Quoted 30 lines
many leading tabs - consider code refactoring"
<http://checkpatch.pl>Quoted 24 lines · Greg KH
Quoted 1 line · Kushal Kothari
Refactor nested if else by combining nested if into a single if
condition and removing unnecessary else conditionals which leads to removing unnecessary tabs .There is no change in logic of new code.
Very long line, please break it up at 72 columns.
And your space around the '.' is odd :(
Quoted 1 line
checkpatch warning : Too many leading tabs - consider code refactoring
What does this mean?
Quoted 6 lines
Signed-off-by Kushal Kothari <[email protected]>--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 65 ++++++++----------- 1 file changed, 26 insertions(+), 39 deletions(-)thanks,
greg k-h
Quoted 4 lines
You are still using spaces the wrong way :)
English, as well as all natural languages that use Latin characters, use punctuation and a strict style that dictates how to use the spaces around
it.
Quoted 3 lines
Please read correctly written English texts, learn and use conventions
Thanks,
Sorry for my naive mistakes. I am taking extra care now when writing, so hopefully, I will not repeat this again.
Quoted 66 lines · Fabio M. De Francesco
Quoted 6 lines · CEST kushal kothari
Quoted 3 lines
Very long line, please break it up at 72 columns.
And your space around the '.' is odd :(
Yes,fixing it.
^^^^^^^^^^^^^^^^^^^^
You are still using spaces the wrong way :)
English, as well as all natural languages that use Latin characters, use punctuation and a strict style that dictates how to use the spaces around it.
Please read correctly written English texts, learn and use conventionsThanks,
Fabio
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
checkpatch warning : Too many leading tabs - consider code refactoring
What does this mean?
Asking about the warning ,correct?
The current code is using very deep indentations (which can be avoided)and
Quoted 1 line
due to this there are many leading tabs. So the checkpatch.pl warns of
"Too
Quoted 4 lines
many leading tabs - consider code refactoring"
<http://checkpatch.pl>On Mon, Oct 25, 2021 at 1:03 PM Greg KH <[email protected]>
Quoted 11 lines · wrote:
Quoted 11 lines · Kushal Kothari
Quoted 1 line
Refactor nested if else by combining nested if into a single if
condition and removing unnecessary else conditionals which leads to removing unnecessary tabs .There is no change in logic of new code.
Very long line, please break it up at 72 columns.
And your space around the '.' is odd :(
Quoted 1 line
checkpatch warning : Too many leading tabs - consider code
refactoring
Quoted 7 lines
Quoted 7 lines
What does this mean?
Quoted 4 lines
Signed-off-by Kushal Kothari <[email protected]>--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 65++++++++-----------
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
1 file changed, 26 insertions(+), 39 deletions(-)thanks,
greg k-h
Quoted 75 lines · Kushal Kothari
Refactor nested if else by combining nested if into a single if condition and removing unnecessary else conditionals which leads to removing unnecessary tabs .There is no change in logic of new code. checkpatch warning : Too many leading tabs - consider code refactoring
Signed-off-by Kushal Kothari <[email protected]>--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 65 ++++++++----------- 1 file changed, 26 insertions(+), 39 deletions(-)drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +20
-39@@ -1192,46 +1192,33 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) p = pframe +WLAN_HDR_A3_LEN + ie_offset; ie_len =0 ;for (;;) { p =rtw_get_ie (p,WLAN_EID_VENDOR_SPECIFIC , &ie_len, pkt_len -WLAN_HDR_A3_LEN - ie_offset); -if (p) { -if (!memcmp (p+2 ,WMM_IE ,6 )) { - - pstat->flags |=WLAN_STA_WME ; - - pstat->qos_option =1 ; - pstat->qos_info = *(p+8 ); - - pstat->max_sp_len = (pstat->qos_info>>5 )&0x3 ; - -if ((pstat->qos_info&0xf ) !=0xf ) - pstat->has_legacy_ac = true; -else - pstat->has_legacy_ac = false; - -if (pstat->qos_info&0xf ) { -if (pstat->qos_info&BIT (0 )) - pstat->uapsd_vo =BIT (0 )|BIT (1 ); -else - pstat->uapsd_vo =0 ; - -if (pstat->qos_info&BIT (1 )) - pstat->uapsd_vi =BIT (0 )|BIT (1 ); -else - pstat->uapsd_vi =0 ; - -if (pstat->qos_info&BIT (2 )) - pstat->uapsd_bk =BIT (0 )|BIT (1 ); -else - pstat->uapsd_bk =0 ; - -if (pstat->qos_info&BIT (3 )) - pstat->uapsd_be =BIT (0 )|BIT (1 ); -else - pstat->uapsd_be =0 ; - - } - -break ; +if (p && !memcmp (p+2 ,WMM_IE ,6 )) { + pstat->flags |=WLAN_STA_WME ; + pstat->qos_option =1 ; + pstat->qos_info = *(p+8 ); + pstat->max_sp_len = (pstat->qos_info>>5 )&0x3 ; + pstat->has_legacy_ac = false; +if ((pstat->qos_info&0xf ) !=0xf ) + pstat->has_legacy_ac = true; + + pstat->uapsd_vo =0 ; +if (pstat->qos_info&0xf ) { +if (pstat->qos_info&BIT (0 )) + pstat->uapsd_vo =BIT (0 )|BIT (1 ); + + pstat->uapsd_vi =0 ; +if (pstat->qos_info&BIT (1 )) + pstat->uapsd_vi =BIT (0 )|BIT (1 ); + + pstat->uapsd_bk =0 ; +if (pstat->qos_info&BIT (2 ))
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) · line 1224
Quoted 10 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +6
-0+ pstat->uapsd_bk =BIT (0 )|BIT (1 ); + + pstat->uapsd_be =0 ; +if (pstat->qos_info&BIT (3 )) + pstat->uapsd_be =BIT (0 )|BIT (1 ); } +break ; }else {break ; }
there is a bug here, if *p* is not null, and *memcmp* failed; then we fall in else part and break, and will miss the next entry in *p* using below statement
p = p + ie_len + 2;
Quoted 1 line
Regards,
~Praveen.
Quoted 1 line
there is a bug here, if *p* is not null, and *memcmp* failed; then we fall
in else part and break, and will miss the next entry in *p* using below
Quoted 3 lines
statement
p = p +
ie_len+ 2;
Yes! I missed this :( Thank you so much for pointing this out. I have fixed this in v2. Can you please have a look ?
Quoted 122 lines · Praveen Kumar
Quoted 1 line · Kushal Kothari
Refactor nested if else by combining nested if into a single if
condition and removing unnecessary else conditionals which leads to removing unnecessary tabs .There is no change in logic of new code.
Review
Quoted 8 lines
checkpatch warning : Too many leading tabs - consider code refactoring
Signed-off-by Kushal Kothari <[email protected]>--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 65 ++++++++----------- 1 file changed, 26 insertions(+), 39 deletions(-)(quoted diff) +0
-0
b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.cdrivers/staging/rtl8723bs/core/rtw_mlme_ext.c unsigned int OnAssocReq(struct adapter
Quoted 4 lines
index
0f82f5031c43..eb10b6f85426100644drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +0
-0@@ -1192,46 +1192,33 @@ unsigned int OnAssocReq(struct adapter*padapter, union
recv_frame*precv_frame)drivers/staging/rtl8723bs/core/rtw_mlme_ext.c unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
Quoted 3 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +0
-0p = pframe +WLAN_HDR_A3_LEN + ie_offset; ie_len =0 ;for (;;) { p = rtw_get_ie(p, WLAN_EID_VENDOR_SPECIFIC,
&ie_len,pkt_len-WLAN_HDR_A3_LEN-ie_offset);drivers/staging/rtl8723bs/core/rtw_mlme_ext.c unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
Quoted 9 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +0
-9-if (p) { -if (!memcmp (p+2 ,WMM_IE ,6 )) { - - pstat->flags |=WLAN_STA_WME ; - - pstat->qos_option =1 ; - pstat->qos_info = *(p+8 ); - - pstat->max_sp_len =(pstat->qos_info>>5)&0x3;
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
Quoted 3 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +0
-3- -if ((pstat->qos_info&0xf ) !=0xf ) - pstat->has_legacy_ac =true;
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c unsigned int OnAssocReq(struct adapter · line 1208
Quoted 2 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +0
-2-else - pstat->has_legacy_ac =false;
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
Quoted 4 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +0
-4- -if (pstat->qos_info&0xf ) { -if (pstat->qos_info&BIT (0 )) - pstat->uapsd_vo =BIT(0)|BIT(1);
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c unsigned int OnAssocReq(struct adapter · line 1214
Quoted 2 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +0
-2-else - pstat->uapsd_vo =0;
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
Quoted 3 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +0
-3- -if (pstat->qos_info&BIT (1 )) - pstat->uapsd_vi =BIT(0)|BIT(1);
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c unsigned int OnAssocReq(struct adapter · line 1219
Quoted 2 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +0
-2-else - pstat->uapsd_vi =0;
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
Quoted 3 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +0
-3- -if (pstat->qos_info&BIT (2 )) - pstat->uapsd_bk =BIT(0)|BIT(1);
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c unsigned int OnAssocReq(struct adapter · line 1224
Quoted 2 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +0
-2-else - pstat->uapsd_bk =0;
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
Quoted 3 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +0
-3- -if (pstat->qos_info&BIT (3 )) - pstat->uapsd_be =BIT(0)|BIT(1);
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c unsigned int OnAssocReq(struct adapter · line 1229
Quoted 2 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +0
-2-else - pstat->uapsd_be =0;
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
Quoted 9 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +5
-4- - } - -break ; +if (p && !memcmp (p+2 ,WMM_IE ,6 )) { + pstat->flags |=WLAN_STA_WME ; + pstat->qos_option =1 ; + pstat->qos_info = *(p+8 ); + pstat->max_sp_len =(pstat->qos_info>>5)&0x3;
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
Quoted 8 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +8
-0+ pstat->has_legacy_ac = false; +if ((pstat->qos_info&0xf ) !=0xf ) + pstat->has_legacy_ac = true; + + pstat->uapsd_vo =0 ; +if (pstat->qos_info&0xf ) { +if (pstat->qos_info&BIT (0 )) + pstat->uapsd_vo =BIT(0)|BIT(1);
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
Quoted 4 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +4
-0+ + pstat->uapsd_vi =0 ; +if (pstat->qos_info&BIT (1 )) + pstat->uapsd_vi =BIT(0)|BIT(1);
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
Quoted 4 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +4
-0+ + pstat->uapsd_bk =0 ; +if (pstat->qos_info&BIT (2 )) + pstat->uapsd_bk =BIT(0)|BIT(1);
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
Quoted 4 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +4
-0+ + pstat->uapsd_be =0 ; +if (pstat->qos_info&BIT (3 )) + pstat->uapsd_be =BIT(0)|BIT(1);
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) · line 1224
Quoted 5 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +1
-0} +break ; }else {break ; }there is a bug here, if *p* is not null, and *memcmp* failed; then we fall in else part and break, and will miss the next entry in *p* using below statement
p = p +
ie_len+ 2;Quoted 1 line
Regards,
~Praveen.