dix: Fix undefined shift in HashResourceID

Again, we need all of the bits of an unsigned int to make this work.
This commit is contained in:
Adam Jackson 2019-10-15 13:08:57 -04:00
parent 3671a3ee88
commit 1e5f478b7e
2 changed files with 3 additions and 4 deletions

View File

@ -671,7 +671,7 @@ InitClientResources(ClientPtr client)
}
int
HashResourceID(XID id, int numBits)
HashResourceID(XID id, unsigned int numBits)
{
static XID mask;
@ -679,7 +679,7 @@ HashResourceID(XID id, int numBits)
mask = RESOURCE_ID_MASK;
id &= mask;
if (numBits < 9)
return (id ^ (id >> numBits) ^ (id >> (numBits<<1))) & ~((~0) << numBits);
return (id ^ (id >> numBits) ^ (id >> (numBits<<1))) & ~((~0U) << numBits);
return (id ^ (id >> numBits)) & ~((~0) << numBits);
}

View File

@ -270,7 +270,6 @@ extern _X_EXPORT RESTYPE TypeMask;
of bits by either masking numBits lower bits of the ID or by
providing at most MAXHASHSIZE hashes.
*/
extern _X_EXPORT int HashResourceID(XID id,
int numBits);
extern _X_EXPORT int HashResourceID(XID id, unsigned int numBits);
#endif /* RESOURCE_H */