From: Sean Cannella Date: Wed, 17 Sep 2014 00:08:52 +0000 (-0700) Subject: Fix folly signed/unsigned comparisons X-Git-Tag: v0.22.0~359 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=a03331d8d54b142fb0ff137dd3f37b10b9bd1bc8;p=folly.git Fix folly signed/unsigned comparisons Summary: Fix a few sign comparison issues in folly::IPAddress @override-unit-failures Test Plan: existing tests, compiled with clang Reviewed By: meyering@fb.com, davejwatson@fb.com Subscribers: njormrod, bmatheny, subodh, ranjeeth, pgriess FB internal diff: D1559152 --- diff --git a/folly/detail/IPAddress.h b/folly/detail/IPAddress.h index ba43bf06..f2552290 100644 --- a/folly/detail/IPAddress.h +++ b/folly/detail/IPAddress.h @@ -85,7 +85,7 @@ inline bool getNthMSBitImpl(const IPAddrType& ip, uint8_t bitIndex, struct Bytes : private boost::noncopyable { // return true if all values of src are zero static bool isZero(const uint8_t* src, std::size_t len) { - for (auto i = 0; i < len; i++) { + for (std::size_t i = 0; i < len; i++) { if (src[i] != 0x00) { return false; } @@ -100,7 +100,7 @@ struct Bytes : private boost::noncopyable { static_assert(N > 0, "Can't mask an empty ByteArray"); std::size_t asize = a.size(); std::array ba{{0}}; - for (int i = 0; i < asize; i++) { + for (std::size_t i = 0; i < asize; i++) { ba[i] = a[i] & b[i]; } return ba; @@ -176,7 +176,7 @@ struct Bytes : private boost::noncopyable { static std::string toHex(const uint8_t* src, std::size_t len) { static const char* const lut = "0123456789abcdef"; std::stringstream ss; - for (int i = 0; i < len; i++) { + for (std::size_t i = 0; i < len; i++) { const unsigned char c = src[i]; ss << lut[c >> 4] << lut[c & 15]; }