Merge pull request #7194 from tryfinally/dev-reverse-bits

Fixed compiler warnings on rev(ulong) function
This commit is contained in:
Salvatore Sanfilippo 2020-05-05 10:26:02 +02:00 committed by GitHub
commit 154e735c46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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);
}