Bug 1235298 - Annotate intentional switch fallthroughs to suppress -Wimplicit-fallthrough warnings in netwerk/. r=mcmanus
authorChris Peterson <cpeterson@mozilla.com>
Sun, 22 Nov 2015 21:58:33 -0800
changeset 314243 3c43444673518cbb001302391998f44f9a291251
parent 314242 4c70584b22c70dd6d1f063fc663043adb730f32a
child 314244 159e7916ff7dd81dd286138925dd1523224d23ab
push id5703
push userraliiev@mozilla.com
push dateMon, 07 Mar 2016 14:18:41 +0000
treeherdermozilla-beta@31e373ad5b5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus
bugs1235298
milestone46.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1235298 - Annotate intentional switch fallthroughs to suppress -Wimplicit-fallthrough warnings in netwerk/. r=mcmanus
netwerk/base/nsURLHelper.cpp
netwerk/cache/nsDiskCacheDevice.cpp
netwerk/cache2/CacheHashUtils.cpp
netwerk/cache2/CacheIndex.cpp
netwerk/cache2/CacheStorageService.cpp
netwerk/cookie/nsCookieService.cpp
netwerk/protocol/http/Http2Stream.cpp
netwerk/protocol/http/SpdyStream31.cpp
netwerk/protocol/http/nsHttpTransaction.cpp
netwerk/protocol/websocket/WebSocketChannel.cpp
netwerk/streamconv/converters/mozTXTToHTMLConv.cpp
netwerk/streamconv/converters/nsHTTPCompressConv.cpp
--- a/netwerk/base/nsURLHelper.cpp
+++ b/netwerk/base/nsURLHelper.cpp
@@ -431,17 +431,17 @@ net_ResolveRelativePath(const nsACString
     for (; !stop; ++beg) {
         c = (beg == end) ? '\0' : *beg;
         //printf("%c [name=%s] [path=%s]\n", c, name.get(), path.get());
         switch (c) {
           case '\0':
           case '#':
           case '?':
             stop = true;
-            // fall through...
+            MOZ_FALLTHROUGH;
           case '/':
             // delimiter found
             if (name.EqualsLiteral("..")) {
                 // pop path
                 // If we already have the delim at end, then
                 //  skip over that when searching for next one to the left
                 int32_t offset = path.Length() - (needsDelim ? 1 : 2);
                 // First check for errors
--- a/netwerk/cache/nsDiskCacheDevice.cpp
+++ b/netwerk/cache/nsDiskCacheDevice.cpp
@@ -299,27 +299,27 @@ nsDiskCache::Hash(const char * key, PLDH
     c += k[8] + (uint32_t(k[9])<<8) + (uint32_t(k[10])<<16) + (uint32_t(k[11])<<24);
     hashmix(a, b, c);
     k += 12; len -= 12;
   }
 
   /*------------------------------------- handle the last 11 bytes */
   c += length;
   switch(len) {              /* all the case statements fall through */
-    case 11: c += (uint32_t(k[10])<<24);
-    case 10: c += (uint32_t(k[9])<<16);
-    case 9 : c += (uint32_t(k[8])<<8);
+    case 11: c += (uint32_t(k[10])<<24);  MOZ_FALLTHROUGH;
+    case 10: c += (uint32_t(k[9])<<16);   MOZ_FALLTHROUGH;
+    case 9 : c += (uint32_t(k[8])<<8);    MOZ_FALLTHROUGH;
     /* the low-order byte of c is reserved for the length */
-    case 8 : b += (uint32_t(k[7])<<24);
-    case 7 : b += (uint32_t(k[6])<<16);
-    case 6 : b += (uint32_t(k[5])<<8);
-    case 5 : b += k[4];
-    case 4 : a += (uint32_t(k[3])<<24);
-    case 3 : a += (uint32_t(k[2])<<16);
-    case 2 : a += (uint32_t(k[1])<<8);
+    case 8 : b += (uint32_t(k[7])<<24);   MOZ_FALLTHROUGH;
+    case 7 : b += (uint32_t(k[6])<<16);   MOZ_FALLTHROUGH;
+    case 6 : b += (uint32_t(k[5])<<8);    MOZ_FALLTHROUGH;
+    case 5 : b += k[4];                   MOZ_FALLTHROUGH;
+    case 4 : a += (uint32_t(k[3])<<24);   MOZ_FALLTHROUGH;
+    case 3 : a += (uint32_t(k[2])<<16);   MOZ_FALLTHROUGH;
+    case 2 : a += (uint32_t(k[1])<<8);    MOZ_FALLTHROUGH;
     case 1 : a += k[0];
     /* case 0: nothing left to add */
   }
   hashmix(a, b, c);
 
   return c;
 }
 
@@ -1147,9 +1147,8 @@ nsDiskCacheDevice::SizeOfIncludingThis(M
 {
     size_t usage = aMallocSizeOf(this);
 
     usage += mCacheMap.SizeOfExcludingThis(aMallocSizeOf);
     usage += mBindery.SizeOfExcludingThis(aMallocSizeOf);
 
     return usage;
 }
-
--- a/netwerk/cache2/CacheHashUtils.cpp
+++ b/netwerk/cache2/CacheHashUtils.cpp
@@ -51,27 +51,27 @@ CacheHash::Hash(const char *aData, uint3
     c += k[8] + (uint32_t(k[9])<<8) + (uint32_t(k[10])<<16) + (uint32_t(k[11])<<24);
     hashmix(a, b, c);
     k += 12; len -= 12;
   }
 
   /*------------------------------------- handle the last 11 bytes */
   c += aSize;
   switch(len) {              /* all the case statements fall through */
-    case 11: c += (uint32_t(k[10])<<24);
-    case 10: c += (uint32_t(k[9])<<16);
-    case 9 : c += (uint32_t(k[8])<<8);
+    case 11: c += (uint32_t(k[10])<<24);  MOZ_FALLTHROUGH;
+    case 10: c += (uint32_t(k[9])<<16);   MOZ_FALLTHROUGH;
+    case 9 : c += (uint32_t(k[8])<<8);    MOZ_FALLTHROUGH;
     /* the low-order byte of c is reserved for the length */
-    case 8 : b += (uint32_t(k[7])<<24);
-    case 7 : b += (uint32_t(k[6])<<16);
-    case 6 : b += (uint32_t(k[5])<<8);
-    case 5 : b += k[4];
-    case 4 : a += (uint32_t(k[3])<<24);
-    case 3 : a += (uint32_t(k[2])<<16);
-    case 2 : a += (uint32_t(k[1])<<8);
+    case 8 : b += (uint32_t(k[7])<<24);   MOZ_FALLTHROUGH;
+    case 7 : b += (uint32_t(k[6])<<16);   MOZ_FALLTHROUGH;
+    case 6 : b += (uint32_t(k[5])<<8);    MOZ_FALLTHROUGH;
+    case 5 : b += k[4];                   MOZ_FALLTHROUGH;
+    case 4 : a += (uint32_t(k[3])<<24);   MOZ_FALLTHROUGH;
+    case 3 : a += (uint32_t(k[2])<<16);   MOZ_FALLTHROUGH;
+    case 2 : a += (uint32_t(k[1])<<8);    MOZ_FALLTHROUGH;
     case 1 : a += k[0];
     /* case 0: nothing left to add */
   }
   hashmix(a, b, c);
 
   return c;
 }
 
@@ -151,18 +151,18 @@ CacheHash::Update(const char *aData, uin
   while (aLen >= 4) {
     Feed(data[0] + (uint32_t(data[1]) << 8) + (uint32_t(data[2]) << 16) +
          (uint32_t(data[3]) << 24));
     data += 4;
     aLen -= 4;
   }
 
   switch (aLen) {
-    case 3: mBuf += data[2] << 16;
-    case 2: mBuf += data[1] << 8;
+    case 3: mBuf += data[2] << 16;  MOZ_FALLTHROUGH;
+    case 2: mBuf += data[1] << 8;   MOZ_FALLTHROUGH;
     case 1: mBuf += data[0];
   }
 
   mBufPos = aLen;
 }
 
 CacheHash::Hash32_t
 CacheHash::GetHash()
@@ -184,9 +184,8 @@ CacheHash::Hash16_t
 CacheHash::GetHash16()
 {
   Hash32_t hash = GetHash();
   return (hash & 0xFFFF);
 }
 
 } // namespace net
 } // namespace mozilla
-
--- a/netwerk/cache2/CacheIndex.cpp
+++ b/netwerk/cache2/CacheIndex.cpp
@@ -122,17 +122,17 @@ private:
     const CacheIndexEntry *entry = nullptr;
 
     switch (mIndex->mState) {
       case CacheIndex::READING:
       case CacheIndex::WRITING:
         if (!mDoNotSearchInUpdates) {
           entry = mIndex->mPendingUpdates.GetEntry(*mHash);
         }
-        // no break
+        MOZ_FALLTHROUGH;
       case CacheIndex::BUILDING:
       case CacheIndex::UPDATING:
       case CacheIndex::READY:
         if (!entry && !mDoNotSearchInIndex) {
           entry = mIndex->mIndex.GetEntry(*mHash);
         }
         break;
       case CacheIndex::INITIAL:
@@ -425,17 +425,17 @@ CacheIndex::Shutdown()
   if (oldState != READY) {
     LOG(("CacheIndex::Shutdown() - Unexpected state. Did posting of "
          "PreShutdownInternal() fail?"));
   }
 
   switch (oldState) {
     case WRITING:
       index->FinishWrite(false);
-      // no break
+      MOZ_FALLTHROUGH;
     case READY:
       if (index->mIndexOnDiskIsValid && !index->mDontMarkIndexClean) {
         if (!sanitize && NS_FAILED(index->WriteLogToDisk())) {
           index->RemoveIndexFromDisk();
         }
       } else {
         index->RemoveIndexFromDisk();
       }
@@ -1120,17 +1120,17 @@ CacheIndex::HasEntry(const SHA1Sum::Hash
   }
 
   const CacheIndexEntry *entry = nullptr;
 
   switch (index->mState) {
     case READING:
     case WRITING:
       entry = index->mPendingUpdates.GetEntry(hash);
-      // no break
+      MOZ_FALLTHROUGH;
     case BUILDING:
     case UPDATING:
     case READY:
       if (!entry) {
         entry = index->mIndex.GetEntry(hash);
       }
       break;
     case INITIAL:
--- a/netwerk/cache2/CacheStorageService.cpp
+++ b/netwerk/cache2/CacheStorageService.cpp
@@ -415,17 +415,17 @@ private:
         // Invoke onCacheStorageInfo with valid information.
         NS_DispatchToMainThread(this);
 
         if (!mVisitEntries) {
           return NS_OK; // done
         }
 
         mPass = ITERATE_METADATA;
-        // no break
+        MOZ_FALLTHROUGH;
 
       case ITERATE_METADATA:
         // Now grab the context iterator.
         if (!mIter) {
           rv = CacheIndex::GetIterator(mLoadInfo, true, getter_AddRefs(mIter));
           if (NS_FAILED(rv)) {
             // Invoke onCacheEntryVisitCompleted now
             return NS_DispatchToMainThread(this);
--- a/netwerk/cookie/nsCookieService.cpp
+++ b/netwerk/cookie/nsCookieService.cpp
@@ -990,16 +990,17 @@ nsCookieService::TryInitDB(bool aRecreat
     case 1:
       {
         // Add the lastAccessed column to the table.
         rv = mDefaultDBState->dbConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
           "ALTER TABLE moz_cookies ADD lastAccessed INTEGER"));
         NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
       }
       // Fall through to the next upgrade.
+      MOZ_FALLTHROUGH;
 
     case 2:
       {
         // Add the baseDomain column and index to the table.
         rv = mDefaultDBState->dbConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
           "ALTER TABLE moz_cookies ADD baseDomain TEXT"));
         NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
 
@@ -1048,16 +1049,17 @@ nsCookieService::TryInitDB(bool aRecreat
         }
 
         // Create an index on baseDomain.
         rv = mDefaultDBState->dbConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
           "CREATE INDEX moz_basedomain ON moz_cookies (baseDomain)"));
         NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
       }
       // Fall through to the next upgrade.
+      MOZ_FALLTHROUGH;
 
     case 3:
       {
         // Add the creationTime column to the table, and create a unique index
         // on (name, host, path). Before we do this, we have to purge the table
         // of expired cookies such that we know that the (name, host, path)
         // index is truly unique -- otherwise we can't create the index. Note
         // that we can't just execute a statement to delete all rows where the
@@ -1144,16 +1146,17 @@ nsCookieService::TryInitDB(bool aRecreat
 
         // Create a unique index on (name, host, path) to allow fast lookup.
         rv = mDefaultDBState->dbConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
           "CREATE UNIQUE INDEX moz_uniqueid "
           "ON moz_cookies (name, host, path)"));
         NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
       }
       // Fall through to the next upgrade.
+      MOZ_FALLTHROUGH;
 
     case 4:
       {
         // We need to add appId/inBrowserElement, plus change a constraint on
         // the table (unique entries now include appId/inBrowserElement):
         // this requires creating a new table and copying the data to it.  We
         // then rename the new table to the old name.
         //
@@ -1191,16 +1194,17 @@ nsCookieService::TryInitDB(bool aRecreat
         rv = mDefaultDBState->dbConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
           "DROP TABLE moz_cookies_old"));
         NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
 
         COOKIE_LOGSTRING(LogLevel::Debug,
           ("Upgraded database to schema version 5"));
       }
       // Fall through to the next upgrade.
+      MOZ_FALLTHROUGH;
 
     case 5:
       {
         // Change in the version: Replace the columns |appId| and
         // |inBrowserElement| by a single column |originAttributes|.
         //
         // Why we made this change: FxOS new security model (NSec) encapsulates
         // "appId/inBrowser" in nsIPrincipal::originAttributes to make it easier
@@ -1256,16 +1260,17 @@ nsCookieService::TryInitDB(bool aRecreat
         // Drop old table
         rv = mDefaultDBState->dbConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
              "DROP TABLE moz_cookies_old"));
         NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
 
         COOKIE_LOGSTRING(LogLevel::Debug,
           ("Upgraded database to schema version 6"));
       }
+      MOZ_FALLTHROUGH;
 
     case 6:
       {
         // We made a mistake in schema version 6. We cannot remove expected
         // columns of any version (checked in the default case) from cookie
         // database, because doing this would destroy the possibility of
         // downgrading database.
         //
@@ -1315,33 +1320,35 @@ nsCookieService::TryInitDB(bool aRecreat
 
         COOKIE_LOGSTRING(LogLevel::Debug,
           ("Upgraded database to schema version 7"));
       }
 
       // No more upgrades. Update the schema version.
       rv = mDefaultDBState->dbConn->SetSchemaVersion(COOKIES_SCHEMA_VERSION);
       NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
+      MOZ_FALLTHROUGH;
 
     case COOKIES_SCHEMA_VERSION:
       break;
 
     case 0:
       {
         NS_WARNING("couldn't get schema version!");
-          
+
         // the table may be usable; someone might've just clobbered the schema
         // version. we can treat this case like a downgrade using the codepath
         // below, by verifying the columns we care about are all there. for now,
         // re-set the schema version in the db, in case the checks succeed (if
         // they don't, we're dropping the table anyway).
         rv = mDefaultDBState->dbConn->SetSchemaVersion(COOKIES_SCHEMA_VERSION);
         NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
       }
       // fall through to downgrade check
+      MOZ_FALLTHROUGH;
 
     // downgrading.
     // if columns have been added to the table, we can still use the ones we
     // understand safely. if columns have been deleted or altered, just
     // blow away the table and start from scratch! if you change the way
     // a column is interpreted, make sure you also change its name so this
     // check will catch it.
     default:
--- a/netwerk/protocol/http/Http2Stream.cpp
+++ b/netwerk/protocol/http/Http2Stream.cpp
@@ -1355,17 +1355,17 @@ Http2Stream::OnReadSegment(const char *b
       return NS_BASE_STREAM_WOULD_BLOCK;
     }
     if (dataLength > mRequestBodyLenRemaining) {
       return NS_ERROR_UNEXPECTED;
     }
     mRequestBodyLenRemaining -= dataLength;
     GenerateDataFrameHeader(dataLength, !mRequestBodyLenRemaining);
     ChangeState(SENDING_BODY);
-    // NO BREAK
+    MOZ_FALLTHROUGH;
 
   case SENDING_BODY:
     MOZ_ASSERT(mTxInlineFrameUsed, "OnReadSegment Send Data Header 0b");
     rv = TransmitFrame(buf, countRead, false);
     MOZ_ASSERT(NS_FAILED(rv) || !mTxInlineFrameUsed,
                "Transmit Frame should be all or nothing");
 
     LOG3(("TransmitFrame() rv=%x returning %d data bytes. "
@@ -1476,9 +1476,8 @@ Http2Stream::MapStreamToHttpConnection()
   RefPtr<SpdyConnectTransaction> qiTrans(mTransaction->QuerySpdyConnectTransaction());
   MOZ_ASSERT(qiTrans);
   qiTrans->MapStreamToHttpConnection(mSocketTransport,
                                      mTransaction->ConnectionInfo());
 }
 
 } // namespace net
 } // namespace mozilla
-
--- a/netwerk/protocol/http/SpdyStream31.cpp
+++ b/netwerk/protocol/http/SpdyStream31.cpp
@@ -1581,17 +1581,17 @@ SpdyStream31::OnReadSegment(const char *
       return NS_BASE_STREAM_WOULD_BLOCK;
     }
     if (dataLength > mRequestBodyLenRemaining) {
       return NS_ERROR_UNEXPECTED;
     }
     mRequestBodyLenRemaining -= dataLength;
     GenerateDataFrameHeader(dataLength, !mRequestBodyLenRemaining);
     ChangeState(SENDING_REQUEST_BODY);
-    // NO BREAK
+    MOZ_FALLTHROUGH;
 
   case SENDING_REQUEST_BODY:
     MOZ_ASSERT(mTxInlineFrameUsed, "OnReadSegment Send Data Header 0b");
     rv = TransmitFrame(buf, countRead, false);
     MOZ_ASSERT(NS_FAILED(rv) || !mTxInlineFrameUsed,
                "Transmit Frame should be all or nothing");
 
     LOG3(("TransmitFrame() rv=%x returning %d data bytes. "
--- a/netwerk/protocol/http/nsHttpTransaction.cpp
+++ b/netwerk/protocol/http/nsHttpTransaction.cpp
@@ -1578,17 +1578,18 @@ nsHttpTransaction::HandleContentStart()
             mResponseHead->Reset();
             // wait to be called again...
             return NS_OK;
         }
 
         // check if this is a no-content response
         switch (mResponseHead->Status()) {
         case 101:
-            mPreserveStream = true;    // fall through to other no content
+            mPreserveStream = true;
+            MOZ_FALLTHROUGH; // to other no content cases:
         case 204:
         case 205:
         case 304:
             mNoContent = true;
             LOG(("this response should not contain a body.\n"));
             break;
         case 421:
             LOG(("Misdirected Request.\n"));
--- a/netwerk/protocol/websocket/WebSocketChannel.cpp
+++ b/netwerk/protocol/websocket/WebSocketChannel.cpp
@@ -2101,16 +2101,17 @@ WebSocketChannel::PrimeNewOutgoingMessag
       if (NS_FAILED(rv)) {
         AbortSession(NS_ERROR_FILE_TOO_BIG);
         return;
       }
       // Now we're a binary string
       msgType = kMsgTypeBinaryString;
 
       // no break: fall down into binary string case
+      MOZ_FALLTHROUGH;
 
     case kMsgTypeBinaryString:
       mOutHeader[0] = kFinalFragBit | nsIWebSocketFrame::OPCODE_BINARY;
       break;
     case kMsgTypeFin:
       MOZ_ASSERT(false, "unreachable");  // avoid compiler warning
       break;
     }
--- a/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp
+++ b/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp
@@ -47,16 +47,17 @@ mozTXTToHTMLConv::EscapeChar(const char1
       break;
     case '"':
       if (inAttribute)
       {
         aStringToAppendTo.AppendLiteral("&quot;");
         break;
       }
       // else fall through
+      MOZ_FALLTHROUGH;
     default:
       aStringToAppendTo += ch;
     }
 
     return;
 }
 
 // EscapeStr takes the passed in string and
@@ -94,16 +95,17 @@ mozTXTToHTMLConv::EscapeStr(nsString& aI
       if (inAttribute)
       {
         aInString.Cut(i, 1);
         aInString.Insert(NS_LITERAL_STRING("&quot;"), i);
         i += 6;
         break;
       }
       // else fall through
+      MOZ_FALLTHROUGH;
     default:
       i++;
     }
   }
 }
 
 void 
 mozTXTToHTMLConv::UnescapeStr(const char16_t * aInString, int32_t aStartPos, int32_t aLength, nsString& aOutString)
@@ -505,17 +507,17 @@ mozTXTToHTMLConv::FindURL(const char16_t
      only abbreviated for '.', RFC2396E and abbreviated for '@' */
   for (modetype iState = unknown; iState <= mozTXTToHTMLConv_lastMode;
        iState = modetype(iState + 1))
     state[iState] = aInString[pos] == ':' ? unchecked : invalid;
   switch (aInString[pos])
   {
   case '@':
     state[RFC2396E] = unchecked;
-    // no break here
+    MOZ_FALLTHROUGH;
   case '.':
     state[abbreviated] = unchecked;
     break;
   case ':':
     state[abbreviated] = invalid;
     break;
   default:
     break;
--- a/netwerk/streamconv/converters/nsHTTPCompressConv.cpp
+++ b/netwerk/streamconv/converters/nsHTTPCompressConv.cpp
@@ -256,17 +256,17 @@ nsHTTPCompressConv::OnDataAvailable(nsIR
     if (rv != NS_OK) {
       return rv;
     }
 
     if (streamLen == 0) {
       return NS_OK;
     }
 
-    // FALLTHROUGH
+    MOZ_FALLTHROUGH;
 
   case HTTP_COMPRESS_DEFLATE:
 
     if (mInpBuffer != nullptr && streamLen > mInpBufferLen) {
       mInpBuffer = (unsigned char *) realloc(mInpBuffer, mInpBufferLen = streamLen);
 
       if (mOutBufferLen < streamLen * 2) {
         mOutBuffer = (unsigned char *) realloc(mOutBuffer, mOutBufferLen = streamLen * 3);