From 0f94b545d63f2349ea2df927c37ed520c1b484d6 Mon Sep 17 00:00:00 2001 From: Trevor Saunders Date: Thu, 10 Jan 2013 03:39:40 -0500 Subject: [PATCH] bug 829288 - fix a bunch of mingw warnings in xpcom/ r=ehsan --- xpcom/base/AvailableMemoryTracker.cpp | 10 +++++----- xpcom/base/nsExceptionService.cpp | 3 ++- xpcom/base/nsStackWalk.cpp | 2 +- xpcom/ds/TimeStamp_windows.cpp | 2 +- xpcom/ds/nsCRT.cpp | 2 +- xpcom/ds/nsWindowsRegKey.cpp | 5 +++-- xpcom/glue/standalone/nsGlueLinkingWin.cpp | 17 ----------------- xpcom/io/nsAnonymousTemporaryFile.cpp | 2 +- xpcom/io/nsLocalFileWin.cpp | 3 ++- xpcom/tests/TestBase64.cpp | 3 ++- 10 files changed, 18 insertions(+), 31 deletions(-) diff --git a/xpcom/base/AvailableMemoryTracker.cpp b/xpcom/base/AvailableMemoryTracker.cpp index 6b45172ff7ea..eb465f44ea81 100644 --- a/xpcom/base/AvailableMemoryTracker.cpp +++ b/xpcom/base/AvailableMemoryTracker.cpp @@ -92,12 +92,12 @@ void safe_write(const char *a) void safe_write(uint64_t x) { // 2^64 is 20 decimal digits. - const int max_len = 21; + const unsigned int max_len = 21; char buf[max_len]; buf[max_len - 1] = '\0'; uint32_t i; - for (i = max_len - 2; i >= 0 && x > 0; i--) + for (i = max_len - 2; i < max_len && x > 0; i--) { buf[i] = "0123456789"[x % 10]; x /= 10; @@ -345,7 +345,7 @@ class NumLowMemoryEventsReporter : public nsIMemoryReporter } }; -class NumLowVirtualMemoryEventsMemoryReporter : public NumLowMemoryEventsReporter +class NumLowVirtualMemoryEventsMemoryReporter MOZ_FINAL : public NumLowMemoryEventsReporter { public: NS_DECL_ISUPPORTS @@ -391,7 +391,7 @@ public: NS_IMPL_ISUPPORTS1(NumLowVirtualMemoryEventsMemoryReporter, nsIMemoryReporter) -class NumLowCommitSpaceEventsMemoryReporter : public NumLowMemoryEventsReporter +class NumLowCommitSpaceEventsMemoryReporter MOZ_FINAL : public NumLowMemoryEventsReporter { public: NS_DECL_ISUPPORTS @@ -433,7 +433,7 @@ public: NS_IMPL_ISUPPORTS1(NumLowCommitSpaceEventsMemoryReporter, nsIMemoryReporter) -class NumLowPhysicalMemoryEventsMemoryReporter : public NumLowMemoryEventsReporter +class NumLowPhysicalMemoryEventsMemoryReporter MOZ_FINAL : public NumLowMemoryEventsReporter { public: NS_DECL_ISUPPORTS diff --git a/xpcom/base/nsExceptionService.cpp b/xpcom/base/nsExceptionService.cpp index b41ee36a0e94..d6654e29d0d0 100644 --- a/xpcom/base/nsExceptionService.cpp +++ b/xpcom/base/nsExceptionService.cpp @@ -4,6 +4,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/Attributes.h" +#include "mozilla/DebugOnly.h" #include "nsISupports.h" #include "nsExceptionService.h" @@ -136,7 +137,7 @@ nsExceptionService::nsExceptionService() #endif /* member initializers and constructor code */ if (tlsIndex == BAD_TLS_INDEX) { - PRStatus status; + DebugOnly status; status = PR_NewThreadPrivateIndex( &tlsIndex, ThreadDestruct ); NS_ASSERTION(status==0, "ScriptErrorService could not allocate TLS storage."); } diff --git a/xpcom/base/nsStackWalk.cpp b/xpcom/base/nsStackWalk.cpp index bd1550ebf79f..c07ff643d046 100644 --- a/xpcom/base/nsStackWalk.cpp +++ b/xpcom/base/nsStackWalk.cpp @@ -236,7 +236,7 @@ CRITICAL_SECTION gDbgHelpCS; // Routine to print an error message to standard error. // Will also call callback with error, if data supplied. -void PrintError(char *prefix) +void PrintError(const char *prefix) { LPVOID lpMsgBuf; DWORD lastErr = GetLastError(); diff --git a/xpcom/ds/TimeStamp_windows.cpp b/xpcom/ds/TimeStamp_windows.cpp index 52f80ef494cc..dc516dd1f7d7 100644 --- a/xpcom/ds/TimeStamp_windows.cpp +++ b/xpcom/ds/TimeStamp_windows.cpp @@ -286,7 +286,7 @@ private: // the system has been woken up, happens mostly on XP. // ---------------------------------------------------------------------------- -class StandbyObserver : public nsIObserver +class StandbyObserver MOZ_FINAL : public nsIObserver { NS_DECL_ISUPPORTS NS_DECL_NSIOBSERVER diff --git a/xpcom/ds/nsCRT.cpp b/xpcom/ds/nsCRT.cpp index 6105dc4064ae..0e8122bbf829 100644 --- a/xpcom/ds/nsCRT.cpp +++ b/xpcom/ds/nsCRT.cpp @@ -141,7 +141,7 @@ const char* nsCRT::memmem(const char* haystack, uint32_t haystackLen, // No memmem means we need to roll our own. This isn't really optimized // for performance ... if that becomes an issue we can take some inspiration // from the js string compare code in jsstr.cpp - for (int32_t i = 0; i < haystackLen - needleLen; i++) { + for (uint32_t i = 0; i < haystackLen - needleLen; i++) { if (!memcmp(haystack + i, needle, needleLen)) return haystack + i; } diff --git a/xpcom/ds/nsWindowsRegKey.cpp b/xpcom/ds/nsWindowsRegKey.cpp index b4cd4f1d9155..0cdf51c8d775 100644 --- a/xpcom/ds/nsWindowsRegKey.cpp +++ b/xpcom/ds/nsWindowsRegKey.cpp @@ -10,6 +10,7 @@ #include "nsWindowsRegKey.h" #include "nsString.h" #include "nsCOMPtr.h" +#include "mozilla/Attributes.h" //----------------------------------------------------------------------------- @@ -18,7 +19,7 @@ #define MAX_KEY_NAME_LEN 255 #define MAX_VALUE_NAME_LEN 16383 -class nsWindowsRegKey : public nsIWindowsRegKey +class nsWindowsRegKey MOZ_FINAL : public nsIWindowsRegKey { public: NS_DECL_ISUPPORTS @@ -179,7 +180,7 @@ nsWindowsRegKey::HasChild(const nsAString &name, bool *result) LONG rv = RegOpenKeyExW(mKey, PromiseFlatString(name).get(), 0, STANDARD_RIGHTS_READ, &key); - if (*result = (rv == ERROR_SUCCESS && key)) + if ((*result = (rv == ERROR_SUCCESS && key))) RegCloseKey(key); return NS_OK; diff --git a/xpcom/glue/standalone/nsGlueLinkingWin.cpp b/xpcom/glue/standalone/nsGlueLinkingWin.cpp index da98158bea50..d8ba541080c9 100644 --- a/xpcom/glue/standalone/nsGlueLinkingWin.cpp +++ b/xpcom/glue/standalone/nsGlueLinkingWin.cpp @@ -74,23 +74,6 @@ ReadDependentCB(const char *aDependentLib, bool do_preload) AppendDependentLib(h); } -// like strpbrk but finds the *last* char, not the first -static char* -ns_strrpbrk(char *string, const char *strCharSet) -{ - char *found = NULL; - for (; *string; ++string) { - for (const char *search = strCharSet; *search; ++search) { - if (*search == *string) { - found = string; - // Since we're looking for the last char, we save "found" - // until we're at the end of the string. - } - } - } - - return found; -} // like strpbrk but finds the *last* char, not the first static wchar_t* ns_wcspbrk(wchar_t *string, const wchar_t *strCharSet) diff --git a/xpcom/io/nsAnonymousTemporaryFile.cpp b/xpcom/io/nsAnonymousTemporaryFile.cpp index a422d4d63c91..aaac18958a22 100644 --- a/xpcom/io/nsAnonymousTemporaryFile.cpp +++ b/xpcom/io/nsAnonymousTemporaryFile.cpp @@ -127,7 +127,7 @@ NS_OpenAnonymousTemporaryFile(PRFileDesc** aOutFileDesc) // idle observer and its timer on shutdown. Note: the observer and idle // services hold references to instances of this object, and those references // are what keep this object alive. -class nsAnonTempFileRemover : public nsIObserver { +class nsAnonTempFileRemover MOZ_FINAL : public nsIObserver { public: NS_DECL_ISUPPORTS diff --git a/xpcom/io/nsLocalFileWin.cpp b/xpcom/io/nsLocalFileWin.cpp index 0beb20564ded..5107cbcdaa4e 100644 --- a/xpcom/io/nsLocalFileWin.cpp +++ b/xpcom/io/nsLocalFileWin.cpp @@ -3,6 +3,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 "mozilla/DebugOnly.h" #include "mozilla/Util.h" #include "nsCOMPtr.h" @@ -3399,7 +3400,7 @@ nsLocalFile::GetHashCode(uint32_t *aResult) void nsLocalFile::GlobalInit() { - nsresult rv = NS_CreateShortcutResolver(); + DebugOnly rv = NS_CreateShortcutResolver(); NS_ASSERTION(NS_SUCCEEDED(rv), "Shortcut resolver could not be created"); } diff --git a/xpcom/tests/TestBase64.cpp b/xpcom/tests/TestBase64.cpp index da6b1667cc52..87b4378f1f12 100644 --- a/xpcom/tests/TestBase64.cpp +++ b/xpcom/tests/TestBase64.cpp @@ -5,6 +5,7 @@ #include "TestHarness.h" +#include "mozilla/Attributes.h" #include "nsIScriptableBase64Encoder.h" #include "nsIInputStream.h" #include "nsAutoPtr.h" @@ -142,7 +143,7 @@ static Test kTests[] = ) }; -class FakeInputStream : public nsIInputStream +class FakeInputStream MOZ_FINAL : public nsIInputStream { public: