[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

route(8) knf



Here is a patch that cleans up some things in route(8), changing mostly
only whitespace and lint hints, with no functional change, so please let
me know of any breakage.

Index: ccitt_addr.c
===================================================================
RCS file: /cvs/src/sbin/route/ccitt_addr.c,v
retrieving revision 1.8
diff -u -p -r1.8 ccitt_addr.c
--- ccitt_addr.c	26 Jun 2003 16:35:21 -0000	1.8
+++ ccitt_addr.c	15 Sep 2004 00:20:26 -0000
@@ -60,14 +60,12 @@ static char *copychar(char *, char *);
 int	ccitt_addr(char *addr, struct sockaddr_x25 *xp);
 
 int
-ccitt_addr(addr, xp)
-char *addr;
-struct sockaddr_x25 *xp;
+ccitt_addr(char *addr, struct sockaddr_x25 *xp)
 {
 	char *p, *ap, *limit;
 	int havenet = 0;
 
-	memset(xp, 0, sizeof (*xp));
+	memset(xp, 0, sizeof(*xp));
 	xp->x25_family = AF_CCITT;
 	xp->x25_len = sizeof(*xp);
 	p = addr;
@@ -96,7 +94,7 @@ struct sockaddr_x25 *xp;
 	 */
 
 	ap = xp->x25_addr;
-	limit = ap + sizeof (xp->x25_addr) - 1;
+	limit = ap + sizeof(xp->x25_addr) - 1;
 	while (*p) {
 		if (*p == ',')
 			break;
@@ -104,7 +102,7 @@ struct sockaddr_x25 *xp;
 			if (havenet)
 				return (0);
 			havenet++;
-			xp->x25_net = atoi (xp->x25_addr);
+			xp->x25_net = atoi(xp->x25_addr);
 			p++;
 			ap = xp->x25_addr;
 			*ap = '\0';
@@ -124,14 +122,14 @@ struct sockaddr_x25 *xp;
 
 	p++;
 	ap = xp->x25_udata + 4;		/* first four bytes are protocol id */
-	limit = ap + sizeof (xp->x25_udata) - 4;
+	limit = ap + sizeof(xp->x25_udata) - 4;
 	xp->x25_udlen = 4;
 	while (*p) {
 		if (*p == ',')
 			break;
 		if (ap >= limit)
 			return (0);
-		p = copychar (p, ap++);
+		p = copychar(p, ap++);
 		xp->x25_udlen++;
 	}
 	if (xp->x25_udlen == 4)
@@ -147,7 +145,7 @@ struct sockaddr_x25 *xp;
 			return (0);
 		if (ap >= limit)
 			return (0);
-		p = copychar (p, ap++);
+		p = copychar(p, ap++);
 	}
 	if (xp->x25_udlen == 0)
 		xp->x25_udlen = ap - xp->x25_udata;
@@ -155,8 +153,7 @@ struct sockaddr_x25 *xp;
 }
 
 static char *
-copychar (from, to)
-char *from, *to;
+copychar(char *from, char *to)
 {
 	int n;
 
Index: route.c
===================================================================
RCS file: /cvs/src/sbin/route/route.c,v
retrieving revision 1.73
diff -u -p -r1.73 route.c
--- route.c	7 Sep 2004 10:14:43 -0000	1.73
+++ route.c	15 Sep 2004 00:20:27 -0000
@@ -90,13 +90,14 @@ union	sockunion {
 typedef union sockunion *sup;
 pid_t	pid;
 int	rtm_addrs, s;
-int	forcehost, forcenet, doflush, nflag, af, qflag, tflag, keyword(char *);
-int	Sflag, iflag, verbose, aflen = sizeof (struct sockaddr_in);
+int	forcehost, forcenet, doflush, nflag, af, qflag, tflag;
+int	Sflag, iflag, verbose, aflen = sizeof(struct sockaddr_in);
 int	locking, lockrest, debugonly;
 struct	rt_metrics rt_metrics;
 u_long  rtm_inits;
 uid_t	uid;
 
+int	 keyword(char *);
 void	 flushroutes(int, char **);
 int	 newroute(int, char **);
 void	 show(int, char *[]);
@@ -129,9 +130,9 @@ usage(char *cp)
 	if (cp)
 		(void) fprintf(stderr, "route: botched keyword: %s\n", cp);
 	(void) fprintf(stderr,
-	    "usage: route [ -nqSv ] cmd [[ -<modifiers> ] args ]\n");
+	    "usage: route [-dnqtv] command [[modifiers] args]\n");
 	(void) fprintf(stderr,
-	    "keywords: get, add, change, delete, show, flush, monitor.\n");
+	    "commands: add, change, delete, flush, get, monitor, show\n");
 	exit(1);
 	/* NOTREACHED */
 }
@@ -220,6 +221,7 @@ main(int argc, char **argv)
 	no_cmd:
 	default:
 		usage(*argv);
+		/* NOTREACHED */
 	}
 	exit(rval);
 }
@@ -621,32 +623,33 @@ show(int argc, char *argv[])
 {
 	int	af = 0;
 
-        if (argc > 1) {
-                argv++;
-                if (argc == 2 && **argv == '-')
-                    switch (keyword(*argv + 1)) {
-                        case K_INET:
-                                af = AF_INET;
-                                break;
+	if (argc > 1) {
+		argv++;
+		if (argc == 2 && **argv == '-')
+			switch (keyword(*argv + 1)) {
+			case K_INET:
+				af = AF_INET;
+				break;
 #ifdef INET6
-                        case K_INET6:
-                                af = AF_INET6;
-                                break;
+			case K_INET6:
+				af = AF_INET6;
+				break;
 #endif
-                        case K_IPX:
-                                af = AF_IPX;
-                                break;
-                        case K_LINK:
-                                af = AF_LINK;
-                                break;
-                        case K_X25:
-                                af = AF_CCITT;
-                                break;
-                        default:
-                                goto bad;
-                } else
-bad:                    usage(*argv);
-        }
+			case K_IPX:
+				af = AF_IPX;
+				break;
+			case K_LINK:
+				af = AF_LINK;
+				break;
+			case K_X25:
+				af = AF_CCITT;
+				break;
+			default:
+				goto bad;
+			}
+		else
+bad:			usage(*argv);
+	}
 	
 	p_rttables(af, 0, Sflag);
 }
@@ -675,11 +678,11 @@ inet_makenetandmask(u_int32_t net, struc
 	} else {
 		addr = net;
 		if ((addr & IN_CLASSA_HOST) == 0)
-			mask =  IN_CLASSA_NET;
+			mask = IN_CLASSA_NET;
 		else if ((addr & IN_CLASSB_HOST) == 0)
-			mask =  IN_CLASSB_NET;
+			mask = IN_CLASSB_NET;
 		else if ((addr & IN_CLASSC_HOST) == 0)
-			mask =  IN_CLASSC_NET;
+			mask = IN_CLASSC_NET;
 		else
 			mask = -1;
 	}
@@ -773,6 +776,7 @@ getaddr(int which, char *s, struct hoste
 		break;
 	default:
 		errx(1, "internal error");
+		/* NOTREACHED */
 	}
 	su->sa.sa_len = aflen;
 	su->sa.sa_family = afamily;
@@ -786,6 +790,7 @@ getaddr(int which, char *s, struct hoste
 		case RTA_NETMASK:
 		case RTA_GENMASK:
 			su->sa.sa_len = 0;
+			break;
 		}
 		return (0);
 	}
@@ -895,9 +900,11 @@ getaddr(int which, char *s, struct hoste
 			return (1);
 		}
 		errx(1, "%s: bad address", s);
+		/* NOTREACHED */
 
 	default:
 		errx(1, "%d: bad address family", afamily);
+		/* NOTREACHED */
 	}
 }
 
@@ -920,6 +927,7 @@ prefixlen(char *s)
 		(void) fprintf(stderr,
 		    "prefixlen is not supported with af %d\n", af);
 		exit(1);
+		/* NOTREACHED */
 	}
 
 	rtm_addrs |= RTA_NETMASK;
@@ -1010,7 +1018,7 @@ monitor(void)
 		interfaces();
 		exit(0);
 	}
-	for(;;) {
+	for (;;) {
 		time_t now;
 		n = read(s, msg, 2048);
 		now = time(NULL);
@@ -1222,6 +1230,7 @@ print_rtmsg(struct rt_msghdr *rtm, int m
 			(long)rtm->rtm_pid, rtm->rtm_seq, rtm->rtm_errno);
 		bprintf(stdout, rtm->rtm_flags, routeflags);
 		pmsg_common(rtm);
+		break;
 	}
 }
 
Index: show.c
===================================================================
RCS file: /cvs/src/sbin/route/show.c,v
retrieving revision 1.33
diff -u -p -r1.33 show.c
--- show.c	5 Jul 2004 02:19:03 -0000	1.33
+++ show.c	15 Sep 2004 00:20:28 -0000
@@ -120,7 +120,7 @@ p_rttables(int af, int Aflag, int Sflag)
 	char *buf = NULL, *next, *lim = NULL;
 	size_t needed;
 	int mib[6];
-        struct sockaddr *sa;
+	struct sockaddr *sa;
 
 	mib[0] = CTL_NET;
 	mib[1] = PF_ROUTE;
@@ -141,7 +141,7 @@ p_rttables(int af, int Aflag, int Sflag)
 			perror("sysctl of routing table");
 			exit(1);
 		}
-		lim  = buf + needed;
+		lim = buf + needed;
 	}
 
 	printf("Routing tables\n");
@@ -221,9 +221,7 @@ get_rtaddrs(int addrs, struct sockaddr *
  * Print a routing table entry.
  */
 void
-p_rtentry(rtm, Aflag, Sflag)
-	struct rt_msghdr *rtm;
-	int		  Aflag, Sflag;
+p_rtentry(struct rt_msghdr *rtm, int Aflag, int Sflag)
 {
 	static int	 old_af = -1;
 	struct sockaddr	*sa = (struct sockaddr *)(rtm + 1);
@@ -269,8 +267,7 @@ p_rtentry(rtm, Aflag, Sflag)
  * Print address family header before a section of the routing table.
  */
 void
-pr_family(af)
-	int af;
+pr_family(int af)
 {
 	char *afname;
 
@@ -353,10 +350,11 @@ p_sockaddr(struct sockaddr *sa, struct s
 	    }
 #endif
 	default:
-	    	if ((flags & RTF_HOST) || mask == NULL)
+		if ((flags & RTF_HOST) || mask == NULL)
 			cp = routename(sa);
 		else
 			cp = netname(sa, mask);;
+		break;
 	}
 	if (width < 0 )
 		printf("%s ", cp);
@@ -456,7 +454,7 @@ routename4(in_addr_t in)
 		cp = "default";
 	if (!cp && !nflag) {
 		if ((hp = gethostbyaddr((char *)&in,
-		    sizeof (in), AF_INET)) != NULL) {
+		    sizeof(in), AF_INET)) != NULL) {
 			if ((cp = strchr(hp->h_name, '.')) &&
 			    !strcmp(cp + 1, domain))
 				*cp = 0;
@@ -701,7 +699,7 @@ ipx_print(struct sockaddr *sa)
 	work = sipx->sipx_addr;
 	port = ntohs(work.ipx_port);
 	work.ipx_port = 0;
-	net.net_e  = work.ipx_net;
+	net.net_e = work.ipx_net;
 	if (ipx_nullhost(work) && net.long_e == 0) {
 		if (!port)
 			return ("*.*");