staging: rtlwifi: rtl8822be: hw.c: Remove parentheses
PATCH 1/1 staging: rtlwifi: rtl8822be: hw.c: Remove parentheses
Remove unnecessary parentheses around right hand side of expression. Issue found with Coccinelle script:
@@expression e1, e2, e3;@@
(if(e1)
e2;
else
e3;
|
e1 =
-(
e2
-)
;
)
--- drivers/staging/rtlwifi/rtl8822be/hw.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/staging/rtlwifi/rtl8822be/hw.c +5 -5
@@ -243,7 +243,7 @@ static void _rtl8822be_fwlps_leave(struct ieee80211_hw *hw)u8 rpwm_val =0 , fw_pwrmode =FW_PS_ACTIVE_MODE ;if (ppsc->low_power_enable) { - rpwm_val = (FW_PS_STATE_ALL_ON_8822B |FW_PS_ACK );/* RF on */ + rpwm_val =FW_PS_STATE_ALL_ON_8822B |FW_PS_ACK ;/* RF on */ _rtl8822be_set_fw_clock_on (hw, rpwm_val, false); rtlhal->allow_sw_to_change_hwclc = false; rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_H2C_FW_PWRMODE,
@@ -474,7 +474,7 @@ void rtl8822be_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)rtl_write_byte (rtlpriv,REG_SECCFG_8822B , *((u8 *)val));break ;case HW_VAR_AMPDU_FACTOR : { -u32 ampdu_len = (*((u8 *)val)); +u32 ampdu_len = *((u8 *)val); ampdu_len = (0x2000 << ampdu_len) -1 ;rtl_write_dword (rtlpriv,REG_AMPDU_MAX_LENGTH_8822B , ampdu_len);
@@ -583,7 +583,7 @@ void rtl8822be_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)_rtl8822be_fwlps_leave (hw); }break ;case HW_VAR_H2C_FW_JOINBSSRPT : { -u8 mstatus = (*(u8 *)val); +u8 mstatus = *(u8 *)val;if (mstatus ==RT_MEDIA_CONNECT ) { rtlpriv->cfg->ops->set_hw_reg (hw,HW_VAR_AID ,NULL );
@@ -1912,7 +1912,7 @@ static void _rtl8822be_read_adapter_info(struct ieee80211_hw *hw)/*board type*/ rtlefuse->board_type = - (((*(u8 *)&hwinfo[EEPROM_RF_BOARD_OPTION_8822B ]) &0xE0 ) >>5 ); + ((*(u8 *)&hwinfo[EEPROM_RF_BOARD_OPTION_8822B ]) &0xE0 ) >>5 ;if ((*(u8 *)&hwinfo[EEPROM_RF_BOARD_OPTION_8822B ]) ==0xFF ) rtlefuse->board_type =0 ;
@@ -2406,7 +2406,7 @@ void rtl8822be_read_bt_coexist_info_from_hwpg(struct ieee80211_hw *hw, rtlpriv->btcoexist.btc_info.bt_type =BT_RTL8822B ; rtlpriv->btcoexist.btc_info.ant_num = - (value &BIT (0 ) ?ANT_TOTAL_X1 :ANT_TOTAL_X2 ); + value &BIT (0 ) ?ANT_TOTAL_X1 :ANT_TOTAL_X2 ; }else { rtlpriv->btcoexist.btc_info.bt_type =BT_RTL8822B ; rtlpriv->btcoexist.btc_info.ant_num =ANT_TOTAL_X2 ;
Signature · 1 line
2.19.1
Quoted 8 lines · Nishka Dasgupta' via outreachy-kernel
Remove unnecessary parentheses around right hand side of expression. Issue found with Coccinelle script:
@@expression e1, e2, e3;@@
(if(e1)
e2;
else
e3;
|
What is the purpose of the above code?
julia
Quoted 71 lines
e1 =
-(
e2
-)
;
)Signed-off-by Nishka Dasgupta <[email protected]>--- drivers/staging/rtlwifi/rtl8822be/hw.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/staging/rtlwifi/rtl8822be/hw.c +5
-6@@ -243,7 +243,7 @@ static void _rtl8822be_fwlps_leave(struct ieee80211_hw *hw)u8 rpwm_val =0 , fw_pwrmode =FW_PS_ACTIVE_MODE ;if (ppsc->low_power_enable) { - rpwm_val = (FW_PS_STATE_ALL_ON_8822B |FW_PS_ACK );/* RF on */ + rpwm_val =FW_PS_STATE_ALL_ON_8822B |FW_PS_ACK ;/* RF on */ _rtl8822be_set_fw_clock_on (hw, rpwm_val, false); rtlhal->allow_sw_to_change_hwclc = false; rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_H2C_FW_PWRMODE,@@ -474,7 +474,7 @@ void rtl8822be_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)rtl_write_byte (rtlpriv,REG_SECCFG_8822B , *((u8 *)val));break ;case HW_VAR_AMPDU_FACTOR : { -u32 ampdu_len = (*((u8 *)val)); +u32 ampdu_len = *((u8 *)val); ampdu_len = (0x2000 << ampdu_len) -1 ;rtl_write_dword (rtlpriv,REG_AMPDU_MAX_LENGTH_8822B , ampdu_len);@@ -583,7 +583,7 @@ void rtl8822be_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)_rtl8822be_fwlps_leave (hw); }break ;case HW_VAR_H2C_FW_JOINBSSRPT : { -u8 mstatus = (*(u8 *)val); +u8 mstatus = *(u8 *)val;if (mstatus ==RT_MEDIA_CONNECT ) { rtlpriv->cfg->ops->set_hw_reg (hw,HW_VAR_AID ,NULL );@@ -1912,7 +1912,7 @@ static void _rtl8822be_read_adapter_info(struct ieee80211_hw *hw)/*board type*/ rtlefuse->board_type = - (((*(u8 *)&hwinfo[EEPROM_RF_BOARD_OPTION_8822B ]) &0xE0 ) >>5 ); + ((*(u8 *)&hwinfo[EEPROM_RF_BOARD_OPTION_8822B ]) &0xE0 ) >>5 ;if ((*(u8 *)&hwinfo[EEPROM_RF_BOARD_OPTION_8822B ]) ==0xFF ) rtlefuse->board_type =0 ;@@ -2406,7 +2406,7 @@ void rtl8822be_read_bt_coexist_info_from_hwpg(struct ieee80211_hw *hw, rtlpriv->btcoexist.btc_info.bt_type =BT_RTL8822B ; rtlpriv->btcoexist.btc_info.ant_num = - (value &BIT (0 ) ?ANT_TOTAL_X1 :ANT_TOTAL_X2 ); + value &BIT (0 ) ?ANT_TOTAL_X1 :ANT_TOTAL_X2 ; }else { rtlpriv->btcoexist.btc_info.bt_type =BT_RTL8822B ; rtlpriv->btcoexist.btc_info.ant_num =ANT_TOTAL_X2 ; --2.19.1
--
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/20190402081946.22590-1-nishka.dasgupta%40yahoo.com.
For more options, visit https://groups.google.com/d/optout.
Quoted 14 lines · Julia Lawall
Quoted 8 lines · Nishka Dasgupta' via outreachy-kernel
Remove unnecessary parentheses around right hand side of expression. Issue found with Coccinelle script:
@@expression e1, e2, e3;@@
(if(e1)
e2;
else
e3;
|
Quoted 1 line
What is the purpose of the above code?
Without that if block, my cocci file was also flagging if-else blocks. This block does nothing if an if-else sequence is matched. After adding this, my .cocci file has only documented assignment statements as required.
- Nishka
Quoted 80 lines
julia
Quoted 64 lines
e1 =
-(
e2
-)
;
)Signed-off-by Nishka Dasgupta <[email protected]>--- drivers/staging/rtlwifi/rtl8822be/hw.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/staging/rtlwifi/rtl8822be/hw.c +5
-6@@ -243,7 +243,7 @@ static void _rtl8822be_fwlps_leave(struct ieee80211_hw *hw)u8 rpwm_val =0 , fw_pwrmode =FW_PS_ACTIVE_MODE ;if (ppsc->low_power_enable) { - rpwm_val = (FW_PS_STATE_ALL_ON_8822B |FW_PS_ACK );/* RF on */ + rpwm_val =FW_PS_STATE_ALL_ON_8822B |FW_PS_ACK ;/* RF on */ _rtl8822be_set_fw_clock_on (hw, rpwm_val, false); rtlhal->allow_sw_to_change_hwclc = false; rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_H2C_FW_PWRMODE,@@ -474,7 +474,7 @@ void rtl8822be_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)rtl_write_byte (rtlpriv,REG_SECCFG_8822B , *((u8 *)val));break ;case HW_VAR_AMPDU_FACTOR : { -u32 ampdu_len = (*((u8 *)val)); +u32 ampdu_len = *((u8 *)val); ampdu_len = (0x2000 << ampdu_len) -1 ;rtl_write_dword (rtlpriv,REG_AMPDU_MAX_LENGTH_8822B , ampdu_len);@@ -583,7 +583,7 @@ void rtl8822be_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)_rtl8822be_fwlps_leave (hw); }break ;case HW_VAR_H2C_FW_JOINBSSRPT : { -u8 mstatus = (*(u8 *)val); +u8 mstatus = *(u8 *)val;if (mstatus ==RT_MEDIA_CONNECT ) { rtlpriv->cfg->ops->set_hw_reg (hw,HW_VAR_AID ,NULL );@@ -1912,7 +1912,7 @@ static void _rtl8822be_read_adapter_info(struct ieee80211_hw *hw)/*board type*/ rtlefuse->board_type = - (((*(u8 *)&hwinfo[EEPROM_RF_BOARD_OPTION_8822B ]) &0xE0 ) >>5 ); + ((*(u8 *)&hwinfo[EEPROM_RF_BOARD_OPTION_8822B ]) &0xE0 ) >>5 ;if ((*(u8 *)&hwinfo[EEPROM_RF_BOARD_OPTION_8822B ]) ==0xFF ) rtlefuse->board_type =0 ;@@ -2406,7 +2406,7 @@ void rtl8822be_read_bt_coexist_info_from_hwpg(struct ieee80211_hw *hw, rtlpriv->btcoexist.btc_info.bt_type =BT_RTL8822B ; rtlpriv->btcoexist.btc_info.ant_num = - (value &BIT (0 ) ?ANT_TOTAL_X1 :ANT_TOTAL_X2 ); + value &BIT (0 ) ?ANT_TOTAL_X1 :ANT_TOTAL_X2 ; }else { rtlpriv->btcoexist.btc_info.bt_type =BT_RTL8822B ; rtlpriv->btcoexist.btc_info.ant_num =ANT_TOTAL_X2 ; --2.19.1
Quoted 7 lines
--
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/20190402081946.22590-1-nishka.dasgupta%40yahoo.com.
For more options, visit https://groups.google.com/d/optout.--
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/alpine.DEB.2.20.1904021151040.3297%40hadrien.
For more options, visit https://groups.google.com/d/optout.
Quoted 15 lines · Nishka Dasgupta
Quoted 14 lines · Julia Lawall
Quoted 8 lines · Nishka Dasgupta' via outreachy-kernel
Remove unnecessary parentheses around right hand side of expression. Issue found with Coccinelle script:
@@expression e1, e2, e3;@@
(if(e1)
e2;
else
e3;
|
Quoted 6 lines
Quoted 1 line
What is the purpose of the above code?
Without that if block, my cocci file was also flagging if-else blocks. This block does nothing if an if-else sequence is matched. After adding this, my .cocci file has only documented assignment statements as required.
Do you have a specific example? I don't see how the pattern below can have an impact on an entire if statement.It only matches an assignment.
julia
Quoted 90 lines
- Nishka
Quoted 66 lines
julia
Quoted 64 lines
e1 =
-(
e2
-)
;
)Signed-off-by Nishka Dasgupta <[email protected]>--- drivers/staging/rtlwifi/rtl8822be/hw.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/staging/rtlwifi/rtl8822be/hw.c +5
-6@@ -243,7 +243,7 @@ static void _rtl8822be_fwlps_leave(struct ieee80211_hw *hw)u8 rpwm_val =0 , fw_pwrmode =FW_PS_ACTIVE_MODE ;if (ppsc->low_power_enable) { - rpwm_val = (FW_PS_STATE_ALL_ON_8822B |FW_PS_ACK );/* RF on */ + rpwm_val =FW_PS_STATE_ALL_ON_8822B |FW_PS_ACK ;/* RF on */ _rtl8822be_set_fw_clock_on (hw, rpwm_val, false); rtlhal->allow_sw_to_change_hwclc = false; rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_H2C_FW_PWRMODE,@@ -474,7 +474,7 @@ void rtl8822be_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)rtl_write_byte (rtlpriv,REG_SECCFG_8822B , *((u8 *)val));break ;case HW_VAR_AMPDU_FACTOR : { -u32 ampdu_len = (*((u8 *)val)); +u32 ampdu_len = *((u8 *)val); ampdu_len = (0x2000 << ampdu_len) -1 ;rtl_write_dword (rtlpriv,REG_AMPDU_MAX_LENGTH_8822B , ampdu_len);@@ -583,7 +583,7 @@ void rtl8822be_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)_rtl8822be_fwlps_leave (hw); }break ;case HW_VAR_H2C_FW_JOINBSSRPT : { -u8 mstatus = (*(u8 *)val); +u8 mstatus = *(u8 *)val;if (mstatus ==RT_MEDIA_CONNECT ) { rtlpriv->cfg->ops->set_hw_reg (hw,HW_VAR_AID ,NULL );@@ -1912,7 +1912,7 @@ static void _rtl8822be_read_adapter_info(struct ieee80211_hw *hw)/*board type*/ rtlefuse->board_type = - (((*(u8 *)&hwinfo[EEPROM_RF_BOARD_OPTION_8822B ]) &0xE0 ) >>5 ); + ((*(u8 *)&hwinfo[EEPROM_RF_BOARD_OPTION_8822B ]) &0xE0 ) >>5 ;if ((*(u8 *)&hwinfo[EEPROM_RF_BOARD_OPTION_8822B ]) ==0xFF ) rtlefuse->board_type =0 ;@@ -2406,7 +2406,7 @@ void rtl8822be_read_bt_coexist_info_from_hwpg(struct ieee80211_hw *hw, rtlpriv->btcoexist.btc_info.bt_type =BT_RTL8822B ; rtlpriv->btcoexist.btc_info.ant_num = - (value &BIT (0 ) ?ANT_TOTAL_X1 :ANT_TOTAL_X2 ); + value &BIT (0 ) ?ANT_TOTAL_X1 :ANT_TOTAL_X2 ; }else { rtlpriv->btcoexist.btc_info.bt_type =BT_RTL8822B ; rtlpriv->btcoexist.btc_info.ant_num =ANT_TOTAL_X2 ; --2.19.1
Quoted 14 lines
Quoted 7 lines
--
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/20190402081946.22590-1-nishka.dasgupta%40yahoo.com.
For more options, visit https://groups.google.com/d/optout.--
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/alpine.DEB.2.20.1904021151040.3297%40hadrien.
For more options, visit https://groups.google.com/d/optout.--
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/CAC4%2B%2BKDCUWt832f%2B4R_Y-UDxe9HXeUf3m_N8QSCqLTr5Gd7Rvw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Quoted 21 lines · Julia Lawall
Quoted 17 lines · Nishka Dasgupta
Quoted 15 lines · Julia Lawall
Quoted 8 lines · Nishka Dasgupta' via outreachy-kernel
Remove unnecessary parentheses around right hand side of expression. Issue found with Coccinelle script:
@@expression e1, e2, e3;@@
(if(e1)
e2;
else
e3;
|What is the purpose of the above code?
Quoted 8 lines
Quoted 4 lines
Without that if block, my cocci file was also flagging if-else blocks. This block does nothing if an if-else sequence is matched. After adding this, my .cocci file has only documented assignment statements as required.
Do you have a specific example? I don't see how the pattern below can have an impact on an entire if statement.It only matches an assignment.
My mistake; a previous version of paren.cocci looked something like this:
@@expression e1, e2;@@
e1 =
- (e2);
+ e2;
This was highlighting if-else blocks in mt7621-spi; it does not appear to be doing so any more, so perhaps whatever was triggering that has been fixed? This previous version of paren.cocci also picks up on expressions that have been split across multiple lines, for some reason. What was I doing wrong with this patch?
- Nishka
Quoted 94 lines
julia
Quoted 90 lines
- Nishka
Quoted 66 lines
julia
Quoted 64 lines
e1 =
-(
e2
-)
;
)Signed-off-by Nishka Dasgupta <[email protected]>--- drivers/staging/rtlwifi/rtl8822be/hw.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/staging/rtlwifi/rtl8822be/hw.c +5
-6@@ -243,7 +243,7 @@ static void _rtl8822be_fwlps_leave(struct ieee80211_hw *hw)u8 rpwm_val =0 , fw_pwrmode =FW_PS_ACTIVE_MODE ;if (ppsc->low_power_enable) { - rpwm_val = (FW_PS_STATE_ALL_ON_8822B |FW_PS_ACK );/* RF on */ + rpwm_val =FW_PS_STATE_ALL_ON_8822B |FW_PS_ACK ;/* RF on */ _rtl8822be_set_fw_clock_on (hw, rpwm_val, false); rtlhal->allow_sw_to_change_hwclc = false; rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_H2C_FW_PWRMODE,@@ -474,7 +474,7 @@ void rtl8822be_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)rtl_write_byte (rtlpriv,REG_SECCFG_8822B , *((u8 *)val));break ;case HW_VAR_AMPDU_FACTOR : { -u32 ampdu_len = (*((u8 *)val)); +u32 ampdu_len = *((u8 *)val); ampdu_len = (0x2000 << ampdu_len) -1 ;rtl_write_dword (rtlpriv,REG_AMPDU_MAX_LENGTH_8822B , ampdu_len);@@ -583,7 +583,7 @@ void rtl8822be_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)_rtl8822be_fwlps_leave (hw); }break ;case HW_VAR_H2C_FW_JOINBSSRPT : { -u8 mstatus = (*(u8 *)val); +u8 mstatus = *(u8 *)val;if (mstatus ==RT_MEDIA_CONNECT ) { rtlpriv->cfg->ops->set_hw_reg (hw,HW_VAR_AID ,NULL );@@ -1912,7 +1912,7 @@ static void _rtl8822be_read_adapter_info(struct ieee80211_hw *hw)/*board type*/ rtlefuse->board_type = - (((*(u8 *)&hwinfo[EEPROM_RF_BOARD_OPTION_8822B ]) &0xE0 ) >>5 ); + ((*(u8 *)&hwinfo[EEPROM_RF_BOARD_OPTION_8822B ]) &0xE0 ) >>5 ;if ((*(u8 *)&hwinfo[EEPROM_RF_BOARD_OPTION_8822B ]) ==0xFF ) rtlefuse->board_type =0 ;@@ -2406,7 +2406,7 @@ void rtl8822be_read_bt_coexist_info_from_hwpg(struct ieee80211_hw *hw, rtlpriv->btcoexist.btc_info.bt_type =BT_RTL8822B ; rtlpriv->btcoexist.btc_info.ant_num = - (value &BIT (0 ) ?ANT_TOTAL_X1 :ANT_TOTAL_X2 ); + value &BIT (0 ) ?ANT_TOTAL_X1 :ANT_TOTAL_X2 ; }else { rtlpriv->btcoexist.btc_info.bt_type =BT_RTL8822B ; rtlpriv->btcoexist.btc_info.ant_num =ANT_TOTAL_X2 ; --2.19.1
Quoted 14 lines
Quoted 7 lines
--
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/20190402081946.22590-1-nishka.dasgupta%40yahoo.com.
For more options, visit https://groups.google.com/d/optout.--
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/alpine.DEB.2.20.1904021151040.3297%40hadrien.
For more options, visit https://groups.google.com/d/optout.--
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/CAC4%2B%2BKDCUWt832f%2B4R_Y-UDxe9HXeUf3m_N8QSCqLTr5Gd7Rvw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Quoted 38 lines · NIshka Dasgupta
Quoted 21 lines · Julia Lawall
Quoted 17 lines · Nishka Dasgupta
Quoted 15 lines · Julia Lawall
Quoted 8 lines · Nishka Dasgupta' via outreachy-kernel
Remove unnecessary parentheses around right hand side of expression. Issue found with Coccinelle script:
@@expression e1, e2, e3;@@
(if(e1)
e2;
else
e3;
|What is the purpose of the above code?
Quoted 8 lines
Quoted 4 lines
Without that if block, my cocci file was also flagging if-else blocks. This block does nothing if an if-else sequence is matched. After adding this, my .cocci file has only documented assignment statements as required.
Do you have a specific example? I don't see how the pattern below can have an impact on an entire if statement.It only matches an assignment.
My mistake; a previous version of
paren.coccilooked something like this:
@@expression e1, e2;@@
e1 =
- (e2);
+ e2;
Quoted 5 lines
This was highlighting if-else blocks in mt7621-spi; it does not appear to be doing so any more, so perhaps whatever was triggering that has been fixed? This previous version of
paren.coccialso picks up on expressions that have been split across multiple lines, for some reason.
What was I doing wrong with this patch?
Often you don't care about the details of parentheses, so if they are uniformly removed, Coccinelle also accepts the case where they simply aren't there. By putting the -( and -) on separate lines, with the unremoved code in the middle, you got around this issue, and it only changes the things that are desirable.
On the other hand, your original rule probably did a good job of solving 80 character problems :)
julia
Quoted 121 lines
- Nishka
Quoted 118 lines
julia
Quoted 114 lines
- Nishka
Quoted 93 lines
julia
Quoted 78 lines
e1 =
-(
e2
-)
;
)Signed-off-by Nishka Dasgupta <[email protected]>--- drivers/staging/rtlwifi/rtl8822be/hw.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/staging/rtlwifi/rtl8822be/hw.c +0
-1@@ -243,7 +243,7 @@ static void _rtl8822be_fwlps_leave(struct ieee80211_hw *hw) u8 rpwm_val = 0, fw_pwrmode = FW_PS_ACTIVE_MODE;if (ppsc->low_power_enable) { - rpwm_val = (FW_PS_STATE_ALL_ON_8822B |FW_PS_ACK );/* RF on */
+rpwm_val=FW_PS_STATE_ALL_ON_8822B|FW_PS_ACK; /* RF
on */_rtl8822be_set_fw_clock_on(hw, rpwm_val, false); rtlhal->allow_sw_to_change_hwclc = false; rtlpriv->cfg->ops->set_hw_reg(hw,
HW_VAR_H2C_FW_PWRMODE,drivers/staging/rtlwifi/rtl8822be/hw.c +1
-1@@ -474,7 +474,7 @@ void rtl8822be_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) rtl_write_byte(rtlpriv, REG_SECCFG_8822B, *((u8 *)val));break ;case HW_VAR_AMPDU_FACTOR : { -u32 ampdu_len = (*((u8 *)val)); +u32 ampdu_len = *((u8 *)val);ampdu_len = (0x2000 << ampdu_len) - 1; rtl_write_dword(rtlpriv, REG_AMPDU_MAX_LENGTH_8822B,
ampdu_len);drivers/staging/rtlwifi/rtl8822be/hw.c +1
-1@@ -583,7 +583,7 @@ void rtl8822be_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)_rtl8822be_fwlps_leave (hw ); }break ;case HW_VAR_H2C_FW_JOINBSSRPT : { -u8 mstatus = (*(u8 *)val); +u8 mstatus = *(u8 *)val;if (mstatus ==RT_MEDIA_CONNECT ) {rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AID,NULL);
drivers/staging/rtlwifi/rtl8822be/hw.c +1
-1@@ -1912,7 +1912,7 @@ static void _rtl8822be_read_adapter_info(struct ieee80211_hw *hw)/*board type*/ rtlefuse->board_type = - (((*(u8 *)&hwinfo[EEPROM_RF_BOARD_OPTION_8822B ]) &0xE0 ) >> 5); + ((*(u8 *)&hwinfo[EEPROM_RF_BOARD_OPTION_8822B ]) &0xE0 ) >>5 ;if ((*(u8 *)&hwinfo[EEPROM_RF_BOARD_OPTION_8822B]) == 0xFF) rtlefuse->board_type = 0;drivers/staging/rtlwifi/rtl8822be/hw.c +1
-1@@ -2406,7 +2406,7 @@ void rtl8822be_read_bt_coexist_info_from_hwpg(struct ieee80211_hw *hw, rtlpriv->btcoexist.btc_info.bt_type = BT_RTL8822B; rtlpriv->btcoexist.btc_info.ant_num = - (value &BIT (0 ) ?ANT_TOTAL_X1 :ANT_TOTAL_X2 ); + value &BIT (0 ) ?ANT_TOTAL_X1 :ANT_TOTAL_X2 ; }else { rtlpriv->btcoexist.btc_info.bt_type =BT_RTL8822B ;rtlpriv->btcoexist.btc_info.ant_num = ANT_TOTAL_X2;--
2.19.1Quoted 11 lines
--
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/20190402081946.22590-1-nishka.dasgupta%40yahoo.com.
For more options, visit https://groups.google.com/d/optout.--
Quoted 8 lines
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/alpine.DEB.2.20.1904021151040.3297%40hadrien.
For more options, visit https://groups.google.com/d/optout.--
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/CAC4%2B%2BKDCUWt832f%2B4R_Y-UDxe9HXeUf3m_N8QSCqLTr5Gd7Rvw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Quoted 48 lines · Julia Lawall
Quoted 38 lines · NIshka Dasgupta
Quoted 21 lines · Julia Lawall
Quoted 17 lines · Nishka Dasgupta
Quoted 15 lines · Julia Lawall
Quoted 8 lines · Nishka Dasgupta' via outreachy-kernel
Remove unnecessary parentheses around right hand side of expression. Issue found with Coccinelle script:
@@expression e1, e2, e3;@@
(if(e1)
e2;
else
e3;
|What is the purpose of the above code?
Quoted 8 lines
Quoted 4 lines
Without that if block, my cocci file was also flagging if-else blocks. This block does nothing if an if-else sequence is matched. After adding this, my .cocci file has only documented assignment statements as required.
Do you have a specific example? I don't see how the pattern below can have an impact on an entire if statement.It only matches an assignment.
My mistake; a previous version of
paren.coccilooked something like this:
@@expression e1, e2;@@
e1 =
- (e2);
+ e2;Quoted 5 lines
This was highlighting if-else blocks in mt7621-spi; it does not appear to be doing so any more, so perhaps whatever was triggering that has been fixed? This previous version of
paren.coccialso picks up on expressions that have been split across multiple lines, for some reason.
What was I doing wrong with this patch?
Quoted 8 lines
Often you don't care about the details of parentheses, so if they are uniformly removed, Coccinelle also accepts the case where they simply aren't there. By putting the -( and -) on separate lines, with the unremoved code in the middle, you got around this issue, and it only changes the things that are desirable.
On the other hand, your original rule probably did a good job of solving 80 character problems :)
I see. Thank you for the clarification!
- Nishka
Quoted 123 lines
julia
Quoted 121 lines
- Nishka
Quoted 118 lines
julia
Quoted 114 lines
- Nishka
Quoted 93 lines
julia
Quoted 78 lines
e1 =
-(
e2
-)
;
)Signed-off-by Nishka Dasgupta <[email protected]>--- drivers/staging/rtlwifi/rtl8822be/hw.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/staging/rtlwifi/rtl8822be/hw.c +0
-1@@ -243,7 +243,7 @@ static void _rtl8822be_fwlps_leave(struct ieee80211_hw *hw) u8 rpwm_val = 0, fw_pwrmode = FW_PS_ACTIVE_MODE;if (ppsc->low_power_enable) { - rpwm_val = (FW_PS_STATE_ALL_ON_8822B |FW_PS_ACK );/* RF on */
+rpwm_val=FW_PS_STATE_ALL_ON_8822B|FW_PS_ACK; /* RF
on */_rtl8822be_set_fw_clock_on(hw, rpwm_val, false); rtlhal->allow_sw_to_change_hwclc = false; rtlpriv->cfg->ops->set_hw_reg(hw,
HW_VAR_H2C_FW_PWRMODE,drivers/staging/rtlwifi/rtl8822be/hw.c +1
-1@@ -474,7 +474,7 @@ void rtl8822be_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) rtl_write_byte(rtlpriv, REG_SECCFG_8822B, *((u8 *)val));break ;case HW_VAR_AMPDU_FACTOR : { -u32 ampdu_len = (*((u8 *)val)); +u32 ampdu_len = *((u8 *)val);ampdu_len = (0x2000 << ampdu_len) - 1; rtl_write_dword(rtlpriv, REG_AMPDU_MAX_LENGTH_8822B,
ampdu_len);drivers/staging/rtlwifi/rtl8822be/hw.c +1
-1@@ -583,7 +583,7 @@ void rtl8822be_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)_rtl8822be_fwlps_leave (hw ); }break ;case HW_VAR_H2C_FW_JOINBSSRPT : { -u8 mstatus = (*(u8 *)val); +u8 mstatus = *(u8 *)val;if (mstatus ==RT_MEDIA_CONNECT ) {rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AID,NULL);
drivers/staging/rtlwifi/rtl8822be/hw.c +1
-1@@ -1912,7 +1912,7 @@ static void _rtl8822be_read_adapter_info(struct ieee80211_hw *hw)/*board type*/ rtlefuse->board_type = - (((*(u8 *)&hwinfo[EEPROM_RF_BOARD_OPTION_8822B ]) &0xE0 ) >> 5); + ((*(u8 *)&hwinfo[EEPROM_RF_BOARD_OPTION_8822B ]) &0xE0 ) >>5 ;if ((*(u8 *)&hwinfo[EEPROM_RF_BOARD_OPTION_8822B]) == 0xFF) rtlefuse->board_type = 0;drivers/staging/rtlwifi/rtl8822be/hw.c +1
-1@@ -2406,7 +2406,7 @@ void rtl8822be_read_bt_coexist_info_from_hwpg(struct ieee80211_hw *hw, rtlpriv->btcoexist.btc_info.bt_type = BT_RTL8822B; rtlpriv->btcoexist.btc_info.ant_num = - (value &BIT (0 ) ?ANT_TOTAL_X1 :ANT_TOTAL_X2 ); + value &BIT (0 ) ?ANT_TOTAL_X1 :ANT_TOTAL_X2 ; }else { rtlpriv->btcoexist.btc_info.bt_type =BT_RTL8822B ;rtlpriv->btcoexist.btc_info.ant_num = ANT_TOTAL_X2;--
2.19.1Quoted 11 lines
--
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/20190402081946.22590-1-nishka.dasgupta%40yahoo.com.
For more options, visit https://groups.google.com/d/optout.--
Quoted 8 lines
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/alpine.DEB.2.20.1904021151040.3297%40hadrien.
For more options, visit https://groups.google.com/d/optout.--
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/CAC4%2B%2BKDCUWt832f%2B4R_Y-UDxe9HXeUf3m_N8QSCqLTr5Gd7Rvw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.