• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1diff --git a/base/third_party/cityhash_v103/src/city_v103.cc b/base/third_party/cityhash_v103/src/city_v103.cc
2index 4aa37301088b4..7866e6cee8187 100644
3--- a/base/third_party/cityhash_v103/src/city_v103.cc
4+++ b/base/third_party/cityhash_v103/src/city_v103.cc
5@@ -117,7 +117,7 @@ static uint64 Rotate(uint64 val, int shift) {
6 // Equivalent to Rotate(), but requires the second arg to be non-zero.
7 // On x86-64, and probably others, it's possible for this to compile
8 // to a single instruction if both args are already in registers.
9-static uint64 RotateByAtLeast1(uint64 val, int shift) {
10+static uint64 RotateByAtLeast1(uint64 val, size_t shift) {
11   return (val >> shift) | (val << (64 - shift));
12 }
13
14@@ -140,11 +140,11 @@ static uint64 HashLen0to16(const char* s, size_t len) {
15     return HashLen16(len + (a << 3), Fetch32(s + len - 4));
16   }
17   if (len > 0) {
18-    uint8 a = s[0];
19-    uint8 b = s[len >> 1];
20-    uint8 c = s[len - 1];
21+    uint8 a = static_cast<uint8>(s[0]);
22+    uint8 b = static_cast<uint8>(s[len >> 1]);
23+    uint8 c = static_cast<uint8>(s[len - 1]);
24     uint32 y = static_cast<uint32>(a) + (static_cast<uint32>(b) << 8);
25-    uint32 z = len + (static_cast<uint32>(c) << 2);
26+    uint32 z = static_cast<uint32>(len) + (static_cast<uint32>(c) << 2);
27     return ShiftMix(y * k2 ^ z * k3) * k2;
28   }
29   return k2;
30@@ -266,15 +266,15 @@ static uint128 CityMurmur(const char* s, size_t len, uint128 seed) {
31   uint64 b = Uint128High64(seed);
32   uint64 c = 0;
33   uint64 d = 0;
34-  signed long l = len - 16;
35-  if (l <= 0) {  // len <= 16
36+  if (len <= 16) {
37     a = ShiftMix(a * k1) * k1;
38     c = b * k1 + HashLen0to16(s, len);
39     d = ShiftMix(a + (len >= 8 ? Fetch64(s) : c));
40-  } else {  // len > 16
41+  } else {
42     c = HashLen16(Fetch64(s + len - 8) + k1, a);
43     d = HashLen16(b + len, c + Fetch64(s + len - 16));
44     a += d;
45+    // len > 16 here, so do...while is safe
46     do {
47       a ^= ShiftMix(Fetch64(s) * k1) * k1;
48       a *= k1;
49@@ -283,8 +283,8 @@ static uint128 CityMurmur(const char* s, size_t len, uint128 seed) {
50       c *= k1;
51       d ^= c;
52       s += 16;
53-      l -= 16;
54-    } while (l > 0);
55+      len -= 16;
56+    } while (len > 16);
57   }
58   a = HashLen16(a, c);
59   b = HashLen16(d, b);
60