Bug 1316909 - Replace 0's with nullptr to work with nsCOMPtr again. r=aleth
authorRichard Marti <richard.marti@gmail.com>
Fri, 11 Nov 2016 19:12:07 +0100
changeset 20685 270d1fada781a7e1614e0317adb9576726b88f2e
parent 20684 6bbafc1273eed73e3ef6192416d7eaf343a2ebb6
child 20686 3bbc1b01ea13a5b280e635d0c3109e35bbc7aa46
push id12516
push userrichard.marti@gmail.com
push dateFri, 11 Nov 2016 18:12:29 +0000
treeherdercomm-central@270d1fada781 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaleth
bugs1316909
Bug 1316909 - Replace 0's with nullptr to work with nsCOMPtr again. r=aleth
ldap/xpcom/src/nsLDAPConnection.cpp
ldap/xpcom/src/nsLDAPService.cpp
ldap/xpcom/src/nsLDAPSyncQuery.cpp
mailnews/addrbook/src/nsAbLDAPListenerBase.cpp
mailnews/base/util/nsMsgIncomingServer.cpp
mailnews/base/util/nsMsgProtocol.cpp
mailnews/compose/src/nsMsgSend.cpp
mailnews/extensions/smime/src/nsMsgComposeSecure.cpp
mailnews/local/src/nsMailboxProtocol.cpp
mailnews/local/src/nsPop3Sink.cpp
mailnews/mime/src/mimecms.cpp
mailnews/mime/src/mimemcms.cpp
mailnews/mime/src/mimemoz2.cpp
--- a/ldap/xpcom/src/nsLDAPConnection.cpp
+++ b/ldap/xpcom/src/nsLDAPConnection.cpp
@@ -31,22 +31,22 @@
 
 using namespace mozilla;
 
 const char kDNSServiceContractId[] = "@mozilla.org/network/dns-service;1";
 
 // constructor
 //
 nsLDAPConnection::nsLDAPConnection()
-    : mConnectionHandle(0),
+    : mConnectionHandle(nullptr),
       mPendingOperationsMutex("nsLDAPConnection.mPendingOperationsMutex"),
       mPendingOperations(10),
       mSSL(false),
       mVersion(nsILDAPConnection::VERSION3),
-      mDNSRequest(0)
+      mDNSRequest(nullptr)
 {
 }
 
 // destructor
 //
 nsLDAPConnection::~nsLDAPConnection()
 {
   nsCOMPtr<nsIObserverService> obsServ =
@@ -200,19 +200,19 @@ nsLDAPConnection::Close()
   NS_ASSERTION(!mThread || NS_SUCCEEDED(mThread->Shutdown()),
                "Failed to shutdown thread cleanly");
 
   // Cancel the DNS lookup if needed, and also drop the reference to the
   // Init listener (if still there).
   //
   if (mDNSRequest) {
       mDNSRequest->Cancel(NS_ERROR_ABORT);
-      mDNSRequest = 0;
+      mDNSRequest = nullptr;
   }
-  mInitListener = 0;
+  mInitListener = nullptr;
 
 }
 
 NS_IMETHODIMP
 nsLDAPConnection::Observe(nsISupports *aSubject, const char *aTopic,
                           const char16_t *aData)
 {
   if (!strcmp(aTopic, "profile-change-net-teardown")) {
@@ -584,23 +584,23 @@ nsLDAPConnection::OnLookupComplete(nsICa
                 }
             }
         }
     }
 
     // Drop the DNS request object, we no longer need it, and set the flag
     // indicating that DNS has finished.
     //
-    mDNSRequest = 0;
+    mDNSRequest = nullptr;
     mDNSHost.Truncate();
 
     // Call the listener, and then we can release our reference to it.
     //
     mInitListener->OnLDAPInit(this, rv);
-    mInitListener = 0;
+    mInitListener = nullptr;
 
     return rv;
 }
 
 nsLDAPConnectionRunnable::nsLDAPConnectionRunnable(int32_t aOperationID,
                                                    nsILDAPOperation *aOperation,
                                                    nsLDAPConnection *aConnection)
   : mOperationID(aOperationID),  mConnection(aConnection)
--- a/ldap/xpcom/src/nsLDAPService.cpp
+++ b/ldap/xpcom/src/nsLDAPService.cpp
@@ -1,10 +1,10 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * 
+ *
  * This Source Code Form is subject to the terms of the Mozilla Public
  * 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 "nsLDAPInternal.h"
 #include "nsLDAPService.h"
 #include "nsLDAPConnection.h"
 #include "nsLDAPOperation.h"
@@ -162,17 +162,17 @@ bool nsLDAPServiceEntry::DeleteEntry()
     mDelete = true;
 
     return true;
 }
 // This is the end of the nsLDAPServiceEntry class
 
 
 // Here begins the implementation for nsLDAPService
-// 
+//
 NS_IMPL_ISUPPORTS(nsLDAPService,
                               nsILDAPService,
                               nsILDAPMessageListener)
 
 
 // constructor
 //
 nsLDAPService::nsLDAPService()
@@ -194,17 +194,17 @@ nsresult nsLDAPService::Init()
 }
 
 // void addServer (in nsILDAPServer aServer);
 NS_IMETHODIMP nsLDAPService::AddServer(nsILDAPServer *aServer)
 {
     nsLDAPServiceEntry *entry;
     nsString key;
     nsresult rv;
-    
+
     if (!aServer) {
         NS_ERROR("nsLDAPService::AddServer: null pointer ");
         return NS_ERROR_NULL_POINTER;
     }
 
     // Set up the hash key for the server entry
     //
     rv = aServer->GetKey(getter_Copies(key));
@@ -255,17 +255,17 @@ NS_IMETHODIMP nsLDAPService::AddServer(n
     return NS_OK;
 }
 
 // void deleteServer (in wstring aKey);
 NS_IMETHODIMP nsLDAPService::DeleteServer(const char16_t *aKey)
 {
     nsLDAPServiceEntry *entry;
     MutexAutoLock lock(mLock);
-        
+
     // We should probably rename the key for this entry now that it's
     // "deleted", so that we can add in a new one with the same ID.
     // This is bug #77669.
     //
     mServers.Get(nsDependentString(aKey), &entry);
     if (entry) {
         if (entry->GetLeases() > 0) {
             return NS_ERROR_FAILURE;
@@ -349,17 +349,17 @@ NS_IMETHODIMP nsLDAPService::RequestConn
 
     }
 
     // We got a new connection, now push the listeners on our stack,
     // until we get the LDAP message back.
     //
     {
         MutexAutoLock lock(mLock);
-            
+
         if (!mServers.Get(nsDependentString(aKey), &entry) ||
             !entry->PushListener(static_cast<nsILDAPMessageListener *>
                                             (aListener))) {
             return NS_ERROR_FAILURE;
         }
     }
 
     return NS_OK;
@@ -421,17 +421,17 @@ NS_IMETHODIMP nsLDAPService::ReconnectCo
 
     if (!aListener) {
         NS_ERROR("nsLDAPService::ReconnectConnection: null pointer ");
         return NS_ERROR_NULL_POINTER;
     }
 
     {
         MutexAutoLock lock(mLock);
-        
+
         if (!mServers.Get(nsDependentString(aKey), &entry)) {
             return NS_ERROR_FAILURE;
         }
         entry->SetTimestamp();
 
         if (entry->IsRebinding()) {
             if (!entry->PushListener(aListener)) {
                 return NS_ERROR_FAILURE;
@@ -455,17 +455,17 @@ NS_IMETHODIMP nsLDAPService::ReconnectCo
 
     rv = EstablishConnection(entry, aListener);
     if (NS_FAILED(rv)) {
         return rv;
     }
 
     {
         MutexAutoLock lock(mLock);
-        
+
         if (!entry->PushListener(static_cast<nsILDAPMessageListener *>
                                             (aListener))) {
             entry->SetRebinding(false);
             return NS_ERROR_FAILURE;
         }
     }
 
     return NS_OK;
@@ -473,17 +473,17 @@ NS_IMETHODIMP nsLDAPService::ReconnectCo
 
 /**
  * Messages received are passed back via this function.
  *
  * @arg aMessage  The message that was returned, 0 if none was.
  *
  * void OnLDAPMessage (in nsILDAPMessage aMessage)
  */
-NS_IMETHODIMP 
+NS_IMETHODIMP
 nsLDAPService::OnLDAPMessage(nsILDAPMessage *aMessage)
 {
     nsCOMPtr<nsILDAPOperation> operation;
     nsCOMPtr<nsILDAPConnection> connection;
     int32_t messageType;
 
     // XXXleif: NULL messages are supposedly allowed, but the semantics
     // are not definted (yet?). This is something to look out for...
@@ -552,17 +552,17 @@ nsLDAPService::OnLDAPMessage(nsILDAPMess
         break;
 
     default:
         NS_WARNING("nsLDAPService::OnLDAPMessage(): unexpected LDAP message "
                    "received");
 
         // get the console service so we can log a message
         //
-        nsCOMPtr<nsIConsoleService> consoleSvc = 
+        nsCOMPtr<nsIConsoleService> consoleSvc =
             do_GetService("@mozilla.org/consoleservice;1", &rv);
         if (NS_FAILED(rv)) {
             NS_ERROR("nsLDAPChannel::OnLDAPMessage() couldn't get console "
                      "service");
             break;
         }
 
         // log the message
@@ -663,17 +663,17 @@ nsLDAPService::EstablishConnection(nsLDA
 
         conn2 = aEntry->GetConnection();
         message = aEntry->GetMessage();
     }
 
     if (conn2) {
         // Drop the new connection, we can't use it.
         //
-        conn = 0;
+        conn = nullptr;
         if (message) {
             aListener->OnLDAPMessage(message);
             return NS_OK;
         }
 
         {
             MutexAutoLock lock(mLock);
 
@@ -704,53 +704,53 @@ nsLDAPService::EstablishConnection(nsLDA
         return NS_ERROR_FAILURE;
     }
 
     rv = operation->Init(conn, this, nullptr);
     if (NS_FAILED(rv)) {
         return NS_ERROR_UNEXPECTED; // this should never happen
     }
 
-    // Start a bind operation 
+    // Start a bind operation
     //
     // Here we need to support the password, see bug #75990
-    // 
+    //
     rv = operation->SimpleBind(password);
     if (NS_FAILED(rv)) {
         // Only pass along errors we are aware of
         if ((rv == NS_ERROR_LDAP_ENCODING_ERROR) ||
             (rv == NS_ERROR_FAILURE) ||
             (rv == NS_ERROR_OUT_OF_MEMORY))
             return rv;
         else
             return NS_ERROR_UNEXPECTED;
     }
 
     return NS_OK;
 }
 
 /* AString createFilter (in unsigned long aMaxSize, in AString aPattern, in AString aPrefix, in AString aSuffix, in AString aAttr, in AString aValue); */
-NS_IMETHODIMP nsLDAPService::CreateFilter(uint32_t aMaxSize, 
+NS_IMETHODIMP nsLDAPService::CreateFilter(uint32_t aMaxSize,
                                           const nsACString & aPattern,
                                           const nsACString & aPrefix,
                                           const nsACString & aSuffix,
                                           const nsACString & aAttr,
                                           const nsACString & aValue,
                                           nsACString & _retval)
 {
     if (!aMaxSize) {
         return NS_ERROR_INVALID_ARG;
     }
 
     // figure out how big of an array we're going to need for the tokens,
     // including a trailing NULL, and allocate space for it.
     //
     const char *iter = aValue.BeginReading();
     const char *iterEnd = aValue.EndReading();
-    uint32_t numTokens = CountTokens(iter, iterEnd); 
+    uint32_t numTokens = CountTokens(iter, iterEnd);
     char **valueWords;
     valueWords = static_cast<char **>(moz_xmalloc((numTokens + 1) *
                                                 sizeof(char *)));
     if (!valueWords) {
         return NS_ERROR_OUT_OF_MEMORY;
     }
 
     // build the array of values
@@ -761,43 +761,43 @@ NS_IMETHODIMP nsLDAPService::CreateFilte
         if ( !valueWords[curToken] ) {
             NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(curToken, valueWords);
             return NS_ERROR_OUT_OF_MEMORY;
         }
         curToken++;
     }
     valueWords[numTokens] = 0;  // end of array signal to LDAP C SDK
 
-    // make buffer to be used for construction 
+    // make buffer to be used for construction
     //
     char *buffer = static_cast<char *>(moz_xmalloc(aMaxSize * sizeof(char)));
     if (!buffer) {
         NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(numTokens, valueWords);
         return NS_ERROR_OUT_OF_MEMORY;
     }
 
     // create the filter itself
     //
     nsresult rv;
-    int result = ldap_create_filter(buffer, aMaxSize, 
+    int result = ldap_create_filter(buffer, aMaxSize,
                    const_cast<char *>(PromiseFlatCString(aPattern).get()),
                    const_cast<char *>(PromiseFlatCString(aPrefix).get()),
                    const_cast<char *>(PromiseFlatCString(aSuffix).get()),
                    const_cast<char *>(PromiseFlatCString(aAttr).get()),
                    const_cast<char *>(PromiseFlatCString(aValue).get()),
                    valueWords);
     switch (result) {
     case LDAP_SUCCESS:
         rv = NS_OK;
         break;
 
     case LDAP_SIZELIMIT_EXCEEDED:
-        MOZ_LOG(gLDAPLogModule, mozilla::LogLevel::Debug, 
+        MOZ_LOG(gLDAPLogModule, mozilla::LogLevel::Debug,
                    ("nsLDAPService::CreateFilter(): "
-                    "filter longer than max size of %d generated", 
+                    "filter longer than max size of %d generated",
                     aMaxSize));
         rv = NS_ERROR_NOT_AVAILABLE;
         break;
 
     case LDAP_PARAM_ERROR:
         rv = NS_ERROR_INVALID_ARG;
         break;
 
@@ -863,17 +863,17 @@ NS_IMETHODIMP nsLDAPService::ParseDn(con
     for (char **component = rdnComponents; *component; ++component)
         ++rdnCount;
     if (rdnCount < 1) {
         NS_ERROR("nsLDAPService::ParseDn: RDN has too few components");
         ldap_value_free(dnComponents);
         ldap_value_free(rdnComponents);
         return NS_ERROR_UNEXPECTED;
     }
-  
+
     // get the RDN attribute names
     char **attrNameArray = static_cast<char **>(
         moz_xmalloc(rdnCount * sizeof(char *)));
     if (!attrNameArray) {
         NS_ERROR("nsLDAPService::ParseDn: out of memory ");
         ldap_value_free(dnComponents);
         ldap_value_free(rdnComponents);
         return NS_ERROR_OUT_OF_MEMORY;
@@ -920,17 +920,17 @@ uint32_t
 nsLDAPService::CountTokens(const char *aIter,
                            const char *aIterEnd)
 {
     uint32_t count(0);
 
     // keep iterating through the string until we hit the end
     //
     while (aIter != aIterEnd) {
-    
+
         // move past any leading spaces
         //
         while (aIter != aIterEnd &&
                ldap_utf8isspace(const_cast<char *>(aIter))){
             ++aIter;
         }
 
         // move past all chars in this token
@@ -940,17 +940,17 @@ nsLDAPService::CountTokens(const char *a
             if (ldap_utf8isspace(const_cast<char *>(aIter))) {
                 ++count;    // token finished; increment the count
                 ++aIter;    // move past the space
                 break;
             }
 
             ++aIter; // move to next char
 
-            // if we've hit the end of this token and the end of this 
+            // if we've hit the end of this token and the end of this
             // iterator simultaneous, be sure to bump the count, since we're
             // never gonna hit the IsAsciiSpace where it's normally done.
             //
             if (aIter == aIterEnd) {
                 ++count;
             }
 
         }
--- a/ldap/xpcom/src/nsLDAPSyncQuery.cpp
+++ b/ldap/xpcom/src/nsLDAPSyncQuery.cpp
@@ -27,19 +27,19 @@ nsLDAPSyncQuery::nsLDAPSyncQuery() :
 // Destructor
 //
 nsLDAPSyncQuery::~nsLDAPSyncQuery()
 {
 }
 
 
 // Messages received are passed back via this function.
-// void OnLDAPMessage (in nsILDAPMessage aMessage) 
+// void OnLDAPMessage (in nsILDAPMessage aMessage)
 //
-NS_IMETHODIMP 
+NS_IMETHODIMP
 nsLDAPSyncQuery::OnLDAPMessage(nsILDAPMessage *aMessage)
 {
     int32_t messageType;
 
     // just in case.
     //
     if (!aMessage) {
         return NS_OK;
@@ -59,29 +59,29 @@ nsLDAPSyncQuery::OnLDAPMessage(nsILDAPMe
 
     case nsILDAPMessage::RES_BIND:
 
         // a bind has completed
         //
         return OnLDAPBind(aMessage);
 
     case nsILDAPMessage::RES_SEARCH_ENTRY:
-        
+
         // a search entry has been returned
         //
         return OnLDAPSearchEntry(aMessage);
 
     case nsILDAPMessage::RES_SEARCH_RESULT:
 
         // the search is finished; we're all done
-        //  
+        //
         return OnLDAPSearchResult(aMessage);
 
     default:
-        
+
         // Given the LDAP operations nsLDAPSyncQuery uses, we should
         // never get here.  If we do get here in a release build, it's
         // probably a bug, but maybe it's the LDAP server doing something
         // weird.  Might as well try and continue anyway.  The session should
         // eventually get reaped by the timeout code, if necessary.
         //
         NS_ERROR("nsLDAPSyncQuery::OnLDAPMessage(): unexpected "
                  "LDAP message received");
@@ -91,56 +91,56 @@ nsLDAPSyncQuery::OnLDAPMessage(nsILDAPMe
 
 // void onLDAPInit (in nsresult aStatus);
 //
 NS_IMETHODIMP
 nsLDAPSyncQuery::OnLDAPInit(nsILDAPConnection *aConn, nsresult aStatus)
 {
     nsresult rv;        // temp for xpcom return values
     // create and initialize an LDAP operation (to be used for the bind)
-    //  
-    mOperation = do_CreateInstance("@mozilla.org/network/ldap-operation;1", 
+    //
+    mOperation = do_CreateInstance("@mozilla.org/network/ldap-operation;1",
                                    &rv);
     if (NS_FAILED(rv)) {
         FinishLDAPQuery();
         return NS_ERROR_FAILURE;
     }
 
     // our OnLDAPMessage accepts all result callbacks
     //
     rv = mOperation->Init(mConnection, this, nullptr);
     if (NS_FAILED(rv)) {
         FinishLDAPQuery();
         return NS_ERROR_UNEXPECTED; // this should never happen
     }
 
-    // kick off a bind operation 
-    // 
-    rv = mOperation->SimpleBind(EmptyCString()); 
+    // kick off a bind operation
+    //
+    rv = mOperation->SimpleBind(EmptyCString());
     if (NS_FAILED(rv)) {
         FinishLDAPQuery();
         return NS_ERROR_FAILURE;
     }
-    
+
     return NS_OK;
 }
 
 nsresult
 nsLDAPSyncQuery::OnLDAPBind(nsILDAPMessage *aMessage)
 {
 
     int32_t errCode;
 
-    mOperation = 0;  // done with bind op; make nsCOMPtr release it
+    mOperation = nullptr;  // done with bind op; make nsCOMPtr release it
 
     // get the status of the bind
     //
     nsresult rv = aMessage->GetErrorCode(&errCode);
     if (NS_FAILED(rv)) {
-        
+
         NS_ERROR("nsLDAPSyncQuery::OnLDAPBind(): couldn't get "
                  "error code from aMessage");
         FinishLDAPQuery();
         return NS_ERROR_FAILURE;
     }
 
 
     // check to be sure the bind succeeded
@@ -202,28 +202,28 @@ nsLDAPSyncQuery::OnLDAPSearchEntry(nsILD
 }
 
 
 nsresult
 nsLDAPSyncQuery::OnLDAPSearchResult(nsILDAPMessage *aMessage)
 {
     // We are done with the LDAP search.
     // Release the control variable for the eventloop and other members
-    // 
+    //
     FinishLDAPQuery();
     return NS_OK;
 }
 
 nsresult
 nsLDAPSyncQuery::StartLDAPSearch()
 {
     nsresult rv;
     // create and initialize an LDAP operation (to be used for the search
-    //  
-    mOperation = 
+    //
+    mOperation =
         do_CreateInstance("@mozilla.org/network/ldap-operation;1", &rv);
 
     if (NS_FAILED(rv)) {
         NS_ERROR("nsLDAPSyncQuery::StartLDAPSearch(): couldn't "
                  "create @mozilla.org/network/ldap-operation;1");
         FinishLDAPQuery();
         return NS_ERROR_FAILURE;
     }
@@ -233,17 +233,17 @@ nsLDAPSyncQuery::StartLDAPSearch()
     rv = mOperation->Init(mConnection, this, nullptr);
     if (NS_FAILED(rv)) {
         NS_ERROR("nsLDAPSyncQuery::StartLDAPSearch(): couldn't "
                  "initialize LDAP operation");
         FinishLDAPQuery();
         return NS_ERROR_UNEXPECTED;
     }
 
-    // get the search filter associated with the directory server url; 
+    // get the search filter associated with the directory server url;
     //
     nsAutoCString urlFilter;
     rv = mServerURL->GetFilter(urlFilter);
     if (NS_FAILED(rv)) {
         FinishLDAPQuery();
         return NS_ERROR_UNEXPECTED;
     }
 
@@ -278,17 +278,17 @@ nsLDAPSyncQuery::StartLDAPSearch()
     if (NS_FAILED(rv)) {
         FinishLDAPQuery();
         return NS_ERROR_FAILURE;
     }
 
     return NS_OK;
 }
 
-// void initConnection (); 
+// void initConnection ();
 //
 nsresult nsLDAPSyncQuery::InitConnection()
 {
     // Because mConnection->Init proxies back to the main thread, this
     // better be the main thread.
     NS_ENSURE_TRUE(NS_IsMainThread(), NS_ERROR_FAILURE);
     nsresult rv;        // temp for xpcom return values
     // create an LDAP connection
@@ -318,62 +318,62 @@ nsresult nsLDAPSyncQuery::InitConnection
     }
 
     return NS_OK;
 }
 
 void
 nsLDAPSyncQuery::FinishLDAPQuery()
 {
-    // We are done with the LDAP operation. 
+    // We are done with the LDAP operation.
     // Release the Control variable for the eventloop
     //
     mFinished = true;
-    
+
     // Release member variables
     //
-    mConnection = 0;
-    mOperation = 0;
-    mServerURL = 0;
- 
+    mConnection = nullptr;
+    mOperation = nullptr;
+    mServerURL = nullptr;
+
 }
 
 /* wstring getQueryResults (in nsILDAPURL aServerURL, in unsigned long aVersion); */
 NS_IMETHODIMP nsLDAPSyncQuery::GetQueryResults(nsILDAPURL *aServerURL,
                                                uint32_t aProtocolVersion,
                                                char16_t **_retval)
 {
     nsresult rv;
-    
+
     if (!aServerURL) {
         NS_ERROR("nsLDAPSyncQuery::GetQueryResults() called without LDAP URL");
         return NS_ERROR_FAILURE;
     }
     mServerURL = aServerURL;
     mProtocolVersion = aProtocolVersion;
 
     nsCOMPtr<nsIThread> currentThread = do_GetCurrentThread();
 
-    // Start an LDAP query. 
-    // InitConnection will bind to the ldap server and post a OnLDAPMessage 
-    // event. This event will trigger a search and the whole operation will 
+    // Start an LDAP query.
+    // InitConnection will bind to the ldap server and post a OnLDAPMessage
+    // event. This event will trigger a search and the whole operation will
     // be carried out by chain of events
     //
     rv = InitConnection();
     if (NS_FAILED(rv))
         return rv;
-    
-    // We want this LDAP query to be synchronous while the XPCOM LDAP is 
-    // async in nature. So this eventQueue handling will wait for the 
-    // LDAP operation to be finished. 
-    // mFinished controls the state of the LDAP opertion. 
+
+    // We want this LDAP query to be synchronous while the XPCOM LDAP is
+    // async in nature. So this eventQueue handling will wait for the
+    // LDAP operation to be finished.
+    // mFinished controls the state of the LDAP opertion.
     // It will be released in any case (success/failure)
-    
-    
-    // Run the event loop, 
+
+
+    // Run the event loop,
     // mFinished is a control variable
     //
     while (!mFinished)
         NS_ENSURE_STATE(NS_ProcessNextEvent(currentThread));
 
     // Return results
     //
     if (!mResults.IsEmpty()) {
--- a/mailnews/addrbook/src/nsAbLDAPListenerBase.cpp
+++ b/mailnews/addrbook/src/nsAbLDAPListenerBase.cpp
@@ -69,17 +69,17 @@ NS_IMETHODIMP nsAbLDAPListenerBase::OnLD
   }
 
   // If mLogin is set, we're expected to use it to get a password.
   //
   if (!mLogin.IsEmpty() && !mSaslMechanism.EqualsLiteral("GSSAPI"))
   {
     // get the string bundle service
     //
-    nsCOMPtr<nsIStringBundleService> stringBundleSvc = 
+    nsCOMPtr<nsIStringBundleService> stringBundleSvc =
       mozilla::services::GetStringBundleService();
     if (!stringBundleSvc)
     {
       NS_ERROR("nsAbLDAPListenerBase::OnLDAPInit():"
                " error getting string bundle service");
       InitFailed();
       return NS_ERROR_UNEXPECTED;
     }
@@ -118,17 +118,17 @@ NS_IMETHODIMP nsAbLDAPListenerBase::OnLD
     if (NS_FAILED(rv))
     {
       NS_ERROR("nsAbLDAPListenerBase::OnLDAPInit(): error getting ascii host"
                "name from directory url");
       InitFailed();
       return rv;
     }
 
-    // hostTemp is only necessary to work around a code-generation 
+    // hostTemp is only necessary to work around a code-generation
     // bug in egcs 1.1.2 (the version of gcc that comes with Red Hat 6.2),
     // which is the default compiler for Mozilla on linux at the moment.
     //
     NS_ConvertASCIItoUTF16 hostTemp(host);
     const char16_t *hostArray[1] = { hostTemp.get() };
 
     // format the hostname into the authprompt text string
     //
@@ -169,17 +169,17 @@ NS_IMETHODIMP nsAbLDAPListenerBase::OnLD
       NS_ERROR("nsAbLDAPListenerBase::OnLDAPInit():"
                " error getting most recent window");
       InitFailed();
       return rv;
     }
 
     // get the window watcher service, so we can get an auth prompter
     //
-    nsCOMPtr<nsIWindowWatcher> windowWatcherSvc = 
+    nsCOMPtr<nsIWindowWatcher> windowWatcherSvc =
       do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv);
     if (NS_FAILED(rv))
     {
       NS_ERROR("nsAbLDAPListenerBase::OnLDAPInit():"
                " couldn't get window watcher service.");
       InitFailed();
       return rv;
     }
@@ -194,17 +194,17 @@ NS_IMETHODIMP nsAbLDAPListenerBase::OnLD
       NS_ERROR("nsAbLDAPMessageBase::OnLDAPInit():"
                " error getting auth prompter");
       InitFailed();
       return rv;
     }
 
     // get authentication password, prompting the user if necessary
     //
-    // we're going to use the URL spec of the server as the "realm" for 
+    // we're going to use the URL spec of the server as the "realm" for
     // wallet to remember the password by / for.
 
     // Get the specification
     nsCString spec;
     rv = mDirectoryUrl->GetSpec(spec);
     if (NS_FAILED(rv))
     {
       NS_ERROR("nsAbLDAPMessageBase::OnLDAPInit():"
@@ -264,28 +264,28 @@ NS_IMETHODIMP nsAbLDAPListenerBase::OnLD
       do_CreateInstance(NS_AUTH_MODULE_CONTRACTID_PREFIX "sasl-gssapi", &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = mOperation->SaslBind(service, mSaslMechanism, authModule);
     if (NS_FAILED(rv))
     {
       NS_ERROR("nsAbLDAPMessageBase::OnLDAPInit(): "
                "failed to perform GSSAPI bind");
-      mOperation = 0; // Break Listener -> Operation -> Listener ref cycle
+      mOperation = nullptr; // Break Listener -> Operation -> Listener ref cycle
       InitFailed();
     }
     return rv;
   }
 
   // Bind
   rv = mOperation->SimpleBind(NS_ConvertUTF16toUTF8(passwd));
   if (NS_FAILED(rv))
   {
     NS_ERROR("nsAbLDAPMessageBase::OnLDAPInit(): failed to perform bind operation");
-    mOperation = 0; // Break Listener->Operation->Listener reference cycle
+    mOperation = nullptr; // Break Listener->Operation->Listener reference cycle
     InitFailed();
   }
   return rv;
 }
 
 nsresult nsAbLDAPListenerBase::OnLDAPMessageBind(nsILDAPMessage *aMessage)
 {
   if (mBound)
@@ -337,17 +337,17 @@ nsresult nsAbLDAPListenerBase::OnLDAPMes
         {
           NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(count, logins);
           return rv;
         }
       }
       NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(count, logins);
 
       // XXX We should probably pop up an error dialog telling
-      // the user that the login failed here, rather than just bringing 
+      // the user that the login failed here, rather than just bringing
       // up the password dialog again, which is what calling OnLDAPInit()
       // does.
       return OnLDAPInit(nullptr, NS_OK);
     }
 
     // Don't know how to handle this, so use the message error code in
     // the failure return value so we hopefully get it back to the UI.
     return NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, errCode);
--- a/mailnews/base/util/nsMsgIncomingServer.cpp
+++ b/mailnews/base/util/nsMsgIncomingServer.cpp
@@ -48,25 +48,25 @@
 #include "mozilla/Services.h"
 #include "nsIMsgFilter.h"
 #include "nsIArray.h"
 #include "nsArrayUtils.h"
 
 #define PORT_NOT_SET -1
 
 nsMsgIncomingServer::nsMsgIncomingServer():
-    m_rootFolder(0),
+    m_rootFolder(nullptr),
     m_downloadedHdrs(50),
     m_numMsgsDownloaded(0),
     m_biffState(nsIMsgFolder::nsMsgBiffState_Unknown),
     m_serverBusy(false),
     m_canHaveFilters(true),
     m_displayStartupPage(true),
     mPerformingBiff(false)
-{ 
+{
 }
 
 nsMsgIncomingServer::~nsMsgIncomingServer()
 {
 }
 
 NS_IMPL_ISUPPORTS(nsMsgIncomingServer, nsIMsgIncomingServer,
   nsISupportsWeakReference)
@@ -909,17 +909,17 @@ nsMsgIncomingServer::GetLocalPath(nsIFil
   rv = localPath->Create(nsIFile::DIRECTORY_TYPE, 0755);
   if (rv == NS_ERROR_FILE_ALREADY_EXISTS)
     rv = NS_OK;
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCString hostname;
   rv = GetHostName(hostname);
   NS_ENSURE_SUCCESS(rv, rv);
-  
+
   // set the leaf name to "dummy", and then call MakeUnique with a suggested leaf name
   rv = localPath->AppendNative(hostname);
   NS_ENSURE_SUCCESS(rv, rv);
   rv = localPath->CreateUnique(nsIFile::DIRECTORY_TYPE, 0755);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = SetLocalPath(localPath);
   NS_ENSURE_SUCCESS(rv, rv);
@@ -1305,17 +1305,17 @@ nsMsgIncomingServer::GetHostName(nsACStr
 
 NS_IMETHODIMP
 nsMsgIncomingServer::GetRealHostName(nsACString& aResult)
 {
   // If 'realhostname' is set (was changed) then use it, otherwise use 'hostname'
   nsresult rv;
   rv = GetCharValue("realhostname", aResult);
   NS_ENSURE_SUCCESS(rv, rv);
-  
+
   if (aResult.IsEmpty())
     return GetHostName(aResult);
 
   if (MsgCountChar(aResult, ':') == 1)
   {
     SetRealHostName(aResult);
     rv = GetCharValue("realhostname", aResult);
   }
--- a/mailnews/base/util/nsMsgProtocol.cpp
+++ b/mailnews/base/util/nsMsgProtocol.cpp
@@ -250,20 +250,20 @@ nsresult nsMsgProtocol::CloseSocket()
     if (strans) {
       strans->SetEventSink(nullptr, nullptr); // break cyclic reference!
     }
   }
   // we need to call Cancel so that we remove the socket transport from the mActiveTransportList.  see bug #30648
   if (m_request) {
     rv = m_request->Cancel(NS_BINDING_ABORTED);
   }
-  m_request = 0;
+  m_request = nullptr;
   if (m_transport) {
     m_transport->Close(NS_BINDING_ABORTED);
-    m_transport = 0;
+    m_transport = nullptr;
   }
 
   return rv;
 }
 
 /*
 * Writes the data contained in dataBuffer into the current output stream. It also informs
 * the transport layer that this data is now available for transmission.
@@ -387,18 +387,18 @@ NS_IMETHODIMP nsMsgProtocol::OnStopReque
         NS_ENSURE_SUCCESS(rv, rv);
 
         rv = mailSession->AlertUser(errorMsg, msgUrl);
       }
     } // if we got an error code
   } // if we have a mailnews url.
 
   // Drop notification callbacks to prevent cycles.
-  mCallbacks = 0;
-  mProgressEventSink = 0;
+  mCallbacks = nullptr;
+  mProgressEventSink = nullptr;
   // Call CloseSocket(), in case we got here because the server dropped the
   // connection while reading, and we never get a chance to get back into
   // the protocol state machine via OnDataAvailable.
   if (m_socketIsOpen)
     CloseSocket();
 
   return rv;
 }
--- a/mailnews/compose/src/nsMsgSend.cpp
+++ b/mailnews/compose/src/nsMsgSend.cpp
@@ -937,17 +937,17 @@ nsMsgComposeAndSend::GatherMimeAttachmen
   status = toppart->Write();
   if (NS_FAILED(status))
     goto FAIL;
 
   /* Close down encryption stream */
   if (m_crypto_closure)
   {
     status = m_crypto_closure->FinishCryptoEncapsulation(false, mSendReport);
-    m_crypto_closure = 0;
+    m_crypto_closure = nullptr;
     if (NS_FAILED(status)) goto FAIL;
   }
 
   if (mOutputFile)
   {
     if (NS_FAILED(mOutputFile->Flush()))
     {
       status = NS_MSG_ERROR_WRITING_FILE;
--- a/mailnews/extensions/smime/src/nsMsgComposeSecure.cpp
+++ b/mailnews/extensions/smime/src/nsMsgComposeSecure.cpp
@@ -681,17 +681,17 @@ nsresult nsMsgComposeSecure::MimeFinishM
   NS_ConvertUTF16toUTF8 sig_content_desc_utf8(mime_smime_sig_content_desc);
 
   /* Compute the hash...
    */
 
   nsAutoCString hashString;
   mDataHash->Finish(false, hashString);
 
-  mDataHash = 0;
+  mDataHash = nullptr;
 
   status = PR_GetError();
   if (status < 0) goto FAIL;
 
   /* Write out the headers for the signature.
    */
   uint32_t L;
   header =
@@ -833,24 +833,24 @@ nsresult nsMsgComposeSecure::MimeFinishE
   }
 
   rv = mEncryptionContext->Finish();
   if (NS_FAILED(rv)) {
     SetError(sendReport, u"ErrorEncryptMail");
     goto FAIL;
   }
 
-  mEncryptionContext = 0;
+  mEncryptionContext = nullptr;
 
   PR_ASSERT(mEncryptionCinfo);
   if (!mEncryptionCinfo) {
     rv = NS_ERROR_FAILURE;
   }
   if (mEncryptionCinfo) {
-    mEncryptionCinfo = 0;
+    mEncryptionCinfo = nullptr;
   }
 
   // Shut down the base64 encoder.
   mCryptoEncoder->Flush();
   mCryptoEncoder = nullptr;
 
   uint32_t n;
   rv = mStream->Write(CRLF, 2, &n);
--- a/mailnews/local/src/nsMailboxProtocol.cpp
+++ b/mailnews/local/src/nsMailboxProtocol.cpp
@@ -54,17 +54,17 @@ nsMailboxProtocol::nsMailboxProtocol(nsI
 
   // initialize the pr log if it hasn't been initialiezed already
   if (!MAILBOX)
     MAILBOX = PR_NewLogModule("MAILBOX");
 }
 
 nsMailboxProtocol::~nsMailboxProtocol()
 {
-  // free our local state 
+  // free our local state
   delete m_lineStreamBuffer;
 }
 
 nsresult nsMailboxProtocol::OpenMultipleMsgTransport(uint64_t offset, int32_t size)
 {
   nsresult rv;
 
   nsCOMPtr<nsIStreamTransportService> serv =
@@ -84,17 +84,17 @@ nsresult nsMailboxProtocol::Initialize(n
   NS_PRECONDITION(aURL, "invalid URL passed into MAILBOX Protocol");
   nsresult rv = NS_OK;
   if (aURL)
   {
     rv = aURL->QueryInterface(NS_GET_IID(nsIMailboxUrl), (void **) getter_AddRefs(m_runningUrl));
     if (NS_SUCCEEDED(rv) && m_runningUrl)
     {
       nsCOMPtr <nsIMsgWindow> window;
-      rv = m_runningUrl->GetMailboxAction(&m_mailboxAction); 
+      rv = m_runningUrl->GetMailboxAction(&m_mailboxAction);
       // clear stopped flag on msg window, because we care.
       nsCOMPtr <nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(m_runningUrl);
       if (mailnewsUrl)
       {
         mailnewsUrl->GetMsgWindow(getter_AddRefs(window));
         if (window)
           window->SetStopped(false);
       }
@@ -170,30 +170,30 @@ nsresult nsMailboxProtocol::Initialize(n
           }
           if (!folder) // must be a .eml file
             rv = OpenFileSocket(aURL, 0, aMsgSize);
         }
         NS_ASSERTION(NS_SUCCEEDED(rv), "oops....i messed something up");
       }
     }
   }
-  
+
   m_lineStreamBuffer = new nsMsgLineStreamBuffer(OUTPUT_BUFFER_SIZE, true);
-  
+
   m_nextState = MAILBOX_READ_FOLDER;
   m_initialState = MAILBOX_READ_FOLDER;
   mCurrentProgress = 0;
-  
+
   // do we really need both?
   m_tempMessageFile = m_tempMsgFile;
   return rv;
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////
-// we suppport the nsIStreamListener interface 
+// we suppport the nsIStreamListener interface
 ////////////////////////////////////////////////////////////////////////////////////////////
 
 NS_IMETHODIMP nsMailboxProtocol::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
 {
   // extract the appropriate event sinks from the url and initialize them in our protocol data
   // the URL should be queried for a nsINewsURL. If it doesn't support a news URL interface then
   // we have an error.
   if (m_nextState == MAILBOX_READ_FOLDER && m_mailboxParser)
@@ -211,42 +211,42 @@ bool nsMailboxProtocol::RunningMultipleM
     uint32_t numMoveCopyMsgs;
     nsresult rv = m_runningUrl->GetNumMoveCopyMsgs(&numMoveCopyMsgs);
     if (NS_SUCCEEDED(rv) && numMoveCopyMsgs > 1)
       return true;
   }
   return false;
 }
 
-// stop binding is a "notification" informing us that the stream associated with aURL is going away. 
+// stop binding is a "notification" informing us that the stream associated with aURL is going away.
 NS_IMETHODIMP nsMailboxProtocol::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult aStatus)
 {
   nsresult rv;
   if (m_nextState == MAILBOX_READ_FOLDER && m_mailboxParser)
   {
     // we need to inform our mailbox parser that there is no more incoming data...
     m_mailboxParser->OnStopRequest(request, ctxt, aStatus);
   }
-  else if (m_nextState == MAILBOX_READ_MESSAGE) 
+  else if (m_nextState == MAILBOX_READ_MESSAGE)
   {
     DoneReadingMessage();
   }
   // I'm not getting cancel status - maybe the load group still has the status.
   bool stopped = false;
   if (m_runningUrl)
   {
     nsCOMPtr <nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(m_runningUrl);
     if (mailnewsUrl)
     {
       nsCOMPtr <nsIMsgWindow> window;
       mailnewsUrl->GetMsgWindow(getter_AddRefs(window));
       if (window)
         window->GetStopped(&stopped);
     }
-    
+
     if (!stopped && NS_SUCCEEDED(aStatus) && (m_mailboxAction == nsIMailboxUrl::ActionCopyMessage || m_mailboxAction == nsIMailboxUrl::ActionMoveMessage))
     {
       uint32_t numMoveCopyMsgs;
       uint32_t curMoveCopyMsgIndex;
       rv = m_runningUrl->GetNumMoveCopyMsgs(&numMoveCopyMsgs);
       if (NS_SUCCEEDED(rv) && numMoveCopyMsgs > 0)
       {
         m_runningUrl->GetCurMoveCopyMsgIndex(&curMoveCopyMsgIndex);
@@ -286,19 +286,19 @@ NS_IMETHODIMP nsMailboxProtocol::OnStopR
                 // now we have to seek to the right position in the file and
                 // basically re-initialize the transport with the correct message size.
                 // then, we have to make sure the url keeps running somehow.
                 nsCOMPtr<nsISupports> urlSupports = do_QueryInterface(m_runningUrl);
                 //
                 // put us in a state where we are always notified of incoming data
                 //
 
-                m_transport = 0; // open new stream transport
-                m_inputStream = 0;
-                m_outputStream = 0;
+                m_transport = nullptr; // open new stream transport
+                m_inputStream = nullptr;
+                m_outputStream = nullptr;
 
                 if (m_multipleMsgMoveCopyStream)
                 {
                   rv = OpenMultipleMsgTransport(msgOffset, msgSize);
                 }
                 else
                 {
                   nsCOMPtr<nsIInputStream> stream;
@@ -350,66 +350,66 @@ NS_IMETHODIMP nsMailboxProtocol::OnStopR
           }
         }
         else
         {
         }
       }
     }
   }
-  // and we want to mark ourselves for deletion or some how inform our protocol manager that we are 
+  // and we want to mark ourselves for deletion or some how inform our protocol manager that we are
   // available for another url if there is one.
-  
+
   // mscott --> maybe we should set our state to done because we don't run multiple urls in a mailbox
   // protocol connection....
   m_nextState = MAILBOX_DONE;
-  
+
   // the following is for smoke test purposes. QA is looking at this "Mailbox Done" string which
   // is printed out to the console and determining if the mail app loaded up correctly...obviously
   // this solution is not very good so we should look at something better, but don't remove this
   // line before talking to me (mscott) and mailnews QA....
-  
+
   MOZ_LOG(MAILBOX, mozilla::LogLevel::Info, ("Mailbox Done\n"));
-  
+
   // when on stop binding is called, we as the protocol are done...let's close down the connection
   // releasing all of our interfaces. It's important to remember that this on stop binding call
   // is coming from netlib so they are never going to ping us again with on data available. This means
   // we'll never be going through the Process loop...
-  
+
   if (m_multipleMsgMoveCopyStream)
   {
     m_multipleMsgMoveCopyStream->Close();
     m_multipleMsgMoveCopyStream = nullptr;
   }
   nsMsgProtocol::OnStopRequest(request, ctxt, aStatus);
-  return CloseSocket(); 
+  return CloseSocket();
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////
 // End of nsIStreamListenerSupport
 //////////////////////////////////////////////////////////////////////////////////////////////
 
 nsresult nsMailboxProtocol::DoneReadingMessage()
 {
   nsresult rv = NS_OK;
   // and close the article file if it was open....
-  
+
   if (m_mailboxAction == nsIMailboxUrl::ActionSaveMessageToDisk && m_msgFileOutputStream)
     rv = m_msgFileOutputStream->Close();
-  
+
   return rv;
 }
 
 nsresult nsMailboxProtocol::SetupMessageExtraction()
 {
-  // Determine the number of bytes we are going to need to read out of the 
+  // Determine the number of bytes we are going to need to read out of the
   // mailbox url....
   nsCOMPtr<nsIMsgDBHdr> msgHdr;
   nsresult rv = NS_OK;
-  
+
   NS_ASSERTION(m_runningUrl, "Not running a url");
   if (m_runningUrl)
   {
     uint32_t messageSize = 0;
     m_runningUrl->GetMessageSize(&messageSize);
     if (!messageSize)
     {
       nsCOMPtr<nsIMsgMessageUrl> msgUrl = do_QueryInterface(m_runningUrl, &rv);
@@ -434,25 +434,25 @@ nsresult nsMailboxProtocol::SetupMessage
 
 nsresult nsMailboxProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
 {
   nsresult rv = NS_OK;
   // if we were already initialized with a consumer, use it...
   nsCOMPtr<nsIStreamListener> consumer = do_QueryInterface(aConsumer);
   if (consumer)
     m_channelListener = consumer;
-  
+
   if (aURL)
   {
     m_runningUrl = do_QueryInterface(aURL);
     if (m_runningUrl)
     {
       // find out from the url what action we are supposed to perform...
       rv = m_runningUrl->GetMailboxAction(&m_mailboxAction);
-      
+
       bool convertData = false;
 
       // need to check if we're fetching an rfc822 part in order to
       // quote a message.
       if (m_mailboxAction == nsIMailboxUrl::ActionFetchMessage)
       {
         nsCOMPtr<nsIMsgMailNewsUrl> msgUrl = do_QueryInterface(m_runningUrl, &rv);
         NS_ENSURE_SUCCESS(rv,rv);
@@ -481,17 +481,17 @@ nsresult nsMailboxProtocol::LoadUrl(nsIU
           nsCOMPtr <nsIStreamListener> conversionListener;
           nsCOMPtr<nsIChannel> channel;
           QueryInterface(NS_GET_IID(nsIChannel), getter_AddRefs(channel));
 
           rv = streamConverter->AsyncConvertData("message/rfc822",
                                                  "*/*",
                                                  consumer, channel, getter_AddRefs(m_channelListener));
       }
-      
+
       if (NS_SUCCEEDED(rv))
       {
         switch (m_mailboxAction)
         {
         case nsIMailboxUrl::ActionParseMailbox:
           // extract the mailbox parser..
           rv = m_runningUrl->GetMailboxParser(getter_AddRefs(m_mailboxParser));
           m_nextState = MAILBOX_READ_FOLDER;
@@ -528,77 +528,77 @@ nsresult nsMailboxProtocol::LoadUrl(nsIU
           break;
         case nsIMailboxUrl::ActionFetchPart:
             m_nextState = MAILBOX_READ_MESSAGE;
             break;
         default:
           break;
         }
       }
-      
+
       rv = nsMsgProtocol::LoadUrl(aURL, m_channelListener);
-      
+
     } // if we received an MAILBOX url...
   } // if we received a url!
-  
+
   return rv;
 }
 
 int32_t nsMailboxProtocol::ReadFolderResponse(nsIInputStream * inputStream, uint64_t sourceOffset, uint32_t length)
 {
   // okay we are doing a folder read in 8K chunks of a mail folder....
   // this is almost too easy....we can just forward the data in this stream on to our
   // folder parser object!!!
-  
+
   nsresult rv = NS_OK;
   mCurrentProgress += length;
-  
+
   if (m_mailboxParser)
   {
     nsCOMPtr <nsIURI> url = do_QueryInterface(m_runningUrl);
     rv = m_mailboxParser->OnDataAvailable(nullptr, url, inputStream, sourceOffset, length); // let the parser deal with it...
   }
   if (NS_FAILED(rv))
   {
     m_nextState = MAILBOX_ERROR_DONE; // drop out of the loop....
     return -1;
   }
-  
+
   // now wait for the next 8K chunk to come in.....
   SetFlag(MAILBOX_PAUSE_FOR_READ);
-  
+
   // leave our state alone so when the next chunk of the mailbox comes in we jump to this state
   // and repeat....how does this process end? Well when the file is done being read in, core net lib
   // will issue an ::OnStopRequest to us...we'll use that as our sign to drop out of this state and to
   // close the protocol instance...
-  
-  return 0; 
+
+  return 0;
 }
 
 int32_t nsMailboxProtocol::ReadMessageResponse(nsIInputStream * inputStream, uint64_t sourceOffset, uint32_t length)
 {
   char *line = nullptr;
   uint32_t status = 0;
   nsresult rv = NS_OK;
   mCurrentProgress += length;
-  
+
   // if we are doing a move or a copy, forward the data onto the copy handler...
   // if we want to display the message then parse the incoming data...
-  
+
   if (m_channelListener)
   {
     // just forward the data we read in to the listener...
     rv = m_channelListener->OnDataAvailable(this, m_channelContext, inputStream, sourceOffset, length);
   }
   else
   {
     bool pauseForMoreData = false;
     bool canonicalLineEnding = false;
     nsCOMPtr<nsIMsgMessageUrl> msgurl = do_QueryInterface(m_runningUrl);
-    
+
     if (msgurl)
       msgurl->GetCanonicalLineEnding(&canonicalLineEnding);
 
     while ((line = m_lineStreamBuffer->ReadNextLine(inputStream, status, pauseForMoreData)) &&
            !pauseForMoreData)
     {
       /* When we're sending this line to a converter (ie,
       it's a message/rfc822) use the local line termination
@@ -628,49 +628,49 @@ int32_t nsMailboxProtocol::ReadMessageRe
           break;
       }
       else
         SetFlag(MAILBOX_MSG_PARSE_FIRST_LINE);
       PR_Free(line);
     }
     PR_Free(line);
   }
-  
+
   SetFlag(MAILBOX_PAUSE_FOR_READ); // wait for more data to become available...
   if (mProgressEventSink && m_runningUrl)
   {
     int64_t maxProgress;
     nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl(do_QueryInterface(m_runningUrl));
     mailnewsUrl->GetMaxProgress(&maxProgress);
     mProgressEventSink->OnProgress(this, m_channelContext,
                                    mCurrentProgress,
                                    maxProgress);
   }
-  
+
   if (NS_FAILED(rv)) return -1;
-  
+
   return 0;
 }
 
 
 /*
  * returns negative if the transfer is finished or error'd out
  *
  * returns zero or more if the transfer needs to be continued.
  */
 nsresult nsMailboxProtocol::ProcessProtocolState(nsIURI * url, nsIInputStream * inputStream, uint64_t offset, uint32_t length)
 {
   nsresult rv = NS_OK;
   int32_t status = 0;
   ClearFlag(MAILBOX_PAUSE_FOR_READ); /* already paused; reset */
-  
+
   while(!TestFlag(MAILBOX_PAUSE_FOR_READ))
   {
-    
-    switch(m_nextState) 
+
+    switch(m_nextState)
     {
     case MAILBOX_READ_MESSAGE:
       if (inputStream == nullptr)
         SetFlag(MAILBOX_PAUSE_FOR_READ);
       else
         status = ReadMessageResponse(inputStream, offset, length);
       break;
     case MAILBOX_READ_FOLDER:
@@ -683,43 +683,43 @@ nsresult nsMailboxProtocol::ProcessProto
     case MAILBOX_ERROR_DONE:
       {
         nsCOMPtr <nsIMsgMailNewsUrl> anotherUrl = do_QueryInterface(m_runningUrl);
         rv = m_nextState == MAILBOX_DONE ? NS_OK : NS_ERROR_FAILURE;
         anotherUrl->SetUrlState(false, rv);
         m_nextState = MAILBOX_FREE;
       }
       break;
-      
+
     case MAILBOX_FREE:
       // MAILBOX is a one time use connection so kill it if we get here...
-      CloseSocket(); 
+      CloseSocket();
       return rv; /* final end */
-      
+
     default: /* should never happen !!! */
       m_nextState = MAILBOX_ERROR_DONE;
       break;
     }
-    
-    /* check for errors during load and call error 
+
+    /* check for errors during load and call error
     * state if found
     */
     if(status < 0 && m_nextState != MAILBOX_FREE)
     {
       m_nextState = MAILBOX_ERROR_DONE;
       /* don't exit! loop around again and do the free case */
       ClearFlag(MAILBOX_PAUSE_FOR_READ);
     }
   } /* while(!MAILBOX_PAUSE_FOR_READ) */
-  
+
   return rv;
 }
 
 nsresult nsMailboxProtocol::CloseSocket()
 {
   // how do you force a release when closing the connection??
-  nsMsgProtocol::CloseSocket(); 
+  nsMsgProtocol::CloseSocket();
   m_runningUrl = nullptr;
   m_mailboxParser = nullptr;
   return NS_OK;
 }
 
 // vim: ts=2 sw=2
--- a/mailnews/local/src/nsPop3Sink.cpp
+++ b/mailnews/local/src/nsPop3Sink.cpp
@@ -272,17 +272,17 @@ nsPop3Sink::EndMailDelivery(nsIPop3Proto
     if (m_outFileStream)
       m_outFileStream->Flush();  // try this.
     m_newMailParser->OnStopRequest(nullptr, nullptr, NS_OK);
     m_newMailParser->EndMsgDownload();
   }
   if (m_outFileStream)
   {
     m_outFileStream->Close();
-    m_outFileStream = 0;
+    m_outFileStream = nullptr;
   }
 
   if (m_downloadingToTempFile)
     m_tmpDownloadFile->Remove(false);
 
   // tell the parser to mark the db valid *after* closing the mailbox.
   if (m_newMailParser)
     m_newMailParser->UpdateDBFolderInfo();
@@ -400,17 +400,17 @@ nsPop3Sink::AbortMailDelivery(nsIPop3Pro
 {
   CheckPartialMessages(protocol);
 
   // ### PS TODO - discard any new message?
 
   if (m_outFileStream)
   {
     m_outFileStream->Close();
-    m_outFileStream = 0;
+    m_outFileStream = nullptr;
   }
 
   if (m_downloadingToTempFile && m_tmpDownloadFile)
     m_tmpDownloadFile->Remove(false);
 
   /* tell the parser to mark the db valid *after* closing the mailbox.
   we have truncated the inbox, so berkeley mailbox and msf file are in sync*/
   if (m_newMailParser)
--- a/mailnews/mime/src/mimecms.cpp
+++ b/mailnews/mime/src/mimecms.cpp
@@ -68,30 +68,30 @@ typedef struct MimeCMSdata
   bool ci_is_encrypted;
   char *sender_addr;
   bool decoding_failed;
   uint32_t decoded_bytes;
   MimeObject *self;
   bool parent_is_encrypted_p;
   bool parent_holds_stamp_p;
   nsCOMPtr<nsIMsgSMIMEHeaderSink> smimeHeaderSink;
-  
+
   MimeCMSdata()
   :output_fn(nullptr),
   output_closure(nullptr),
   ci_is_encrypted(false),
   sender_addr(nullptr),
   decoding_failed(false),
   decoded_bytes(0),
   self(nullptr),
   parent_is_encrypted_p(false),
   parent_holds_stamp_p(false)
   {
   }
-  
+
   ~MimeCMSdata()
   {
     if(sender_addr)
       PR_Free(sender_addr);
 
     // Do an orderly release of nsICMSDecoder and nsICMSMessage //
     if (decoder_context)
     {
@@ -135,17 +135,17 @@ bool MimeEncryptedCMS_encrypted_p (MimeO
     if (!data || !data->content_info) return false;
                 data->content_info->ContentIsEncrypted(&encrypted);
           return encrypted;
   }
   return false;
 }
 
 
-bool MimeCMSHeadersAndCertsMatch(nsICMSMessage *content_info, 
+bool MimeCMSHeadersAndCertsMatch(nsICMSMessage *content_info,
                                    nsIX509Cert *signerCert,
                                    const char *from_addr,
                                    const char *from_name,
                                    const char *sender_addr,
                                    const char *sender_name,
                                    bool *signing_cert_without_email_address)
 {
   nsCString cert_addr;
@@ -213,17 +213,17 @@ public:
   NS_DECL_NSISMIMEVERIFICATIONLISTENER
 
   nsSMimeVerificationListener(const char *aFromAddr, const char *aFromName,
                               const char *aSenderAddr, const char *aSenderName,
                               nsIMsgSMIMEHeaderSink *aHeaderSink, int32_t aMimeNestingLevel);
 
 protected:
   virtual ~nsSMimeVerificationListener() {}
-  
+
   /**
    * It is safe to declare this implementation as thread safe,
    * despite not using a lock to protect the members.
    * Because of the way the object will be used, we don't expect a race.
    * After construction, the object is passed to another thread,
    * but will no longer be accessed on the original thread.
    * The other thread is unable to access/modify self's data members.
    * When the other thread is finished, it will call into the "Notify"
@@ -295,27 +295,27 @@ nsSMimeVerificationListener::nsSMimeVeri
   mSenderName = aSenderName;
 }
 
 NS_IMETHODIMP nsSMimeVerificationListener::Notify(nsICMSMessage2 *aVerifiedMessage,
                                                   nsresult aVerificationResultCode)
 {
   // Only continue if we have a valid pointer to the UI
   NS_ENSURE_FALSE(mSinkIsNull, NS_OK);
-  
+
   NS_ENSURE_TRUE(aVerifiedMessage, NS_ERROR_FAILURE);
-  
+
   nsCOMPtr<nsICMSMessage> msg = do_QueryInterface(aVerifiedMessage);
   NS_ENSURE_TRUE(msg, NS_ERROR_FAILURE);
-  
+
   nsCOMPtr<nsIX509Cert> signerCert;
   msg->GetSignerCert(getter_AddRefs(signerCert));
-  
+
   int32_t signature_status = nsICMSMessageErrors::GENERAL_ERROR;
-  
+
   if (NS_FAILED(aVerificationResultCode))
   {
     if (NS_ERROR_MODULE_SECURITY == NS_ERROR_GET_MODULE(aVerificationResultCode))
       signature_status = NS_ERROR_GET_CODE(aVerificationResultCode);
     else if (NS_ERROR_NOT_IMPLEMENTED == aVerificationResultCode)
       signature_status = nsICMSMessageErrors::VERIFY_ERROR_PROCESSING;
   }
   else
@@ -328,17 +328,17 @@ NS_IMETHODIMP nsSMimeVerificationListene
                                                 &signing_cert_without_email_address);
     if (!good_p)
     {
       if (signing_cert_without_email_address)
         signature_status = nsICMSMessageErrors::VERIFY_CERT_WITHOUT_ADDRESS;
       else
         signature_status = nsICMSMessageErrors::VERIFY_HEADER_MISMATCH;
     }
-    else 
+    else
       signature_status = nsICMSMessageErrors::SUCCESS;
   }
 
   ProxySignedStatus(mHeaderSink, mMimeNestingLevel, signature_status, signerCert);
 
   return NS_OK;
 }
 
@@ -406,17 +406,17 @@ int MIMEGetRelativeCryptoNestLevel(MimeO
   if (!CryptoObjectIsChildOfTopShownObject) {
     return -1;
   }
 
   return aCryptoPartNestLevel - aTopMessageNestLevel;
 }
 
 static void *MimeCMS_init(MimeObject *obj,
-                          int (*output_fn) (const char *buf, int32_t buf_size, void *output_closure), 
+                          int (*output_fn) (const char *buf, int32_t buf_size, void *output_closure),
                           void *output_closure)
 {
   MimeCMSdata *data;
   nsresult rv;
 
   if (!(obj && obj->options && output_fn)) return 0;
 
   data = new MimeCMSdata;
@@ -567,23 +567,23 @@ void MimeCMSRequestAsyncSignatureVerific
                                               const char *aFromAddr, const char *aFromName,
                                               const char *aSenderAddr, const char *aSenderName,
                                               nsIMsgSMIMEHeaderSink *aHeaderSink, int32_t aMimeNestingLevel,
                                               unsigned char* item_data, uint32_t item_len)
 {
   nsCOMPtr<nsICMSMessage2> msg2 = do_QueryInterface(aCMSMsg);
   if (!msg2)
     return;
-  
-  RefPtr<nsSMimeVerificationListener> listener = 
+
+  RefPtr<nsSMimeVerificationListener> listener =
     new nsSMimeVerificationListener(aFromAddr, aFromName, aSenderAddr, aSenderName,
                                     aHeaderSink, aMimeNestingLevel);
   if (!listener)
     return;
-  
+
   if (item_data)
     msg2->AsyncVerifyDetachedSignature(listener, item_data, item_len);
   else
     msg2->AsyncVerifySignature(listener);
 }
 
 static int
 MimeCMS_eof (void *crypto_closure, bool abort_p)
@@ -606,17 +606,17 @@ MimeCMS_eof (void *crypto_closure, bool 
    blurb about whether the signature validation was cool.
    */
 
   PR_SetError(0, 0);
   rv = data->decoder_context->Finish(getter_AddRefs(data->content_info));
   if (NS_FAILED(rv))
     status = nsICMSMessageErrors::GENERAL_ERROR;
 
-  data->decoder_context = 0;
+  data->decoder_context = nullptr;
 
   nsCOMPtr<nsIX509Cert> certOfInterest;
 
   if (!data->smimeHeaderSink)
     return 0;
 
   if (aRelativeNestLevel < 0)
     return 0;
@@ -670,24 +670,24 @@ MimeCMS_eof (void *crypto_closure, bool 
         return 0;
       }
 
       nsCString from_addr;
       nsCString from_name;
       nsCString sender_addr;
       nsCString sender_name;
 
-      MimeCMSGetFromSender(data->self, 
+      MimeCMSGetFromSender(data->self,
                            from_addr, from_name,
                            sender_addr, sender_name);
 
-      MimeCMSRequestAsyncSignatureVerification(data->content_info, 
+      MimeCMSRequestAsyncSignatureVerification(data->content_info,
                                                from_addr.get(), from_name.get(),
                                                sender_addr.get(), sender_name.get(),
-                                               data->smimeHeaderSink, aRelativeNestLevel, 
+                                               data->smimeHeaderSink, aRelativeNestLevel,
                                                nullptr, 0);
     }
   }
 
   if (data->ci_is_encrypted)
   {
     data->smimeHeaderSink->EncryptionStatus(
       aRelativeNestLevel,
@@ -699,17 +699,17 @@ MimeCMS_eof (void *crypto_closure, bool 
   return 0;
 }
 
 static void
 MimeCMS_free (void *crypto_closure)
 {
   MimeCMSdata *data = (MimeCMSdata *) crypto_closure;
   if (!data) return;
-  
+
   delete data;
 }
 
 static char *
 MimeCMS_generate (void *crypto_closure)
 {
   return nullptr;
 }
--- a/mailnews/mime/src/mimemcms.cpp
+++ b/mailnews/mime/src/mimemcms.cpp
@@ -296,17 +296,17 @@ MimeMultCMS_data_eof (void *crypto_closu
 
   data->item_len  = hashString.Length();
   data->item_data = new unsigned char[data->item_len];
   if (!data->item_data) return MIME_OUT_OF_MEMORY;
 
   memcpy(data->item_data, hashString.get(), data->item_len);
 
   // Release our reference to nsICryptoHash //
-  data->data_hash_context = 0;
+  data->data_hash_context = nullptr;
 
   /* At this point, data->item.data contains a digest for the first part.
    When we process the signature, the security library will compare this
    digest to what's in the signature object. */
 
   return 0;
 }
 
@@ -378,17 +378,17 @@ MimeMultCMS_sig_eof (void *crypto_closur
    We save away the value returned and will use it later to emit a
    blurb about whether the signature validation was cool.
    */
 
   if (data->sig_decoder_context) {
     data->sig_decoder_context->Finish(getter_AddRefs(data->content_info));
 
     // Release our reference to nsICMSDecoder //
-    data->sig_decoder_context = 0;
+    data->sig_decoder_context = nullptr;
   }
 
   return 0;
 }
 
 static void
 MimeMultCMS_free (void *crypto_closure)
 {
--- a/mailnews/mime/src/mimemoz2.cpp
+++ b/mailnews/mime/src/mimemoz2.cpp
@@ -491,17 +491,17 @@ GenerateAttachmentData(MimeObject *objec
 
 nsresult
 BuildAttachmentList(MimeObject *anObject, nsMsgAttachmentData *aAttachData, const char *aMessageURL)
 {
   nsresult              rv;
   int32_t               i;
   MimeContainer         *cobj = (MimeContainer *) anObject;
   bool                  found_output = false;
-  
+
   if ( (!anObject) || (!cobj->children) || (!cobj->nchildren) ||
        (mime_typep(anObject, (MimeObjectClass *)&mimeExternalBodyClass)))
     return NS_OK;
 
   for (i = 0; i < cobj->nchildren ; i++)
   {
     MimeObject    *child = cobj->children[i];
     char          *ct = child->content_type;
@@ -1525,17 +1525,17 @@ mime_bridge_create_display_stream(
     delete msd;
     return nullptr;
   }
 
   // Need the text converter...
   rv = CallCreateInstance(MOZ_TXTTOHTMLCONV_CONTRACTID, &(msd->options->conv));
   if (NS_FAILED(rv))
   {
-    msd->options->m_prefBranch = 0;
+    msd->options->m_prefBranch = nullptr;
     delete msd;
     return nullptr;
   }
 
   //
   // Set the defaults, based on the context, and the output-type.
   //
   MIME_HeaderType = MimeHeadersAll;
@@ -1775,17 +1775,17 @@ mimeEmitterAddAllHeaders(MimeDisplayOpti
 
   mime_stream_data  *msd = GetMSD(opt);
   if (!msd)
     return NS_ERROR_FAILURE;
 
   if (msd->output_emitter)
   {
     nsIMimeEmitter *emitter = (nsIMimeEmitter *)msd->output_emitter;
-    return emitter->AddAllHeaders(Substring(allheaders, 
+    return emitter->AddAllHeaders(Substring(allheaders,
                                             allheaders + allheadersize));
   }
 
   return NS_ERROR_FAILURE;
 }
 
 extern "C" nsresult
 mimeEmitterStartAttachment(MimeDisplayOptions *opt, const char *name, const char *contentType, const char *url,