From 66f807ed8b3634dc73d9f7526c484e43f094c0ee Mon Sep 17 00:00:00 2001 From: des Date: Thu, 23 Oct 2008 15:53:51 +0000 Subject: Retire the MALLOC and FREE macros. They are an abomination unto style(9). MFC after: 3 months --- sys/nfs4client/nfs4_dev.c | 4 ++-- sys/nfs4client/nfs4_idmap.c | 36 ++++++++++++++++++------------------ sys/nfs4client/nfs4_socket.c | 2 +- sys/nfs4client/nfs4_vfsops.c | 6 +++--- sys/nfs4client/nfs4_vn_subs.c | 4 ++-- sys/nfs4client/nfs4_vnops.c | 17 ++++++++--------- 6 files changed, 34 insertions(+), 35 deletions(-) (limited to 'sys/nfs4client') diff --git a/sys/nfs4client/nfs4_dev.c b/sys/nfs4client/nfs4_dev.c index 35276d3..d8186e6 100644 --- a/sys/nfs4client/nfs4_dev.c +++ b/sys/nfs4client/nfs4_dev.c @@ -69,9 +69,9 @@ struct nfs4dev_upcall { }; -#define nfs4dev_upcall_get(MP) MALLOC((MP), struct nfs4dev_upcall *, sizeof(struct nfs4dev_upcall), M_NFS4DEV, M_WAITOK | M_ZERO) +#define nfs4dev_upcall_get(MP) (MP) = malloc(sizeof(struct nfs4dev_upcall), M_NFS4DEV, M_WAITOK | M_ZERO) -#define nfs4dev_upcall_put(MP) FREE((MP), M_NFS4DEV) +#define nfs4dev_upcall_put(MP) free((MP), M_NFS4DEV) static int nfs4dev_nopen = 0; static struct thread * nfs4dev_reader = NULL; diff --git a/sys/nfs4client/nfs4_idmap.c b/sys/nfs4client/nfs4_idmap.c index 000ad17..5a02b47 100644 --- a/sys/nfs4client/nfs4_idmap.c +++ b/sys/nfs4client/nfs4_idmap.c @@ -56,8 +56,8 @@ MALLOC_DEFINE(M_IDMAP, "idmap", "idmap"); -#define idmap_entry_get(ID) MALLOC((ID), struct idmap_entry, sizeof(struct idmap_entry), M_IDMAP, M_WAITOK | M_ZERO) -#define idmap_entry_put(ID) FREE((ID), M_IDMAP) +#define idmap_entry_get(ID) (ID) = malloc(sizeof(struct idmap_entry), M_IDMAP, M_WAITOK | M_ZERO) +#define idmap_entry_put(ID) free((ID), M_IDMAP) @@ -106,7 +106,7 @@ idmap_upcall_name(uint32_t type, char * name, struct idmap_entry ** found) return EFAULT; /* XXX */ } - MALLOC(e, struct idmap_entry *, sizeof(struct idmap_entry), M_IDMAP, + e = malloc(sizeof(struct idmap_entry), M_IDMAP, M_WAITOK | M_ZERO); e->id_info.id_type = type; @@ -144,7 +144,7 @@ idmap_upcall_id(uint32_t type, ident_t id, struct idmap_entry ** found) if (type > IDMAP_MAX_TYPE) panic("bad type"); /* XXX */ - MALLOC(e, struct idmap_entry *, sizeof(struct idmap_entry), M_IDMAP, + e = malloc(sizeof(struct idmap_entry), M_IDMAP, M_WAITOK | M_ZERO); e->id_info.id_type = type; @@ -340,14 +340,14 @@ void idmap_uninit(void) e = TAILQ_FIRST(&idmap_uid_hash.hash_name[i]); TAILQ_REMOVE(&idmap_uid_hash.hash_name[i], e, id_entry_name); TAILQ_REMOVE(&idmap_uid_hash.hash_id[i], e, id_entry_id); - FREE(e, M_IDMAP); + free(e, M_IDMAP); } while(!TAILQ_EMPTY(&idmap_gid_hash.hash_name[i])) { e = TAILQ_FIRST(&idmap_gid_hash.hash_name[i]); TAILQ_REMOVE(&idmap_gid_hash.hash_name[i], e, id_entry_name); TAILQ_REMOVE(&idmap_gid_hash.hash_id[i], e, id_entry_id); - FREE(e, M_IDMAP); + free(e, M_IDMAP); } } @@ -376,7 +376,7 @@ idmap_uid_to_name(uid_t uid, char ** name, size_t * len) if (idmap_add(e) != 0) { IDMAP_DEBUG("idmap_add failed\n"); - FREE(e, M_IDMAP); + free(e, M_IDMAP); return EFAULT; } } @@ -409,7 +409,7 @@ idmap_gid_to_name(gid_t gid, char ** name, size_t * len) if (idmap_add(e) != 0) { IDMAP_DEBUG("idmap_add failed\n"); - FREE(e, M_IDMAP); + free(e, M_IDMAP); } } @@ -434,31 +434,31 @@ idmap_name_to_uid(char * name, size_t len, uid_t * id) } /* XXX hack */ - MALLOC(namestr, char *, len + 1, M_TEMP, M_WAITOK); + namestr = malloc(len + 1, M_TEMP, M_WAITOK); bcopy(name, namestr, len); namestr[len] = '\0'; if ((e = idmap_name_lookup(IDMAP_TYPE_UID, namestr)) == NULL) { if ((error = idmap_upcall_name(IDMAP_TYPE_UID, namestr, &e))) { - FREE(namestr, M_TEMP); + free(namestr, M_TEMP); return error; } if (e == NULL) { IDMAP_DEBUG("no error from upcall, but no data returned\n"); - FREE(namestr, M_TEMP); + free(namestr, M_TEMP); return EFAULT; } if (idmap_add(e) != 0) { IDMAP_DEBUG("idmap_add failed\n"); - FREE(e, M_IDMAP); + free(e, M_IDMAP); } } *id = e->id_info.id_id.uid; - FREE(namestr, M_TEMP); + free(namestr, M_TEMP); return 0; } @@ -479,7 +479,7 @@ idmap_name_to_gid(char * name, size_t len, gid_t * id) } /* XXX hack */ - MALLOC(namestr, char *, len + 1, M_TEMP, M_WAITOK); + namestr = malloc(len + 1, M_TEMP, M_WAITOK); bcopy(name, namestr, len); namestr[len] = '\0'; @@ -487,23 +487,23 @@ idmap_name_to_gid(char * name, size_t len, gid_t * id) if ((e = idmap_name_lookup(IDMAP_TYPE_GID, namestr)) == NULL) { if ((error = idmap_upcall_name(IDMAP_TYPE_GID, namestr, &e)) != 0) { IDMAP_DEBUG("error in upcall\n"); - FREE(namestr, M_TEMP); + free(namestr, M_TEMP); return error; } if (e == NULL) { IDMAP_DEBUG("no error from upcall, but no data returned\n"); - FREE(namestr, M_TEMP); + free(namestr, M_TEMP); return EFAULT; } if (idmap_add(e) != 0) { IDMAP_DEBUG("idmap_add failed\n"); - FREE(e, M_IDMAP); + free(e, M_IDMAP); } } *id = e->id_info.id_id.gid; - FREE(namestr, M_TEMP); + free(namestr, M_TEMP); return 0; } diff --git a/sys/nfs4client/nfs4_socket.c b/sys/nfs4client/nfs4_socket.c index e5b2ab8..754ba47 100644 --- a/sys/nfs4client/nfs4_socket.c +++ b/sys/nfs4client/nfs4_socket.c @@ -180,7 +180,7 @@ nfs4_connect(struct nfsmount *nmp) struct thread * td = curthread; #endif - MALLOC(auth, struct rpc_auth *, sizeof(struct rpc_auth), M_TEMP, M_WAITOK); + auth = malloc(sizeof(struct rpc_auth), M_TEMP, M_WAITOK); auth->auth_type = RPCAUTH_UNIX; /* translate nfs flags -> rpcclnt flags */ diff --git a/sys/nfs4client/nfs4_vfsops.c b/sys/nfs4client/nfs4_vfsops.c index d7d853c..8980cef 100644 --- a/sys/nfs4client/nfs4_vfsops.c +++ b/sys/nfs4client/nfs4_vfsops.c @@ -555,7 +555,7 @@ mountnfs(struct nfs_args *argp, struct mount *mp, struct sockaddr *nam, if (mp->mnt_flag & MNT_UPDATE) { nmp = VFSTONFS(mp); /* update paths, file handles, etc, here XXX */ - FREE(nam, M_SONAME); + free(nam, M_SONAME); return (0); } else { nmp = uma_zalloc(nfsmount_zone, M_WAITOK); @@ -660,7 +660,7 @@ bad: mtx_destroy(&nmp->nm_mtx); nfs4_disconnect(nmp); uma_zfree(nfsmount_zone, nmp); - FREE(nam, M_SONAME); + free(nam, M_SONAME); return (error); } @@ -699,7 +699,7 @@ nfs4_unmount(struct mount *mp, int mntflags, struct thread *td) * We are now committed to the unmount. */ nfs4_disconnect(nmp); - FREE(nmp->nm_nam, M_SONAME); + free(nmp->nm_nam, M_SONAME); /* XXX there's a race condition here for SMP */ wakeup(&nfs4_daemonproc); diff --git a/sys/nfs4client/nfs4_vn_subs.c b/sys/nfs4client/nfs4_vn_subs.c index 317c7ff..12095d0 100644 --- a/sys/nfs4client/nfs4_vn_subs.c +++ b/sys/nfs4client/nfs4_vn_subs.c @@ -176,7 +176,7 @@ nfs4_getcookie(struct nfsnode *np, off_t off, int add) dp = LIST_FIRST(&np->n_cookies); if (!dp) { if (add) { - MALLOC(dp, struct nfsdmap *, sizeof (struct nfsdmap), + dp = malloc(sizeof (struct nfsdmap), M_NFSDIROFF, M_WAITOK); dp->ndm_eocookie = 0; LIST_INSERT_HEAD(&np->n_cookies, dp, ndm_list); @@ -191,7 +191,7 @@ nfs4_getcookie(struct nfsnode *np, off_t off, int add) return (NULL); dp = LIST_NEXT(dp, ndm_list); } else if (add) { - MALLOC(dp2, struct nfsdmap *, sizeof (struct nfsdmap), + dp2 = malloc(sizeof (struct nfsdmap), M_NFSDIROFF, M_WAITOK); dp2->ndm_eocookie = 0; LIST_INSERT_AFTER(dp, dp2, ndm_list); diff --git a/sys/nfs4client/nfs4_vnops.c b/sys/nfs4client/nfs4_vnops.c index 0f54077..db2b30a 100644 --- a/sys/nfs4client/nfs4_vnops.c +++ b/sys/nfs4client/nfs4_vnops.c @@ -506,8 +506,8 @@ nfs4_openrpc(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp, np->n_dvp = dvp; np->n_namelen = cnp->cn_namelen; /* XXX memory leaks on these; track! */ if (np->n_name != NULL) - FREE(np->n_name, M_NFSREQ); - MALLOC(np->n_name, u_char *, np->n_namelen + 1, M_NFSREQ, M_WAITOK); + free(np->n_name, M_NFSREQ); + np->n_name = malloc(np->n_namelen + 1, M_NFSREQ, M_WAITOK); bcopy(cnp->cn_nameptr, np->n_name, np->n_namelen); np->n_name[np->n_namelen] = '\0'; if (flags & FWRITE) @@ -1071,8 +1071,8 @@ nfs4_lookup(struct vop_lookup_args *ap) np->n_dvp = dvp; np->n_namelen = cnp->cn_namelen; if (np->n_name != NULL) - FREE(np->n_name, M_NFSREQ); - MALLOC(np->n_name, u_char *, np->n_namelen + 1, M_NFSREQ, M_WAITOK); + free(np->n_name, M_NFSREQ); + np->n_name = malloc(np->n_namelen + 1, M_NFSREQ, M_WAITOK); bcopy(cnp->cn_nameptr, np->n_name, np->n_namelen); np->n_name[np->n_namelen] = '\0'; @@ -1455,7 +1455,7 @@ nfs4_createrpc(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp, m_freem(mrep); /* XXX */ - /*FREE(cnp->cn_pnbuf, M_NAMEI);*/ + /*free(cnp->cn_pnbuf, M_NAMEI);*/ if (error != 0 && newvp != NULL) vput(newvp); else if (error == 0) @@ -2235,7 +2235,7 @@ nfs4_sillyrename(struct vnode *dvp, struct vnode *vp, struct componentname *cnp) if (vp->v_type == VDIR) panic("nfs: sillyrename dir"); #endif - MALLOC(sp, struct sillyrename *, sizeof (struct sillyrename), + sp = malloc(sizeof (struct sillyrename), M_NFSREQ, M_WAITOK); sp->s_cred = crhold(cnp->cn_cred); sp->s_dvp = dvp; @@ -2351,9 +2351,8 @@ nfs4_lookitup(struct vnode *dvp, const char *name, int len, struct ucred *cred, np->n_dvp = dvp; np->n_namelen = len; if (np->n_name != NULL) - FREE(np->n_name, M_NFSREQ); - MALLOC(np->n_name, u_char *, - np->n_namelen + 1, M_NFSREQ, M_WAITOK); + free(np->n_name, M_NFSREQ); + np->n_name = malloc( np->n_namelen + 1, M_NFSREQ, M_WAITOK); memcpy(np->n_name, name, len); np->n_name[len] = '\0'; } -- cgit v1.1