From 630bc4c173adf97b4b82fd5fabded98e98a19b5f Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Sat, 7 Apr 2012 14:25:00 -0700 Subject: [PATCH] Bug 605180 - Fix build warnings in netwerk/. r=jduell --- netwerk/base/src/nsInputStreamPump.cpp | 4 ++++ netwerk/base/src/nsSocketTransport2.cpp | 14 ++++++------- netwerk/base/src/nsStandardURL.cpp | 4 ++-- netwerk/base/src/nsURLHelper.cpp | 4 ++-- netwerk/cache/nsCacheService.cpp | 20 +++++++++---------- netwerk/cache/nsDiskCacheBlockFile.h | 6 +++--- netwerk/cache/nsDiskCacheDeviceSQL.cpp | 2 +- netwerk/cookie/nsCookieService.cpp | 12 ++++++----- netwerk/mime/nsMIMEHeaderParamImpl.cpp | 6 ++---- netwerk/protocol/data/Makefile.in | 1 + netwerk/protocol/device/Makefile.in | 1 + netwerk/protocol/file/Makefile.in | 1 + netwerk/protocol/ftp/Makefile.in | 1 + .../http/HttpChannelParentListener.cpp | 1 - netwerk/protocol/http/PHttpChannelParams.h | 3 +-- netwerk/protocol/http/nsHttpChannel.cpp | 8 +++++--- netwerk/protocol/res/Makefile.in | 1 + netwerk/protocol/viewsource/Makefile.in | 1 + netwerk/protocol/websocket/Makefile.in | 1 + netwerk/protocol/wyciwyg/Makefile.in | 1 + .../converters/mozTXTToHTMLConv.cpp | 2 +- netwerk/streamconv/test/TestStreamConv.cpp | 3 ++- netwerk/test/TestCookie.cpp | 2 +- 23 files changed, 56 insertions(+), 43 deletions(-) diff --git a/netwerk/base/src/nsInputStreamPump.cpp b/netwerk/base/src/nsInputStreamPump.cpp index 30cd8642eb4..43839743331 100644 --- a/netwerk/base/src/nsInputStreamPump.cpp +++ b/netwerk/base/src/nsInputStreamPump.cpp @@ -404,6 +404,10 @@ nsInputStreamPump::OnInputStreamReady(nsIAsyncInputStream *stream) case STATE_STOP: nextState = OnStateStop(); break; + default: + nextState = 0; + NS_NOTREACHED("Unknown enum value."); + return NS_ERROR_UNEXPECTED; } if (mState == nextState && !mSuspendCount) { diff --git a/netwerk/base/src/nsSocketTransport2.cpp b/netwerk/base/src/nsSocketTransport2.cpp index f5bc71b020b..f0e5913615f 100644 --- a/netwerk/base/src/nsSocketTransport2.cpp +++ b/netwerk/base/src/nsSocketTransport2.cpp @@ -343,7 +343,7 @@ nsSocketInputStream::Read(char *buf, PRUint32 count, PRUint32 *countRead) *countRead = 0; - PRFileDesc *fd; + PRFileDesc* fd = nsnull; { MutexAutoLock lock(mTransport->mLock); @@ -364,7 +364,7 @@ nsSocketInputStream::Read(char *buf, PRUint32 count, PRUint32 *countRead) SOCKET_LOG((" PR_Read returned [n=%d]\n", n)); - nsresult rv; + nsresult rv = NS_OK; { MutexAutoLock lock(mTransport->mLock); @@ -567,7 +567,7 @@ nsSocketOutputStream::Write(const char *buf, PRUint32 count, PRUint32 *countWrit if (count == 0 && mByteCount) return NS_OK; - PRFileDesc *fd; + PRFileDesc* fd = nsnull; { MutexAutoLock lock(mTransport->mLock); @@ -588,13 +588,13 @@ nsSocketOutputStream::Write(const char *buf, PRUint32 count, PRUint32 *countWrit SOCKET_LOG((" PR_Write returned [n=%d]\n", n)); - nsresult rv; + nsresult rv = NS_OK; { MutexAutoLock lock(mTransport->mLock); #ifdef ENABLE_SOCKET_TRACING - if (n > 0) - mTransport->TraceOutBuf(buf, n); + if (n > 0) + mTransport->TraceOutBuf(buf, n); #endif mTransport->ReleaseFD_Locked(fd); @@ -1875,7 +1875,7 @@ nsSocketTransport::IsAlive(bool *result) { *result = false; - PRFileDesc *fd; + PRFileDesc* fd = nsnull; { MutexAutoLock lock(mLock); if (NS_FAILED(mCondition)) diff --git a/netwerk/base/src/nsStandardURL.cpp b/netwerk/base/src/nsStandardURL.cpp index 86f4c5d8a46..42d075a58e2 100644 --- a/netwerk/base/src/nsStandardURL.cpp +++ b/netwerk/base/src/nsStandardURL.cpp @@ -506,8 +506,8 @@ nsStandardURL::BuildNormalizedSpec(const char *spec) // escaping is required). nsCAutoString encUsername, encPassword, encHost, encDirectory, encBasename, encExtension, encQuery, encRef; - bool useEncUsername, useEncPassword, useEncHost, useEncDirectory, - useEncBasename, useEncExtension, useEncQuery, useEncRef; + bool useEncUsername, useEncPassword, useEncHost = false, + useEncDirectory, useEncBasename, useEncExtension, useEncQuery, useEncRef; nsCAutoString portbuf; // diff --git a/netwerk/base/src/nsURLHelper.cpp b/netwerk/base/src/nsURLHelper.cpp index 31108c67c6e..ddd64112008 100644 --- a/netwerk/base/src/nsURLHelper.cpp +++ b/netwerk/base/src/nsURLHelper.cpp @@ -858,8 +858,8 @@ net_ParseMediaType(const nsACString &aMediaTypeStr, const char* charset = ""; const char* charsetEnd = charset; - PRInt32 charsetParamStart; - PRInt32 charsetParamEnd; + PRInt32 charsetParamStart = 0; + PRInt32 charsetParamEnd = 0; // Iterate over parameters bool typeHasCharset = false; diff --git a/netwerk/cache/nsCacheService.cpp b/netwerk/cache/nsCacheService.cpp index 617bed5daa5..13b3dddd447 100644 --- a/netwerk/cache/nsCacheService.cpp +++ b/netwerk/cache/nsCacheService.cpp @@ -1,7 +1,6 @@ /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* vim: set sw=4 ts=8 et tw=80 : */ -/* - * ***** BEGIN LICENSE BLOCK ***** +/* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version @@ -1387,35 +1386,36 @@ nsCacheService::EvictEntriesForClient(const char * clientID, storagePolicy == nsICache::STORE_ON_DISK) { if (mEnableDiskDevice) { - nsresult rv; + nsresult rv = NS_OK; if (!mDiskDevice) rv = CreateDiskDevice(); if (mDiskDevice) rv = mDiskDevice->EvictEntries(clientID); - if (NS_FAILED(rv)) res = rv; + if (NS_FAILED(rv)) + res = rv; } } // Only clear the offline cache if it has been specifically asked for. if (storagePolicy == nsICache::STORE_OFFLINE) { if (mEnableOfflineDevice) { - nsresult rv; + nsresult rv = NS_OK; if (!mOfflineDevice) rv = CreateOfflineDevice(); if (mOfflineDevice) rv = mOfflineDevice->EvictEntries(clientID); - if (NS_FAILED(rv)) res = rv; + if (NS_FAILED(rv)) + res = rv; } } if (storagePolicy == nsICache::STORE_ANYWHERE || storagePolicy == nsICache::STORE_IN_MEMORY) { - // If there is no memory device, there is no need to evict it... if (mMemoryDevice) { - nsresult rv; - rv = mMemoryDevice->EvictEntries(clientID); - if (NS_FAILED(rv)) res = rv; + nsresult rv = mMemoryDevice->EvictEntries(clientID); + if (NS_FAILED(rv)) + res = rv; } } diff --git a/netwerk/cache/nsDiskCacheBlockFile.h b/netwerk/cache/nsDiskCacheBlockFile.h index ef3c28ee912..8ddb115d62d 100644 --- a/netwerk/cache/nsDiskCacheBlockFile.h +++ b/netwerk/cache/nsDiskCacheBlockFile.h @@ -1,6 +1,6 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * ***** BEGIN LICENSE BLOCK ***** +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* vim: set sw=4 ts=8 et tw=80 : */ +/* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version diff --git a/netwerk/cache/nsDiskCacheDeviceSQL.cpp b/netwerk/cache/nsDiskCacheDeviceSQL.cpp index 323164a2e47..7597f9df02f 100644 --- a/netwerk/cache/nsDiskCacheDeviceSQL.cpp +++ b/netwerk/cache/nsDiskCacheDeviceSQL.cpp @@ -1895,7 +1895,7 @@ nsOfflineCacheDevice::GetMatchingNamespace(const nsCString &clientID, bool found = false; nsCString nsSpec; - PRInt32 nsType; + PRInt32 nsType = 0; nsCString nsData; while (hasRows) diff --git a/netwerk/cookie/nsCookieService.cpp b/netwerk/cookie/nsCookieService.cpp index e488e634c8c..ea42867d97a 100644 --- a/netwerk/cookie/nsCookieService.cpp +++ b/netwerk/cookie/nsCookieService.cpp @@ -84,6 +84,7 @@ #include "mozilla/FunctionTimer.h" #include "mozilla/Util.h" // for DebugOnly +using namespace mozilla; using namespace mozilla::net; /****************************************************************************** @@ -3541,7 +3542,7 @@ nsCookieService::FindStaleCookie(nsCookieEntry *aEntry, { aIter.entry = NULL; - PRInt64 oldestTime; + PRInt64 oldestTime = 0; const nsCookieEntry::ArrayType &cookies = aEntry->GetCookies(); for (nsCookieEntry::IndexType i = 0; i < cookies.Length(); ++i) { nsCookie *cookie = cookies[i]; @@ -3672,8 +3673,9 @@ nsCookieService::RemoveCookieFromList(const nsListIter &aIter, nsCOMPtr params; paramsArray->NewBindingParams(getter_AddRefs(params)); - nsresult rv = params->BindUTF8StringByName(NS_LITERAL_CSTRING("name"), - aIter.Cookie()->Name()); + DebugOnly rv = + params->BindUTF8StringByName(NS_LITERAL_CSTRING("name"), + aIter.Cookie()->Name()); NS_ASSERT_SUCCESS(rv); rv = params->BindUTF8StringByName(NS_LITERAL_CSTRING("host"), @@ -3718,12 +3720,12 @@ bindCookieParameters(mozIStorageBindingParamsArray *aParamsArray, { NS_ASSERTION(aParamsArray, "Null params array passed to bindCookieParameters!"); NS_ASSERTION(aCookie, "Null cookie passed to bindCookieParameters!"); - nsresult rv; // Use the asynchronous binding methods to ensure that we do not acquire the // database lock. nsCOMPtr params; - rv = aParamsArray->NewBindingParams(getter_AddRefs(params)); + DebugOnly rv = + aParamsArray->NewBindingParams(getter_AddRefs(params)); NS_ASSERT_SUCCESS(rv); // Bind our values to params diff --git a/netwerk/mime/nsMIMEHeaderParamImpl.cpp b/netwerk/mime/nsMIMEHeaderParamImpl.cpp index 2ea2e40e26e..1d6ac5de7ae 100644 --- a/netwerk/mime/nsMIMEHeaderParamImpl.cpp +++ b/netwerk/mime/nsMIMEHeaderParamImpl.cpp @@ -1,6 +1,5 @@ /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim:expandtab:shiftwidth=2:tabstop=4: - */ +/* vim: set sw=4 ts=8 et tw=80 : */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -923,7 +922,7 @@ static const char especials[] = "()<>@,;:\\\"/[]?.="; nsresult DecodeRFC2047Str(const char *aHeader, const char *aDefaultCharset, bool aOverrideCharset, nsACString &aResult) { - const char *p, *q, *r; + const char *p, *q = nsnull, *r; char *decodedText; const char *begin; // tracking pointer for where we are in the input buffer PRInt32 isLastEncodedWord = 0; @@ -1059,4 +1058,3 @@ nsresult DecodeRFC2047Str(const char *aHeader, const char *aDefaultCharset, return NS_OK; } - diff --git a/netwerk/protocol/data/Makefile.in b/netwerk/protocol/data/Makefile.in index 21914f426a4..feac68a7253 100644 --- a/netwerk/protocol/data/Makefile.in +++ b/netwerk/protocol/data/Makefile.in @@ -39,6 +39,7 @@ DEPTH = ../../.. topsrcdir = @top_srcdir@ srcdir = @srcdir@ VPATH = @srcdir@ +FAIL_ON_WARNINGS = 1 include $(DEPTH)/config/autoconf.mk diff --git a/netwerk/protocol/device/Makefile.in b/netwerk/protocol/device/Makefile.in index 78634c4b223..6fb7bad881c 100644 --- a/netwerk/protocol/device/Makefile.in +++ b/netwerk/protocol/device/Makefile.in @@ -38,6 +38,7 @@ DEPTH = ../../.. topsrcdir = @top_srcdir@ srcdir = @srcdir@ VPATH = @srcdir@ +FAIL_ON_WARNINGS = 1 include $(DEPTH)/config/autoconf.mk diff --git a/netwerk/protocol/file/Makefile.in b/netwerk/protocol/file/Makefile.in index 1fa24ea42b9..96a61292771 100644 --- a/netwerk/protocol/file/Makefile.in +++ b/netwerk/protocol/file/Makefile.in @@ -39,6 +39,7 @@ DEPTH = ../../.. topsrcdir = @top_srcdir@ srcdir = @srcdir@ VPATH = @srcdir@ +FAIL_ON_WARNINGS = 1 include $(DEPTH)/config/autoconf.mk diff --git a/netwerk/protocol/ftp/Makefile.in b/netwerk/protocol/ftp/Makefile.in index 01c3e018ac2..58fd2559cf8 100644 --- a/netwerk/protocol/ftp/Makefile.in +++ b/netwerk/protocol/ftp/Makefile.in @@ -39,6 +39,7 @@ DEPTH = ../../.. topsrcdir = @top_srcdir@ srcdir = @srcdir@ VPATH = @srcdir@ +FAIL_ON_WARNINGS = 1 include $(DEPTH)/config/autoconf.mk diff --git a/netwerk/protocol/http/HttpChannelParentListener.cpp b/netwerk/protocol/http/HttpChannelParentListener.cpp index 11f0aebac93..c2e638fc97d 100644 --- a/netwerk/protocol/http/HttpChannelParentListener.cpp +++ b/netwerk/protocol/http/HttpChannelParentListener.cpp @@ -1,6 +1,5 @@ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set sw=2 ts=8 et tw=80 : */ - /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * diff --git a/netwerk/protocol/http/PHttpChannelParams.h b/netwerk/protocol/http/PHttpChannelParams.h index 73f892b36e2..d0baeb19c42 100644 --- a/netwerk/protocol/http/PHttpChannelParams.h +++ b/netwerk/protocol/http/PHttpChannelParams.h @@ -1,6 +1,5 @@ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set sw=2 ts=8 et tw=80 : */ - /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -17,7 +16,7 @@ * The Original Code is mozilla.org code. * * The Initial Developer of the Original Code is - * The Mozilla Foundation + * The Mozilla Foundation * Portions created by the Initial Developer are Copyright (C) 2010 * the Initial Developer. All Rights Reserved. * diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index 6db44633ef1..754143fa8a1 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -2379,11 +2379,13 @@ nsHttpChannel::OpenNormalCacheEntry() nsCOMPtr session; rv = gHttpHandler->GetCacheSession(storagePolicy, getter_AddRefs(session)); - if (NS_FAILED(rv)) return rv; + if (NS_FAILED(rv)) + return rv; - nsCacheAccessMode accessRequested; + nsCacheAccessMode accessRequested = 0; rv = DetermineCacheAccess(&accessRequested); - if (NS_FAILED(rv)) return rv; + if (NS_FAILED(rv)) + return rv; mOnCacheEntryAvailableCallback = &nsHttpChannel::OnNormalCacheEntryAvailable; diff --git a/netwerk/protocol/res/Makefile.in b/netwerk/protocol/res/Makefile.in index 3e38cb74593..caf65c93847 100644 --- a/netwerk/protocol/res/Makefile.in +++ b/netwerk/protocol/res/Makefile.in @@ -39,6 +39,7 @@ DEPTH = ../../.. topsrcdir = @top_srcdir@ srcdir = @srcdir@ VPATH = @srcdir@ +FAIL_ON_WARNINGS = 1 include $(DEPTH)/config/autoconf.mk diff --git a/netwerk/protocol/viewsource/Makefile.in b/netwerk/protocol/viewsource/Makefile.in index d117d3e08b7..2ab47525505 100644 --- a/netwerk/protocol/viewsource/Makefile.in +++ b/netwerk/protocol/viewsource/Makefile.in @@ -40,6 +40,7 @@ DEPTH = ../../.. topsrcdir = @top_srcdir@ srcdir = @srcdir@ VPATH = @srcdir@ +FAIL_ON_WARNINGS = 1 include $(DEPTH)/config/autoconf.mk diff --git a/netwerk/protocol/websocket/Makefile.in b/netwerk/protocol/websocket/Makefile.in index b9809f147c1..7fce4af43d0 100644 --- a/netwerk/protocol/websocket/Makefile.in +++ b/netwerk/protocol/websocket/Makefile.in @@ -39,6 +39,7 @@ DEPTH = ../../.. topsrcdir = @top_srcdir@ srcdir = @srcdir@ VPATH = @srcdir@ +FAIL_ON_WARNINGS = 1 include $(DEPTH)/config/autoconf.mk diff --git a/netwerk/protocol/wyciwyg/Makefile.in b/netwerk/protocol/wyciwyg/Makefile.in index 4b8ead01279..916cce026f7 100644 --- a/netwerk/protocol/wyciwyg/Makefile.in +++ b/netwerk/protocol/wyciwyg/Makefile.in @@ -38,6 +38,7 @@ DEPTH = ../../.. topsrcdir = @top_srcdir@ srcdir = @srcdir@ VPATH = @srcdir@ +FAIL_ON_WARNINGS = 1 include $(DEPTH)/config/autoconf.mk diff --git a/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp b/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp index 08da82266e0..17cc4edb3d7 100644 --- a/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp +++ b/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp @@ -804,7 +804,7 @@ mozTXTToHTMLConv::GlyphHit(const PRUnichar * aInString, PRInt32 aInLength, bool // temporary variable used to store the glyph html text nsAutoString outputHTML; bool bTestSmilie; - bool bArg; + bool bArg = false; int i; // refactor some of this mess to avoid code duplication and speed execution a bit diff --git a/netwerk/streamconv/test/TestStreamConv.cpp b/netwerk/streamconv/test/TestStreamConv.cpp index 55009ea06ea..72f5f9aa02f 100644 --- a/netwerk/streamconv/test/TestStreamConv.cpp +++ b/netwerk/streamconv/test/TestStreamConv.cpp @@ -103,7 +103,8 @@ public: rv = inStr->Read(buffer, len, &read); buffer[len] = '\0'; if (NS_SUCCEEDED(rv)) { - printf("CONTEXT %p: Received %u bytes and the following data: \n %s\n\n", ctxt, read, buffer); + printf("CONTEXT %p: Received %u bytes and the following data: \n %s\n\n", + static_cast(ctxt), read, buffer); } nsMemory::Free(buffer); diff --git a/netwerk/test/TestCookie.cpp b/netwerk/test/TestCookie.cpp index 0d51c4d9b91..5cf40aded4e 100644 --- a/netwerk/test/TestCookie.cpp +++ b/netwerk/test/TestCookie.cpp @@ -525,7 +525,7 @@ main(PRInt32 argc, char *argv[]) rv[2] = CheckResult(cookie.get(), MUST_CONTAIN, "test=same"); rv[3] = CheckResult(cookie.get(), MUST_NOT_CONTAIN, "newtest=ciao"); rv[4] = CheckResult(cookie.get(), MUST_NOT_CONTAIN, "newtest=foo"); - rv[5] = CheckResult(cookie.get(), MUST_CONTAIN, "newtest=reincarnated") != nsnull; + rv[5] = CheckResult(cookie.get(), MUST_CONTAIN, "newtest=reincarnated"); SetACookie(cookieService, "http://multiple.cookies/", nsnull, "test=expiry; domain=.multiple.cookies; max-age=0", nsnull); GetACookie(cookieService, "http://multiple.cookies/", nsnull, getter_Copies(cookie)); rv[6] = CheckResult(cookie.get(), MUST_NOT_CONTAIN, "test=same");