This squashes some compiler warnings on CentOS 7:
dtstrhash.c: In function 'dtstrhash':
dtstrhash.c:22:18: warning: conversion to 'unsigned int' from 'int' may change
the sign of the result [-Wsign-conversion]
h = (h + (s[0]<<8) + s[1])*DT_PRIME;
^
dtstrhash.c:28:18: warning: conversion to 'unsigned int' from 'int' may change
the sign of the result [-Wsign-conversion]
h = (h + (s[0]<<8) + s[1])*DT_PRIME;
^
dtstrhash.c:30:18: warning: conversion to 'unsigned int' from 'int' may change
the sign of the result [-Wsign-conversion]
h = (h + (s[0]<<8))*DT_PRIME;
if(n <= 0)
{ for(; *s != 0; s += s[1] ? 2 : 1)
- h = (h + (s[0]<<8) + s[1])*DT_PRIME;
+ h = (h + ((unsigned)s[0] << 8u) + (unsigned)s[1]) * DT_PRIME;
n = s - (unsigned char*)args;
}
else
{ unsigned char* ends;
for(ends = s+n-1; s < ends; s += 2)
- h = (h + (s[0]<<8) + s[1])*DT_PRIME;
+ h = (h + ((unsigned)s[0] << 8u) + (unsigned)s[1]) * DT_PRIME;
if(s <= ends)
- h = (h + (s[0]<<8))*DT_PRIME;
+ h = (h + ((unsigned)s[0] << 8u)) * DT_PRIME;
}
return (h+n)*DT_PRIME;
}