summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorniklas <niklas@openbsd.org>1999-01-11 01:29:17 +0000
committerniklas <niklas@openbsd.org>1999-01-11 01:29:17 +0000
commit055b6e76eb781517f91d8e2964d2963ddd5ff0d6 (patch)
tree9d5a31157d4d8ffc9e0d1b0c6c5d8d8630b0c40f /sys
parentAdhere better to DIAGNOSTIC and DDB options (diff)
downloadwireguard-openbsd-055b6e76eb781517f91d8e2964d2963ddd5ff0d6.tar.xz
wireguard-openbsd-055b6e76eb781517f91d8e2964d2963ddd5ff0d6.zip
Sanity panics into DIAGNOSTIC
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/subr_rmap.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/sys/kern/subr_rmap.c b/sys/kern/subr_rmap.c
index 0e7662246ed..c15f13c24c1 100644
--- a/sys/kern/subr_rmap.c
+++ b/sys/kern/subr_rmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_rmap.c,v 1.3 1996/04/21 22:27:23 deraadt Exp $ */
+/* $OpenBSD: subr_rmap.c,v 1.4 1999/01/11 01:29:17 niklas Exp $ */
/* $NetBSD: subr_rmap.c,v 1.11 1996/03/16 23:17:11 christos Exp $ */
/*
@@ -61,9 +61,12 @@ rminit(mp, size, addr, name, nelem)
{
struct mapent *ep;
+#ifdef DIAGNOSTIC
/* mapsize had better be at least 2 */
if (nelem < 2 || addr <= 0 || size < 0)
panic("rminit %s",name);
+#endif
+
mp->m_name = name;
mp->m_limit = (struct mapent *)mp + nelem;
@@ -90,9 +93,11 @@ rmalloc(mp, size)
long addr;
/* first check arguments */
+#ifdef DIAGNOSTIC
if (size < 0)
panic("rmalloc %s", mp->m_name);
- if (!size)
+#endif
+ if (size <= 0)
return 0;
fp = 0;
@@ -140,9 +145,11 @@ rmfree(mp, size, addr)
{
struct mapent *ep, *fp;
+#ifdef DIAGNOSTIC
/* first check arguments */
if (size <= 0 || addr <= 0)
panic("rmfree %s", mp->m_name);
+#endif
while (1) {
fp = 0;
@@ -158,8 +165,11 @@ rmfree(mp, size, addr)
if (ep < mp->m_limit
&& ep[1].m_addr
&& (addr += size) >= ep[1].m_addr) {
- if (addr > ep[1].m_addr) /* overlapping frees? */
+#ifdef DIAGNOSTIC
+ /* overlapping frees? */
+ if (addr > ep[1].m_addr)
panic("rmfree %s", mp->m_name);
+#endif
/* the next slot is now contiguous, so join ... */
ep->m_size += ep[1].m_size;
ovbcopy(ep + 2, ep + 1,