From 4648c7948d85dbf650f819bc26d3e48f57a66a86 Mon Sep 17 00:00:00 2001
From: Konstantin Osipov <kostja@tarantool.org>
Date: Tue, 29 Jul 2014 20:09:43 +0400
Subject: [PATCH] gh-148: fix a failing small_alloc.test on 32 bit platforms.

---
 src/lib/small/small.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/lib/small/small.c b/src/lib/small/small.c
index f54c9e4c1b..c49eb817ad 100644
--- a/src/lib/small/small.c
+++ b/src/lib/small/small.c
@@ -167,10 +167,13 @@ smalloc_nothrow(struct small_alloc *alloc, size_t size)
 	struct mempool *pool;
 	if (size <= alloc->step_pool_objsize_max) {
 		/* Allocate in a stepped pool. */
-		int idx = (size + STEP_SIZE - 1) >> STEP_SIZE_LB;
-		const int objsize_min_lb =
-			alloc->step_pools[0].objsize >> STEP_SIZE_LB;
-		idx = idx > objsize_min_lb ? idx - objsize_min_lb : 0;
+		int idx;
+		if (size <= alloc->step_pools[0].objsize)
+			idx = 0;
+		else {
+			idx = (size - alloc->step_pools[0].objsize
+			       + STEP_SIZE - 1) >> STEP_SIZE_LB;
+		}
 		pool = &alloc->step_pools[idx];
 		assert(size <= pool->objsize &&
 		       (size + STEP_SIZE > pool->objsize || idx == 0));
-- 
GitLab