From: jsg Date: Sun, 24 Oct 2021 00:02:24 +0000 (+0000) Subject: use NULL not 0 for pointer values in kern X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=da571dddb577899c3c6d6d8e2afe36992eb1d438;p=openbsd use NULL not 0 for pointer values in kern ok semarie@ --- diff --git a/sys/ddb/db_sym.h b/sys/ddb/db_sym.h index fe1aff6d6af..c8daa983104 100644 --- a/sys/ddb/db_sym.h +++ b/sys/ddb/db_sym.h @@ -75,11 +75,11 @@ void db_symbol_values(Elf_Sym *, char **, db_expr_t *); /* return name and value of symbol */ #define db_find_sym_and_offset(val,namep,offp) \ - db_symbol_values(db_search_symbol(val,DB_STGY_ANY,offp),namep,0) + db_symbol_values(db_search_symbol(val,DB_STGY_ANY,offp),namep,NULL) /* find name&value given approx val */ #define db_find_xtrn_sym_and_offset(val,namep,offp) \ - db_symbol_values(db_search_symbol(val,DB_STGY_XTRN,offp),namep,0) + db_symbol_values(db_search_symbol(val,DB_STGY_XTRN,offp),namep,NULL) /* ditto, but no locals */ void db_printsym(db_expr_t, db_strategy_t, int (*)(const char *, ...)); diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 0c6ceb3546d..43f1f315fa9 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_exit.c,v 1.199 2021/03/12 10:13:28 mpi Exp $ */ +/* $OpenBSD: kern_exit.c,v 1.200 2021/10/24 00:02:24 jsg Exp $ */ /* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */ /* @@ -266,7 +266,7 @@ exit1(struct proc *p, int xexit, int xsig, int flags) qr = LIST_FIRST(&pr->ps_children); if (qr) /* only need this if any child is S_ZOMB */ wakeup(initprocess); - for (; qr != 0; qr = nqr) { + for (; qr != NULL; qr = nqr) { nqr = LIST_NEXT(qr, ps_sibling); /* * Traced processes are killed since their diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index bbe709ea883..d99310d0fa5 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_proc.c,v 1.90 2021/02/08 10:51:01 mpi Exp $ */ +/* $OpenBSD: kern_proc.c,v 1.91 2021/10/24 00:02:25 jsg Exp $ */ /* $NetBSD: kern_proc.c,v 1.14 1996/02/09 18:59:41 christos Exp $ */ /* @@ -320,7 +320,7 @@ leavepgrp(struct process *pr) LIST_REMOVE(pr, ps_pglist); if (LIST_EMPTY(&pr->ps_pgrp->pg_members)) pgdelete(pr->ps_pgrp); - pr->ps_pgrp = 0; + pr->ps_pgrp = NULL; } /* diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c index f6fff9d87bb..2d2d74ac7aa 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_prot.c,v 1.77 2021/01/17 15:28:22 mvs Exp $ */ +/* $OpenBSD: kern_prot.c,v 1.78 2021/10/24 00:02:25 jsg Exp $ */ /* $NetBSD: kern_prot.c,v 1.33 1996/02/09 18:59:42 christos Exp $ */ /* @@ -271,7 +271,8 @@ sys_setpgid(struct proc *curp, void *v, register_t *retval) newpgrp = pool_get(&pgrp_pool, PR_WAITOK); if (pid != 0 && pid != curpr->ps_pid) { - if ((targpr = prfind(pid)) == 0 || !inferior(targpr, curpr)) { + if ((targpr = prfind(pid)) == NULL || + !inferior(targpr, curpr)) { error = ESRCH; goto out; } diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 1f87dc5a18d..c2a6b6d7011 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sig.c,v 1.286 2021/10/23 14:56:55 claudio Exp $ */ +/* $OpenBSD: kern_sig.c,v 1.287 2021/10/24 00:02:25 jsg Exp $ */ /* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */ /* @@ -230,7 +230,7 @@ sigstkinit(struct sigaltstack *ss) { ss->ss_flags = SS_DISABLE; ss->ss_size = 0; - ss->ss_sp = 0; + ss->ss_sp = NULL; } /* @@ -1116,7 +1116,7 @@ ptsignal(struct proc *p, int signum, enum signal_type type) atomic_clearbits_int(siglist, mask); if (action == SIG_CATCH) goto runfast; - if (p->p_wchan == 0) + if (p->p_wchan == NULL) goto run; p->p_stat = SSLEEP; goto out; @@ -1410,12 +1410,12 @@ postsig(struct proc *p, int signum) action = ps->ps_sigact[signum]; info = (ps->ps_siginfo & mask) != 0; onstack = (ps->ps_sigonstack & mask) != 0; - sigval.sival_ptr = 0; + sigval.sival_ptr = NULL; if (p->p_sisig != signum) { trapno = 0; code = SI_USER; - sigval.sival_ptr = 0; + sigval.sival_ptr = NULL; } else { trapno = p->p_sitrapno; code = p->p_sicode; @@ -2139,7 +2139,7 @@ single_thread_clear(struct proc *p, int flag) * it back into some sleep queue */ if (q->p_stat == SSTOP && (q->p_flag & flag) == 0) { - if (q->p_wchan == 0) + if (q->p_wchan == NULL) setrunnable(q); else q->p_stat = SSLEEP; diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index d2069599418..320ed09a21f 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.394 2021/05/04 21:57:15 bluhm Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.395 2021/10/24 00:02:25 jsg Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -1998,7 +1998,7 @@ sysctl_proc_nobroadcastkill(int *name, u_int namelen, void *newp, size_t newlen, return (EINVAL); /* Only root can change PS_NOBROADCASTKILL */ - if (newp != 0 && (error = suser(cp)) != 0) + if (newp != NULL && (error = suser(cp)) != 0) return (error); /* get the PS_NOBROADCASTKILL flag */ diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index 69a4a3b19db..3d35064ece1 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_tc.c,v 1.74 2021/06/19 13:49:39 cheloha Exp $ */ +/* $OpenBSD: kern_tc.c,v 1.75 2021/10/24 00:02:25 jsg Exp $ */ /* * Copyright (c) 2000 Poul-Henning Kamp @@ -56,7 +56,7 @@ dummy_get_timecount(struct timecounter *tc) static struct timecounter dummy_timecounter = { .tc_get_timecount = dummy_get_timecount, - .tc_poll_pps = 0, + .tc_poll_pps = NULL, .tc_counter_mask = ~0u, .tc_frequency = 1000000, .tc_name = "dummy", diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c index 64ddf136069..ecff6940caa 100644 --- a/sys/kern/subr_disk.c +++ b/sys/kern/subr_disk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_disk.c,v 1.245 2021/06/13 13:17:59 krw Exp $ */ +/* $OpenBSD: subr_disk.c,v 1.246 2021/10/24 00:02:25 jsg Exp $ */ /* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */ /* @@ -387,7 +387,7 @@ readdoslabel(struct buf *bp, void (*strat)(struct buf *), if (error == 0) { dospartoff = DL_GETBSTART(gptlp); dospartend = DL_GETBEND(gptlp); - if (partoffp == 0) + if (partoffp == NULL) *lp = *gptlp; free(gptlp, M_DEVBUF, sizeof(struct disklabel)); diff --git a/sys/kern/subr_userconf.c b/sys/kern/subr_userconf.c index a86660c0d28..6f080f54dc1 100644 --- a/sys/kern/subr_userconf.c +++ b/sys/kern/subr_userconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_userconf.c,v 1.46 2019/09/06 21:30:31 cheloha Exp $ */ +/* $OpenBSD: subr_userconf.c,v 1.47 2021/10/24 00:02:25 jsg Exp $ */ /* * Copyright (c) 1996-2001 Mats O Jansson @@ -118,7 +118,7 @@ userconf_init(void) struct cfdata *cd; int ln; - while (cfdata[i].cf_attach != 0) { + while (cfdata[i].cf_attach != NULL) { userconf_maxdev = i; userconf_totdev = i; @@ -132,7 +132,7 @@ userconf_init(void) i++; } - while (cfdata[i].cf_attach == 0) { + while (cfdata[i].cf_attach == NULL) { userconf_totdev = i; i++; } @@ -884,7 +884,7 @@ userconf_common_dev(char *dev, int len, short unit, short state, char routine) break; } - while (cfdata[i].cf_attach != 0) { + while (cfdata[i].cf_attach != NULL) { if (strlen(cfdata[i].cf_driver->cd_name) == len) { /* @@ -1108,7 +1108,7 @@ userconf_add(char *dev, int len, short unit, short state) /* Find max unit number of the device type */ i = 0; - while (cfdata[i].cf_attach != 0) { + while (cfdata[i].cf_attach != NULL) { if (strlen(cfdata[i].cf_driver->cd_name) == len && strncasecmp(dev, cfdata[i].cf_driver->cd_name, len) == 0) { @@ -1133,7 +1133,7 @@ userconf_add(char *dev, int len, short unit, short state) star_unit = -1; i = 0; - while (cfdata[i].cf_attach != 0) { + while (cfdata[i].cf_attach != NULL) { if (strlen(cfdata[i].cf_driver->cd_name) == len && strncasecmp(dev, cfdata[i].cf_driver->cd_name, len) == 0) { @@ -1152,7 +1152,7 @@ userconf_add(char *dev, int len, short unit, short state) star_unit++; i = 0; - while (cfdata[i].cf_attach != 0) { + while (cfdata[i].cf_attach != NULL) { if (strlen(cfdata[i].cf_driver->cd_name) == len && strncasecmp(dev, cfdata[i].cf_driver->cd_name, len) == 0) { diff --git a/sys/kern/sys_socket.c b/sys/kern/sys_socket.c index f522890eb29..103ee79ca6a 100644 --- a/sys/kern/sys_socket.c +++ b/sys/kern/sys_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_socket.c,v 1.46 2021/06/07 09:10:32 mpi Exp $ */ +/* $OpenBSD: sys_socket.c,v 1.47 2021/10/24 00:02:25 jsg Exp $ */ /* $NetBSD: sys_socket.c,v 1.13 1995/08/12 23:59:09 mycroft Exp $ */ /* @@ -216,6 +216,6 @@ soo_close(struct file *fp, struct proc *p) flags = (fp->f_flag & FNONBLOCK) ? MSG_DONTWAIT : 0; error = soclose(fp->f_data, flags); } - fp->f_data = 0; + fp->f_data = NULL; return (error); } diff --git a/sys/kern/tty.c b/sys/kern/tty.c index 7f41b2bf923..eaaa4b2a6e4 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.169 2021/05/19 18:10:45 kettenis Exp $ */ +/* $OpenBSD: tty.c,v 1.170 2021/10/24 00:02:25 jsg Exp $ */ /* $NetBSD: tty.c,v 1.68.4.2 1996/06/06 16:04:52 thorpej Exp $ */ /*- @@ -1452,7 +1452,7 @@ ttypend(struct tty *tp) SET(tp->t_state, TS_TYPEN); tq = tp->t_rawq; tp->t_rawq.c_cc = 0; - tp->t_rawq.c_cf = tp->t_rawq.c_cl = 0; + tp->t_rawq.c_cf = tp->t_rawq.c_cl = NULL; while ((c = getc(&tq)) >= 0) ttyinput(c, tp); CLR(tp->t_state, TS_TYPEN); diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c index 42eb39e2eb9..bf213d2a118 100644 --- a/sys/kern/tty_pty.c +++ b/sys/kern/tty_pty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty_pty.c,v 1.109 2021/10/22 15:11:32 mpi Exp $ */ +/* $OpenBSD: tty_pty.c,v 1.110 2021/10/24 00:02:25 jsg Exp $ */ /* $NetBSD: tty_pty.c,v 1.33.4.1 1996/06/02 09:08:11 mrg Exp $ */ /* @@ -335,7 +335,7 @@ ptswrite(dev_t dev, struct uio *uio, int flag) struct pt_softc *pti = pt_softc[minor(dev)]; struct tty *tp = pti->pt_tty; - if (tp->t_oproc == 0) + if (tp->t_oproc == NULL) return (EIO); return ((*linesw[tp->t_line].l_write)(tp, uio, flag)); } @@ -429,7 +429,7 @@ ptcclose(dev_t dev, int flag, int devtype, struct proc *p) (void)(*linesw[tp->t_line].l_modem)(tp, 0); tp->t_state &= ~TS_CARR_ON; - tp->t_oproc = 0; /* mark closed */ + tp->t_oproc = NULL; /* mark closed */ return (0); } diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index 59aa2e56589..07dfe468d1b 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_syscalls.c,v 1.193 2021/07/02 12:17:41 bluhm Exp $ */ +/* $OpenBSD: uipc_syscalls.c,v 1.194 2021/10/24 00:02:25 jsg Exp $ */ /* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */ /* @@ -513,7 +513,7 @@ sys_sendto(struct proc *p, void *v, register_t *retval) msg.msg_namelen = SCARG(uap, tolen); msg.msg_iov = &aiov; msg.msg_iovlen = 1; - msg.msg_control = 0; + msg.msg_control = NULL; msg.msg_flags = 0; aiov.iov_base = (char *)SCARG(uap, buf); aiov.iov_len = SCARG(uap, len); @@ -708,7 +708,7 @@ sys_recvfrom(struct proc *p, void *v, register_t *retval) msg.msg_iovlen = 1; aiov.iov_base = SCARG(uap, buf); aiov.iov_len = SCARG(uap, len); - msg.msg_control = 0; + msg.msg_control = NULL; msg.msg_flags = SCARG(uap, flags); return (recvit(p, SCARG(uap, s), &msg, (caddr_t)SCARG(uap, fromlenaddr), retval)); @@ -1048,7 +1048,7 @@ sys_getsockname(struct proc *p, void *v, register_t *retval) goto bad; m = m_getclr(M_WAIT, MT_SONAME); s = solock(so); - error = (*so->so_proto->pr_usrreq)(so, PRU_SOCKADDR, 0, m, 0, p); + error = (*so->so_proto->pr_usrreq)(so, PRU_SOCKADDR, NULL, m, NULL, p); sounlock(so, s); if (error) goto bad; @@ -1091,7 +1091,7 @@ sys_getpeername(struct proc *p, void *v, register_t *retval) goto bad; m = m_getclr(M_WAIT, MT_SONAME); s = solock(so); - error = (*so->so_proto->pr_usrreq)(so, PRU_PEERADDR, 0, m, 0, p); + error = (*so->so_proto->pr_usrreq)(so, PRU_PEERADDR, NULL, m, NULL, p); sounlock(so, s); if (error) goto bad; diff --git a/sys/kern/vfs_biomem.c b/sys/kern/vfs_biomem.c index b3c41c6551a..fc6e5e93677 100644 --- a/sys/kern/vfs_biomem.c +++ b/sys/kern/vfs_biomem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_biomem.c,v 1.50 2021/09/05 11:44:46 mpi Exp $ */ +/* $OpenBSD: vfs_biomem.c,v 1.51 2021/10/24 00:02:25 jsg Exp $ */ /* * Copyright (c) 2007 Artur Grabowski @@ -238,7 +238,7 @@ buf_unmap(struct buf *bp) TAILQ_REMOVE(&buf_valist, bp, b_valist); bcstats.kvaslots_avail--; va = (vaddr_t)bp->b_data; - bp->b_data = 0; + bp->b_data = NULL; pmap_kremove(va, bp->b_bufsize); pmap_update(pmap_kernel()); diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index 94943dad1e1..16a42e905b8 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_lookup.c,v 1.85 2021/07/16 07:59:38 claudio Exp $ */ +/* $OpenBSD: vfs_lookup.c,v 1.86 2021/10/24 00:02:25 jsg Exp $ */ /* $NetBSD: vfs_lookup.c,v 1.17 1996/02/09 19:00:59 christos Exp $ */ /* @@ -381,7 +381,7 @@ int vfs_lookup(struct nameidata *ndp) { char *cp; /* pointer into pathname argument */ - struct vnode *dp = 0; /* the directory we are searching */ + struct vnode *dp = NULL; /* the directory we are searching */ struct vnode *tdp; /* saved dp */ struct mount *mp; /* mount table entry */ int docache; /* == 0 do not cache last component */ @@ -725,7 +725,7 @@ bad: int vfs_relookup(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp) { - struct vnode *dp = 0; /* the directory we are searching */ + struct vnode *dp = NULL; /* the directory we are searching */ int wantparent; /* 1 => wantparent or lockparent flag */ int rdonly; /* lookup read-only flag bit */ int error = 0; diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 88e00128892..f8a300a3007 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_subr.c,v 1.311 2021/10/23 14:42:07 mpi Exp $ */ +/* $OpenBSD: vfs_subr.c,v 1.312 2021/10/24 00:02:25 jsg Exp $ */ /* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */ /* @@ -271,8 +271,8 @@ vfs_rootmountalloc(char *fstypename, char *devname, struct mount **mpp) mp = vfs_mount_alloc(NULLVP, vfsp); mp->mnt_flag |= MNT_RDONLY; mp->mnt_stat.f_mntonname[0] = '/'; - copystr(devname, mp->mnt_stat.f_mntfromname, MNAMELEN, 0); - copystr(devname, mp->mnt_stat.f_mntfromspec, MNAMELEN, 0); + copystr(devname, mp->mnt_stat.f_mntfromname, MNAMELEN, NULL); + copystr(devname, mp->mnt_stat.f_mntfromspec, MNAMELEN, NULL); *mpp = mp; return (0); } @@ -428,7 +428,7 @@ getnewvnode(enum vtagtype tag, struct mount *mp, const struct vops *vops, if (vp == NULL) { splx(s); tablefull("vnode"); - *vpp = 0; + *vpp = NULL; return (ENFILE); } @@ -465,7 +465,7 @@ getnewvnode(enum vtagtype tag, struct mount *mp, const struct vops *vops, insmntque(vp, mp); *vpp = vp; vp->v_usecount = 1; - vp->v_data = 0; + vp->v_data = NULL; return (0); } @@ -531,7 +531,7 @@ getdevvp(dev_t dev, struct vnode **vpp, enum vtype type) } vp = nvp; vp->v_type = type; - if ((nvp = checkalias(vp, dev, NULL)) != 0) { + if ((nvp = checkalias(vp, dev, NULL)) != NULL) { vput(vp); vp = nvp; } @@ -1153,7 +1153,8 @@ vgonel(struct vnode *vp, struct proc *p) * If special device, remove it from special device alias list * if it is on one. */ - if ((vp->v_type == VBLK || vp->v_type == VCHR) && vp->v_specinfo != 0) { + if ((vp->v_type == VBLK || vp->v_type == VCHR) && + vp->v_specinfo != NULL) { if ((vp->v_flag & VALIASED) == 0 && vp->v_type == VCHR && (cdevsw[major(vp->v_rdev)].d_flags & D_CLONE) && (minor(vp->v_rdev) >> CLONE_SHIFT == 0)) { @@ -1433,7 +1434,7 @@ vfs_hang_addrlist(struct mount *mp, struct netexport *nep, struct radix_node_head *rnh; int nplen, i; struct radix_node *rn; - struct sockaddr *saddr, *smask = 0; + struct sockaddr *saddr, *smask = NULL; int error; if (argp->ex_addrlen == 0) { @@ -1486,7 +1487,7 @@ vfs_hang_addrlist(struct mount *mp, struct netexport *nep, goto out; } rn = rn_addroute(saddr, smask, rnh, np->netc_rnodes, 0); - if (rn == 0 || np != (struct netcred *)rn) { /* already exists */ + if (rn == NULL || np != (struct netcred *)rn) { /* already exists */ error = EPERM; goto out; } @@ -1757,7 +1758,7 @@ vfs_shutdown(struct proc *p) printf("syncing disks..."); - if (panicstr == 0) { + if (panicstr == NULL) { /* Sync before unmount, in case we hang on something. */ sys_sync(p, NULL, NULL); vfs_unmountall();