Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1469763 > unrolled thread

[PATCH] Staging: wlan-ng: removed duplicate code in p80211req.c

Started byClaudiu Beznea <claudiu.beznea@gmail.com>
First post2016-08-25 00:20 +0200
Last post2016-08-25 00:40 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] Staging: wlan-ng: removed duplicate code in p80211req.c Claudiu Beznea <claudiu.beznea@gmail.com> - 2016-08-25 00:20 +0200
    Re: [PATCH] Staging: wlan-ng: removed duplicate code in p80211req.c Joe Perches <joe@perches.com> - 2016-08-25 00:40 +0200

#1469763 — [PATCH] Staging: wlan-ng: removed duplicate code in p80211req.c

FromClaudiu Beznea <claudiu.beznea@gmail.com>
Date2016-08-25 00:20 +0200
Subject[PATCH] Staging: wlan-ng: removed duplicate code in p80211req.c
Message-ID<s9OGB-kt-3@gated-at.bofh.it>
This patch removes duplicate code in p80211req_mibset_mibget()
by adding p80211req_handle_action() function.

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

diff --git a/drivers/staging/wlan-ng/p80211req.c b/drivers/staging/wlan-ng/p80211req.c
index 4b84b56..7e91dfd 100644
--- a/drivers/staging/wlan-ng/p80211req.c
+++ b/drivers/staging/wlan-ng/p80211req.c
@@ -76,6 +76,8 @@ static void p80211req_handlemsg(wlandevice_t *wlandev, struct p80211msg *msg);
 static void p80211req_mibset_mibget(wlandevice_t *wlandev,
 				   struct p80211msg_dot11req_mibget *mib_msg,
 				   int isget);
+static void p80211req_handle_action(struct wlandevice *wlandev, u32 *data,
+				    int isget, u32 flag);
 
 /*----------------------------------------------------------------
 * p80211req_dorequest
@@ -219,32 +221,31 @@ static void p80211req_mibset_mibget(wlandevice_t *wlandev,
 	case DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked:{
 		u32 *data = (u32 *) mibitem->data;
 
-		if (isget) {
-			if (wlandev->hostwep & HOSTWEP_PRIVACYINVOKED)
-				*data = P80211ENUM_truth_true;
-			else
-				*data = P80211ENUM_truth_false;
-		} else {
-			wlandev->hostwep &= ~(HOSTWEP_PRIVACYINVOKED);
-			if (*data == P80211ENUM_truth_true)
-				wlandev->hostwep |= HOSTWEP_PRIVACYINVOKED;
-		}
+		p80211req_handle_action(wlandev, data, isget,
+					HOSTWEP_PRIVACYINVOKED);
 	break;
 	}
 	case DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted:{
 		u32 *data = (u32 *) mibitem->data;
 
-		if (isget) {
-			if (wlandev->hostwep & HOSTWEP_EXCLUDEUNENCRYPTED)
-				*data = P80211ENUM_truth_true;
-			else
-				*data = P80211ENUM_truth_false;
-		} else {
-			wlandev->hostwep &= ~(HOSTWEP_EXCLUDEUNENCRYPTED);
-			if (*data == P80211ENUM_truth_true)
-				wlandev->hostwep |= HOSTWEP_EXCLUDEUNENCRYPTED;
-		}
+		p80211req_handle_action(wlandev, data, isget,
+					HOSTWEP_EXCLUDEUNENCRYPTED);
 	break;
 	}
 	}
 }
+
+static void p80211req_handle_action(struct wlandevice *wlandev, u32 *data,
+				    int isget, u32 flag)
+{
+	if (isget) {
+		if (wlandev->hostwep & flag)
+			*data = P80211ENUM_truth_true;
+		else
+			*data = P80211ENUM_truth_false;
+	} else {
+		wlandev->hostwep &= ~flag;
+		if (*data == P80211ENUM_truth_true)
+			wlandev->hostwep |= flag;
+	}
+}
-- 
1.9.1

[toc] | [next] | [standalone]


#1469766

FromJoe Perches <joe@perches.com>
Date2016-08-25 00:40 +0200
Message-ID<s9OZX-yy-3@gated-at.bofh.it>
In reply to#1469763
On Thu, 2016-08-25 at 00:55 +0300, Claudiu Beznea wrote:
> This patch removes duplicate code in p80211req_mibset_mibget()
> by adding p80211req_handle_action() function.

Better would be to remove the prototype and move the
new static to the location of the prototype.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web