From 0b17fba7bc072f1ad8b739d53d3e957e270d9377 Mon Sep 17 00:00:00 2001 From: Andre Oppermann Date: Wed, 11 Aug 2004 10:46:15 +0000 Subject: [PATCH] Consistently use NULL for pointer comparisons. --- sys/netinet/ip_input.c | 22 +++++++++++----------- sys/netinet/ip_output.c | 20 ++++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 3bb82776ad6..61db043867b 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -343,7 +343,7 @@ ip_input(struct mbuf *m) goto tooshort; if (m->m_len < sizeof (struct ip) && - (m = m_pullup(m, sizeof (struct ip))) == 0) { + (m = m_pullup(m, sizeof (struct ip))) == NULL) { ipstat.ips_toosmall++; return; } @@ -360,7 +360,7 @@ ip_input(struct mbuf *m) goto bad; } if (hlen > m->m_len) { - if ((m = m_pullup(m, hlen)) == 0) { + if ((m = m_pullup(m, hlen)) == NULL) { ipstat.ips_badhlen++; return; } @@ -1366,7 +1366,7 @@ ip_dooptions(struct mbuf *m, int pass, struct sockaddr_in *next_hop) ipaddr.sin_addr = ip->ip_dst; ia = (struct in_ifaddr *) ifa_ifwithaddr((struct sockaddr *)&ipaddr); - if (ia == 0) { + if (ia == NULL) { if (opt == IPOPT_SSRR) { type = ICMP_UNREACH; code = ICMP_UNREACH_SRCFAIL; @@ -1430,11 +1430,11 @@ ip_dooptions(struct mbuf *m, int pass, struct sockaddr_in *next_hop) if (opt == IPOPT_SSRR) { #define INA struct in_ifaddr * #define SA struct sockaddr * - if ((ia = (INA)ifa_ifwithdstaddr((SA)&ipaddr)) == 0) + if ((ia = (INA)ifa_ifwithdstaddr((SA)&ipaddr)) == NULL) ia = (INA)ifa_ifwithnet((SA)&ipaddr); } else ia = ip_rtaddr(ipaddr.sin_addr); - if (ia == 0) { + if (ia == NULL) { type = ICMP_UNREACH; code = ICMP_UNREACH_SRCFAIL; goto bad; @@ -1474,8 +1474,8 @@ ip_dooptions(struct mbuf *m, int pass, struct sockaddr_in *next_hop) * locate outgoing interface; if we're the destination, * use the incoming interface (should be same). */ - if ((ia = (INA)ifa_ifwithaddr((SA)&ipaddr)) == 0 && - (ia = ip_rtaddr(ipaddr.sin_addr)) == 0) { + if ((ia = (INA)ifa_ifwithaddr((SA)&ipaddr)) == NULL && + (ia = ip_rtaddr(ipaddr.sin_addr)) == NULL) { type = ICMP_UNREACH; code = ICMP_UNREACH_HOST; goto bad; @@ -1523,7 +1523,7 @@ ip_dooptions(struct mbuf *m, int pass, struct sockaddr_in *next_hop) ipaddr.sin_addr = dst; ia = (INA)ifaof_ifpforaddr((SA)&ipaddr, m->m_pkthdr.rcvif); - if (ia == 0) + if (ia == NULL) continue; (void)memcpy(sin, &IA_SIN(ia)->sin_addr, sizeof(struct in_addr)); @@ -1539,7 +1539,7 @@ ip_dooptions(struct mbuf *m, int pass, struct sockaddr_in *next_hop) } (void)memcpy(&ipaddr.sin_addr, sin, sizeof(struct in_addr)); - if (ifa_ifwithaddr((SA)&ipaddr) == 0) + if (ifa_ifwithaddr((SA)&ipaddr) == NULL) continue; cp[IPOPT_OFFSET] += sizeof(struct in_addr); off += sizeof(struct in_addr); @@ -1629,7 +1629,7 @@ ip_srcroute() if (ip_nhops == 0) return ((struct mbuf *)0); m = m_get(M_DONTWAIT, MT_HEADER); - if (m == 0) + if (m == NULL) return ((struct mbuf *)0); #define OPTSIZ (sizeof(ip_srcrt.nop) + sizeof(ip_srcrt.srcopt)) @@ -1780,7 +1780,7 @@ ip_forward(struct mbuf *m, int srcrt, struct sockaddr_in *next_hop) } #endif - if ((ia = ip_rtaddr(pkt_dst)) == 0) { + if ((ia = ip_rtaddr(pkt_dst)) == NULL) { icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_HOST, 0, 0); return; } diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 6705f7d4587..8f7003ca4a5 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -240,7 +240,7 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, RTFREE(ro->ro_rt); ro->ro_rt = (struct rtentry *)0; } - if (ro->ro_rt == 0) { + if (ro->ro_rt == NULL) { bzero(dst, sizeof(*dst)); dst->sin_family = AF_INET; dst->sin_len = sizeof(*dst); @@ -251,8 +251,8 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, * short circuit routing lookup. */ if (flags & IP_ROUTETOIF) { - if ((ia = ifatoia(ifa_ifwithdstaddr(sintosa(dst)))) == 0 && - (ia = ifatoia(ifa_ifwithnet(sintosa(dst)))) == 0) { + if ((ia = ifatoia(ifa_ifwithdstaddr(sintosa(dst)))) == NULL && + (ia = ifatoia(ifa_ifwithnet(sintosa(dst)))) == NULL) { ipstat.ips_noroute++; error = ENETUNREACH; goto bad; @@ -275,9 +275,9 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, * as this is probably required in all cases for correct * operation (as it is for ARP). */ - if (ro->ro_rt == 0) + if (ro->ro_rt == NULL) rtalloc_ign(ro, 0); - if (ro->ro_rt == 0) { + if (ro->ro_rt == NULL) { ipstat.ips_noroute++; error = EHOSTUNREACH; goto bad; @@ -899,7 +899,7 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, ro_fwd->ro_rt = 0; rtalloc_ign(ro_fwd, RTF_CLONING); - if (ro_fwd->ro_rt == 0) { + if (ro_fwd->ro_rt == NULL) { ipstat.ips_noroute++; error = EHOSTUNREACH; goto bad; @@ -1163,7 +1163,7 @@ ip_fragment(struct ip *ip, struct mbuf **m_frag, int mtu, int mhlen = sizeof (struct ip); MGETHDR(m, M_DONTWAIT, MT_HEADER); - if (m == 0) { + if (m == NULL) { error = ENOBUFS; ipstat.ips_odropped++; goto done; @@ -1192,7 +1192,7 @@ ip_fragment(struct ip *ip, struct mbuf **m_frag, int mtu, mhip->ip_off |= IP_MF; mhip->ip_len = htons((u_short)(len + mhlen)); m->m_next = m_copy(m0, off, len); - if (m->m_next == 0) { /* copy failed */ + if (m->m_next == NULL) { /* copy failed */ m_free(m); error = ENOBUFS; /* ??? */ ipstat.ips_odropped++; @@ -1289,7 +1289,7 @@ ip_insertoptions(m, opt, phlen) ip->ip_dst = p->ipopt_dst; if (m->m_flags & M_EXT || m->m_data - optlen < m->m_pktdat) { MGETHDR(n, M_DONTWAIT, MT_HEADER); - if (n == 0) { + if (n == NULL) { *phlen = 0; return (m); } @@ -1394,7 +1394,7 @@ ip_ctloutput(so, sopt) break; } MGET(m, sopt->sopt_td ? M_TRYWAIT : M_DONTWAIT, MT_HEADER); - if (m == 0) { + if (m == NULL) { error = ENOBUFS; break; } -- 2.45.2