summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2020-09-25 08:04:48 +0000
committermpi <mpi@openbsd.org>2020-09-25 08:04:48 +0000
commite74923656e6791af0d64e03f73bb2c57d47e3065 (patch)
tree5ecc1075ed4248192e4db910aa7a7e9fafce28f6
parentAdd missing call to uvm_grow(9). (diff)
downloadwireguard-openbsd-e74923656e6791af0d64e03f73bb2c57d47e3065.tar.xz
wireguard-openbsd-e74923656e6791af0d64e03f73bb2c57d47e3065.zip
Use KASSERT() instead of if(x) panic() for sanity checks.
Reduce the diff with NetBSD. ok kettenis@, deraadt@
-rw-r--r--sys/uvm/uvm_amap.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/sys/uvm/uvm_amap.c b/sys/uvm/uvm_amap.c
index c3f56621473..310e5e8446f 100644
--- a/sys/uvm/uvm_amap.c
+++ b/sys/uvm/uvm_amap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_amap.c,v 1.83 2020/09/22 14:31:08 mpi Exp $ */
+/* $OpenBSD: uvm_amap.c,v 1.84 2020/09/25 08:04:48 mpi Exp $ */
/* $NetBSD: uvm_amap.c,v 1.27 2000/11/25 06:27:59 chs Exp $ */
/*
@@ -1019,9 +1019,7 @@ amap_lookup(struct vm_aref *aref, vaddr_t offset)
AMAP_B2SLOT(slot, offset);
slot += aref->ar_pageoff;
-
- if (slot >= amap->am_nslot)
- panic("amap_lookup: offset out of range");
+ KASSERT(slot < amap->am_nslot);
chunk = amap_chunk_get(amap, slot, 0, PR_NOWAIT);
if (chunk == NULL)
@@ -1046,8 +1044,7 @@ amap_lookups(struct vm_aref *aref, vaddr_t offset,
AMAP_B2SLOT(slot, offset);
slot += aref->ar_pageoff;
- if ((slot + (npages - 1)) >= amap->am_nslot)
- panic("amap_lookups: offset out of range");
+ KASSERT((slot + (npages - 1)) < amap->am_nslot);
for (i = 0, lcv = slot; lcv < slot + npages; i += n, lcv += n) {
n = UVM_AMAP_CHUNK - UVM_AMAP_SLOTIDX(lcv);
@@ -1078,9 +1075,7 @@ amap_populate(struct vm_aref *aref, vaddr_t offset)
AMAP_B2SLOT(slot, offset);
slot += aref->ar_pageoff;
-
- if (slot >= amap->am_nslot)
- panic("amap_populate: offset out of range");
+ KASSERT(slot < amap->am_nslot);
chunk = amap_chunk_get(amap, slot, 1, PR_WAITOK);
KASSERT(chunk != NULL);
@@ -1101,9 +1096,8 @@ amap_add(struct vm_aref *aref, vaddr_t offset, struct vm_anon *anon,
AMAP_B2SLOT(slot, offset);
slot += aref->ar_pageoff;
+ KASSERT(slot < amap->am_nslot);
- if (slot >= amap->am_nslot)
- panic("amap_add: offset out of range");
chunk = amap_chunk_get(amap, slot, 1, PR_NOWAIT);
if (chunk == NULL)
return 1;
@@ -1144,9 +1138,7 @@ amap_unadd(struct vm_aref *aref, vaddr_t offset)
AMAP_B2SLOT(slot, offset);
slot += aref->ar_pageoff;
-
- if (slot >= amap->am_nslot)
- panic("amap_unadd: offset out of range");
+ KASSERT(slot < amap->am_nslot);
chunk = amap_chunk_get(amap, slot, 0, PR_NOWAIT);
if (chunk == NULL)
panic("amap_unadd: chunk for slot %d not present", slot);