Bug 1235298 - Annotate intentional switch fallthroughs to suppress -Wimplicit-fallthrough warnings in netwerk/. r=mcmanus

This commit is contained in:
Chris Peterson 2015-11-22 21:58:33 -08:00
parent 4bcd2a67bf
commit 659b30fd0b
12 changed files with 44 additions and 36 deletions

View File

@ -436,7 +436,7 @@ net_ResolveRelativePath(const nsACString &relativePath,
case '#':
case '?':
stop = true;
// fall through...
MOZ_FALLTHROUGH;
case '/':
// delimiter found
if (name.EqualsLiteral("..")) {

View File

@ -304,17 +304,17 @@ nsDiskCache::Hash(const char * key, PLDHashNumber initval)
/*------------------------------------- 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 */
}
@ -1152,4 +1152,3 @@ nsDiskCacheDevice::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf)
return usage;
}

View File

@ -56,17 +56,17 @@ CacheHash::Hash(const char *aData, uint32_t aSize, uint32_t aInitval)
/*------------------------------------- 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 */
}
@ -156,8 +156,8 @@ CacheHash::Update(const char *aData, uint32_t aLen)
}
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];
}
@ -189,4 +189,3 @@ CacheHash::GetHash16()
} // namespace net
} // namespace mozilla

View File

@ -127,7 +127,7 @@ private:
if (!mDoNotSearchInUpdates) {
entry = mIndex->mPendingUpdates.GetEntry(*mHash);
}
// no break
MOZ_FALLTHROUGH;
case CacheIndex::BUILDING:
case CacheIndex::UPDATING:
case CacheIndex::READY:
@ -430,7 +430,7 @@ CacheIndex::Shutdown()
switch (oldState) {
case WRITING:
index->FinishWrite(false);
// no break
MOZ_FALLTHROUGH;
case READY:
if (index->mIndexOnDiskIsValid && !index->mDontMarkIndexClean) {
if (!sanitize && NS_FAILED(index->WriteLogToDisk())) {
@ -1125,7 +1125,7 @@ CacheIndex::HasEntry(const SHA1Sum::Hash &hash, EntryStatus *_retval, bool *_pin
case READING:
case WRITING:
entry = index->mPendingUpdates.GetEntry(hash);
// no break
MOZ_FALLTHROUGH;
case BUILDING:
case UPDATING:
case READY:

View File

@ -420,7 +420,7 @@ private:
}
mPass = ITERATE_METADATA;
// no break
MOZ_FALLTHROUGH;
case ITERATE_METADATA:
// Now grab the context iterator.

View File

@ -995,6 +995,7 @@ nsCookieService::TryInitDB(bool aRecreateDB)
NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
}
// Fall through to the next upgrade.
MOZ_FALLTHROUGH;
case 2:
{
@ -1053,6 +1054,7 @@ nsCookieService::TryInitDB(bool aRecreateDB)
NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
}
// Fall through to the next upgrade.
MOZ_FALLTHROUGH;
case 3:
{
@ -1149,6 +1151,7 @@ nsCookieService::TryInitDB(bool aRecreateDB)
NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
}
// Fall through to the next upgrade.
MOZ_FALLTHROUGH;
case 4:
{
@ -1196,6 +1199,7 @@ nsCookieService::TryInitDB(bool aRecreateDB)
("Upgraded database to schema version 5"));
}
// Fall through to the next upgrade.
MOZ_FALLTHROUGH;
case 5:
{
@ -1261,6 +1265,7 @@ nsCookieService::TryInitDB(bool aRecreateDB)
COOKIE_LOGSTRING(LogLevel::Debug,
("Upgraded database to schema version 6"));
}
MOZ_FALLTHROUGH;
case 6:
{
@ -1320,6 +1325,7 @@ nsCookieService::TryInitDB(bool aRecreateDB)
// 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;
@ -1327,7 +1333,7 @@ nsCookieService::TryInitDB(bool aRecreateDB)
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,
@ -1337,6 +1343,7 @@ nsCookieService::TryInitDB(bool aRecreateDB)
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

View File

@ -1360,7 +1360,7 @@ Http2Stream::OnReadSegment(const char *buf,
mRequestBodyLenRemaining -= dataLength;
GenerateDataFrameHeader(dataLength, !mRequestBodyLenRemaining);
ChangeState(SENDING_BODY);
// NO BREAK
MOZ_FALLTHROUGH;
case SENDING_BODY:
MOZ_ASSERT(mTxInlineFrameUsed, "OnReadSegment Send Data Header 0b");
@ -1481,4 +1481,3 @@ Http2Stream::MapStreamToHttpConnection()
} // namespace net
} // namespace mozilla

View File

@ -1586,7 +1586,7 @@ SpdyStream31::OnReadSegment(const char *buf,
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");

View File

@ -1583,7 +1583,8 @@ nsHttpTransaction::HandleContentStart()
// 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:

View File

@ -2106,6 +2106,7 @@ WebSocketChannel::PrimeNewOutgoingMessage()
msgType = kMsgTypeBinaryString;
// no break: fall down into binary string case
MOZ_FALLTHROUGH;
case kMsgTypeBinaryString:
mOutHeader[0] = kFinalFragBit | nsIWebSocketFrame::OPCODE_BINARY;

View File

@ -52,6 +52,7 @@ mozTXTToHTMLConv::EscapeChar(const char16_t ch, nsString& aStringToAppendTo,
break;
}
// else fall through
MOZ_FALLTHROUGH;
default:
aStringToAppendTo += ch;
}
@ -99,6 +100,7 @@ mozTXTToHTMLConv::EscapeStr(nsString& aInString, bool inAttribute)
break;
}
// else fall through
MOZ_FALLTHROUGH;
default:
i++;
}
@ -510,7 +512,7 @@ mozTXTToHTMLConv::FindURL(const char16_t * aInString, int32_t aInLength, const u
{
case '@':
state[RFC2396E] = unchecked;
// no break here
MOZ_FALLTHROUGH;
case '.':
state[abbreviated] = unchecked;
break;

View File

@ -261,7 +261,7 @@ nsHTTPCompressConv::OnDataAvailable(nsIRequest* request,
return NS_OK;
}
// FALLTHROUGH
MOZ_FALLTHROUGH;
case HTTP_COMPRESS_DEFLATE: