[PATCH v5 1/7] staging: rtl8723bs: use continue statements to reduce indentation

Michael Huang posted 7 patches 2 weeks ago
[PATCH v5 1/7] staging: rtl8723bs: use continue statements to reduce indentation
Posted by Michael Huang 2 weeks ago
Refactor nested if-statements using "continue"
statements. This flattens the logic, reduces deep indentation,
and improves overall code readability.

Signed-off-by: Michael Huang <tehsiu.huang@gmail.com>
---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 48 ++++++++++---------
 1 file changed, 25 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index fa1e3ad59254..d80c1a2620e2 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -3684,29 +3684,29 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter)
 
 
 		for (i = 0; i < 8; i++) {
-			if (ICS[i][0] == 1) {
-				int j, k = 0;
+			int j, k = 0;
 
-				InfoContent[k] = i;
-				/* SET_BSS_INTOLERANT_ELE_REG_CLASS(InfoContent, i); */
-				k++;
+			if (ICS[i][0] != 1)
+				continue;
 
-				for (j = 1; j <= 14; j++) {
-					if (ICS[i][j] == 1) {
-						if (k < 16) {
-							InfoContent[k] = j; /* channel number */
-							/* SET_BSS_INTOLERANT_ELE_CHANNEL(InfoContent+k, j); */
-							k++;
-						}
-					}
-				}
+			InfoContent[k] = i;
+			/* SET_BSS_INTOLERANT_ELE_REG_CLASS(InfoContent, i); */
+			k++;
 
-				pframe = rtw_set_ie(pframe, WLAN_EID_BSS_INTOLERANT_CHL_REPORT, k, InfoContent, &(pattrib->pktlen));
+			for (j = 1; j <= 14; j++) {
+				if (ICS[i][j] != 1)
+					continue;
 
+				if (k < 16) {
+					InfoContent[k] = j; /* channel number */
+					/* SET_BSS_INTOLERANT_ELE_CHANNEL(InfoContent+k, j); */
+					k++;
+				}
 			}
 
-		}
+			pframe = rtw_set_ie(pframe, WLAN_EID_BSS_INTOLERANT_CHL_REPORT, k, InfoContent, &(pattrib->pktlen));
 
+		}
 
 	}
 
@@ -3831,14 +3831,16 @@ void site_survey(struct adapter *padapter)
 				int i;
 
 				for (i = 0; i < RTW_SSID_SCAN_AMOUNT; i++) {
-					if (pmlmeext->sitesurvey_res.ssid[i].ssid_length) {
-						/* IOT issue, When wifi_spec is not set, send one probe req without WPS IE. */
-						if (padapter->registrypriv.wifi_spec)
-							issue_probereq(padapter, &(pmlmeext->sitesurvey_res.ssid[i]), NULL);
-						else
-							issue_probereq_ex(padapter, &(pmlmeext->sitesurvey_res.ssid[i]), NULL, 0, 0, 0, 0);
+					if (!pmlmeext->sitesurvey_res.ssid[i].ssid_length)
+						continue;
+
+					/* IOT issue, When wifi_spec is not set, send one probe req without WPS IE. */
+					if (padapter->registrypriv.wifi_spec)
 						issue_probereq(padapter, &(pmlmeext->sitesurvey_res.ssid[i]), NULL);
-					}
+					else
+						issue_probereq_ex(padapter, &(pmlmeext->sitesurvey_res.ssid[i]), NULL, 0, 0, 0, 0);
+
+					issue_probereq(padapter, &(pmlmeext->sitesurvey_res.ssid[i]), NULL);
 				}
 
 				if (pmlmeext->sitesurvey_res.scan_mode == SCAN_ACTIVE) {
-- 
2.43.0
Re: [PATCH v5 1/7] staging: rtl8723bs: use continue statements to reduce indentation
Posted by Joe Perches 2 weeks ago
On Sat, 2026-01-24 at 15:15 -0800, Michael Huang wrote:
> Refactor nested if-statements using "continue"
> statements. This flattens the logic, reduces deep indentation,
> and improves overall code readability.
[]
> diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
[]
> @@ -3684,29 +3684,29 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter)
>  
>  
>  		for (i = 0; i < 8; i++) {
> -			if (ICS[i][0] == 1) {

Several additional things to consider for readability

o Rename ICS to something more meaningful
o Separate the ICS[x][0] uses to another named array [8]
o Adding #defines for the array bounds 8 and 15 (or 14)
o Change the loop bounds from 1 to 0 and 15 to 14 
o Converting this/these arrays to bool
o Use boolean logic
Re: [PATCH v5 1/7] staging: rtl8723bs: use continue statements to reduce indentation
Posted by Te-Hsiu Huang 1 week, 6 days ago
On Sun, Jan 25, 2026 at 10:13 AM Joe Perches <joe@perches.com> wrote:

> Several additional things to consider for readability
>
> o Rename ICS to something more meaningful
> o Separate the ICS[x][0] uses to another named array [8]
> o Adding #defines for the array bounds 8 and 15 (or 14)
> o Change the loop bounds from 1 to 0 and 15 to 14
> o Converting this/these arrays to bool
> o Use boolean logic

Hi Joe,

Thanks for your valuable suggestions!!!

These points—especially renaming ICS, using #defines for array bounds,
and converting to boolean logic—would definitely improve the long-term
maintainability of this driver.

However, to keep this series focused on fixing the immediate
checkpatch warnings and reducing indentation as suggested by Dan,
would it be acceptable to handle these larger refactoring tasks in a
separate follow-up patch series?

I'd like to ensure the current cleanup (v5) is stable and correct
before introducing more significant structural changes to the logic.
Really appreciate your time!

Best regards,
Michael