Commit 536e40ae authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

src: Fix hash calculation because of signed integer promotion

parent 42ea5abd
...@@ -75,8 +75,9 @@ int compute_hash_values(std::vector<uint64_t> &hash_values, ...@@ -75,8 +75,9 @@ int compute_hash_values(std::vector<uint64_t> &hash_values,
v = (static_cast<uint64_t>(md[24]) << 56) + v = (static_cast<uint64_t>(md[24]) << 56) +
(static_cast<uint64_t>(md[25]) << 48) + (static_cast<uint64_t>(md[25]) << 48) +
(static_cast<uint64_t>(md[26]) << 40) + (static_cast<uint64_t>(md[26]) << 40) +
(static_cast<uint64_t>(md[27]) << 32) + (md[28] << 24) + (static_cast<uint64_t>(md[27]) << 32) +
(md[29] << 16) + (md[30] << 8) + md[31]; (static_cast<uint64_t>(md[28]) << 24) + (md[29] << 16) + (md[30] << 8) +
md[31];
v &= mask; v &= mask;
*p++ = v; *p++ = v;
...@@ -252,8 +253,9 @@ int cache_digest_hash(uint64_t &key, size_t nbits, const StringRef &s) { ...@@ -252,8 +253,9 @@ int cache_digest_hash(uint64_t &key, size_t nbits, const StringRef &s) {
key = (static_cast<uint64_t>(md[24]) << 56) + key = (static_cast<uint64_t>(md[24]) << 56) +
(static_cast<uint64_t>(md[25]) << 48) + (static_cast<uint64_t>(md[25]) << 48) +
(static_cast<uint64_t>(md[26]) << 40) + (static_cast<uint64_t>(md[26]) << 40) +
(static_cast<uint64_t>(md[27]) << 32) + (md[28] << 24) + (static_cast<uint64_t>(md[27]) << 32) +
(md[29] << 16) + (md[30] << 8) + md[31]; (static_cast<uint64_t>(md[28]) << 24) + (md[29] << 16) + (md[30] << 8) +
md[31];
key &= mask; key &= mask;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment