[PATCH 17/25] MBO: Re-factor wpas_mbo_np_chan_attrs()

Ilan Peer ilan.peer at intel.com
Mon Feb 15 06:53:45 PST 2016


From: Avraham Stern <avraham.stern at intel.com>

Re-factor wpas_mbo_np_chan_attrs() to make it more readable
and remove local variables that are not necessary.

Signed-off-by: Avraham Stern <avraham.stern at intel.com>
---
 wpa_supplicant/mbo.c | 27 ++++++++-------------------
 1 file changed, 8 insertions(+), 19 deletions(-)

diff --git a/wpa_supplicant/mbo.c b/wpa_supplicant/mbo.c
index 2fda743..af7edde 100644
--- a/wpa_supplicant/mbo.c
+++ b/wpa_supplicant/mbo.c
@@ -82,9 +82,6 @@ static void wpas_mbo_np_chan_attr(struct wpa_supplicant *wpa_s,
 {
 	size_t size = end - start + 4;
 
-	if (start == end)
-		return;
-
 	if (size + 2 > wpabuf_tailroom(mbo))
 		return;
 
@@ -109,9 +106,6 @@ static void wpas_mbo_np_chan_subelement(struct wpa_supplicant *wpa_s,
 {
 	size_t size = end - start + 8;
 
-	if (start == end)
-		return;
-
 	if (size + 2 > wpabuf_tailroom(mbo))
 		return;
 
@@ -123,7 +117,6 @@ static void wpas_mbo_np_chan_subelement(struct wpa_supplicant *wpa_s,
 static void wpas_mbo_np_chan_attrs(struct wpa_supplicant *wpa_s,
 				   struct wpabuf *mbo, int subelement)
 {
-	u8 oper_class = 0, reason = 0, reason_detail = 0, preference = 0;
 	u8 i, start = 0;
 
 	if (!wpa_s->np_chan || !wpa_s->np_chan_num) {
@@ -132,26 +125,22 @@ static void wpas_mbo_np_chan_attrs(struct wpa_supplicant *wpa_s,
 		return;
 	}
 
-	for (i = 0; i <= wpa_s->np_chan_num; i++) {
+	for (i = 1; i <= wpa_s->np_chan_num; i++) {
 		if (i == wpa_s->np_chan_num ||
-		    wpa_s->np_chan[i].oper_class != oper_class ||
-		    wpa_s->np_chan[i].reason != reason ||
-		    wpa_s->np_chan[i].reason_detail != reason_detail ||
-		    wpa_s->np_chan[i].preference != preference) {
+		    wpa_s->np_chan[i].oper_class !=
+		    wpa_s->np_chan[start].oper_class ||
+		    wpa_s->np_chan[i].reason != wpa_s->np_chan[start].reason ||
+		    wpa_s->np_chan[i].reason_detail !=
+		    wpa_s->np_chan[start].reason_detail ||
+		    wpa_s->np_chan[i].preference !=
+		    wpa_s->np_chan[start].preference) {
 			if (subelement)
 				wpas_mbo_np_chan_subelement(wpa_s, mbo, start,
 							    i);
 			else
 				wpas_mbo_np_chan_attr(wpa_s, mbo, start, i);
 
-			if (i == wpa_s->np_chan_num)
-				return;
-
 			start = i;
-			oper_class = wpa_s->np_chan[i].oper_class;
-			reason = wpa_s->np_chan[i].reason;
-			reason_detail = wpa_s->np_chan[i].reason_detail;
-			preference = wpa_s->np_chan[i].preference;
 		}
 	}
 }
-- 
1.9.1




More information about the Hostap mailing list