Convert various "if (x) panic()" idioms into "KASSERT(!x)". The panic message isn't helping for such sanity checks and this help reducing the diff with NetBSD.
ok? Index: uvm/uvm_amap.c =================================================================== RCS file: /cvs/src/sys/uvm/uvm_amap.c,v retrieving revision 1.83 diff -u -p -r1.83 uvm_amap.c --- uvm/uvm_amap.c 22 Sep 2020 14:31:08 -0000 1.83 +++ uvm/uvm_amap.c 24 Sep 2020 09:47:54 -0000 @@ -1019,9 +1019,7 @@ amap_lookup(struct vm_aref *aref, vaddr_ 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 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, vadd 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 o 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 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);