Bug 805552: Use DebugOnly in /netwerk to fix opt build warnings (treated as errors) for set-but-only-checked-in-debug-builds nsresult values. r=jduell
authorDaniel Holbert <dholbert@cs.stanford.edu>
Thu, 25 Oct 2012 12:47:55 -0700
changeset 111569 3dc8241751a9361dc5537694d54a68fd37e1cd33
parent 111568 e12cf7513bff45fcf0bf4a14a0cb520c95c3b98f
child 111570 f258c53b90ea8477749ce81904a94bf932c636fc
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersjduell
bugs805552
milestone19.0a1
Bug 805552: Use DebugOnly in /netwerk to fix opt build warnings (treated as errors) for set-but-only-checked-in-debug-builds nsresult values. r=jduell
netwerk/base/src/nsIOService.cpp
netwerk/base/src/nsLoadGroup.cpp
netwerk/base/src/nsRequestObserverProxy.cpp
netwerk/cache/nsDiskCacheDevice.cpp
netwerk/cookie/nsCookieService.cpp
--- a/netwerk/base/src/nsIOService.cpp
+++ b/netwerk/base/src/nsIOService.cpp
@@ -37,22 +37,24 @@
 #include "nsIPermissionManager.h"
 #include "nsTArray.h"
 #include "nsIConsoleService.h"
 #include "nsIUploadChannel2.h"
 #include "nsXULAppAPI.h"
 #include "nsIProxiedChannel.h"
 #include "nsIProtocolProxyCallback.h"
 #include "nsICancelable.h"
-
+#include "mozilla/Util.h"
 
 #if defined(XP_WIN) || defined(MOZ_PLATFORM_MAEMO)
 #include "nsNativeConnectionHelper.h"
 #endif
 
+using namespace mozilla;
+
 #define PORT_PREF_PREFIX           "network.security.ports."
 #define PORT_PREF(x)               PORT_PREF_PREFIX x
 #define AUTODIAL_PREF              "network.autodial-helper.enabled"
 #define MANAGE_OFFLINE_STATUS_PREF "network.manage-offline-status"
 
 // Nb: these have been misnomers since bug 715770 removed the buffer cache.
 // "network.segment.count" and "network.segment.size" would be better names,
 // but the old names are still used to preserve backward compatibility.
@@ -687,17 +689,16 @@ nsIOService::SetOffline(bool offline)
             (void)observerService->NotifyObservers(nullptr,
                 NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC, offline ? 
                 NS_LITERAL_STRING("true").get() :
                 NS_LITERAL_STRING("false").get());
         }
     }
 
     nsIIOService *subject = static_cast<nsIIOService *>(this);
-    nsresult rv;
     while (mSetOfflineValue != mOffline) {
         offline = mSetOfflineValue;
 
         if (offline && !mOffline) {
             NS_NAMED_LITERAL_STRING(offlineString, NS_IOSERVICE_OFFLINE);
             mOffline = true; // indicate we're trying to shutdown
 
             // don't care if notifications fail
@@ -716,17 +717,17 @@ nsIOService::SetOffline(bool offline)
                 observerService->NotifyObservers(subject,
                                                  NS_IOSERVICE_OFFLINE_STATUS_TOPIC,
                                                  offlineString.get());
         }
         else if (!offline && mOffline) {
             // go online
             if (mDNSService) {
                 mDNSService->SetOffline(false);
-                rv = mDNSService->Init();
+                DebugOnly<nsresult> rv = mDNSService->Init();
                 NS_ASSERTION(NS_SUCCEEDED(rv), "DNS service init failed");
             }
             InitializeSocketTransportService();
             mOffline = false;    // indicate success only AFTER we've
                                     // brought up the services
 
             // trigger a PAC reload when we come back online
             if (mProxyService)
@@ -740,21 +741,21 @@ nsIOService::SetOffline(bool offline)
         }
     }
 
     // Don't notify here, as the above notifications (if used) suffice.
     if (mShutdown && mOffline) {
         // be sure to try and shutdown both (even if the first fails)...
         // shutdown dns service first, because it has callbacks for socket transport
         if (mDNSService) {
-            rv = mDNSService->Shutdown();
+            DebugOnly<nsresult> rv = mDNSService->Shutdown();
             NS_ASSERTION(NS_SUCCEEDED(rv), "DNS service shutdown failed");
         }
         if (mSocketTransportService) {
-            rv = mSocketTransportService->Shutdown();
+            DebugOnly<nsresult> rv = mSocketTransportService->Shutdown();
             NS_ASSERTION(NS_SUCCEEDED(rv), "socket transport service shutdown failed");
         }
     }
 
     mSettingOffline = false;
 
     return NS_OK;
 }
--- a/netwerk/base/src/nsLoadGroup.cpp
+++ b/netwerk/base/src/nsLoadGroup.cpp
@@ -13,16 +13,17 @@
 #include "prlog.h"
 #include "nsCRT.h"
 #include "netCore.h"
 #include "nsXPIDLString.h"
 #include "nsReadableUtils.h"
 #include "nsString.h"
 #include "nsTArray.h"
 #include "mozilla/Telemetry.h"
+#include "mozilla/Util.h"
 
 using namespace mozilla;
 
 #if defined(PR_LOGGING)
 //
 // Log module for nsILoadGroup logging...
 //
 // To enable logging (see prlog.h for full details):
@@ -127,19 +128,17 @@ nsLoadGroup::nsLoadGroup(nsISupports* ou
     // Initialize the ops in the hash to null to make sure we get
     // consistent errors if someone fails to call ::Init() on an
     // nsLoadGroup.
     mRequests.ops = nullptr;
 }
 
 nsLoadGroup::~nsLoadGroup()
 {
-    nsresult rv;
-
-    rv = Cancel(NS_BINDING_ABORTED);
+    DebugOnly<nsresult> rv = Cancel(NS_BINDING_ABORTED);
     NS_ASSERTION(NS_SUCCEEDED(rv), "Cancel failed");
 
     if (mRequests.ops) {
         PL_DHashTableFinish(&mRequests);
     }
 
     mDefaultLoadRequest = 0;
 
--- a/netwerk/base/src/nsRequestObserverProxy.cpp
+++ b/netwerk/base/src/nsRequestObserverProxy.cpp
@@ -6,16 +6,19 @@
 #include "nscore.h"
 #include "nsRequestObserverProxy.h"
 #include "nsIRequest.h"
 #include "nsIServiceManager.h"
 #include "nsProxyRelease.h"
 #include "nsAutoPtr.h"
 #include "nsString.h"
 #include "prlog.h"
+#include "mozilla/Util.h"
+
+using namespace mozilla;
 
 #if defined(PR_LOGGING)
 static PRLogModuleInfo *gRequestObserverProxyLog;
 #endif
 
 #define LOG(args) PR_LOG(gRequestObserverProxyLog, PR_LOG_DEBUG, args)
 
 //-----------------------------------------------------------------------------
@@ -85,29 +88,28 @@ public:
     {
         NS_PRECONDITION(mProxy, "null pointer");
     }
 
     virtual ~nsOnStopRequestEvent() {}
 
     NS_IMETHOD Run()
     {
-        nsresult rv, status = NS_OK;
-
         LOG(("nsOnStopRequestEvent::HandleEvent [req=%x]\n", mRequest.get()));
 
         nsCOMPtr<nsIRequestObserver> observer = mProxy->mObserver;
         if (!observer) {
             NS_NOTREACHED("already handled onStopRequest event (observer is null)");
             return NS_OK;
         }
         // Do not allow any more events to be handled after OnStopRequest
         mProxy->mObserver = 0;
 
-        rv = mRequest->GetStatus(&status);
+        nsresult status = NS_OK;
+        DebugOnly<nsresult> rv = mRequest->GetStatus(&status);
         NS_ASSERTION(NS_SUCCEEDED(rv), "GetStatus failed for request!");
 
         LOG(("handle stopevent=%p\n", this));
         (void) observer->OnStopRequest(mRequest, mContext, status);
 
         return NS_OK;
     }
 };
--- a/netwerk/cache/nsDiskCacheDevice.cpp
+++ b/netwerk/cache/nsDiskCacheDevice.cpp
@@ -41,16 +41,17 @@
 #include "nsIInputStream.h"
 #include "nsIOutputStream.h"
 #include "nsCRT.h"
 #include "nsCOMArray.h"
 #include "nsISimpleEnumerator.h"
 
 #include "nsThreadUtils.h"
 #include "mozilla/Telemetry.h"
+#include "mozilla/Util.h"
 
 static const char DISK_CACHE_DEVICE_ID[] = { "disk" };
 using namespace mozilla;
 
 class nsDiskCacheDeviceDeactivateEntryEvent : public nsRunnable {
 public:
     nsDiskCacheDeviceDeactivateEntryEvent(nsDiskCacheDevice *device,
                                           nsCacheEntry * entry,
@@ -531,31 +532,30 @@ nsDiskCacheDevice::FindEntry(nsCString *
 
 
 /**
  *  NOTE: called while holding the cache service lock
  */
 nsresult
 nsDiskCacheDevice::DeactivateEntry(nsCacheEntry * entry)
 {
-    nsresult              rv = NS_OK;
     nsDiskCacheBinding * binding = GetCacheEntryBinding(entry);
     if (!IsValidBinding(binding))
         return NS_ERROR_UNEXPECTED;
 
     CACHE_LOG_DEBUG(("CACHE: disk DeactivateEntry [%p %x]\n",
         entry, binding->mRecord.HashNumber()));
 
     nsDiskCacheDeviceDeactivateEntryEvent *event =
         new nsDiskCacheDeviceDeactivateEntryEvent(this, entry, binding);
 
     // ensure we can cancel the event via the binding later if necessary
     binding->mDeactivateEvent = event;
 
-    rv = nsCacheService::DispatchToCacheIOThread(event);
+    DebugOnly<nsresult> rv = nsCacheService::DispatchToCacheIOThread(event);
     NS_ASSERTION(NS_SUCCEEDED(rv), "DeactivateEntry: Failed dispatching "
                                    "deactivation event");
     return NS_OK;
 }
 
 /**
  *  NOTE: called while holding the cache service lock
  */
--- a/netwerk/cookie/nsCookieService.cpp
+++ b/netwerk/cookie/nsCookieService.cpp
@@ -460,21 +460,20 @@ public:
     , mCanceled(false)
   {
   }
 
   void Cancel() { mCanceled = true; }
 
   NS_IMETHOD HandleResult(mozIStorageResultSet *aResult)
   {
-    nsresult rv;
     nsCOMPtr<mozIStorageRow> row;
 
     while (1) {
-      rv = aResult->GetNextRow(getter_AddRefs(row));
+      DebugOnly<nsresult> rv = aResult->GetNextRow(getter_AddRefs(row));
       NS_ASSERT_SUCCESS(rv);
 
       if (!row)
         break;
 
       CookieDomainTuple *tuple = mDBState->hostArray.AppendElement();
       row->GetUTF8String(9, tuple->key.mBaseDomain);
       tuple->key.mAppId = static_cast<uint32_t>(row->AsInt32(10));
@@ -1418,17 +1417,17 @@ nsCookieService::RebuildCorruptDB(DBStat
   if (length == 0) {
     COOKIE_LOGSTRING(PR_LOG_DEBUG,
       ("RebuildCorruptDB(): nothing to write, rebuild complete"));
     mDefaultDBState->corruptFlag = DBState::OK;
     return;
   }
 
   // Execute the statement. If any errors crop up, we won't try again.
-  nsresult rv = stmt->BindParameters(paramsArray);
+  DebugOnly<nsresult> rv = stmt->BindParameters(paramsArray);
   NS_ASSERT_SUCCESS(rv);
   nsCOMPtr<mozIStoragePendingStatement> handle;
   rv = stmt->ExecuteAsync(aDBState->insertListener, getter_AddRefs(handle));
   NS_ASSERT_SUCCESS(rv);    
 }
 
 nsCookieService::~nsCookieService()
 {
@@ -1971,17 +1970,17 @@ nsCookieService::Read()
 
 // Extract data from a single result row and create an nsCookie.
 // This is templated since 'T' is different for sync vs async results.
 template<class T> nsCookie*
 nsCookieService::GetCookieFromRow(T &aRow)
 {
   // Skip reading 'baseDomain' -- up to the caller.
   nsCString name, value, host, path;
-  nsresult rv = aRow->GetUTF8String(0, name);
+  DebugOnly<nsresult> rv = aRow->GetUTF8String(0, name);
   NS_ASSERT_SUCCESS(rv);
   rv = aRow->GetUTF8String(1, value);
   NS_ASSERT_SUCCESS(rv);
   rv = aRow->GetUTF8String(2, host);
   NS_ASSERT_SUCCESS(rv);
   rv = aRow->GetUTF8String(3, path);
   NS_ASSERT_SUCCESS(rv);
 
@@ -2047,17 +2046,17 @@ nsCookieService::CancelAsyncRead(bool aP
   // mode.) As long as we do all our operations on the default state, we're OK.
   NS_ASSERTION(mDefaultDBState, "no default DBState");
   NS_ASSERTION(mDefaultDBState->pendingRead, "no pending read");
   NS_ASSERTION(mDefaultDBState->readListener, "no read listener");
 
   // Cancel the pending read, kill the read listener, and empty the array
   // of data already read in on the background thread.
   mDefaultDBState->readListener->Cancel();
-  mozilla::DebugOnly<nsresult> rv = mDefaultDBState->pendingRead->Cancel();
+  DebugOnly<nsresult> rv = mDefaultDBState->pendingRead->Cancel();
   NS_ASSERT_SUCCESS(rv);
 
   mDefaultDBState->stmtReadDomain = nullptr;
   mDefaultDBState->pendingRead = nullptr;
   mDefaultDBState->readListener = nullptr;
   mDefaultDBState->hostArray.Clear();
 
   // Only clear the 'readSet' table if we no longer need to know what set of
@@ -2597,17 +2596,17 @@ nsCookieService::GetCookieStringInternal
       if (currentTimeInUsec - cookie->LastAccessed() > kCookieStaleThreshold)
         UpdateCookieInList(cookie, currentTimeInUsec, paramsArray);
     }
     // Update the database now if necessary.
     if (paramsArray) {
       uint32_t length;
       paramsArray->GetLength(&length);
       if (length) {
-        nsresult rv = stmt->BindParameters(paramsArray);
+        DebugOnly<nsresult> rv = stmt->BindParameters(paramsArray);
         NS_ASSERT_SUCCESS(rv);
         nsCOMPtr<mozIStoragePendingStatement> handle;
         rv = stmt->ExecuteAsync(mDBState->updateListener,
           getter_AddRefs(handle));
         NS_ASSERT_SUCCESS(rv);
       }
     }
   }
@@ -3615,17 +3614,17 @@ nsCookieService::PurgeCookies(int64_t aC
     RemoveCookieFromList(purgeList[i], paramsArray);
   }
 
   // Update the database if we have entries to purge.
   if (paramsArray) {
     uint32_t length;
     paramsArray->GetLength(&length);
     if (length) {
-      nsresult rv = stmt->BindParameters(paramsArray);
+      DebugOnly<nsresult> rv = stmt->BindParameters(paramsArray);
       NS_ASSERT_SUCCESS(rv);
       nsCOMPtr<mozIStoragePendingStatement> handle;
       rv = stmt->ExecuteAsync(mDBState->removeListener, getter_AddRefs(handle));
       NS_ASSERT_SUCCESS(rv);
     }
   }
 
   // reset the oldest time indicator
@@ -4053,17 +4052,17 @@ nsCookieService::AddCookieToList(const n
     if (!paramsArray) {
       stmt->NewBindingParamsArray(getter_AddRefs(paramsArray));
     }
     bindCookieParameters(paramsArray, aKey, aCookie);
 
     // If we were supplied an array to store parameters, we shouldn't call
     // executeAsync - someone up the stack will do this for us.
     if (!aParamsArray) {
-      nsresult rv = stmt->BindParameters(paramsArray);
+      DebugOnly<nsresult> rv = stmt->BindParameters(paramsArray);
       NS_ASSERT_SUCCESS(rv);
       nsCOMPtr<mozIStoragePendingStatement> handle;
       rv = stmt->ExecuteAsync(mDBState->insertListener, getter_AddRefs(handle));
       NS_ASSERT_SUCCESS(rv);
     }
   }
 }
 
@@ -4079,18 +4078,19 @@ nsCookieService::UpdateCookieInList(nsCo
 
   // if it's a non-session cookie, update it in the db too
   if (!aCookie->IsSession() && aParamsArray) {
     // Create our params holder.
     nsCOMPtr<mozIStorageBindingParams> params;
     aParamsArray->NewBindingParams(getter_AddRefs(params));
 
     // Bind our parameters.
-    nsresult rv = params->BindInt64ByName(NS_LITERAL_CSTRING("lastAccessed"),
-                                          aLastAccessed);
+    DebugOnly<nsresult> rv =
+      params->BindInt64ByName(NS_LITERAL_CSTRING("lastAccessed"),
+                              aLastAccessed);
     NS_ASSERT_SUCCESS(rv);
 
     rv = params->BindUTF8StringByName(NS_LITERAL_CSTRING("name"),
                                       aCookie->Name());
     NS_ASSERT_SUCCESS(rv);
 
     rv = params->BindUTF8StringByName(NS_LITERAL_CSTRING("host"),
                                       aCookie->Host());