Unnecessary code cleanup patches
Subsystems (4)
cover Unnecessary code cleanup patches
The patchset modifies unnecessary duplicate NULL test on a value in an expression, when the value has been NULL tested in a previous expression.
Abraham Samuel Adekunle (2):
staging: media: Remove NULL test on an already tested value
staging: rtl8723bs: Prevent duplicate NULL tests on a value
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 2 +- drivers/staging/media/av7110/sp8870.c | 2 +- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 2 +- drivers/staging/rtl8723bs/core/rtw_xmit.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/2 staging: media: Remove NULL test on an already tested value
When a value has been tested for NULL in an expression, a second NULL test on the same value in another expression is unnecessary when the value has not been assigned NULL.
Remove unnecessary duplicate NULL tests on the same value that has previously been NULL tested.
Found by Coccinelle
--- drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 2 +- drivers/staging/media/av7110/sp8870.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +1 -1
@@ -1292,7 +1292,7 @@ static int gmin_get_config_dsm_var(struct device *dev,* if it founds something different than string, letting it * to fall back to the old code. */ -if (cur && cur->type !=ACPI_TYPE_STRING ) { +if (cur->type !=ACPI_TYPE_STRING ) {dev_info (dev,"found non-string _DSM entry for '%s'\n" , var);ACPI_FREE (obj);return -EINVAL ;
drivers/staging/media/av7110/sp8870.c +1 -1
@@ -508,7 +508,7 @@ static int sp8870_set_frontend(struct dvb_frontend *fe) }if (debug) { -if (valid) { + {if (trials >1 ) {pr_info ("%s(): firmware lockup!!!\n" , __func__);pr_info ("%s(): recovered after %i trial(s))\n" , __func__, trials -1 );
Signature · 1 line
2.34.1
PATCH 2/2 staging: rtl8723bs: Prevent duplicate NULL tests on a value
In reply to Abraham Samuel AdekunleWhen a value has been tested for NULL in an expression, a second NULL test on the same value in another expression is unnecessary when the value has not been assigned NULL.
Remove unnecessary duplicate NULL tests on the same value that has previously been NULL tested.
Found by Coccinelle
--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 2 +- drivers/staging/rtl8723bs/core/rtw_xmit.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +1 -1
@@ -1323,7 +1323,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)spin_unlock_bh (&pstapriv->asoc_list_lock);/* now the station is qualified to join our BSS... */ -if (pstat && (pstat->state &WIFI_FW_ASSOC_SUCCESS ) && (status ==WLAN_STATUS_SUCCESS )) { +if ((pstat->state &WIFI_FW_ASSOC_SUCCESS ) && (status ==WLAN_STATUS_SUCCESS )) {/* 1 bss_cap_update & sta_info_update */ bss_cap_update_on_sta_join (padapter, pstat);sta_info_update (padapter, pstat);
drivers/staging/rtl8723bs/core/rtw_xmit.c +1 -1
@@ -941,7 +941,7 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattrif (!(psta->state & _FW_LINKED))return _FAIL; -if (psta) { + { psta->sta_xmitpriv.txseq_tid[pattrib->priority]++; psta->sta_xmitpriv.txseq_tid[pattrib->priority] &=0xFFF ; pattrib->seqnum = psta->sta_xmitpriv.txseq_tid[pattrib->priority];
Signature · 1 line
2.34.1
Re: [PATCH 1/2] staging: media: Remove NULL test on an already tested value
In reply to Abraham Samuel AdekunleQuoted 10 lines · Abraham Samuel Adekunle
When a value has been tested for NULL in an expression, a second NULL test on the same value in another expression is unnecessary when the value has not been assigned NULL.
Remove unnecessary duplicate NULL tests on the same value that has previously been NULL tested.
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 2 +- drivers/staging/media/av7110/sp8870.c | 2 +-
Please, split this on per driver basis, as they have different maintainers and trees to go through.
...
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c static int gmin_get_config_dsm_var(struct device *dev, · line 1298
Quoted 11 lines
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +1
-1@@ -1292,7 +1292,7 @@ static int gmin_get_config_dsm_var(struct device *dev,* if it founds something different than string, letting it * to fall back to the old code. */ -if (cur && cur->type !=ACPI_TYPE_STRING ) { +if (cur->type !=ACPI_TYPE_STRING ) {dev_info (dev,"found non-string _DSM entry for '%s'\n" , var);ACPI_FREE (obj);return -EINVAL ;
This change is good.
...
drivers/staging/media/av7110/sp8870.c static int sp8870_set_frontend(struct dvb_frontend *fe) · line 514
Quoted 13 lines
drivers/staging/media/av7110/sp8870.c +1
-1@@ -508,7 +508,7 @@ static int sp8870_set_frontend(struct dvb_frontend *fe) }if (debug) { -if (valid) { + {if (trials >1 ) {pr_info ("%s(): firmware lockup!!!\n" , __func__);pr_info ("%s(): recovered after %i trial(s))\n" , __func__, trials -1 );
But this is not fully done. Why do we need to keep {}? Just shift left the code and remove those {} altogether.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 2/2] staging: rtl8723bs: Prevent duplicate NULL tests on a value
In reply to Abraham Samuel AdekunleQuoted 9 lines · Abraham Samuel Adekunle
When a value has been tested for NULL in an expression, a second NULL test on the same value in another expression is unnecessary when the value has not been assigned NULL.
Remove unnecessary duplicate NULL tests on the same value that has previously been NULL tested.
Found by Coccinelle
...
drivers/staging/rtl8723bs/core/rtw_xmit.c s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr · line 947
Quoted 5 lines
drivers/staging/rtl8723bs/core/rtw_xmit.c +1
-1-if (psta) { + { psta->sta_xmitpriv.txseq_tid[pattrib->priority]++; psta->sta_xmitpriv.txseq_tid[pattrib->priority] &=0xFFF ; pattrib->seqnum = psta->sta_xmitpriv.txseq_tid[pattrib->priority];
Same comment, shift left and remove pointless {} altogether.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 1/2] staging: media: Remove NULL test on an already tested value
In reply to Andy ShevchenkoQuoted 8 lines · Andy Shevchenko
Quoted 5 lines · Abraham Samuel Adekunle
When a value has been tested for NULL in an expression, a second NULL test on the same value in another expression is unnecessary when the value has not been assigned NULL.
Quoted 8 lines
Quoted 5 lines
Remove unnecessary duplicate NULL tests on the same value that has previously been NULL tested.
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 2 +- drivers/staging/media/av7110/sp8870.c | 2 +-Please, split this on per driver basis, as they have different maintainers and trees to go through.
Thank you for your review.
I will do that.
Quoted 26 lines
...
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c static int gmin_get_config_dsm_var(struct device *dev, · line 1298
Quoted 11 lines
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +1
-1@@ -1292,7 +1292,7 @@ static int gmin_get_config_dsm_var(struct device *dev,* if it founds something different than string, letting it * to fall back to the old code. */ -if (cur && cur->type !=ACPI_TYPE_STRING ) { +if (cur->type !=ACPI_TYPE_STRING ) {dev_info (dev,"found non-string _DSM entry for '%s'\n" , var);ACPI_FREE (obj);return -EINVAL ;This change is good.
...
Quoted 7 lines
drivers/staging/media/av7110/sp8870.c +0
-0@@ -508,7 +508,7 @@ static int sp8870_set_frontend(struct dvb_frontend *fe) }
Quoted 9 lines
drivers/staging/media/av7110/sp8870.c static int sp8870_set_frontend(struct dvb_frontend *fe) · line 514
Quoted 6 lines
drivers/staging/media/av7110/sp8870.c +1
-1if (debug) { -if (valid) { + {if (trials >1 ) {pr_info ("%s(): firmware lockup!!!\n" , __func__);pr_info ("%s(): recovered after %i trial(s))\n" , __func__, trials -1 );But this is not fully done. Why do we need to keep {}? Just shift left the code and remove those {} altogether.
Okay I will effect the change.
Thanks
Adekunle