From: stefan Date: Mon, 11 Jul 2016 08:38:49 +0000 (+0000) Subject: Make sure variables are used initialized in amap_wiperange X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=14f3bdb35266e21ec294db521edd215e1f8a43e8;p=openbsd Make sure variables are used initialized in amap_wiperange Uninitialized variables used in an if/else could cause a slower codepath to be taken, but the end effect of both paths is the same. Found by jsg@ --- diff --git a/sys/uvm/uvm_amap.c b/sys/uvm/uvm_amap.c index f282277ac69..c6994212886 100644 --- a/sys/uvm/uvm_amap.c +++ b/sys/uvm/uvm_amap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_amap.c,v 1.73 2016/07/09 17:13:05 stefan Exp $ */ +/* $OpenBSD: uvm_amap.c,v 1.74 2016/07/11 08:38:49 stefan Exp $ */ /* $NetBSD: uvm_amap.c,v 1.27 2000/11/25 06:27:59 chs Exp $ */ /* @@ -895,6 +895,9 @@ amap_wiperange(struct vm_amap *amap, int slotoff, int slots) int bucket, startbucket, endbucket; struct vm_amap_chunk *chunk, *nchunk; + startbucket = UVM_AMAP_BUCKET(amap, slotoff); + endbucket = UVM_AMAP_BUCKET(amap, slotoff + slots - 1); + /* * we can either traverse the amap by am_chunks or by am_buckets * depending on which is cheaper. decide now. @@ -913,9 +916,6 @@ amap_wiperange(struct vm_amap *amap, int slotoff, int slots) amap_chunk_free(amap, chunk); } } else { - startbucket = UVM_AMAP_BUCKET(amap, slotoff); - endbucket = UVM_AMAP_BUCKET(amap, slotoff + slots - 1); - for (bucket = startbucket; bucket <= endbucket; bucket++) { for (chunk = amap->am_buckets[bucket]; chunk != NULL; chunk = nchunk) {