Use type of the constant 1 identical to the type of the
variable holding the bit mask to prevent using the same bit
twice.
For example, on 64 bit machines, int is 32 bits and long is
64 bits. So 1 << 0 is equal 1 << 32 whereas the correct usage
should be 1L << shift_val

Found by Dotan Barak at Mellanox
Signed-off-by: Eli Cohen <[EMAIL PROTECTED]>

---
Index: libmlx4/src/dbrec.c
===================================================================
--- libmlx4.orig/src/dbrec.c    2007-06-04 12:53:57.000000000 +0300
+++ libmlx4/src/dbrec.c 2007-06-04 16:53:31.000000000 +0300
@@ -110,7 +110,7 @@
                /* nothing */;
 
        j = ffsl(page->free[i]);
-       page->free[i] &= ~(1 << (j - 1));
+       page->free[i] &= ~(1L << (j - 1));
        db = page->buf.buf + (i * 8 * sizeof (long) + (j - 1)) * db_size[type];
 
 out:
@@ -135,7 +135,7 @@
                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))] |= 1L << (i % (8 * sizeof (long)));
 
        if (!--page->use_cnt) {
                if (page->prev)

_______________________________________________
general mailing list
[email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to