1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-29 12:03:03 +00:00

Fix a number of style issues in the MALLOC / FREE commit. I've tried to

be careful not to fix anything that was already broken; the NFSv4 code is
particularly bad in this respect.
This commit is contained in:
Dag-Erling Smørgrav 2008-10-23 20:26:15 +00:00
parent cdab8377da
commit e11e3f187d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=184214
32 changed files with 96 additions and 81 deletions

View File

@ -202,8 +202,7 @@ hfsc_add_altq(struct pf_altq *a)
if (!ALTQ_IS_READY(&ifp->if_snd)) if (!ALTQ_IS_READY(&ifp->if_snd))
return (ENODEV); return (ENODEV);
hif = malloc(sizeof(struct hfsc_if), hif = malloc(sizeof(struct hfsc_if), M_DEVBUF, M_WAITOK);
M_DEVBUF, M_WAITOK);
if (hif == NULL) if (hif == NULL)
return (ENOMEM); return (ENOMEM);
bzero(hif, sizeof(struct hfsc_if)); bzero(hif, sizeof(struct hfsc_if));
@ -404,14 +403,12 @@ hfsc_class_create(struct hfsc_if *hif, struct service_curve *rsc,
} }
#endif #endif
cl = malloc(sizeof(struct hfsc_class), cl = malloc(sizeof(struct hfsc_class), M_DEVBUF, M_WAITOK);
M_DEVBUF, M_WAITOK);
if (cl == NULL) if (cl == NULL)
return (NULL); return (NULL);
bzero(cl, sizeof(struct hfsc_class)); bzero(cl, sizeof(struct hfsc_class));
cl->cl_q = malloc(sizeof(class_queue_t), cl->cl_q = malloc(sizeof(class_queue_t), M_DEVBUF, M_WAITOK);
M_DEVBUF, M_WAITOK);
if (cl->cl_q == NULL) if (cl->cl_q == NULL)
goto err_ret; goto err_ret;
bzero(cl->cl_q, sizeof(class_queue_t)); bzero(cl->cl_q, sizeof(class_queue_t));
@ -471,7 +468,8 @@ hfsc_class_create(struct hfsc_if *hif, struct service_curve *rsc,
#endif /* ALTQ_RED */ #endif /* ALTQ_RED */
if (rsc != NULL && (rsc->m1 != 0 || rsc->m2 != 0)) { if (rsc != NULL && (rsc->m1 != 0 || rsc->m2 != 0)) {
cl->cl_rsc = malloc( sizeof(struct internal_sc), M_DEVBUF, M_WAITOK); cl->cl_rsc = malloc(sizeof(struct internal_sc),
M_DEVBUF, M_WAITOK);
if (cl->cl_rsc == NULL) if (cl->cl_rsc == NULL)
goto err_ret; goto err_ret;
sc2isc(rsc, cl->cl_rsc); sc2isc(rsc, cl->cl_rsc);
@ -479,14 +477,16 @@ hfsc_class_create(struct hfsc_if *hif, struct service_curve *rsc,
rtsc_init(&cl->cl_eligible, cl->cl_rsc, 0, 0); rtsc_init(&cl->cl_eligible, cl->cl_rsc, 0, 0);
} }
if (fsc != NULL && (fsc->m1 != 0 || fsc->m2 != 0)) { if (fsc != NULL && (fsc->m1 != 0 || fsc->m2 != 0)) {
cl->cl_fsc = malloc( sizeof(struct internal_sc), M_DEVBUF, M_WAITOK); cl->cl_fsc = malloc(sizeof(struct internal_sc),
M_DEVBUF, M_WAITOK);
if (cl->cl_fsc == NULL) if (cl->cl_fsc == NULL)
goto err_ret; goto err_ret;
sc2isc(fsc, cl->cl_fsc); sc2isc(fsc, cl->cl_fsc);
rtsc_init(&cl->cl_virtual, cl->cl_fsc, 0, 0); rtsc_init(&cl->cl_virtual, cl->cl_fsc, 0, 0);
} }
if (usc != NULL && (usc->m1 != 0 || usc->m2 != 0)) { if (usc != NULL && (usc->m1 != 0 || usc->m2 != 0)) {
cl->cl_usc = malloc( sizeof(struct internal_sc), M_DEVBUF, M_WAITOK); cl->cl_usc = malloc(sizeof(struct internal_sc),
M_DEVBUF, M_WAITOK);
if (cl->cl_usc == NULL) if (cl->cl_usc == NULL)
goto err_ret; goto err_ret;
sc2isc(usc, cl->cl_usc); sc2isc(usc, cl->cl_usc);
@ -1740,8 +1740,7 @@ hfsc_attach(ifq, bandwidth)
{ {
struct hfsc_if *hif; struct hfsc_if *hif;
hif = malloc(sizeof(struct hfsc_if), hif = malloc(sizeof(struct hfsc_if), M_DEVBUF, M_WAITOK);
M_DEVBUF, M_WAITOK);
if (hif == NULL) if (hif == NULL)
return (NULL); return (NULL);
bzero(hif, sizeof(struct hfsc_if)); bzero(hif, sizeof(struct hfsc_if));
@ -1801,19 +1800,22 @@ hfsc_class_modify(cl, rsc, fsc, usc)
rsc_tmp = fsc_tmp = usc_tmp = NULL; rsc_tmp = fsc_tmp = usc_tmp = NULL;
if (rsc != NULL && (rsc->m1 != 0 || rsc->m2 != 0) && if (rsc != NULL && (rsc->m1 != 0 || rsc->m2 != 0) &&
cl->cl_rsc == NULL) { cl->cl_rsc == NULL) {
rsc_tmp = malloc( sizeof(struct internal_sc), M_DEVBUF, M_WAITOK); rsc_tmp = malloc(sizeof(struct internal_sc),
M_DEVBUF, M_WAITOK);
if (rsc_tmp == NULL) if (rsc_tmp == NULL)
return (ENOMEM); return (ENOMEM);
} }
if (fsc != NULL && (fsc->m1 != 0 || fsc->m2 != 0) && if (fsc != NULL && (fsc->m1 != 0 || fsc->m2 != 0) &&
cl->cl_fsc == NULL) { cl->cl_fsc == NULL) {
fsc_tmp = malloc( sizeof(struct internal_sc), M_DEVBUF, M_WAITOK); fsc_tmp = malloc(sizeof(struct internal_sc),
M_DEVBUF, M_WAITOK);
if (fsc_tmp == NULL) if (fsc_tmp == NULL)
return (ENOMEM); return (ENOMEM);
} }
if (usc != NULL && (usc->m1 != 0 || usc->m2 != 0) && if (usc != NULL && (usc->m1 != 0 || usc->m2 != 0) &&
cl->cl_usc == NULL) { cl->cl_usc == NULL) {
usc_tmp = malloc( sizeof(struct internal_sc), M_DEVBUF, M_WAITOK); usc_tmp = malloc(sizeof(struct internal_sc),
M_DEVBUF, M_WAITOK);
if (usc_tmp == NULL) if (usc_tmp == NULL)
return (ENOMEM); return (ENOMEM);
} }

View File

@ -331,8 +331,7 @@ pmc_debugflags_parse(char *newstr, char *fence)
int error, found, *newbits, tmp; int error, found, *newbits, tmp;
size_t kwlen; size_t kwlen;
tmpflags = malloc(sizeof(*tmpflags), tmpflags = malloc(sizeof(*tmpflags), M_PMC, M_WAITOK|M_ZERO);
M_PMC, M_WAITOK|M_ZERO);
p = newstr; p = newstr;
error = 0; error = 0;
@ -777,8 +776,7 @@ pmc_link_target_process(struct pmc *pm, struct pmc_process *pp)
__LINE__, pp, pm)); __LINE__, pp, pm));
#endif #endif
pt = malloc(sizeof(struct pmc_target), pt = malloc(sizeof(struct pmc_target), M_PMC, M_ZERO|M_WAITOK);
M_PMC, M_ZERO|M_WAITOK);
pt->pt_process = pp; pt->pt_process = pp;
@ -1861,8 +1859,7 @@ pmc_allocate_owner_descriptor(struct proc *p)
poh = &pmc_ownerhash[hindex]; poh = &pmc_ownerhash[hindex];
/* allocate space for N pointers and one descriptor struct */ /* allocate space for N pointers and one descriptor struct */
po = malloc(sizeof(struct pmc_owner), po = malloc(sizeof(struct pmc_owner), M_PMC, M_ZERO|M_WAITOK);
M_PMC, M_ZERO|M_WAITOK);
po->po_sscount = po->po_error = po->po_flags = 0; po->po_sscount = po->po_error = po->po_flags = 0;
po->po_file = NULL; po->po_file = NULL;
@ -1915,7 +1912,7 @@ pmc_find_process_descriptor(struct proc *p, uint32_t mode)
if (mode & PMC_FLAG_ALLOCATE) { if (mode & PMC_FLAG_ALLOCATE) {
/* allocate additional space for 'n' pmc pointers */ /* allocate additional space for 'n' pmc pointers */
ppnew = malloc( sizeof(struct pmc_process) + md->pmd_npmc * ppnew = malloc(sizeof(struct pmc_process) + md->pmd_npmc *
sizeof(struct pmc_targetstate), M_PMC, M_ZERO|M_WAITOK); sizeof(struct pmc_targetstate), M_PMC, M_ZERO|M_WAITOK);
} }
@ -2818,8 +2815,7 @@ pmc_syscall_handler(struct thread *td, void *syscall_args)
npmc = md->pmd_npmc; npmc = md->pmd_npmc;
pmcinfo_size = npmc * sizeof(struct pmc_info); pmcinfo_size = npmc * sizeof(struct pmc_info);
pmcinfo = malloc(pmcinfo_size, M_PMC, pmcinfo = malloc(pmcinfo_size, M_PMC, M_WAITOK);
M_WAITOK);
p = pmcinfo; p = pmcinfo;
@ -4356,7 +4352,8 @@ pmc_initialize(void)
M_PMC, M_WAITOK|M_ZERO); M_PMC, M_WAITOK|M_ZERO);
/* per-cpu 'saved values' for managing process-mode PMCs */ /* per-cpu 'saved values' for managing process-mode PMCs */
pmc_pcpu_saved = malloc( sizeof(pmc_value_t) * maxcpu * md->pmd_npmc, M_PMC, M_WAITOK); pmc_pcpu_saved = malloc(sizeof(pmc_value_t) * maxcpu * md->pmd_npmc,
M_PMC, M_WAITOK);
/* Perform CPU-dependent initialization. */ /* Perform CPU-dependent initialization. */
pmc_save_cpu_binding(&pb); pmc_save_cpu_binding(&pb);
@ -4376,7 +4373,7 @@ pmc_initialize(void)
for (cpu = 0; cpu < maxcpu; cpu++) { for (cpu = 0; cpu < maxcpu; cpu++) {
if (!pmc_cpu_is_active(cpu)) if (!pmc_cpu_is_active(cpu))
continue; continue;
sb = malloc( sizeof(struct pmc_samplebuffer) + sb = malloc(sizeof(struct pmc_samplebuffer) +
pmc_nsamples * sizeof(struct pmc_sample), M_PMC, pmc_nsamples * sizeof(struct pmc_sample), M_PMC,
M_WAITOK|M_ZERO); M_WAITOK|M_ZERO);
@ -4385,7 +4382,8 @@ pmc_initialize(void)
KASSERT(pmc_pcpu[cpu] != NULL, KASSERT(pmc_pcpu[cpu] != NULL,
("[pmc,%d] cpu=%d Null per-cpu data", __LINE__, cpu)); ("[pmc,%d] cpu=%d Null per-cpu data", __LINE__, cpu));
sb->ps_callchains = malloc( pmc_callchaindepth * pmc_nsamples * sizeof(uintptr_t), sb->ps_callchains = malloc(pmc_callchaindepth *
pmc_nsamples * sizeof(uintptr_t),
M_PMC, M_WAITOK|M_ZERO); M_PMC, M_WAITOK|M_ZERO);
for (n = 0, ps = sb->ps_samples; n < pmc_nsamples; n++, ps++) for (n = 0, ps = sb->ps_samples; n < pmc_nsamples; n++, ps++)

View File

@ -628,7 +628,8 @@ p4_init(int cpu)
if (pcs == NULL) /* decline to init */ if (pcs == NULL) /* decline to init */
return ENXIO; return ENXIO;
plcs = malloc( sizeof(struct p4_logicalcpu), M_PMC, M_WAITOK|M_ZERO); plcs = malloc(sizeof(struct p4_logicalcpu),
M_PMC, M_WAITOK|M_ZERO);
/* The TSC is architectural state and is not shared */ /* The TSC is architectural state and is not shared */
plcs->pc_hwpmcs[0] = &plcs->pc_tsc; plcs->pc_hwpmcs[0] = &plcs->pc_tsc;
@ -644,8 +645,7 @@ p4_init(int cpu)
return 0; return 0;
} }
pcs = malloc(sizeof(struct p4_cpu), M_PMC, pcs = malloc(sizeof(struct p4_cpu), M_PMC, M_WAITOK|M_ZERO);
M_WAITOK|M_ZERO);
if (pcs == NULL) if (pcs == NULL)
return ENOMEM; return ENOMEM;

View File

@ -3177,7 +3177,7 @@ ray_com_malloc(ray_comqfn_t function, int flags, char *mesg)
{ {
struct ray_comq_entry *com; struct ray_comq_entry *com;
com = malloc( sizeof(struct ray_comq_entry), M_RAYCOM, M_WAITOK); com = malloc(sizeof(struct ray_comq_entry), M_RAYCOM, M_WAITOK);
return (ray_com_init(com, function, flags, mesg)); return (ray_com_init(com, function, flags, mesg));
} }

View File

@ -305,7 +305,7 @@ sr_attach(device_t device)
int unit; /* index: channel w/in card */ int unit; /* index: channel w/in card */
hc = (struct sr_hardc *)device_get_softc(device); hc = (struct sr_hardc *)device_get_softc(device);
sc = malloc( hc->numports * sizeof(struct sr_softc), sc = malloc(hc->numports * sizeof(struct sr_softc),
M_DEVBUF, M_WAITOK | M_ZERO); M_DEVBUF, M_WAITOK | M_ZERO);
if (sc == NULL) if (sc == NULL)
goto errexit; goto errexit;

View File

@ -278,7 +278,8 @@ hpfs_cpinit (
cpicnt = hpmp->hpm_sp.sp_cpinum; cpicnt = hpmp->hpm_sp.sp_cpinum;
hpmp->hpm_cpdblk = malloc( cpicnt * sizeof(struct cpdblk), M_HPFSMNT, M_WAITOK); hpmp->hpm_cpdblk = malloc(cpicnt * sizeof(struct cpdblk),
M_HPFSMNT, M_WAITOK);
cpdbp = hpmp->hpm_cpdblk; cpdbp = hpmp->hpm_cpdblk;
lsn = hpmp->hpm_sp.sp_cpi; lsn = hpmp->hpm_sp.sp_cpi;

View File

@ -1143,7 +1143,8 @@ ntfs_ntreaddir(
if (fp->f_dirblbuf == NULL) { if (fp->f_dirblbuf == NULL) {
fp->f_dirblsz = vap->va_a_iroot->ir_size; fp->f_dirblsz = vap->va_a_iroot->ir_size;
fp->f_dirblbuf = malloc( max(vap->va_datalen,fp->f_dirblsz), M_NTFSDIR, M_WAITOK); fp->f_dirblbuf = malloc(max(vap->va_datalen,fp->f_dirblsz),
M_NTFSDIR, M_WAITOK);
} }
blsize = fp->f_dirblsz; blsize = fp->f_dirblsz;

View File

@ -416,7 +416,7 @@ ntfs_mountfs(devvp, mp, td)
} }
/* Alloc memory for attribute definitions */ /* Alloc memory for attribute definitions */
ntmp->ntm_ad = malloc( num * sizeof(struct ntvattrdef), ntmp->ntm_ad = malloc(num * sizeof(struct ntvattrdef),
M_NTFSMNT, M_WAITOK); M_NTFSMNT, M_WAITOK);
ntmp->ntm_adnum = num; ntmp->ntm_adnum = num;

View File

@ -647,8 +647,7 @@ udf_vget(struct mount *mp, ino_t ino, int flags, struct vnode **vpp)
return (ENOMEM); return (ENOMEM);
} }
size = UDF_FENTRY_SIZE + le32toh(fe->l_ea) + le32toh(fe->l_ad); size = UDF_FENTRY_SIZE + le32toh(fe->l_ea) + le32toh(fe->l_ad);
unode->fentry = malloc(size, M_UDFFENTRY, unode->fentry = malloc(size, M_UDFFENTRY, M_NOWAIT | M_ZERO);
M_NOWAIT | M_ZERO);
if (unode->fentry == NULL) { if (unode->fentry == NULL) {
printf("Cannot allocate file entry block\n"); printf("Cannot allocate file entry block\n");
vgone(vp); vgone(vp);
@ -757,7 +756,8 @@ udf_find_partmaps(struct udf_mnt *udfmp, struct logvol_desc *lvd)
pms = (struct part_map_spare *)pmap; pms = (struct part_map_spare *)pmap;
pmap += UDF_PMAP_TYPE2_SIZE; pmap += UDF_PMAP_TYPE2_SIZE;
udfmp->s_table = malloc( le32toh(pms->st_size), M_UDFMOUNT, M_NOWAIT | M_ZERO); udfmp->s_table = malloc(le32toh(pms->st_size),
M_UDFMOUNT, M_NOWAIT | M_ZERO);
if (udfmp->s_table == NULL) if (udfmp->s_table == NULL)
return (ENOMEM); return (ENOMEM);

View File

@ -440,7 +440,8 @@ unionfs_get_node_status(struct unionfs_node *unp, struct thread *td,
} }
/* create a new unionfs node status */ /* create a new unionfs node status */
unsp = malloc( sizeof(struct unionfs_node_status), M_TEMP, M_WAITOK | M_ZERO); unsp = malloc(sizeof(struct unionfs_node_status),
M_TEMP, M_WAITOK | M_ZERO);
unsp->uns_pid = pid; unsp->uns_pid = pid;
LIST_INSERT_HEAD(&(unp->un_unshead), unsp, uns_list); LIST_INSERT_HEAD(&(unp->un_unshead), unsp, uns_list);

View File

@ -2409,7 +2409,7 @@ filedesc_to_leader_alloc(struct filedesc_to_leader *old, struct filedesc *fdp, s
{ {
struct filedesc_to_leader *fdtol; struct filedesc_to_leader *fdtol;
fdtol = malloc( sizeof(struct filedesc_to_leader), fdtol = malloc(sizeof(struct filedesc_to_leader),
M_FILEDESC_TO_LEADER, M_FILEDESC_TO_LEADER,
M_WAITOK); M_WAITOK);
fdtol->fdl_refcount = 1; fdtol->fdl_refcount = 1;

View File

@ -529,8 +529,7 @@ filt_timerattach(struct knote *kn)
kn->kn_flags |= EV_CLEAR; /* automatically set */ kn->kn_flags |= EV_CLEAR; /* automatically set */
kn->kn_status &= ~KN_DETACHED; /* knlist_add usually sets it */ kn->kn_status &= ~KN_DETACHED; /* knlist_add usually sets it */
calloutp = malloc(sizeof(*calloutp), calloutp = malloc(sizeof(*calloutp), M_KQUEUE, M_WAITOK);
M_KQUEUE, M_WAITOK);
callout_init(calloutp, CALLOUT_MPSAFE); callout_init(calloutp, CALLOUT_MPSAFE);
kn->kn_hook = calloutp; kn->kn_hook = calloutp;
callout_reset_curcpu(calloutp, timertoticks(kn->kn_sdata), callout_reset_curcpu(calloutp, timertoticks(kn->kn_sdata),
@ -1109,7 +1108,7 @@ kqueue_expand(struct kqueue *kq, struct filterops *fops, uintptr_t ident,
size = kq->kq_knlistsize; size = kq->kq_knlistsize;
while (size <= fd) while (size <= fd)
size += KQEXTENT; size += KQEXTENT;
list = malloc( size * sizeof list, M_KQUEUE, mflag); list = malloc(size * sizeof list, M_KQUEUE, mflag);
if (list == NULL) if (list == NULL)
return ENOMEM; return ENOMEM;
KQ_LOCK(kq); KQ_LOCK(kq);

View File

@ -1893,8 +1893,8 @@ linker_hwpmc_list_objects(void)
retry: retry:
/* allocate nmappings+1 entries */ /* allocate nmappings+1 entries */
hc.kobase = malloc( (hc.nmappings + 1) * sizeof(struct pmckern_map_in), M_LINKER, hc.kobase = malloc((hc.nmappings + 1) * sizeof(struct pmckern_map_in),
M_WAITOK | M_ZERO); M_LINKER, M_WAITOK | M_ZERO);
hc.nobjects = 0; hc.nobjects = 0;
if (linker_file_foreach(linker_hwpmc_list_object, &hc) != 0) { if (linker_file_foreach(linker_hwpmc_list_object, &hc) != 0) {

View File

@ -146,7 +146,8 @@ mtx_pool_create(const char *mtx_name, int pool_size, int opts)
mtx_name); mtx_name);
pool_size = 128; pool_size = 128;
} }
pool = malloc( sizeof (struct mtx_pool) + ((pool_size - 1) * sizeof (struct mtx)), pool = malloc(sizeof (struct mtx_pool) +
((pool_size - 1) * sizeof (struct mtx)),
M_MTXPOOL, M_WAITOK | M_ZERO); M_MTXPOOL, M_WAITOK | M_ZERO);
mtx_pool_initialize(pool, mtx_name, pool_size, opts); mtx_pool_initialize(pool, mtx_name, pool_size, opts);
return pool; return pool;

View File

@ -708,7 +708,7 @@ witness_initialize(void *dummy __unused)
struct witness *w, *w1; struct witness *w, *w1;
int i; int i;
w_data = malloc( sizeof (struct witness) * WITNESS_COUNT, M_WITNESS, w_data = malloc(sizeof (struct witness) * WITNESS_COUNT, M_WITNESS,
M_NOWAIT | M_ZERO); M_NOWAIT | M_ZERO);
/* /*

View File

@ -664,7 +664,8 @@ sltstart(struct tty *tp)
register u_char *cp; register u_char *cp;
if (sc->bpfbuf == NULL) if (sc->bpfbuf == NULL)
sc->bpfbuf = malloc( SLTMAX + SLIP_HDRLEN, M_SL, M_NOWAIT); sc->bpfbuf = malloc(SLTMAX + SLIP_HDRLEN,
M_SL, M_NOWAIT);
if (sc->bpfbuf) { if (sc->bpfbuf) {
cp = sc->bpfbuf + SLIP_HDRLEN; cp = sc->bpfbuf + SLIP_HDRLEN;

View File

@ -377,7 +377,7 @@ ng_btsocket_l2cap_raw_input(void *context, int pending)
rt = (ng_btsocket_l2cap_rtentry_t *) rt = (ng_btsocket_l2cap_rtentry_t *)
NG_HOOK_PRIVATE(hook); NG_HOOK_PRIVATE(hook);
if (rt == NULL) { if (rt == NULL) {
rt = malloc( sizeof(*rt), rt = malloc(sizeof(*rt),
M_NETGRAPH_BTSOCKET_L2CAP_RAW, M_NETGRAPH_BTSOCKET_L2CAP_RAW,
M_NOWAIT|M_ZERO); M_NOWAIT|M_ZERO);
if (rt == NULL) if (rt == NULL)

View File

@ -331,7 +331,7 @@ ng_netflow_cache_init(priv_p priv)
uma_zone_set_max(priv->zone, CACHESIZE); uma_zone_set_max(priv->zone, CACHESIZE);
/* Allocate hash. */ /* Allocate hash. */
priv->hash = malloc( NBUCKETS * sizeof(struct flow_hash_entry), priv->hash = malloc(NBUCKETS * sizeof(struct flow_hash_entry),
M_NETFLOW_HASH, M_WAITOK | M_ZERO); M_NETFLOW_HASH, M_WAITOK | M_ZERO);
if (priv->hash == NULL) { if (priv->hash == NULL) {

View File

@ -190,10 +190,12 @@ nga_constructor(node_p node)
sc->cfg.accm = ~0; sc->cfg.accm = ~0;
sc->cfg.amru = NG_ASYNC_DEFAULT_MRU; sc->cfg.amru = NG_ASYNC_DEFAULT_MRU;
sc->cfg.smru = NG_ASYNC_DEFAULT_MRU; sc->cfg.smru = NG_ASYNC_DEFAULT_MRU;
sc->abuf = malloc( ASYNC_BUF_SIZE(sc->cfg.smru), M_NETGRAPH_ASYNC, M_NOWAIT); sc->abuf = malloc(ASYNC_BUF_SIZE(sc->cfg.smru),
M_NETGRAPH_ASYNC, M_NOWAIT);
if (sc->abuf == NULL) if (sc->abuf == NULL)
goto fail; goto fail;
sc->sbuf = malloc( SYNC_BUF_SIZE(sc->cfg.amru), M_NETGRAPH_ASYNC, M_NOWAIT); sc->sbuf = malloc(SYNC_BUF_SIZE(sc->cfg.amru),
M_NETGRAPH_ASYNC, M_NOWAIT);
if (sc->sbuf == NULL) { if (sc->sbuf == NULL) {
free(sc->abuf, M_NETGRAPH_ASYNC); free(sc->abuf, M_NETGRAPH_ASYNC);
fail: fail:

View File

@ -304,7 +304,8 @@ ng_bridge_constructor(node_p node)
ng_callout_init(&priv->timer); ng_callout_init(&priv->timer);
/* Allocate and initialize hash table, etc. */ /* Allocate and initialize hash table, etc. */
priv->tab = malloc( MIN_BUCKETS * sizeof(*priv->tab), M_NETGRAPH_BRIDGE, M_NOWAIT | M_ZERO); priv->tab = malloc(MIN_BUCKETS * sizeof(*priv->tab),
M_NETGRAPH_BRIDGE, M_NOWAIT | M_ZERO);
if (priv->tab == NULL) { if (priv->tab == NULL) {
free(priv, M_NETGRAPH_BRIDGE); free(priv, M_NETGRAPH_BRIDGE);
return (ENOMEM); return (ENOMEM);
@ -358,7 +359,8 @@ ng_bridge_newhook(node_p node, hook_p hook, const char *name)
return (EINVAL); return (EINVAL);
if (priv->links[linkNum] != NULL) if (priv->links[linkNum] != NULL)
return (EISCONN); return (EISCONN);
priv->links[linkNum] = malloc( sizeof(*priv->links[linkNum]), M_NETGRAPH_BRIDGE, M_NOWAIT|M_ZERO); priv->links[linkNum] = malloc(sizeof(*priv->links[linkNum]),
M_NETGRAPH_BRIDGE, M_NOWAIT|M_ZERO);
if (priv->links[linkNum] == NULL) if (priv->links[linkNum] == NULL)
return (ENOMEM); return (ENOMEM);
priv->links[linkNum]->hook = hook; priv->links[linkNum]->hook = hook;
@ -848,7 +850,7 @@ ng_bridge_put(priv_p priv, const u_char *addr, int linkNum)
#endif #endif
/* Allocate and initialize new hashtable entry */ /* Allocate and initialize new hashtable entry */
hent = malloc( sizeof(*hent), M_NETGRAPH_BRIDGE, M_NOWAIT); hent = malloc(sizeof(*hent), M_NETGRAPH_BRIDGE, M_NOWAIT);
if (hent == NULL) if (hent == NULL)
return (0); return (0);
bcopy(addr, hent->host.addr, ETHER_ADDR_LEN); bcopy(addr, hent->host.addr, ETHER_ADDR_LEN);
@ -892,7 +894,8 @@ ng_bridge_rehash(priv_p priv)
newMask = newNumBuckets - 1; newMask = newNumBuckets - 1;
/* Allocate and initialize new table */ /* Allocate and initialize new table */
newTab = malloc( newNumBuckets * sizeof(*newTab), M_NETGRAPH_BRIDGE, M_NOWAIT | M_ZERO); newTab = malloc(newNumBuckets * sizeof(*newTab),
M_NETGRAPH_BRIDGE, M_NOWAIT | M_ZERO);
if (newTab == NULL) if (newTab == NULL)
return; return;

View File

@ -403,7 +403,7 @@ ng_fec_addport(struct ng_fec_private *priv, char *iface)
} }
/* Allocate new list entry. */ /* Allocate new list entry. */
new = malloc( sizeof(struct ng_fec_portlist), M_NETGRAPH, M_NOWAIT); new = malloc(sizeof(struct ng_fec_portlist), M_NETGRAPH, M_NOWAIT);
if (new == NULL) if (new == NULL)
return(ENOMEM); return(ENOMEM);

View File

@ -428,7 +428,8 @@ ng_l2tp_newhook(node_p node, hook_p hook, const char *name)
return (EINVAL); return (EINVAL);
/* Create hook private structure */ /* Create hook private structure */
hpriv = malloc( sizeof(*hpriv), M_NETGRAPH_L2TP, M_NOWAIT | M_ZERO); hpriv = malloc(sizeof(*hpriv),
M_NETGRAPH_L2TP, M_NOWAIT | M_ZERO);
if (hpriv == NULL) if (hpriv == NULL)
return (ENOMEM); return (ENOMEM);
hpriv->conf.session_id = session_id; hpriv->conf.session_id = session_id;

View File

@ -295,7 +295,8 @@ ng_mppc_rcvmsg(node_p node, item_p item, hook_p lasthook)
d->history = NULL; d->history = NULL;
} }
if ((cfg->bits & MPPC_BIT) != 0) { if ((cfg->bits & MPPC_BIT) != 0) {
d->history = malloc( isComp ? MPPC_SizeOfCompressionHistory() : d->history = malloc(isComp ?
MPPC_SizeOfCompressionHistory() :
MPPC_SizeOfDecompressionHistory(), MPPC_SizeOfDecompressionHistory(),
M_NETGRAPH_MPPC, M_NOWAIT); M_NETGRAPH_MPPC, M_NOWAIT);
if (d->history == NULL) if (d->history == NULL)

View File

@ -817,7 +817,7 @@ inp_get_source_filters(struct inpcb *inp, struct sockopt *sopt)
* has asked for, but we always tell userland how big the * has asked for, but we always tell userland how big the
* buffer really needs to be. * buffer really needs to be.
*/ */
tss = malloc( sizeof(struct sockaddr_storage) * msfr.msfr_nsrcs, tss = malloc(sizeof(struct sockaddr_storage) * msfr.msfr_nsrcs,
M_TEMP, M_NOWAIT); M_TEMP, M_NOWAIT);
if (tss == NULL) { if (tss == NULL) {
error = ENOBUFS; error = ENOBUFS;
@ -1569,7 +1569,7 @@ inp_set_source_filters(struct inpcb *inp, struct sockopt *sopt)
* that we may copy them with a single copyin. This * that we may copy them with a single copyin. This
* allows us to deal with page faults up-front. * allows us to deal with page faults up-front.
*/ */
kss = malloc( sizeof(struct sockaddr_storage) * msfr.msfr_nsrcs, kss = malloc(sizeof(struct sockaddr_storage) * msfr.msfr_nsrcs,
M_TEMP, M_WAITOK); M_TEMP, M_WAITOK);
error = copyin(msfr.msfr_srcs, kss, error = copyin(msfr.msfr_srcs, kss,
sizeof(struct sockaddr_storage) * msfr.msfr_nsrcs); sizeof(struct sockaddr_storage) * msfr.msfr_nsrcs);
@ -1623,7 +1623,7 @@ inp_set_source_filters(struct inpcb *inp, struct sockopt *sopt)
* entries we are about to allocate, in case we * entries we are about to allocate, in case we
* abruptly need to free them. * abruptly need to free them.
*/ */
pnims = malloc( sizeof(struct in_msource *) * msfr.msfr_nsrcs, pnims = malloc(sizeof(struct in_msource *) * msfr.msfr_nsrcs,
M_TEMP, M_WAITOK | M_ZERO); M_TEMP, M_WAITOK | M_ZERO);
/* /*
@ -1634,8 +1634,8 @@ inp_set_source_filters(struct inpcb *inp, struct sockopt *sopt)
pkss = kss; pkss = kss;
nims = NULL; nims = NULL;
for (i = 0; i < msfr.msfr_nsrcs; i++, pkss++) { for (i = 0; i < msfr.msfr_nsrcs; i++, pkss++) {
nims = malloc( sizeof(struct in_msource) * msfr.msfr_nsrcs, nims = malloc(sizeof(struct in_msource) *
M_IPMSOURCE, M_WAITOK | M_ZERO); msfr.msfr_nsrcs, M_IPMSOURCE, M_WAITOK | M_ZERO);
pnims[i] = nims; pnims[i] = nims;
} }
if (i < msfr.msfr_nsrcs) { if (i < msfr.msfr_nsrcs) {

View File

@ -247,8 +247,8 @@ syncache_init(void)
&V_tcp_syncache.cache_limit); &V_tcp_syncache.cache_limit);
/* Allocate the hash table. */ /* Allocate the hash table. */
V_tcp_syncache.hashbase = malloc( V_tcp_syncache.hashsize * sizeof(struct syncache_head), V_tcp_syncache.hashbase = malloc(V_tcp_syncache.hashsize *
M_SYNCACHE, M_WAITOK | M_ZERO); sizeof(struct syncache_head), M_SYNCACHE, M_WAITOK | M_ZERO);
/* Initialize the hash buckets. */ /* Initialize the hash buckets. */
for (i = 0; i < V_tcp_syncache.hashsize; i++) { for (i = 0; i < V_tcp_syncache.hashsize; i++) {

View File

@ -565,7 +565,7 @@ rip6_attach(struct socket *so, int proto, struct thread *td)
error = soreserve(so, rip_sendspace, rip_recvspace); error = soreserve(so, rip_sendspace, rip_recvspace);
if (error) if (error)
return (error); return (error);
filter = malloc( sizeof(struct icmp6_filter), M_PCB, M_NOWAIT); filter = malloc(sizeof(struct icmp6_filter), M_PCB, M_NOWAIT);
if (filter == NULL) if (filter == NULL)
return (ENOMEM); return (ENOMEM);
INP_INFO_WLOCK(&V_ripcbinfo); INP_INFO_WLOCK(&V_ripcbinfo);

View File

@ -2235,8 +2235,7 @@ nfs4_sillyrename(struct vnode *dvp, struct vnode *vp, struct componentname *cnp)
if (vp->v_type == VDIR) if (vp->v_type == VDIR)
panic("nfs: sillyrename dir"); panic("nfs: sillyrename dir");
#endif #endif
sp = malloc(sizeof (struct sillyrename), sp = malloc(sizeof (struct sillyrename), M_NFSREQ, M_WAITOK);
M_NFSREQ, M_WAITOK);
sp->s_cred = crhold(cnp->cn_cred); sp->s_cred = crhold(cnp->cn_cred);
sp->s_dvp = dvp; sp->s_dvp = dvp;
sp->s_removeit = nfs4_removeit; sp->s_removeit = nfs4_removeit;
@ -2352,7 +2351,7 @@ nfs4_lookitup(struct vnode *dvp, const char *name, int len, struct ucred *cred,
np->n_namelen = len; np->n_namelen = len;
if (np->n_name != NULL) if (np->n_name != NULL)
free(np->n_name, M_NFSREQ); free(np->n_name, M_NFSREQ);
np->n_name = malloc( np->n_namelen + 1, M_NFSREQ, M_WAITOK); np->n_name = malloc(np->n_namelen + 1, M_NFSREQ, M_WAITOK);
memcpy(np->n_name, name, len); memcpy(np->n_name, name, len);
np->n_name[len] = '\0'; np->n_name[len] = '\0';
} }

View File

@ -281,7 +281,8 @@ nfs_dolock(struct vop_advlock_args *ap)
* if there is no nfsowner table yet, allocate one. * if there is no nfsowner table yet, allocate one.
*/ */
if (p->p_nlminfo == NULL) { if (p->p_nlminfo == NULL) {
p->p_nlminfo = malloc( sizeof(struct nlminfo), M_NLMINFO, M_WAITOK | M_ZERO); p->p_nlminfo = malloc(sizeof(struct nlminfo),
M_NLMINFO, M_WAITOK | M_ZERO);
p->p_nlminfo->pid_start = p->p_stats->p_start; p->p_nlminfo->pid_start = p->p_stats->p_start;
timevaladd(&p->p_nlminfo->pid_start, &boottime); timevaladd(&p->p_nlminfo->pid_start, &boottime);
} }

View File

@ -267,7 +267,8 @@ cryptof_ioctl(
goto bail; goto bail;
} }
crie.cri_key = malloc( crie.cri_klen / 8, M_XDATA, M_WAITOK); crie.cri_key = malloc(crie.cri_klen / 8,
M_XDATA, M_WAITOK);
if ((error = copyin(sop->key, crie.cri_key, if ((error = copyin(sop->key, crie.cri_key,
crie.cri_klen / 8))) crie.cri_klen / 8)))
goto bail; goto bail;
@ -284,7 +285,8 @@ cryptof_ioctl(
} }
if (cria.cri_klen) { if (cria.cri_klen) {
cria.cri_key = malloc( cria.cri_klen / 8, M_XDATA, M_WAITOK); cria.cri_key = malloc(cria.cri_klen / 8,
M_XDATA, M_WAITOK);
if ((error = copyin(sop->mackey, cria.cri_key, if ((error = copyin(sop->mackey, cria.cri_key,
cria.cri_klen / 8))) cria.cri_klen / 8)))
goto bail; goto bail;
@ -776,11 +778,9 @@ csecreate(struct fcrypt *fcr, u_int64_t sid, caddr_t key, u_int64_t keylen,
#ifdef INVARIANTS #ifdef INVARIANTS
/* NB: required when mtx_init is built with INVARIANTS */ /* NB: required when mtx_init is built with INVARIANTS */
cse = malloc(sizeof(struct csession), cse = malloc(sizeof(struct csession), M_XDATA, M_NOWAIT | M_ZERO);
M_XDATA, M_NOWAIT | M_ZERO);
#else #else
cse = malloc(sizeof(struct csession), cse = malloc(sizeof(struct csession), M_XDATA, M_NOWAIT);
M_XDATA, M_NOWAIT);
#endif #endif
if (cse == NULL) if (cse == NULL)
return NULL; return NULL;
@ -840,7 +840,7 @@ cryptoioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread
switch (cmd) { switch (cmd) {
case CRIOGET: case CRIOGET:
fcr = malloc( sizeof(struct fcrypt), M_XDATA, M_WAITOK); fcr = malloc(sizeof(struct fcrypt), M_XDATA, M_WAITOK);
TAILQ_INIT(&fcr->csessions); TAILQ_INIT(&fcr->csessions);
fcr->sesn = 0; fcr->sesn = 0;

View File

@ -152,7 +152,8 @@ sysctl_rule(SYSCTL_HANDLER_ARGS)
error = SYSCTL_IN(req, &temprule, sizeof(temprule)); error = SYSCTL_IN(req, &temprule, sizeof(temprule));
if (error) if (error)
return (error); return (error);
ruleptr = malloc( sizeof(*ruleptr), M_MACBSDEXTENDED, M_WAITOK | M_ZERO); ruleptr = malloc(sizeof(*ruleptr), M_MACBSDEXTENDED,
M_WAITOK | M_ZERO);
} }
mtx_lock(&ugidfw_mtx); mtx_lock(&ugidfw_mtx);

View File

@ -3920,7 +3920,8 @@ initiate_write_inodeblock_ufs1(inodedep, bp)
if (inodedep->id_savedino1 != NULL) if (inodedep->id_savedino1 != NULL)
panic("initiate_write_inodeblock_ufs1: I/O underway"); panic("initiate_write_inodeblock_ufs1: I/O underway");
FREE_LOCK(&lk); FREE_LOCK(&lk);
sip = malloc( sizeof(struct ufs1_dinode), M_SAVEDINO, M_SOFTDEP_FLAGS); sip = malloc(sizeof(struct ufs1_dinode),
M_SAVEDINO, M_SOFTDEP_FLAGS);
ACQUIRE_LOCK(&lk); ACQUIRE_LOCK(&lk);
inodedep->id_savedino1 = sip; inodedep->id_savedino1 = sip;
*inodedep->id_savedino1 = *dp; *inodedep->id_savedino1 = *dp;
@ -4065,7 +4066,8 @@ initiate_write_inodeblock_ufs2(inodedep, bp)
if (inodedep->id_savedino2 != NULL) if (inodedep->id_savedino2 != NULL)
panic("initiate_write_inodeblock_ufs2: I/O underway"); panic("initiate_write_inodeblock_ufs2: I/O underway");
FREE_LOCK(&lk); FREE_LOCK(&lk);
sip = malloc( sizeof(struct ufs2_dinode), M_SAVEDINO, M_SOFTDEP_FLAGS); sip = malloc(sizeof(struct ufs2_dinode),
M_SAVEDINO, M_SOFTDEP_FLAGS);
ACQUIRE_LOCK(&lk); ACQUIRE_LOCK(&lk);
inodedep->id_savedino2 = sip; inodedep->id_savedino2 = sip;
*inodedep->id_savedino2 = *dp; *inodedep->id_savedino2 = *dp;

View File

@ -588,7 +588,8 @@ ufs_extattr_enable(struct ufsmount *ump, int attrnamespace,
if (backing_vnode->v_type != VREG) if (backing_vnode->v_type != VREG)
return (EINVAL); return (EINVAL);
attribute = malloc( sizeof(struct ufs_extattr_list_entry), M_UFS_EXTATTR, M_WAITOK); attribute = malloc(sizeof(struct ufs_extattr_list_entry),
M_UFS_EXTATTR, M_WAITOK);
if (attribute == NULL) if (attribute == NULL)
return (ENOMEM); return (ENOMEM);