summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>1997-12-31 04:19:04 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>1997-12-31 04:19:04 +0000
commit452754ae6dd957d850d25a0458fea73326cc5316 (patch)
treecb18fb8cba4c0c38853e75481d02068bff4f71c2
parent8bbfae4b2e1220379bf8b09052ee0135c6068ee1 (diff)
NULL is not 0
-rw-r--r--sys/net/route.c68
1 files changed, 35 insertions, 33 deletions
diff --git a/sys/net/route.c b/sys/net/route.c
index def1e123a44..9cb79ef9d2e 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.c,v 1.5 1997/09/21 03:52:42 niklas Exp $ */
+/* $OpenBSD: route.c,v 1.6 1997/12/31 04:19:03 mickey Exp $ */
/* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */
/*
@@ -148,7 +148,7 @@ rtfree(rt)
{
register struct ifaddr *ifa;
- if (rt == 0)
+ if (rt == NULL)
panic("rtfree");
rt->rt_refcnt--;
if (rt->rt_refcnt <= 0 && (rt->rt_flags & RTF_UP) == 0) {
@@ -194,12 +194,12 @@ rtredirect(dst, gateway, netmask, flags, src, rtp)
{
register struct rtentry *rt;
int error = 0;
- short *stat = 0;
+ short *stat = NULL;
struct rt_addrinfo info;
struct ifaddr *ifa;
/* verify the gateway is directly reachable */
- if ((ifa = ifa_ifwithnet(gateway)) == 0) {
+ if ((ifa = ifa_ifwithnet(gateway)) == NULL) {
error = ENETUNREACH;
goto out;
}
@@ -214,7 +214,7 @@ rtredirect(dst, gateway, netmask, flags, src, rtp)
if (!(flags & RTF_DONE) && rt &&
(!equal(src, rt->rt_gateway) || rt->rt_ifa != ifa))
error = EINVAL;
- else if (ifa_ifwithaddr(gateway))
+ else if (ifa_ifwithaddr(gateway) != NULL)
error = EHOSTUNREACH;
if (error)
goto done;
@@ -224,7 +224,7 @@ rtredirect(dst, gateway, netmask, flags, src, rtp)
* which use routing redirects generated by smart gateways
* to dynamically build the routing tables.
*/
- if ((rt == 0) || (rt_mask(rt) && rt_mask(rt)->sa_len < 2))
+ if ((rt == NULL) || (rt_mask(rt) && rt_mask(rt)->sa_len < 2))
goto create;
/*
* Don't listen to the redirect if it's
@@ -312,10 +312,10 @@ ifa_ifwithroute(flags, dst, gateway)
* as our clue to the interface. Otherwise
* we can use the local address.
*/
- ifa = 0;
+ ifa = NULL;
if (flags & RTF_HOST)
ifa = ifa_ifwithdstaddr(dst);
- if (ifa == 0)
+ if (ifa == NULL)
ifa = ifa_ifwithaddr(gateway);
} else {
/*
@@ -325,20 +325,20 @@ ifa_ifwithroute(flags, dst, gateway)
*/
ifa = ifa_ifwithdstaddr(gateway);
}
- if (ifa == 0)
+ if (ifa == NULL)
ifa = ifa_ifwithnet(gateway);
- if (ifa == 0) {
+ if (ifa == NULL) {
struct rtentry *rt = rtalloc1(dst, 0);
- if (rt == 0)
- return (0);
+ if (rt == NULL)
+ return (NULL);
rt->rt_refcnt--;
- if ((ifa = rt->rt_ifa) == 0)
- return (0);
+ if ((ifa = rt->rt_ifa) == NULL)
+ return (NULL);
}
if (ifa->ifa_addr->sa_family != dst->sa_family) {
struct ifaddr *oifa = ifa;
ifa = ifaof_ifpforaddr(dst, ifa->ifa_ifp);
- if (ifa == 0)
+ if (ifa == NULL)
ifa = oifa;
}
return (ifa);
@@ -388,21 +388,21 @@ rtrequest(req, dst, gateway, netmask, flags, ret_nrt)
break;
case RTM_RESOLVE:
- if (ret_nrt == 0 || (rt = *ret_nrt) == 0)
+ if (ret_nrt == NULL || (rt = *ret_nrt) == NULL)
senderr(EINVAL);
ifa = rt->rt_ifa;
flags = rt->rt_flags & ~RTF_CLONING;
gateway = rt->rt_gateway;
- if ((netmask = rt->rt_genmask) == 0)
+ if ((netmask = rt->rt_genmask) == NULL)
flags |= RTF_HOST;
goto makeroute;
case RTM_ADD:
- if ((ifa = ifa_ifwithroute(flags, dst, gateway)) == 0)
+ if ((ifa = ifa_ifwithroute(flags, dst, gateway)) == NULL)
senderr(ENETUNREACH);
makeroute:
R_Malloc(rt, struct rtentry *, sizeof(*rt));
- if (rt == 0)
+ if (rt == NULL)
senderr(ENOBUFS);
Bzero(rt, sizeof(*rt));
rt->rt_flags = RTF_UP | flags;
@@ -417,7 +417,7 @@ rtrequest(req, dst, gateway, netmask, flags, ret_nrt)
Bcopy(dst, ndst, dst->sa_len);
rn = rnh->rnh_addaddr((caddr_t)ndst, (caddr_t)netmask,
rnh, rt->rt_nodes);
- if (rn == 0) {
+ if (rn == NULL) {
if (rt->rt_gwroute)
rtfree(rt->rt_gwroute);
Free(rt_key(rt));
@@ -430,7 +430,7 @@ rtrequest(req, dst, gateway, netmask, flags, ret_nrt)
if (req == RTM_RESOLVE)
rt->rt_rmx = (*ret_nrt)->rt_rmx; /* copy metrics */
if (ifa->ifa_rtrequest)
- ifa->ifa_rtrequest(req, rt, SA(ret_nrt ? *ret_nrt : 0));
+ ifa->ifa_rtrequest(req, rt, SA(ret_nrt ? *ret_nrt : NULL));
if (ret_nrt) {
*ret_nrt = rt;
rt->rt_refcnt++;
@@ -451,24 +451,26 @@ rt_setgate(rt0, dst, gate)
int dlen = ROUNDUP(dst->sa_len), glen = ROUNDUP(gate->sa_len);
register struct rtentry *rt = rt0;
- if (rt->rt_gateway == 0 || glen > ROUNDUP(rt->rt_gateway->sa_len)) {
+ if (rt->rt_gateway == NULL || glen > ROUNDUP(rt->rt_gateway->sa_len)) {
old = (caddr_t)rt_key(rt);
R_Malloc(new, caddr_t, dlen + glen);
- if (new == 0)
+ if (new == NULL)
return 1;
rt->rt_nodes->rn_key = new;
} else {
new = rt->rt_nodes->rn_key;
- old = 0;
+ old = NULL;
}
Bcopy(gate, (rt->rt_gateway = (struct sockaddr *)(new + dlen)), glen);
if (old) {
Bcopy(dst, new, dlen);
Free(old);
}
- if (rt->rt_gwroute) {
- rt = rt->rt_gwroute; RTFREE(rt);
- rt = rt0; rt->rt_gwroute = 0;
+ if (rt->rt_gwroute != NULL) {
+ rt = rt->rt_gwroute;
+ RTFREE(rt);
+ rt = rt0;
+ rt->rt_gwroute = NULL;
}
if (rt->rt_flags & RTF_GATEWAY) {
rt->rt_gwroute = rtalloc1(gate, 1);
@@ -508,8 +510,8 @@ rtinit(ifa, cmd, flags)
register struct rtentry *rt;
register struct sockaddr *dst;
register struct sockaddr *deldst;
- struct mbuf *m = 0;
- struct rtentry *nrt = 0;
+ struct mbuf *m = NULL;
+ struct rtentry *nrt = NULL;
int error;
dst = flags & RTF_HOST ? ifa->ifa_dstaddr : ifa->ifa_addr;
@@ -523,7 +525,7 @@ rtinit(ifa, cmd, flags)
if ((rt = rtalloc1(dst, 0)) != NULL) {
rt->rt_refcnt--;
if (rt->rt_ifa != ifa) {
- if (m)
+ if (m != NULL)
(void) m_free(m);
return (flags & RTF_HOST ? EHOSTUNREACH
: ENETUNREACH);
@@ -532,16 +534,16 @@ rtinit(ifa, cmd, flags)
}
error = rtrequest(cmd, dst, ifa->ifa_addr, ifa->ifa_netmask,
flags | ifa->ifa_flags, &nrt);
- if (m)
+ if (m != NULL)
(void) m_free(m);
- if (cmd == RTM_DELETE && error == 0 && (rt = nrt)) {
+ if (cmd == RTM_DELETE && error == 0 && (rt = nrt) != NULL) {
rt_newaddrmsg(cmd, ifa, error, nrt);
if (rt->rt_refcnt <= 0) {
rt->rt_refcnt++;
rtfree(rt);
}
}
- if (cmd == RTM_ADD && error == 0 && (rt = nrt)) {
+ if (cmd == RTM_ADD && error == 0 && (rt = nrt) != NULL) {
rt->rt_refcnt--;
if (rt->rt_ifa != ifa) {
printf("rtinit: wrong ifa (%p) was (%p)\n",