]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
make mkmask robust against zero elements
authorMichael Schroeder <mls@suse.de>
Mon, 14 Sep 2015 10:20:10 +0000 (12:20 +0200)
committerMichael Schroeder <mls@suse.de>
Mon, 14 Sep 2015 10:20:10 +0000 (12:20 +0200)
src/hash.h

index 1290afa15bc7347819b707f56d229ddb026d272d..4f595bbb17e9417142c4e2e97be271e7767d16f3 100644 (file)
@@ -73,14 +73,14 @@ relhash(Id name, Id evr, int flags)
 
 
 /* compute bitmask for value
- * returns smallest (2^n-1) > 2 * num
+ * returns smallest (2^n-1) > 2 * num + 3
  *
  * used for Hashtable 'modulo' operation
  */
 static inline Hashval
 mkmask(unsigned int num)
 {
-  num *= 2;
+  num = num * 2 + 3;
   while (num & (num - 1))
     num &= num - 1;
   return num * 2 - 1;