linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] rlt8723bs cleanup
@ 2022-04-01 19:06 Sevinj Aghayeva
  2022-04-01 19:06 ` [PATCH 1/3] staging: rtl8723bs: remove redundant braces in if statements Sevinj Aghayeva
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Sevinj Aghayeva @ 2022-04-01 19:06 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-staging, linux-kernel, outreachy, Sevinj Aghayeva

These patches fix three categories of checkpatch warnings (redundant
braces, redundant else branches after return/break, and constant
placements on tests) in file rtw_mlme_ext.c, which is part of the
rtl8723bs driver. False positives, such as

if (foo) {
	/* TODO: ... */
}

were not altered.

---
v1 -> v2: Removing a redundant else branch left a variable declaration
mixed with code, which was caught by the kernel test bot. Move the
declaration to the beginning of a function.
---

Sevinj Aghayeva (3):
  staging: rtl8723bs: remove redundant braces in if statements
  staging: rtl8723bs: place constants on the right side of tests
  staging: rtl8723bs: remove redundant else branches

 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 167 ++++++++----------
 1 file changed, 70 insertions(+), 97 deletions(-)

-- 
2.25.1


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

* [PATCH 1/3] staging: rtl8723bs: remove redundant braces in if statements
  2022-04-01 19:06 [PATCH v2 0/3] rlt8723bs cleanup Sevinj Aghayeva
@ 2022-04-01 19:06 ` Sevinj Aghayeva
  2022-04-01 19:06 ` [PATCH 2/3] staging: rtl8723bs: place constants on the right side of tests Sevinj Aghayeva
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Sevinj Aghayeva @ 2022-04-01 19:06 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-staging, linux-kernel, outreachy, Sevinj Aghayeva

Adhere to Linux kernel coding style.

Reported by checkpatch:

WARNING: braces {} are not necessary for single statement blocks

Signed-off-by: Sevinj Aghayeva <sevinj.aghayeva@gmail.com>
---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 76 +++++++------------
 1 file changed, 26 insertions(+), 50 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index 49a3f45cb771..9f328e9a81ff 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -271,12 +271,9 @@ static int has_channel(struct rt_channel_info *channel_set,
 {
 	int i;
 
-	for (i = 0; i < chanset_size; i++) {
-		if (channel_set[i].ChannelNum == chan) {
+	for (i = 0; i < chanset_size; i++)
+		if (channel_set[i].ChannelNum == chan)
 			return 1;
-		}
-	}
-
 	return 0;
 }
 
@@ -649,9 +646,8 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame)
 			if (psta) {
 				/* update WMM, ERP in the beacon */
 				/* todo: the timer is used instead of the number of the beacon received */
-				if ((sta_rx_pkts(psta) & 0xf) == 0) {
+				if ((sta_rx_pkts(psta) & 0xf) == 0)
 					update_beacon_info(padapter, pframe, len, psta);
-				}
 			} else {
 				/* allocate a new CAM entry for IBSS station */
 				cam_idx = allocate_fw_sta_entry(padapter);
@@ -916,11 +912,10 @@ unsigned int OnAuthClient(struct adapter *padapter, union recv_frame *precv_fram
 			go2asoc = 1;
 		}
 	} else if (seq == 4) {
-		if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) {
+		if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared)
 			go2asoc = 1;
-		} else {
+		else
 			goto authclnt_fail;
-		}
 	} else {
 		/*  this is also illegal */
 		goto authclnt_fail;
@@ -1455,11 +1450,10 @@ unsigned int OnAssocRsp(struct adapter *padapter, union recv_frame *precv_frame)
 	UpdateBrateTbl(padapter, pmlmeinfo->network.supported_rates);
 
 report_assoc_result:
-	if (res > 0) {
+	if (res > 0)
 		rtw_buf_update(&pmlmepriv->assoc_rsp, &pmlmepriv->assoc_rsp_len, pframe, pkt_len);
-	} else {
+	else
 		rtw_buf_free(&pmlmepriv->assoc_rsp, &pmlmepriv->assoc_rsp_len);
-	}
 
 	report_join_res(padapter, res);
 
@@ -1531,9 +1525,8 @@ unsigned int OnDeAuth(struct adapter *padapter, union recv_frame *precv_frame)
 			   reason, GetAddr3Ptr(pframe),
 			   ignore_received_deauth);
 
-		if (0 == ignore_received_deauth) {
+		if (0 == ignore_received_deauth)
 			receive_disconnect(padapter, GetAddr3Ptr(pframe), reason);
-		}
 	}
 	pmlmepriv->LinkDetectInfo.bBusyTraffic = false;
 	return _SUCCESS;
@@ -1674,11 +1667,10 @@ unsigned int OnAction_back(struct adapter *padapter, union recv_frame *precv_fra
 			/* process_addba_req(padapter, (u8 *)&(pmlmeinfo->ADDBA_req), GetAddr3Ptr(pframe)); */
 			process_addba_req(padapter, (u8 *)&(pmlmeinfo->ADDBA_req), addr);
 
-			if (pmlmeinfo->accept_addba_req) {
+			if (pmlmeinfo->accept_addba_req)
 				issue_action_BA(padapter, addr, WLAN_ACTION_ADDBA_RESP, 0);
-			} else {
+			else
 				issue_action_BA(padapter, addr, WLAN_ACTION_ADDBA_RESP, 37);/* reject ADDBA Req */
-			}
 
 			break;
 
@@ -1774,9 +1766,8 @@ static unsigned int on_action_public_vendor(union recv_frame *precv_frame)
 	u8 *pframe = precv_frame->u.hdr.rx_data;
 	u8 *frame_body = pframe + sizeof(struct ieee80211_hdr_3addr);
 
-	if (!memcmp(frame_body + 2, P2P_OUI, 4)) {
+	if (!memcmp(frame_body + 2, P2P_OUI, 4))
 		ret = on_action_public_p2p(precv_frame);
-	}
 
 	return ret;
 }
@@ -2187,9 +2178,8 @@ void issue_beacon(struct adapter *padapter, int timeout_ms)
 
 			wps_ie = rtw_get_wps_ie(pmgntframe->buf_addr+TXDESC_OFFSET+sizeof(struct ieee80211_hdr_3addr)+_BEACON_IE_OFFSET_,
 				pattrib->pktlen-sizeof(struct ieee80211_hdr_3addr)-_BEACON_IE_OFFSET_, NULL, &wps_ielen);
-			if (wps_ie && wps_ielen > 0) {
+			if (wps_ie && wps_ielen > 0)
 				rtw_get_wps_attr_content(wps_ie,  wps_ielen, WPS_ATTR_SELECTED_REGISTRAR, (u8 *)(&sr), NULL);
-			}
 			if (sr != 0)
 				set_fwstate(pmlmepriv, WIFI_UNDER_WPS);
 			else
@@ -2245,9 +2235,8 @@ void issue_beacon(struct adapter *padapter, int timeout_ms)
 
 
 	/*  EXTERNDED SUPPORTED RATE */
-	if (rate_len > 8) {
+	if (rate_len > 8)
 		pframe = rtw_set_ie(pframe, WLAN_EID_EXT_SUPP_RATES, (rate_len - 8), (cur_network->supported_rates + 8), &pattrib->pktlen);
-	}
 
 
 	/* todo:HT for adhoc */
@@ -2447,9 +2436,8 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p
 
 
 		/*  EXTERNDED SUPPORTED RATE */
-		if (rate_len > 8) {
+		if (rate_len > 8)
 			pframe = rtw_set_ie(pframe, WLAN_EID_EXT_SUPP_RATES, (rate_len - 8), (cur_network->supported_rates + 8), &pattrib->pktlen);
-		}
 
 
 		/* todo:HT for adhoc */
@@ -2674,9 +2662,8 @@ void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short
 
 		/*  setting auth algo number */
 		val16 = (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) ? 1 : 0;/*  0:OPEN System, 1:Shared key */
-		if (val16) {
+		if (val16)
 			use_shared_key = 1;
-		}
 		le_tmp = cpu_to_le16(val16);
 
 		/* setting IV for auth seq #3 */
@@ -2831,16 +2818,14 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i
 				break;
 			}
 
-			if (!pbuf || ie_len == 0) {
+			if (!pbuf || ie_len == 0)
 				break;
-			}
 		}
 
 	}
 
-	if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK) {
+	if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK)
 		pframe = rtw_set_ie(pframe, WLAN_EID_VENDOR_SPECIFIC, 6, REALTEK_96B_IE, &(pattrib->pktlen));
-	}
 
 	/* add WPS IE ie for wps 2.0 */
 	if (pmlmepriv->wps_assoc_resp_ie && pmlmepriv->wps_assoc_resp_ie_len > 0) {
@@ -3301,9 +3286,8 @@ static int _issue_deauth(struct adapter *padapter, unsigned char *da,
 	__le16 le_tmp;
 
 	pmgntframe = alloc_mgtxmitframe(pxmitpriv);
-	if (!pmgntframe) {
+	if (!pmgntframe)
 		goto exit;
-	}
 
 	/* update attribute */
 	pattrib = &pmgntframe->attrib;
@@ -3627,9 +3611,8 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter)
 	action = ACT_PUBLIC_BSSCOEXIST;
 
 	pmgntframe = alloc_mgtxmitframe(pxmitpriv);
-	if (!pmgntframe) {
+	if (!pmgntframe)
 		return;
-	}
 
 	/* update attribute */
 	pattrib = &pmgntframe->attrib;
@@ -3802,9 +3785,8 @@ unsigned int send_beacon(struct adapter *padapter)
 
 	} while (false == bxmitok && issue < 100 && !padapter->bSurpriseRemoved && !padapter->bDriverStopped);
 
-	if (padapter->bSurpriseRemoved || padapter->bDriverStopped) {
+	if (padapter->bSurpriseRemoved || padapter->bDriverStopped)
 		return _FAIL;
-	}
 
 
 	if (!bxmitok)
@@ -4388,9 +4370,8 @@ static void process_80211d(struct adapter *padapter, struct wlan_bssid_ex *bssid
 			}
 
 			/*  skip AP 2.4G channel plan */
-			while ((j < chplan_ap.Len) && (chplan_ap.Channel[j] <= 14)) {
+			while ((j < chplan_ap.Len) && (chplan_ap.Channel[j] <= 14))
 				j++;
-			}
 		}
 
 		pmlmeext->update_channel_plan_by_ap_done = 1;
@@ -4402,9 +4383,8 @@ static void process_80211d(struct adapter *padapter, struct wlan_bssid_ex *bssid
 	i = 0;
 	while ((i < MAX_CHANNEL_NUM) && (chplan_new[i].ChannelNum != 0)) {
 		if (chplan_new[i].ChannelNum == channel) {
-			if (chplan_new[i].ScanType == SCAN_PASSIVE) {
+			if (chplan_new[i].ScanType == SCAN_PASSIVE)
 				chplan_new[i].ScanType = SCAN_ACTIVE;
-			}
 			break;
 		}
 		i++;
@@ -4629,9 +4609,8 @@ void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsi
 	struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
 
 	pcmd_obj = rtw_zmalloc(sizeof(struct cmd_obj));
-	if (!pcmd_obj) {
+	if (!pcmd_obj)
 		return;
-	}
 
 	cmdsz = (sizeof(struct stadel_event) + sizeof(struct C2HEvent_Header));
 	pevtcmd = rtw_zmalloc(cmdsz);
@@ -5124,9 +5103,8 @@ void survey_timer_hdl(struct timer_list *t)
 
 	/* issue rtw_sitesurvey_cmd */
 	if (pmlmeext->sitesurvey_res.state > SCAN_START) {
-		if (pmlmeext->sitesurvey_res.state ==  SCAN_PROCESS) {
+		if (pmlmeext->sitesurvey_res.state ==  SCAN_PROCESS)
 			pmlmeext->sitesurvey_res.channel_idx++;
-		}
 
 		if (pmlmeext->scan_abort) {
 			pmlmeext->sitesurvey_res.channel_idx = pmlmeext->sitesurvey_res.ch_num;
@@ -5135,9 +5113,8 @@ void survey_timer_hdl(struct timer_list *t)
 		}
 
 		ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
-		if (!ph2c) {
+		if (!ph2c)
 			goto exit_survey_timer_hdl;
-		}
 
 		psurveyPara = rtw_zmalloc(sizeof(struct sitesurvey_parm));
 		if (!psurveyPara) {
@@ -5348,9 +5325,8 @@ u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf)
 
 	/* check already connecting to AP or not */
 	if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) {
-		if (pmlmeinfo->state & WIFI_FW_STATION_STATE) {
+		if (pmlmeinfo->state & WIFI_FW_STATION_STATE)
 			issue_deauth_ex(padapter, pnetwork->mac_address, WLAN_REASON_DEAUTH_LEAVING, 1, 100);
-		}
 		pmlmeinfo->state = WIFI_FW_NULL_STATE;
 
 		/* clear CAM */
-- 
2.25.1


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

* [PATCH 2/3] staging: rtl8723bs: place constants on the right side of tests
  2022-04-01 19:06 [PATCH v2 0/3] rlt8723bs cleanup Sevinj Aghayeva
  2022-04-01 19:06 ` [PATCH 1/3] staging: rtl8723bs: remove redundant braces in if statements Sevinj Aghayeva
@ 2022-04-01 19:06 ` Sevinj Aghayeva
  2022-04-01 19:07 ` [PATCH 3/3] staging: rtl8723bs: remove redundant else branches Sevinj Aghayeva
  2022-04-01 19:13 ` [PATCH v2 0/3] rlt8723bs cleanup Sevinj Aghayeva
  3 siblings, 0 replies; 9+ messages in thread
From: Sevinj Aghayeva @ 2022-04-01 19:06 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-staging, linux-kernel, outreachy, Sevinj Aghayeva

Adhere to Linux kernel coding style.

Reported by checkpatch:

WARNING: Comparisons should place the constant on the right side of the test

Signed-off-by: Sevinj Aghayeva <sevinj.aghayeva@gmail.com>
---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 34 +++++++++----------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index 9f328e9a81ff..81e4b1bf68f6 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -308,11 +308,11 @@ static void init_channel_list(struct adapter *padapter, struct rt_channel_info *
 			if (!has_channel(channel_set, chanset_size, ch))
 				continue;
 
-			if ((0 == padapter->registrypriv.ht_enable) && (8 == o->inc))
+			if ((padapter->registrypriv.ht_enable == 0) && (o->inc == 8))
 				continue;
 
-			if ((0 < (padapter->registrypriv.bw_mode & 0xf0)) &&
-				((BW40MINUS == o->bw) || (BW40PLUS == o->bw)))
+			if (((padapter->registrypriv.bw_mode & 0xf0) > 0) &&
+				((o->bw == BW40MINUS) || (o->bw == BW40PLUS)))
 				continue;
 
 			if (!reg) {
@@ -342,7 +342,7 @@ static u8 init_channel_set(struct adapter *padapter, u8 ChannelPlan, struct rt_c
 
 	if (is_supported_24g(padapter->registrypriv.wireless_mode)) {
 		b2_4GBand = true;
-		if (RT_CHANNEL_DOMAIN_REALTEK_DEFINE == ChannelPlan)
+		if (ChannelPlan == RT_CHANNEL_DOMAIN_REALTEK_DEFINE)
 			Index2G = RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE.Index2G;
 		else
 			Index2G = RTW_ChannelPlanMap[ChannelPlan].Index2G;
@@ -352,14 +352,14 @@ static u8 init_channel_set(struct adapter *padapter, u8 ChannelPlan, struct rt_c
 		for (index = 0; index < RTW_ChannelPlan2G[Index2G].Len; index++) {
 			channel_set[chanset_size].ChannelNum = RTW_ChannelPlan2G[Index2G].Channel[index];
 
-			if ((RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN == ChannelPlan) ||/* Channel 1~11 is active, and 12~14 is passive */
-				(RT_CHANNEL_DOMAIN_GLOBAL_NULL == ChannelPlan)) {
+			if ((ChannelPlan == RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN) || /* Channel 1~11 is active, and 12~14 is passive */
+				(ChannelPlan == RT_CHANNEL_DOMAIN_GLOBAL_NULL)) {
 				if (channel_set[chanset_size].ChannelNum >= 1 && channel_set[chanset_size].ChannelNum <= 11)
 					channel_set[chanset_size].ScanType = SCAN_ACTIVE;
 				else if ((channel_set[chanset_size].ChannelNum  >= 12 && channel_set[chanset_size].ChannelNum  <= 14))
 					channel_set[chanset_size].ScanType  = SCAN_PASSIVE;
-			} else if (RT_CHANNEL_DOMAIN_WORLD_WIDE_13 == ChannelPlan ||
-				RT_CHANNEL_DOMAIN_2G_WORLD == Index2G) { /*  channel 12~13, passive scan */
+			} else if (ChannelPlan == RT_CHANNEL_DOMAIN_WORLD_WIDE_13 ||
+				Index2G == RT_CHANNEL_DOMAIN_2G_WORLD) { /* channel 12~13, passive scan */
 				if (channel_set[chanset_size].ChannelNum <= 11)
 					channel_set[chanset_size].ScanType = SCAN_ACTIVE;
 				else
@@ -1326,7 +1326,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) && (WLAN_STATUS_SUCCESS == status)) {
+	if (pstat && (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);
@@ -1514,7 +1514,7 @@ unsigned int OnDeAuth(struct adapter *padapter, union recv_frame *precv_frame)
 			(pmlmeinfo->state & WIFI_FW_ASSOC_STATE)) {
 			if (reason == WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA) {
 				ignore_received_deauth = 1;
-			} else if (WLAN_REASON_PREV_AUTH_NOT_VALID == reason) {
+			} else if (reason == WLAN_REASON_PREV_AUTH_NOT_VALID) {
 				/*  TODO: 802.11r */
 				ignore_received_deauth = 1;
 			}
@@ -1525,7 +1525,7 @@ unsigned int OnDeAuth(struct adapter *padapter, union recv_frame *precv_frame)
 			   reason, GetAddr3Ptr(pframe),
 			   ignore_received_deauth);
 
-		if (0 == ignore_received_deauth)
+		if (ignore_received_deauth == 0)
 			receive_disconnect(padapter, GetAddr3Ptr(pframe), reason);
 	}
 	pmlmepriv->LinkDetectInfo.bBusyTraffic = false;
@@ -3536,13 +3536,13 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
 				rtw_hal_get_def_var(padapter,
 						    HW_VAR_MAX_RX_AMPDU_FACTOR, &max_rx_ampdu_factor);
 
-			if (IEEE80211_HT_MAX_AMPDU_64K == max_rx_ampdu_factor)
+			if (max_rx_ampdu_factor == IEEE80211_HT_MAX_AMPDU_64K)
 				BA_para_set = ((le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x1000); /* 64 buffer size */
-			else if (IEEE80211_HT_MAX_AMPDU_32K == max_rx_ampdu_factor)
+			else if (max_rx_ampdu_factor == IEEE80211_HT_MAX_AMPDU_32K)
 				BA_para_set = ((le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x0800); /* 32 buffer size */
-			else if (IEEE80211_HT_MAX_AMPDU_16K == max_rx_ampdu_factor)
+			else if (max_rx_ampdu_factor == IEEE80211_HT_MAX_AMPDU_16K)
 				BA_para_set = ((le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x0400); /* 16 buffer size */
-			else if (IEEE80211_HT_MAX_AMPDU_8K == max_rx_ampdu_factor)
+			else if (max_rx_ampdu_factor == IEEE80211_HT_MAX_AMPDU_8K)
 				BA_para_set = ((le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x0200); /* 8 buffer size */
 			else
 				BA_para_set = ((le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x1000); /* 64 buffer size */
@@ -5065,7 +5065,7 @@ void linked_status_chk(struct adapter *padapter)
 			if (pmlmeinfo->FW_sta_info[i].status == 1) {
 				psta = pmlmeinfo->FW_sta_info[i].psta;
 
-				if (NULL == psta)
+				if (psta == NULL)
 					continue;
 
 				if (pmlmeinfo->FW_sta_info[i].rx_pkt == sta_rx_pkts(psta)) {
@@ -6049,7 +6049,7 @@ u8 run_in_thread_hdl(struct adapter *padapter, u8 *pbuf)
 	struct RunInThread_param *p;
 
 
-	if (NULL == pbuf)
+	if (pbuf == NULL)
 		return H2C_PARAMETERS_ERROR;
 	p = (struct RunInThread_param *)pbuf;
 
-- 
2.25.1


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

* [PATCH 3/3] staging: rtl8723bs: remove redundant else branches
  2022-04-01 19:06 [PATCH v2 0/3] rlt8723bs cleanup Sevinj Aghayeva
  2022-04-01 19:06 ` [PATCH 1/3] staging: rtl8723bs: remove redundant braces in if statements Sevinj Aghayeva
  2022-04-01 19:06 ` [PATCH 2/3] staging: rtl8723bs: place constants on the right side of tests Sevinj Aghayeva
@ 2022-04-01 19:07 ` Sevinj Aghayeva
  2022-04-01 19:13 ` [PATCH v2 0/3] rlt8723bs cleanup Sevinj Aghayeva
  3 siblings, 0 replies; 9+ messages in thread
From: Sevinj Aghayeva @ 2022-04-01 19:07 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-staging, linux-kernel, outreachy, Sevinj Aghayeva

Adhere to Linux kernel coding style.

Reported by checkpatch:

WARNING: else is not generally useful after a break or return

Signed-off-by: Sevinj Aghayeva <sevinj.aghayeva@gmail.com>
---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 63 +++++++++----------
 1 file changed, 30 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index 81e4b1bf68f6..7a941832ee34 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -907,10 +907,9 @@ unsigned int OnAuthClient(struct adapter *padapter, union recv_frame *precv_fram
 			set_link_timer(pmlmeext, REAUTH_TO);
 
 			return _SUCCESS;
-		} else {
-			/*  open system */
-			go2asoc = 1;
 		}
+		/*  open system */
+		go2asoc = 1;
 	} else if (seq == 4) {
 		if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared)
 			go2asoc = 1;
@@ -1467,6 +1466,7 @@ unsigned int OnDeAuth(struct adapter *padapter, union recv_frame *precv_frame)
 	struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
 	struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
 	u8 *pframe = precv_frame->u.hdr.rx_data;
+	int ignore_received_deauth = 0;
 
 	/* check A3 */
 	if (memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), ETH_ALEN))
@@ -1502,32 +1502,31 @@ unsigned int OnDeAuth(struct adapter *padapter, union recv_frame *precv_frame)
 
 
 		return _SUCCESS;
-	} else {
-		int	ignore_received_deauth = 0;
-
-		/* 	Commented by Albert 20130604 */
-		/* 	Before sending the auth frame to start the STA/GC mode connection with AP/GO, */
-		/* 	we will send the deauth first. */
-		/* 	However, the Win8.1 with BRCM Wi-Fi will send the deauth with reason code 6 to us after receieving our deauth. */
-		/* 	Added the following code to avoid this case. */
-		if ((pmlmeinfo->state & WIFI_FW_AUTH_STATE) ||
-			(pmlmeinfo->state & WIFI_FW_ASSOC_STATE)) {
-			if (reason == WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA) {
-				ignore_received_deauth = 1;
-			} else if (reason == WLAN_REASON_PREV_AUTH_NOT_VALID) {
-				/*  TODO: 802.11r */
-				ignore_received_deauth = 1;
-			}
+	}
+
+	/* 	Commented by Albert 20130604 */
+	/* 	Before sending the auth frame to start the STA/GC mode connection with AP/GO, */
+	/* 	we will send the deauth first. */
+	/* 	However, the Win8.1 with BRCM Wi-Fi will send the deauth with reason code 6 to us after receieving our deauth. */
+	/* 	Added the following code to avoid this case. */
+	if ((pmlmeinfo->state & WIFI_FW_AUTH_STATE) ||
+		(pmlmeinfo->state & WIFI_FW_ASSOC_STATE)) {
+		if (reason == WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA) {
+			ignore_received_deauth = 1;
+		} else if (reason == WLAN_REASON_PREV_AUTH_NOT_VALID) {
+			/*  TODO: 802.11r */
+			ignore_received_deauth = 1;
 		}
+	}
 
-		netdev_dbg(padapter->pnetdev,
-			   "sta recv deauth reason code(%d) sta:%pM, ignore = %d\n",
-			   reason, GetAddr3Ptr(pframe),
-			   ignore_received_deauth);
+	netdev_dbg(padapter->pnetdev,
+		"sta recv deauth reason code(%d) sta:%pM, ignore = %d\n",
+		reason, GetAddr3Ptr(pframe),
+		ignore_received_deauth);
+
+	if (ignore_received_deauth == 0)
+		receive_disconnect(padapter, GetAddr3Ptr(pframe), reason);
 
-		if (ignore_received_deauth == 0)
-			receive_disconnect(padapter, GetAddr3Ptr(pframe), reason);
-	}
 	pmlmepriv->LinkDetectInfo.bBusyTraffic = false;
 	return _SUCCESS;
 
@@ -1574,16 +1573,14 @@ unsigned int OnDisassoc(struct adapter *padapter, union recv_frame *precv_frame)
 		}
 
 		return _SUCCESS;
-	} else {
-		netdev_dbg(padapter->pnetdev,
-			   "sta recv disassoc reason code(%d) sta:%pM\n",
-			   reason, GetAddr3Ptr(pframe));
-
-		receive_disconnect(padapter, GetAddr3Ptr(pframe), reason);
 	}
+	netdev_dbg(padapter->pnetdev,
+		"sta recv disassoc reason code(%d) sta:%pM\n",
+		reason, GetAddr3Ptr(pframe));
+
+	receive_disconnect(padapter, GetAddr3Ptr(pframe), reason);
 	pmlmepriv->LinkDetectInfo.bBusyTraffic = false;
 	return _SUCCESS;
-
 }
 
 unsigned int OnAtim(struct adapter *padapter, union recv_frame *precv_frame)
-- 
2.25.1


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

* Re: [PATCH v2 0/3] rlt8723bs cleanup
  2022-04-01 19:06 [PATCH v2 0/3] rlt8723bs cleanup Sevinj Aghayeva
                   ` (2 preceding siblings ...)
  2022-04-01 19:07 ` [PATCH 3/3] staging: rtl8723bs: remove redundant else branches Sevinj Aghayeva
@ 2022-04-01 19:13 ` Sevinj Aghayeva
  3 siblings, 0 replies; 9+ messages in thread
From: Sevinj Aghayeva @ 2022-04-01 19:13 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-staging, linux-kernel, outreachy

Oops, apologies for the noise!

I tried to send v2 of the patchset but I had older versions of the
patches in /tmp and since I specified /tmp/*.patch to git send-email
per tutorial, it ended up sending all of the files there. I will send
a v3 ASAP and update the tutorial to prevent others from repeating the
same mistake!

On Fri, Apr 1, 2022 at 3:07 PM Sevinj Aghayeva
<sevinj.aghayeva@gmail.com> wrote:
>
> These patches fix three categories of checkpatch warnings (redundant
> braces, redundant else branches after return/break, and constant
> placements on tests) in file rtw_mlme_ext.c, which is part of the
> rtl8723bs driver. False positives, such as
>
> if (foo) {
>         /* TODO: ... */
> }
>
> were not altered.
>
> ---
> v1 -> v2: Removing a redundant else branch left a variable declaration
> mixed with code, which was caught by the kernel test bot. Move the
> declaration to the beginning of a function.
> ---
>
> Sevinj Aghayeva (3):
>   staging: rtl8723bs: remove redundant braces in if statements
>   staging: rtl8723bs: place constants on the right side of tests
>   staging: rtl8723bs: remove redundant else branches
>
>  drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 167 ++++++++----------
>  1 file changed, 70 insertions(+), 97 deletions(-)
>
> --
> 2.25.1
>


-- 

Sevinj.Aghayeva

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

* Re: [PATCH 3/3] staging: rtl8723bs: remove redundant else branches
  2022-04-03 11:03   ` Greg Kroah-Hartman
@ 2022-04-03 15:33     ` Sevinj Aghayeva
  0 siblings, 0 replies; 9+ messages in thread
From: Sevinj Aghayeva @ 2022-04-03 15:33 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-staging, linux-kernel, outreachy

On Sun, Apr 3, 2022 at 7:03 AM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> On Fri, Apr 01, 2022 at 09:02:47AM -0400, Sevinj Aghayeva wrote:
> > Adhere to Linux kernel coding style.
> >
> > Reported by checkpatch:
> >
> > WARNING: else is not generally useful after a break or return
> >
> > Signed-off-by: Sevinj Aghayeva <sevinj.aghayeva@gmail.com>
> > ---
> >  drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 63 +++++++++----------
> >  1 file changed, 30 insertions(+), 33 deletions(-)
> >
> > diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
> > index 81e4b1bf68f6..b80d9061f5a5 100644
> > --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
> > +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
> > @@ -907,10 +907,9 @@ unsigned int OnAuthClient(struct adapter *padapter, union recv_frame *precv_fram
> >                       set_link_timer(pmlmeext, REAUTH_TO);
> >
> >                       return _SUCCESS;
> > -             } else {
> > -                     /*  open system */
> > -                     go2asoc = 1;
> >               }
> > +             /*  open system */
> > +             go2asoc = 1;
> >       } else if (seq == 4) {
> >               if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared)
> >                       go2asoc = 1;
> > @@ -1502,32 +1501,32 @@ unsigned int OnDeAuth(struct adapter *padapter, union recv_frame *precv_frame)
> >
> >
> >               return _SUCCESS;
> > -     } else {
> > -             int     ignore_received_deauth = 0;
> > -
> > -             /*      Commented by Albert 20130604 */
> > -             /*      Before sending the auth frame to start the STA/GC mode connection with AP/GO, */
> > -             /*      we will send the deauth first. */
> > -             /*      However, the Win8.1 with BRCM Wi-Fi will send the deauth with reason code 6 to us after receieving our deauth. */
> > -             /*      Added the following code to avoid this case. */
> > -             if ((pmlmeinfo->state & WIFI_FW_AUTH_STATE) ||
> > -                     (pmlmeinfo->state & WIFI_FW_ASSOC_STATE)) {
> > -                     if (reason == WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA) {
> > -                             ignore_received_deauth = 1;
> > -                     } else if (reason == WLAN_REASON_PREV_AUTH_NOT_VALID) {
> > -                             /*  TODO: 802.11r */
> > -                             ignore_received_deauth = 1;
> > -                     }
> > +     }
> > +     int     ignore_received_deauth = 0;
> > +
> > +     /*      Commented by Albert 20130604 */
> > +     /*      Before sending the auth frame to start the STA/GC mode connection with AP/GO, */
> > +     /*      we will send the deauth first. */
> > +     /*      However, the Win8.1 with BRCM Wi-Fi will send the deauth with reason code 6 to us after receieving our deauth. */
> > +     /*      Added the following code to avoid this case. */
> > +     if ((pmlmeinfo->state & WIFI_FW_AUTH_STATE) ||
> > +             (pmlmeinfo->state & WIFI_FW_ASSOC_STATE)) {
>
> Very odd indentation :(
>

Just to make sure, are you not happy about the existing code or the
comments being indented? Because I've preserved the code structure and
have only removed the else branch. If you could clarify, I would know
what to fix.

Thanks!

-- 

Sevinj.Aghayeva

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

* Re: [PATCH 3/3] staging: rtl8723bs: remove redundant else branches
  2022-04-01 13:02 ` [PATCH 3/3] staging: rtl8723bs: remove redundant else branches Sevinj Aghayeva
  2022-04-01 18:08   ` kernel test robot
@ 2022-04-03 11:03   ` Greg Kroah-Hartman
  2022-04-03 15:33     ` Sevinj Aghayeva
  1 sibling, 1 reply; 9+ messages in thread
From: Greg Kroah-Hartman @ 2022-04-03 11:03 UTC (permalink / raw)
  To: Sevinj Aghayeva; +Cc: linux-staging, linux-kernel, outreachy

On Fri, Apr 01, 2022 at 09:02:47AM -0400, Sevinj Aghayeva wrote:
> Adhere to Linux kernel coding style.
> 
> Reported by checkpatch:
> 
> WARNING: else is not generally useful after a break or return
> 
> Signed-off-by: Sevinj Aghayeva <sevinj.aghayeva@gmail.com>
> ---
>  drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 63 +++++++++----------
>  1 file changed, 30 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
> index 81e4b1bf68f6..b80d9061f5a5 100644
> --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
> +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
> @@ -907,10 +907,9 @@ unsigned int OnAuthClient(struct adapter *padapter, union recv_frame *precv_fram
>  			set_link_timer(pmlmeext, REAUTH_TO);
>  
>  			return _SUCCESS;
> -		} else {
> -			/*  open system */
> -			go2asoc = 1;
>  		}
> +		/*  open system */
> +		go2asoc = 1;
>  	} else if (seq == 4) {
>  		if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared)
>  			go2asoc = 1;
> @@ -1502,32 +1501,32 @@ unsigned int OnDeAuth(struct adapter *padapter, union recv_frame *precv_frame)
>  
>  
>  		return _SUCCESS;
> -	} else {
> -		int	ignore_received_deauth = 0;
> -
> -		/* 	Commented by Albert 20130604 */
> -		/* 	Before sending the auth frame to start the STA/GC mode connection with AP/GO, */
> -		/* 	we will send the deauth first. */
> -		/* 	However, the Win8.1 with BRCM Wi-Fi will send the deauth with reason code 6 to us after receieving our deauth. */
> -		/* 	Added the following code to avoid this case. */
> -		if ((pmlmeinfo->state & WIFI_FW_AUTH_STATE) ||
> -			(pmlmeinfo->state & WIFI_FW_ASSOC_STATE)) {
> -			if (reason == WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA) {
> -				ignore_received_deauth = 1;
> -			} else if (reason == WLAN_REASON_PREV_AUTH_NOT_VALID) {
> -				/*  TODO: 802.11r */
> -				ignore_received_deauth = 1;
> -			}
> +	}
> +	int	ignore_received_deauth = 0;
> +
> +	/* 	Commented by Albert 20130604 */
> +	/* 	Before sending the auth frame to start the STA/GC mode connection with AP/GO, */
> +	/* 	we will send the deauth first. */
> +	/* 	However, the Win8.1 with BRCM Wi-Fi will send the deauth with reason code 6 to us after receieving our deauth. */
> +	/* 	Added the following code to avoid this case. */
> +	if ((pmlmeinfo->state & WIFI_FW_AUTH_STATE) ||
> +		(pmlmeinfo->state & WIFI_FW_ASSOC_STATE)) {

Very odd indentation :(


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

* Re: [PATCH 3/3] staging: rtl8723bs: remove redundant else branches
  2022-04-01 13:02 ` [PATCH 3/3] staging: rtl8723bs: remove redundant else branches Sevinj Aghayeva
@ 2022-04-01 18:08   ` kernel test robot
  2022-04-03 11:03   ` Greg Kroah-Hartman
  1 sibling, 0 replies; 9+ messages in thread
From: kernel test robot @ 2022-04-01 18:08 UTC (permalink / raw)
  To: Sevinj Aghayeva, Greg Kroah-Hartman
  Cc: kbuild-all, linux-staging, linux-kernel, outreachy, Sevinj Aghayeva

Hi Sevinj,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on staging/staging-testing]
[also build test WARNING on v5.17 next-20220401]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Sevinj-Aghayeva/rlt8723bs-cleanup/20220401-210507
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git b22c721c4f3fd4608da059c56fbe7a0cc598fb6a
config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20220402/202204020208.cUdIa2Q2-lkp@intel.com/config)
compiler: alpha-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/ed0a6d578663ac28fa89918bc7ad86c0e6f82f8a
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Sevinj-Aghayeva/rlt8723bs-cleanup/20220401-210507
        git checkout ed0a6d578663ac28fa89918bc7ad86c0e6f82f8a
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=alpha SHELL=/bin/bash drivers/staging/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/staging/rtl8723bs/core/rtw_mlme_ext.c: In function 'OnDeAuth':
>> drivers/staging/rtl8723bs/core/rtw_mlme_ext.c:1505:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
    1505 |         int     ignore_received_deauth = 0;
         |         ^~~


vim +1505 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c

554c0a3abf216c Hans de Goede   2017-03-29  1461  
554c0a3abf216c Hans de Goede   2017-03-29  1462  unsigned int OnDeAuth(struct adapter *padapter, union recv_frame *precv_frame)
554c0a3abf216c Hans de Goede   2017-03-29  1463  {
554c0a3abf216c Hans de Goede   2017-03-29  1464  	unsigned short	reason;
554c0a3abf216c Hans de Goede   2017-03-29  1465  	struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
554c0a3abf216c Hans de Goede   2017-03-29  1466  	struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
554c0a3abf216c Hans de Goede   2017-03-29  1467  	struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
554c0a3abf216c Hans de Goede   2017-03-29  1468  	u8 *pframe = precv_frame->u.hdr.rx_data;
554c0a3abf216c Hans de Goede   2017-03-29  1469  
554c0a3abf216c Hans de Goede   2017-03-29  1470  	/* check A3 */
554c0a3abf216c Hans de Goede   2017-03-29  1471  	if (memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), ETH_ALEN))
554c0a3abf216c Hans de Goede   2017-03-29  1472  		return _SUCCESS;
554c0a3abf216c Hans de Goede   2017-03-29  1473  
554c0a3abf216c Hans de Goede   2017-03-29  1474  	reason = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN));
554c0a3abf216c Hans de Goede   2017-03-29  1475  
0ad02fa8b90a87 Georgiana Chelu 2017-09-22  1476  	if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
554c0a3abf216c Hans de Goede   2017-03-29  1477  		struct sta_info *psta;
554c0a3abf216c Hans de Goede   2017-03-29  1478  		struct sta_priv *pstapriv = &padapter->stapriv;
554c0a3abf216c Hans de Goede   2017-03-29  1479  
554c0a3abf216c Hans de Goede   2017-03-29  1480  		/* rtw_free_stainfo(padapter, psta); */
554c0a3abf216c Hans de Goede   2017-03-29  1481  
79df841b435018 Fabio Aiuto     2021-04-15  1482  		netdev_dbg(padapter->pnetdev,
79df841b435018 Fabio Aiuto     2021-04-15  1483  			   "ap recv deauth reason code(%d) sta:%pM\n", reason,
79df841b435018 Fabio Aiuto     2021-04-15  1484  			   GetAddr2Ptr(pframe));
554c0a3abf216c Hans de Goede   2017-03-29  1485  
554c0a3abf216c Hans de Goede   2017-03-29  1486  		psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe));
554c0a3abf216c Hans de Goede   2017-03-29  1487  		if (psta) {
554c0a3abf216c Hans de Goede   2017-03-29  1488  			u8 updated = false;
554c0a3abf216c Hans de Goede   2017-03-29  1489  
554c0a3abf216c Hans de Goede   2017-03-29  1490  			spin_lock_bh(&pstapriv->asoc_list_lock);
554c0a3abf216c Hans de Goede   2017-03-29  1491  			if (list_empty(&psta->asoc_list) == false) {
554c0a3abf216c Hans de Goede   2017-03-29  1492  				list_del_init(&psta->asoc_list);
554c0a3abf216c Hans de Goede   2017-03-29  1493  				pstapriv->asoc_list_cnt--;
554c0a3abf216c Hans de Goede   2017-03-29  1494  				updated = ap_free_sta(padapter, psta, false, reason);
554c0a3abf216c Hans de Goede   2017-03-29  1495  
554c0a3abf216c Hans de Goede   2017-03-29  1496  			}
554c0a3abf216c Hans de Goede   2017-03-29  1497  			spin_unlock_bh(&pstapriv->asoc_list_lock);
554c0a3abf216c Hans de Goede   2017-03-29  1498  
554c0a3abf216c Hans de Goede   2017-03-29  1499  			associated_clients_update(padapter, updated);
554c0a3abf216c Hans de Goede   2017-03-29  1500  		}
554c0a3abf216c Hans de Goede   2017-03-29  1501  
554c0a3abf216c Hans de Goede   2017-03-29  1502  
554c0a3abf216c Hans de Goede   2017-03-29  1503  		return _SUCCESS;
ed0a6d578663ac Sevinj Aghayeva 2022-04-01  1504  	}
554c0a3abf216c Hans de Goede   2017-03-29 @1505  	int	ignore_received_deauth = 0;
554c0a3abf216c Hans de Goede   2017-03-29  1506  
554c0a3abf216c Hans de Goede   2017-03-29  1507  	/* 	Commented by Albert 20130604 */
554c0a3abf216c Hans de Goede   2017-03-29  1508  	/* 	Before sending the auth frame to start the STA/GC mode connection with AP/GO, */
554c0a3abf216c Hans de Goede   2017-03-29  1509  	/* 	we will send the deauth first. */
554c0a3abf216c Hans de Goede   2017-03-29  1510  	/* 	However, the Win8.1 with BRCM Wi-Fi will send the deauth with reason code 6 to us after receieving our deauth. */
554c0a3abf216c Hans de Goede   2017-03-29  1511  	/* 	Added the following code to avoid this case. */
554c0a3abf216c Hans de Goede   2017-03-29  1512  	if ((pmlmeinfo->state & WIFI_FW_AUTH_STATE) ||
554c0a3abf216c Hans de Goede   2017-03-29  1513  		(pmlmeinfo->state & WIFI_FW_ASSOC_STATE)) {
554c0a3abf216c Hans de Goede   2017-03-29  1514  		if (reason == WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA) {
554c0a3abf216c Hans de Goede   2017-03-29  1515  			ignore_received_deauth = 1;
a8be3a14951eb8 Sevinj Aghayeva 2022-04-01  1516  		} else if (reason == WLAN_REASON_PREV_AUTH_NOT_VALID) {
554c0a3abf216c Hans de Goede   2017-03-29  1517  			/*  TODO: 802.11r */
554c0a3abf216c Hans de Goede   2017-03-29  1518  			ignore_received_deauth = 1;
554c0a3abf216c Hans de Goede   2017-03-29  1519  		}
554c0a3abf216c Hans de Goede   2017-03-29  1520  	}
554c0a3abf216c Hans de Goede   2017-03-29  1521  
79df841b435018 Fabio Aiuto     2021-04-15  1522  	netdev_dbg(padapter->pnetdev,
79df841b435018 Fabio Aiuto     2021-04-15  1523  		"sta recv deauth reason code(%d) sta:%pM, ignore = %d\n",
79df841b435018 Fabio Aiuto     2021-04-15  1524  		reason, GetAddr3Ptr(pframe),
79df841b435018 Fabio Aiuto     2021-04-15  1525  		ignore_received_deauth);
554c0a3abf216c Hans de Goede   2017-03-29  1526  
a8be3a14951eb8 Sevinj Aghayeva 2022-04-01  1527  	if (ignore_received_deauth == 0)
554c0a3abf216c Hans de Goede   2017-03-29  1528  		receive_disconnect(padapter, GetAddr3Ptr(pframe), reason);
ed0a6d578663ac Sevinj Aghayeva 2022-04-01  1529  
554c0a3abf216c Hans de Goede   2017-03-29  1530  	pmlmepriv->LinkDetectInfo.bBusyTraffic = false;
554c0a3abf216c Hans de Goede   2017-03-29  1531  	return _SUCCESS;
554c0a3abf216c Hans de Goede   2017-03-29  1532  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

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

* [PATCH 3/3] staging: rtl8723bs: remove redundant else branches
  2022-04-01 13:02 [PATCH " Sevinj Aghayeva
@ 2022-04-01 13:02 ` Sevinj Aghayeva
  2022-04-01 18:08   ` kernel test robot
  2022-04-03 11:03   ` Greg Kroah-Hartman
  0 siblings, 2 replies; 9+ messages in thread
From: Sevinj Aghayeva @ 2022-04-01 13:02 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-staging, linux-kernel, outreachy, Sevinj Aghayeva

Adhere to Linux kernel coding style.

Reported by checkpatch:

WARNING: else is not generally useful after a break or return

Signed-off-by: Sevinj Aghayeva <sevinj.aghayeva@gmail.com>
---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 63 +++++++++----------
 1 file changed, 30 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index 81e4b1bf68f6..b80d9061f5a5 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -907,10 +907,9 @@ unsigned int OnAuthClient(struct adapter *padapter, union recv_frame *precv_fram
 			set_link_timer(pmlmeext, REAUTH_TO);
 
 			return _SUCCESS;
-		} else {
-			/*  open system */
-			go2asoc = 1;
 		}
+		/*  open system */
+		go2asoc = 1;
 	} else if (seq == 4) {
 		if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared)
 			go2asoc = 1;
@@ -1502,32 +1501,32 @@ unsigned int OnDeAuth(struct adapter *padapter, union recv_frame *precv_frame)
 
 
 		return _SUCCESS;
-	} else {
-		int	ignore_received_deauth = 0;
-
-		/* 	Commented by Albert 20130604 */
-		/* 	Before sending the auth frame to start the STA/GC mode connection with AP/GO, */
-		/* 	we will send the deauth first. */
-		/* 	However, the Win8.1 with BRCM Wi-Fi will send the deauth with reason code 6 to us after receieving our deauth. */
-		/* 	Added the following code to avoid this case. */
-		if ((pmlmeinfo->state & WIFI_FW_AUTH_STATE) ||
-			(pmlmeinfo->state & WIFI_FW_ASSOC_STATE)) {
-			if (reason == WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA) {
-				ignore_received_deauth = 1;
-			} else if (reason == WLAN_REASON_PREV_AUTH_NOT_VALID) {
-				/*  TODO: 802.11r */
-				ignore_received_deauth = 1;
-			}
+	}
+	int	ignore_received_deauth = 0;
+
+	/* 	Commented by Albert 20130604 */
+	/* 	Before sending the auth frame to start the STA/GC mode connection with AP/GO, */
+	/* 	we will send the deauth first. */
+	/* 	However, the Win8.1 with BRCM Wi-Fi will send the deauth with reason code 6 to us after receieving our deauth. */
+	/* 	Added the following code to avoid this case. */
+	if ((pmlmeinfo->state & WIFI_FW_AUTH_STATE) ||
+		(pmlmeinfo->state & WIFI_FW_ASSOC_STATE)) {
+		if (reason == WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA) {
+			ignore_received_deauth = 1;
+		} else if (reason == WLAN_REASON_PREV_AUTH_NOT_VALID) {
+			/*  TODO: 802.11r */
+			ignore_received_deauth = 1;
 		}
+	}
 
-		netdev_dbg(padapter->pnetdev,
-			   "sta recv deauth reason code(%d) sta:%pM, ignore = %d\n",
-			   reason, GetAddr3Ptr(pframe),
-			   ignore_received_deauth);
+	netdev_dbg(padapter->pnetdev,
+		"sta recv deauth reason code(%d) sta:%pM, ignore = %d\n",
+		reason, GetAddr3Ptr(pframe),
+		ignore_received_deauth);
+
+	if (ignore_received_deauth == 0)
+		receive_disconnect(padapter, GetAddr3Ptr(pframe), reason);
 
-		if (ignore_received_deauth == 0)
-			receive_disconnect(padapter, GetAddr3Ptr(pframe), reason);
-	}
 	pmlmepriv->LinkDetectInfo.bBusyTraffic = false;
 	return _SUCCESS;
 
@@ -1574,16 +1573,14 @@ unsigned int OnDisassoc(struct adapter *padapter, union recv_frame *precv_frame)
 		}
 
 		return _SUCCESS;
-	} else {
-		netdev_dbg(padapter->pnetdev,
-			   "sta recv disassoc reason code(%d) sta:%pM\n",
-			   reason, GetAddr3Ptr(pframe));
-
-		receive_disconnect(padapter, GetAddr3Ptr(pframe), reason);
 	}
+	netdev_dbg(padapter->pnetdev,
+		"sta recv disassoc reason code(%d) sta:%pM\n",
+		reason, GetAddr3Ptr(pframe));
+
+	receive_disconnect(padapter, GetAddr3Ptr(pframe), reason);
 	pmlmepriv->LinkDetectInfo.bBusyTraffic = false;
 	return _SUCCESS;
-
 }
 
 unsigned int OnAtim(struct adapter *padapter, union recv_frame *precv_frame)
-- 
2.25.1


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

end of thread, other threads:[~2022-04-03 15:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-01 19:06 [PATCH v2 0/3] rlt8723bs cleanup Sevinj Aghayeva
2022-04-01 19:06 ` [PATCH 1/3] staging: rtl8723bs: remove redundant braces in if statements Sevinj Aghayeva
2022-04-01 19:06 ` [PATCH 2/3] staging: rtl8723bs: place constants on the right side of tests Sevinj Aghayeva
2022-04-01 19:07 ` [PATCH 3/3] staging: rtl8723bs: remove redundant else branches Sevinj Aghayeva
2022-04-01 19:13 ` [PATCH v2 0/3] rlt8723bs cleanup Sevinj Aghayeva
  -- strict thread matches above, loose matches on Subject: below --
2022-04-01 13:02 [PATCH " Sevinj Aghayeva
2022-04-01 13:02 ` [PATCH 3/3] staging: rtl8723bs: remove redundant else branches Sevinj Aghayeva
2022-04-01 18:08   ` kernel test robot
2022-04-03 11:03   ` Greg Kroah-Hartman
2022-04-03 15:33     ` Sevinj Aghayeva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).