summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2004-04-01 23:56:06 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2004-04-01 23:56:06 +0000
commit0dd0d415ae2fcc73a387c9da4e33a7f53b3ae348 (patch)
tree915adabeddd8c421c4fa44c64dab09027bdc7477 /sys
parent250e36b4b591050c7285b3eae1d16f7176a5aa83 (diff)
use NULL for ptrs. parts from Joris Vink
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/uipc_domain.c12
-rw-r--r--sys/kern/uipc_mbuf.c29
-rw-r--r--sys/kern/uipc_socket.c20
-rw-r--r--sys/kern/uipc_socket2.c26
-rw-r--r--sys/kern/uipc_syscalls.c6
-rw-r--r--sys/kern/uipc_usrreq.c50
6 files changed, 71 insertions, 72 deletions
diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c
index 74d52f8a2e8..59c9200d653 100644
--- a/sys/kern/uipc_domain.c
+++ b/sys/kern/uipc_domain.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_domain.c,v 1.16 2004/02/24 21:43:55 tedu Exp $ */
+/* $OpenBSD: uipc_domain.c,v 1.17 2004/04/01 23:56:05 tedu Exp $ */
/* $NetBSD: uipc_domain.c,v 1.14 1996/02/09 19:00:44 christos Exp $ */
/*
@@ -145,12 +145,12 @@ pffindtype(family, type)
for (dp = domains; dp; dp = dp->dom_next)
if (dp->dom_family == family)
goto found;
- return (0);
+ return (NULL);
found:
for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
if (pr->pr_type && pr->pr_type == type)
return (pr);
- return (0);
+ return (NULL);
}
struct protosw *
@@ -159,14 +159,14 @@ pffindproto(family, protocol, type)
{
register struct domain *dp;
register struct protosw *pr;
- struct protosw *maybe = 0;
+ struct protosw *maybe = NULL;
if (family == 0)
- return (0);
+ return (NULL);
for (dp = domains; dp; dp = dp->dom_next)
if (dp->dom_family == family)
goto found;
- return (0);
+ return (NULL);
found:
for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) {
if ((pr->pr_protocol == protocol) && (pr->pr_type == type))
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index 1e6cb942c65..1bbc6b0b3b0 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_mbuf.c,v 1.64 2004/01/28 20:19:24 dhartmei Exp $ */
+/* $OpenBSD: uipc_mbuf.c,v 1.65 2004/04/01 23:56:05 tedu Exp $ */
/* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */
/*
@@ -314,7 +314,7 @@ m_copym0(m, off0, len, wait, deep)
if (off == 0 && m->m_flags & M_PKTHDR)
copyhdr = 1;
while (off > 0) {
- if (m == 0)
+ if (m == NULL)
panic("m_copym0: null mbuf");
if (off < m->m_len)
break;
@@ -322,16 +322,16 @@ m_copym0(m, off0, len, wait, deep)
m = m->m_next;
}
np = &top;
- top = 0;
+ top = NULL;
while (len > 0) {
- if (m == 0) {
+ if (m == NULL) {
if (len != M_COPYALL)
- panic("m_copym0: m == 0 and not COPYALL");
+ panic("m_copym0: m == NULL and not COPYALL");
break;
}
MGET(n, wait, m->m_type);
*np = n;
- if (n == 0)
+ if (n == NULL)
goto nospace;
if (copyhdr) {
M_DUP_PKTHDR(n, m);
@@ -376,13 +376,13 @@ m_copym0(m, off0, len, wait, deep)
}
np = &n->m_next;
}
- if (top == 0)
+ if (top == NULL)
MCFail++;
return (top);
nospace:
m_freem(top);
MCFail++;
- return (0);
+ return (NULL);
}
/*
@@ -439,14 +439,14 @@ m_copyback(m0, off, len, cp)
register struct mbuf *m = m0, *n;
int totlen = 0;
- if (m0 == 0)
+ if (m0 == NULL)
return;
while (off > (mlen = m->m_len)) {
off -= mlen;
totlen += mlen;
- if (m->m_next == 0) {
+ if (m->m_next == NULL) {
n = m_getclr(M_DONTWAIT, m->m_type);
- if (n == 0)
+ if (n == NULL)
goto out;
n->m_len = min(MLEN, len + off);
m->m_next = n;
@@ -463,9 +463,9 @@ m_copyback(m0, off, len, cp)
totlen += mlen;
if (len == 0)
break;
- if (m->m_next == 0) {
+ if (m->m_next == NULL) {
n = m_get(M_DONTWAIT, m->m_type);
- if (n == 0)
+ if (n == NULL)
break;
n->m_len = min(MLEN, len);
m->m_next = n;
@@ -741,8 +741,7 @@ m_getptr(m, loc, off)
}
else
return (NULL);
- }
- else
+ } else
m = m->m_next;
}
}
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index dd9ccc822b8..c5f72a067cf 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_socket.c,v 1.51 2003/07/21 22:44:50 tedu Exp $ */
+/* $OpenBSD: uipc_socket.c,v 1.52 2004/04/01 23:56:05 tedu Exp $ */
/* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */
/*
@@ -102,7 +102,7 @@ socreate(dom, aso, type, proto)
prp = pffindproto(dom, proto, type);
else
prp = pffindtype(dom, type);
- if (prp == 0 || prp->pr_usrreq == 0)
+ if (prp == NULL || prp->pr_usrreq == 0)
return (EPROTONOSUPPORT);
if (prp->pr_type != type)
return (EPROTOTYPE);
@@ -602,7 +602,7 @@ bad:
return (error);
}
if (mp)
- *mp = (struct mbuf *)0;
+ *mp = NULL;
if (so->so_state & SS_ISCONFIRMING && uio->uio_resid)
(*pr->pr_usrreq)(so, PRU_RCVD, NULL, NULL, NULL);
@@ -623,13 +623,13 @@ restart:
* we have to do the receive in sections, and thus risk returning
* a short count if a timeout or signal occurs after we start.
*/
- if (m == 0 || (((flags & MSG_DONTWAIT) == 0 &&
+ if (m == NULL || (((flags & MSG_DONTWAIT) == 0 &&
so->so_rcv.sb_cc < uio->uio_resid) &&
(so->so_rcv.sb_cc < so->so_rcv.sb_lowat ||
((flags & MSG_WAITALL) && uio->uio_resid <= so->so_rcv.sb_hiwat)) &&
- m->m_nextpkt == 0 && (pr->pr_flags & PR_ATOMIC) == 0)) {
+ m->m_nextpkt == NULL && (pr->pr_flags & PR_ATOMIC) == 0)) {
#ifdef DIAGNOSTIC
- if (m == 0 && so->so_rcv.sb_cc)
+ if (m == NULL && so->so_rcv.sb_cc)
panic("receive 1");
#endif
if (so->so_error) {
@@ -797,7 +797,7 @@ dontblock:
* we must note any additions to the sockbuf when we
* block interrupts again.
*/
- if (mp == 0 && uio_error == 0) {
+ if (mp == NULL && uio_error == 0) {
SBLASTRECORDCHK(&so->so_rcv, "soreceive uiomove");
SBLASTMBUFCHK(&so->so_rcv, "soreceive uiomove");
resid = uio->uio_resid;
@@ -823,7 +823,7 @@ dontblock:
*mp = m;
mp = &m->m_next;
so->so_rcv.sb_mb = m = m->m_next;
- *mp = (struct mbuf *)0;
+ *mp = NULL;
} else {
MFREE(m, so->so_rcv.sb_mb);
m = so->so_rcv.sb_mb;
@@ -877,7 +877,7 @@ dontblock:
* with a short count but without error.
* Keep sockbuf locked against other readers.
*/
- while (flags & MSG_WAITALL && m == 0 && uio->uio_resid > 0 &&
+ while (flags & MSG_WAITALL && m == NULL && uio->uio_resid > 0 &&
!sosendallatonce(so) && !nextrecord) {
if (so->so_error || so->so_state & SS_CANTRCVMORE)
break;
@@ -900,7 +900,7 @@ dontblock:
(void) sbdroprecord(&so->so_rcv);
}
if ((flags & MSG_PEEK) == 0) {
- if (m == 0) {
+ if (m == NULL) {
/*
* First part is an inline SB_EMPTY_FIXUP(). Second
* part makes sure sb_lastrecord is up-to-date if
diff --git a/sys/kern/uipc_socket2.c b/sys/kern/uipc_socket2.c
index f26cd314958..0fa88f6c008 100644
--- a/sys/kern/uipc_socket2.c
+++ b/sys/kern/uipc_socket2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_socket2.c,v 1.35 2003/07/21 22:44:50 tedu Exp $ */
+/* $OpenBSD: uipc_socket2.c,v 1.36 2004/04/01 23:56:05 tedu Exp $ */
/* $NetBSD: uipc_socket2.c,v 1.11 1996/02/04 02:17:55 christos Exp $ */
/*
@@ -499,7 +499,7 @@ sbappend(sb, m)
{
register struct mbuf *n;
- if (m == 0)
+ if (m == NULL)
return;
SBLASTRECORDCHK(sb, "sbappend 1");
@@ -579,7 +579,7 @@ sbappendrecord(struct sockbuf *sb, struct mbuf *m0)
{
struct mbuf *m;
- if (m0 == 0)
+ if (m0 == NULL)
return;
/*
@@ -590,7 +590,7 @@ sbappendrecord(struct sockbuf *sb, struct mbuf *m0)
SBLASTRECORDCHK(sb, "sbappendrecord 1");
SBLINKRECORD(sb, m0);
m = m0->m_next;
- m0->m_next = 0;
+ m0->m_next = NULL;
if (m && (m0->m_flags & M_EOR)) {
m0->m_flags &= ~M_EOR;
m->m_flags |= M_EOR;
@@ -609,7 +609,7 @@ sbinsertoob(struct sockbuf *sb, struct mbuf *m0)
{
struct mbuf *m, **mp;
- if (m0 == 0)
+ if (m0 == NULL)
return;
SBLASTRECORDCHK(sb, "sbinsertoob 1");
@@ -639,7 +639,7 @@ sbinsertoob(struct sockbuf *sb, struct mbuf *m0)
}
*mp = m0;
m = m0->m_next;
- m0->m_next = 0;
+ m0->m_next = NULL;
if (m && (m0->m_flags & M_EOR)) {
m0->m_flags &= ~M_EOR;
m->m_flags |= M_EOR;
@@ -667,7 +667,7 @@ sbappendaddr(struct sockbuf *sb, struct sockaddr *asa, struct mbuf *m0,
space += m0->m_pkthdr.len;
for (n = control; n; n = n->m_next) {
space += n->m_len;
- if (n->m_next == 0) /* keep pointer to last control buf */
+ if (n->m_next == NULL) /* keep pointer to last control buf */
break;
}
if (space > sbspace(sb))
@@ -675,7 +675,7 @@ sbappendaddr(struct sockbuf *sb, struct sockaddr *asa, struct mbuf *m0,
if (asa->sa_len > MLEN)
return (0);
MGET(m, M_DONTWAIT, MT_SONAME);
- if (m == 0)
+ if (m == NULL)
return (0);
m->m_len = asa->sa_len;
bcopy(asa, mtod(m, caddr_t), asa->sa_len);
@@ -707,11 +707,11 @@ sbappendcontrol(struct sockbuf *sb, struct mbuf *m0, struct mbuf *control)
struct mbuf *m, *mlast, *n;
int space = 0;
- if (control == 0)
+ if (control == NULL)
panic("sbappendcontrol");
for (m = control; ; m = m->m_next) {
space += m->m_len;
- if (m->m_next == 0)
+ if (m->m_next == NULL)
break;
}
n = m; /* save pointer to last control buffer */
@@ -780,7 +780,7 @@ sbcompress(struct sockbuf *sb, struct mbuf *m, struct mbuf *n)
n = m;
m->m_flags &= ~M_EOR;
m = m->m_next;
- n->m_next = 0;
+ n->m_next = NULL;
}
if (eor) {
if (n)
@@ -821,8 +821,8 @@ sbdrop(struct sockbuf *sb, int len)
next = (m = sb->sb_mb) ? m->m_nextpkt : 0;
while (len > 0) {
- if (m == 0) {
- if (next == 0)
+ if (m == NULL) {
+ if (next == NULL)
panic("sbdrop");
m = next;
next = m->m_nextpkt;
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index e130c3eafb4..81f6010c492 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_syscalls.c,v 1.57 2004/01/06 04:18:18 tedu Exp $ */
+/* $OpenBSD: uipc_syscalls.c,v 1.58 2004/04/01 23:56:05 tedu Exp $ */
/* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */
/*
@@ -719,7 +719,7 @@ recvit(p, s, mp, namelenp, retsize)
if (mp->msg_name) {
socklen_t alen;
- if (from == 0)
+ if (from == NULL)
alen = 0;
else {
/* save sa_len before it is destroyed by MSG_COMPAT */
@@ -770,7 +770,7 @@ recvit(p, s, mp, namelenp, retsize)
}
#endif
len = mp->msg_controllen;
- if (len <= 0 || control == 0)
+ if (len <= 0 || control == NULL)
len = 0;
else {
struct mbuf *m = control;
diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c
index af41b16a6ac..439060c5455 100644
--- a/sys/kern/uipc_usrreq.c
+++ b/sys/kern/uipc_usrreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_usrreq.c,v 1.25 2004/01/06 04:18:18 tedu Exp $ */
+/* $OpenBSD: uipc_usrreq.c,v 1.26 2004/04/01 23:56:05 tedu Exp $ */
/* $NetBSD: uipc_usrreq.c,v 1.18 1996/02/09 19:00:50 christos Exp $ */
/*
@@ -77,7 +77,7 @@ uipc_usrreq(so, req, m, nam, control)
error = EOPNOTSUPP;
goto release;
}
- if (unp == 0 && req != PRU_ATTACH) {
+ if (unp == NULL && req != PRU_ATTACH) {
error = EINVAL;
goto release;
}
@@ -100,7 +100,7 @@ uipc_usrreq(so, req, m, nam, control)
break;
case PRU_LISTEN:
- if (unp->unp_vnode == 0)
+ if (unp->unp_vnode == NULL)
error = EINVAL;
break;
@@ -147,7 +147,7 @@ uipc_usrreq(so, req, m, nam, control)
case SOCK_STREAM:
#define rcv (&so->so_rcv)
#define snd (&so2->so_snd)
- if (unp->unp_conn == 0)
+ if (unp->unp_conn == NULL)
break;
so2 = unp->unp_conn->unp_socket;
/*
@@ -185,7 +185,7 @@ uipc_usrreq(so, req, m, nam, control)
if (error)
break;
} else {
- if (unp->unp_conn == 0) {
+ if (unp->unp_conn == NULL) {
error = ENOTCONN;
break;
}
@@ -197,8 +197,8 @@ uipc_usrreq(so, req, m, nam, control)
from = &sun_noname;
if (sbappendaddr(&so2->so_rcv, from, m, control)) {
sorwakeup(so2);
- m = 0;
- control = 0;
+ m = NULL;
+ control = NULL;
} else
error = ENOBUFS;
if (nam)
@@ -213,7 +213,7 @@ uipc_usrreq(so, req, m, nam, control)
error = EPIPE;
break;
}
- if (unp->unp_conn == 0)
+ if (unp->unp_conn == NULL)
panic("uipc 3");
so2 = unp->unp_conn->unp_socket;
/*
@@ -223,7 +223,7 @@ uipc_usrreq(so, req, m, nam, control)
*/
if (control) {
if (sbappendcontrol(rcv, m, control))
- control = 0;
+ control = NULL;
} else
sbappend(rcv, m);
snd->sb_mbmax -=
@@ -232,7 +232,7 @@ uipc_usrreq(so, req, m, nam, control)
snd->sb_hiwat -= rcv->sb_cc - unp->unp_conn->unp_cc;
unp->unp_conn->unp_cc = rcv->sb_cc;
sorwakeup(so2);
- m = 0;
+ m = NULL;
#undef snd
#undef rcv
break;
@@ -248,7 +248,7 @@ uipc_usrreq(so, req, m, nam, control)
case PRU_SENSE:
((struct stat *) m)->st_blksize = so->so_snd.sb_hiwat;
- if (so->so_type == SOCK_STREAM && unp->unp_conn != 0) {
+ if (so->so_type == SOCK_STREAM && unp->unp_conn != NULL) {
so2 = unp->unp_conn->unp_socket;
((struct stat *) m)->st_blksize += so2->so_rcv.sb_cc;
}
@@ -367,16 +367,16 @@ unp_detach(unp)
{
if (unp->unp_vnode) {
- unp->unp_vnode->v_socket = 0;
+ unp->unp_vnode->v_socket = NULL;
vrele(unp->unp_vnode);
- unp->unp_vnode = 0;
+ unp->unp_vnode = NULL;
}
if (unp->unp_conn)
unp_disconnect(unp);
while (unp->unp_refs)
unp_drop(unp->unp_refs, ECONNRESET);
soisdisconnected(unp->unp_socket);
- unp->unp_socket->so_pcb = 0;
+ unp->unp_socket->so_pcb = NULL;
m_freem(unp->unp_addr);
if (unp_rights) {
/*
@@ -471,7 +471,7 @@ unp_connect(so, nam, p)
if ((error = VOP_ACCESS(vp, VWRITE, p->p_ucred, p)) != 0)
goto bad;
so2 = vp->v_socket;
- if (so2 == 0) {
+ if (so2 == NULL) {
error = ECONNREFUSED;
goto bad;
}
@@ -539,9 +539,9 @@ unp_disconnect(unp)
{
register struct unpcb *unp2 = unp->unp_conn;
- if (unp2 == 0)
+ if (unp2 == NULL)
return;
- unp->unp_conn = 0;
+ unp->unp_conn = NULL;
switch (unp->unp_socket->so_type) {
case SOCK_DGRAM:
@@ -550,7 +550,7 @@ unp_disconnect(unp)
else {
unp2 = unp2->unp_refs;
for (;;) {
- if (unp2 == 0)
+ if (unp2 == NULL)
panic("unp_disconnect");
if (unp2->unp_nextref == unp)
break;
@@ -558,13 +558,13 @@ unp_disconnect(unp)
}
unp2->unp_nextref = unp->unp_nextref;
}
- unp->unp_nextref = 0;
+ unp->unp_nextref = NULL;
unp->unp_socket->so_state &= ~SS_ISCONNECTED;
break;
case SOCK_STREAM:
soisdisconnected(unp->unp_socket);
- unp2->unp_conn = 0;
+ unp2->unp_conn = NULL;
soisdisconnected(unp2->unp_socket);
break;
}
@@ -600,7 +600,7 @@ unp_drop(unp, errno)
so->so_error = errno;
unp_disconnect(unp);
if (so->so_head) {
- so->so_pcb = 0;
+ so->so_pcb = NULL;
sofree(so);
m_freem(unp->unp_addr);
free(unp, M_PCB);
@@ -665,7 +665,7 @@ restart:
* zero the pointer before calling unp_discard,
* since it may end up in unp_gc()..
*/
- *rp++ = 0;
+ *rp++ = NULL;
unp_discard(fp);
}
goto out;
@@ -840,7 +840,7 @@ unp_gc()
fp->f_flag |= FMARK;
if (fp->f_type != DTYPE_SOCKET ||
- (so = (struct socket *)fp->f_data) == 0)
+ (so = (struct socket *)fp->f_data) == NULL)
continue;
if (so->so_proto->pr_domain != &unixdomain ||
(so->so_proto->pr_flags&PR_RIGHTS) == 0)
@@ -904,8 +904,8 @@ unp_gc()
* 91/09/19, bsy@cs.cmu.edu
*/
extra_ref = malloc(nfiles * sizeof(struct file *), M_FILE, M_WAITOK);
- for (nunref = 0, fp = LIST_FIRST(&filehead), fpp = extra_ref; fp != 0;
- fp = nextfp) {
+ for (nunref = 0, fp = LIST_FIRST(&filehead), fpp = extra_ref;
+ fp != NULL; fp = nextfp) {
nextfp = LIST_NEXT(fp, f_list);
if (fp->f_count == 0)
continue;