Skip to contentSkip to conversation

staging: rtl8188eu: add spaces around operators in mlme_linux.c

PATCH In review Michael Straube 2 participants 4 messages Jan 17, 2019 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 staging: rtl8188eu: add spaces around operators in mlme_linux.c

Add spaces around '+' and '-' to follow kernel coding style. Reported by checkpatch.

---
 drivers/staging/rtl8188eu/os_dep/mlme_linux.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8188eu/os_dep/mlme_linux.c +2 -2
index d5ceb3beabbc..8180769610c3 100644
@@ -99,13 +99,13 @@ void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie)
 		memset(buff, 0, IW_CUSTOM_MAX);
 		p = buff;
 		p += sprintf(p, "ASSOCINFO(ReqIEs =");
-		len = sec_ie[1]+2;
+		len = sec_ie[1] + 2;
 		len =  min_t(uint, len, IW_CUSTOM_MAX);
 		for (i = 0; i < len; i++)
 			p += sprintf(p, "%02x", sec_ie[i]);
 		p += sprintf(p, ")");
 		memset(&wrqu, 0, sizeof(wrqu));
-		wrqu.data.length = p-buff;
+		wrqu.data.length = p - buff;
 		wrqu.data.length = min_t(__u16, wrqu.data.length, IW_CUSTOM_MAX);
 		wireless_send_event(adapter->pnetdev, IWEVCUSTOM, &wrqu, buff);
 		kfree(buff);
Signature · 1 line
2.20.1
#1 lore raw

PATCH 2/2 staging: rtl8188eu: cleanup indenting issue in mlme_linux.c

Cleanup indenting issue reported by checkpatch.
CHECK: Alignment should match open parenthesis

---
 drivers/staging/rtl8188eu/os_dep/mlme_linux.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/rtl8188eu/os_dep/mlme_linux.c +2 -3
index 8180769610c3..2bc49d074ce4 100644
@@ -52,9 +52,8 @@ void rtw_reset_securitypriv(struct adapter *adapter)
 		memset((unsigned char *)&adapter->securitypriv, 0, sizeof(struct security_priv));
 
 		/*  Restore the PMK information to securitypriv structure for the following connection. */
-		memcpy(&adapter->securitypriv.PMKIDList[0],
-			    &backup_pmkid[0],
-			    sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
+		memcpy(&adapter->securitypriv.PMKIDList[0], &backup_pmkid[0],
+		       sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
 		adapter->securitypriv.PMKIDIndex = backup_index;
 		adapter->securitypriv.btkip_countermeasure = backup_counter;
 		adapter->securitypriv.btkip_countermeasure_time = backup_time;
Signature · 1 line
2.20.1
#2 lore raw

Re: [PATCH 2/2] staging: rtl8188eu: cleanup indenting issue in mlme_linux.c

Quoted 2 lines · Michael Straube

Cleanup indenting issue reported by checkpatch.
CHECK: Alignment should match open parenthesis

[]

drivers/staging/rtl8188eu/os_dep/mlme_linux.c

Quoted 1 line
drivers/staging/rtl8188eu/os_dep/mlme_linux.c +0 -0

[]

drivers/staging/rtl8188eu/os_dep/mlme_linux.c void rtw_reset_securitypriv(struct adapter *adapter) · line 56

Quoted 9 lines
drivers/staging/rtl8188eu/os_dep/mlme_linux.c +2 -3
@@ -52,9 +52,8 @@ void rtw_reset_securitypriv(struct adapter *adapter)
 		memset((unsigned char *)&adapter->securitypriv, 0, sizeof(struct security_priv));
 
 		/*  Restore the PMK information to securitypriv structure for the following connection. */
-		memcpy(&adapter->securitypriv.PMKIDList[0],
-			    &backup_pmkid[0],
-			    sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
+		memcpy(&adapter->securitypriv.PMKIDList[0], &backup_pmkid[0],
+		       sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);

Hi.

Please try not to blindly follow checkpatch messages but please do try to make the code more readable.

Just below this block is another block with a temporary that uses &adapter->securitypriv.

How about hoisting the temporary and using that?

Something like:

---
 drivers/staging/rtl8188eu/os_dep/mlme_linux.c | 32 +++++++++++++--------------
 1 file changed, 16 insertions(+), 16 deletions(-)
drivers/staging/rtl8188eu/os_dep/mlme_linux.c +16 -16
index d5ceb3beabbc..320a0be2af3d 100644
@@ -39,31 +39,31 @@ void rtw_reset_securitypriv(struct adapter *adapter)
 	u8	backup_index = 0;
 	u8	backup_counter = 0x00;
 	u32	backup_time = 0;
+	struct security_priv *psec_priv = &adapter->securitypriv;
 
-	if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) {
+	if (psec_priv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) {
 		/* 802.1x */
 		/*  We have to backup the PMK information for WiFi PMK Caching test item. */
 		/*  Backup the btkip_countermeasure information. */
 		/*  When the countermeasure is trigger, the driver have to disconnect with AP for 60 seconds. */
-		memcpy(&backup_pmkid[0], &adapter->securitypriv.PMKIDList[0], sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
-		backup_index = adapter->securitypriv.PMKIDIndex;
-		backup_counter = adapter->securitypriv.btkip_countermeasure;
-		backup_time = adapter->securitypriv.btkip_countermeasure_time;
-		memset((unsigned char *)&adapter->securitypriv, 0, sizeof(struct security_priv));
+		memcpy(backup_pmkid, psec_priv->PMKIDList,
+		       sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
+		backup_index = psec_priv->PMKIDIndex;
+		backup_counter = psec_priv->btkip_countermeasure;
+		backup_time = psec_priv->btkip_countermeasure_time;
+
+		memset(psec_priv, 0, sizeof(*psec_priv));
 
 		/*  Restore the PMK information to securitypriv structure for the following connection. */
-		memcpy(&adapter->securitypriv.PMKIDList[0],
-			    &backup_pmkid[0],
-			    sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
-		adapter->securitypriv.PMKIDIndex = backup_index;
-		adapter->securitypriv.btkip_countermeasure = backup_counter;
-		adapter->securitypriv.btkip_countermeasure_time = backup_time;
-		adapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen;
-		adapter->securitypriv.ndisencryptstatus = Ndis802_11WEPDisabled;
+		memcpy(psec_priv->PMKIDList, backup_pmkid,
+		       sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
+		psec_priv->PMKIDIndex = backup_index;
+		psec_priv->btkip_countermeasure = backup_counter;
+		psec_priv->btkip_countermeasure_time = backup_time;
+		psec_priv->ndisauthtype = Ndis802_11AuthModeOpen;
+		psec_priv->ndisencryptstatus = Ndis802_11WEPDisabled;
 	} else {
 		/* reset values in securitypriv */
-		struct security_priv *psec_priv = &adapter->securitypriv;
-
 		psec_priv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open;
 		psec_priv->dot11PrivacyAlgrthm = _NO_PRIVACY_;
 		psec_priv->dot11PrivacyKeyIndex = 0;
#3 lore raw

Re: [PATCH 2/2] staging: rtl8188eu: cleanup indenting issue in mlme_linux.c

Quoted 18 lines · Joe Perches
Quoted 2 lines · Michael Straube

Cleanup indenting issue reported by checkpatch.
CHECK: Alignment should match open parenthesis

[]

drivers/staging/rtl8188eu/os_dep/mlme_linux.c

Quoted 1 line
drivers/staging/rtl8188eu/os_dep/mlme_linux.c +0 -0

[]

drivers/staging/rtl8188eu/os_dep/mlme_linux.c void rtw_reset_securitypriv(struct adapter *adapter) · line 56

Quoted 9 lines
drivers/staging/rtl8188eu/os_dep/mlme_linux.c +2 -3
@@ -52,9 +52,8 @@ void rtw_reset_securitypriv(struct adapter *adapter)
  		memset((unsigned char *)&adapter->securitypriv, 0, sizeof(struct security_priv));
 
  		/*  Restore the PMK information to securitypriv structure for the following connection. */
-		memcpy(&adapter->securitypriv.PMKIDList[0],
-			    &backup_pmkid[0],
-			    sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
+		memcpy(&adapter->securitypriv.PMKIDList[0], &backup_pmkid[0],
+		       sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);

Hi.

Quoted 8 lines

Please try not to blindly follow checkpatch messages but please do try to make the code more readable.

Just below this block is another block with a temporary that uses &adapter->securitypriv.

How about hoisting the temporary and using that?

Hi.

I will keep that in mind and try to be more attentive. Thanks for the hints.

Quoted 59 lines

Something like:

---
  drivers/staging/rtl8188eu/os_dep/mlme_linux.c | 32 +++++++++++++--------------
  1 file changed, 16 insertions(+), 16 deletions(-)
drivers/staging/rtl8188eu/os_dep/mlme_linux.c +16 -16
index d5ceb3beabbc..320a0be2af3d 100644
@@ -39,31 +39,31 @@ void rtw_reset_securitypriv(struct adapter *adapter)
  	u8	backup_index = 0;
  	u8	backup_counter = 0x00;
  	u32	backup_time = 0;
+	struct security_priv *psec_priv = &adapter->securitypriv;
 
-	if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) {
+	if (psec_priv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) {
  		/* 802.1x */
  		/*  We have to backup the PMK information for WiFi PMK Caching test item. */
  		/*  Backup the btkip_countermeasure information. */
  		/*  When the countermeasure is trigger, the driver have to disconnect with AP for 60 seconds. */
-		memcpy(&backup_pmkid[0], &adapter->securitypriv.PMKIDList[0], sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
-		backup_index = adapter->securitypriv.PMKIDIndex;
-		backup_counter = adapter->securitypriv.btkip_countermeasure;
-		backup_time = adapter->securitypriv.btkip_countermeasure_time;
-		memset((unsigned char *)&adapter->securitypriv, 0, sizeof(struct security_priv));
+		memcpy(backup_pmkid, psec_priv->PMKIDList,
+		       sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
+		backup_index = psec_priv->PMKIDIndex;
+		backup_counter = psec_priv->btkip_countermeasure;
+		backup_time = psec_priv->btkip_countermeasure_time;
+
+		memset(psec_priv, 0, sizeof(*psec_priv));
 
  		/*  Restore the PMK information to securitypriv structure for the following connection. */
-		memcpy(&adapter->securitypriv.PMKIDList[0],
-			    &backup_pmkid[0],
-			    sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
-		adapter->securitypriv.PMKIDIndex = backup_index;
-		adapter->securitypriv.btkip_countermeasure = backup_counter;
-		adapter->securitypriv.btkip_countermeasure_time = backup_time;
-		adapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen;
-		adapter->securitypriv.ndisencryptstatus = Ndis802_11WEPDisabled;
+		memcpy(psec_priv->PMKIDList, backup_pmkid,
+		       sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
+		psec_priv->PMKIDIndex = backup_index;
+		psec_priv->btkip_countermeasure = backup_counter;
+		psec_priv->btkip_countermeasure_time = backup_time;
+		psec_priv->ndisauthtype = Ndis802_11AuthModeOpen;
+		psec_priv->ndisencryptstatus = Ndis802_11WEPDisabled;
  	} else {
  		/* reset values in securitypriv */
-		struct security_priv *psec_priv = &adapter->securitypriv;
-
  		psec_priv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open;
  		psec_priv->dot11PrivacyAlgrthm = _NO_PRIVACY_;
  		psec_priv->dot11PrivacyKeyIndex = 0;