From 1e5f478b7e1183d38ad07d1f5e68fdc9680f2eb8 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Tue, 15 Oct 2019 13:08:57 -0400 Subject: [PATCH] dix: Fix undefined shift in HashResourceID Again, we need all of the bits of an unsigned int to make this work. --- dix/resource.c | 4 ++-- include/resource.h | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/dix/resource.c b/dix/resource.c index a42cd007f..6c0be2e04 100644 --- a/dix/resource.c +++ b/dix/resource.c @@ -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); } diff --git a/include/resource.h b/include/resource.h index 5871a4cb4..6caf846c4 100644 --- a/include/resource.h +++ b/include/resource.h @@ -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 */