svn commit: r299768 - in head/sbin/routed: . rtquery

Pedro F. Giffuni pfg at FreeBSD.org
Sat May 14 22:40:10 UTC 2016


Author: pfg
Date: Sat May 14 22:40:08 2016
New Revision: 299768
URL: https://svnweb.freebsd.org/changeset/base/299768

Log:
  routed(8): use NULL instead of zero for pointers.

Modified:
  head/sbin/routed/if.c
  head/sbin/routed/input.c
  head/sbin/routed/main.c
  head/sbin/routed/output.c
  head/sbin/routed/parms.c
  head/sbin/routed/radix.c
  head/sbin/routed/rdisc.c
  head/sbin/routed/rtquery/rtquery.c
  head/sbin/routed/table.c
  head/sbin/routed/trace.c

Modified: head/sbin/routed/if.c
==============================================================================
--- head/sbin/routed/if.c	Sat May 14 22:29:11 2016	(r299767)
+++ head/sbin/routed/if.c	Sat May 14 22:40:08 2016	(r299768)
@@ -110,14 +110,14 @@ if_link(struct interface *ifp)
 
 	hifp = AHASH(ifp->int_addr);
 	ifp->int_ahash_prev = hifp;
-	if ((ifp->int_ahash = *hifp) != 0)
+	if ((ifp->int_ahash = *hifp) != NULL)
 		(*hifp)->int_ahash_prev = &ifp->int_ahash;
 	*hifp = ifp;
 
 	if (ifp->int_if_flags & IFF_BROADCAST) {
 		hifp = BHASH(ifp->int_brdaddr);
 		ifp->int_bhash_prev = hifp;
-		if ((ifp->int_bhash = *hifp) != 0)
+		if ((ifp->int_bhash = *hifp) != NULL)
 			(*hifp)->int_bhash_prev = &ifp->int_bhash;
 		*hifp = ifp;
 	}
@@ -128,11 +128,11 @@ if_link(struct interface *ifp)
 	hifp = nhash(ifp->int_name);
 	if (ifp->int_state & IS_ALIAS) {
 		/* put aliases on the end of the hash chain */
-		while (*hifp != 0)
+		while (*hifp != NULL)
 			hifp = &(*hifp)->int_nhash;
 	}
 	ifp->int_nhash_prev = hifp;
-	if ((ifp->int_nhash = *hifp) != 0)
+	if ((ifp->int_nhash = *hifp) != NULL)
 		(*hifp)->int_nhash_prev = &ifp->int_nhash;
 	*hifp = ifp;
 }
@@ -145,7 +145,7 @@ ifwithaddr(naddr addr,
 	   int	bcast,			/* notice IFF_BROADCAST address */
 	   int	remote)			/* include IS_REMOTE interfaces */
 {
-	struct interface *ifp, *possible = 0;
+	struct interface *ifp, *possible = NULL;
 
 	remote = (remote == 0) ? IS_REMOTE : 0;
 
@@ -185,7 +185,7 @@ ifwithname(char *name,			/* "ec0" or wha
 	struct interface *ifp;
 
 	for (;;) {
-		for (ifp = *nhash(name); ifp != 0; ifp = ifp->int_nhash) {
+		for (ifp = *nhash(name); ifp != NULL; ifp = ifp->int_nhash) {
 			/* If the network address is not specified,
 			 * ignore any alias interfaces.  Otherwise, look
 			 * for the interface with the target name and address.
@@ -239,7 +239,7 @@ iflookup(naddr addr)
 	struct interface *ifp, *maybe;
 	int once = 0;
 
-	maybe = 0;
+	maybe = NULL;
 	for (;;) {
 		LIST_FOREACH(ifp, &ifnet, int_list) {
 			if (ifp->int_if_flags & IFF_POINTOPOINT) {
@@ -255,13 +255,13 @@ iflookup(naddr addr)
 				/* Look for the longest approximate match.
 				 */
 				if (on_net(addr, ifp->int_net, ifp->int_mask)
-				    && (maybe == 0
+				    && (maybe == NULL
 					|| ifp->int_mask > maybe->int_mask))
 					maybe = ifp;
 			}
 		}
 
-		if (maybe != 0 || once || IF_RESCAN_DELAY())
+		if (maybe != NULL || once || IF_RESCAN_DELAY())
 			return maybe;
 		once = 1;
 
@@ -304,7 +304,7 @@ ripv1_mask_net(naddr addr,		/* in networ
 	if (addr == 0)			/* default always has 0 mask */
 		return mask;
 
-	if (ifp != 0 && ifp->int_ripv1_mask != HOST_MASK) {
+	if (ifp != NULL && ifp->int_ripv1_mask != HOST_MASK) {
 		/* If the target network is that of the associated interface
 		 * on which it arrived, then use the netmask of the interface.
 		 */
@@ -329,7 +329,7 @@ ripv1_mask_net(naddr addr,		/* in networ
 
 	/* check special definitions */
 	if (mask == 0) {
-		for (r1p = r1nets; r1p != 0; r1p = r1p->r1net_next) {
+		for (r1p = r1nets; r1p != NULL; r1p = r1p->r1net_next) {
 			if (on_net(addr, r1p->r1net_net, r1p->r1net_match)
 			    && r1p->r1net_mask > mask)
 				mask = r1p->r1net_mask;
@@ -425,7 +425,7 @@ check_remote(struct interface *ifp)
 	    return 1;
 
 	rt = rtfind(ifp->int_addr);
-	if (rt != 0
+	if (rt != NULL 
 	    && rt->rt_ifp != 0
 	    &&on_net(ifp->int_addr,
 		     rt->rt_ifp->int_net, rt->rt_ifp->int_mask))
@@ -497,7 +497,7 @@ ifdel(struct interface *ifp)
 			    && !TRACEACTIONS)
 				LOGERR("setsockopt(MCAST_LEAVE_GROUP RIP)");
 			if (rip_sock_mcast == ifp)
-				rip_sock_mcast = 0;
+				rip_sock_mcast = NULL;
 		}
 		if (ifp->int_rip_sock >= 0) {
 			(void)close(ifp->int_rip_sock);
@@ -906,7 +906,7 @@ ifinit(void)
 		ifp = ifwithname(ifs.int_name, ((ifs.int_state & IS_ALIAS)
 						? ifs.int_addr
 						: 0));
-		if (ifp != 0) {
+		if (ifp != NULL) {
 			ifp->int_state |= IS_CHECKED;
 
 			if (0 != ((ifp->int_if_flags ^ ifs.int_if_flags)
@@ -927,11 +927,11 @@ ifinit(void)
 				trace_act("interface %s has changed",
 					  ifp->int_name);
 				ifdel(ifp);
-				ifp = 0;
+				ifp = NULL;
 			}
 		}
 
-		if (ifp != 0) {
+		if (ifp != NULL) {
 			/* The primary representative of an alias worries
 			 * about how things are working.
 			 */
@@ -1051,7 +1051,7 @@ ifinit(void)
 		 */
 		ifp = check_dup(ifs.int_addr,ifs.int_dstaddr,ifs.int_mask,
 				ifs.int_if_flags);
-		if (ifp != 0) {
+		if (ifp != NULL) {
 			/* Ignore duplicates of itself, caused by having
 			 * IP aliases on the same network.
 			 */
@@ -1154,15 +1154,15 @@ ifinit(void)
 	if (advertise_mhome
 	    || (tot_interfaces > 1
 		&& mhome
-		&& (ifp = ifwithaddr(myaddr, 0, 0)) != 0
+		&& (ifp = ifwithaddr(myaddr, 0, 0)) != NULL
 		&& foundloopback)) {
 		advertise_mhome = 1;
 		rt = rtget(myaddr, HOST_MASK);
-		if (rt != 0) {
+		if (rt != NULL) {
 			if (rt->rt_ifp != ifp
 			    || rt->rt_router != loopaddr) {
 				rtdelete(rt);
-				rt = 0;
+				rt = NULL;
 			} else {
 				loop_rts.rts_ifp = ifp;
 				loop_rts.rts_metric = 0;
@@ -1171,7 +1171,7 @@ ifinit(void)
 					 &loop_rts, 0);
 			}
 		}
-		if (rt == 0) {
+		if (rt == NULL) {
 			loop_rts.rts_ifp = ifp;
 			loop_rts.rts_metric = 0;
 			rtadd(myaddr, HOST_MASK, RS_MHOME, &loop_rts);
@@ -1220,11 +1220,11 @@ ifinit(void)
 			 */
 			del_static(ifp->int_addr, HOST_MASK, 0, 0);
 			rt = rtget(ifp->int_addr, HOST_MASK);
-			if (rt != 0 && rt->rt_router != loopaddr) {
+			if (rt != NULL && rt->rt_router != loopaddr) {
 				rtdelete(rt);
-				rt = 0;
+				rt = NULL;
 			}
-			if (rt != 0) {
+			if (rt != NULL) {
 				if (!(rt->rt_state & RS_LOCAL)
 				    || rt->rt_metric > ifp->int_metric) {
 					ifp1 = ifp;
@@ -1247,16 +1247,17 @@ ifinit(void)
 	}
 
 	/* add the authority routes */
-	for (intnetp = intnets; intnetp!=0; intnetp = intnetp->intnet_next) {
+	for (intnetp = intnets; intnetp != NULL;
+	    intnetp = intnetp->intnet_next) {
 		rt = rtget(intnetp->intnet_addr, intnetp->intnet_mask);
-		if (rt != 0
+		if (rt != NULL
 		    && !(rt->rt_state & RS_NO_NET_SYN)
 		    && !(rt->rt_state & RS_NET_INT)) {
 			rtdelete(rt);
-			rt = 0;
+			rt = NULL;
 		}
-		if (rt == 0) {
-			loop_rts.rts_ifp = 0;
+		if (rt == NULL) {
+			loop_rts.rts_ifp = NULL;
 			loop_rts.rts_metric = intnetp->intnet_metric-1;
 			rtadd(intnetp->intnet_addr, intnetp->intnet_mask,
 			      RS_NET_SYN | RS_NET_INT, &loop_rts);
@@ -1281,14 +1282,14 @@ check_net_syn(struct interface *ifp)
 	if (have_ripv1_out || have_ripv1_in) {
 		ifp->int_state |= IS_NEED_NET_SYN;
 		rt = rtget(ifp->int_std_addr, ifp->int_std_mask);
-		if (rt != 0
+		if (rt != NULL
 		    && 0 == (rt->rt_state & RS_NO_NET_SYN)
 		    && (!(rt->rt_state & RS_NET_SYN)
 			|| rt->rt_metric > ifp->int_metric)) {
 			rtdelete(rt);
-			rt = 0;
+			rt = NULL;
 		}
-		if (rt == 0) {
+		if (rt == NULL) {
 			new.rts_ifp = ifp;
 			new.rts_gate = ifp->int_addr;
 			new.rts_router = ifp->int_addr;
@@ -1302,7 +1303,7 @@ check_net_syn(struct interface *ifp)
 
 		rt = rtget(ifp->int_std_addr,
 			   ifp->int_std_mask);
-		if (rt != 0
+		if (rt != NULL
 		    && (rt->rt_state & RS_NET_SYN)
 		    && rt->rt_ifp == ifp)
 			rtbad_sub(rt);
@@ -1357,21 +1358,21 @@ addrouteforif(struct interface *ifp)
 	 */
 	del_static(dst, ifp->int_mask, 0, 0);
 	rt = rtget(dst, ifp->int_mask);
-	if (rt != 0) {
+	if (rt != NULL) {
 		if ((rt->rt_ifp != ifp
 		     || rt->rt_router != ifp->int_addr)
 		    && (!(ifp->int_state & IS_DUP)
 			|| rt->rt_ifp == 0
 			|| (rt->rt_ifp->int_state & IS_BROKE))) {
 			rtdelete(rt);
-			rt = 0;
+			rt = NULL;
 		} else {
 			rtchange(rt, ((rt->rt_state | RS_IF)
 				      & ~(RS_NET_SYN | RS_LOCAL)),
 				 &new, 0);
 		}
 	}
-	if (rt == 0) {
+	if (rt == NULL) {
 		if (ifp->int_transitions++ > 0)
 			trace_act("re-install interface %s",
 				  ifp->int_name);

Modified: head/sbin/routed/input.c
==============================================================================
--- head/sbin/routed/input.c	Sat May 14 22:29:11 2016	(r299767)
+++ head/sbin/routed/input.c	Sat May 14 22:40:08 2016	(r299768)
@@ -100,9 +100,9 @@ read_rip(int sock,
 			if (aifp->int_addr == from.sin_addr.s_addr)
 				break;
 		}
-		if (aifp == 0) {
+		if (aifp == NULL) {
 			aifp = ifwithname(inbuf.ifname, 0);
-			if (aifp == 0) {
+			if (aifp == NULL) {
 				msglim(&bad_name, from.sin_addr.s_addr,
 				       "impossible interface name %.*s",
 				       IFNAMSIZ, inbuf.ifname);
@@ -115,13 +115,13 @@ read_rip(int sock,
 				/* If it came via the wrong interface, do not
 				 * trust it.
 				 */
-				aifp = 0;
+				aifp = NULL;
 			}
 		}
 #else
 		aifp = iflookup(from.sin_addr.s_addr);
 #endif
-		if (sifp == 0)
+		if (sifp == NULL)
 			sifp = aifp;
 
 		input(&from, sifp, aifp, &inbuf.pbuf.rip, cc);
@@ -148,19 +148,19 @@ input(struct sockaddr_in *from,		/* rece
 	struct interface *ifp1;
 	naddr gate, mask, v1_mask, dst, ddst_h = 0;
 	struct auth *ap;
-	struct tgate *tg = 0;
+	struct tgate *tg = NULL;
 	struct tgate_net *tn;
 	int i, j;
 
 	/* Notice when we hear from a remote gateway
 	 */
-	if (aifp != 0
+	if (aifp != NULL
 	    && (aifp->int_state & IS_REMOTE))
 		aifp->int_act_time = now.tv_sec;
 
 	trace_rip("Recv", "from", from, sifp, rip, cc);
 
-	if (sifp == 0) {
+	if (sifp == NULL) {
 		trace_pkt("    discard a request from an indirect router"
 		    " (possibly an attack)");
 		return;
@@ -206,7 +206,7 @@ input(struct sockaddr_in *from,		/* rece
 	case RIPCMD_REQUEST:
 		/* For mere requests, be a little sloppy about the source
 		 */
-		if (aifp == 0)
+		if (aifp == NULL)
 			aifp = sifp;
 
 		/* Are we talking to ourself or a remote gateway?
@@ -233,7 +233,7 @@ input(struct sockaddr_in *from,		/* rece
 			 * the router does not depend on us.
 			 */
 			if (rip_sock < 0
-			    || (aifp != 0
+			    || (aifp != NULL
 				&& IS_RIP_OUT_OFF(aifp->int_state))) {
 				trace_pkt("    discard request while RIP off");
 				return;
@@ -263,20 +263,20 @@ input(struct sockaddr_in *from,		/* rece
 		}
 
 		if (rip->rip_vers == RIPv2
-		    && (aifp == 0 || (aifp->int_state & IS_NO_RIPV1_OUT))) {
+		    && (aifp == NULL || (aifp->int_state & IS_NO_RIPV1_OUT))) {
 			v12buf.buf->rip_vers = RIPv2;
 			/* If we have a secret but it is a cleartext secret,
 			 * do not disclose our secret unless the other guy
 			 * already knows it.
 			 */
 			ap = find_auth(aifp);
-			if (ap != 0 && ap->type == RIP_AUTH_PW
+			if (ap != NULL && ap->type == RIP_AUTH_PW
 			    && n->n_family == RIP_AF_AUTH
 			    && !ck_passwd(aifp,rip,lim,FROM_NADDR,&use_auth))
-				ap = 0;
+				ap = NULL;
 		} else {
 			v12buf.buf->rip_vers = RIPv1;
-			ap = 0;
+			ap = NULL;
 		}
 		clr_ws_buf(&v12buf, ap);
 
@@ -308,7 +308,8 @@ input(struct sockaddr_in *from,		/* rece
 					if ((aifp != NULL && insecure > 0) ||
 					    (aifp == NULL && insecure > 1))
 						supply(from, aifp, OUT_QUERY, 0,
-						       rip->rip_vers, ap != 0);
+						       rip->rip_vers,
+						       ap != NULL);
 					else
 						trace_pkt("Warning: "
 						    "possible attack detected");
@@ -323,7 +324,7 @@ input(struct sockaddr_in *from,		/* rece
 				 * to keep an unwary host that is just starting
 				 * from picking us as a router.
 				 */
-				if (aifp == 0) {
+				if (aifp == NULL) {
 					trace_pkt("ignore distant router");
 					return;
 				}
@@ -347,7 +348,7 @@ input(struct sockaddr_in *from,		/* rece
 					v12buf.n->n_family = RIP_AF_INET;
 					v12buf.n->n_dst = RIP_DEFAULT;
 					i = aifp->int_d_metric;
-					if (0 != (rt = rtget(RIP_DEFAULT, 0))) {
+					if (NULL != (rt = rtget(RIP_DEFAULT, 0))) {
 					    j = (rt->rt_metric
 						 +aifp->int_metric
 						 +aifp->int_adj_outmetric
@@ -369,7 +370,7 @@ input(struct sockaddr_in *from,		/* rece
 				supply(from, aifp, OUT_UNICAST, 0,
 				       (aifp->int_state & IS_NO_RIPV1_OUT)
 				       ? RIPv2 : RIPv1,
-				       ap != 0);
+				       ap != NULL);
 				return;
 			}
 
@@ -411,7 +412,7 @@ input(struct sockaddr_in *from,		/* rece
 
 			if (v12buf.buf->rip_vers != RIPv1)
 				v12buf.n->n_mask = mask;
-			if (rt == 0) {
+			if (rt == NULL) {
 				/* we do not have the answer */
 				v12buf.n->n_metric = HOPCNT_INFINITY;
 			} else {
@@ -433,7 +434,7 @@ input(struct sockaddr_in *from,		/* rece
 				if (v12buf.buf->rip_vers != RIPv1) {
 					v12buf.n->n_tag = rt->rt_tag;
 					v12buf.n->n_mask = mask;
-					if (aifp != 0
+					if (aifp != NULL
 					    && on_net(rt->rt_gate,
 						      aifp->int_net,
 						      aifp->int_mask)
@@ -451,7 +452,7 @@ input(struct sockaddr_in *from,		/* rece
 
 		/* Send the answer about specific routes.
 		 */
-		if (ap != 0 && ap->type == RIP_AUTH_MD5)
+		if (ap != NULL && ap->type == RIP_AUTH_MD5)
 			end_md5_auth(&v12buf, ap);
 
 		if (from->sin_port != htons(RIP_PORT)) {
@@ -486,7 +487,7 @@ input(struct sockaddr_in *from,		/* rece
 			       naddr_ntoa(FROM_NADDR));
 			return;
 		}
-		if (aifp == 0) {
+		if (aifp == NULL) {
 			msglog("trace command from unknown router %s",
 			       naddr_ntoa(FROM_NADDR));
 			return;
@@ -543,7 +544,7 @@ input(struct sockaddr_in *from,		/* rece
 		 * via broadcast or point-to-point networks, and from
 		 * those listed in /etc/gateways.
 		 */
-		if (aifp == 0) {
+		if (aifp == NULL) {
 			msglim(&unk_router, FROM_NADDR,
 			       "   discard response from %s"
 			       " via unexpected interface",
@@ -588,7 +589,7 @@ input(struct sockaddr_in *from,		/* rece
 			tg = tgates;
 			while (tg->tgate_addr != FROM_NADDR) {
 				tg = tg->tgate_next;
-				if (tg == 0) {
+				if (tg == NULL) {
 					trace_pkt("    discard RIP response"
 						  " from untrusted router %s",
 						  naddr_ntoa(FROM_NADDR));
@@ -733,7 +734,7 @@ input(struct sockaddr_in *from,		/* rece
 			 * of the defense against RS_NET_SYN.
 			 */
 			if (have_ripv1_out
-			    && (((rt = rtget(dst,mask)) == 0
+			    && (((rt = rtget(dst,mask)) == NULL
 				 || !(rt->rt_state & RS_NET_SYN)))
 			    && (v1_mask = ripv1_mask_net(dst,0)) > mask) {
 				ddst_h = v1_mask & -v1_mask;
@@ -798,7 +799,7 @@ input_route(naddr dst,			/* network orde
 	 * If our interface is broken, switch to using the other guy.
 	 */
 	ifp1 = ifwithaddr(dst, 1, 1);
-	if (ifp1 != 0
+	if (ifp1 != NULL
 	    && (!(ifp1->int_state & IS_BROKE)
 		|| (ifp1->int_state & IS_PASSIVE)))
 		return;
@@ -809,7 +810,7 @@ input_route(naddr dst,			/* network orde
 
 	/* Consider adding the route if we do not already have it.
 	 */
-	if (rt == 0) {
+	if (rt == NULL) {
 		/* Ignore unknown routes being poisoned.
 		 */
 		if (new->rts_metric == HOPCNT_INFINITY)
@@ -817,7 +818,7 @@ input_route(naddr dst,			/* network orde
 
 		/* Ignore the route if it points to us */
 		if (n->n_nhop != 0
-		    && 0 != ifwithaddr(n->n_nhop, 1, 0))
+		    && ifwithaddr(n->n_nhop, 1, 0) != NULL)
 			return;
 
 		/* If something has not gone crazy and tried to fill
@@ -915,7 +916,7 @@ input_route(naddr dst,			/* network orde
 		 * Ignore the route if it points to us.
 		 */
 		if (n->n_nhop != 0
-		    && 0 != ifwithaddr(n->n_nhop, 1, 0))
+		    && NULL != ifwithaddr(n->n_nhop, 1, 0))
 			return;
 
 		/* the loop above set rts0=worst spare */

Modified: head/sbin/routed/main.c
==============================================================================
--- head/sbin/routed/main.c	Sat May 14 22:29:11 2016	(r299767)
+++ head/sbin/routed/main.c	Sat May 14 22:40:08 2016	(r299768)
@@ -752,7 +752,7 @@ rip_on(struct interface *ifp)
 	 * multicasts for this interface.
 	 */
 	if (rip_sock >= 0) {
-		if (ifp != 0)
+		if (ifp != NULL)
 			rip_mcast_on(ifp);
 		return;
 	}
@@ -778,7 +778,7 @@ rip_on(struct interface *ifp)
 		}
 
 		rip_sock = get_rip_sock(INADDR_ANY, 1);
-		rip_sock_mcast = 0;
+		rip_sock_mcast = NULL;
 
 		/* Do not advertise anything until we have heard something
 		 */
@@ -791,7 +791,7 @@ rip_on(struct interface *ifp)
 		}
 		ifinit_timer.tv_sec = now.tv_sec;
 
-	} else if (ifp != 0
+	} else if (ifp != NULL
 		   && !(ifp->int_state & IS_REMOTE)
 		   && ifp->int_rip_sock < 0) {
 		/* RIP is off, so ensure there are sockets on which
@@ -811,7 +811,7 @@ rtmalloc(size_t size,
 	 const char *msg)
 {
 	void *p = malloc(size);
-	if (p == 0)
+	if (p == NULL)
 		logbad(1,"malloc(%lu) failed in %s", (u_long)size, msg);
 	return p;
 }
@@ -871,7 +871,7 @@ msglog(const char *p, ...)
 	va_start(args, p);
 	vsyslog(LOG_ERR, p, args);
 	va_end(args);
-	if (ftrace != 0) {
+	if (ftrace != NULL) {
 		if (ftrace == stdout)
 			(void)fputs("routed: ", ftrace);
 		va_start(args, p);
@@ -906,7 +906,7 @@ msglim(struct msg_limit *lim, naddr addr
 			/* Reuse a slot at most once every 10 minutes.
 			 */
 			if (lim->reuse > now.tv_sec) {
-				ms = 0;
+				ms = NULL;
 			} else {
 				ms = ms1;
 				lim->reuse = now.tv_sec + 10*60;
@@ -918,13 +918,13 @@ msglim(struct msg_limit *lim, naddr addr
 			 * most once an hour.
 			 */
 			if (ms->until > now.tv_sec)
-				ms = 0;
+				ms = NULL;
 			break;
 		}
 		if (ms->until < ms1->until)
 			ms = ms1;
 	}
-	if (ms != 0) {
+	if (ms != NULL) {
 		ms->addr = addr;
 		ms->until = now.tv_sec + 60*60;	/* 60 minutes */
 
@@ -937,7 +937,7 @@ msglim(struct msg_limit *lim, naddr addr
 	}
 
 	/* always display the message if tracing */
-	if (ftrace != 0) {
+	if (ftrace != NULL) {
 		va_start(args, p);
 		(void)vfprintf(ftrace, p, args);
 		va_end(args);

Modified: head/sbin/routed/output.c
==============================================================================
--- head/sbin/routed/output.c	Sat May 14 22:29:11 2016	(r299767)
+++ head/sbin/routed/output.c	Sat May 14 22:40:08 2016	(r299768)
@@ -164,7 +164,7 @@ output(enum output_type type,
 					LOGERR("setsockopt(rip_sock, "
 					       "IP_MULTICAST_IF)");
 					errno = serrno;
-					ifp = 0;
+					ifp = NULL;
 					return -1;
 				}
 				rip_sock_mcast = ifp;
@@ -187,11 +187,11 @@ output(enum output_type type,
 	res = sendto(soc, buf, size, flags,
 		     (struct sockaddr *)&osin, sizeof(osin));
 	if (res < 0
-	    && (ifp == 0 || !(ifp->int_state & IS_BROKE))) {
+	    && (ifp == NULL || !(ifp->int_state & IS_BROKE))) {
 		serrno = errno;
 		msglog("%s sendto(%s%s%s.%d): %s", msg,
-		       ifp != 0 ? ifp->int_name : "",
-		       ifp != 0 ? ", " : "",
+		       ifp != NULL ? ifp->int_name : "",
+		       ifp != NULL ? ", " : "",
 		       inet_ntoa(osin.sin_addr),
 		       ntohs(osin.sin_port),
 		       strerror(errno));
@@ -214,10 +214,10 @@ find_auth(struct interface *ifp)
 	int i;
 
 
-	if (ifp == 0)
+	if (ifp == NULL)
 		return 0;
 
-	res = 0;
+	res = NULL;
 	ap = ifp->int_auth;
 	for (i = 0; i < MAX_AUTH_KEYS; i++, ap++) {
 		/* stop looking after the last key */
@@ -230,13 +230,13 @@ find_auth(struct interface *ifp)
 
 		if ((u_long)ap->end < (u_long)clk.tv_sec) {
 			/* note best expired password as a fall-back */
-			if (res == 0 || (u_long)ap->end > (u_long)res->end)
+			if (res == NULL || (u_long)ap->end > (u_long)res->end)
 				res = ap;
 			continue;
 		}
 
 		/* note key with the best future */
-		if (res == 0 || (u_long)res->end < (u_long)ap->end)
+		if (res == NULL || (u_long)res->end < (u_long)ap->end)
 			res = ap;
 	}
 	return res;
@@ -255,7 +255,7 @@ clr_ws_buf(struct ws_buf *wb,
 
 	/* (start to) install authentication if appropriate
 	 */
-	if (ap == 0)
+	if (ap == NULL)
 		return;
 
 	na = (struct netauth*)wb->n;
@@ -317,11 +317,11 @@ supply_write(struct ws_buf *wb)
 	case NO_OUT_RIPV2:
 		break;
 	default:
-		if (ws.a != 0 && ws.a->type == RIP_AUTH_MD5)
+		if (ws.a != NULL && ws.a->type == RIP_AUTH_MD5)
 			end_md5_auth(wb,ws.a);
 		if (output(wb->type, &ws.to, ws.ifp, wb->buf,
 			   ((char *)wb->n - (char*)wb->buf)) < 0
-		    && ws.ifp != 0)
+		    && ws.ifp != NULL)
 			if_sick(ws.ifp);
 		ws.npackets++;
 		break;
@@ -587,7 +587,7 @@ walk_supply(struct radix_node *rn,
 	 * to say every 30 seconds to help detect broken Ethernets or
 	 * other interfaces where one packet every 30 seconds costs nothing.
 	 */
-	if (ws.ifp != 0
+	if (ws.ifp != NULL
 	    && !(ws.state & WS_ST_QUERY)
 	    && (ws.state & WS_ST_TO_ON_NET)
 	    && (!(RT->rt_state & RS_IF)
@@ -680,7 +680,7 @@ supply(struct sockaddr_in *dst,
 	ws.to_std_mask = std_mask(ws.to.sin_addr.s_addr);
 	ws.to_std_net = ntohl(ws.to.sin_addr.s_addr) & ws.to_std_mask;
 
-	if (ifp != 0) {
+	if (ifp != NULL) {
 		ws.to_mask = ifp->int_mask;
 		ws.to_net = ifp->int_net;
 		if (on_net(ws.to.sin_addr.s_addr, ws.to_net, ws.to_mask))
@@ -698,7 +698,7 @@ supply(struct sockaddr_in *dst,
 	if (flash)
 		ws.state |= WS_ST_FLASH;
 
-	if ((ws.ifp = ifp) == 0) {
+	if ((ws.ifp = ifp) == NULL) {
 		ws.metric = 1;
 	} else {
 		/* Adjust the advertised metric by the outgoing interface
@@ -739,18 +739,18 @@ supply(struct sockaddr_in *dst,
 		if ((ws.state & WS_ST_QUERY)
 		    || !(ws.state & WS_ST_TO_ON_NET)) {
 			ws.state |= (WS_ST_AG | WS_ST_SUPER_AG);
-		} else if (ifp == 0 || !(ifp->int_state & IS_NO_AG)) {
+		} else if (ifp == NULL || !(ifp->int_state & IS_NO_AG)) {
 			ws.state |= WS_ST_AG;
 			if (type != OUT_BROADCAST
-			    && (ifp == 0
+			    && (ifp == NULL
 				|| !(ifp->int_state & IS_NO_SUPER_AG)))
 				ws.state |= WS_ST_SUPER_AG;
 		}
 	}
 
 	ws.a = (vers == RIPv2) ? find_auth(ifp) : 0;
-	if (!passwd_ok && ws.a != 0 && ws.a->type == RIP_AUTH_PW)
-		ws.a = 0;
+	if (!passwd_ok && ws.a != NULL && ws.a->type == RIP_AUTH_PW)
+		ws.a = NULL;
 	clr_ws_buf(&v12buf,ws.a);
 	clr_ws_buf(&v2buf,ws.a);
 
@@ -758,7 +758,7 @@ supply(struct sockaddr_in *dst,
 	 * a better, real default route.
 	 */
 	if (supplier && (def_metric = ifp->int_d_metric) != 0) {
-		if (0 == (rt = rtget(RIP_DEFAULT, 0))
+		if ((rt = rtget(RIP_DEFAULT, 0)) == NULL 
 		    || rt->rt_metric+ws.metric >= def_metric) {
 			ws.state |= WS_ST_DEFAULT;
 			ag_check(0, 0, 0, 0, def_metric, def_metric,

Modified: head/sbin/routed/parms.c
==============================================================================
--- head/sbin/routed/parms.c	Sat May 14 22:29:11 2016	(r299767)
+++ head/sbin/routed/parms.c	Sat May 14 22:40:08 2016	(r299768)
@@ -60,7 +60,7 @@ get_parms(struct interface *ifp)
 
 	/* get all relevant parameters
 	 */
-	for (parmp = parms; parmp != 0; parmp = parmp->parm_next) {
+	for (parmp = parms; parmp != NULL; parmp = parmp->parm_next) {
 		if (parmp->parm_name[0] == '\0'
 		    || !strcmp(ifp->int_name, parmp->parm_name)
 		    || (parmp->parm_name[0] == '\n'
@@ -178,7 +178,7 @@ gwkludge(void)
 
 
 	fp = fopen(_PATH_GATEWAYS, "r");
-	if (fp == 0)
+	if (fp == NULL)
 		return;
 
 	if (0 > fstat(fileno(fp), &sb)) {
@@ -208,7 +208,7 @@ gwkludge(void)
 			cp = parse_parms(lptr,
 					 (sb.st_uid == 0
 					  && !(sb.st_mode&(S_IRWXG|S_IRWXO))));
-			if (cp != 0)
+			if (cp != NULL)
 				msglog("%s in line %d of "_PATH_GATEWAYS,
 				       cp, lnum);
 			continue;
@@ -315,7 +315,7 @@ gwkludge(void)
 			state |= IS_NO_RIP;
 
 		ifp = check_dup(gate,dst,netmask,state);
-		if (ifp != 0) {
+		if (ifp != NULL) {
 			msglog("duplicate "_PATH_GATEWAYS" entry \"%s\"",lptr);
 			continue;
 		}
@@ -419,7 +419,7 @@ exit:
 		return -1;
 
 	*buf = '\0';			/* terminate copy of token */
-	if (delimp != 0)
+	if (delimp != NULL)
 		*delimp = c;		/* return delimiter */
 	*linep = pc-1;			/* say where we ended */
 	return 0;
@@ -521,14 +521,14 @@ get_passwd(char *tgt,
 
 		if (delim == '|') {
 			val0 = ++val;
-			if (0 != (p = parse_ts(&k.start,&val,val0,&delim,
-					       buf,sizeof(buf))))
+			if (NULL != (p = parse_ts(&k.start,&val,val0,&delim,
+						  buf,sizeof(buf))))
 				return p;
 			if (delim != '|')
 				return "missing second timestamp";
 			val0 = ++val;
-			if (0 != (p = parse_ts(&k.end,&val,val0,&delim,
-					       buf,sizeof(buf))))
+			if (NULL != (p = parse_ts(&k.end,&val,val0,&delim,
+						  buf,sizeof(buf))))
 				return p;
 			if ((u_long)k.start > (u_long)k.end) {
 				sprintf(buf,"out of order timestamp %.30s",
@@ -570,7 +570,7 @@ parse_parms(char *line,
 	struct r1net *r1netp;
 	struct tgate *tg;
 	naddr addr, mask;
-	char delim, *val0 = 0, *tgt, *val, *p;
+	char delim, *val0 = NULL, *tgt, *val, *p;
 	const char *msg;
 	char buf[BUFSIZ], buf2[BUFSIZ];
 	int i;
@@ -856,7 +856,7 @@ check_parms(struct parm *new)
 	/* compare with existing sets of parameters
 	 */
 	for (parmpp = &parms;
-	     (parmp = *parmpp) != 0;
+	     (parmp = *parmpp) != NULL;
 	     parmpp = &parmp->parm_next) {
 		if (strcmp(new->parm_name, parmp->parm_name))
 			continue;
@@ -943,7 +943,7 @@ getnet(char *name,
 
 	/* Detect and separate "1.2.3.4/24"
 	 */
-	if (0 != (mname = strrchr(name,'/'))) {
+	if (NULL != (mname = strrchr(name,'/'))) {
 		i = (int)(mname - name);
 		if (i > (int)sizeof(hname)-1)	/* name too long */
 			return 0;
@@ -954,7 +954,7 @@ getnet(char *name,
 	}
 
 	np = getnetbyname(name);
-	if (np != 0) {
+	if (np != NULL) {
 		in.s_addr = (naddr)np->n_net;
 		if (0 == (in.s_addr & 0xff000000))
 			in.s_addr <<= 8;

Modified: head/sbin/routed/radix.c
==============================================================================
--- head/sbin/routed/radix.c	Sat May 14 22:29:11 2016	(r299767)
+++ head/sbin/routed/radix.c	Sat May 14 22:40:08 2016	(r299768)
@@ -169,7 +169,8 @@ rn_lookup(void *v_arg, void *m_arg, stru
 	caddr_t netmask = 0;
 
 	if (m_arg) {
-		if ((x = rn_addmask(m_arg, 1, head->rnh_treetop->rn_off)) == 0)
+		if ((x = rn_addmask(m_arg, 1,
+		    head->rnh_treetop->rn_off)) == NULL)
 			return (0);
 		netmask = x->rn_key;
 	}
@@ -190,7 +191,7 @@ rn_satisfies_leaf(char *trial,
 	char *cplim;
 	int length = min(*(u_char *)cp, *(u_char *)cp2);
 
-	if (cp3 == 0)
+	if (cp3 == NULL)
 		cp3 = rn_ones;
 	else
 		length = min(length, *(u_char *)cp3);
@@ -445,7 +446,7 @@ rn_addmask(void *n_arg, int search, int 
 	*addmask_key = last_zeroed = mlen;
 	x = rn_search(addmask_key, rn_masktop);
 	if (Bcmp(addmask_key, x->rn_key, mlen) != 0)
-		x = 0;
+		x = NULL;
 	if (x || search)
 		return (x);
 	x = (struct radix_node *)rtmalloc(max_keylen + 2*sizeof(*x),
@@ -500,7 +501,7 @@ rn_new_radix_mask(struct radix_node *tt,
 	struct radix_mask *m;
 
 	MKGet(m);
-	if (m == 0) {
+	if (m == NULL) {
 		log(LOG_ERR, "Mask for route not entered\n");
 		return (0);
 	}
@@ -523,7 +524,7 @@ rn_addroute(void *v_arg,
 	    struct radix_node treenodes[2])
 {
 	caddr_t v = (caddr_t)v_arg, netmask = (caddr_t)n_arg;
-	struct radix_node *t, *x = 0, *tt;
+	struct radix_node *t, *x = NULL, *tt;
 	struct radix_node *saved_tt, *top = head->rnh_treetop;
 	short b = 0, b_leaf = 0;
 	int keyduplicated;
@@ -538,7 +539,7 @@ rn_addroute(void *v_arg,
 	 * nodes and possibly save time in calculating indices.
 	 */
 	if (netmask)  {
-		if ((x = rn_addmask(netmask, 0, top->rn_off)) == 0)
+		if ((x = rn_addmask(netmask, 0, top->rn_off)) == NULL)
 			return (0);
 		b_leaf = x->rn_b;
 		b = -1 - x->rn_b;
@@ -616,7 +617,7 @@ rn_addroute(void *v_arg,
 		for (mp = &x->rn_mklist; (m = *mp); mp = &m->rm_mklist)
 			if (m->rm_b >= b_leaf)
 				break;
-		t->rn_mklist = m; *mp = 0;
+		t->rn_mklist = m; *mp = NULL;
 	}
 on2:
 	/* Add new route to highest possible ancestor's list */
@@ -678,21 +679,21 @@ rn_delete(void *v_arg,
 	vlen =  *(u_char *)v;
 	saved_tt = tt;
 	top = x;
-	if (tt == 0 ||
+	if (tt == NULL ||
 	    Bcmp(v + head_off, tt->rn_key + head_off, vlen - head_off))
 		return (0);
 	/*
 	 * Delete our route from mask lists.
 	 */
 	if (netmask) {
-		if ((x = rn_addmask(netmask, 1, head_off)) == 0)
+		if ((x = rn_addmask(netmask, 1, head_off)) == NULL)
 			return (0);
 		netmask = x->rn_key;
 		while (tt->rn_mask != netmask)
-			if ((tt = tt->rn_dupedkey) == 0)
+			if ((tt = tt->rn_dupedkey) == NULL)
 				return (0);
 	}
-	if (tt->rn_mask == 0 || (saved_m = m = tt->rn_mklist) == 0)
+	if (tt->rn_mask == 0 || (saved_m = m = tt->rn_mklist) == NULL)
 		goto on1;
 	if (tt->rn_flags & RNF_NORMAL) {
 		if (m->rm_leaf != tt || m->rm_refs > 0) {
@@ -721,7 +722,7 @@ rn_delete(void *v_arg,
 			MKFree(m);
 			break;
 		}
-	if (m == 0) {
+	if (m == NULL) {
 		log(LOG_ERR, "rn_delete: couldn't find our annotation\n");
 		if (tt->rn_flags & RNF_NORMAL)
 			return (0); /* Dangling ref to us */

Modified: head/sbin/routed/rdisc.c
==============================================================================
--- head/sbin/routed/rdisc.c	Sat May 14 22:29:11 2016	(r299767)
+++ head/sbin/routed/rdisc.c	Sat May 14 22:40:08 2016	(r299768)
@@ -118,7 +118,7 @@ trace_rdisc(const char	*act,
 	n_long *wp, *lim;
 
 
-	if (!TRACEPACKETS || ftrace == 0)
+	if (!TRACEPACKETS || ftrace == NULL)
 		return;
 
 	lastlog();
@@ -310,7 +310,7 @@ rdisc_age(naddr bad_gate)
 		/* If switching from client to server, get rid of old
 		 * default routes.
 		 */
-		if (cur_drp != 0)
+		if (cur_drp != NULL)
 			rdisc_sort();
 		rdisc_adv();
 		return;
@@ -462,7 +462,7 @@ rdisc_sort(void)
 
 	/* Find the best discovered route.
 	 */
-	new_drp = 0;
+	new_drp = NULL;
 	for (drp = drs; drp < &drs[MAX_ADS]; drp++) {
 		if (drp->dr_ts == 0)
 			continue;
@@ -487,7 +487,7 @@ rdisc_sort(void)
 		 * bad routers.
 		 * Avoid sick interfaces.
 		 */
-		if (new_drp == 0
+		if (new_drp == NULL
 		    || (!((new_st ^ drp->dr_ifp->int_state) & IS_SICK)
 			&& (new_pref < drp->dr_pref
 			    || (new_pref == drp->dr_pref
@@ -509,11 +509,11 @@ rdisc_sort(void)
 
 		/* Stop using discovered routes if they are all bad
 		 */
-		if (new_drp == 0) {
+		if (new_drp == NULL) {
 			trace_act("turn off Router Discovery client");
 			rdisc_ok = 0;
 
-			if (rt != 0
+			if (rt != NULL
 			    && (rt->rt_state & RS_RDISC)) {
 				new = rt->rt_spares[0];
 				new.rts_metric = HOPCNT_INFINITY;
@@ -524,7 +524,7 @@ rdisc_sort(void)
 			}
 
 		} else {
-			if (cur_drp == 0) {
+			if (cur_drp == NULL) {
 				trace_act("turn on Router Discovery client"
 					  " using %s via %s",
 					  naddr_ntoa(new_drp->dr_gate),
@@ -546,7 +546,7 @@ rdisc_sort(void)
 			new.rts_router = new_drp->dr_gate;
 			new.rts_metric = HOPCNT_INFINITY-1;
 			new.rts_time = now.tv_sec;
-			if (rt != 0) {
+			if (rt != NULL) {
 				rtchange(rt, rt->rt_state | RS_RDISC, &new, 0);
 			} else {
 				rtadd(RIP_DEFAULT, 0, RS_RDISC, &new);
@@ -588,7 +588,7 @@ parse_ad(naddr from,
 
 	/* ignore pointers to ourself and routes via unreachable networks
 	 */
-	if (ifwithaddr(gate, 1, 0) != 0) {
+	if (ifwithaddr(gate, 1, 0) != NULL) {
 		trace_pkt("    discard Router Discovery Ad pointing at us");
 		return;
 	}
@@ -608,7 +608,7 @@ parse_ad(naddr from,
 		life = 0;
 	}
 
-	for (new_drp = 0, drp = drs; drp < &drs[MAX_ADS]; drp++) {
+	for (new_drp = NULL, drp = drs; drp < &drs[MAX_ADS]; drp++) {

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-head mailing list