[RFC 5/5] hostapd: Reduce indention in vlan_dynamic_add

Helmut Schaa helmut.schaa
Mon Mar 17 06:16:28 PDT 2014


Signed-off-by: Helmut Schaa <helmut.schaa at googlemail.com>
---
 src/ap/vlan_init.c | 30 ++++++++++++++----------------
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/src/ap/vlan_init.c b/src/ap/vlan_init.c
index 4835860..cd775c7 100644
--- a/src/ap/vlan_init.c
+++ b/src/ap/vlan_init.c
@@ -931,25 +931,23 @@ int vlan_setup_encryption_dyn(struct hostapd_data *hapd,
 static int vlan_dynamic_add(struct hostapd_data *hapd,
 			    struct hostapd_vlan *vlan)
 {
-	while (vlan) {
-		if (vlan->vlan_id != VLAN_ID_WILDCARD) {
-			if (hostapd_vlan_if_add(hapd, vlan->ifname,
-						vlan->bridge[0] == '\0' ?
-						NULL : vlan->bridge)) {
-				if (errno != EEXIST) {
-					wpa_printf(MSG_ERROR, "VLAN: Could "
-						   "not add VLAN %s: %s",
-						   vlan->ifname,
-						   strerror(errno));
-					return -1;
-				}
+	for (; vlan; vlan = vlan->next) {
+		if (vlan->vlan_id == VLAN_ID_WILDCARD)
+			continue;
+
+		if (hostapd_vlan_if_add(hapd, vlan->ifname,
+					vlan->bridge[0] == '\0' ?
+					NULL : vlan->bridge)) {
+			if (errno != EEXIST) {
+				wpa_printf(MSG_ERROR, "VLAN: Could "
+					   "not add VLAN %s: %s",
+					   vlan->ifname, strerror(errno));
+				return -1;
 			}
+		}
 #ifdef CONFIG_FULL_DYNAMIC_VLAN
-			ifconfig_up(vlan->ifname);
+		ifconfig_up(vlan->ifname);
 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
-		}
-
-		vlan = vlan->next;
 	}
 
 	return 0;
-- 
1.8.1.4




More information about the Hostap mailing list