Module Name:    src
Committed By:   msaitoh
Date:           Wed Nov 22 04:27:57 UTC 2017

Modified Files:
        src/sys/net: if_ethersubr.c

Log Message:
- Modify ether_ioctl() for readability. No functional change.
- KNF


To generate a diff of this commit:
cvs rdiff -u -r1.246 -r1.247 src/sys/net/if_ethersubr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/if_ethersubr.c
diff -u src/sys/net/if_ethersubr.c:1.246 src/sys/net/if_ethersubr.c:1.247
--- src/sys/net/if_ethersubr.c:1.246	Thu Nov 16 03:07:18 2017
+++ src/sys/net/if_ethersubr.c	Wed Nov 22 04:27:57 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ethersubr.c,v 1.246 2017/11/16 03:07:18 ozaki-r Exp $	*/
+/*	$NetBSD: if_ethersubr.c,v 1.247 2017/11/22 04:27:57 msaitoh Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.246 2017/11/16 03:07:18 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.247 2017/11/22 04:27:57 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -226,13 +226,13 @@ ether_output(struct ifnet * const ifp0, 
 		ifp = ifp->if_carpdev;
 		/* ac = (struct arpcom *)ifp; */
 
-		if ((ifp0->if_flags & (IFF_UP|IFF_RUNNING)) !=
-		    (IFF_UP|IFF_RUNNING))
+		if ((ifp0->if_flags & (IFF_UP | IFF_RUNNING)) !=
+		    (IFF_UP | IFF_RUNNING))
 			senderr(ENETDOWN);
 	}
 #endif /* NCARP > 0 */
 
-	if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
+	if ((ifp->if_flags & (IFF_UP | IFF_RUNNING)) != (IFF_UP | IFF_RUNNING))
 		senderr(ENETDOWN);
 
 	switch (dst->sa_family) {
@@ -640,7 +640,7 @@ ether_input(struct ifnet *ifp, struct mb
 			return;
 	}
 #endif /* NCARP > 0 */
-	if ((m->m_flags & (M_BCAST|M_MCAST|M_PROMISC)) == 0 &&
+	if ((m->m_flags & (M_BCAST | M_MCAST | M_PROMISC)) == 0 &&
 	    (ifp->if_flags & IFF_PROMISC) != 0 &&
 	    memcmp(CLLADDR(ifp->if_sadl), eh->ether_dhost,
 		   ETHER_ADDR_LEN) != 0) {
@@ -1348,8 +1348,8 @@ ether_ioctl(struct ifnet *ifp, u_long cm
 	    {
 		struct ifaddr *ifa = (struct ifaddr *)data;
 		if (ifa->ifa_addr->sa_family != AF_LINK
-		    && (ifp->if_flags & (IFF_UP|IFF_RUNNING)) !=
-		       (IFF_UP|IFF_RUNNING)) {
+		    && (ifp->if_flags & (IFF_UP | IFF_RUNNING)) !=
+		       (IFF_UP | IFF_RUNNING)) {
 			ifp->if_flags |= IFF_UP;
 			if ((error = (*ifp->if_init)(ifp)) != 0)
 				return error;
@@ -1384,7 +1384,7 @@ ether_ioctl(struct ifnet *ifp, u_long cm
 	case SIOCSIFFLAGS:
 		if ((error = ifioctl_common(ifp, cmd, data)) != 0)
 			return error;
-		switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) {
+		switch (ifp->if_flags & (IFF_UP | IFF_RUNNING)) {
 		case IFF_RUNNING:
 			/*
 			 * If interface is marked down and it is running,
@@ -1398,18 +1398,21 @@ ether_ioctl(struct ifnet *ifp, u_long cm
 			 * start it.
 			 */
 			return (*ifp->if_init)(ifp);
-		case IFF_UP|IFF_RUNNING:
+		case IFF_UP | IFF_RUNNING:
 			error = 0;
-			if (ec->ec_ifflags_cb == NULL ||
-			    (error = (*ec->ec_ifflags_cb)(ec)) == ENETRESET) {
-				/*
-				 * Reset the interface to pick up
-				 * changes in any other flags that
-				 * affect the hardware state.
-				 */
-				return (*ifp->if_init)(ifp);
-			} else 
-				return error;
+			if (ec->ec_ifflags_cb != NULL) {
+				error = (*ec->ec_ifflags_cb)(ec);
+				if (error == ENETRESET) {
+					/*
+					 * Reset the interface to pick up
+					 * changes in any other flags that
+					 * affect the hardware state.
+					 */
+					return (*ifp->if_init)(ifp);
+				}
+			} else
+				error = (*ifp->if_init)(ifp);
+			return error;
 		case 0:
 			break;
 		}

Reply via email to