summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2014-11-15 00:03:12 +0000
committertedu <tedu@openbsd.org>2014-11-15 00:03:12 +0000
commit03f59418eced6fb3772abdf5168e0025319565a9 (patch)
treec3cd613304053febae1d331846dbb4f7db17cc2b
parentprefer sizeof(*ptr) to sizeof(struct) for malloc and free (diff)
downloadwireguard-openbsd-03f59418eced6fb3772abdf5168e0025319565a9.tar.xz
wireguard-openbsd-03f59418eced6fb3772abdf5168e0025319565a9.zip
add sizes for free(ptr, sizeof(*ptr)). use sizeof(*ptr) for malloc sizes.
-rw-r--r--sys/nfs/nfs_kq.c6
-rw-r--r--sys/nfs/nfs_node.c4
-rw-r--r--sys/nfs/nfs_syscalls.c12
-rw-r--r--sys/nfs/nfs_vfsops.c8
4 files changed, 15 insertions, 15 deletions
diff --git a/sys/nfs/nfs_kq.c b/sys/nfs/nfs_kq.c
index 00cc0f9e51f..b6b227c52a7 100644
--- a/sys/nfs/nfs_kq.c
+++ b/sys/nfs/nfs_kq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_kq.c,v 1.21 2014/08/06 19:31:30 guenther Exp $ */
+/* $OpenBSD: nfs_kq.c,v 1.22 2014/11/15 00:03:12 tedu Exp $ */
/* $NetBSD: nfs_kq.c,v 1.7 2003/10/30 01:43:10 simonb Exp $ */
/*-
@@ -203,7 +203,7 @@ filt_nfsdetach(struct knote *kn)
} else {
/* last user, g/c */
SLIST_REMOVE(&kevlist, ke, kevq, kev_link);
- free(ke, M_KEVENT, 0);
+ free(ke, M_KEVENT, sizeof(*ke));
}
break;
}
@@ -317,7 +317,7 @@ nfs_kqfilter(void *v)
ke->usecount++;
} else {
/* need a new one */
- ke = malloc(sizeof(struct kevq), M_KEVENT, M_WAITOK);
+ ke = malloc(sizeof(*ke), M_KEVENT, M_WAITOK);
ke->vp = vp;
ke->usecount = 1;
ke->flags = 0;
diff --git a/sys/nfs/nfs_node.c b/sys/nfs/nfs_node.c
index 3523a1e59f1..b5610761f51 100644
--- a/sys/nfs/nfs_node.c
+++ b/sys/nfs/nfs_node.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_node.c,v 1.57 2014/09/14 14:17:26 jsg Exp $ */
+/* $OpenBSD: nfs_node.c,v 1.58 2014/11/15 00:03:12 tedu Exp $ */
/* $NetBSD: nfs_node.c,v 1.16 1996/02/18 11:53:42 fvdl Exp $ */
/*
@@ -199,7 +199,7 @@ nfs_inactive(void *v)
nfs_removeit(sp);
crfree(sp->s_cred);
vrele(sp->s_dvp);
- free(sp, M_NFSREQ, 0);
+ free(sp, M_NFSREQ, sizeof(*sp));
}
np->n_flag &= (NMODIFIED | NFLUSHINPROG | NFLUSHWANT);
diff --git a/sys/nfs/nfs_syscalls.c b/sys/nfs/nfs_syscalls.c
index 84c3216f535..da84ada82ae 100644
--- a/sys/nfs/nfs_syscalls.c
+++ b/sys/nfs/nfs_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_syscalls.c,v 1.97 2014/07/12 18:43:52 tedu Exp $ */
+/* $OpenBSD: nfs_syscalls.c,v 1.98 2014/11/15 00:03:12 tedu Exp $ */
/* $NetBSD: nfs_syscalls.c,v 1.19 1996/02/18 11:53:52 fvdl Exp $ */
/*
@@ -271,7 +271,7 @@ nfssvc_addsock(struct file *fp, struct mbuf *mynam)
if (tslp)
slp = tslp;
else {
- slp = malloc(sizeof(struct nfssvc_sock), M_NFSSVC,
+ slp = malloc(sizeof(*slp), M_NFSSVC,
M_WAITOK|M_ZERO);
TAILQ_INSERT_TAIL(&nfssvc_sockhead, slp, ns_chain);
}
@@ -456,7 +456,7 @@ loop:
done:
TAILQ_REMOVE(&nfsd_head, nfsd, nfsd_chain);
splx(s);
- free((caddr_t)nfsd, M_NFSD, 0);
+ free(nfsd, M_NFSD, sizeof(*nfsd));
if (--nfs_numnfsd == 0)
nfsrv_init(1); /* Reinitialize everything */
return (error);
@@ -506,7 +506,7 @@ nfsrv_slpderef(struct nfssvc_sock *slp)
{
if (--(slp->ns_sref) == 0 && (slp->ns_flag & SLP_VALID) == 0) {
TAILQ_REMOVE(&nfssvc_sockhead, slp, ns_chain);
- free((caddr_t)slp, M_NFSSVC, 0);
+ free(slp, M_NFSSVC, sizeof(*slp));
}
}
@@ -530,7 +530,7 @@ nfsrv_init(int terminating)
if (slp->ns_flag & SLP_VALID)
nfsrv_zapsock(slp);
TAILQ_REMOVE(&nfssvc_sockhead, slp, ns_chain);
- free((caddr_t)slp, M_NFSSVC, 0);
+ free(slp, M_NFSSVC, sizeof(*slp));
}
nfsrv_cleancache(); /* And clear out server cache */
}
@@ -545,7 +545,7 @@ nfsrv_init(int terminating)
TAILQ_INIT(&nfsd_head);
nfsd_head_flag &= ~NFSD_CHECKSLP;
- nfs_udpsock = malloc(sizeof(struct nfssvc_sock), M_NFSSVC,
+ nfs_udpsock = malloc(sizeof(*nfs_udpsock), M_NFSSVC,
M_WAITOK|M_ZERO);
TAILQ_INSERT_HEAD(&nfssvc_sockhead, nfs_udpsock, ns_chain);
diff --git a/sys/nfs/nfs_vfsops.c b/sys/nfs/nfs_vfsops.c
index 84ff1381d05..2949fcbf25e 100644
--- a/sys/nfs/nfs_vfsops.c
+++ b/sys/nfs/nfs_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_vfsops.c,v 1.102 2014/11/14 23:01:44 tedu Exp $ */
+/* $OpenBSD: nfs_vfsops.c,v 1.103 2014/11/15 00:03:12 tedu Exp $ */
/* $NetBSD: nfs_vfsops.c,v 1.46.4.1 1996/05/25 22:40:35 fvdl Exp $ */
/*
@@ -622,7 +622,7 @@ mountnfs(struct nfs_args *argp, struct mount *mp, struct mbuf *nam,
m_freem(nam);
return (0);
} else {
- nmp = malloc(sizeof(struct nfsmount), M_NFSMNT,
+ nmp = malloc(sizeof(*nmp), M_NFSMNT,
M_WAITOK|M_ZERO);
mp->mnt_data = (qaddr_t)nmp;
}
@@ -677,7 +677,7 @@ mountnfs(struct nfs_args *argp, struct mount *mp, struct mbuf *nam,
return (0);
bad:
nfs_disconnect(nmp);
- free((caddr_t)nmp, M_NFSMNT, 0);
+ free(nmp, M_NFSMNT, sizeof(*nmp));
m_freem(nam);
return (error);
}
@@ -702,7 +702,7 @@ nfs_unmount(struct mount *mp, int mntflags, struct proc *p)
nfs_disconnect(nmp);
m_freem(nmp->nm_nam);
timeout_del(&nmp->nm_rtimeout);
- free(nmp, M_NFSMNT, 0);
+ free(nmp, M_NFSMNT, sizeof(*nmp));
return (0);
}