break;
case MEMCACHED_HASH_FNV1A_64:
{
- hash= FNV_64_INIT;
+ hash= (uint32_t) FNV_64_INIT;
for (x= 0; x < key_length; x++)
{
hash ^= key[x];
- hash *= FNV_64_PRIME;
+ hash *= (uint32_t) FNV_64_PRIME;
}
}
break;
case MEMCACHED_DISTRIBUTION_MODULA:
return hash % ptr->number_of_hosts;
case MEMCACHED_DISTRIBUTION_RANDOM:
- return random() % ptr->number_of_hosts;
+ return (uint32_t) random() % ptr->number_of_hosts;
default:
WATCHPOINT_ASSERT(0); /* We have added a distribution without extending the logic */
return hash % ptr->number_of_hosts;
static uint32_t internal_generate_hash(const char *key, size_t key_length)
{
const char *ptr= key;
- uint32_t value= 0;
+ int32_t value= 0;
while (key_length--)
{
- value += *ptr++;
+ value += (int32_t) *ptr++;
value += (value << 10);
value ^= (value >> 6);
}
value ^= (value >> 11);
value += (value << 15);
- return value == 0 ? 1 : value;
+ return value == 0 ? 1 : (uint32_t) value;
}
static uint32_t internal_generate_md5(const char *key, size_t key_length)