diff --git a/browser/extensions/pdfjs/README.mozilla b/browser/extensions/pdfjs/README.mozilla index 9d7b7b7cb766..6c58a4d1bcf4 100644 --- a/browser/extensions/pdfjs/README.mozilla +++ b/browser/extensions/pdfjs/README.mozilla @@ -1,5 +1,5 @@ This is the PDF.js project output, https://github.com/mozilla/pdf.js -Current extension version is: 2.2.67 +Current extension version is: 2.2.71 -Taken from upstream commit: d587abbc +Taken from upstream commit: 80135378 diff --git a/browser/extensions/pdfjs/content/build/pdf.js b/browser/extensions/pdfjs/content/build/pdf.js index 7884cbdf7c2d..24f8c6990ed9 100644 --- a/browser/extensions/pdfjs/content/build/pdf.js +++ b/browser/extensions/pdfjs/content/build/pdf.js @@ -123,8 +123,8 @@ return /******/ (function(modules) { // webpackBootstrap "use strict"; -var pdfjsVersion = '2.2.67'; -var pdfjsBuild = 'd587abbc'; +var pdfjsVersion = '2.2.71'; +var pdfjsBuild = '80135378'; var pdfjsSharedUtil = __w_pdfjs_require__(1); @@ -196,6 +196,7 @@ exports.createPromiseCapability = createPromiseCapability; exports.getVerbosityLevel = getVerbosityLevel; exports.info = info; exports.isArrayBuffer = isArrayBuffer; +exports.isArrayEqual = isArrayEqual; exports.isBool = isBool; exports.isEmptyObj = isEmptyObj; exports.isNum = isNum; @@ -974,6 +975,16 @@ function isArrayBuffer(v) { return typeof v === 'object' && v !== null && v.byteLength !== undefined; } +function isArrayEqual(arr1, arr2) { + if (arr1.length !== arr2.length) { + return false; + } + + return arr1.every(function (element, index) { + return element === arr2[index]; + }); +} + function isSpace(ch) { return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A; } @@ -1290,7 +1301,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) { return worker.messageHandler.sendWithPromise('GetDocRequest', { docId, - apiVersion: '2.2.67', + apiVersion: '2.2.71', source: { data: source.data, url: source.url, @@ -1418,8 +1429,7 @@ class PDFDataRangeTransport { exports.PDFDataRangeTransport = PDFDataRangeTransport; class PDFDocumentProxy { - constructor(pdfInfo, transport, loadingTask) { - this.loadingTask = loadingTask; + constructor(pdfInfo, transport) { this._pdfInfo = pdfInfo; this._transport = transport; } @@ -1504,6 +1514,10 @@ class PDFDocumentProxy { return this._transport.loadingParams; } + get loadingTask() { + return this._transport.loadingTask; + } + } exports.PDFDocumentProxy = PDFDocumentProxy; @@ -2371,10 +2385,9 @@ class WorkerTransport { messageHandler.on('GetDoc', function ({ pdfInfo }) { - this.numPages = pdfInfo.numPages; - this.pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask); + this._numPages = pdfInfo.numPages; - loadingTask._capability.resolve(this.pdfDocument); + loadingTask._capability.resolve(new PDFDocumentProxy(pdfInfo, this)); }, this); messageHandler.on('PasswordRequest', function (exception) { this._passwordCapability = (0, _util.createPromiseCapability)(); @@ -2671,7 +2684,7 @@ class WorkerTransport { } getPage(pageNumber) { - if (!Number.isInteger(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) { + if (!Number.isInteger(pageNumber) || pageNumber <= 0 || pageNumber > this._numPages) { return Promise.reject(new Error('Invalid page request')); } @@ -3033,9 +3046,9 @@ const InternalRenderTask = function InternalRenderTaskClosure() { return InternalRenderTask; }(); -const version = '2.2.67'; +const version = '2.2.71'; exports.version = version; -const build = 'd587abbc'; +const build = '80135378'; exports.build = build; /***/ }), diff --git a/browser/extensions/pdfjs/content/build/pdf.worker.js b/browser/extensions/pdfjs/content/build/pdf.worker.js index e2ae57ca0066..10cd243299a7 100644 --- a/browser/extensions/pdfjs/content/build/pdf.worker.js +++ b/browser/extensions/pdfjs/content/build/pdf.worker.js @@ -123,8 +123,8 @@ return /******/ (function(modules) { // webpackBootstrap "use strict"; -const pdfjsVersion = '2.2.67'; -const pdfjsBuild = 'd587abbc'; +const pdfjsVersion = '2.2.71'; +const pdfjsBuild = '80135378'; const pdfjsCoreWorker = __w_pdfjs_require__(1); @@ -378,7 +378,7 @@ var WorkerMessageHandler = { var WorkerTasks = []; const verbosity = (0, _util.getVerbosityLevel)(); let apiVersion = docParams.apiVersion; - let workerVersion = '2.2.67'; + let workerVersion = '2.2.71'; if (apiVersion !== workerVersion) { throw new Error(`The API version "${apiVersion}" does not match ` + `the Worker version "${workerVersion}".`); @@ -844,6 +844,7 @@ exports.createPromiseCapability = createPromiseCapability; exports.getVerbosityLevel = getVerbosityLevel; exports.info = info; exports.isArrayBuffer = isArrayBuffer; +exports.isArrayEqual = isArrayEqual; exports.isBool = isBool; exports.isEmptyObj = isEmptyObj; exports.isNum = isNum; @@ -1622,6 +1623,16 @@ function isArrayBuffer(v) { return typeof v === 'object' && v !== null && v.byteLength !== undefined; } +function isArrayEqual(arr1, arr2) { + if (arr1.length !== arr2.length) { + return false; + } + + return arr1.every(function (element, index) { + return element === arr2[index]; + }); +} + function isSpace(ch) { return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A; } @@ -20801,12 +20812,11 @@ var PartialEvaluator = function PartialEvaluatorClosure() { textContentItem.fontName = font.loadedName; var tsm = [textState.fontSize * textState.textHScale, 0, 0, textState.fontSize, 0, textState.textRise]; - if (font.isType3Font && textState.fontMatrix !== _util.FONT_IDENTITY_MATRIX && textState.fontSize === 1) { - var glyphHeight = font.bbox[3] - font.bbox[1]; + if (font.isType3Font && textState.fontSize <= 1 && !(0, _util.isArrayEqual)(textState.fontMatrix, _util.FONT_IDENTITY_MATRIX)) { + const glyphHeight = font.bbox[3] - font.bbox[1]; if (glyphHeight > 0) { - glyphHeight = glyphHeight * textState.fontMatrix[3]; - tsm[3] *= glyphHeight; + tsm[3] *= glyphHeight * textState.fontMatrix[3]; } } diff --git a/browser/extensions/pdfjs/moz.yaml b/browser/extensions/pdfjs/moz.yaml index 988b3a73ff92..78a3d01189f3 100644 --- a/browser/extensions/pdfjs/moz.yaml +++ b/browser/extensions/pdfjs/moz.yaml @@ -20,7 +20,7 @@ origin: # Human-readable identifier for this version/release # Generally "version NNN", "tag SSS", "bookmark SSS" - release: version 2.2.67 + release: version 2.2.71 # The package's license, where possible using the mnemonic from # https://spdx.org/licenses/ diff --git a/dom/system/OSFileConstants.cpp b/dom/system/OSFileConstants.cpp index 99086a5affce..3339b5f0b9f3 100644 --- a/dom/system/OSFileConstants.cpp +++ b/dom/system/OSFileConstants.cpp @@ -223,7 +223,7 @@ nsresult OSFileConstantsService::InitOSFileConstants() { // Get the umask from the system-info service. // The property will always be present, but it will be zero on // non-Unix systems. - // nsSystemInfo::gUserUmask is initialized by NS_InitXPCOM2 so we don't need + // nsSystemInfo::gUserUmask is initialized by NS_InitXPCOM so we don't need // to initialize the service. mUserUmask = nsSystemInfo::gUserUmask; diff --git a/js/xpconnect/src/XPCShellImpl.cpp b/js/xpconnect/src/XPCShellImpl.cpp index d26503056e25..2f560835ee54 100644 --- a/js/xpconnect/src/XPCShellImpl.cpp +++ b/js/xpconnect/src/XPCShellImpl.cpp @@ -1233,9 +1233,9 @@ int XRE_XPCShellMain(int argc, char** argv, char** envp, } nsCOMPtr servMan; - rv = NS_InitXPCOM2(getter_AddRefs(servMan), appDir, &dirprovider); + rv = NS_InitXPCOM(getter_AddRefs(servMan), appDir, &dirprovider); if (NS_FAILED(rv)) { - printf("NS_InitXPCOM2 failed!\n"); + printf("NS_InitXPCOM failed!\n"); return 1; } diff --git a/layout/style/test/ParseCSS.cpp b/layout/style/test/ParseCSS.cpp index 839fa8ca765b..82a4b91f4bb2 100644 --- a/layout/style/test/ParseCSS.cpp +++ b/layout/style/test/ParseCSS.cpp @@ -57,7 +57,7 @@ int main(int argc, char **argv) { if (argc < 2) { fprintf(stderr, "%s [FILE]...\n", argv[0]); } - nsresult rv = NS_InitXPCOM2(nullptr, nullptr, nullptr); + nsresult rv = NS_InitXPCOM(nullptr, nullptr, nullptr); if (NS_FAILED(rv)) return (int)rv; int res = 0; diff --git a/layout/style/test/TestCSSPropertyLookup.cpp b/layout/style/test/TestCSSPropertyLookup.cpp index 9c55dc46d02a..b4a2ed4164c4 100644 --- a/layout/style/test/TestCSSPropertyLookup.cpp +++ b/layout/style/test/TestCSSPropertyLookup.cpp @@ -84,7 +84,7 @@ bool TestKeywords() { } int main(void) { - nsresult rv = NS_InitXPCOM2(nullptr, nullptr, nullptr); + nsresult rv = NS_InitXPCOM(nullptr, nullptr, nullptr); NS_ENSURE_SUCCESS(rv, 2); bool testOK = true; diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index ba29e6512db2..43e758d04b12 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -1293,8 +1293,8 @@ nsresult ScopedXPCOMStartup::Initialize() { nsresult rv; - rv = NS_InitXPCOM2(&mServiceManager, gDirServiceProvider->GetAppDir(), - gDirServiceProvider); + rv = NS_InitXPCOM(&mServiceManager, gDirServiceProvider->GetAppDir(), + gDirServiceProvider); if (NS_FAILED(rv)) { NS_ERROR("Couldn't start xpcom!"); mServiceManager = nullptr; diff --git a/toolkit/xre/nsEmbedFunctions.cpp b/toolkit/xre/nsEmbedFunctions.cpp index 2c4f45ba8567..2d89b1ddeffe 100644 --- a/toolkit/xre/nsEmbedFunctions.cpp +++ b/toolkit/xre/nsEmbedFunctions.cpp @@ -190,7 +190,7 @@ nsresult XRE_InitEmbedding2(nsIFile* aLibXULDirectory, nsIFile* aAppDirectory, aAppDirProvider); if (NS_FAILED(rv)) return rv; - rv = NS_InitXPCOM2(nullptr, aAppDirectory, gDirServiceProvider); + rv = NS_InitXPCOM(nullptr, aAppDirectory, gDirServiceProvider); if (NS_FAILED(rv)) return rv; // We do not need to autoregister components here. The CheckCompatibility() diff --git a/tools/fuzzing/interface/harness/FuzzerTestHarness.h b/tools/fuzzing/interface/harness/FuzzerTestHarness.h index 9bc020744f1a..cc54f7eecb5a 100644 --- a/tools/fuzzing/interface/harness/FuzzerTestHarness.h +++ b/tools/fuzzing/interface/harness/FuzzerTestHarness.h @@ -67,9 +67,9 @@ class ScopedXPCOM : public nsIDirectoryServiceProvider2 { mTestName = testName; printf("Running %s tests...\n", mTestName); - nsresult rv = NS_InitXPCOM2(&mServMgr, nullptr, this); + nsresult rv = NS_InitXPCOM(&mServMgr, nullptr, this); if (NS_FAILED(rv)) { - fail("NS_InitXPCOM2 returned failure code 0x%" PRIx32, + fail("NS_InitXPCOM returned failure code 0x%" PRIx32, static_cast(rv)); mServMgr = nullptr; return; diff --git a/xpcom/base/LogModulePrefWatcher.cpp b/xpcom/base/LogModulePrefWatcher.cpp index 955d181b3bfe..011ab5f4a15a 100644 --- a/xpcom/base/LogModulePrefWatcher.cpp +++ b/xpcom/base/LogModulePrefWatcher.cpp @@ -34,7 +34,7 @@ NS_IMPL_ISUPPORTS(LogModulePrefWatcher, nsIObserver) * 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, @@ -106,7 +106,7 @@ static void LoadPrefValue(const char* aName) { LogModule::Get(moduleName)->SetLevel(logLevel); } -void LoadExistingPrefs() { +static void LoadExistingPrefs() { nsIPrefBranch* root = Preferences::GetRootBranch(); if (!root) { return; diff --git a/xpcom/base/Logging.cpp b/xpcom/base/Logging.cpp index e464a2856205..3cb0ef664e0b 100644 --- a/xpcom/base/Logging.cpp +++ b/xpcom/base/Logging.cpp @@ -80,7 +80,7 @@ LogLevel ToLogLevel(int32_t aLevel) { return static_cast(aLevel); } -const char* ToLogStr(LogLevel aLevel) { +static const char* ToLogStr(LogLevel aLevel) { switch (aLevel) { case LogLevel::Error: return "E"; @@ -127,7 +127,8 @@ class LogFile { 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); diff --git a/xpcom/base/nsCycleCollector.cpp b/xpcom/base/nsCycleCollector.cpp index fc28718ed51f..957260ba57ac 100644 --- a/xpcom/base/nsCycleCollector.cpp +++ b/xpcom/base/nsCycleCollector.cpp @@ -209,9 +209,9 @@ 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) { diff --git a/xpcom/base/nsSystemInfo.cpp b/xpcom/base/nsSystemInfo.cpp index be35dd64f6b9..b7ed0b3bd2f7 100644 --- a/xpcom/base/nsSystemInfo.cpp +++ b/xpcom/base/nsSystemInfo.cpp @@ -66,7 +66,7 @@ # include "mozilla/SandboxInfo.h" #endif -// Slot for NS_InitXPCOM2 to pass information to nsSystemInfo::Init. +// Slot for NS_InitXPCOM to pass information to nsSystemInfo::Init. // Only set to nonzero (potentially) if XP_UNIX. On such systems, the // system call to discover the appropriate value is not thread-safe, // so we must call it before going multithreaded, but nsSystemInfo::Init diff --git a/xpcom/base/nsSystemInfo.h b/xpcom/base/nsSystemInfo.h index 434ea497be9d..3ca0a7e4239b 100644 --- a/xpcom/base/nsSystemInfo.h +++ b/xpcom/base/nsSystemInfo.h @@ -32,8 +32,8 @@ class nsSystemInfo final : public nsHashPropertyBag nsresult Init(); - // Slot for NS_InitXPCOM2 to pass information to nsSystemInfo::Init. - // See comments above the variable definition and in NS_InitXPCOM2. + // Slot for NS_InitXPCOM to pass information to nsSystemInfo::Init. + // See comments above the variable definition and in NS_InitXPCOM. static uint32_t gUserUmask; #ifdef MOZ_WIDGET_ANDROID diff --git a/xpcom/build/XPCOMInit.cpp b/xpcom/build/XPCOMInit.cpp index db28de1f3240..e7d5d51785b1 100644 --- a/xpcom/build/XPCOMInit.cpp +++ b/xpcom/build/XPCOMInit.cpp @@ -203,11 +203,6 @@ NS_GetDebug(nsIDebug2** aResult) { return nsDebugImpl::Create(nullptr, NS_GET_IID(nsIDebug2), (void**)aResult); } -EXPORT_XPCOM_API(nsresult) -NS_InitXPCOM(nsIServiceManager** aResult, nsIFile* aBinDirectory) { - return NS_InitXPCOM2(aResult, aBinDirectory, nullptr); -} - class ICUReporter final : public nsIMemoryReporter, public CountingAllocatorBase { public: @@ -273,8 +268,8 @@ static bool sInitializedJS = false; // Note that on OSX, aBinDirectory will point to .app/Contents/Resources/browser EXPORT_XPCOM_API(nsresult) -NS_InitXPCOM2(nsIServiceManager** aResult, nsIFile* aBinDirectory, - nsIDirectoryServiceProvider* aAppFileLocationProvider) { +NS_InitXPCOM(nsIServiceManager** aResult, nsIFile* aBinDirectory, + nsIDirectoryServiceProvider* aAppFileLocationProvider) { static bool sInitialized = false; if (sInitialized) { return NS_ERROR_FAILURE; diff --git a/xpcom/build/nsXPCOM.h b/xpcom/build/nsXPCOM.h index e326dd0de2f5..9dbed182b7c2 100644 --- a/xpcom/build/nsXPCOM.h +++ b/xpcom/build/nsXPCOM.h @@ -73,8 +73,8 @@ struct Module; * initialisation. */ XPCOM_API(nsresult) -NS_InitXPCOM2(nsIServiceManager** aResult, nsIFile* aBinDirectory, - nsIDirectoryServiceProvider* aAppFileLocationProvider); +NS_InitXPCOM(nsIServiceManager** aResult, nsIFile* aBinDirectory, + nsIDirectoryServiceProvider* aAppFileLocationProvider); /** * Initialize only minimal components of XPCOM. This ensures nsThreadManager, diff --git a/xpcom/components/nsCategoryManager.cpp b/xpcom/components/nsCategoryManager.cpp index 3e0dacdb67ce..d70b224d84e3 100644 --- a/xpcom/components/nsCategoryManager.cpp +++ b/xpcom/components/nsCategoryManager.cpp @@ -4,8 +4,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "nsICategoryManager.h" #include "nsCategoryManager.h" +#include "nsCategoryManagerUtils.h" #include "prio.h" #include "prlock.h" diff --git a/xpcom/components/nsComponentManager.cpp b/xpcom/components/nsComponentManager.cpp index 717b24322623..915e493a0e4b 100644 --- a/xpcom/components/nsComponentManager.cpp +++ b/xpcom/components/nsComponentManager.cpp @@ -418,13 +418,13 @@ extern mozilla::Module const* const __stop_kPStaticModules __asm( # 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; } diff --git a/xpcom/ds/Dafsa.cpp b/xpcom/ds/Dafsa.cpp index c30b428cd808..8854e0ff1de8 100644 --- a/xpcom/ds/Dafsa.cpp +++ b/xpcom/ds/Dafsa.cpp @@ -20,8 +20,8 @@ const int mozilla::Dafsa::kKeyNotFound = -1; // 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 @@ -52,31 +52,31 @@ bool GetNextOffset(const unsigned char** pos, const unsigned char* end, } // 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; @@ -88,8 +88,8 @@ bool GetReturnValue(const unsigned char* offset, const unsigned char* end, // 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; diff --git a/xpcom/io/CocoaFileUtils.mm b/xpcom/io/CocoaFileUtils.mm index 099bd5051603..8bdc0877e509 100644 --- a/xpcom/io/CocoaFileUtils.mm +++ b/xpcom/io/CocoaFileUtils.mm @@ -192,7 +192,7 @@ void AddOriginMetadataToFile(const CFStringRef filePath, const CFURLRef sourceUR } // Can be called off of the main thread. -CFStringRef GetQuarantinePropKey() { +static CFStringRef GetQuarantinePropKey() { if (nsCocoaFeatures::OnYosemiteOrLater()) { return kCFURLQuarantinePropertiesKey; } @@ -200,8 +200,8 @@ CFStringRef GetQuarantinePropKey() { } // 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) { diff --git a/xpcom/io/nsDirectoryServiceDefs.h b/xpcom/io/nsDirectoryServiceDefs.h index b178cd3c20a4..c134ca8c2c0e 100644 --- a/xpcom/io/nsDirectoryServiceDefs.h +++ b/xpcom/io/nsDirectoryServiceDefs.h @@ -40,7 +40,7 @@ /* This location is similar to NS_OS_CURRENT_PROCESS_DIR, however, * NS_XPCOM_CURRENT_PROCESS_DIR can be overriden by passing a "bin - * directory" to NS_InitXPCOM2(). + * directory" to NS_InitXPCOM(). */ #define NS_XPCOM_CURRENT_PROCESS_DIR "XCurProcD" diff --git a/xpcom/io/nsPipe3.cpp b/xpcom/io/nsPipe3.cpp index 2fdb106987d6..4d689869d9be 100644 --- a/xpcom/io/nsPipe3.cpp +++ b/xpcom/io/nsPipe3.cpp @@ -22,6 +22,7 @@ #include "nsIClassInfoImpl.h" #include "nsAlgorithm.h" #include "nsMemory.h" +#include "nsPipe.h" #include "nsIAsyncInputStream.h" #include "nsIAsyncOutputStream.h" diff --git a/xpcom/io/nsStringStream.cpp b/xpcom/io/nsStringStream.cpp index d6c422b5c150..a08712d79d1a 100644 --- a/xpcom/io/nsStringStream.cpp +++ b/xpcom/io/nsStringStream.cpp @@ -24,6 +24,7 @@ #include "mozilla/ipc/InputStreamUtils.h" #include "mozilla/ReentrantMonitor.h" #include "nsIIPCSerializableInputStream.h" +#include "XPCOMModule.h" using namespace mozilla::ipc; using mozilla::Maybe; diff --git a/xpcom/rust/gtest/bench-collections/Bench.cpp b/xpcom/rust/gtest/bench-collections/Bench.cpp index 2c4c4df80a02..6bce28cbefec 100644 --- a/xpcom/rust/gtest/bench-collections/Bench.cpp +++ b/xpcom/rust/gtest/bench-collections/Bench.cpp @@ -62,7 +62,7 @@ using namespace mozilla; // - 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; @@ -82,7 +82,8 @@ struct Params { // 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 hs; for (size_t j = 0; j < aParams->mNumInserts; j++) { @@ -122,7 +123,8 @@ void Bench_Cpp_unordered_set(const Params* aParams, void** aVals, size_t aLen) { } // 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++) { @@ -163,7 +165,8 @@ void Bench_Cpp_PLDHashTable(const Params* aParams, void** aVals, size_t aLen) { } // 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, MallocAllocPolicy> hs; for (size_t j = 0; j < aParams->mNumInserts; j++) { diff --git a/xpcom/tests/RegFactory.cpp b/xpcom/tests/RegFactory.cpp index 64d9bd5e7843..cb5ba00d2692 100644 --- a/xpcom/tests/RegFactory.cpp +++ b/xpcom/tests/RegFactory.cpp @@ -101,7 +101,7 @@ int main(int argc, char *argv[]) { nsresult rv; { nsCOMPtr servMan; - rv = NS_InitXPCOM2(getter_AddRefs(servMan), nullptr, nullptr); + rv = NS_InitXPCOM(getter_AddRefs(servMan), nullptr, nullptr); if (NS_FAILED(rv)) return -1; nsCOMPtr registrar = do_QueryInterface(servMan); NS_ASSERTION(registrar, "Null nsIComponentRegistrar"); diff --git a/xpcom/tests/TestHarness.h b/xpcom/tests/TestHarness.h index 4cb1586f0bcd..123841a1f0ad 100644 --- a/xpcom/tests/TestHarness.h +++ b/xpcom/tests/TestHarness.h @@ -82,9 +82,9 @@ class ScopedXPCOM : public nsIDirectoryServiceProvider2 { mTestName = testName; printf("Running %s tests...\n", mTestName); - nsresult rv = NS_InitXPCOM2(&mServMgr, nullptr, this); + nsresult rv = NS_InitXPCOM(&mServMgr, nullptr, this); if (NS_FAILED(rv)) { - fail("NS_InitXPCOM2 returned failure code 0x%" PRIx32, + fail("NS_InitXPCOM returned failure code 0x%" PRIx32, static_cast(rv)); mServMgr = nullptr; return; diff --git a/xpcom/tests/TestShutdown.cpp b/xpcom/tests/TestShutdown.cpp index c6e6cbfb8068..4b277d423c7e 100644 --- a/xpcom/tests/TestShutdown.cpp +++ b/xpcom/tests/TestShutdown.cpp @@ -8,10 +8,9 @@ // Gee this seems simple! It's for testing for memory leaks with Purify. void main(int argc, char* argv[]) { - nsresult rv; nsIServiceManager* servMgr; - rv = NS_InitXPCOM2(&servMgr, nullptr, nullptr); - NS_ASSERTION(NS_SUCCEEDED(rv), "NS_InitXPCOM failed"); + nsresult rv = NS_InitXPCOM(&servMgr, nullptr, nullptr); + MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv), "NS_InitXPCOM failed"); // try loading a component and releasing it to see if it leaks if (argc > 1 && argv[1] != nullptr) { @@ -34,5 +33,5 @@ void main(int argc, char* argv[]) { } rv = NS_ShutdownXPCOM(servMgr); - NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed"); + MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed"); } diff --git a/xpcom/tests/TestStreamUtils.cpp b/xpcom/tests/TestStreamUtils.cpp index e787b2fb8ad2..ab414cb3251c 100644 --- a/xpcom/tests/TestStreamUtils.cpp +++ b/xpcom/tests/TestStreamUtils.cpp @@ -51,7 +51,7 @@ int main(int argc, char** argv) { int count = 1; if (argc > 1) count = atoi(argv[1]); - if (NS_FAILED(NS_InitXPCOM2(nullptr, nullptr, nullptr))) return -1; + if (NS_FAILED(NS_InitXPCOM(nullptr, nullptr, nullptr))) return -1; while (count--) { for (const Test* t = tests; t->name != nullptr; ++t) { diff --git a/xpcom/tests/gtest/TestAtoms.cpp b/xpcom/tests/gtest/TestAtoms.cpp index c3c0c94745d7..d064fdc96820 100644 --- a/xpcom/tests/gtest/TestAtoms.cpp +++ b/xpcom/tests/gtest/TestAtoms.cpp @@ -111,7 +111,7 @@ TEST(Atoms, Invalid) { #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. diff --git a/xpcom/tests/gtest/TestCOMPtr.cpp b/xpcom/tests/gtest/TestCOMPtr.cpp index a96aef0a3a9e..61b1604a8410 100644 --- a/xpcom/tests/gtest/TestCOMPtr.cpp +++ b/xpcom/tests/gtest/TestCOMPtr.cpp @@ -84,7 +84,7 @@ nsresult IFoo::QueryInterface(const nsIID& aIID, void** aResult) { return status; } -nsresult CreateIFoo(void** result) +static nsresult CreateIFoo(void** result) // a typical factory function (that calls AddRef) { auto* foop = new IFoo; @@ -95,14 +95,14 @@ nsresult CreateIFoo(void** result) return NS_OK; } -void set_a_IFoo(nsCOMPtr* result) { +static void set_a_IFoo(nsCOMPtr* 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 foop(do_QueryInterface(static_cast(new IFoo))); *result = foop; } -nsCOMPtr return_a_IFoo() { +static nsCOMPtr return_a_IFoo() { nsCOMPtr foop(do_QueryInterface(static_cast(new IFoo))); return foop; } @@ -161,7 +161,7 @@ nsresult IBar::QueryInterface(const nsID& aIID, void** aResult) { return status; } -nsresult CreateIBar(void** result) +static nsresult CreateIBar(void** result) // a typical factory function (that calls AddRef) { auto* barp = new IBar; @@ -172,11 +172,11 @@ nsresult CreateIBar(void** result) 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 @@ -260,7 +260,7 @@ TEST(COMPtr, AddRefAndRelease) { ASSERT_EQ(IBar::total_destructions_, 1); } -void Comparison() { +TEST(COMPtr, Comparison) { IFoo::total_constructions_ = 0; IFoo::total_destructions_ = 0; @@ -295,7 +295,7 @@ void Comparison() { ASSERT_EQ(IFoo::total_destructions_, 2); } -void DontAddRef() { +TEST(COMPtr, DontAddRef) { { auto* raw_foo1p = new IFoo; raw_foo1p->AddRef(); diff --git a/xpcom/tests/gtest/TestCRT.cpp b/xpcom/tests/gtest/TestCRT.cpp index 595d104c42e4..cbcc375bd1dd 100644 --- a/xpcom/tests/gtest/TestCRT.cpp +++ b/xpcom/tests/gtest/TestCRT.cpp @@ -14,7 +14,7 @@ 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 { diff --git a/xpcom/tests/gtest/TestCallTemplates.cpp b/xpcom/tests/gtest/TestCallTemplates.cpp index 7dfd0847acec..bd262dfa4a04 100644 --- a/xpcom/tests/gtest/TestCallTemplates.cpp +++ b/xpcom/tests/gtest/TestCallTemplates.cpp @@ -69,7 +69,7 @@ NS_IMPL_ISUPPORTS(nsTestService, nsITestService, nsISupportsWeakReference) } 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 diff --git a/xpcom/tests/gtest/TestDeadlockDetector.cpp b/xpcom/tests/gtest/TestDeadlockDetector.cpp index 61a0db1ab21c..2fa0036fd40f 100644 --- a/xpcom/tests/gtest/TestDeadlockDetector.cpp +++ b/xpcom/tests/gtest/TestDeadlockDetector.cpp @@ -59,7 +59,7 @@ class TESTNAME(DeadlockDetectorTest) : public ::testing::Test { unsigned int mOldSleepDuration; }; -void DisableCrashReporter() { +static void DisableCrashReporter() { nsCOMPtr crashreporter = do_GetService("@mozilla.org/toolkit/crash-reporter;1"); if (crashreporter) { @@ -71,7 +71,7 @@ void DisableCrashReporter() { // Single-threaded sanity tests // Stupidest possible deadlock. -int Sanity_Child() { +static int Sanity_Child() { DisableCrashReporter(); MUTEX m1("dd.sanity.m1"); @@ -92,7 +92,7 @@ TEST_F(TESTNAME(DeadlockDetectorTest), TESTNAME(SanityDeathTest)) { } // Slightly less stupid deadlock. -int Sanity2_Child() { +static int Sanity2_Child() { DisableCrashReporter(); MUTEX m1("dd.sanity2.m1"); @@ -156,7 +156,7 @@ TEST_F(TESTNAME(DeadlockDetectorTest), TESTNAME(Sanity3DeathTest)) } #endif -int Sanity4_Child() { +static int Sanity4_Child() { DisableCrashReporter(); mozilla::ReentrantMonitor m1("dd.sanity4.m1"); @@ -179,7 +179,7 @@ TEST_F(TESTNAME(DeadlockDetectorTest), TESTNAME(Sanity4DeathTest)) { ASSERT_DEATH_IF_SUPPORTED(Sanity4_Child(), regex); } -int Sanity5_Child() { +static int Sanity5_Child() { DisableCrashReporter(); mozilla::RecursiveMutex m1("dd.sanity4.m1"); @@ -300,7 +300,7 @@ static void ContentionNoDeadlock_thread(void* arg) { } } -int ContentionNoDeadlock_Child() { +static int ContentionNoDeadlock_Child() { const size_t kMutexCount = 4; PRThread* threads[3]; diff --git a/xpcom/tests/gtest/TestHashtables.cpp b/xpcom/tests/gtest/TestHashtables.cpp index 73f5d46d8047..c954b3e066d4 100644 --- a/xpcom/tests/gtest/TestHashtables.cpp +++ b/xpcom/tests/gtest/TestHashtables.cpp @@ -37,7 +37,7 @@ struct EntityNode { 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}, @@ -85,8 +85,8 @@ static uint32_t nsTIterPrintRemove(nsTHashtable& hash) { return n; } -void testTHashtable(nsTHashtable& hash, - uint32_t numEntries) { +static void testTHashtable(nsTHashtable& hash, + uint32_t numEntries) { uint32_t i; for (i = 0; i < numEntries; ++i) { EntityToUnicodeEntry* entry = hash.PutEntry(gEntities[i].mStr); @@ -202,7 +202,7 @@ nsresult IFoo::GetString(nsACString& aString) { return NS_OK; } -nsresult CreateIFoo(IFoo** result) +static nsresult CreateIFoo(IFoo** result) // a typical factory function (that calls AddRef) { auto* foop = new IFoo(); diff --git a/xpcom/tests/gtest/TestMoveString.cpp b/xpcom/tests/gtest/TestMoveString.cpp index ddb78e765b1d..fb71d0bf43e0 100644 --- a/xpcom/tests/gtest/TestMoveString.cpp +++ b/xpcom/tests/gtest/TestMoveString.cpp @@ -22,7 +22,7 @@ namespace TestMoveString { 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); @@ -31,13 +31,13 @@ void SetAsOwned(nsACString& aStr, const char* aValue) { 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)); } diff --git a/xpcom/tests/gtest/TestMruCache.cpp b/xpcom/tests/gtest/TestMruCache.cpp index c04d8086a473..9b5ccb57a340 100644 --- a/xpcom/tests/gtest/TestMruCache.cpp +++ b/xpcom/tests/gtest/TestMruCache.cpp @@ -49,7 +49,7 @@ struct Convertable { }; // Helper to create a StringStructMap key. -nsCString MakeStringKey(char aKey) { +static nsCString MakeStringKey(char aKey) { nsCString key; key.Append(aKey); return key; diff --git a/xpcom/tests/gtest/TestMultiplexInputStream.cpp b/xpcom/tests/gtest/TestMultiplexInputStream.cpp index f695522e2752..f3cdd2268b3b 100644 --- a/xpcom/tests/gtest/TestMultiplexInputStream.cpp +++ b/xpcom/tests/gtest/TestMultiplexInputStream.cpp @@ -103,7 +103,7 @@ TEST(MultiplexInputStream, Seek_SET) { ASSERT_EQ(0, strncmp(readBuf, "The qu", count)); } -already_AddRefed CreateStreamHelper() { +static already_AddRefed CreateStreamHelper() { nsCOMPtr multiplexStream = do_CreateInstance("@mozilla.org/io/multiplex-input-stream;1"); diff --git a/xpcom/tests/gtest/TestNonBlockingAsyncInputStream.cpp b/xpcom/tests/gtest/TestNonBlockingAsyncInputStream.cpp index a74661578d0d..51e99e377eca 100644 --- a/xpcom/tests/gtest/TestNonBlockingAsyncInputStream.cpp +++ b/xpcom/tests/gtest/TestNonBlockingAsyncInputStream.cpp @@ -59,9 +59,9 @@ class ReadSegmentsData { 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(aClosure); if (aInStr != data->mStream) return NS_ERROR_FAILURE; memcpy(&data->mBuffer[aOffset], aBuffer, aCount); diff --git a/xpcom/tests/gtest/TestNsDeque.cpp b/xpcom/tests/gtest/TestNsDeque.cpp index 0c6d3faa1048..b6f080f8436b 100644 --- a/xpcom/tests/gtest/TestNsDeque.cpp +++ b/xpcom/tests/gtest/TestNsDeque.cpp @@ -237,7 +237,7 @@ TEST(NsDeque, TestPushFront) { << "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"; diff --git a/xpcom/tests/gtest/TestNsRefPtr.cpp b/xpcom/tests/gtest/TestNsRefPtr.cpp index 40282794a8aa..cab656216662 100644 --- a/xpcom/tests/gtest/TestNsRefPtr.cpp +++ b/xpcom/tests/gtest/TestNsRefPtr.cpp @@ -102,7 +102,7 @@ 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; @@ -113,14 +113,14 @@ nsresult CreateFoo(void** result) return NS_OK; } -void set_a_Foo(RefPtr* result) { +static void set_a_Foo(RefPtr* result) { assert(result); RefPtr foop(do_QueryObject(new Foo)); *result = foop; } -RefPtr return_a_Foo() { +static RefPtr return_a_Foo() { RefPtr foop(do_QueryObject(new Foo)); return foop; } @@ -388,8 +388,8 @@ class ObjectForConstPtr { #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) { diff --git a/xpcom/tests/gtest/TestPLDHash.cpp b/xpcom/tests/gtest/TestPLDHash.cpp index 4ade6b023633..abea40b96dd8 100644 --- a/xpcom/tests/gtest/TestPLDHash.cpp +++ b/xpcom/tests/gtest/TestPLDHash.cpp @@ -30,7 +30,7 @@ extern unsigned int _gdb_sleep_duration; // 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. @@ -87,19 +87,19 @@ void TestCrashyOperation(void (*aCrashyOperation)()) { #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); } diff --git a/xpcom/tests/gtest/TestPipes.cpp b/xpcom/tests/gtest/TestPipes.cpp index 83bf2543912d..9c8e33d373f6 100644 --- a/xpcom/tests/gtest/TestPipes.cpp +++ b/xpcom/tests/gtest/TestPipes.cpp @@ -95,7 +95,7 @@ class nsReceiver final : public nsIRunnable { NS_IMPL_ISUPPORTS(nsReceiver, nsIRunnable) -nsresult TestPipe(nsIInputStream* in, nsIOutputStream* out) { +static nsresult TestPipe(nsIInputStream* in, nsIOutputStream* out) { RefPtr receiver = new nsReceiver(in); if (!receiver) return NS_ERROR_OUT_OF_MEMORY; @@ -209,7 +209,7 @@ class nsShortReader final : public nsIRunnable { NS_IMPL_ISUPPORTS(nsShortReader, nsIRunnable) -nsresult TestShortWrites(nsIInputStream* in, nsIOutputStream* out) { +static nsresult TestShortWrites(nsIInputStream* in, nsIOutputStream* out) { RefPtr receiver = new nsShortReader(in); if (!receiver) return NS_ERROR_OUT_OF_MEMORY; @@ -351,7 +351,7 @@ TEST(Pipes, ChainedPipes) { //////////////////////////////////////////////////////////////////////////////// -void RunTests(uint32_t segSize, uint32_t segCount) { +static void RunTests(uint32_t segSize, uint32_t segCount) { nsresult rv; nsCOMPtr in; nsCOMPtr out; diff --git a/xpcom/tests/gtest/TestSlicedInputStream.cpp b/xpcom/tests/gtest/TestSlicedInputStream.cpp index c9bc57bb9856..004e3d081a39 100644 --- a/xpcom/tests/gtest/TestSlicedInputStream.cpp +++ b/xpcom/tests/gtest/TestSlicedInputStream.cpp @@ -108,8 +108,9 @@ class NonSeekableStringStream final : public nsIAsyncInputStream { 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; @@ -122,9 +123,10 @@ SlicedInputStream* CreateSeekableStreams(uint32_t aSize, uint64_t aStart, // 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; diff --git a/xpcom/tests/gtest/TestStrings.cpp b/xpcom/tests/gtest/TestStrings.cpp index 81d258de8229..497b6c71c6de 100644 --- a/xpcom/tests/gtest/TestStrings.cpp +++ b/xpcom/tests/gtest/TestStrings.cpp @@ -468,7 +468,7 @@ class Strings : public ::testing::Test { nsCString mViThousandUtf8; }; -void test_assign_helper(const nsACString& in, nsACString& _retval) { +static void test_assign_helper(const nsACString& in, nsACString& _retval) { _retval = in; } diff --git a/xpcom/tests/gtest/TestTArray.cpp b/xpcom/tests/gtest/TestTArray.cpp index 9978421aef12..edd7276436f5 100644 --- a/xpcom/tests/gtest/TestTArray.cpp +++ b/xpcom/tests/gtest/TestTArray.cpp @@ -57,7 +57,7 @@ struct nsTArray_CopyChooser { namespace TestTArray { -const nsTArray& DummyArray() { +static const nsTArray& DummyArray() { static nsTArray sArray; if (sArray.IsEmpty()) { const int data[] = {4, 1, 2, 8}; @@ -69,7 +69,7 @@ const nsTArray& DummyArray() { // This returns an invalid nsTArray with a huge length in order to test that // fallible operations actually fail. #ifdef DEBUG -const nsTArray& FakeHugeArray() { +static const nsTArray& FakeHugeArray() { static nsTArray sArray; if (sArray.IsEmpty()) { sArray.AppendElement(); diff --git a/xpcom/tests/gtest/TestThrottledEventQueue.cpp b/xpcom/tests/gtest/TestThrottledEventQueue.cpp index 64919a6bb10d..91691d6e50fb 100644 --- a/xpcom/tests/gtest/TestThrottledEventQueue.cpp +++ b/xpcom/tests/gtest/TestThrottledEventQueue.cpp @@ -93,7 +93,7 @@ struct RunnableQueue : nsISerialEventTarget { NS_IMPL_ISUPPORTS(RunnableQueue, nsIEventTarget, nsISerialEventTarget) -void Enqueue(nsIEventTarget* target, function&& aCallable) { +static void Enqueue(nsIEventTarget* target, function&& aCallable) { nsresult rv = target->Dispatch(NS_NewRunnableFunction("TEQ GTest", move(aCallable))); MOZ_ALWAYS_TRUE(NS_SUCCEEDED(rv)); diff --git a/xpcom/tests/gtest/TestUTF.cpp b/xpcom/tests/gtest/TestUTF.cpp index 586f033bfaca..a2a50b4b352b 100644 --- a/xpcom/tests/gtest/TestUTF.cpp +++ b/xpcom/tests/gtest/TestUTF.cpp @@ -116,7 +116,7 @@ TEST(UTF, Hash16) { * This tests the handling of a non-ascii character at various locations in a * UTF-16 string that is being converted to UTF-8. */ -void NonASCII16_helper(const size_t aStrSize) { +static void NonASCII16_helper(const size_t aStrSize) { const size_t kTestSize = aStrSize; const size_t kMaxASCII = 0x80; const char16_t kUTF16Char = 0xC9; @@ -154,7 +154,7 @@ void NonASCII16_helper(const size_t aStrSize) { // First add the leading ASCII chars. expected.Append(asciiCString.BeginReading(), i); - // Now append the UTF-8 surrogate pair we expect the UTF-16 unicode char to + // Now append the UTF-8 pair we expect the UTF-16 unicode char to // be converted to. for (auto& c : kUTF8Surrogates) { expected.Append(c); @@ -167,6 +167,15 @@ void NonASCII16_helper(const size_t aStrSize) { } } +TEST(UTF, NonASCII16) { + // Test with various string sizes to catch any special casing. + NonASCII16_helper(1); + NonASCII16_helper(8); + NonASCII16_helper(16); + NonASCII16_helper(32); + NonASCII16_helper(512); +} + TEST(UTF, UTF8CharEnumerator) { const char* p = "\x61\xC0\xC2\xC2\x80\xE0\x80\x80\xE0\xA0\x80\xE1\x80\x80\xED\xBF\xBF\xED" diff --git a/xpcom/tests/windows/TestHelloXPLoop.cpp b/xpcom/tests/windows/TestHelloXPLoop.cpp index c8682ca5c868..627ce497db62 100644 --- a/xpcom/tests/windows/TestHelloXPLoop.cpp +++ b/xpcom/tests/windows/TestHelloXPLoop.cpp @@ -32,7 +32,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prevInstance, LPSTR lpszCmdLine, { // Needed to scope all nsCOMPtr within XPCOM Init and Shutdown nsresult rv; nsCOMPtr servMan; - rv = NS_InitXPCOM2(getter_AddRefs(servMan), nullptr, nullptr); + rv = NS_InitXPCOM(getter_AddRefs(servMan), nullptr, nullptr); if (NS_FAILED(rv)) { ErrorBox("Failed to initialize xpcom."); return -1; diff --git a/xpcom/threads/BlockingResourceBase.cpp b/xpcom/threads/BlockingResourceBase.cpp index 8963abfa458a..c3918573d5cb 100644 --- a/xpcom/threads/BlockingResourceBase.cpp +++ b/xpcom/threads/BlockingResourceBase.cpp @@ -83,7 +83,7 @@ void BlockingResourceBase::GetStackTrace(AcquisitionState& aState) { * 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!"); diff --git a/xpcom/threads/CPUUsageWatcher.cpp b/xpcom/threads/CPUUsageWatcher.cpp index 7f615c87ac81..68f8662bbce2 100644 --- a/xpcom/threads/CPUUsageWatcher.cpp +++ b/xpcom/threads/CPUUsageWatcher.cpp @@ -38,17 +38,18 @@ 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 GetProcessCPUStats(int32_t numCPUs) { +static Result GetProcessCPUStats( + int32_t numCPUs) { CPUStats result = {}; rusage usage; int32_t rusageResult = getrusage(RUSAGE_SELF, &usage); @@ -77,7 +78,7 @@ Result GetProcessCPUStats(int32_t numCPUs) { return result; } -Result GetGlobalCPUStats() { +static Result GetGlobalCPUStats() { CPUStats result = {}; host_cpu_load_info_data_t loadInfo; mach_msg_type_number_t loadInfoCount = HOST_CPU_LOAD_INFO_COUNT; diff --git a/xpcom/threads/ThreadDelay.cpp b/xpcom/threads/ThreadDelay.cpp index ec6f5b9eda8b..1c38e255100b 100644 --- a/xpcom/threads/ThreadDelay.cpp +++ b/xpcom/threads/ThreadDelay.cpp @@ -4,6 +4,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "ThreadDelay.h" #include "mozilla/Assertions.h" #include "mozilla/ChaosMode.h" diff --git a/xpcom/threads/nsTimerImpl.cpp b/xpcom/threads/nsTimerImpl.cpp index c160ab69372d..bc6974b27697 100644 --- a/xpcom/threads/nsTimerImpl.cpp +++ b/xpcom/threads/nsTimerImpl.cpp @@ -193,7 +193,7 @@ nsresult NS_NewTimerWithFuncCallback(nsITimer** aTimer, // static mozilla::LazyLogModule sTimerFiringsLog("TimerFirings"); -mozilla::LogModule* GetTimerFiringsLog() { return sTimerFiringsLog; } +static mozilla::LogModule* GetTimerFiringsLog() { return sTimerFiringsLog; } #include