summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authordwmalone <dwmalone@FreeBSD.org>2000-12-08 21:51:06 +0000
committerdwmalone <dwmalone@FreeBSD.org>2000-12-08 21:51:06 +0000
commitdd75d1d73b4f3034c1d9f621a49fff58b1d71eb1 (patch)
tree197ae73617ae75afe008897f6906b84835589ea2 /sys/kern
parented5dbfbd3cd619638a7baac288f548aa1398edac (diff)
downloadFreeBSD-src-dd75d1d73b4f3034c1d9f621a49fff58b1d71eb1.zip
FreeBSD-src-dd75d1d73b4f3034c1d9f621a49fff58b1d71eb1.tar.gz
Convert more malloc+bzero to malloc+M_ZERO.
Submitted by: josh@zipperup.org Submitted by: Robert Drehmel <robd@gmx.net>
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_conf.c3
-rw-r--r--sys/kern/kern_descrip.c6
-rw-r--r--sys/kern/kern_event.c3
-rw-r--r--sys/kern/kern_jail.c3
-rw-r--r--sys/kern/kern_linker.c16
-rw-r--r--sys/kern/kern_mutex.c4
-rw-r--r--sys/kern/kern_sysctl.c3
-rw-r--r--sys/kern/link_elf.c3
-rw-r--r--sys/kern/link_elf_obj.c3
-rw-r--r--sys/kern/subr_blist.c4
-rw-r--r--sys/kern/subr_bus.c21
-rw-r--r--sys/kern/subr_kobj.c3
-rw-r--r--sys/kern/subr_prof.c3
-rw-r--r--sys/kern/subr_rman.c15
-rw-r--r--sys/kern/subr_turnstile.c4
-rw-r--r--sys/kern/subr_witness.c4
-rw-r--r--sys/kern/tty.c3
-rw-r--r--sys/kern/tty_pty.c3
-rw-r--r--sys/kern/tty_snoop.c3
-rw-r--r--sys/kern/uipc_socket.c6
-rw-r--r--sys/kern/uipc_syscalls.c4
-rw-r--r--sys/kern/vfs_export.c6
-rw-r--r--sys/kern/vfs_extattr.c3
-rw-r--r--sys/kern/vfs_init.c4
-rw-r--r--sys/kern/vfs_subr.c6
-rw-r--r--sys/kern/vfs_syscalls.c3
26 files changed, 50 insertions, 89 deletions
diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c
index 8c20321..0c446c8 100644
--- a/sys/kern/kern_conf.c
+++ b/sys/kern/kern_conf.c
@@ -170,8 +170,7 @@ allocdev(void)
if (stashed >= DEVT_STASH) {
MALLOC(si, struct specinfo *, sizeof(*si), M_DEVT,
- M_USE_RESERVE);
- bzero(si, sizeof(*si));
+ M_USE_RESERVE | M_ZERO);
} else if (LIST_FIRST(&dev_free)) {
si = LIST_FIRST(&dev_free);
LIST_REMOVE(si, si_hash);
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index 29de2b1..75ec0ee 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -859,8 +859,7 @@ falloc(p, resultfp, resultfd)
* the list of open files.
*/
nfiles++;
- MALLOC(fp, struct file *, sizeof(struct file), M_FILE, M_WAITOK);
- bzero(fp, sizeof(struct file));
+ MALLOC(fp, struct file *, sizeof(struct file), M_FILE, M_WAITOK | M_ZERO);
/*
* wait until after malloc (which may have blocked) returns before
@@ -915,8 +914,7 @@ fdinit(p)
register struct filedesc *fdp = p->p_fd;
MALLOC(newfdp, struct filedesc0 *, sizeof(struct filedesc0),
- M_FILEDESC, M_WAITOK);
- bzero(newfdp, sizeof(struct filedesc0));
+ M_FILEDESC, M_WAITOK | M_ZERO);
newfdp->fd_fd.fd_cdir = fdp->fd_cdir;
if (newfdp->fd_fd.fd_cdir)
VREF(newfdp->fd_fd.fd_cdir);
diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c
index 64d8d9f..56e818a 100644
--- a/sys/kern/kern_event.c
+++ b/sys/kern/kern_event.c
@@ -306,8 +306,7 @@ kqueue(struct proc *p, struct kqueue_args *uap)
fp->f_flag = FREAD | FWRITE;
fp->f_type = DTYPE_KQUEUE;
fp->f_ops = &kqueueops;
- kq = malloc(sizeof(struct kqueue), M_TEMP, M_WAITOK);
- bzero(kq, sizeof(*kq));
+ kq = malloc(sizeof(struct kqueue), M_TEMP, M_WAITOK | M_ZERO);
TAILQ_INIT(&kq->kq_head);
fp->f_data = (caddr_t)kq;
p->p_retval[0] = fd;
diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c
index d180f3c..97bb2bb 100644
--- a/sys/kern/kern_jail.c
+++ b/sys/kern/kern_jail.c
@@ -64,8 +64,7 @@ jail(p, uap)
return (error);
if (j.version != 0)
return (EINVAL);
- MALLOC(pr, struct prison *, sizeof *pr , M_PRISON, M_WAITOK);
- bzero((caddr_t)pr, sizeof *pr);
+ MALLOC(pr, struct prison *, sizeof *pr , M_PRISON, M_WAITOK | M_ZERO);
error = copyinstr(j.hostname, &pr->pr_host, sizeof pr->pr_host, 0);
if (error)
goto bail;
diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c
index 2060958..9fce595 100644
--- a/sys/kern/kern_linker.c
+++ b/sys/kern/kern_linker.c
@@ -515,10 +515,9 @@ linker_file_add_dependancy(linker_file_t file, linker_file_t dep)
linker_file_t* newdeps;
newdeps = malloc((file->ndeps + 1) * sizeof(linker_file_t*),
- M_LINKER, M_WAITOK);
+ M_LINKER, M_WAITOK | M_ZERO);
if (newdeps == NULL)
return ENOMEM;
- bzero(newdeps, (file->ndeps + 1) * sizeof(linker_file_t*));
if (file->deps) {
bcopy(file->deps, newdeps, file->ndeps * sizeof(linker_file_t*));
@@ -589,12 +588,11 @@ linker_file_lookup_symbol(linker_file_t file, const char* name, int deps)
cp = malloc(sizeof(struct common_symbol)
+ common_size
+ strlen(name) + 1,
- M_LINKER, M_WAITOK);
+ M_LINKER, M_WAITOK | M_ZERO);
if (!cp) {
KLD_DPF(SYM, ("linker_file_lookup_symbol: nomem\n"));
return 0;
}
- bzero(cp, sizeof(struct common_symbol) + common_size + strlen(name)+ 1);
cp->address = (caddr_t) (cp + 1);
cp->name = cp->address + common_size;
@@ -1021,10 +1019,9 @@ linker_preload(void* arg)
/* XXX what can we do? this is a build error. :-( */
continue;
}
- mod = malloc(sizeof(struct modlist), M_LINKER, M_NOWAIT);
+ mod = malloc(sizeof(struct modlist), M_LINKER, M_NOWAIT|M_ZERO);
if (mod == NULL)
panic("no memory for module list");
- bzero(mod, sizeof(*mod));
mod->container = linker_kernel_file;
mod->name = modname;
TAILQ_INSERT_TAIL(&found_modules, mod, link);
@@ -1082,10 +1079,10 @@ restart:
TAILQ_REMOVE(&loaded_files, lf, loaded);
goto restart; /* we changed the tailq next ptr */
}
- mod = malloc(sizeof(struct modlist), M_LINKER, M_NOWAIT);
+ mod = malloc(sizeof(struct modlist), M_LINKER,
+ M_NOWAIT|M_ZERO);
if (mod == NULL)
panic("no memory for module list");
- bzero(mod, sizeof(*mod));
mod->container = lf;
mod->name = modname;
TAILQ_INSERT_TAIL(&found_modules, mod, link);
@@ -1383,10 +1380,9 @@ linker_load_dependancies(linker_file_t lf)
if (mp->md_type != MDT_VERSION)
continue;
modname = linker_reloc_ptr(lf, mp->md_cval);
- mod = malloc(sizeof(struct modlist), M_LINKER, M_NOWAIT);
+ mod = malloc(sizeof(struct modlist), M_LINKER, M_NOWAIT|M_ZERO);
if (mod == NULL)
panic("no memory for module list");
- bzero(mod, sizeof(*mod));
mod->container = lf;
mod->name = modname;
TAILQ_INSERT_TAIL(&found_modules, mod, link);
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c
index 5290d90..af317f0 100644
--- a/sys/kern/kern_mutex.c
+++ b/sys/kern/kern_mutex.c
@@ -599,9 +599,9 @@ mtx_init(struct mtx *m, const char *t, int flag)
#endif
/* XXX - should not use DEVBUF */
- debug = malloc(sizeof(struct mtx_debug), M_DEVBUF, M_NOWAIT);
+ debug = malloc(sizeof(struct mtx_debug), M_DEVBUF,
+ M_NOWAIT | M_ZERO);
MPASS(debug != NULL);
- bzero(debug, sizeof(struct mtx_debug));
}
#endif
bzero((void *)m, sizeof *m);
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index 2085c90..e9aeff5 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -339,8 +339,7 @@ sysctl_add_oid(struct sysctl_ctx_list *clist, struct sysctl_oid_list *parent,
return (NULL);
}
}
- oidp = malloc(sizeof(struct sysctl_oid), M_SYSCTLOID, M_WAITOK);
- bzero(oidp, sizeof(struct sysctl_oid));
+ oidp = malloc(sizeof(struct sysctl_oid), M_SYSCTLOID, M_WAITOK|M_ZERO);
oidp->oid_parent = parent;
SLIST_NEXT(oidp, oid_link) = NULL;
oidp->oid_number = number;
diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c
index f812bfd..9908d8a 100644
--- a/sys/kern/link_elf.c
+++ b/sys/kern/link_elf.c
@@ -728,12 +728,11 @@ link_elf_load_file(linker_class_t cls, const char* filename, linker_file_t* resu
nbytes = hdr->e_shnum * hdr->e_shentsize;
if (nbytes == 0 || hdr->e_shoff == 0)
goto nosyms;
- shdr = malloc(nbytes, M_LINKER, M_WAITOK);
+ shdr = malloc(nbytes, M_LINKER, M_WAITOK | M_ZERO);
if (shdr == NULL) {
error = ENOMEM;
goto out;
}
- bzero(shdr, nbytes);
error = vn_rdwr(UIO_READ, nd.ni_vp,
(caddr_t)shdr, nbytes, hdr->e_shoff,
UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, p);
diff --git a/sys/kern/link_elf_obj.c b/sys/kern/link_elf_obj.c
index f812bfd..9908d8a 100644
--- a/sys/kern/link_elf_obj.c
+++ b/sys/kern/link_elf_obj.c
@@ -728,12 +728,11 @@ link_elf_load_file(linker_class_t cls, const char* filename, linker_file_t* resu
nbytes = hdr->e_shnum * hdr->e_shentsize;
if (nbytes == 0 || hdr->e_shoff == 0)
goto nosyms;
- shdr = malloc(nbytes, M_LINKER, M_WAITOK);
+ shdr = malloc(nbytes, M_LINKER, M_WAITOK | M_ZERO);
if (shdr == NULL) {
error = ENOMEM;
goto out;
}
- bzero(shdr, nbytes);
error = vn_rdwr(UIO_READ, nd.ni_vp,
(caddr_t)shdr, nbytes, hdr->e_shoff,
UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, p);
diff --git a/sys/kern/subr_blist.c b/sys/kern/subr_blist.c
index d706524..9ac4338 100644
--- a/sys/kern/subr_blist.c
+++ b/sys/kern/subr_blist.c
@@ -152,9 +152,7 @@ blist_create(daddr_t blocks)
skip = (skip + 1) << BLIST_META_RADIX_SHIFT;
}
- bl = malloc(sizeof(struct blist), M_SWAP, M_WAITOK);
-
- bzero(bl, sizeof(*bl));
+ bl = malloc(sizeof(struct blist), M_SWAP, M_WAITOK | M_ZERO);
bl->bl_blocks = blocks;
bl->bl_radix = radix;
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index a89048a..5032ab0 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -125,10 +125,9 @@ devclass_find_internal(const char *classname, int create)
PDEBUG(("%s not found%s", classname, (create? ", creating": "")));
if (create) {
dc = malloc(sizeof(struct devclass) + strlen(classname) + 1,
- M_BUS, M_NOWAIT);
+ M_BUS, M_NOWAIT|M_ZERO);
if (!dc)
return NULL;
- bzero(dc, sizeof(struct devclass) + strlen(classname) + 1);
dc->name = (char*) (dc + 1);
strcpy(dc->name, classname);
dc->devices = NULL;
@@ -162,10 +161,9 @@ devclass_add_driver(devclass_t dc, driver_t *driver)
PDEBUG(("%s", DRIVERNAME(driver)));
- dl = malloc(sizeof *dl, M_BUS, M_NOWAIT);
+ dl = malloc(sizeof *dl, M_BUS, M_NOWAIT|M_ZERO);
if (!dl)
return ENOMEM;
- bzero(dl, sizeof *dl);
/*
* Compile the driver's methods. Also increase the reference count
@@ -322,10 +320,9 @@ devclass_get_devices(devclass_t dc, device_t **devlistp, int *devcountp)
if (dc->devices[i])
count++;
- list = malloc(count * sizeof(device_t), M_TEMP, M_NOWAIT);
+ list = malloc(count * sizeof(device_t), M_TEMP, M_NOWAIT|M_ZERO);
if (!list)
return ENOMEM;
- bzero(list, count * sizeof(device_t));
count = 0;
for (i = 0; i < dc->maxunit; i++)
@@ -405,10 +402,9 @@ devclass_add_device(devclass_t dc, device_t dev)
PDEBUG(("%s in devclass %s", DEVICENAME(dev), DEVCLANAME(dc)));
buflen = strlen(dc->name) + 5;
- dev->nameunit = malloc(buflen, M_BUS, M_NOWAIT);
+ dev->nameunit = malloc(buflen, M_BUS, M_NOWAIT|M_ZERO);
if (!dev->nameunit)
return ENOMEM;
- bzero(dev->nameunit, buflen);
if ((error = devclass_alloc_unit(dc, &dev->unit)) != 0) {
free(dev->nameunit, M_BUS);
@@ -460,10 +456,9 @@ make_device(device_t parent, const char *name, int unit)
} else
dc = NULL;
- dev = malloc(sizeof(struct device), M_BUS, M_NOWAIT);
+ dev = malloc(sizeof(struct device), M_BUS, M_NOWAIT|M_ZERO);
if (!dev)
return 0;
- bzero(dev, sizeof(struct device));
dev->parent = parent;
TAILQ_INIT(&dev->children);
@@ -715,10 +710,9 @@ device_get_children(device_t dev, device_t **devlistp, int *devcountp)
child = TAILQ_NEXT(child, link))
count++;
- list = malloc(count * sizeof(device_t), M_TEMP, M_NOWAIT);
+ list = malloc(count * sizeof(device_t), M_TEMP, M_NOWAIT|M_ZERO);
if (!list)
return ENOMEM;
- bzero(list, count * sizeof(device_t));
count = 0;
for (child = TAILQ_FIRST(&dev->children); child;
@@ -993,13 +987,12 @@ device_set_driver(device_t dev, driver_t *driver)
if (driver) {
kobj_init((kobj_t) dev, (kobj_class_t) driver);
if (!(dev->flags & DF_EXTERNALSOFTC)) {
- dev->softc = malloc(driver->size, M_BUS, M_NOWAIT);
+ dev->softc = malloc(driver->size, M_BUS, M_NOWAIT|M_ZERO);
if (!dev->softc) {
kobj_init((kobj_t) dev, &null_class);
dev->driver = NULL;
return ENOMEM;
}
- bzero(dev->softc, driver->size);
}
} else
kobj_init((kobj_t) dev, &null_class);
diff --git a/sys/kern/subr_kobj.c b/sys/kern/subr_kobj.c
index 2f3e60f..659e97a 100644
--- a/sys/kern/subr_kobj.c
+++ b/sys/kern/subr_kobj.c
@@ -175,10 +175,9 @@ kobj_create(kobj_class_t cls,
/*
* Allocate and initialise the new object.
*/
- obj = malloc(cls->size, mtype, mflags);
+ obj = malloc(cls->size, mtype, mflags | M_ZERO);
if (!obj)
return 0;
- bzero(obj, cls->size);
kobj_init(obj, cls);
return obj;
diff --git a/sys/kern/subr_prof.c b/sys/kern/subr_prof.c
index 1c84108..3da2a05 100644
--- a/sys/kern/subr_prof.c
+++ b/sys/kern/subr_prof.c
@@ -114,12 +114,11 @@ kmstartup(dummy)
p->tolimit = MAXARCS;
p->tossize = p->tolimit * sizeof(struct tostruct);
cp = (char *)malloc(p->kcountsize + p->fromssize + p->tossize,
- M_GPROF, M_NOWAIT);
+ M_GPROF, M_NOWAIT | M_ZERO);
if (cp == 0) {
printf("No memory for profiling.\n");
return;
}
- bzero(cp, p->kcountsize + p->tossize + p->fromssize);
p->tos = (struct tostruct *)cp;
cp += p->tossize;
p->kcount = (HISTCOUNTER *)cp;
diff --git a/sys/kern/subr_rman.c b/sys/kern/subr_rman.c
index c3f7faf..ccd1af1 100644
--- a/sys/kern/subr_rman.c
+++ b/sys/kern/subr_rman.c
@@ -120,10 +120,9 @@ rman_manage_region(struct rman *rm, u_long start, u_long end)
{
struct resource *r, *s;
- r = malloc(sizeof *r, M_RMAN, M_NOWAIT);
+ r = malloc(sizeof *r, M_RMAN, M_NOWAIT | M_ZERO);
if (r == 0)
return ENOMEM;
- bzero(r, sizeof *r);
r->r_sharehead = 0;
r->r_start = start;
r->r_end = end;
@@ -247,10 +246,9 @@ rman_reserve_resource(struct rman *rm, u_long start, u_long end, u_long count,
* split it in two. The first case requires
* two new allocations; the second requires but one.
*/
- rv = malloc(sizeof *rv, M_RMAN, M_NOWAIT);
+ rv = malloc(sizeof *rv, M_RMAN, M_NOWAIT | M_ZERO);
if (rv == 0)
goto out;
- bzero(rv, sizeof *rv);
rv->r_start = rstart;
rv->r_end = rstart + count - 1;
rv->r_flags = flags | RF_ALLOCATED;
@@ -267,13 +265,12 @@ rman_reserve_resource(struct rman *rm, u_long start, u_long end, u_long count,
/*
* We are allocating in the middle.
*/
- r = malloc(sizeof *r, M_RMAN, M_NOWAIT);
+ r = malloc(sizeof *r, M_RMAN, M_NOWAIT|M_ZERO);
if (r == 0) {
free(rv, M_RMAN);
rv = 0;
goto out;
}
- bzero(r, sizeof *r);
r->r_start = rv->r_end + 1;
r->r_end = s->r_end;
r->r_flags = s->r_flags;
@@ -326,10 +323,9 @@ rman_reserve_resource(struct rman *rm, u_long start, u_long end, u_long count,
rend = min(s->r_end, max(start + count, end));
if (s->r_start >= start && s->r_end <= end
&& (s->r_end - s->r_start + 1) == count) {
- rv = malloc(sizeof *rv, M_RMAN, M_NOWAIT);
+ rv = malloc(sizeof *rv, M_RMAN, M_NOWAIT | M_ZERO);
if (rv == 0)
goto out;
- bzero(rv, sizeof *rv);
rv->r_start = s->r_start;
rv->r_end = s->r_end;
rv->r_flags = s->r_flags &
@@ -338,13 +334,12 @@ rman_reserve_resource(struct rman *rm, u_long start, u_long end, u_long count,
rv->r_rm = rm;
if (s->r_sharehead == 0) {
s->r_sharehead = malloc(sizeof *s->r_sharehead,
- M_RMAN, M_NOWAIT);
+ M_RMAN, M_NOWAIT | M_ZERO);
if (s->r_sharehead == 0) {
free(rv, M_RMAN);
rv = 0;
goto out;
}
- bzero(s->r_sharehead, sizeof *s->r_sharehead);
LIST_INIT(s->r_sharehead);
LIST_INSERT_HEAD(s->r_sharehead, s,
r_sharelink);
diff --git a/sys/kern/subr_turnstile.c b/sys/kern/subr_turnstile.c
index 5290d90..af317f0 100644
--- a/sys/kern/subr_turnstile.c
+++ b/sys/kern/subr_turnstile.c
@@ -599,9 +599,9 @@ mtx_init(struct mtx *m, const char *t, int flag)
#endif
/* XXX - should not use DEVBUF */
- debug = malloc(sizeof(struct mtx_debug), M_DEVBUF, M_NOWAIT);
+ debug = malloc(sizeof(struct mtx_debug), M_DEVBUF,
+ M_NOWAIT | M_ZERO);
MPASS(debug != NULL);
- bzero(debug, sizeof(struct mtx_debug));
}
#endif
bzero((void *)m, sizeof *m);
diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c
index 5290d90..af317f0 100644
--- a/sys/kern/subr_witness.c
+++ b/sys/kern/subr_witness.c
@@ -599,9 +599,9 @@ mtx_init(struct mtx *m, const char *t, int flag)
#endif
/* XXX - should not use DEVBUF */
- debug = malloc(sizeof(struct mtx_debug), M_DEVBUF, M_NOWAIT);
+ debug = malloc(sizeof(struct mtx_debug), M_DEVBUF,
+ M_NOWAIT | M_ZERO);
MPASS(debug != NULL);
- bzero(debug, sizeof(struct mtx_debug));
}
#endif
bzero((void *)m, sizeof *m);
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index ce11ea5..b80d266 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -2423,8 +2423,7 @@ ttymalloc(tp)
if (tp)
return(tp);
- tp = malloc(sizeof *tp, M_TTYS, M_WAITOK);
- bzero(tp, sizeof *tp);
+ tp = malloc(sizeof *tp, M_TTYS, M_WAITOK | M_ZERO);
ttyregister(tp);
return (tp);
}
diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c
index 58af6c6..f7a4370 100644
--- a/sys/kern/tty_pty.c
+++ b/sys/kern/tty_pty.c
@@ -147,8 +147,7 @@ ptyinit(n)
if (n & ~0xff)
return (NODEV);
- pt = malloc(sizeof(*pt), M_PTY, M_WAITOK);
- bzero(pt, sizeof(*pt));
+ pt = malloc(sizeof(*pt), M_PTY, M_WAITOK | M_ZERO);
pt->devs = devs = make_dev(&pts_cdevsw, n,
UID_ROOT, GID_WHEEL, 0666, "tty%c%r", names[n / 32], n % 32);
pt->devc = devc = make_dev(&ptc_cdevsw, n,
diff --git a/sys/kern/tty_snoop.c b/sys/kern/tty_snoop.c
index 9950513..b448e30 100644
--- a/sys/kern/tty_snoop.c
+++ b/sys/kern/tty_snoop.c
@@ -291,8 +291,7 @@ snpopen(dev, flag, mode, p)
if (dev->si_drv1 == NULL) {
int mynor = minor(dev);
- dev->si_drv1 = snp = malloc(sizeof(*snp), M_SNP, M_WAITOK);
- bzero(snp, sizeof(*snp));
+ dev->si_drv1 = snp = malloc(sizeof(*snp), M_SNP, M_WAITOK|M_ZERO);
make_dev(&snp_cdevsw, mynor, 0, 0, 0600, "snp%d", mynor);
} else
return (EBUSY);
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 2d8a578..a93ee50 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -1045,8 +1045,7 @@ do_setopt_accept_filter(so, sopt)
error = ENOENT;
goto out;
}
- MALLOC(af, struct so_accf *, sizeof(*af), M_ACCF, M_WAITOK);
- bzero(af, sizeof(*af));
+ MALLOC(af, struct so_accf *, sizeof(*af), M_ACCF, M_WAITOK | M_ZERO);
if (afp->accf_create != NULL) {
if (afap->af_name[0] != '\0') {
int len = strlen(afap->af_name) + 1;
@@ -1310,8 +1309,7 @@ sogetopt(so, sopt)
if ((so->so_options & SO_ACCEPTCONN) == 0)
return (EINVAL);
MALLOC(afap, struct accept_filter_arg *, sizeof(*afap),
- M_TEMP, M_WAITOK);
- bzero(afap, sizeof(*afap));
+ M_TEMP, M_WAITOK | M_ZERO);
if ((so->so_options & SO_ACCEPTFILTER) != 0) {
strcpy(afap->af_name, so->so_accf->so_accept_filter->accf_name);
if (so->so_accf->so_accept_filter_str != NULL)
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index d5cc5ea..d5b8ec5 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -1421,8 +1421,8 @@ sf_buf_init(void *arg)
mtx_enter(&sf_freelist.sf_lock, MTX_DEF);
SLIST_INIT(&sf_freelist);
sf_base = kmem_alloc_pageable(kernel_map, nsfbufs * PAGE_SIZE);
- sf_bufs = malloc(nsfbufs * sizeof(struct sf_buf), M_TEMP, M_NOWAIT);
- bzero(sf_bufs, nsfbufs * sizeof(struct sf_buf));
+ sf_bufs = malloc(nsfbufs * sizeof(struct sf_buf), M_TEMP,
+ M_NOWAIT | M_ZERO);
for (i = 0; i < nsfbufs; i++) {
sf_bufs[i].kva = sf_base + i * PAGE_SIZE;
SLIST_INSERT_HEAD(&sf_freelist, &sf_bufs[i], free_list);
diff --git a/sys/kern/vfs_export.c b/sys/kern/vfs_export.c
index 8bfc501..a6bae88 100644
--- a/sys/kern/vfs_export.c
+++ b/sys/kern/vfs_export.c
@@ -335,8 +335,7 @@ vfs_rootmountalloc(fstypename, devname, mpp)
break;
if (vfsp == NULL)
return (ENODEV);
- mp = malloc((u_long)sizeof(struct mount), M_MOUNT, M_WAITOK);
- bzero((char *)mp, (u_long)sizeof(struct mount));
+ mp = malloc((u_long)sizeof(struct mount), M_MOUNT, M_WAITOK | M_ZERO);
lockinit(&mp->mnt_lock, PVFS, "vfslock", 0, LK_NOPAUSE);
(void)vfs_busy(mp, LK_NOWAIT, 0, p);
LIST_INIT(&mp->mnt_vnodelist);
@@ -2322,8 +2321,7 @@ vfs_hang_addrlist(mp, nep, argp)
return (0);
}
i = sizeof(struct netcred) + argp->ex_addrlen + argp->ex_masklen;
- np = (struct netcred *) malloc(i, M_NETADDR, M_WAITOK);
- bzero((caddr_t) np, i);
+ np = (struct netcred *) malloc(i, M_NETADDR, M_WAITOK | M_ZERO);
saddr = (struct sockaddr *) (np + 1);
if ((error = copyin(argp->ex_addr, (caddr_t) saddr, argp->ex_addrlen)))
goto out;
diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c
index 59aacb5..5f1a1d4 100644
--- a/sys/kern/vfs_extattr.c
+++ b/sys/kern/vfs_extattr.c
@@ -256,8 +256,7 @@ mount(p, uap)
/*
* Allocate and initialize the filesystem.
*/
- mp = malloc(sizeof(struct mount), M_MOUNT, M_WAITOK);
- bzero((char *)mp, (u_long)sizeof(struct mount));
+ mp = malloc(sizeof(struct mount), M_MOUNT, M_WAITOK | M_ZERO);
lockinit(&mp->mnt_lock, PVFS, "vfslock", 0, LK_NOPAUSE);
(void)vfs_busy(mp, LK_NOWAIT, 0, p);
mp->mnt_op = vfsp->vfc_vfsops;
diff --git a/sys/kern/vfs_init.c b/sys/kern/vfs_init.c
index 3a053cf..3f36a5f 100644
--- a/sys/kern/vfs_init.c
+++ b/sys/kern/vfs_init.c
@@ -119,10 +119,10 @@ vfs_opv_recalc(void)
if (*opv_desc_vector_p)
FREE(*opv_desc_vector_p, M_VNODE);
MALLOC(*opv_desc_vector_p, vop_t **,
- vfs_opv_numops * sizeof(vop_t *), M_VNODE, M_WAITOK);
+ vfs_opv_numops * sizeof(vop_t *), M_VNODE,
+ M_WAITOK | M_ZERO);
if (*opv_desc_vector_p == NULL)
panic("no memory for vop_t ** vector");
- bzero(*opv_desc_vector_p, vfs_opv_numops * sizeof(vop_t *));
/* Fill in, with slot 0 being to return EOPNOTSUPP */
opv_desc_vector = *opv_desc_vector_p;
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index 8bfc501..a6bae88 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -335,8 +335,7 @@ vfs_rootmountalloc(fstypename, devname, mpp)
break;
if (vfsp == NULL)
return (ENODEV);
- mp = malloc((u_long)sizeof(struct mount), M_MOUNT, M_WAITOK);
- bzero((char *)mp, (u_long)sizeof(struct mount));
+ mp = malloc((u_long)sizeof(struct mount), M_MOUNT, M_WAITOK | M_ZERO);
lockinit(&mp->mnt_lock, PVFS, "vfslock", 0, LK_NOPAUSE);
(void)vfs_busy(mp, LK_NOWAIT, 0, p);
LIST_INIT(&mp->mnt_vnodelist);
@@ -2322,8 +2321,7 @@ vfs_hang_addrlist(mp, nep, argp)
return (0);
}
i = sizeof(struct netcred) + argp->ex_addrlen + argp->ex_masklen;
- np = (struct netcred *) malloc(i, M_NETADDR, M_WAITOK);
- bzero((caddr_t) np, i);
+ np = (struct netcred *) malloc(i, M_NETADDR, M_WAITOK | M_ZERO);
saddr = (struct sockaddr *) (np + 1);
if ((error = copyin(argp->ex_addr, (caddr_t) saddr, argp->ex_addrlen)))
goto out;
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index 59aacb5..5f1a1d4 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -256,8 +256,7 @@ mount(p, uap)
/*
* Allocate and initialize the filesystem.
*/
- mp = malloc(sizeof(struct mount), M_MOUNT, M_WAITOK);
- bzero((char *)mp, (u_long)sizeof(struct mount));
+ mp = malloc(sizeof(struct mount), M_MOUNT, M_WAITOK | M_ZERO);
lockinit(&mp->mnt_lock, PVFS, "vfslock", 0, LK_NOPAUSE);
(void)vfs_busy(mp, LK_NOWAIT, 0, p);
mp->mnt_op = vfsp->vfc_vfsops;
OpenPOWER on IntegriCloud