From fdfe9f6a2a27d10c4c94e29ee62c26061c9761a0 Mon Sep 17 00:00:00 2001 From: jdybnis Date: Wed, 26 Nov 2008 07:20:00 +0000 Subject: [PATCH 1/1] minor change --- struct/skiplist.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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; } -- 2.40.0