nfs: Remove NFSSOCKADDRALLOC, NFSSOCKADDRFREE macros
They were just thin wrappers over malloc(9) w/ M_ZERO and free(9). Discussed with: rmacklem, markj Sponsored by: Dell EMC Isilon
This commit is contained in:
parent
222daa421f
commit
b97b91b547
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=328418
@ -3067,7 +3067,7 @@ nfsrv_nfsuserdport(struct sockaddr *sad, u_short port, NFSPROC_T *p)
|
||||
if (nfsrv_nfsuserd) {
|
||||
NFSUNLOCKNAMEID();
|
||||
error = EPERM;
|
||||
NFSSOCKADDRFREE(sad);
|
||||
free(sad, M_SONAME);
|
||||
goto out;
|
||||
}
|
||||
nfsrv_nfsuserd = 1;
|
||||
@ -3088,7 +3088,8 @@ nfsrv_nfsuserdport(struct sockaddr *sad, u_short port, NFSPROC_T *p)
|
||||
/* Use the port# for a UDP socket (old nfsuserd). */
|
||||
rp->nr_sotype = SOCK_DGRAM;
|
||||
rp->nr_soproto = IPPROTO_UDP;
|
||||
NFSSOCKADDRALLOC(rp->nr_nam);
|
||||
rp->nr_nam = malloc(sizeof(*rp->nr_nam), M_SONAME, M_WAITOK |
|
||||
M_ZERO);
|
||||
NFSSOCKADDRSIZE(rp->nr_nam, sizeof (struct sockaddr_in));
|
||||
ad = NFSSOCKADDR(rp->nr_nam, struct sockaddr_in *);
|
||||
ad->sin_family = AF_INET;
|
||||
@ -3099,7 +3100,7 @@ nfsrv_nfsuserdport(struct sockaddr *sad, u_short port, NFSPROC_T *p)
|
||||
rp->nr_vers = RPCNFSUSERD_VERS;
|
||||
error = newnfs_connect(NULL, rp, NFSPROCCRED(p), p, 0);
|
||||
if (error) {
|
||||
NFSSOCKADDRFREE(rp->nr_nam);
|
||||
free(rp->nr_nam, M_SONAME);
|
||||
nfsrv_nfsuserd = 0;
|
||||
}
|
||||
out:
|
||||
@ -3122,7 +3123,7 @@ nfsrv_nfsuserddelport(void)
|
||||
nfsrv_nfsuserd = 0;
|
||||
NFSUNLOCKNAMEID();
|
||||
newnfs_disconnect(&nfsrv_nfsuserdsock);
|
||||
NFSSOCKADDRFREE(nfsrv_nfsuserdsock.nr_nam);
|
||||
free(nfsrv_nfsuserdsock.nr_nam, M_SONAME);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -628,18 +628,7 @@ void nfsrvd_rcv(struct socket *, void *, int);
|
||||
* mbufs any more.)
|
||||
*/
|
||||
#define NFSSOCKADDR(a, t) ((t)(a))
|
||||
#define NFSSOCKADDRALLOC(a) \
|
||||
do { \
|
||||
(a) = malloc(sizeof (struct sockaddr), \
|
||||
M_SONAME, M_WAITOK); \
|
||||
NFSBZERO((a), sizeof (struct sockaddr)); \
|
||||
} while (0)
|
||||
#define NFSSOCKADDRSIZE(a, s) ((a)->sa_len = (s))
|
||||
#define NFSSOCKADDRFREE(a) \
|
||||
do { \
|
||||
if (a) \
|
||||
free((a), M_SONAME); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* These should be defined as a process or thread structure, as required
|
||||
|
@ -3477,7 +3477,8 @@ nfsrvd_setclientid(struct nfsrv_descript *nd, __unused int isdgram,
|
||||
clp->lc_stateid = malloc(sizeof(struct nfsstatehead) *
|
||||
nfsrv_statehashsize, M_NFSDCLIENT, M_WAITOK);
|
||||
NFSINITSOCKMUTEX(&clp->lc_req.nr_mtx);
|
||||
NFSSOCKADDRALLOC(clp->lc_req.nr_nam);
|
||||
clp->lc_req.nr_nam = malloc(sizeof(*clp->lc_req.nr_nam), M_SONAME,
|
||||
M_WAITOK | M_ZERO);
|
||||
NFSSOCKADDRSIZE(clp->lc_req.nr_nam, sizeof (struct sockaddr_in));
|
||||
clp->lc_req.nr_cred = NULL;
|
||||
NFSBCOPY(verf, clp->lc_verf, NFSX_VERF);
|
||||
@ -3533,7 +3534,7 @@ nfsrvd_setclientid(struct nfsrv_descript *nd, __unused int isdgram,
|
||||
(void) nfsm_strtom(nd, addrbuf, strlen(addrbuf));
|
||||
}
|
||||
if (clp) {
|
||||
NFSSOCKADDRFREE(clp->lc_req.nr_nam);
|
||||
free(clp->lc_req.nr_nam, M_SONAME);
|
||||
NFSFREEMUTEX(&clp->lc_req.nr_mtx);
|
||||
free(clp->lc_stateid, M_NFSDCLIENT);
|
||||
free(clp, M_NFSDCLIENT);
|
||||
@ -3551,7 +3552,7 @@ nfsrvd_setclientid(struct nfsrv_descript *nd, __unused int isdgram,
|
||||
return (0);
|
||||
nfsmout:
|
||||
if (clp) {
|
||||
NFSSOCKADDRFREE(clp->lc_req.nr_nam);
|
||||
free(clp->lc_req.nr_nam, M_SONAME);
|
||||
NFSFREEMUTEX(&clp->lc_req.nr_mtx);
|
||||
free(clp->lc_stateid, M_NFSDCLIENT);
|
||||
free(clp, M_NFSDCLIENT);
|
||||
@ -3753,7 +3754,8 @@ nfsrvd_exchangeid(struct nfsrv_descript *nd, __unused int isdgram,
|
||||
clp->lc_stateid = malloc(sizeof(struct nfsstatehead) *
|
||||
nfsrv_statehashsize, M_NFSDCLIENT, M_WAITOK);
|
||||
NFSINITSOCKMUTEX(&clp->lc_req.nr_mtx);
|
||||
NFSSOCKADDRALLOC(clp->lc_req.nr_nam);
|
||||
clp->lc_req.nr_nam = malloc(sizeof(*clp->lc_req.nr_nam), M_SONAME,
|
||||
M_WAITOK | M_ZERO);
|
||||
NFSSOCKADDRSIZE(clp->lc_req.nr_nam, sizeof (struct sockaddr_in));
|
||||
sad = NFSSOCKADDR(nd->nd_nam, struct sockaddr_in *);
|
||||
rad = NFSSOCKADDR(clp->lc_req.nr_nam, struct sockaddr_in *);
|
||||
@ -3813,7 +3815,7 @@ nfsrvd_exchangeid(struct nfsrv_descript *nd, __unused int isdgram,
|
||||
*/
|
||||
nd->nd_repstat = nfsrv_setclient(nd, &clp, &clientid, &confirm, p);
|
||||
if (clp != NULL) {
|
||||
NFSSOCKADDRFREE(clp->lc_req.nr_nam);
|
||||
free(clp->lc_req.nr_nam, M_SONAME);
|
||||
NFSFREEMUTEX(&clp->lc_req.nr_mtx);
|
||||
free(clp->lc_stateid, M_NFSDCLIENT);
|
||||
free(clp, M_NFSDCLIENT);
|
||||
@ -3846,7 +3848,7 @@ nfsrvd_exchangeid(struct nfsrv_descript *nd, __unused int isdgram,
|
||||
return (0);
|
||||
nfsmout:
|
||||
if (clp != NULL) {
|
||||
NFSSOCKADDRFREE(clp->lc_req.nr_nam);
|
||||
free(clp->lc_req.nr_nam, M_SONAME);
|
||||
NFSFREEMUTEX(&clp->lc_req.nr_mtx);
|
||||
free(clp->lc_stateid, M_NFSDCLIENT);
|
||||
free(clp, M_NFSDCLIENT);
|
||||
|
@ -1226,7 +1226,7 @@ nfsrv_zapclient(struct nfsclient *clp, NFSPROC_T *p)
|
||||
}
|
||||
#endif
|
||||
newnfs_disconnect(&clp->lc_req);
|
||||
NFSSOCKADDRFREE(clp->lc_req.nr_nam);
|
||||
free(clp->lc_req.nr_nam, M_SONAME);
|
||||
NFSFREEMUTEX(&clp->lc_req.nr_mtx);
|
||||
free(clp->lc_stateid, M_NFSDCLIENT);
|
||||
free(clp, M_NFSDCLIENT);
|
||||
|
Loading…
Reference in New Issue
Block a user