From: jdybnis Date: Wed, 26 Nov 2008 07:20:00 +0000 (+0000) Subject: minor change X-Git-Url: https://pd.if.org/git/?p=nbds;a=commitdiff_plain;h=fdfe9f6a2a27d10c4c94e29ee62c26061c9761a0 minor change --- diff --git a/struct/skiplist.c b/struct/skiplist.c index f7cdf33..aa283fb 100644 --- a/struct/skiplist.c +++ b/struct/skiplist.c @@ -40,13 +40,12 @@ struct sl { static int random_level (void) { unsigned r = nbd_rand(); - if (r&1) + if (r & 1) return 0; - int n = __builtin_ctz(r)-1; #if MAX_LEVEL < 31 - if (n > MAX_LEVEL) - return MAX_LEVEL; + r |= 1 << (MAX_LEVEL+1); #endif + int n = __builtin_ctz(r)-1; assert(n <= MAX_LEVEL); return n; }