bug 829288 - fix a bunch of mingw warnings in xpcom/ r=ehsan

This commit is contained in:
Trevor Saunders 2013-01-10 03:39:40 -05:00
parent 4e2a77b182
commit e1d9c076e4
10 changed files with 18 additions and 31 deletions

View File

@ -92,12 +92,12 @@ void safe_write(const char *a)
void safe_write(uint64_t x) void safe_write(uint64_t x)
{ {
// 2^64 is 20 decimal digits. // 2^64 is 20 decimal digits.
const int max_len = 21; const unsigned int max_len = 21;
char buf[max_len]; char buf[max_len];
buf[max_len - 1] = '\0'; buf[max_len - 1] = '\0';
uint32_t i; 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]; buf[i] = "0123456789"[x % 10];
x /= 10; x /= 10;
@ -345,7 +345,7 @@ class NumLowMemoryEventsReporter : public nsIMemoryReporter
} }
}; };
class NumLowVirtualMemoryEventsMemoryReporter : public NumLowMemoryEventsReporter class NumLowVirtualMemoryEventsMemoryReporter MOZ_FINAL : public NumLowMemoryEventsReporter
{ {
public: public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
@ -391,7 +391,7 @@ public:
NS_IMPL_ISUPPORTS1(NumLowVirtualMemoryEventsMemoryReporter, nsIMemoryReporter) NS_IMPL_ISUPPORTS1(NumLowVirtualMemoryEventsMemoryReporter, nsIMemoryReporter)
class NumLowCommitSpaceEventsMemoryReporter : public NumLowMemoryEventsReporter class NumLowCommitSpaceEventsMemoryReporter MOZ_FINAL : public NumLowMemoryEventsReporter
{ {
public: public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
@ -433,7 +433,7 @@ public:
NS_IMPL_ISUPPORTS1(NumLowCommitSpaceEventsMemoryReporter, nsIMemoryReporter) NS_IMPL_ISUPPORTS1(NumLowCommitSpaceEventsMemoryReporter, nsIMemoryReporter)
class NumLowPhysicalMemoryEventsMemoryReporter : public NumLowMemoryEventsReporter class NumLowPhysicalMemoryEventsMemoryReporter MOZ_FINAL : public NumLowMemoryEventsReporter
{ {
public: public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS

View File

@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "mozilla/DebugOnly.h"
#include "nsISupports.h" #include "nsISupports.h"
#include "nsExceptionService.h" #include "nsExceptionService.h"
@ -136,7 +137,7 @@ nsExceptionService::nsExceptionService()
#endif #endif
/* member initializers and constructor code */ /* member initializers and constructor code */
if (tlsIndex == BAD_TLS_INDEX) { if (tlsIndex == BAD_TLS_INDEX) {
PRStatus status; DebugOnly<PRStatus> status;
status = PR_NewThreadPrivateIndex( &tlsIndex, ThreadDestruct ); status = PR_NewThreadPrivateIndex( &tlsIndex, ThreadDestruct );
NS_ASSERTION(status==0, "ScriptErrorService could not allocate TLS storage."); NS_ASSERTION(status==0, "ScriptErrorService could not allocate TLS storage.");
} }

View File

@ -236,7 +236,7 @@ CRITICAL_SECTION gDbgHelpCS;
// Routine to print an error message to standard error. // Routine to print an error message to standard error.
// Will also call callback with error, if data supplied. // Will also call callback with error, if data supplied.
void PrintError(char *prefix) void PrintError(const char *prefix)
{ {
LPVOID lpMsgBuf; LPVOID lpMsgBuf;
DWORD lastErr = GetLastError(); DWORD lastErr = GetLastError();

View File

@ -286,7 +286,7 @@ private:
// the system has been woken up, happens mostly on XP. // 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_ISUPPORTS
NS_DECL_NSIOBSERVER NS_DECL_NSIOBSERVER

View File

@ -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 // 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 // for performance ... if that becomes an issue we can take some inspiration
// from the js string compare code in jsstr.cpp // 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)) if (!memcmp(haystack + i, needle, needleLen))
return haystack + i; return haystack + i;
} }

View File

@ -10,6 +10,7 @@
#include "nsWindowsRegKey.h" #include "nsWindowsRegKey.h"
#include "nsString.h" #include "nsString.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "mozilla/Attributes.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -18,7 +19,7 @@
#define MAX_KEY_NAME_LEN 255 #define MAX_KEY_NAME_LEN 255
#define MAX_VALUE_NAME_LEN 16383 #define MAX_VALUE_NAME_LEN 16383
class nsWindowsRegKey : public nsIWindowsRegKey class nsWindowsRegKey MOZ_FINAL : public nsIWindowsRegKey
{ {
public: public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
@ -179,7 +180,7 @@ nsWindowsRegKey::HasChild(const nsAString &name, bool *result)
LONG rv = RegOpenKeyExW(mKey, PromiseFlatString(name).get(), 0, LONG rv = RegOpenKeyExW(mKey, PromiseFlatString(name).get(), 0,
STANDARD_RIGHTS_READ, &key); STANDARD_RIGHTS_READ, &key);
if (*result = (rv == ERROR_SUCCESS && key)) if ((*result = (rv == ERROR_SUCCESS && key)))
RegCloseKey(key); RegCloseKey(key);
return NS_OK; return NS_OK;

View File

@ -74,23 +74,6 @@ ReadDependentCB(const char *aDependentLib, bool do_preload)
AppendDependentLib(h); 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 // like strpbrk but finds the *last* char, not the first
static wchar_t* static wchar_t*
ns_wcspbrk(wchar_t *string, const wchar_t *strCharSet) ns_wcspbrk(wchar_t *string, const wchar_t *strCharSet)

View File

@ -127,7 +127,7 @@ NS_OpenAnonymousTemporaryFile(PRFileDesc** aOutFileDesc)
// idle observer and its timer on shutdown. Note: the observer and idle // idle observer and its timer on shutdown. Note: the observer and idle
// services hold references to instances of this object, and those references // services hold references to instances of this object, and those references
// are what keep this object alive. // are what keep this object alive.
class nsAnonTempFileRemover : public nsIObserver { class nsAnonTempFileRemover MOZ_FINAL : public nsIObserver {
public: public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS

View File

@ -3,6 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/DebugOnly.h"
#include "mozilla/Util.h" #include "mozilla/Util.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
@ -3399,7 +3400,7 @@ nsLocalFile::GetHashCode(uint32_t *aResult)
void void
nsLocalFile::GlobalInit() nsLocalFile::GlobalInit()
{ {
nsresult rv = NS_CreateShortcutResolver(); DebugOnly<nsresult> rv = NS_CreateShortcutResolver();
NS_ASSERTION(NS_SUCCEEDED(rv), "Shortcut resolver could not be created"); NS_ASSERTION(NS_SUCCEEDED(rv), "Shortcut resolver could not be created");
} }

View File

@ -5,6 +5,7 @@
#include "TestHarness.h" #include "TestHarness.h"
#include "mozilla/Attributes.h"
#include "nsIScriptableBase64Encoder.h" #include "nsIScriptableBase64Encoder.h"
#include "nsIInputStream.h" #include "nsIInputStream.h"
#include "nsAutoPtr.h" #include "nsAutoPtr.h"
@ -142,7 +143,7 @@ static Test kTests[] =
) )
}; };
class FakeInputStream : public nsIInputStream class FakeInputStream MOZ_FINAL : public nsIInputStream
{ {
public: public: