Skip to contentSkip to conversation

Unnecessary code cleanup patches

PATCH Superseded Abraham Samuel Adekunle 2 participants 3 messages Apr 4, 2025 Staging

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v4 cover Unnecessary code cleanup patches

The patchset modifies unnecessary duplicate NULL tests on a value in an expression, when the value has been NULL tested in a previous expression.

- Changes in v3:
- Changed other cases to use modulo (% 4096) over (& 0xfff).
- Modified commit message to reflect these changes.
- Changes in v2:
- Dropped patch files for media drivers from patchset as it is not meant for outreachy applicants.
- Added full-stop sign to text in commit message.
- Made code more readable by adding a line break.
- Changed cases to use modulo (% 4096) over (& 0xff).
- Changes in v1
- Patch for drivers/staging/media/av7110/sp8870.c and drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
is split into two different patches in the patchset for use by the different driver maintainers.
- Added subject title for each of the separated patches.
- Patch 1: Removed unnecessary curly braces {} initially inserted.
- Patch 2: Unnecessary {} was also removed for v1.

Abraham Samuel Adekunle (1):
staging: rtl8723bs: Prevent duplicate NULL tests on a value

 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c |  2 +-
 drivers/staging/rtl8723bs/core/rtw_xmit.c     | 58 +++++++++----------
 2 files changed, 30 insertions(+), 30 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v4 1/1 staging: rtl8723bs: Prevent duplicate NULL tests on a 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.

While at it, convert '& 0xfff' cases to use modulo operator and decimal number to make the upper limit visible and clear what the semantic of it is.

Found by Coccinelle.

---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c |  2 +-
 drivers/staging/rtl8723bs/core/rtw_xmit.c     | 58 +++++++++----------
 2 files changed, 30 insertions(+), 30 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +1 -1
index 90966b7034ab..675226535cd1 100644
@@ -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 +29 -29

64 lines not on this page · raw message

Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH v4 1/1] staging: rtl8723bs: Prevent duplicate NULL tests on a value

On Fri, Apr 4, 2025 at 11:51 AM Abraham Samuel Adekunle <[email protected]> wrote:

...

Quoted 3 lines

While at it, convert '& 0xfff' cases to use modulo operator and decimal number to make the upper limit visible and clear what the semantic of it is.

I think there is a consensus now that this should be a separate followup change.

...

Quoted 1 line

+ psta->sta_xmitpriv.txseq_tid[pattrib->priority] &= 0xFFF;

This also has the same semantic and may be changed in that patch.

Signature · 2 lines
With Best Regards,
Andy Shevchenko