Bug 1534878 - xpcom: Make some global functions static. r=erahm
authorChris Peterson <cpeterson@mozilla.com>
Sun, 24 Feb 2019 17:35:59 -0800
changeset 464363 5ff84e853d70
parent 464362 cce7932305d8
child 464364 25fbad7b3214
push id35714
push userapavel@mozilla.com
push dateSat, 16 Mar 2019 09:47:26 +0000
treeherdermozilla-central@124ee436c421 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerserahm
bugs1534878
milestone67.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 1534878 - xpcom: Make some global functions static. r=erahm clang's -Wmissing-prototypes option identifies global functions that can be made static (because they're only called from one compilation unit) or removed (if they're never called). xpcom/base/Logging.cpp:85:13 [-Wmissing-prototypes] no previous prototype for function 'ToLogStr' xpcom/base/Logging.cpp:132:13 [-Wmissing-prototypes] no previous prototype for function 'ExpandPIDMarker' xpcom/base/LogModulePrefWatcher.cpp:37:6 [-Wmissing-prototypes] no previous prototype for function 'ResetExistingPrefs' xpcom/base/LogModulePrefWatcher.cpp:109:6 [-Wmissing-prototypes] no previous prototype for function 'LoadExistingPrefs' xpcom/base/nsCycleCollector.cpp:212:6 [-Wmissing-prototypes] no previous prototype for function 'SuspectUsingNurseryPurpleBuffer' xpcom/components/nsComponentManager.cpp:421:31 [-Wmissing-prototypes] no previous prototype for function 'begin' xpcom/components/nsComponentManager.cpp:427:31 [-Wmissing-prototypes] no previous prototype for function 'end' xpcom/ds/Dafsa.cpp:23:6 [-Wmissing-prototypes] no previous prototype for function 'GetNextOffset' xpcom/ds/Dafsa.cpp:55:6 [-Wmissing-prototypes] no previous prototype for function 'IsEOL' xpcom/ds/Dafsa.cpp:62:6 [-Wmissing-prototypes] no previous prototype for function 'IsMatch' xpcom/ds/Dafsa.cpp:70:6 [-Wmissing-prototypes] no previous prototype for function 'IsEndCharMatch' xpcom/ds/Dafsa.cpp:78:6 [-Wmissing-prototypes] no previous prototype for function 'GetReturnValue' xpcom/ds/Dafsa.cpp:91:5 [-Wmissing-prototypes] no previous prototype for function 'LookupString' xpcom/io/CocoaFileUtils.mm:195:13 [-Wmissing-prototypes] no previous prototype for function 'GetQuarantinePropKey' xpcom/io/CocoaFileUtils.mm:203:24 [-Wmissing-prototypes] no previous prototype for function 'CreateQuarantineDictionary' xpcom/rust/gtest/bench-collections/Bench.cpp:65:11 [-Wmissing-prototypes] no previous prototype for function 'MyRand' xpcom/rust/gtest/bench-collections/Bench.cpp:85:6 [-Wmissing-prototypes] no previous prototype for function 'Bench_Cpp_unordered_set' xpcom/rust/gtest/bench-collections/Bench.cpp:125:6 [-Wmissing-prototypes] no previous prototype for function 'Bench_Cpp_PLDHashTable' xpcom/rust/gtest/bench-collections/Bench.cpp:166:6 [-Wmissing-prototypes] no previous prototype for function 'Bench_Cpp_MozHashSet' xpcom/tests/gtest/TestAtoms.cpp:114:6 [-Wmissing-prototypes] no previous prototype for function 'isStaticAtom' xpcom/tests/gtest/TestCallTemplates.cpp:72:6 [-Wmissing-prototypes] no previous prototype for function 'JustTestingCompilation' xpcom/tests/gtest/TestCOMPtr.cpp:87:10 [-Wmissing-prototypes] no previous prototype for function 'CreateIFoo' xpcom/tests/gtest/TestCOMPtr.cpp:98:6 [-Wmissing-prototypes] no previous prototype for function 'set_a_IFoo' xpcom/tests/gtest/TestCOMPtr.cpp:105:16 [-Wmissing-prototypes] no previous prototype for function 'return_a_IFoo' xpcom/tests/gtest/TestCOMPtr.cpp:164:10 [-Wmissing-prototypes] no previous prototype for function 'CreateIBar' xpcom/tests/gtest/TestCOMPtr.cpp:175:6 [-Wmissing-prototypes] no previous prototype for function 'AnIFooPtrPtrContext' xpcom/tests/gtest/TestCOMPtr.cpp:177:6 [-Wmissing-prototypes] no previous prototype for function 'AVoidPtrPtrContext' xpcom/tests/gtest/TestCOMPtr.cpp:179:6 [-Wmissing-prototypes] no previous prototype for function 'AnISupportsPtrPtrContext' xpcom/tests/gtest/TestCOMPtr.cpp:263:6 [-Wmissing-prototypes] no previous prototype for function 'Comparison' xpcom/tests/gtest/TestCOMPtr.cpp:298:6 [-Wmissing-prototypes] no previous prototype for function 'DontAddRef' xpcom/tests/gtest/TestCRT.cpp:17:5 [-Wmissing-prototypes] no previous prototype for function 'sign' xpcom/tests/gtest/TestDeadlockDetector.cpp:62:6 [-Wmissing-prototypes] no previous prototype for function 'DisableCrashReporter' xpcom/tests/gtest/TestDeadlockDetector.cpp:74:5 [-Wmissing-prototypes] no previous prototype for function 'Sanity_Child' xpcom/tests/gtest/TestDeadlockDetector.cpp:95:5 [-Wmissing-prototypes] no previous prototype for function 'Sanity2_Child' xpcom/tests/gtest/TestDeadlockDetector.cpp:159:5 [-Wmissing-prototypes] no previous prototype for function 'Sanity4_Child' xpcom/tests/gtest/TestDeadlockDetector.cpp:182:5 [-Wmissing-prototypes] no previous prototype for function 'Sanity5_Child' xpcom/tests/gtest/TestDeadlockDetector.cpp:303:5 [-Wmissing-prototypes] no previous prototype for function 'ContentionNoDeadlock_Child' xpcom/tests/gtest/TestHashtables.cpp:88:6 [-Wmissing-prototypes] no previous prototype for function 'testTHashtable' xpcom/tests/gtest/TestHashtables.cpp:205:10 [-Wmissing-prototypes] no previous prototype for function 'CreateIFoo' xpcom/tests/gtest/TestMoveString.cpp:25:6 [-Wmissing-prototypes] no previous prototype for function 'SetAsOwned' xpcom/tests/gtest/TestMoveString.cpp:34:6 [-Wmissing-prototypes] no previous prototype for function 'ExpectTruncated' xpcom/tests/gtest/TestMoveString.cpp:40:6 [-Wmissing-prototypes] no previous prototype for function 'ExpectNew' xpcom/tests/gtest/TestMruCache.cpp:52:11 [-Wmissing-prototypes] no previous prototype for function 'MakeStringKey' xpcom/tests/gtest/TestMultiplexInputStream.cpp:106:34 [-Wmissing-prototypes] no previous prototype for function 'CreateStreamHelper' xpcom/tests/gtest/TestNonBlockingAsyncInputStream.cpp:62:10 [-Wmissing-prototypes] no previous prototype for function 'ReadSegmentsFunction' xpcom/tests/gtest/TestNsDeque.cpp:240:6 [-Wmissing-prototypes] no previous prototype for function 'CheckIfQueueEmpty' xpcom/tests/gtest/TestNsRefPtr.cpp:105:10 [-Wmissing-prototypes] no previous prototype for function 'CreateFoo' xpcom/tests/gtest/TestNsRefPtr.cpp:116:6 [-Wmissing-prototypes] no previous prototype for function 'set_a_Foo' xpcom/tests/gtest/TestNsRefPtr.cpp:123:13 [-Wmissing-prototypes] no previous prototype for function 'return_a_Foo' xpcom/tests/gtest/TestNsRefPtr.cpp:391:6 [-Wmissing-prototypes] no previous prototype for function 'AnFooPtrPtrContext' xpcom/tests/gtest/TestNsRefPtr.cpp:392:6 [-Wmissing-prototypes] no previous prototype for function 'AVoidPtrPtrContext' xpcom/tests/gtest/TestPLDHash.cpp:33:6 [-Wmissing-prototypes] no previous prototype for function 'TestCrashyOperation' xpcom/tests/gtest/TestPipes.cpp:98:10 [-Wmissing-prototypes] no previous prototype for function 'TestPipe' xpcom/tests/gtest/TestPipes.cpp:212:10 [-Wmissing-prototypes] no previous prototype for function 'TestShortWrites' xpcom/tests/gtest/TestPipes.cpp:354:6 [-Wmissing-prototypes] no previous prototype for function 'RunTests' xpcom/tests/gtest/TestPLDHash.cpp:90:6 [-Wmissing-prototypes] no previous prototype for function 'InitCapacityOk_InitialLengthTooBig' xpcom/tests/gtest/TestPLDHash.cpp:95:6 [-Wmissing-prototypes] no previous prototype for function 'InitCapacityOk_InitialEntryStoreTooBig' xpcom/tests/gtest/TestPLDHash.cpp:102:6 [-Wmissing-prototypes] no previous prototype for function 'InitCapacityOk_EntrySizeTooBig' xpcom/tests/gtest/TestSlicedInputStream.cpp:111:20 [-Wmissing-prototypes] no previous prototype for function 'CreateSeekableStreams' xpcom/tests/gtest/TestSlicedInputStream.cpp:125:20 [-Wmissing-prototypes] no previous prototype for function 'CreateNonSeekableStreams' xpcom/tests/gtest/TestStrings.cpp:471:6 [-Wmissing-prototypes] no previous prototype for function 'test_assign_helper' xpcom/tests/gtest/TestTArray.cpp:60:22 [-Wmissing-prototypes] no previous prototype for function 'DummyArray' xpcom/tests/gtest/TestTArray.cpp:72:22 [-Wmissing-prototypes] no previous prototype for function 'FakeHugeArray' xpcom/tests/gtest/TestThrottledEventQueue.cpp:96:6 [-Wmissing-prototypes] no previous prototype for function 'Enqueue' xpcom/threads/BlockingResourceBase.cpp:86:6 [-Wmissing-prototypes] no previous prototype for function 'PrintCycle' xpcom/threads/CPUUsageWatcher.cpp:41:10 [-Wmissing-prototypes] no previous prototype for function 'GetMicroseconds' xpcom/threads/CPUUsageWatcher.cpp:46:10 [-Wmissing-prototypes] no previous prototype for function 'GetMicroseconds' xpcom/threads/CPUUsageWatcher.cpp:51:40 [-Wmissing-prototypes] no previous prototype for function 'GetProcessCPUStats' xpcom/threads/CPUUsageWatcher.cpp:80:40 [-Wmissing-prototypes] no previous prototype for function 'GetGlobalCPUStats' xpcom/threads/nsTimerImpl.cpp:196:21 [-Wmissing-prototypes] no previous prototype for function 'GetTimerFiringsLog' Differential Revision: https://phabricator.services.mozilla.com/D23264
xpcom/base/LogModulePrefWatcher.cpp
xpcom/base/Logging.cpp
xpcom/base/nsCycleCollector.cpp
xpcom/components/nsComponentManager.cpp
xpcom/ds/Dafsa.cpp
xpcom/io/CocoaFileUtils.mm
xpcom/rust/gtest/bench-collections/Bench.cpp
xpcom/tests/gtest/TestAtoms.cpp
xpcom/tests/gtest/TestCOMPtr.cpp
xpcom/tests/gtest/TestCRT.cpp
xpcom/tests/gtest/TestCallTemplates.cpp
xpcom/tests/gtest/TestDeadlockDetector.cpp
xpcom/tests/gtest/TestHashtables.cpp
xpcom/tests/gtest/TestMoveString.cpp
xpcom/tests/gtest/TestMruCache.cpp
xpcom/tests/gtest/TestMultiplexInputStream.cpp
xpcom/tests/gtest/TestNonBlockingAsyncInputStream.cpp
xpcom/tests/gtest/TestNsDeque.cpp
xpcom/tests/gtest/TestNsRefPtr.cpp
xpcom/tests/gtest/TestPLDHash.cpp
xpcom/tests/gtest/TestPipes.cpp
xpcom/tests/gtest/TestSlicedInputStream.cpp
xpcom/tests/gtest/TestStrings.cpp
xpcom/tests/gtest/TestTArray.cpp
xpcom/tests/gtest/TestThrottledEventQueue.cpp
xpcom/threads/BlockingResourceBase.cpp
xpcom/threads/CPUUsageWatcher.cpp
xpcom/threads/nsTimerImpl.cpp
--- a/xpcom/base/LogModulePrefWatcher.cpp
+++ b/xpcom/base/LogModulePrefWatcher.cpp
@@ -29,17 +29,17 @@ NS_IMPL_ISUPPORTS(LogModulePrefWatcher, 
 /**
  * Resets all the preferences in the logging. branch
  * This is needed because we may crash while logging, and this would cause us
  * to log after restarting as well.
  *
  * If logging after restart is desired, set the logging.config.clear_on_startup
  * pref to false, or use the MOZ_LOG_FILE and MOZ_LOG_MODULES env vars.
  */
-void ResetExistingPrefs() {
+static void ResetExistingPrefs() {
   uint32_t count;
   char** names;
   nsresult rv = Preferences::GetRootBranch()->GetChildList(kLoggingPrefPrefix,
                                                            &count, &names);
   if (NS_SUCCEEDED(rv) && count) {
     for (size_t i = 0; i < count; i++) {
       // Clearing the pref will cause it to reload, thus resetting the log level
       Preferences::ClearUser(names[i]);
@@ -101,17 +101,17 @@ static void LoadPrefValue(const char* aN
       logLevel = LogLevel::Verbose;
     }
   }
 
   const char* moduleName = aName + strlen(kLoggingPrefPrefix);
   LogModule::Get(moduleName)->SetLevel(logLevel);
 }
 
-void LoadExistingPrefs() {
+static void LoadExistingPrefs() {
   nsIPrefBranch* root = Preferences::GetRootBranch();
   if (!root) {
     return;
   }
 
   uint32_t count;
   char** names;
   nsresult rv = root->GetChildList(kLoggingPrefPrefix, &count, &names);
--- a/xpcom/base/Logging.cpp
+++ b/xpcom/base/Logging.cpp
@@ -75,17 +75,17 @@ void log_print(const LogModule* aModule,
 }  // namespace detail
 
 LogLevel ToLogLevel(int32_t aLevel) {
   aLevel = std::min(aLevel, static_cast<int32_t>(LogLevel::Verbose));
   aLevel = std::max(aLevel, static_cast<int32_t>(LogLevel::Disabled));
   return static_cast<LogLevel>(aLevel);
 }
 
-const char* ToLogStr(LogLevel aLevel) {
+static const char* ToLogStr(LogLevel aLevel) {
   switch (aLevel) {
     case LogLevel::Error:
       return "E";
     case LogLevel::Warning:
       return "W";
     case LogLevel::Info:
       return "I";
     case LogLevel::Debug:
@@ -122,17 +122,18 @@ class LogFile {
   }
 
   FILE* File() const { return mFile; }
   uint32_t Num() const { return mFileNum; }
 
   LogFile* mNextToRelease;
 };
 
-const char* ExpandPIDMarker(const char* aFilename, char (&buffer)[2048]) {
+static const char* ExpandPIDMarker(const char* aFilename,
+                                   char (&buffer)[2048]) {
   MOZ_ASSERT(aFilename);
   static const char kPIDToken[] = "%PID";
   const char* pidTokenPtr = strstr(aFilename, kPIDToken);
   if (pidTokenPtr &&
       SprintfLiteral(
           buffer, "%.*s%s%d%s", static_cast<int>(pidTokenPtr - aFilename),
           aFilename, XRE_IsParentProcess() ? "-main." : "-child.",
           base::GetCurrentProcId(), pidTokenPtr + strlen(kPIDToken)) > 0) {
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -204,19 +204,19 @@ struct NurseryPurpleBufferEntry {
 
 #define NURSERY_PURPLE_BUFFER_SIZE 2048
 bool gNurseryPurpleBufferEnabled = true;
 NurseryPurpleBufferEntry gNurseryPurpleBufferEntry[NURSERY_PURPLE_BUFFER_SIZE];
 uint32_t gNurseryPurpleBufferEntryCount = 0;
 
 void ClearNurseryPurpleBuffer();
 
-void SuspectUsingNurseryPurpleBuffer(void* aPtr,
-                                     nsCycleCollectionParticipant* aCp,
-                                     nsCycleCollectingAutoRefCnt* aRefCnt) {
+static void SuspectUsingNurseryPurpleBuffer(
+    void* aPtr, nsCycleCollectionParticipant* aCp,
+    nsCycleCollectingAutoRefCnt* aRefCnt) {
   MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
   MOZ_ASSERT(gNurseryPurpleBufferEnabled);
   if (gNurseryPurpleBufferEntryCount == NURSERY_PURPLE_BUFFER_SIZE) {
     ClearNurseryPurpleBuffer();
   }
 
   gNurseryPurpleBufferEntry[gNurseryPurpleBufferEntryCount] = {aPtr, aCp,
                                                                aRefCnt};
--- a/xpcom/components/nsComponentManager.cpp
+++ b/xpcom/components/nsComponentManager.cpp
@@ -413,23 +413,23 @@ extern mozilla::Module const* const __st
     "section$start$__DATA$.kPStaticModules");
 extern mozilla::Module const* const __stop_kPStaticModules __asm(
     "section$end$__DATA$.kPStaticModules");
 
 #  else
 #    error Do not know how to find NSModules.
 #  endif
 
-mozilla::Module const* const* begin(AllStaticModules& _) {
+static mozilla::Module const* const* begin(AllStaticModules& _) {
   return &__start_kPStaticModules;
 }
 
 #endif
 
-mozilla::Module const* const* end(AllStaticModules& _) {
+static mozilla::Module const* const* end(AllStaticModules& _) {
   return &__stop_kPStaticModules;
 }
 
 /* static */
 void nsComponentManagerImpl::InitializeStaticModules() {
   if (sExtraStaticModules) {
     return;
   }
--- a/xpcom/ds/Dafsa.cpp
+++ b/xpcom/ds/Dafsa.cpp
@@ -15,18 +15,18 @@
 
 const int mozilla::Dafsa::kKeyNotFound = -1;
 
 // Note the DAFSA implementation was lifted from eTLD code in Chromium that was
 // originally lifted from Firefox.
 
 // Read next offset from pos.
 // Returns true if an offset could be read, false otherwise.
-bool GetNextOffset(const unsigned char** pos, const unsigned char* end,
-                   const unsigned char** offset) {
+static bool GetNextOffset(const unsigned char** pos, const unsigned char* end,
+                          const unsigned char** offset) {
   if (*pos == end) return false;
 
   // When reading an offset the byte array must always contain at least
   // three more bytes to consume. First the offset to read, then a node
   // to skip over and finally a destination node. No object can be smaller
   // than one byte.
   MOZ_ASSERT(*pos + 2 < end);
   size_t bytes_consumed;
@@ -47,54 +47,54 @@ bool GetNextOffset(const unsigned char**
     *pos = end;
   } else {
     *pos += bytes_consumed;
   }
   return true;
 }
 
 // Check if byte at offset is last in label.
-bool IsEOL(const unsigned char* offset, const unsigned char* end) {
+static bool IsEOL(const unsigned char* offset, const unsigned char* end) {
   MOZ_ASSERT(offset < end);
   return (*offset & 0x80) != 0;
 }
 
 // Check if byte at offset matches first character in key.
 // This version matches characters not last in label.
-bool IsMatch(const unsigned char* offset, const unsigned char* end,
-             const char* key) {
+static bool IsMatch(const unsigned char* offset, const unsigned char* end,
+                    const char* key) {
   MOZ_ASSERT(offset < end);
   return *offset == *key;
 }
 
 // Check if byte at offset matches first character in key.
 // This version matches characters last in label.
-bool IsEndCharMatch(const unsigned char* offset, const unsigned char* end,
-                    const char* key) {
+static bool IsEndCharMatch(const unsigned char* offset,
+                           const unsigned char* end, const char* key) {
   MOZ_ASSERT(offset < end);
   return *offset == (*key | 0x80);
 }
 
 // Read return value at offset.
 // Returns true if a return value could be read, false otherwise.
-bool GetReturnValue(const unsigned char* offset, const unsigned char* end,
-                    int* return_value) {
+static bool GetReturnValue(const unsigned char* offset,
+                           const unsigned char* end, int* return_value) {
   MOZ_ASSERT(offset < end);
   if ((*offset & 0xE0) == 0x80) {
     *return_value = *offset & 0x0F;
     return true;
   }
   return false;
 }
 
 // Lookup a domain key in a byte array generated by make_dafsa.py.
 // The rule type is returned if key is found, otherwise kKeyNotFound is
 // returned.
-int LookupString(const unsigned char* graph, size_t length, const char* key,
-                 size_t key_length) {
+static int LookupString(const unsigned char* graph, size_t length,
+                        const char* key, size_t key_length) {
   const unsigned char* pos = graph;
   const unsigned char* end = graph + length;
   const unsigned char* offset = pos;
   const char* key_end = key + key_length;
   while (GetNextOffset(&pos, end, &offset)) {
     //   char <char>+ end_char offsets
     //   char <char>+ return value
     //   char end_char offsets
--- a/xpcom/io/CocoaFileUtils.mm
+++ b/xpcom/io/CocoaFileUtils.mm
@@ -187,26 +187,26 @@ void AddOriginMetadataToFile(const CFStr
 
   mdItemSetAttributeFunc(mdItem, kMDItemWhereFroms, list);
 
   ::CFRelease(list);
   ::CFRelease(mdItem);
 }
 
 // Can be called off of the main thread.
-CFStringRef GetQuarantinePropKey() {
+static CFStringRef GetQuarantinePropKey() {
   if (nsCocoaFeatures::OnYosemiteOrLater()) {
     return kCFURLQuarantinePropertiesKey;
   }
   return kLSItemQuarantineProperties;
 }
 
 // Can be called off of the main thread.
-CFMutableDictionaryRef CreateQuarantineDictionary(const CFURLRef aFileURL,
-                                                  const bool aCreateProps) {
+static CFMutableDictionaryRef CreateQuarantineDictionary(const CFURLRef aFileURL,
+                                                         const bool aCreateProps) {
   // The properties key changed in 10.10:
   CFDictionaryRef quarantineProps = NULL;
   if (aCreateProps) {
     quarantineProps = ::CFDictionaryCreate(NULL, NULL, NULL, 0, &kCFTypeDictionaryKeyCallBacks,
                                            &kCFTypeDictionaryValueCallBacks);
   } else {
     Boolean success =
         ::CFURLCopyResourcePropertyForKey(aFileURL, GetQuarantinePropKey(), &quarantineProps, NULL);
--- a/xpcom/rust/gtest/bench-collections/Bench.cpp
+++ b/xpcom/rust/gtest/bench-collections/Bench.cpp
@@ -57,17 +57,17 @@
 
 using namespace mozilla;
 
 // This function gives a pseudo-random sequence with the following properties:
 // - Deterministic and platform-independent.
 // - No duplicates in the first VALS_LEN results, which is useful for ensuring
 //   the tables get to a particular size, and also for guaranteeing lookups
 //   that fail.
-uintptr_t MyRand() {
+static uintptr_t MyRand() {
   static uintptr_t s = 0;
   s = s * 1103515245 + 12345;
   return s;
 }
 
 // Keep this in sync with Params in bench.rs.
 struct Params {
   const char* mConfigName;
@@ -77,17 +77,18 @@ struct Params {
   size_t mNumIterations;         // Iterates the full table each time
   bool mRemoveInserts;           // Remove all entries at end?
 };
 
 // We don't use std::unordered_{set,map}, but it's an interesting thing to
 // benchmark against.
 //
 // Keep this in sync with all the other Bench_*() functions.
-void Bench_Cpp_unordered_set(const Params* aParams, void** aVals, size_t aLen) {
+static void Bench_Cpp_unordered_set(const Params* aParams, void** aVals,
+                                    size_t aLen) {
   std::unordered_set<void*> hs;
 
   for (size_t j = 0; j < aParams->mNumInserts; j++) {
     hs.insert(aVals[j]);
   }
 
   for (size_t i = 0; i < aParams->mNumSuccessfulLookups; i++) {
     for (size_t j = 0; j < aParams->mNumInserts; j++) {
@@ -117,17 +118,18 @@ void Bench_Cpp_unordered_set(const Param
     }
     MOZ_RELEASE_ASSERT(hs.size() == 0);
   } else {
     MOZ_RELEASE_ASSERT(hs.size() == aParams->mNumInserts);
   }
 }
 
 // Keep this in sync with all the other Bench_*() functions.
-void Bench_Cpp_PLDHashTable(const Params* aParams, void** aVals, size_t aLen) {
+static void Bench_Cpp_PLDHashTable(const Params* aParams, void** aVals,
+                                   size_t aLen) {
   PLDHashTable hs(PLDHashTable::StubOps(), sizeof(PLDHashEntryStub));
 
   for (size_t j = 0; j < aParams->mNumInserts; j++) {
     auto entry = static_cast<PLDHashEntryStub*>(hs.Add(aVals[j]));
     MOZ_RELEASE_ASSERT(!entry->key);
     entry->key = aVals[j];
   }
 
@@ -158,17 +160,18 @@ void Bench_Cpp_PLDHashTable(const Params
     }
     MOZ_RELEASE_ASSERT(hs.EntryCount() == 0);
   } else {
     MOZ_RELEASE_ASSERT(hs.EntryCount() == aParams->mNumInserts);
   }
 }
 
 // Keep this in sync with all the other Bench_*() functions.
-void Bench_Cpp_MozHashSet(const Params* aParams, void** aVals, size_t aLen) {
+static void Bench_Cpp_MozHashSet(const Params* aParams, void** aVals,
+                                 size_t aLen) {
   mozilla::HashSet<void*, mozilla::DefaultHasher<void*>, MallocAllocPolicy> hs;
 
   for (size_t j = 0; j < aParams->mNumInserts; j++) {
     MOZ_RELEASE_ASSERT(hs.put(aVals[j]));
   }
 
   for (size_t i = 0; i < aParams->mNumSuccessfulLookups; i++) {
     for (size_t j = 0; j < aParams->mNumInserts; j++) {
--- a/xpcom/tests/gtest/TestAtoms.cpp
+++ b/xpcom/tests/gtest/TestAtoms.cpp
@@ -106,17 +106,17 @@ TEST(Atoms, Invalid) {
   }
 #endif
 }
 
 #define FIRST_ATOM_STR "first static atom. Hello!"
 #define SECOND_ATOM_STR "second static atom. @World!"
 #define THIRD_ATOM_STR "third static atom?!"
 
-bool isStaticAtom(nsAtom* atom) {
+static bool isStaticAtom(nsAtom* atom) {
   // Don't use logic && in order to ensure that all addrefs/releases are always
   // run, even if one of the tests fail. This allows us to run this code on a
   // non-static atom without affecting its refcount.
   bool rv = (atom->AddRef() == 2);
   rv &= (atom->AddRef() == 2);
   rv &= (atom->AddRef() == 2);
 
   rv &= (atom->Release() == 1);
--- a/xpcom/tests/gtest/TestCOMPtr.cpp
+++ b/xpcom/tests/gtest/TestCOMPtr.cpp
@@ -79,35 +79,35 @@ nsresult IFoo::QueryInterface(const nsII
   }
 
   NS_IF_ADDREF(rawPtr);
   *aResult = rawPtr;
 
   return status;
 }
 
-nsresult CreateIFoo(void** result)
+static nsresult CreateIFoo(void** result)
 // a typical factory function (that calls AddRef)
 {
   auto* foop = new IFoo;
 
   foop->AddRef();
   *result = foop;
 
   return NS_OK;
 }
 
-void set_a_IFoo(nsCOMPtr<IFoo>* result) {
+static void set_a_IFoo(nsCOMPtr<IFoo>* result) {
   // Various places in this file do a static_cast to nsISupports* in order to
   // make the QI non-trivial, to avoid hitting a static assert.
   nsCOMPtr<IFoo> foop(do_QueryInterface(static_cast<nsISupports*>(new IFoo)));
   *result = foop;
 }
 
-nsCOMPtr<IFoo> return_a_IFoo() {
+static nsCOMPtr<IFoo> return_a_IFoo() {
   nsCOMPtr<IFoo> foop(do_QueryInterface(static_cast<nsISupports*>(new IFoo)));
   return foop;
 }
 
 #define NS_IBAR_IID                                  \
   {                                                  \
     0x6f7652e1, 0xee43, 0x11d1, {                    \
       0x9c, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 \
@@ -156,32 +156,32 @@ nsresult IBar::QueryInterface(const nsID
   }
 
   NS_IF_ADDREF(rawPtr);
   *aResult = rawPtr;
 
   return status;
 }
 
-nsresult CreateIBar(void** result)
+static nsresult CreateIBar(void** result)
 // a typical factory function (that calls AddRef)
 {
   auto* barp = new IBar;
 
   barp->AddRef();
   *result = barp;
 
   return NS_OK;
 }
 
-void AnIFooPtrPtrContext(IFoo**) {}
+static void AnIFooPtrPtrContext(IFoo**) {}
 
-void AVoidPtrPtrContext(void**) {}
+static void AVoidPtrPtrContext(void**) {}
 
-void AnISupportsPtrPtrContext(nsISupports**) {}
+static void AnISupportsPtrPtrContext(nsISupports**) {}
 
 }  // namespace TestCOMPtr
 
 using namespace TestCOMPtr;
 
 TEST(COMPtr, Bloat_Raw_Unsafe) {
   // ER: I'm not sure what this is testing...
   IBar* barP = 0;
@@ -255,17 +255,17 @@ TEST(COMPtr, AddRefAndRelease) {
   {
     nsCOMPtr<IFoo> foop(do_QueryInterface(static_cast<nsISupports*>(new IBar)));
     mozilla::Unused << foop;
   }
 
   ASSERT_EQ(IBar::total_destructions_, 1);
 }
 
-void Comparison() {
+TEST(COMPtr, Comparison) {
   IFoo::total_constructions_ = 0;
   IFoo::total_destructions_ = 0;
 
   {
     nsCOMPtr<IFoo> foo1p(
         do_QueryInterface(static_cast<nsISupports*>(new IFoo)));
     nsCOMPtr<IFoo> foo2p(
         do_QueryInterface(static_cast<nsISupports*>(new IFoo)));
@@ -290,17 +290,17 @@ void Comparison() {
 
     ASSERT_EQ(foo1p->refcount_, (unsigned int)2);
     ASSERT_EQ(foo2p->refcount_, (unsigned int)2);
   }
 
   ASSERT_EQ(IFoo::total_destructions_, 2);
 }
 
-void DontAddRef() {
+TEST(COMPtr, DontAddRef) {
   {
     auto* raw_foo1p = new IFoo;
     raw_foo1p->AddRef();
 
     auto* raw_foo2p = new IFoo;
     raw_foo2p->AddRef();
 
     nsCOMPtr<IFoo> foo1p(dont_AddRef(raw_foo1p));
--- a/xpcom/tests/gtest/TestCRT.cpp
+++ b/xpcom/tests/gtest/TestCRT.cpp
@@ -9,17 +9,17 @@
 #include "plstr.h"
 #include <stdlib.h>
 #include "gtest/gtest.h"
 
 namespace TestCRT {
 
 // The return from strcmp etc is only defined to be postive, zero or
 // negative. The magnitude of a non-zero return is irrelevant.
-int sign(int val) {
+static int sign(int val) {
   if (val == 0) {
     return 0;
   } else {
     if (val > 0) {
       return 1;
     } else {
       return -1;
     }
--- a/xpcom/tests/gtest/TestCallTemplates.cpp
+++ b/xpcom/tests/gtest/TestCallTemplates.cpp
@@ -64,17 +64,17 @@ NS_IMPL_ISUPPORTS(nsTestService, nsITest
 #define NS_TEST_SERVICE_CID                          \
   {                                                  \
     0xa00c1406, 0x283a, 0x45c9, {                    \
       0xae, 0xd2, 0x1a, 0xb6, 0xdd, 0xba, 0xfe, 0x53 \
     }                                                \
   }
 static NS_DEFINE_CID(kTestServiceCID, NS_TEST_SERVICE_CID);
 
-void JustTestingCompilation() {
+inline void JustTestingCompilation() {
   /*
    * NOTE:  This does NOT demonstrate how these functions are
    * intended to be used.  They are intended for filling in out
    * parameters that need to be |AddRef|ed.  I'm just too lazy
    * to write lots of little getter functions for a test program
    * when I don't need to.
    */
 
--- a/xpcom/tests/gtest/TestDeadlockDetector.cpp
+++ b/xpcom/tests/gtest/TestDeadlockDetector.cpp
@@ -54,29 +54,29 @@ class TESTNAME(DeadlockDetectorTest) : p
   }
 
   void TearDown() final { ::_gdb_sleep_duration = mOldSleepDuration; }
 
  private:
   unsigned int mOldSleepDuration;
 };
 
-void DisableCrashReporter() {
+static void DisableCrashReporter() {
   nsCOMPtr<nsICrashReporter> crashreporter =
       do_GetService("@mozilla.org/toolkit/crash-reporter;1");
   if (crashreporter) {
     crashreporter->SetEnabled(false);
   }
 }
 
 //-----------------------------------------------------------------------------
 // Single-threaded sanity tests
 
 // Stupidest possible deadlock.
-int Sanity_Child() {
+static int Sanity_Child() {
   DisableCrashReporter();
 
   MUTEX m1("dd.sanity.m1");
   m1.Lock();
   m1.Lock();
   return 0;  // not reached
 }
 
@@ -87,17 +87,17 @@ TEST_F(TESTNAME(DeadlockDetectorTest), T
       "=== Cycle completed at.*--- Mutex : dd.sanity.m1.*"
       "###!!! Deadlock may happen NOW!.*"  // better catch these easy cases...
       "###!!! ASSERTION: Potential deadlock detected.*";
 
   ASSERT_DEATH_IF_SUPPORTED(Sanity_Child(), regex);
 }
 
 // Slightly less stupid deadlock.
-int Sanity2_Child() {
+static int Sanity2_Child() {
   DisableCrashReporter();
 
   MUTEX m1("dd.sanity2.m1");
   MUTEX m2("dd.sanity2.m2");
   m1.Lock();
   m2.Lock();
   m1.Lock();
   return 0;  // not reached
@@ -151,17 +151,17 @@ TEST_F(TESTNAME(DeadlockDetectorTest), T
         "--- Next dependency:.*--- Mutex : dd.sanity3.m4.*"
         "=== Cycle completed at.*--- Mutex : dd.sanity3.m1.*"
         "###!!! ASSERTION: Potential deadlock detected.*";
 
     ASSERT_DEATH_IF_SUPPORTED(Sanity3_Child(), regex);
 }
 #endif
 
-int Sanity4_Child() {
+static int Sanity4_Child() {
   DisableCrashReporter();
 
   mozilla::ReentrantMonitor m1("dd.sanity4.m1");
   MUTEX m2("dd.sanity4.m2");
   m1.Enter();
   m2.Lock();
   m1.Enter();
   return 0;
@@ -174,17 +174,17 @@ TEST_F(TESTNAME(DeadlockDetectorTest), T
       "=== Cyclical dependency starts at.*--- ReentrantMonitor : "
       "dd.sanity4.m1.*"
       "--- Next dependency:.*--- Mutex : dd.sanity4.m2.*"
       "=== Cycle completed at.*--- ReentrantMonitor : dd.sanity4.m1.*"
       "###!!! ASSERTION: Potential deadlock detected.*";
   ASSERT_DEATH_IF_SUPPORTED(Sanity4_Child(), regex);
 }
 
-int Sanity5_Child() {
+static int Sanity5_Child() {
   DisableCrashReporter();
 
   mozilla::RecursiveMutex m1("dd.sanity4.m1");
   MUTEX m2("dd.sanity4.m2");
   m1.Lock();
   m2.Lock();
   m1.Lock();
   return 0;
@@ -295,17 +295,17 @@ static void ContentionNoDeadlock_thread(
     for (int32_t i = starti; i < (int32_t)cndMs.Length(); ++i) cndMs[i]->Lock();
     // comment out the next two lines for deadlocking fun!
     for (int32_t i = cndMs.Length() - 1; i >= starti; --i) cndMs[i]->Unlock();
 
     starti = (starti + 1) % 3;
   }
 }
 
-int ContentionNoDeadlock_Child() {
+static int ContentionNoDeadlock_Child() {
   const size_t kMutexCount = 4;
 
   PRThread* threads[3];
   nsTArray<MUTEX*> locks;
   ThreadState states[] = {{locks, 0}, {locks, 1}, {locks, 2}};
 
   for (uint32_t i = 0; i < kMutexCount; ++i)
     locks.AppendElement(new MUTEX("dd.cnd.ms"));
--- a/xpcom/tests/gtest/TestHashtables.cpp
+++ b/xpcom/tests/gtest/TestHashtables.cpp
@@ -32,17 +32,17 @@ class TestUniChar  // for nsClassHashtab
   uint32_t mWord;
 };
 
 struct EntityNode {
   const char* mStr;  // never owns buffer
   uint32_t mUnicode;
 };
 
-EntityNode gEntities[] = {
+static const EntityNode gEntities[] = {
     {"nbsp", 160},   {"iexcl", 161}, {"cent", 162},   {"pound", 163},
     {"curren", 164}, {"yen", 165},   {"brvbar", 166}, {"sect", 167},
     {"uml", 168},    {"copy", 169},  {"ordf", 170},   {"laquo", 171},
     {"not", 172},    {"shy", 173},   {"reg", 174},    {"macr", 175}};
 
 #define ENTITY_COUNT (unsigned(sizeof(gEntities) / sizeof(EntityNode)))
 
 class EntityToUnicodeEntry : public PLDHashEntryHdr {
@@ -80,18 +80,18 @@ static uint32_t nsTIterPrintRemove(nsTHa
   uint32_t n = 0;
   for (auto iter = hash.Iter(); !iter.Done(); iter.Next()) {
     iter.Remove();
     n++;
   }
   return n;
 }
 
-void testTHashtable(nsTHashtable<EntityToUnicodeEntry>& hash,
-                    uint32_t numEntries) {
+static void testTHashtable(nsTHashtable<EntityToUnicodeEntry>& hash,
+                           uint32_t numEntries) {
   uint32_t i;
   for (i = 0; i < numEntries; ++i) {
     EntityToUnicodeEntry* entry = hash.PutEntry(gEntities[i].mStr);
 
     EXPECT_TRUE(entry);
 
     EXPECT_FALSE(entry->mNode);
     entry->mNode = &gEntities[i];
@@ -197,17 +197,17 @@ nsresult IFoo::SetString(const nsACStrin
   return NS_OK;
 }
 
 nsresult IFoo::GetString(nsACString& aString) {
   aString = mString;
   return NS_OK;
 }
 
-nsresult CreateIFoo(IFoo** result)
+static nsresult CreateIFoo(IFoo** result)
 // a typical factory function (that calls AddRef)
 {
   auto* foop = new IFoo();
 
   foop->AddRef();
   *result = foop;
 
   return NS_OK;
--- a/xpcom/tests/gtest/TestMoveString.cpp
+++ b/xpcom/tests/gtest/TestMoveString.cpp
@@ -17,32 +17,32 @@
 
 namespace TestMoveString {
 
 #define NEW_VAL "**new value**"
 #define OLD_VAL "old value"
 
 typedef mozilla::detail::StringDataFlags Df;
 
-void SetAsOwned(nsACString& aStr, const char* aValue) {
+static void SetAsOwned(nsACString& aStr, const char* aValue) {
   size_t len = strlen(aValue);
   char* data = new char[len + 1];
   memcpy(data, aValue, len + 1);
   aStr.Adopt(data, len);
   EXPECT_EQ(aStr.GetDataFlags(), Df::OWNED | Df::TERMINATED);
   EXPECT_STREQ(aStr.BeginReading(), aValue);
 }
 
-void ExpectTruncated(const nsACString& aStr) {
+static void ExpectTruncated(const nsACString& aStr) {
   EXPECT_EQ(aStr.Length(), uint32_t(0));
   EXPECT_STREQ(aStr.BeginReading(), "");
   EXPECT_EQ(aStr.GetDataFlags(), Df::TERMINATED);
 }
 
-void ExpectNew(const nsACString& aStr) {
+static void ExpectNew(const nsACString& aStr) {
   EXPECT_EQ(aStr.Length(), strlen(NEW_VAL));
   EXPECT_TRUE(aStr.EqualsASCII(NEW_VAL));
 }
 
 TEST(MoveString, SharedIntoOwned) {
   nsCString out;
   SetAsOwned(out, OLD_VAL);
   EXPECT_EQ(out.GetDataFlags(), Df::OWNED | Df::TERMINATED);
--- a/xpcom/tests/gtest/TestMruCache.cpp
+++ b/xpcom/tests/gtest/TestMruCache.cpp
@@ -44,17 +44,17 @@ struct StringStructMap
 // Helper for emulating convertable holders such as RefPtr.
 template <typename T>
 struct Convertable {
   T mItem;
   operator T() const { return mItem; }
 };
 
 // Helper to create a StringStructMap key.
-nsCString MakeStringKey(char aKey) {
+static nsCString MakeStringKey(char aKey) {
   nsCString key;
   key.Append(aKey);
   return key;
 }
 
 TEST(MruCache, TestNullChecker) {
   using mozilla::detail::EmptyChecker;
 
--- a/xpcom/tests/gtest/TestMultiplexInputStream.cpp
+++ b/xpcom/tests/gtest/TestMultiplexInputStream.cpp
@@ -98,17 +98,17 @@ TEST(MultiplexInputStream, Seek_SET) {
   ASSERT_TRUE(NS_SUCCEEDED(rv));
   ASSERT_EQ((uint64_t)6, count);
   rv = stream->Available(&length);
   ASSERT_TRUE(NS_SUCCEEDED(rv));
   ASSERT_EQ((uint64_t)buf2.Length() - 6 + buf3.Length(), length);
   ASSERT_EQ(0, strncmp(readBuf, "The qu", count));
 }
 
-already_AddRefed<nsIInputStream> CreateStreamHelper() {
+static already_AddRefed<nsIInputStream> CreateStreamHelper() {
   nsCOMPtr<nsIMultiplexInputStream> multiplexStream =
       do_CreateInstance("@mozilla.org/io/multiplex-input-stream;1");
 
   nsCString buf1;
   buf1.AssignLiteral("Hello");
 
   nsCOMPtr<nsIInputStream> inputStream1 = new testing::AsyncStringStream(buf1);
   multiplexStream->AppendStream(inputStream1);
--- a/xpcom/tests/gtest/TestNonBlockingAsyncInputStream.cpp
+++ b/xpcom/tests/gtest/TestNonBlockingAsyncInputStream.cpp
@@ -54,19 +54,19 @@ class ReadSegmentsData {
  public:
   ReadSegmentsData(nsIInputStream* aStream, char* aBuffer)
       : mStream(aStream), mBuffer(aBuffer) {}
 
   nsIInputStream* mStream;
   char* mBuffer;
 };
 
-nsresult ReadSegmentsFunction(nsIInputStream* aInStr, void* aClosure,
-                              const char* aBuffer, uint32_t aOffset,
-                              uint32_t aCount, uint32_t* aCountWritten) {
+static nsresult ReadSegmentsFunction(nsIInputStream* aInStr, void* aClosure,
+                                     const char* aBuffer, uint32_t aOffset,
+                                     uint32_t aCount, uint32_t* aCountWritten) {
   ReadSegmentsData* data = static_cast<ReadSegmentsData*>(aClosure);
   if (aInStr != data->mStream) return NS_ERROR_FAILURE;
   memcpy(&data->mBuffer[aOffset], aBuffer, aCount);
   *aCountWritten = aCount;
   return NS_OK;
 }
 
 TEST(TestNonBlockingAsyncInputStream, ReadSegments) {
--- a/xpcom/tests/gtest/TestNsDeque.cpp
+++ b/xpcom/tests/gtest/TestNsDeque.cpp
@@ -232,17 +232,17 @@ TEST(NsDeque, TestPushFront) {
   d.PushFront(pool + kMaxSizeBeforeGrowth + 1);
   EXPECT_EQ(kMaxSizeBeforeGrowth + 2, d.GetSize()) << "verify size";
 
   static const int t3[] = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
   EXPECT_TRUE(VerifyContents(d, t3, kMaxSizeBeforeGrowth + 2))
       << "verify pushfront 3";
 }
 
-void CheckIfQueueEmpty(nsDeque& d) {
+static void CheckIfQueueEmpty(nsDeque& d) {
   EXPECT_EQ(0u, d.GetSize()) << "Size should be 0";
   EXPECT_EQ(nullptr, d.Pop()) << "Invalid operation should return nullptr";
   EXPECT_EQ(nullptr, d.PopFront()) << "Invalid operation should return nullptr";
   EXPECT_EQ(nullptr, d.Peek()) << "Invalid operation should return nullptr";
   EXPECT_EQ(nullptr, d.PeekFront())
       << "Invalid operation should return nullptr";
   EXPECT_EQ(nullptr, d.ObjectAt(0u))
       << "Invalid operation should return nullptr";
--- a/xpcom/tests/gtest/TestNsRefPtr.cpp
+++ b/xpcom/tests/gtest/TestNsRefPtr.cpp
@@ -97,35 +97,35 @@ nsresult Foo::QueryInterface(const nsIID
 
 void Foo::MemberFunction(int aArg1, int* aArgPtr, int& aArgRef) {}
 
 void Foo::VirtualMemberFunction(int aArg1, int* aArgPtr, int& aArgRef) {}
 
 void Foo::VirtualConstMemberFunction(int aArg1, int* aArgPtr,
                                      int& aArgRef) const {}
 
-nsresult CreateFoo(void** result)
+static nsresult CreateFoo(void** result)
 // a typical factory function (that calls AddRef)
 {
   auto* foop = new Foo;
 
   foop->AddRef();
   *result = foop;
 
   return NS_OK;
 }
 
-void set_a_Foo(RefPtr<Foo>* result) {
+static void set_a_Foo(RefPtr<Foo>* result) {
   assert(result);
 
   RefPtr<Foo> foop(do_QueryObject(new Foo));
   *result = foop;
 }
 
-RefPtr<Foo> return_a_Foo() {
+static RefPtr<Foo> return_a_Foo() {
   RefPtr<Foo> foop(do_QueryObject(new Foo));
   return foop;
 }
 
 #define NS_BAR_IID                                   \
   {                                                  \
     0x6f7652e1, 0xee43, 0x11d1, {                    \
       0x9c, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 \
@@ -383,18 +383,18 @@ class ObjectForConstPtr {
 
  public:
   NS_INLINE_DECL_THREADSAFE_MUTABLE_REFCOUNTING(ObjectForConstPtr)
   void ConstMemberFunction(int aArg1, int* aArgPtr, int& aArgRef) const {}
 };
 #undef NS_INLINE_DECL_THREADSAFE_MUTABLE_REFCOUNTING
 
 namespace TestNsRefPtr {
-void AnFooPtrPtrContext(Foo**) {}
-void AVoidPtrPtrContext(void**) {}
+static void AnFooPtrPtrContext(Foo**) {}
+static void AVoidPtrPtrContext(void**) {}
 }  // namespace TestNsRefPtr
 
 TEST(nsRefPtr, RefPtrCompilationTests) {
   {
     RefPtr<Foo> fooP;
 
     AnFooPtrPtrContext(getter_AddRefs(fooP));
     AVoidPtrPtrContext(getter_AddRefs(fooP));
--- a/xpcom/tests/gtest/TestPLDHash.cpp
+++ b/xpcom/tests/gtest/TestPLDHash.cpp
@@ -25,17 +25,17 @@ extern unsigned int _gdb_sleep_duration;
 // We can test that certain operations cause expected aborts by forking
 // and then checking that the child aborted in the expected way (i.e. via
 // MOZ_CRASH). We skip this for the following configurations.
 // - On Windows, because it doesn't have fork().
 // - On non-DEBUG builds, because the crashes cause the crash reporter to pop
 //   up when running this test locally, which is surprising and annoying.
 // - On ASAN builds, because ASAN alters the way a MOZ_CRASHing process
 //   terminates, which makes it harder to test if the right thing has occurred.
-void TestCrashyOperation(void (*aCrashyOperation)()) {
+static void TestCrashyOperation(void (*aCrashyOperation)()) {
 #if defined(XP_UNIX) && defined(DEBUG) && !defined(MOZ_ASAN)
   // We're about to trigger a crash. When it happens don't pause to allow GDB
   // to be attached.
   unsigned int old_gdb_sleep_duration = _gdb_sleep_duration;
   _gdb_sleep_duration = 0;
 
   int pid = fork();
   ASSERT_NE(pid, -1);
@@ -82,29 +82,29 @@ void TestCrashyOperation(void (*aCrashyO
       ASSERT_TRUE(false);
     }
   }
 
   _gdb_sleep_duration = old_gdb_sleep_duration;
 #endif
 }
 
-void InitCapacityOk_InitialLengthTooBig() {
+static void InitCapacityOk_InitialLengthTooBig() {
   PLDHashTable t(PLDHashTable::StubOps(), sizeof(PLDHashEntryStub),
                  PLDHashTable::kMaxInitialLength + 1);
 }
 
-void InitCapacityOk_InitialEntryStoreTooBig() {
+static void InitCapacityOk_InitialEntryStoreTooBig() {
   // Try the smallest disallowed power-of-two entry store size, which is 2^32
   // bytes (which overflows to 0). (Note that the 2^23 *length* gets converted
   // to a 2^24 *capacity*.)
   PLDHashTable t(PLDHashTable::StubOps(), (uint32_t)1 << 8, (uint32_t)1 << 23);
 }
 
-void InitCapacityOk_EntrySizeTooBig() {
+static void InitCapacityOk_EntrySizeTooBig() {
   // Try the smallest disallowed entry size, which is 256 bytes.
   PLDHashTable t(PLDHashTable::StubOps(), 256);
 }
 
 TEST(PLDHashTableTest, InitCapacityOk) {
   // Try the largest allowed capacity.  With kMaxCapacity==1<<26, this
   // would allocate (if we added an element) 0.5GB of entry store on 32-bit
   // platforms and 1GB on 64-bit platforms.
--- a/xpcom/tests/gtest/TestPipes.cpp
+++ b/xpcom/tests/gtest/TestPipes.cpp
@@ -90,17 +90,17 @@ class nsReceiver final : public nsIRunna
 
  protected:
   nsCOMPtr<nsIInputStream> mIn;
   uint32_t mCount;
 };
 
 NS_IMPL_ISUPPORTS(nsReceiver, nsIRunnable)
 
-nsresult TestPipe(nsIInputStream* in, nsIOutputStream* out) {
+static nsresult TestPipe(nsIInputStream* in, nsIOutputStream* out) {
   RefPtr<nsReceiver> receiver = new nsReceiver(in);
   if (!receiver) return NS_ERROR_OUT_OF_MEMORY;
 
   nsresult rv;
 
   nsCOMPtr<nsIThread> thread;
   rv = NS_NewNamedThread("TestPipe", getter_AddRefs(thread), receiver);
   if (NS_FAILED(rv)) return rv;
@@ -204,17 +204,17 @@ class nsShortReader final : public nsIRu
  protected:
   nsCOMPtr<nsIInputStream> mIn;
   uint32_t mReceived;
   ReentrantMonitor* mMon;
 };
 
 NS_IMPL_ISUPPORTS(nsShortReader, nsIRunnable)
 
-nsresult TestShortWrites(nsIInputStream* in, nsIOutputStream* out) {
+static nsresult TestShortWrites(nsIInputStream* in, nsIOutputStream* out) {
   RefPtr<nsShortReader> receiver = new nsShortReader(in);
   if (!receiver) return NS_ERROR_OUT_OF_MEMORY;
 
   nsresult rv;
 
   nsCOMPtr<nsIThread> thread;
   rv = NS_NewNamedThread("TestShortWrites", getter_AddRefs(thread), receiver);
   if (NS_FAILED(rv)) return rv;
@@ -346,17 +346,17 @@ TEST(Pipes, ChainedPipes) {
   if (NS_FAILED(rv)) return;
 
   thread->Shutdown();
   receiverThread->Shutdown();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
-void RunTests(uint32_t segSize, uint32_t segCount) {
+static void RunTests(uint32_t segSize, uint32_t segCount) {
   nsresult rv;
   nsCOMPtr<nsIInputStream> in;
   nsCOMPtr<nsIOutputStream> out;
   uint32_t bufSize = segSize * segCount;
   if (gTrace) {
     printf("Testing New Pipes: segment size %d buffer size %d\n", segSize,
            bufSize);
     printf("Testing long writes...\n");
--- a/xpcom/tests/gtest/TestSlicedInputStream.cpp
+++ b/xpcom/tests/gtest/TestSlicedInputStream.cpp
@@ -103,33 +103,35 @@ class NonSeekableStringStream final : pu
 
  private:
   ~NonSeekableStringStream() {}
 };
 
 NS_IMPL_ISUPPORTS(NonSeekableStringStream, nsIInputStream, nsIAsyncInputStream)
 
 // Helper function for creating a seekable nsIInputStream + a SlicedInputStream.
-SlicedInputStream* CreateSeekableStreams(uint32_t aSize, uint64_t aStart,
-                                         uint64_t aLength, nsCString& aBuffer) {
+static SlicedInputStream* CreateSeekableStreams(uint32_t aSize, uint64_t aStart,
+                                                uint64_t aLength,
+                                                nsCString& aBuffer) {
   aBuffer.SetLength(aSize);
   for (uint32_t i = 0; i < aSize; ++i) {
     aBuffer.BeginWriting()[i] = i % 10;
   }
 
   nsCOMPtr<nsIInputStream> stream;
   NS_NewCStringInputStream(getter_AddRefs(stream), aBuffer);
   return new SlicedInputStream(stream.forget(), aStart, aLength);
 }
 
 // Helper function for creating a non-seekable nsIInputStream + a
 // SlicedInputStream.
-SlicedInputStream* CreateNonSeekableStreams(uint32_t aSize, uint64_t aStart,
-                                            uint64_t aLength,
-                                            nsCString& aBuffer) {
+static SlicedInputStream* CreateNonSeekableStreams(uint32_t aSize,
+                                                   uint64_t aStart,
+                                                   uint64_t aLength,
+                                                   nsCString& aBuffer) {
   aBuffer.SetLength(aSize);
   for (uint32_t i = 0; i < aSize; ++i) {
     aBuffer.BeginWriting()[i] = i % 10;
   }
 
   RefPtr<NonSeekableStringStream> stream = new NonSeekableStringStream(aBuffer);
   return new SlicedInputStream(stream.forget(), aStart, aLength);
 }
--- a/xpcom/tests/gtest/TestStrings.cpp
+++ b/xpcom/tests/gtest/TestStrings.cpp
@@ -463,17 +463,17 @@ class Strings : public ::testing::Test {
   nsCString mRuThousandUtf8;
   nsCString mThThousandUtf8;
   nsCString mJaThousandUtf8;
   nsCString mKoThousandUtf8;
   nsCString mTrThousandUtf8;
   nsCString mViThousandUtf8;
 };
 
-void test_assign_helper(const nsACString& in, nsACString& _retval) {
+static void test_assign_helper(const nsACString& in, nsACString& _retval) {
   _retval = in;
 }
 
 // Simple helper struct to test if conditionally enabled string functions are
 // working.
 template <typename T>
 struct EnableTest {
   template <typename Q = T, typename EnableIfChar16 = mozilla::Char16OnlyT<Q>>
--- a/xpcom/tests/gtest/TestTArray.cpp
+++ b/xpcom/tests/gtest/TestTArray.cpp
@@ -52,29 +52,29 @@ struct nsTArray_CopyChooser<TestTArray::
 
 template <>
 struct nsTArray_CopyChooser<TestTArray::Movable> {
   typedef nsTArray_CopyWithConstructors<TestTArray::Movable> Type;
 };
 
 namespace TestTArray {
 
-const nsTArray<int>& DummyArray() {
+static const nsTArray<int>& DummyArray() {
   static nsTArray<int> sArray;
   if (sArray.IsEmpty()) {
     const int data[] = {4, 1, 2, 8};
     sArray.AppendElements(data, ArrayLength(data));
   }
   return sArray;
 }
 
 // This returns an invalid nsTArray with a huge length in order to test that
 // fallible operations actually fail.
 #ifdef DEBUG
-const nsTArray<int>& FakeHugeArray() {
+static const nsTArray<int>& FakeHugeArray() {
   static nsTArray<int> sArray;
   if (sArray.IsEmpty()) {
     sArray.AppendElement();
     ((nsTArrayHeader*)sArray.DebugGetHeader())->mLength = UINT32_MAX;
   }
   return sArray;
 }
 #endif
--- a/xpcom/tests/gtest/TestThrottledEventQueue.cpp
+++ b/xpcom/tests/gtest/TestThrottledEventQueue.cpp
@@ -88,17 +88,17 @@ struct RunnableQueue : nsISerialEventTar
   NS_DECL_THREADSAFE_ISUPPORTS
 
  private:
   virtual ~RunnableQueue() {}
 };
 
 NS_IMPL_ISUPPORTS(RunnableQueue, nsIEventTarget, nsISerialEventTarget)
 
-void Enqueue(nsIEventTarget* target, function<void()>&& aCallable) {
+static void Enqueue(nsIEventTarget* target, function<void()>&& aCallable) {
   nsresult rv =
       target->Dispatch(NS_NewRunnableFunction("TEQ GTest", move(aCallable)));
   MOZ_ALWAYS_TRUE(NS_SUCCEEDED(rv));
 }
 
 }  // namespace TestThrottledEventQueue
 
 using namespace TestThrottledEventQueue;
--- a/xpcom/threads/BlockingResourceBase.cpp
+++ b/xpcom/threads/BlockingResourceBase.cpp
@@ -78,17 +78,17 @@ void BlockingResourceBase::GetStackTrace
  * negative.
  *
  * *NOT* thread safe.  Calls |Print()|.
  *
  * FIXME bug 456272 hack alert: because we can't write call
  * contexts into strings, all info is written to stderr, but only
  * some info is written into |aOut|
  */
-bool PrintCycle(
+static bool PrintCycle(
     const BlockingResourceBase::DDT::ResourceAcquisitionArray* aCycle,
     nsACString& aOut) {
   NS_ASSERTION(aCycle->Length() > 1, "need > 1 element for cycle!");
 
   bool maybeImminent = true;
 
   fputs("=== Cyclical dependency starts at\n", stderr);
   aOut += "Cyclical dependency starts at\n";
--- a/xpcom/threads/CPUUsageWatcher.cpp
+++ b/xpcom/threads/CPUUsageWatcher.cpp
@@ -33,27 +33,28 @@ struct CPUStats {
 };
 
 #  ifdef XP_MACOSX
 
 static const uint64_t kMicrosecondsPerSecond = 1000000LL;
 static const uint64_t kNanosecondsPerMicrosecond = 1000LL;
 static const uint64_t kCPUCheckInterval = kMicrosecondsPerSecond / 2LL;
 
-uint64_t GetMicroseconds(timeval time) {
+static uint64_t GetMicroseconds(timeval time) {
   return ((uint64_t)time.tv_sec) * kMicrosecondsPerSecond +
          (uint64_t)time.tv_usec;
 }
 
-uint64_t GetMicroseconds(mach_timespec_t time) {
+static uint64_t GetMicroseconds(mach_timespec_t time) {
   return ((uint64_t)time.tv_sec) * kMicrosecondsPerSecond +
          ((uint64_t)time.tv_nsec) / kNanosecondsPerMicrosecond;
 }
 
-Result<CPUStats, CPUUsageWatcherError> GetProcessCPUStats(int32_t numCPUs) {
+static Result<CPUStats, CPUUsageWatcherError> GetProcessCPUStats(
+    int32_t numCPUs) {
   CPUStats result = {};
   rusage usage;
   int32_t rusageResult = getrusage(RUSAGE_SELF, &usage);
   if (rusageResult == -1) {
     return Err(GetProcessTimesError);
   }
   result.usageTime =
       GetMicroseconds(usage.ru_utime) + GetMicroseconds(usage.ru_stime);
@@ -72,17 +73,17 @@ Result<CPUStats, CPUUsageWatcherError> G
   result.updateTime = GetMicroseconds(time);
 
   // getrusage will give us the sum of the values across all
   // of our cores. Divide by the number of CPUs to get an average.
   result.usageTime /= numCPUs;
   return result;
 }
 
-Result<CPUStats, CPUUsageWatcherError> GetGlobalCPUStats() {
+static Result<CPUStats, CPUUsageWatcherError> GetGlobalCPUStats() {
   CPUStats result = {};
   host_cpu_load_info_data_t loadInfo;
   mach_msg_type_number_t loadInfoCount = HOST_CPU_LOAD_INFO_COUNT;
   kern_return_t statsResult =
       host_statistics(mach_host_self(), HOST_CPU_LOAD_INFO,
                       (host_info_t)&loadInfo, &loadInfoCount);
   if (statsResult != KERN_SUCCESS) {
     return Err(HostStatisticsError);
--- a/xpcom/threads/nsTimerImpl.cpp
+++ b/xpcom/threads/nsTimerImpl.cpp
@@ -188,17 +188,17 @@ nsresult NS_NewTimerWithFuncCallback(nsI
 // This will show how often each unique line appears, with the most common ones
 // first.
 //
 // More detailed docs are here:
 // https://developer.mozilla.org/en-US/docs/Mozilla/Performance/TimerFirings_logging
 //
 static mozilla::LazyLogModule sTimerFiringsLog("TimerFirings");
 
-mozilla::LogModule* GetTimerFiringsLog() { return sTimerFiringsLog; }
+static mozilla::LogModule* GetTimerFiringsLog() { return sTimerFiringsLog; }
 
 #include <math.h>
 
 double nsTimerImpl::sDeltaSumSquared = 0;
 double nsTimerImpl::sDeltaSum = 0;
 double nsTimerImpl::sDeltaNum = 0;
 
 static void myNS_MeanAndStdDev(double n, double sumOfValues,