From: Michael Schroeder Date: Mon, 14 Sep 2015 10:20:10 +0000 (+0200) Subject: make mkmask robust against zero elements X-Git-Tag: 0.6.13~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a2a5f3771c01811d22da48619cbb07d31abdf294;p=thirdparty%2Flibsolv.git make mkmask robust against zero elements --- diff --git a/src/hash.h b/src/hash.h index 1290afa1..4f595bbb 100644 --- a/src/hash.h +++ b/src/hash.h @@ -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;