Fix compiler warnings on function rev(unsigned long)

This commit is contained in:
Muhammad Zahalqa 2020-05-04 12:36:01 +03:00 committed by antirez
parent 6b8fdaa8d6
commit 6bbfb97a89

View File

@ -766,9 +766,9 @@ dictEntry *dictGetFairRandomKey(dict *d) {
/* Function to reverse bits. Algorithm from:
* http://graphics.stanford.edu/~seander/bithacks.html#ReverseParallel */
static unsigned long rev(unsigned long v) {
unsigned long s = 8 * sizeof(v); // bit size; must be power of 2
unsigned long mask = ~0;
while ((s >>= 1) > 0) {
unsigned long s = CHAR_BIT * sizeof(v); // bit size; must be power of 2
unsigned long mask = ~0UL;
while ((s >>= 1) > 0UL) {
mask ^= (mask << s);
v = ((v >> s) & mask) | ((v << s) & ~mask);
}