From: Michael Lee Date: Wed, 6 Apr 2016 15:00:14 +0000 (-0700) Subject: Start compiling a bit of `-Wshadow` X-Git-Tag: 2016.07.26~367 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=448f12723308ca0582f0c4f7f53d32a5b3c1ebaf;p=folly.git Start compiling a bit of `-Wshadow` Summary: Sometimes variable shadowing is fine, sometimes it can cause subtle mistakes. Reviewed By: yfeldblum Differential Revision: D3140450 fb-gh-sync-id: acf7195ad65614d4f012bef8ce7dccb3a3038456 fbshipit-source-id: acf7195ad65614d4f012bef8ce7dccb3a3038456 --- diff --git a/folly/Format.cpp b/folly/Format.cpp index 0d1d61b1..e6df1141 100644 --- a/folly/Format.cpp +++ b/folly/Format.cpp @@ -214,11 +214,11 @@ void FormatArg::initSlow() { } auto readInt = [&] { - auto const b = p; + auto const c = p; do { ++p; } while (p != end && *p >= '0' && *p <= '9'); - return to(StringPiece(b, p)); + return to(StringPiece(c, p)); }; if (*p == '*') { @@ -242,12 +242,12 @@ void FormatArg::initSlow() { } if (*p == '.') { - auto b = ++p; + auto d = ++p; while (p != end && *p >= '0' && *p <= '9') { ++p; } - if (p != b) { - precision = to(StringPiece(b, p)); + if (p != d) { + precision = to(StringPiece(d, p)); if (p != end && *p == '.') { trailingDot = true; ++p; diff --git a/folly/SocketAddress.cpp b/folly/SocketAddress.cpp index d3614d6c..e9a9043b 100644 --- a/folly/SocketAddress.cpp +++ b/folly/SocketAddress.cpp @@ -36,7 +36,7 @@ namespace { * A structure to free a struct addrinfo when it goes out of scope. */ struct ScopedAddrInfo { - explicit ScopedAddrInfo(struct addrinfo* info) : info(info) {} + explicit ScopedAddrInfo(struct addrinfo* addrinfo) : info(addrinfo) {} ~ScopedAddrInfo() { freeaddrinfo(info); } diff --git a/folly/detail/RangeSse42.cpp b/folly/detail/RangeSse42.cpp index b963e5e7..09e37781 100644 --- a/folly/detail/RangeSse42.cpp +++ b/folly/detail/RangeSse42.cpp @@ -115,11 +115,9 @@ size_t qfind_first_byte_of_needles16(const StringPieceLite haystack, // Now, we can do aligned loads hereafter... size_t i = nextAlignedIndex(haystack.data()); for (; i < haystack.size(); i+= 16) { - auto arr1 = _mm_load_si128( - reinterpret_cast(haystack.data() + i)); - auto index = _mm_cmpestri( - arr2, needles.size(), - arr1, haystack.size() - i, 0); + arr1 = + _mm_load_si128(reinterpret_cast(haystack.data() + i)); + index = _mm_cmpestri(arr2, needles.size(), arr1, haystack.size() - i, 0); if (index < 16) { return i + index; } @@ -211,7 +209,7 @@ size_t qfind_first_byte_of_sse42(const StringPieceLite haystack, size_t i = nextAlignedIndex(haystack.data()); for (; i < haystack.size(); i += 16) { - auto ret = scanHaystackBlock(haystack, needles, i); + ret = scanHaystackBlock(haystack, needles, i); if (ret != std::string::npos) { return ret; }