Index: webrtc/base/ipaddress.cc |
diff --git a/webrtc/base/ipaddress.cc b/webrtc/base/ipaddress.cc |
index c92f33c74d8baaa9b947da93e7fa1e7099d17982..b1d1265ae479ee4c97f106d2a52fabb0614ca897 100644 |
--- a/webrtc/base/ipaddress.cc |
+++ b/webrtc/base/ipaddress.cc |
@@ -412,7 +412,9 @@ int CountIPMaskBits(IPAddress mask) { |
// http://graphics.stanford.edu/~seander/bithacks.html |
// Counts the trailing 0s in the word. |
unsigned int zeroes = 32; |
- word_to_count &= -static_cast<int32_t>(word_to_count); |
+ // This could also be written word_to_count &= -word_to_count, but |
+ // MSVC emits warning C4146 when negating an unsigned number. |
+ word_to_count &= ~word_to_count + 1; // Isolate lowest set bit. |
if (word_to_count) zeroes--; |
if (word_to_count & 0x0000FFFF) zeroes -= 16; |
if (word_to_count & 0x00FF00FF) zeroes -= 8; |
@@ -522,4 +524,4 @@ IPAddress GetAnyIP(int family) { |
return rtc::IPAddress(); |
} |
-} // Namespace rtc |
+} // namespace rtc |