From e3e95816d8388ff9d68656a99236e2a3e4a282a6 Mon Sep 17 00:00:00 2001 From: Chris Peterson Date: Thu, 29 Oct 2015 21:31:32 -0700 Subject: [PATCH] Bug 1220035 - Fix -Wimplicit-fallthrough warnings in xpcom. r=mccr8 xpcom/base/nsDebugImpl.cpp:458:5 [-Wimplicit-fallthrough] unannotated fall-through between switch labels xpcom/ds/nsCheapSets.h:139:5 [-Wimplicit-fallthrough] unannotated fall-through between switch labels xpcom/ds/nsPersistentProperties.cpp:232:9 [-Wimplicit-fallthrough] unannotated fall-through between switch labels xpcom/ds/nsVariant.cpp:360:5 [-Wimplicit-fallthrough] unannotated fall-through between switch labels xpcom/ds/nsVariant.cpp:766:5 [-Wimplicit-fallthrough] unannotated fall-through between switch labels xpcom/ds/nsVariant.cpp:1658:9 [-Wimplicit-fallthrough] unannotated fall-through between switch labels xpcom/ds/nsVariant.cpp:1661:5 [-Wimplicit-fallthrough] unannotated fall-through between switch labels xpcom/glue/nsTextFormatter.cpp:355:5 [-Wimplicit-fallthrough] unannotated fall-through between switch labels xpcom/glue/nsTextFormatter.cpp:362:5 [-Wimplicit-fallthrough] unannotated fall-through between switch labels xpcom/io/nsWildCard.cpp:85:7 [-Wimplicit-fallthrough] unannotated fall-through between switch labels xpcom/io/nsWildCard.cpp:401:7 [-Wimplicit-fallthrough] unannotated fall-through between switch labels --- xpcom/base/nsDebugImpl.cpp | 2 +- xpcom/ds/nsCheapSets.h | 3 ++- xpcom/ds/nsPersistentProperties.cpp | 2 +- xpcom/ds/nsVariant.cpp | 7 +++++-- xpcom/glue/nsTextFormatter.cpp | 4 ++-- xpcom/io/nsWildCard.cpp | 5 ++--- 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/xpcom/base/nsDebugImpl.cpp b/xpcom/base/nsDebugImpl.cpp index c5f1204276f..afc3fbe4947 100644 --- a/xpcom/base/nsDebugImpl.cpp +++ b/xpcom/base/nsDebugImpl.cpp @@ -433,6 +433,7 @@ NS_DebugBreak(uint32_t aSeverity, const char* aStr, const char* aExpr, nsTraceRefcnt::WalkTheStack(stderr); #endif // !defined(MOZILLA_XPCOMRT_API) // Fall through to abort + MOZ_FALLTHROUGH; case NS_ASSERT_ABORT: Abort(buf.buffer); @@ -607,4 +608,3 @@ NS_ABORT_OOM(size_t aSize) #endif MOZ_CRASH(); } - diff --git a/xpcom/ds/nsCheapSets.h b/xpcom/ds/nsCheapSets.h index e61febffe5a..1401bc5f1a2 100644 --- a/xpcom/ds/nsCheapSets.h +++ b/xpcom/ds/nsCheapSets.h @@ -135,7 +135,8 @@ nsCheapSet::Put(const KeyType aVal) mUnion.table = table; mState = MANY; } - // Fall through. + MOZ_FALLTHROUGH; + case MANY: mUnion.table->PutEntry(aVal); return NS_OK; diff --git a/xpcom/ds/nsPersistentProperties.cpp b/xpcom/ds/nsPersistentProperties.cpp index 8f62bec775b..f783e21d82e 100644 --- a/xpcom/ds/nsPersistentProperties.cpp +++ b/xpcom/ds/nsPersistentProperties.cpp @@ -227,7 +227,7 @@ nsPropertiesParser::ParseValueCharacter(char16_t aChar, const char16_t* aCur, aTokenStart = aCur + 1; break; } - // no break + MOZ_FALLTHROUGH; case '\r': // we're done! We have a key and value diff --git a/xpcom/ds/nsVariant.cpp b/xpcom/ds/nsVariant.cpp index 1c4ad76289c..fc4c6d11ff0 100644 --- a/xpcom/ds/nsVariant.cpp +++ b/xpcom/ds/nsVariant.cpp @@ -356,7 +356,8 @@ CloneArray(uint16_t aInType, const nsIID* aInIID, if (aOutIID) { *aOutIID = *aInIID; } - // fall through... + MOZ_FALLTHROUGH; + case nsIDataType::VTYPE_INTERFACE: { memcpy(*aOutValue, aInValue, allocSize); @@ -759,7 +760,7 @@ nsDiscriminatedUnion::ToString(nsACString& aOutString) const case nsIDataType::VTYPE_WSTRING_SIZE_IS: case nsIDataType::VTYPE_WCHAR: NS_ERROR("ToString being called for a string type - screwy logic!"); - // fall through... + MOZ_FALLTHROUGH; // XXX We might want stringified versions of these... ??? @@ -1654,10 +1655,12 @@ nsDiscriminatedUnion::Traverse(nsCycleCollectionTraversalCallback& aCb) const NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(aCb, "mData[i]"); aCb.NoteXPCOMChild(*p); } + break; } default: break; } + break; default: break; } diff --git a/xpcom/glue/nsTextFormatter.cpp b/xpcom/glue/nsTextFormatter.cpp index c361ca9f1ef..cceec274c59 100644 --- a/xpcom/glue/nsTextFormatter.cpp +++ b/xpcom/glue/nsTextFormatter.cpp @@ -351,14 +351,14 @@ cvt_f(SprintfState* aState, double aDouble, int aWidth, int aPrec, break; case 'E': exp = 'E'; - // no break + MOZ_FALLTHROUGH; case 'e': numdigits = aPrec + 1; mode = 2; break; case 'G': exp = 'E'; - // no break + MOZ_FALLTHROUGH; case 'g': if (aPrec == 0) { aPrec = 1; diff --git a/xpcom/io/nsWildCard.cpp b/xpcom/io/nsWildCard.cpp index 9b8ab8112b5..9125cbbb8f6 100644 --- a/xpcom/io/nsWildCard.cpp +++ b/xpcom/io/nsWildCard.cpp @@ -81,7 +81,7 @@ _valid_subexp(const T* aExpr, T aStop1, T aStop2) return INVALID_SXP; } ++tld; - /* fall through */ + MOZ_FALLTHROUGH; case '*': case '?': case '$': @@ -397,7 +397,7 @@ _shexp_match(const T* aStr, const T* aExpr, bool aCaseInsensitive, return ABORTED; case '\\': ++y; - /* fall through */ + MOZ_FALLTHROUGH; default: if (aCaseInsensitive) { if (::upper(aStr[x]) != ::upper(aExpr[y])) { @@ -414,7 +414,6 @@ _shexp_match(const T* aStr, const T* aExpr, bool aCaseInsensitive, return (aStr[x] ? NOMATCH : MATCH); } - template static int ns_WildCardMatch(const T* aStr, const T* aXp, bool aCaseInsensitive)