Start compiling a bit of `-Wshadow`
authorMichael Lee <mzlee@fb.com>
Wed, 6 Apr 2016 15:00:14 +0000 (08:00 -0700)
committerFacebook Github Bot 4 <facebook-github-bot-4-bot@fb.com>
Wed, 6 Apr 2016 15:05:39 +0000 (08:05 -0700)
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

folly/Format.cpp
folly/SocketAddress.cpp
folly/detail/RangeSse42.cpp

index 0d1d61b126d19e7ad99be135922aef04575a4f68..e6df11419f7dce100dc2113739da6089022c5535 100644 (file)
@@ -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<int>(StringPiece(b, p));
+      return to<int>(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<int>(StringPiece(b, p));
+      if (p != d) {
+        precision = to<int>(StringPiece(d, p));
         if (p != end && *p == '.') {
           trailingDot = true;
           ++p;
index d3614d6cc28145a186fe390ed5a46036ff1b52f8..e9a9043b0daa61c5732d6c228db4f17263554bef 100644 (file)
@@ -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);
   }
index b963e5e774b707c112bb9ec4430b0d84fa3fe744..09e37781e943a5b3de2932681f5d4008947dcfc3 100644 (file)
@@ -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<const __m128i*>(haystack.data() + i));
-    auto index = _mm_cmpestri(
-        arr2, needles.size(),
-        arr1, haystack.size() - i, 0);
+    arr1 =
+        _mm_load_si128(reinterpret_cast<const __m128i*>(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<true>(haystack, needles, i);
+    ret = scanHaystackBlock<true>(haystack, needles, i);
     if (ret != std::string::npos) {
       return ret;
     }