public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] staging: rtl8723bs: core/rtw_mlme_ext.c: flatten control flow in OnAssocReq()
@ 2026-01-13 21:14 William Hansen-Baird
  2026-01-13 21:14 ` [PATCH 2/2] staging: rtl8723bs: core/rtw_mlme_ext.c: flatten indentation with early loop continue " William Hansen-Baird
  2026-01-16 13:05 ` [PATCH 1/2] staging: rtl8723bs: core/rtw_mlme_ext.c: flatten control flow " Greg KH
  0 siblings, 2 replies; 4+ messages in thread
From: William Hansen-Baird @ 2026-01-13 21:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-staging, linux-kernel, William Hansen-Baird

Rewrite if-else construct with an early exit to reduce indentation,
and make the execution clearer.

Signed-off-by: William Hansen-Baird <william.hansen.baird@gmail.com>
---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 59 +++++++++----------
 1 file changed, 29 insertions(+), 30 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index ac49bfbaa5bb..d3b395894d4b 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -1181,47 +1181,46 @@ 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)) {
+			if (!p)
+				break;
 
-					pstat->flags |= WLAN_STA_WME;
+			if (!memcmp(p+2, WMM_IE, 6)) {
 
-					pstat->qos_option = 1;
-					pstat->qos_info = *(p+8);
+				pstat->flags |= WLAN_STA_WME;
 
-					pstat->max_sp_len = (pstat->qos_info>>5)&0x3;
+				pstat->qos_option = 1;
+				pstat->qos_info = *(p+8);
 
-					if ((pstat->qos_info&0xf) != 0xf)
-						pstat->has_legacy_ac = true;
-					else
-						pstat->has_legacy_ac = false;
+				pstat->max_sp_len = (pstat->qos_info>>5)&0x3;
 
-					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&0xf) != 0xf)
+					pstat->has_legacy_ac = true;
+				else
+					pstat->has_legacy_ac = false;
 
-						if (pstat->qos_info&BIT(1))
-							pstat->uapsd_vi = BIT(0)|BIT(1);
-						else
-							pstat->uapsd_vi = 0;
+				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(2))
-							pstat->uapsd_bk = BIT(0)|BIT(1);
-						else
-							pstat->uapsd_bk = 0;
+					if (pstat->qos_info&BIT(1))
+						pstat->uapsd_vi = BIT(0)|BIT(1);
+					else
+						pstat->uapsd_vi = 0;
 
-						if (pstat->qos_info&BIT(3))
-							pstat->uapsd_be = BIT(0)|BIT(1);
-						else
-							pstat->uapsd_be = 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;
 				}
-			} else {
+
 				break;
 			}
 			p = p + ie_len + 2;
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] staging: rtl8723bs: core/rtw_mlme_ext.c: flatten indentation with early loop continue in OnAssocReq()
  2026-01-13 21:14 [PATCH 1/2] staging: rtl8723bs: core/rtw_mlme_ext.c: flatten control flow in OnAssocReq() William Hansen-Baird
@ 2026-01-13 21:14 ` William Hansen-Baird
  2026-01-16 13:06   ` Greg KH
  2026-01-16 13:05 ` [PATCH 1/2] staging: rtl8723bs: core/rtw_mlme_ext.c: flatten control flow " Greg KH
  1 sibling, 1 reply; 4+ messages in thread
From: William Hansen-Baird @ 2026-01-13 21:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-staging, linux-kernel, William Hansen-Baird

Replace large if (memcmp(p+2, WMM_IE, 6)) inside the for (;;) loop,
which ends with a break, with an early continue.
This reduces deep nesting and is purely stylistic.

Signed-off-by: William Hansen-Baird <william.hansen.baird@gmail.com>
---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 61 ++++++++++---------
 1 file changed, 31 insertions(+), 30 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index d3b395894d4b..4eb28577fb6a 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -1184,46 +1184,47 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
 			if (!p)
 				break;
 
-			if (!memcmp(p+2, WMM_IE, 6)) {
+			if (memcmp(p+2, WMM_IE, 6)) {
+				p = p + ie_len + 2;
+				continue;
+			}
 
-				pstat->flags |= WLAN_STA_WME;
+			pstat->flags |= WLAN_STA_WME;
 
-				pstat->qos_option = 1;
-				pstat->qos_info = *(p+8);
+			pstat->qos_option = 1;
+			pstat->qos_info = *(p+8);
 
-				pstat->max_sp_len = (pstat->qos_info>>5)&0x3;
+			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&0xf) != 0xf)
+				pstat->has_legacy_ac = true;
+			else
+				pstat->has_legacy_ac = false;
 
-					if (pstat->qos_info&BIT(1))
-						pstat->uapsd_vi = BIT(0)|BIT(1);
-					else
-						pstat->uapsd_vi = 0;
+			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(2))
-						pstat->uapsd_bk = BIT(0)|BIT(1);
-					else
-						pstat->uapsd_bk = 0;
+				if (pstat->qos_info&BIT(1))
+					pstat->uapsd_vi = BIT(0)|BIT(1);
+				else
+					pstat->uapsd_vi = 0;
 
-					if (pstat->qos_info&BIT(3))
-						pstat->uapsd_be = BIT(0)|BIT(1);
-					else
-						pstat->uapsd_be = 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;
 			}
-			p = p + ie_len + 2;
+
+			break;
 		}
 	}
 
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] staging: rtl8723bs: core/rtw_mlme_ext.c: flatten control flow in OnAssocReq()
  2026-01-13 21:14 [PATCH 1/2] staging: rtl8723bs: core/rtw_mlme_ext.c: flatten control flow in OnAssocReq() William Hansen-Baird
  2026-01-13 21:14 ` [PATCH 2/2] staging: rtl8723bs: core/rtw_mlme_ext.c: flatten indentation with early loop continue " William Hansen-Baird
@ 2026-01-16 13:05 ` Greg KH
  1 sibling, 0 replies; 4+ messages in thread
From: Greg KH @ 2026-01-16 13:05 UTC (permalink / raw)
  To: William Hansen-Baird; +Cc: linux-staging, linux-kernel

On Tue, Jan 13, 2026 at 04:14:32PM -0500, William Hansen-Baird wrote:
> Rewrite if-else construct with an early exit to reduce indentation,
> and make the execution clearer.
> 
> Signed-off-by: William Hansen-Baird <william.hansen.baird@gmail.com>
> ---
>  drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 59 +++++++++----------
>  1 file changed, 29 insertions(+), 30 deletions(-)
> 
> diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
> index ac49bfbaa5bb..d3b395894d4b 100644
> --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
> +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
> @@ -1181,47 +1181,46 @@ 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)) {
> +			if (!p)
> +				break;
>  
> -					pstat->flags |= WLAN_STA_WME;
> +			if (!memcmp(p+2, WMM_IE, 6)) {
>  
> -					pstat->qos_option = 1;
> -					pstat->qos_info = *(p+8);
> +				pstat->flags |= WLAN_STA_WME;
>  
> -					pstat->max_sp_len = (pstat->qos_info>>5)&0x3;
> +				pstat->qos_option = 1;
> +				pstat->qos_info = *(p+8);
>  
> -					if ((pstat->qos_info&0xf) != 0xf)
> -						pstat->has_legacy_ac = true;
> -					else
> -						pstat->has_legacy_ac = false;
> +				pstat->max_sp_len = (pstat->qos_info>>5)&0x3;
>  
> -					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&0xf) != 0xf)
> +					pstat->has_legacy_ac = true;
> +				else
> +					pstat->has_legacy_ac = false;
>  
> -						if (pstat->qos_info&BIT(1))
> -							pstat->uapsd_vi = BIT(0)|BIT(1);
> -						else
> -							pstat->uapsd_vi = 0;
> +				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(2))
> -							pstat->uapsd_bk = BIT(0)|BIT(1);
> -						else
> -							pstat->uapsd_bk = 0;
> +					if (pstat->qos_info&BIT(1))
> +						pstat->uapsd_vi = BIT(0)|BIT(1);
> +					else
> +						pstat->uapsd_vi = 0;
>  
> -						if (pstat->qos_info&BIT(3))
> -							pstat->uapsd_be = BIT(0)|BIT(1);
> -						else
> -							pstat->uapsd_be = 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;
>  				}
> -			} else {
> +
>  				break;

If all ways through this loop ends up in a break, why is this a loop at
all?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] staging: rtl8723bs: core/rtw_mlme_ext.c: flatten indentation with early loop continue in OnAssocReq()
  2026-01-13 21:14 ` [PATCH 2/2] staging: rtl8723bs: core/rtw_mlme_ext.c: flatten indentation with early loop continue " William Hansen-Baird
@ 2026-01-16 13:06   ` Greg KH
  0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2026-01-16 13:06 UTC (permalink / raw)
  To: William Hansen-Baird; +Cc: linux-staging, linux-kernel

On Tue, Jan 13, 2026 at 04:14:33PM -0500, William Hansen-Baird wrote:
> Replace large if (memcmp(p+2, WMM_IE, 6)) inside the for (;;) loop,
> which ends with a break, with an early continue.
> This reduces deep nesting and is purely stylistic.
> 
> Signed-off-by: William Hansen-Baird <william.hansen.baird@gmail.com>
> ---
>  drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 61 ++++++++++---------
>  1 file changed, 31 insertions(+), 30 deletions(-)
> 
> diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
> index d3b395894d4b..4eb28577fb6a 100644
> --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
> +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
> @@ -1184,46 +1184,47 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
>  			if (!p)
>  				break;
>  
> -			if (!memcmp(p+2, WMM_IE, 6)) {
> +			if (memcmp(p+2, WMM_IE, 6)) {
> +				p = p + ie_len + 2;
> +				continue;

Ah, here's the loop, sorry about the previous review comment.

Ugh, what a mess.  I'll take this now, hopefully it all still works :)

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-01-16 13:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-13 21:14 [PATCH 1/2] staging: rtl8723bs: core/rtw_mlme_ext.c: flatten control flow in OnAssocReq() William Hansen-Baird
2026-01-13 21:14 ` [PATCH 2/2] staging: rtl8723bs: core/rtw_mlme_ext.c: flatten indentation with early loop continue " William Hansen-Baird
2026-01-16 13:06   ` Greg KH
2026-01-16 13:05 ` [PATCH 1/2] staging: rtl8723bs: core/rtw_mlme_ext.c: flatten control flow " Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox