From: Eli Cohen Date: Mon, 4 Jun 2007 14:16:35 +0000 (+0300) Subject: Fix word size in doorbell allocator bitmaps X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=5de6edbaf6a34967d79f1d7082ad8371e79fb766;p=~shefty%2Flibmlx4.git Fix word size in doorbell allocator bitmaps Use an explicitly long constant 1UL identical to the type of the variable holding the bit mask. This avoids using the same bit twice, because on 64 bit architectures, 1 << 32 == 0. Found by Dotan Barak at Mellanox. Signed-off-by: Eli Cohen Signed-off-by: Roland Dreier --- diff --git a/src/dbrec.c b/src/dbrec.c index e59bc9e..02ef237 100644 --- a/src/dbrec.c +++ b/src/dbrec.c @@ -110,7 +110,7 @@ found: /* nothing */; j = ffsl(page->free[i]); - page->free[i] &= ~(1 << (j - 1)); + page->free[i] &= ~(1UL << (j - 1)); db = page->buf.buf + (i * 8 * sizeof (long) + (j - 1)) * db_size[type]; out: @@ -135,7 +135,7 @@ void mlx4_free_db(struct mlx4_context *context, enum mlx4_db_type type, uint32_t goto out; i = ((void *) db - page->buf.buf) / db_size[type]; - page->free[i / (8 * sizeof (long))] |= 1 << (i % (8 * sizeof (long))); + page->free[i / (8 * sizeof (long))] |= 1UL << (i % (8 * sizeof (long))); if (!--page->use_cnt) { if (page->prev)