From 0dbaae1ce2e5d050c430fee328aff1bede204bb9 Mon Sep 17 00:00:00 2001 From: Chris Peterson Date: Mon, 7 Sep 2015 23:56:16 -0700 Subject: [PATCH] Bug 1204403 - Fix -Wshadow warnings in xpcom. r=mccr8 --- xpcom/base/SystemMemoryReporter.cpp | 33 ++-- xpcom/base/moz.build | 3 + xpcom/base/nsStatusReporterManager.cpp | 6 +- xpcom/build/moz.build | 1 + xpcom/ds/moz.build | 3 + xpcom/ds/nsVariant.cpp | 6 +- xpcom/glue/GenericModule.cpp | 14 +- xpcom/glue/moz.build | 3 + xpcom/glue/nsCRTGlue.cpp | 18 +- xpcom/glue/nsTArray-inl.h | 4 +- xpcom/glue/tests/gtest/TestThreadUtils.cpp | 186 ++++++++++---------- xpcom/io/moz.build | 1 + xpcom/io/nsEscape.cpp | 42 +++-- xpcom/io/nsLocalFileCommon.cpp | 6 +- xpcom/io/nsMultiplexInputStream.cpp | 9 +- xpcom/libxpcomrt/moz.build | 3 + xpcom/reflect/xptcall/md/unix/moz.build | 3 + xpcom/reflect/xptinfo/xptiInterfaceInfo.cpp | 6 +- xpcom/string/moz.build | 3 + xpcom/tests/TestHashtables.cpp | 8 +- xpcom/tests/TestRacingServiceManager.cpp | 14 +- xpcom/tests/bug656331_component/moz.build | 3 + xpcom/tests/gtest/moz.build | 3 + xpcom/tests/moz.build | 3 + xpcom/tests/nsIFileEnumerator.cpp | 18 +- xpcom/typelib/xpt/moz.build | 3 + 26 files changed, 215 insertions(+), 187 deletions(-) diff --git a/xpcom/base/SystemMemoryReporter.cpp b/xpcom/base/SystemMemoryReporter.cpp index 37ec77d68249..3438686dbd20 100644 --- a/xpcom/base/SystemMemoryReporter.cpp +++ b/xpcom/base/SystemMemoryReporter.cpp @@ -144,13 +144,13 @@ public: do { \ size_t amount = _amount; /* evaluate _amount only once */ \ if (amount > 0) { \ - nsresult rv; \ - rv = aHandleReport->Callback(NS_LITERAL_CSTRING("System"), _path, \ + nsresult rvReport; \ + rvReport = aHandleReport->Callback(NS_LITERAL_CSTRING("System"), _path, \ KIND_NONHEAP, _units, amount, _desc, \ aData); \ - if (NS_WARN_IF(NS_FAILED(rv))) { \ + if (NS_WARN_IF(NS_FAILED(rvReport))) { \ _cleanup; \ - return rv; \ + return rvReport; \ } \ } \ } while (0) @@ -373,14 +373,15 @@ private: char devMinor[17]; unsigned int inode; char line[1025]; + // This variable holds the path of the current entry, or is void // if we're scanning for the start of a new entry. - nsAutoCString path; + nsAutoCString currentPath; int pathOffset; - path.SetIsVoid(true); + currentPath.SetIsVoid(true); while (fgets(line, sizeof(line), aFile)) { - if (path.IsVoid()) { + if (currentPath.IsVoid()) { int n = sscanf(line, "%llx-%llx %4s %llx " "%16[0-9a-fA-F]:%16[0-9a-fA-F] %u %n", @@ -388,8 +389,8 @@ private: devMinor, &inode, &pathOffset); if (n >= argCount - 1) { - path.Assign(line + pathOffset); - path.StripChars("\n"); + currentPath.Assign(line + pathOffset); + currentPath.StripChars("\n"); } continue; } @@ -404,14 +405,14 @@ private: size_t pss = pss_kb * 1024; if (pss > 0) { nsAutoCString name, description, tag; - GetReporterNameAndDescription(path.get(), perms, name, description, tag); + GetReporterNameAndDescription(currentPath.get(), perms, name, description, tag); - nsAutoCString path("mem/processes/"); - path.Append(aProcessName); - path.Append('/'); - path.Append(name); + nsAutoCString processMemPath("mem/processes/"); + processMemPath.Append(aProcessName); + processMemPath.Append('/'); + processMemPath.Append(name); - REPORT(path, pss, description); + REPORT(processMemPath, pss, description); // Increment the appropriate aProcessSizes values, and the total. aProcessSizes->Add(tag, pss); @@ -419,7 +420,7 @@ private: } // Now that we've seen the PSS, we're done with this entry. - path.SetIsVoid(true); + currentPath.SetIsVoid(true); } return NS_OK; } diff --git a/xpcom/base/moz.build b/xpcom/base/moz.build index f2027b2e1a56..34a899df0229 100644 --- a/xpcom/base/moz.build +++ b/xpcom/base/moz.build @@ -152,3 +152,6 @@ LOCAL_INCLUDES += [ if CONFIG['MOZ_WIDGET_GTK']: CXXFLAGS += CONFIG['TK_CFLAGS'] + +if CONFIG['GNU_CXX']: + CXXFLAGS += ['-Wshadow'] diff --git a/xpcom/base/nsStatusReporterManager.cpp b/xpcom/base/nsStatusReporterManager.cpp index e851ef7a10e1..5677b071deb5 100644 --- a/xpcom/base/nsStatusReporterManager.cpp +++ b/xpcom/base/nsStatusReporterManager.cpp @@ -78,9 +78,9 @@ NS_STATUS_REPORTER_IMPLEMENT(StatusReporter, "StatusReporter State", getStatus) do { \ const char* s2 = (s); \ uint32_t dummy; \ - nsresult rv = (o)->Write((s2), strlen(s2), &dummy); \ - if (NS_WARN_IF(NS_FAILED(rv))) \ - return rv; \ + nsresult rvDump = (o)->Write((s2), strlen(s2), &dummy); \ + if (NS_WARN_IF(NS_FAILED(rvDump))) \ + return rvDump; \ } while (0) static nsresult diff --git a/xpcom/build/moz.build b/xpcom/build/moz.build index bd97e00eb389..f6a5800e3843 100644 --- a/xpcom/build/moz.build +++ b/xpcom/build/moz.build @@ -70,6 +70,7 @@ SOURCES += [ if CONFIG['GNU_CC']: CFLAGS += ['-Wshadow'] + CXXFLAGS += ['-Wshadow'] include('/ipc/chromium/chromium-config.mozbuild') diff --git a/xpcom/ds/moz.build b/xpcom/ds/moz.build index 257b6540b6c2..08056079e6b6 100644 --- a/xpcom/ds/moz.build +++ b/xpcom/ds/moz.build @@ -100,3 +100,6 @@ LOCAL_INCLUDES += [ ] FINAL_LIBRARY = 'xul' + +if CONFIG['GNU_CXX']: + CXXFLAGS += ['-Wshadow'] diff --git a/xpcom/ds/nsVariant.cpp b/xpcom/ds/nsVariant.cpp index 9bd98e2aef23..4cff91b94739 100644 --- a/xpcom/ds/nsVariant.cpp +++ b/xpcom/ds/nsVariant.cpp @@ -1016,9 +1016,9 @@ nsDiscriminatedUnion::ConvertToStringWithSize(uint32_t* aSize, char** aStr) cons // *aSize = *mUTF8StringValue->Length(); // *aStr = ToNewCString(*mUTF8StringValue); // But this will have to do for now. - NS_ConvertUTF8toUTF16 tempString(*u.mUTF8StringValue); - *aSize = tempString.Length(); - *aStr = ToNewCString(tempString); + const NS_ConvertUTF8toUTF16 tempString16(*u.mUTF8StringValue); + *aSize = tempString16.Length(); + *aStr = ToNewCString(tempString16); break; } case nsIDataType::VTYPE_CHAR_STR: { diff --git a/xpcom/glue/GenericModule.cpp b/xpcom/glue/GenericModule.cpp index f2260a13f71f..0b5cd3a7c24e 100644 --- a/xpcom/glue/GenericModule.cpp +++ b/xpcom/glue/GenericModule.cpp @@ -50,17 +50,17 @@ GenericModule::RegisterSelf(nsIComponentManager* aCompMgr, const char* aLoaderStr, const char* aType) { - nsCOMPtr r = do_QueryInterface(aCompMgr); + nsCOMPtr registrar = do_QueryInterface(aCompMgr); for (const Module::CIDEntry* e = mData->mCIDs; e->cid; ++e) { - r->RegisterFactoryLocation(*e->cid, "", nullptr, aLocation, - aLoaderStr, aType); + registrar->RegisterFactoryLocation(*e->cid, "", nullptr, aLocation, + aLoaderStr, aType); } for (const Module::ContractIDEntry* e = mData->mContractIDs; e && e->contractid; ++e) { - r->RegisterFactoryLocation(*e->cid, "", e->contractid, aLocation, - aLoaderStr, aType); + registrar->RegisterFactoryLocation(*e->cid, "", e->contractid, aLocation, + aLoaderStr, aType); } nsCOMPtr catman; @@ -71,9 +71,9 @@ GenericModule::RegisterSelf(nsIComponentManager* aCompMgr, catman = do_GetService(NS_CATEGORYMANAGER_CONTRACTID); } - nsAutoCString r; + nsAutoCString prevValue; catman->AddCategoryEntry(e->category, e->entry, e->value, true, true, - getter_Copies(r)); + getter_Copies(prevValue)); } return NS_OK; } diff --git a/xpcom/glue/moz.build b/xpcom/glue/moz.build index 037abaf69d45..be3cdbf4bd20 100644 --- a/xpcom/glue/moz.build +++ b/xpcom/glue/moz.build @@ -120,3 +120,6 @@ USE_LIBS += [ NO_EXPAND_LIBS = True DIST_INSTALL = True + +if CONFIG['GNU_CXX']: + CXXFLAGS += ['-Wshadow'] diff --git a/xpcom/glue/nsCRTGlue.cpp b/xpcom/glue/nsCRTGlue.cpp index d95a0d69e4cf..1bc4377a3f16 100644 --- a/xpcom/glue/nsCRTGlue.cpp +++ b/xpcom/glue/nsCRTGlue.cpp @@ -278,19 +278,19 @@ NS_IsAsciiDigit(char16_t aChar) return aChar >= '0' && aChar <= '9'; } - #ifndef XPCOM_GLUE_AVOID_NSPR -#define TABLE_SIZE 36 -static const char table[] = { - 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', - 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', - 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', - '4', '5', '6', '7', '8', '9' -}; void NS_MakeRandomString(char* aBuf, int32_t aBufLen) { +#define TABLE_SIZE 36 + static const char table[] = { + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', + 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', + 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', + '4', '5', '6', '7', '8', '9' + }; + // turn PR_Now() into milliseconds since epoch // and salt rand with that. static unsigned int seed = 0; @@ -435,5 +435,3 @@ fprintf_stderr(FILE* aFile, const char* aFmt, ...) } va_end(args); } - - diff --git a/xpcom/glue/nsTArray-inl.h b/xpcom/glue/nsTArray-inl.h index 8017714e81ab..9683d9c597cc 100644 --- a/xpcom/glue/nsTArray-inl.h +++ b/xpcom/glue/nsTArray-inl.h @@ -267,8 +267,8 @@ nsTArray_base::ShiftData(index_type aStart, aStart *= aElemSize; aNewLen *= aElemSize; aOldLen *= aElemSize; - char* base = reinterpret_cast(mHdr + 1) + aStart; - Copy::MoveElements(base + aNewLen, base + aOldLen, num, aElemSize); + char* baseAddr = reinterpret_cast(mHdr + 1) + aStart; + Copy::MoveElements(baseAddr + aNewLen, baseAddr + aOldLen, num, aElemSize); } } diff --git a/xpcom/glue/tests/gtest/TestThreadUtils.cpp b/xpcom/glue/tests/gtest/TestThreadUtils.cpp index 9884d2b7e87a..fc7509972fab 100644 --- a/xpcom/glue/tests/gtest/TestThreadUtils.cpp +++ b/xpcom/glue/tests/gtest/TestThreadUtils.cpp @@ -289,20 +289,20 @@ TEST(ThreadUtils, main) // Test legacy functions. - nsCOMPtr r = + nsCOMPtr r1 = NS_NewRunnableMethod(rpt, &ThreadUtilsObject::Test0); - r->Run(); + r1->Run(); EXPECT_EQ(count += 1, rpt->mCount); - r = NS_NewRunnableMethodWithArg(rpt, &ThreadUtilsObject::Test1i, 11); - r->Run(); + r1 = NS_NewRunnableMethodWithArg(rpt, &ThreadUtilsObject::Test1i, 11); + r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); EXPECT_EQ(11, rpt->mA0); // Test variadic function with simple POD arguments. - r = NS_NewRunnableMethodWithArgs(rpt, &ThreadUtilsObject::Test0); - r->Run(); + r1 = NS_NewRunnableMethodWithArgs(rpt, &ThreadUtilsObject::Test0); + r1->Run(); EXPECT_EQ(count += 1, rpt->mCount); static_assert( @@ -314,29 +314,29 @@ TEST(ThreadUtils, main) StoreCopyPassByValue>::value, "detail::ParameterStorage>::Type should be StoreCopyPassByValue"); - r = NS_NewRunnableMethodWithArgs(rpt, &ThreadUtilsObject::Test1i, 12); - r->Run(); + r1 = NS_NewRunnableMethodWithArgs(rpt, &ThreadUtilsObject::Test1i, 12); + r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); EXPECT_EQ(12, rpt->mA0); - r = NS_NewRunnableMethodWithArgs( - rpt, &ThreadUtilsObject::Test2i, 21, 22); - r->Run(); + r1 = NS_NewRunnableMethodWithArgs( + rpt, &ThreadUtilsObject::Test2i, 21, 22); + r1->Run(); EXPECT_EQ(count += 3, rpt->mCount); EXPECT_EQ(21, rpt->mA0); EXPECT_EQ(22, rpt->mA1); - r = NS_NewRunnableMethodWithArgs( - rpt, &ThreadUtilsObject::Test3i, 31, 32, 33); - r->Run(); + r1 = NS_NewRunnableMethodWithArgs( + rpt, &ThreadUtilsObject::Test3i, 31, 32, 33); + r1->Run(); EXPECT_EQ(count += 4, rpt->mCount); EXPECT_EQ(31, rpt->mA0); EXPECT_EQ(32, rpt->mA1); EXPECT_EQ(33, rpt->mA2); - r = NS_NewRunnableMethodWithArgs( - rpt, &ThreadUtilsObject::Test4i, 41, 42, 43, 44); - r->Run(); + r1 = NS_NewRunnableMethodWithArgs( + rpt, &ThreadUtilsObject::Test4i, 41, 42, 43, 44); + r1->Run(); EXPECT_EQ(count += 5, rpt->mCount); EXPECT_EQ(41, rpt->mA0); EXPECT_EQ(42, rpt->mA1); @@ -347,8 +347,8 @@ TEST(ThreadUtils, main) // Passing a short to make sure forwarding works with an inexact type match. short int si = 11; - r = NS_NewRunnableMethodWithArgs(rpt, &ThreadUtilsObject::Test1i, si); - r->Run(); + r1 = NS_NewRunnableMethodWithArgs(rpt, &ThreadUtilsObject::Test1i, si); + r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); EXPECT_EQ(si, rpt->mA0); @@ -373,8 +373,8 @@ TEST(ThreadUtils, main) "detail::ParameterStorage::Type::passed_type should be int*"); { int i = 12; - r = NS_NewRunnableMethodWithArgs(rpt, &ThreadUtilsObject::Test1pi, &i); - r->Run(); + r1 = NS_NewRunnableMethodWithArgs(rpt, &ThreadUtilsObject::Test1pi, &i); + r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); EXPECT_EQ(i, rpt->mA0); } @@ -400,8 +400,8 @@ TEST(ThreadUtils, main) "detail::ParameterStorage::Type::passed_type should be const int*"); { int i = 1201; - r = NS_NewRunnableMethodWithArgs(rpt, &ThreadUtilsObject::Test1pci, &i); - r->Run(); + r1 = NS_NewRunnableMethodWithArgs(rpt, &ThreadUtilsObject::Test1pci, &i); + r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); EXPECT_EQ(i, rpt->mA0); } @@ -415,9 +415,9 @@ TEST(ThreadUtils, main) "StoreCopyPassByPtr::passed_type should be int*"); { int i = 1202; - r = NS_NewRunnableMethodWithArgs>( - rpt, &ThreadUtilsObject::Test1pi, i); - r->Run(); + r1 = NS_NewRunnableMethodWithArgs>( + rpt, &ThreadUtilsObject::Test1pi, i); + r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); EXPECT_EQ(i, rpt->mA0); } @@ -431,9 +431,9 @@ TEST(ThreadUtils, main) "StoreCopyPassByConstPtr::passed_type should be const int*"); { int i = 1203; - r = NS_NewRunnableMethodWithArgs>( - rpt, &ThreadUtilsObject::Test1pci, i); - r->Run(); + r1 = NS_NewRunnableMethodWithArgs>( + rpt, &ThreadUtilsObject::Test1pci, i); + r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); EXPECT_EQ(i, rpt->mA0); } @@ -491,8 +491,8 @@ TEST(ThreadUtils, main) "ParameterStorage::Type::passed_type should be int&"); { int i = 13; - r = NS_NewRunnableMethodWithArgs(rpt, &ThreadUtilsObject::Test1ri, i); - r->Run(); + r1 = NS_NewRunnableMethodWithArgs(rpt, &ThreadUtilsObject::Test1ri, i); + r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); EXPECT_EQ(i, rpt->mA0); } @@ -512,10 +512,10 @@ TEST(ThreadUtils, main) "ParameterStorage::Type::passed_type should be int&&"); { int i = 14; - r = NS_NewRunnableMethodWithArgs( + r1 = NS_NewRunnableMethodWithArgs( rpt, &ThreadUtilsObject::Test1rri, mozilla::Move(i)); } - r->Run(); + r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); EXPECT_EQ(14, rpt->mA0); @@ -534,10 +534,10 @@ TEST(ThreadUtils, main) "ParameterStorage&&>::Type::passed_type should be UniquePtr&&"); { mozilla::UniquePtr upi; - r = NS_NewRunnableMethodWithArgs&&>( + r1 = NS_NewRunnableMethodWithArgs&&>( rpt, &ThreadUtilsObject::Test1upi, mozilla::Move(upi)); } - r->Run(); + r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); EXPECT_EQ(-1, rpt->mA0); rpt->mA0 = 0; @@ -557,48 +557,48 @@ TEST(ThreadUtils, main) "ParameterStorage>>::Type::passed_type should be UniquePtr&&"); { mozilla::UniquePtr upi; - r = NS_NewRunnableMethodWithArgs - >>( - rpt, &ThreadUtilsObject::Test1upi, mozilla::Move(upi)); + r1 = NS_NewRunnableMethodWithArgs + >>( + rpt, &ThreadUtilsObject::Test1upi, mozilla::Move(upi)); } - r->Run(); + r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); EXPECT_EQ(-1, rpt->mA0); // Unique pointer as xvalue. { mozilla::UniquePtr upi = mozilla::MakeUnique(1); - r = NS_NewRunnableMethodWithArgs&&>( - rpt, &ThreadUtilsObject::Test1upi, mozilla::Move(upi)); + r1 = NS_NewRunnableMethodWithArgs&&>( + rpt, &ThreadUtilsObject::Test1upi, mozilla::Move(upi)); } - r->Run(); + r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); EXPECT_EQ(1, rpt->mA0); { mozilla::UniquePtr upi = mozilla::MakeUnique(1); - r = NS_NewRunnableMethodWithArgs - >> - (rpt, &ThreadUtilsObject::Test1upi, mozilla::Move(upi)); + r1 = NS_NewRunnableMethodWithArgs + >> + (rpt, &ThreadUtilsObject::Test1upi, mozilla::Move(upi)); } - r->Run(); + r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); EXPECT_EQ(1, rpt->mA0); // Unique pointer as prvalue. - r = NS_NewRunnableMethodWithArgs&&>( - rpt, &ThreadUtilsObject::Test1upi, mozilla::MakeUnique(2)); - r->Run(); + r1 = NS_NewRunnableMethodWithArgs&&>( + rpt, &ThreadUtilsObject::Test1upi, mozilla::MakeUnique(2)); + r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); EXPECT_EQ(2, rpt->mA0); // Unique pointer as lvalue to lref. { mozilla::UniquePtr upi; - r = NS_NewRunnableMethodWithArgs&>( - rpt, &ThreadUtilsObject::Test1rupi, upi); + r1 = NS_NewRunnableMethodWithArgs&>( + rpt, &ThreadUtilsObject::Test1rupi, upi); // Passed as lref, so Run() must be called while local upi is still alive! - r->Run(); + r1->Run(); } EXPECT_EQ(count += 2, rpt->mCount); EXPECT_EQ(-1, rpt->mA0); @@ -608,15 +608,15 @@ TEST(ThreadUtils, main) Spy::ClearAll(); if (gDebug) { printf("%d - Test: Store copy from lvalue, pass by value\n", __LINE__); } { // Block around nsCOMPtr lifetime. - nsCOMPtr r; + nsCOMPtr r2; { // Block around Spy lifetime. if (gDebug) { printf("%d - Spy s(10)\n", __LINE__); } Spy s(10); EXPECT_EQ(1, gConstructions); EXPECT_EQ(1, gAlive); - if (gDebug) { printf("%d - r = NS_NewRunnableMethodWithArgs>(&TestByValue, s)\n", __LINE__); } - r = NS_NewRunnableMethodWithArgs>( - rpt, &ThreadUtilsObject::TestByValue, s); + if (gDebug) { printf("%d - r2 = NS_NewRunnableMethodWithArgs>(&TestByValue, s)\n", __LINE__); } + r2 = NS_NewRunnableMethodWithArgs>( + rpt, &ThreadUtilsObject::TestByValue, s); EXPECT_EQ(2, gAlive); EXPECT_LE(1, gCopyConstructions); // At least 1 copy-construction. Spy::ClearActions(); @@ -626,7 +626,7 @@ TEST(ThreadUtils, main) EXPECT_EQ(1, gAlive); Spy::ClearActions(); if (gDebug) { printf("%d - Run()\n", __LINE__); } - r->Run(); + r2->Run(); EXPECT_LE(1, gCopyConstructions); // Another copy-construction in call. EXPECT_EQ(10, rpt->mSpy.mID); EXPECT_LE(1, gDestructions); @@ -641,8 +641,8 @@ TEST(ThreadUtils, main) Spy::ClearAll(); if (gDebug) { printf("%d - Test: Store copy from prvalue, pass by value\n", __LINE__); } { - if (gDebug) { printf("%d - r = NS_NewRunnableMethodWithArgs>(&TestByValue, Spy(11))\n", __LINE__); } - nsCOMPtr r = + if (gDebug) { printf("%d - r3 = NS_NewRunnableMethodWithArgs>(&TestByValue, Spy(11))\n", __LINE__); } + nsCOMPtr r3 = NS_NewRunnableMethodWithArgs>( rpt, &ThreadUtilsObject::TestByValue, Spy(11)); EXPECT_EQ(1, gAlive); @@ -650,7 +650,7 @@ TEST(ThreadUtils, main) EXPECT_LE(1, gMoveConstructions); Spy::ClearActions(); if (gDebug) { printf("%d - Run()\n", __LINE__); } - r->Run(); + r3->Run(); EXPECT_LE(1, gCopyConstructions); // Another copy-construction in call. EXPECT_EQ(11, rpt->mSpy.mID); EXPECT_LE(1, gDestructions); @@ -664,13 +664,13 @@ TEST(ThreadUtils, main) Spy::ClearAll(); { // Store copy from xvalue, pass by value. - nsCOMPtr r; + nsCOMPtr r4; { Spy s(12); EXPECT_EQ(1, gConstructions); EXPECT_EQ(1, gAlive); Spy::ClearActions(); - r = NS_NewRunnableMethodWithArgs>( + r4 = NS_NewRunnableMethodWithArgs>( rpt, &ThreadUtilsObject::TestByValue, mozilla::Move(s)); EXPECT_LE(1, gMoveConstructions); EXPECT_EQ(1, gAlive); @@ -681,7 +681,7 @@ TEST(ThreadUtils, main) EXPECT_EQ(1, gAlive); EXPECT_EQ(0, gZombies); Spy::ClearActions(); - r->Run(); + r4->Run(); EXPECT_LE(1, gCopyConstructions); // Another copy-construction in call. EXPECT_EQ(12, rpt->mSpy.mID); EXPECT_LE(1, gDestructions); @@ -695,15 +695,15 @@ TEST(ThreadUtils, main) Spy::ClearAll(); if (gDebug) { printf("%d - Test: Store copy from lvalue, pass by const lvalue ref\n", __LINE__); } { // Block around nsCOMPtr lifetime. - nsCOMPtr r; + nsCOMPtr r5; { // Block around Spy lifetime. if (gDebug) { printf("%d - Spy s(20)\n", __LINE__); } Spy s(20); EXPECT_EQ(1, gConstructions); EXPECT_EQ(1, gAlive); - if (gDebug) { printf("%d - r = NS_NewRunnableMethodWithArgs>(&TestByConstLRef, s)\n", __LINE__); } - r = NS_NewRunnableMethodWithArgs>( - rpt, &ThreadUtilsObject::TestByConstLRef, s); + if (gDebug) { printf("%d - r5 = NS_NewRunnableMethodWithArgs>(&TestByConstLRef, s)\n", __LINE__); } + r5 = NS_NewRunnableMethodWithArgs>( + rpt, &ThreadUtilsObject::TestByConstLRef, s); EXPECT_EQ(2, gAlive); EXPECT_LE(1, gCopyConstructions); // At least 1 copy-construction. Spy::ClearActions(); @@ -713,7 +713,7 @@ TEST(ThreadUtils, main) EXPECT_EQ(1, gAlive); Spy::ClearActions(); if (gDebug) { printf("%d - Run()\n", __LINE__); } - r->Run(); + r5->Run(); EXPECT_EQ(0, gCopyConstructions); // No copies in call. EXPECT_EQ(20, rpt->mSpy.mID); EXPECT_EQ(0, gDestructions); @@ -728,8 +728,8 @@ TEST(ThreadUtils, main) Spy::ClearAll(); if (gDebug) { printf("%d - Test: Store copy from prvalue, pass by const lvalue ref\n", __LINE__); } { - if (gDebug) { printf("%d - r = NS_NewRunnableMethodWithArgs>(&TestByConstLRef, Spy(21))\n", __LINE__); } - nsCOMPtr r = + if (gDebug) { printf("%d - r6 = NS_NewRunnableMethodWithArgs>(&TestByConstLRef, Spy(21))\n", __LINE__); } + nsCOMPtr r6 = NS_NewRunnableMethodWithArgs>( rpt, &ThreadUtilsObject::TestByConstLRef, Spy(21)); EXPECT_EQ(1, gAlive); @@ -737,7 +737,7 @@ TEST(ThreadUtils, main) EXPECT_LE(1, gMoveConstructions); Spy::ClearActions(); if (gDebug) { printf("%d - Run()\n", __LINE__); } - r->Run(); + r6->Run(); EXPECT_EQ(0, gCopyConstructions); // No copies in call. EXPECT_EQ(21, rpt->mSpy.mID); EXPECT_EQ(0, gDestructions); @@ -752,15 +752,15 @@ TEST(ThreadUtils, main) Spy::ClearAll(); if (gDebug) { printf("%d - Test: Store copy from lvalue, pass by rvalue ref\n", __LINE__); } { // Block around nsCOMPtr lifetime. - nsCOMPtr r; + nsCOMPtr r7; { // Block around Spy lifetime. if (gDebug) { printf("%d - Spy s(30)\n", __LINE__); } Spy s(30); EXPECT_EQ(1, gConstructions); EXPECT_EQ(1, gAlive); - if (gDebug) { printf("%d - r = NS_NewRunnableMethodWithArgs>(&TestByRRef, s)\n", __LINE__); } - r = NS_NewRunnableMethodWithArgs>( - rpt, &ThreadUtilsObject::TestByRRef, s); + if (gDebug) { printf("%d - r7 = NS_NewRunnableMethodWithArgs>(&TestByRRef, s)\n", __LINE__); } + r7 = NS_NewRunnableMethodWithArgs>( + rpt, &ThreadUtilsObject::TestByRRef, s); EXPECT_EQ(2, gAlive); EXPECT_LE(1, gCopyConstructions); // At least 1 copy-construction. Spy::ClearActions(); @@ -770,7 +770,7 @@ TEST(ThreadUtils, main) EXPECT_EQ(1, gAlive); Spy::ClearActions(); if (gDebug) { printf("%d - Run()\n", __LINE__); } - r->Run(); + r7->Run(); EXPECT_LE(1, gMoves); // Move in call. EXPECT_EQ(30, rpt->mSpy.mID); EXPECT_EQ(0, gDestructions); @@ -786,8 +786,8 @@ TEST(ThreadUtils, main) Spy::ClearAll(); if (gDebug) { printf("%d - Test: Store copy from prvalue, pass by rvalue ref\n", __LINE__); } { - if (gDebug) { printf("%d - r = NS_NewRunnableMethodWithArgs>(&TestByRRef, Spy(31))\n", __LINE__); } - nsCOMPtr r = + if (gDebug) { printf("%d - r8 = NS_NewRunnableMethodWithArgs>(&TestByRRef, Spy(31))\n", __LINE__); } + nsCOMPtr r8 = NS_NewRunnableMethodWithArgs>( rpt, &ThreadUtilsObject::TestByRRef, Spy(31)); EXPECT_EQ(1, gAlive); @@ -795,7 +795,7 @@ TEST(ThreadUtils, main) EXPECT_LE(1, gMoveConstructions); Spy::ClearActions(); if (gDebug) { printf("%d - Run()\n", __LINE__); } - r->Run(); + r8->Run(); EXPECT_LE(1, gMoves); // Move in call. EXPECT_EQ(31, rpt->mSpy.mID); EXPECT_EQ(0, gDestructions); @@ -816,8 +816,8 @@ TEST(ThreadUtils, main) EXPECT_EQ(1, gConstructions); EXPECT_EQ(1, gAlive); Spy::ClearActions(); - if (gDebug) { printf("%d - r = NS_NewRunnableMethodWithArgs(&TestByLRef, s)\n", __LINE__); } - nsCOMPtr r = + if (gDebug) { printf("%d - r9 = NS_NewRunnableMethodWithArgs(&TestByLRef, s)\n", __LINE__); } + nsCOMPtr r9 = NS_NewRunnableMethodWithArgs( rpt, &ThreadUtilsObject::TestByLRef, s); EXPECT_EQ(0, gAllConstructions); @@ -825,7 +825,7 @@ TEST(ThreadUtils, main) EXPECT_EQ(1, gAlive); Spy::ClearActions(); if (gDebug) { printf("%d - Run()\n", __LINE__); } - r->Run(); + r9->Run(); EXPECT_LE(1, gAssignments); // Assignment from reference in call. EXPECT_EQ(40, rpt->mSpy.mID); EXPECT_EQ(&s, rpt->mSpyPtr); @@ -841,7 +841,7 @@ TEST(ThreadUtils, main) Spy::ClearAll(); if (gDebug) { printf("%d - Test: Store nsRefPtr, pass by pointer\n", __LINE__); } { // Block around nsCOMPtr lifetime. - nsCOMPtr r; + nsCOMPtr r10; SpyWithISupports* ptr = 0; { // Block around nsRefPtr lifetime. if (gDebug) { printf("%d - nsRefPtr s(new SpyWithISupports(45))\n", __LINE__); } @@ -849,9 +849,9 @@ TEST(ThreadUtils, main) ptr = s.get(); EXPECT_EQ(1, gConstructions); EXPECT_EQ(1, gAlive); - if (gDebug) { printf("%d - r = NS_NewRunnableMethodWithArgs>(&TestByRRef, s.get())\n", __LINE__); } - r = NS_NewRunnableMethodWithArgs>( - rpt, &ThreadUtilsObject::TestByPointer, s.get()); + if (gDebug) { printf("%d - r10 = NS_NewRunnableMethodWithArgs>(&TestByRRef, s.get())\n", __LINE__); } + r10 = NS_NewRunnableMethodWithArgs>( + rpt, &ThreadUtilsObject::TestByPointer, s.get()); EXPECT_LE(0, gAllConstructions); EXPECT_EQ(1, gAlive); Spy::ClearActions(); @@ -861,7 +861,7 @@ TEST(ThreadUtils, main) EXPECT_EQ(1, gAlive); Spy::ClearActions(); if (gDebug) { printf("%d - Run()\n", __LINE__); } - r->Run(); + r10->Run(); EXPECT_LE(1, gAssignments); // Assignment from pointee in call. EXPECT_EQ(45, rpt->mSpy.mID); EXPECT_EQ(ptr, rpt->mSpyPtr); @@ -882,8 +882,8 @@ TEST(ThreadUtils, main) EXPECT_EQ(1, gConstructions); EXPECT_EQ(1, gAlive); Spy::ClearActions(); - if (gDebug) { printf("%d - r = NS_NewRunnableMethodWithArgs(&TestByPointer, s)\n", __LINE__); } - nsCOMPtr r = + if (gDebug) { printf("%d - r11 = NS_NewRunnableMethodWithArgs(&TestByPointer, s)\n", __LINE__); } + nsCOMPtr r11 = NS_NewRunnableMethodWithArgs( rpt, &ThreadUtilsObject::TestByPointer, &s); EXPECT_EQ(0, gAllConstructions); @@ -891,7 +891,7 @@ TEST(ThreadUtils, main) EXPECT_EQ(1, gAlive); Spy::ClearActions(); if (gDebug) { printf("%d - Run()\n", __LINE__); } - r->Run(); + r11->Run(); EXPECT_LE(1, gAssignments); // Assignment from pointee in call. EXPECT_EQ(55, rpt->mSpy.mID); EXPECT_EQ(&s, rpt->mSpyPtr); @@ -912,8 +912,8 @@ TEST(ThreadUtils, main) EXPECT_EQ(1, gConstructions); EXPECT_EQ(1, gAlive); Spy::ClearActions(); - if (gDebug) { printf("%d - r = NS_NewRunnableMethodWithArgs(&TestByPointer, s)\n", __LINE__); } - nsCOMPtr r = + if (gDebug) { printf("%d - r12 = NS_NewRunnableMethodWithArgs(&TestByPointer, s)\n", __LINE__); } + nsCOMPtr r12 = NS_NewRunnableMethodWithArgs( rpt, &ThreadUtilsObject::TestByPointerToConst, &s); EXPECT_EQ(0, gAllConstructions); @@ -921,7 +921,7 @@ TEST(ThreadUtils, main) EXPECT_EQ(1, gAlive); Spy::ClearActions(); if (gDebug) { printf("%d - Run()\n", __LINE__); } - r->Run(); + r12->Run(); EXPECT_LE(1, gAssignments); // Assignment from pointee in call. EXPECT_EQ(60, rpt->mSpy.mID); EXPECT_EQ(&s, rpt->mSpyPtr); diff --git a/xpcom/io/moz.build b/xpcom/io/moz.build index 14006c5a7990..f05e7850c02a 100644 --- a/xpcom/io/moz.build +++ b/xpcom/io/moz.build @@ -125,6 +125,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': if CONFIG['GNU_CC']: CFLAGS += ['-Wshadow'] + CXXFLAGS += ['-Wshadow'] include('/ipc/chromium/chromium-config.mozbuild') diff --git a/xpcom/io/nsEscape.cpp b/xpcom/io/nsEscape.cpp index ca64d93731d2..b5145932c575 100644 --- a/xpcom/io/nsEscape.cpp +++ b/xpcom/io/nsEscape.cpp @@ -12,7 +12,8 @@ #include "nsCRT.h" #include "plstr.h" -static const char hexChars[] = "0123456789ABCDEF"; +static const char hexCharsUpper[] = "0123456789ABCDEF"; +static const char hexCharsUpperLower[] = "0123456789ABCDEFabcdef"; static const int netCharType[256] = /* Bit 0 xalpha -- the alphas @@ -51,8 +52,8 @@ AppendPercentHex(char* aBuffer, unsigned char aChar) { uint32_t i = 0; aBuffer[i++] = '%'; - aBuffer[i++] = hexChars[aChar >> 4]; // high nibble - aBuffer[i++] = hexChars[aChar & 0xF]; // low nibble + aBuffer[i++] = hexCharsUpper[aChar >> 4]; // high nibble + aBuffer[i++] = hexCharsUpper[aChar & 0xF]; // low nibble return i; } @@ -63,11 +64,11 @@ AppendPercentHex(char16_t* aBuffer, char16_t aChar) aBuffer[i++] = '%'; if (aChar & 0xff00) { aBuffer[i++] = 'u'; - aBuffer[i++] = hexChars[aChar >> 12]; // high-byte high nibble - aBuffer[i++] = hexChars[(aChar >> 8) & 0xF]; // high-byte low nibble + aBuffer[i++] = hexCharsUpper[aChar >> 12]; // high-byte high nibble + aBuffer[i++] = hexCharsUpper[(aChar >> 8) & 0xF]; // high-byte low nibble } - aBuffer[i++] = hexChars[(aChar >> 4) & 0xF]; // low-byte high nibble - aBuffer[i++] = hexChars[aChar & 0xF]; // low-byte low nibble + aBuffer[i++] = hexCharsUpper[(aChar >> 4) & 0xF]; // low-byte high nibble + aBuffer[i++] = hexCharsUpper[aChar & 0xF]; // low-byte low nibble return i; } @@ -124,8 +125,8 @@ nsEscapeCount(const char* aStr, nsEscapeMask aFlags, size_t* aOutLen) *dst++ = '+'; /* convert spaces to pluses */ } else { *dst++ = HEX_ESCAPE; - *dst++ = hexChars[c >> 4]; /* high nibble */ - *dst++ = hexChars[c & 0x0f]; /* low nibble */ + *dst++ = hexCharsUpper[c >> 4]; /* high nibble */ + *dst++ = hexCharsUpper[c & 0x0f]; /* low nibble */ } } } else { @@ -135,8 +136,8 @@ nsEscapeCount(const char* aStr, nsEscapeMask aFlags, size_t* aOutLen) *dst++ = c; } else { *dst++ = HEX_ESCAPE; - *dst++ = hexChars[c >> 4]; /* high nibble */ - *dst++ = hexChars[c & 0x0f]; /* low nibble */ + *dst++ = hexCharsUpper[c >> 4]; /* high nibble */ + *dst++ = hexCharsUpper[c & 0x0f]; /* low nibble */ } } } @@ -175,7 +176,6 @@ nsUnescapeCount(char* aStr) { char* src = aStr; char* dst = aStr; - static const char hexChars[] = "0123456789ABCDEFabcdef"; char c1[] = " "; char c2[] = " "; @@ -197,8 +197,8 @@ nsUnescapeCount(char* aStr) c2[0] = *(src + 2); } - if (*src != HEX_ESCAPE || PL_strpbrk(pc1, hexChars) == 0 || - PL_strpbrk(pc2, hexChars) == 0) { + if (*src != HEX_ESCAPE || PL_strpbrk(pc1, hexCharsUpperLower) == 0 || + PL_strpbrk(pc2, hexCharsUpperLower) == 0) { *dst++ = *src++; } else { src++; /* walk over escape */ @@ -498,7 +498,7 @@ NS_EscapeURL(const nsAFlatString& aStr, const nsTArray& aForbidden, nsSubstring& aResult) { bool didEscape = false; - for (size_t i = 0, len = aStr.Length(); i < len; ) { + for (size_t i = 0, strLen = aStr.Length(); i < strLen; ) { size_t j; if (MOZ_UNLIKELY(FindFirstMatchFrom(aStr, i, aForbidden, &j))) { if (i == 0) { @@ -511,14 +511,14 @@ NS_EscapeURL(const nsAFlatString& aStr, const nsTArray& aForbidden, aResult.Append(nsDependentSubstring(aStr, i, j - i)); } char16_t buffer[ENCODE_MAX_LEN]; - uint32_t len = ::AppendPercentHex(buffer, aStr[j]); - MOZ_ASSERT(len <= ENCODE_MAX_LEN, "buffer overflow"); - aResult.Append(buffer, len); + uint32_t bufferLen = ::AppendPercentHex(buffer, aStr[j]); + MOZ_ASSERT(bufferLen <= ENCODE_MAX_LEN, "buffer overflow"); + aResult.Append(buffer, bufferLen); i = j + 1; } else { if (MOZ_UNLIKELY(didEscape)) { // The tail of the string that needs no escaping. - aResult.Append(nsDependentSubstring(aStr, i, len - i)); + aResult.Append(nsDependentSubstring(aStr, i, strLen - i)); } break; } @@ -529,7 +529,7 @@ NS_EscapeURL(const nsAFlatString& aStr, const nsTArray& aForbidden, return aStr; } -#define ISHEX(c) memchr(hexChars, c, sizeof(hexChars)-1) +#define ISHEX(c) memchr(hexCharsUpperLower, c, sizeof(hexCharsUpperLower)-1) bool NS_UnescapeURL(const char* aStr, int32_t aLen, uint32_t aFlags, @@ -549,8 +549,6 @@ NS_UnescapeURL(const char* aStr, int32_t aLen, uint32_t aFlags, bool writing = !!(aFlags & esc_AlwaysCopy); bool skipControl = !!(aFlags & esc_SkipControl); - static const char hexChars[] = "0123456789ABCDEFabcdef"; - const char* last = aStr; const char* p = aStr; diff --git a/xpcom/io/nsLocalFileCommon.cpp b/xpcom/io/nsLocalFileCommon.cpp index 6c2c60c6143f..acdd7a9436dd 100644 --- a/xpcom/io/nsLocalFileCommon.cpp +++ b/xpcom/io/nsLocalFileCommon.cpp @@ -138,9 +138,9 @@ nsLocalFile::CreateUnique(uint32_t aType, uint32_t aAttributes) rootName.SetLength(maxRootLength); SetNativeLeafName(rootName + suffix); #endif - nsresult rv = Create(aType, aAttributes); - if (rv != NS_ERROR_FILE_ALREADY_EXISTS) { - return rv; + nsresult rvCreate = Create(aType, aAttributes); + if (rvCreate != NS_ERROR_FILE_ALREADY_EXISTS) { + return rvCreate; } } diff --git a/xpcom/io/nsMultiplexInputStream.cpp b/xpcom/io/nsMultiplexInputStream.cpp index 4b61d5108cae..69f63f5c768c 100644 --- a/xpcom/io/nsMultiplexInputStream.cpp +++ b/xpcom/io/nsMultiplexInputStream.cpp @@ -99,8 +99,8 @@ AvailableMaybeSeek(nsIInputStream* aStream, uint64_t* aResult) // Seek() could reopen the file if REOPEN_ON_REWIND flag is set. nsCOMPtr seekable = do_QueryInterface(aStream); if (seekable) { - nsresult rv = seekable->Seek(nsISeekableStream::NS_SEEK_CUR, 0); - if (NS_SUCCEEDED(rv)) { + nsresult rvSeek = seekable->Seek(nsISeekableStream::NS_SEEK_CUR, 0); + if (NS_SUCCEEDED(rvSeek)) { rv = aStream->Available(aResult); } } @@ -117,8 +117,8 @@ TellMaybeSeek(nsISeekableStream* aSeekable, int64_t* aResult) // NS_BASE_STREAM_CLOSED. // If nsIFileInputStream is closed in Read() due to CLOSE_ON_EOF flag, // Seek() could reopen the file if REOPEN_ON_REWIND flag is set. - nsresult rv = aSeekable->Seek(nsISeekableStream::NS_SEEK_CUR, 0); - if (NS_SUCCEEDED(rv)) { + nsresult rvSeek = aSeekable->Seek(nsISeekableStream::NS_SEEK_CUR, 0); + if (NS_SUCCEEDED(rvSeek)) { rv = aSeekable->Tell(aResult); } } @@ -828,4 +828,3 @@ nsMultiplexInputStream::Clone(nsIInputStream** aClone) clone.forget(aClone); return NS_OK; } - diff --git a/xpcom/libxpcomrt/moz.build b/xpcom/libxpcomrt/moz.build index 922de9053d80..82c8ac981a63 100644 --- a/xpcom/libxpcomrt/moz.build +++ b/xpcom/libxpcomrt/moz.build @@ -138,3 +138,6 @@ DEFINES['MOZILLA_EXTERNAL_LINKAGE'] = True include('/ipc/chromium/chromium-config.mozbuild') SPHINX_TREES['libxpcomrt'] = 'docs' + +if CONFIG['GNU_CXX']: + CXXFLAGS += ['-Wshadow'] diff --git a/xpcom/reflect/xptcall/md/unix/moz.build b/xpcom/reflect/xptcall/md/unix/moz.build index 00d8cca1b28f..3dad5e63d519 100644 --- a/xpcom/reflect/xptcall/md/unix/moz.build +++ b/xpcom/reflect/xptcall/md/unix/moz.build @@ -325,3 +325,6 @@ LOCAL_INCLUDES += [ ] NO_PGO = True + +if CONFIG['GNU_CXX']: + CXXFLAGS += ['-Wshadow'] diff --git a/xpcom/reflect/xptinfo/xptiInterfaceInfo.cpp b/xpcom/reflect/xptinfo/xptiInterfaceInfo.cpp index db92c3c3ed44..07af453ce90e 100644 --- a/xpcom/reflect/xptinfo/xptiInterfaceInfo.cpp +++ b/xpcom/reflect/xptinfo/xptiInterfaceInfo.cpp @@ -603,11 +603,11 @@ xptiInterfaceEntry::GetInterfaceIsArgNumberForParam(uint16_t methodIndex, return NS_OK; } -nsresult -xptiInterfaceEntry::IsIID(const nsIID * IID, bool *_retval) +nsresult +xptiInterfaceEntry::IsIID(const nsIID * iid, bool *_retval) { // It is not necessary to Resolve because this info is read from manifest. - *_retval = mIID.Equals(*IID); + *_retval = mIID.Equals(*iid); return NS_OK; } diff --git a/xpcom/string/moz.build b/xpcom/string/moz.build index aa3516b75250..8e6096a806b6 100644 --- a/xpcom/string/moz.build +++ b/xpcom/string/moz.build @@ -57,3 +57,6 @@ if CONFIG['INTEL_ARCHITECTURE']: SOURCES['nsUTF8UtilsSSE2.cpp'].flags += CONFIG['SSE2_FLAGS'] FINAL_LIBRARY = 'xul' + +if CONFIG['GNU_CXX']: + CXXFLAGS += ['-Wshadow'] diff --git a/xpcom/tests/TestHashtables.cpp b/xpcom/tests/TestHashtables.cpp index d6ada3f2a710..43c719c452dc 100644 --- a/xpcom/tests/TestHashtables.cpp +++ b/xpcom/tests/TestHashtables.cpp @@ -639,10 +639,10 @@ main(void) { printf("FAILED\n"); exit (30); } - - nsAutoCString str; - myEnt->GetString(str); - printf("Found %s\n", str.get()); + + nsAutoCString myEntStr; + myEnt->GetString(myEntStr); + printf("Found %s\n", myEntStr.get()); } printf("Testing nonexistent entries..."); diff --git a/xpcom/tests/TestRacingServiceManager.cpp b/xpcom/tests/TestRacingServiceManager.cpp index 5051b4aabd20..b1cb6a033baa 100644 --- a/xpcom/tests/TestRacingServiceManager.cpp +++ b/xpcom/tests/TestRacingServiceManager.cpp @@ -259,7 +259,7 @@ int main(int argc, char** argv) ScopedXPCOM xpcom("RacingServiceManager"); NS_ENSURE_FALSE(xpcom.failed(), 1); - AutoCreateAndDestroyReentrantMonitor mon(&gReentrantMonitor); + AutoCreateAndDestroyReentrantMonitor mon1(&gReentrantMonitor); nsRefPtr runnable = new Runnable(); NS_ENSURE_TRUE(runnable, 1); @@ -270,13 +270,13 @@ int main(int argc, char** argv) NS_ENSURE_SUCCESS(rv, 1); { - ReentrantMonitorAutoEnter mon(*gReentrantMonitor); + ReentrantMonitorAutoEnter mon2(*gReentrantMonitor); gMainThreadWaiting = true; - mon.Notify(); + mon2.Notify(); while (!gCreateInstanceCalled) { - mon.Wait(); + mon2.Wait(); } } @@ -292,13 +292,13 @@ int main(int argc, char** argv) NS_ENSURE_SUCCESS(rv, 1); { - ReentrantMonitorAutoEnter mon(*gReentrantMonitor); + ReentrantMonitorAutoEnter mon3(*gReentrantMonitor); gMainThreadWaiting = true; - mon.Notify(); + mon3.Notify(); while (!gCreateInstanceCalled) { - mon.Wait(); + mon3.Wait(); } } diff --git a/xpcom/tests/bug656331_component/moz.build b/xpcom/tests/bug656331_component/moz.build index a8f34881dc10..3683f1ac3a23 100644 --- a/xpcom/tests/bug656331_component/moz.build +++ b/xpcom/tests/bug656331_component/moz.build @@ -21,3 +21,6 @@ DEFINES['LIBRARY_FILENAME'] = '%s%s%s' % ( # Need to link with CoreFoundation on Mac if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': OS_LIBS += CONFIG['TK_LIBS'] + +if CONFIG['GNU_CXX']: + CXXFLAGS += ['-Wshadow'] diff --git a/xpcom/tests/gtest/moz.build b/xpcom/tests/gtest/moz.build index b163ad26ad20..3ac40f7f5f8f 100644 --- a/xpcom/tests/gtest/moz.build +++ b/xpcom/tests/gtest/moz.build @@ -28,3 +28,6 @@ UNIFIED_SOURCES += [ ] FINAL_LIBRARY = 'xul-gtest' + +if CONFIG['GNU_CXX']: + CXXFLAGS += ['-Wshadow'] diff --git a/xpcom/tests/moz.build b/xpcom/tests/moz.build index 4b7df48113b2..abffb597d724 100644 --- a/xpcom/tests/moz.build +++ b/xpcom/tests/moz.build @@ -108,3 +108,6 @@ LOCAL_INCLUDES += [ RESOURCE_FILES += [ 'test.properties', ] + +if CONFIG['GNU_CXX']: + CXXFLAGS += ['-Wshadow'] diff --git a/xpcom/tests/nsIFileEnumerator.cpp b/xpcom/tests/nsIFileEnumerator.cpp index fee7314106a8..471291c3eb79 100644 --- a/xpcom/tests/nsIFileEnumerator.cpp +++ b/xpcom/tests/nsIFileEnumerator.cpp @@ -9,11 +9,11 @@ #include "nsISimpleEnumerator.h" #include "nsCOMPtr.h" -bool LoopInDir(nsIFile* file) +static bool LoopInDir(nsIFile* aFile) { nsresult rv; nsCOMPtr entries; - rv = file->GetDirectoryEntries(getter_AddRefs(entries)); + rv = aFile->GetDirectoryEntries(getter_AddRefs(entries)); if(NS_FAILED(rv) || !entries) return false; @@ -24,18 +24,18 @@ bool LoopInDir(nsIFile* file) entries->GetNext(getter_AddRefs(sup)); if(!sup) return false; - - nsCOMPtr file = do_QueryInterface(sup); - if(!file) + + nsCOMPtr nextFile = do_QueryInterface(sup); + if (!nextFile) return false; nsAutoCString name; - if(NS_FAILED(file->GetNativeLeafName(name))) + if(NS_FAILED(nextFile->GetNativeLeafName(name))) return false; bool isDir; printf("%s\n", name.get()); - rv = file->IsDirectory(&isDir); + rv = nextFile->IsDirectory(&isDir); if (NS_FAILED(rv)) { printf("IsDirectory Failed!!!\n"); @@ -44,8 +44,8 @@ bool LoopInDir(nsIFile* file) if (isDir) { - LoopInDir(file); - } + LoopInDir(nextFile); + } } return true; } diff --git a/xpcom/typelib/xpt/moz.build b/xpcom/typelib/xpt/moz.build index 9e804f584527..c238a4b6fff4 100644 --- a/xpcom/typelib/xpt/moz.build +++ b/xpcom/typelib/xpt/moz.build @@ -36,3 +36,6 @@ if CONFIG['_MSC_VER']: DEFINES['MOZ_NO_MOZALLOC'] = True DIST_INSTALL = True + +if CONFIG['GNU_CXX']: + CXXFLAGS += ['-Wshadow']