Commit a03331d8 authored by Sean Cannella's avatar Sean Cannella Committed by Dave Watson

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
parent 9d4d4b00
...@@ -85,7 +85,7 @@ inline bool getNthMSBitImpl(const IPAddrType& ip, uint8_t bitIndex, ...@@ -85,7 +85,7 @@ inline bool getNthMSBitImpl(const IPAddrType& ip, uint8_t bitIndex,
struct Bytes : private boost::noncopyable { struct Bytes : private boost::noncopyable {
// return true if all values of src are zero // return true if all values of src are zero
static bool isZero(const uint8_t* src, std::size_t len) { 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) { if (src[i] != 0x00) {
return false; return false;
} }
...@@ -100,7 +100,7 @@ struct Bytes : private boost::noncopyable { ...@@ -100,7 +100,7 @@ struct Bytes : private boost::noncopyable {
static_assert(N > 0, "Can't mask an empty ByteArray"); static_assert(N > 0, "Can't mask an empty ByteArray");
std::size_t asize = a.size(); std::size_t asize = a.size();
std::array<uint8_t, N> ba{{0}}; std::array<uint8_t, N> ba{{0}};
for (int i = 0; i < asize; i++) { for (std::size_t i = 0; i < asize; i++) {
ba[i] = a[i] & b[i]; ba[i] = a[i] & b[i];
} }
return ba; return ba;
...@@ -176,7 +176,7 @@ struct Bytes : private boost::noncopyable { ...@@ -176,7 +176,7 @@ struct Bytes : private boost::noncopyable {
static std::string toHex(const uint8_t* src, std::size_t len) { static std::string toHex(const uint8_t* src, std::size_t len) {
static const char* const lut = "0123456789abcdef"; static const char* const lut = "0123456789abcdef";
std::stringstream ss; 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]; const unsigned char c = src[i];
ss << lut[c >> 4] << lut[c & 15]; ss << lut[c >> 4] << lut[c & 15];
} }
......
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