From 6fd2dd44d12bda46762c28cc112568cb8610c3f2 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 2 Feb 2010 13:43:58 -0800 Subject: [PATCH] --- yaml --- r: 180169 b: refs/heads/master c: 859ddf09743a8cc680af33f7259ccd0fd36bfe9d h: refs/heads/master i: 180167: f47ee85aa45e9c1b1e0b9ca8032da12b862a74ea v: v3 --- [refs] | 2 +- trunk/lib/idr.c | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index 8977b224a21e..8b89b739e887 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 1a45dcfe2525e9432cb4aba461d4994fc2befe42 +refs/heads/master: 859ddf09743a8cc680af33f7259ccd0fd36bfe9d diff --git a/trunk/lib/idr.c b/trunk/lib/idr.c index 1cac726c44bc..ba7d37cf7847 100644 --- a/trunk/lib/idr.c +++ b/trunk/lib/idr.c @@ -140,8 +140,7 @@ static int sub_alloc(struct idr *idp, int *starting_id, struct idr_layer **pa) id = *starting_id; restart: p = idp->top; - l = idp->layers; - pa[l--] = NULL; + l = p->layer; while (1) { /* * We run around this while until we reach the leaf node... @@ -155,8 +154,8 @@ static int sub_alloc(struct idr *idp, int *starting_id, struct idr_layer **pa) oid = id; id = (id | ((1 << (IDR_BITS * l)) - 1)) + 1; - /* if already at the top layer, we need to grow */ - if (!(p = pa[l])) { + /* did id go over the limit? */ + if (id >= (1 << (idp->layers * IDR_BITS))) { *starting_id = id; return IDR_NEED_TO_GROW; }