All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Staging: wlan-ng: improve code aspect in p80211req_mibset_mibget()
@ 2016-09-06 16:30 Claudiu Beznea
  2016-09-12 11:19 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Claudiu Beznea @ 2016-09-06 16:30 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-kernel, Claudiu Beznea

This patch improves code aspect in p80211req_mibset_mibget() function
by removing accolades which followed case statements. To do so,
some data variable ware declared at the beginning of the
function and also pstr and key variables were initialized
only in the code which uses them.

Signed-off-by: Claudiu Beznea <claudiu.beznea@gmail.com>
---
 drivers/staging/wlan-ng/p80211req.c | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/wlan-ng/p80211req.c b/drivers/staging/wlan-ng/p80211req.c
index 5c2b801..fe5bf4b 100644
--- a/drivers/staging/wlan-ng/p80211req.c
+++ b/drivers/staging/wlan-ng/p80211req.c
@@ -196,22 +196,26 @@ static void p80211req_mibset_mibget(wlandevice_t *wlandev,
 				   int isget)
 {
 	p80211itemd_t *mibitem = (p80211itemd_t *) mib_msg->mibattribute.data;
-	p80211pstrd_t *pstr = (p80211pstrd_t *) mibitem->data;
-	u8 *key = mibitem->data + sizeof(p80211pstrd_t);
+	p80211pstrd_t *pstr;
+	u8 *key;
+	u32 *data;
 
 	switch (mibitem->did) {
 	case DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0:
 	case DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1:
 	case DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2:
 	case DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3:
-		if (!isget)
+		if (!isget) {
+			pstr = (struct p80211pstrd *)mibitem->data;
+			key = mibitem->data + sizeof(struct p80211pstrd);
 			wep_change_key(wlandev,
 				       P80211DID_ITEM(mibitem->did) - 1,
 				       key, pstr->len);
+		}
 		break;
 
-	case DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID:{
-		u32 *data = (u32 *) mibitem->data;
+	case DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID:
+		data = (u32 *)mibitem->data;
 
 		if (isget) {
 			*data = wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK;
@@ -219,21 +223,20 @@ static void p80211req_mibset_mibget(wlandevice_t *wlandev,
 			wlandev->hostwep &= ~(HOSTWEP_DEFAULTKEY_MASK);
 			wlandev->hostwep |= (*data & HOSTWEP_DEFAULTKEY_MASK);
 		}
-	break;
-	}
-	case DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked:{
-		u32 *data = (u32 *) mibitem->data;
+		break;
+
+	case DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked:
+		data = (u32 *)mibitem->data;
 
 		p80211req_handle_action(wlandev, data, isget,
 					HOSTWEP_PRIVACYINVOKED);
-	break;
-	}
-	case DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted:{
-		u32 *data = (u32 *) mibitem->data;
+		break;
+
+	case DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted:
+		data = (u32 *)mibitem->data;
 
 		p80211req_handle_action(wlandev, data, isget,
 					HOSTWEP_EXCLUDEUNENCRYPTED);
-	break;
-	}
+		break;
 	}
 }
-- 
1.9.1

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

* Re: [PATCH] Staging: wlan-ng: improve code aspect in p80211req_mibset_mibget()
  2016-09-06 16:30 [PATCH] Staging: wlan-ng: improve code aspect in p80211req_mibset_mibget() Claudiu Beznea
@ 2016-09-12 11:19 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2016-09-12 11:19 UTC (permalink / raw)
  To: Claudiu Beznea; +Cc: devel, linux-kernel

On Tue, Sep 06, 2016 at 07:30:50PM +0300, Claudiu Beznea wrote:
> This patch improves code aspect in p80211req_mibset_mibget() function
> by removing accolades which followed case statements. To do so,
> some data variable ware declared at the beginning of the
> function and also pstr and key variables were initialized
> only in the code which uses them.
> 
> Signed-off-by: Claudiu Beznea <claudiu.beznea@gmail.com>
> ---
>  drivers/staging/wlan-ng/p80211req.c | 33 ++++++++++++++++++---------------
>  1 file changed, 18 insertions(+), 15 deletions(-)

Didn't apply to my tree for some reason, can you refresh and resend?

thanks,

greg k-h

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

end of thread, other threads:[~2016-09-12 11:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-06 16:30 [PATCH] Staging: wlan-ng: improve code aspect in p80211req_mibset_mibget() Claudiu Beznea
2016-09-12 11:19 ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.