Bug 784739 - Switch from NULL to nullptr in netwerk/ (2/2); r=ehsan
authorBirunthan Mohanathas <birunthan@mohanathas.com>
Thu, 19 Sep 2013 15:29:27 -0400
changeset 147979 ae180b16eda7b404086e25aa9924c6879c573040
parent 147978 06025e91dc9f8d13813c886341831986af7d29a7
child 147980 b0d8ceeede143feb79da2ab69bbd06268621dd3a
push id25321
push useremorley@mozilla.com
push dateFri, 20 Sep 2013 09:19:10 +0000
treeherdermozilla-central@d923570ed720 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs784739
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 784739 - Switch from NULL to nullptr in netwerk/ (2/2); r=ehsan
netwerk/mime/nsMIMEHeaderParamImpl.cpp
netwerk/protocol/device/AndroidCaptureProvider.cpp
netwerk/protocol/device/CameraStreamImpl.cpp
netwerk/protocol/file/nsFileProtocolHandler.cpp
netwerk/protocol/http/SpdySession2.cpp
netwerk/protocol/http/SpdySession3.cpp
netwerk/protocol/http/SpdyStream3.cpp
netwerk/protocol/http/nsHttpChannel.cpp
netwerk/protocol/http/nsHttpConnectionMgr.cpp
netwerk/protocol/websocket/WebSocketChannel.h
netwerk/socket/nsSOCKSIOLayer.cpp
netwerk/streamconv/converters/nsDirIndexParser.cpp
netwerk/streamconv/converters/nsHTTPCompressConv.cpp
netwerk/streamconv/converters/nsMultiMixedConv.cpp
netwerk/streamconv/test/TestStreamConv.cpp
netwerk/system/win32/nsNotifyAddrListener.cpp
netwerk/test/ReadNTLM.cpp
netwerk/test/TestPageLoad.cpp
netwerk/test/TestSTSParser.cpp
netwerk/test/TestWriteSpeed.cpp
netwerk/wifi/nsWifiScannerSolaris.cpp
netwerk/wifi/nsWifiScannerWin.cpp
--- a/netwerk/mime/nsMIMEHeaderParamImpl.cpp
+++ b/netwerk/mime/nsMIMEHeaderParamImpl.cpp
@@ -197,22 +197,22 @@ class Continuation {
 
     const char *value;
     uint32_t length;
     bool needsPercentDecoding;
     bool wasQuotedString;
 };
 
 // combine segments into a single string, returning the allocated string
-// (or NULL) while emptying the list 
+// (or nullptr) while emptying the list 
 char *combineContinuations(nsTArray<Continuation>& aArray)
 {
   // Sanity check
   if (aArray.Length() == 0)
-    return NULL;
+    return nullptr;
 
   // Get an upper bound for the length
   uint32_t length = 0;
   for (uint32_t i = 0; i < aArray.Length(); i++) {
     length += aArray[i].length;
   }
 
   // Allocate
@@ -234,17 +234,17 @@ char *combineContinuations(nsTArray<Cont
       if (cont.wasQuotedString) {
         RemoveQuotedStringEscapes(c);
       }
     }
 
     // return null if empty value
     if (*result == '\0') {
       nsMemory::Free(result);
-      result = NULL;
+      result = nullptr;
     }
   } else {
     // Handle OOM
     NS_WARNING("Out of memory\n");
   }
 
   return result;
 }
@@ -430,19 +430,19 @@ nsMIMEHeaderParamImpl::DoParameterIntern
   //    title*2="Else..."
   // D. title*0="Hey, what you think you are doing?"
   //    title*1="There is no charset and lang info."
   // RFC5987: only A and B
   
   // collect results for the different algorithms (plain filename,
   // RFC5987/2231-encoded filename, + continuations) separately and decide
   // which to use at the end
-  char *caseAResult = NULL;
-  char *caseBResult = NULL;
-  char *caseCDResult = NULL;
+  char *caseAResult = nullptr;
+  char *caseBResult = nullptr;
+  char *caseCDResult = nullptr;
 
   // collect continuation segments
   nsTArray<Continuation> segments;
 
 
   // our copies of the charset parameter, kept separately as they might
   // differ for the two formats
   nsDependentCSubstring charsetB, charsetCD;
@@ -450,19 +450,19 @@ nsMIMEHeaderParamImpl::DoParameterIntern
   nsDependentCSubstring lang;
 
   int32_t paramLen = strlen(aParamName);
 
   while (*str) {
     // find name/value
 
     const char *nameStart = str;
-    const char *nameEnd = NULL;
+    const char *nameEnd = nullptr;
     const char *valueStart = str;
-    const char *valueEnd = NULL;
+    const char *valueEnd = nullptr;
     bool isQuotedString = false;
 
     NS_ASSERTION(!nsCRT::IsAsciiSpace(*str), "should be after whitespace.");
 
     // Skip forward to the end of this token. 
     for (; *str && !nsCRT::IsAsciiSpace(*str) && *str != '=' && *str != ';'; str++)
       ;
     nameEnd = str;
@@ -563,21 +563,21 @@ nsMIMEHeaderParamImpl::DoParameterIntern
         const char *sQuote2 = sQuote1 ? PL_strchr(sQuote1 + 1, 0x27) : nullptr;
 
         // Two single quotation marks must be present even in
         // absence of charset and lang. 
         if (!sQuote1 || !sQuote2) {
           NS_WARNING("Mandatory two single quotes are missing in header parameter\n");
         }
 
-        const char *charsetStart = NULL;
+        const char *charsetStart = nullptr;
         int32_t charsetLength = 0;
-        const char *langStart = NULL;
+        const char *langStart = nullptr;
         int32_t langLength = 0;
-        const char *rawValStart = NULL;
+        const char *rawValStart = nullptr;
         int32_t rawValLength = 0;
 
         if (sQuote2 && sQuote1) {
           // both delimiters present: charSet'lang'rawVal
           rawValStart = sQuote2 + 1;
           rawValLength = valueEnd - rawValStart;
 
           langStart = sQuote1 + 1;
@@ -672,41 +672,41 @@ increment_str:
   }
 
   caseCDResult = combineContinuations(segments);
 
   if (caseBResult && !charsetB.IsEmpty()) {
     // check that the 2231/5987 result decodes properly given the
     // specified character set
     if (!IsValidOctetSequenceForCharset(charsetB, caseBResult))
-      caseBResult = NULL;
+      caseBResult = nullptr;
   }
 
   if (caseCDResult && !charsetCD.IsEmpty()) {
     // check that the 2231/5987 result decodes properly given the
     // specified character set
     if (!IsValidOctetSequenceForCharset(charsetCD, caseCDResult))
-      caseCDResult = NULL;
+      caseCDResult = nullptr;
   }
 
   if (caseBResult) {
     // prefer simple 5987 format over 2231 with continuations
     *aResult = caseBResult;
-    caseBResult = NULL;
+    caseBResult = nullptr;
     charset.Assign(charsetB);
   }
   else if (caseCDResult) {
     // prefer 2231/5987 with or without continuations over plain format
     *aResult = caseCDResult;
-    caseCDResult = NULL;
+    caseCDResult = nullptr;
     charset.Assign(charsetCD);
   }
   else if (caseAResult) {
     *aResult = caseAResult;
-    caseAResult = NULL;
+    caseAResult = nullptr;
   }
 
   // free unused stuff
   nsMemory::Free(caseAResult);
   nsMemory::Free(caseBResult);
   nsMemory::Free(caseCDResult);
 
   // if we have a result
--- a/netwerk/protocol/device/AndroidCaptureProvider.cpp
+++ b/netwerk/protocol/device/AndroidCaptureProvider.cpp
@@ -252,23 +252,23 @@ NS_IMETHODIMP AndroidCameraInputStream::
 }
 
 /**
  * AndroidCaptureProvider implementation
  */
 
 NS_IMPL_ISUPPORTS0(AndroidCaptureProvider)
 
-AndroidCaptureProvider* AndroidCaptureProvider::sInstance = NULL;
+AndroidCaptureProvider* AndroidCaptureProvider::sInstance = nullptr;
 
 AndroidCaptureProvider::AndroidCaptureProvider() {
 }
 
 AndroidCaptureProvider::~AndroidCaptureProvider() {
-  AndroidCaptureProvider::sInstance = NULL;
+  AndroidCaptureProvider::sInstance = nullptr;
 }
 
 nsresult AndroidCaptureProvider::Init(nsACString& aContentType,
                         nsCaptureParams* aParams,
                         nsIInputStream** aStream) {
 
   NS_ENSURE_ARG_POINTER(aParams);
 
--- a/netwerk/protocol/device/CameraStreamImpl.cpp
+++ b/netwerk/protocol/device/CameraStreamImpl.cpp
@@ -23,18 +23,18 @@ Java_org_mozilla_gecko_GeckoAppShell_cam
     impl->transmitFrame(env, &data);
 }
 
 using namespace mozilla;
 
 namespace mozilla {
 namespace net {
 
-static CameraStreamImpl* mCamera0 = NULL;
-static CameraStreamImpl* mCamera1 = NULL;
+static CameraStreamImpl* mCamera0 = nullptr;
+static CameraStreamImpl* mCamera1 = nullptr;
 
 /**
  * CameraStreamImpl
  */
 
 void CameraStreamImpl::transmitFrame(JNIEnv *env, jbyteArray *data) {
     if (!mCallback)
       return;
@@ -43,17 +43,17 @@ void CameraStreamImpl::transmitFrame(JNI
     uint32_t length = env->GetArrayLength(*data);
     if (length > 0) {
         mCallback->ReceiveFrame((char*)jFrame, length);
     }
     env->ReleaseByteArrayElements(*data, jFrame, 0);
 }
 
 CameraStreamImpl* CameraStreamImpl::GetInstance(uint32_t aCamera) {
-    CameraStreamImpl* res = NULL;
+    CameraStreamImpl* res = nullptr;
     switch(aCamera) {
         case 0:
             if (mCamera0)
                 res = mCamera0;
             else
                 res = mCamera0 = new CameraStreamImpl(aCamera);
             break;
         case 1:
@@ -86,13 +86,13 @@ bool CameraStreamImpl::Init(const nsCStr
     mCallback = aCallback;
     mWidth = width;
     mHeight = height;
     return AndroidBridge::Bridge()->InitCamera(contentType, camera, &mWidth, &mHeight, &mFps);
 }
 
 void CameraStreamImpl::Close() {
     AndroidBridge::Bridge()->CloseCamera();
-    mCallback = NULL;
+    mCallback = nullptr;
 }
 
 } // namespace net
 } // namespace mozilla
--- a/netwerk/protocol/file/nsFileProtocolHandler.cpp
+++ b/netwerk/protocol/file/nsFileProtocolHandler.cpp
@@ -73,17 +73,17 @@ nsFileProtocolHandler::ReadURLFile(nsIFi
     if (!StringTail(path, 4).LowerCaseEqualsLiteral(".url"))
         return NS_ERROR_NOT_AVAILABLE;
 
     HRESULT result;
 
     rv = NS_ERROR_NOT_AVAILABLE;
 
     IUniformResourceLocatorW* urlLink = nullptr;
-    result = ::CoCreateInstance(CLSID_InternetShortcut, NULL, CLSCTX_INPROC_SERVER,
+    result = ::CoCreateInstance(CLSID_InternetShortcut, nullptr, CLSCTX_INPROC_SERVER,
                                 IID_IUniformResourceLocatorW, (void**)&urlLink);
     if (SUCCEEDED(result) && urlLink) {
         IPersistFile* urlFile = nullptr;
         result = urlLink->QueryInterface(IID_IPersistFile, (void**)&urlFile);
         if (SUCCEEDED(result) && urlFile) {
             result = urlFile->Load(path.get(), STGM_READ);
             if (SUCCEEDED(result) ) {
                 LPWSTR lpTemp = nullptr;
--- a/netwerk/protocol/http/SpdySession2.cpp
+++ b/netwerk/protocol/http/SpdySession2.cpp
@@ -719,17 +719,17 @@ SpdySession2::ConvertHeaders(nsDependent
       nsDependentCSubstring valueString =
         Substring(reinterpret_cast<const char *>(nvpair) + 4 + nameLen,
                   reinterpret_cast<const char *>(nvpair) + 4 + nameLen +
                   valueLen);
 
       mFlatHTTPResponseHeaders.Append(nameString);
       mFlatHTTPResponseHeaders.Append(NS_LITERAL_CSTRING(": "));
 
-      // expand NULL bytes in the value string
+      // expand nullptr bytes in the value string
       for (char *cPtr = valueString.BeginWriting();
            cPtr && cPtr < valueString.EndWriting();
            ++cPtr) {
         if (*cPtr != 0) {
           mFlatHTTPResponseHeaders.Append(*cPtr);
           continue;
         }
 
@@ -2213,17 +2213,17 @@ SpdySession2::Available()
 
 nsHttpRequestHead *
 SpdySession2::RequestHead()
 {
   MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
   MOZ_ASSERT(false,
              "SpdySession2::RequestHead() "
              "should not be called after SPDY is setup");
-  return NULL;
+  return nullptr;
 }
 
 uint32_t
 SpdySession2::Http1xTransactionCount()
 {
   return 0;
 }
 
--- a/netwerk/protocol/http/SpdySession3.cpp
+++ b/netwerk/protocol/http/SpdySession3.cpp
@@ -2601,17 +2601,17 @@ SpdySession3::Available()
 
 nsHttpRequestHead *
 SpdySession3::RequestHead()
 {
   MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
   MOZ_ASSERT(false,
              "SpdySession3::RequestHead() "
              "should not be called after SPDY is setup");
-  return NULL;
+  return nullptr;
 }
 
 uint32_t
 SpdySession3::Http1xTransactionCount()
 {
   return 0;
 }
 
--- a/netwerk/protocol/http/SpdyStream3.cpp
+++ b/netwerk/protocol/http/SpdyStream3.cpp
@@ -1213,17 +1213,17 @@ SpdyStream3::ConvertHeaders(nsACString &
         nsDependentCSubstring valueString =
           Substring(reinterpret_cast<const char *>(nvpair) + 8 + nameLen,
                     reinterpret_cast<const char *>(nvpair) + 8 + nameLen +
                     valueLen);
 
         aHeadersOut.Append(nameString);
         aHeadersOut.Append(NS_LITERAL_CSTRING(": "));
 
-        // expand NULL bytes in the value string
+        // expand nullptr bytes in the value string
         for (char *cPtr = valueString.BeginWriting();
              cPtr && cPtr < valueString.EndWriting();
              ++cPtr) {
           if (*cPtr != 0) {
             aHeadersOut.Append(*cPtr);
             continue;
           }
 
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -1200,17 +1200,17 @@ nsHttpChannel::ProcessSTSHeader()
     if (rv == NS_ERROR_NOT_AVAILABLE) {
         LOG(("STS: No STS header, continuing load.\n"));
         return NS_OK;
     }
     // All other failures are fatal.
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = sss->ProcessHeader(nsISiteSecurityService::HEADER_HSTS, mURI,
-                            stsHeader.get(), flags, NULL, NULL);
+                            stsHeader.get(), flags, nullptr, nullptr);
     if (NS_FAILED(rv)) {
         AddSecurityMessage(NS_LITERAL_STRING("InvalidSTSHeaders"),
                 NS_LITERAL_STRING("Invalid HSTS Headers"));
         LOG(("STS: Failed to parse STS header, continuing load.\n"));
     }
 
     return NS_OK;
 }
@@ -1630,17 +1630,17 @@ nsHttpChannel::PromptTempRedirect()
     if (NS_FAILED(rv)) return rv;
 
     nsCOMPtr<nsIStringBundle> stringBundle;
     rv = bundleService->CreateBundle(NECKO_MSGS_URL, getter_AddRefs(stringBundle));
     if (NS_FAILED(rv)) return rv;
 
     nsXPIDLString messageString;
     rv = stringBundle->GetStringFromName(NS_LITERAL_STRING("RepostFormData").get(), getter_Copies(messageString));
-    // GetStringFromName can return NS_OK and NULL messageString.
+    // GetStringFromName can return NS_OK and nullptr messageString.
     if (NS_SUCCEEDED(rv) && messageString) {
         bool repost = false;
 
         nsCOMPtr<nsIPrompt> prompt;
         GetCallback(prompt);
         if (!prompt)
             return NS_ERROR_NO_INTERFACE;
 
--- a/netwerk/protocol/http/nsHttpConnectionMgr.cpp
+++ b/netwerk/protocol/http/nsHttpConnectionMgr.cpp
@@ -206,17 +206,17 @@ nsHttpConnectionMgr::ConditionallyStopPr
         return;
 
     LOG(("nsHttpConnectionMgr::StopPruneDeadConnectionsTimer\n"));
 
     // Reset mTimeOfNextWakeUp so that we can find a new shortest value.
     mTimeOfNextWakeUp = UINT64_MAX;
     if (mTimer) {
         mTimer->Cancel();
-        mTimer = NULL;
+        mTimer = nullptr;
     }
 }
 
 void
 nsHttpConnectionMgr::ConditionallyStopTimeoutTick()
 {
     LOG(("nsHttpConnectionMgr::ConditionallyStopTimeoutTick "
          "armed=%d active=%d\n", mTimeoutTickArmed, mNumActiveConns));
--- a/netwerk/protocol/websocket/WebSocketChannel.h
+++ b/netwerk/protocol/websocket/WebSocketChannel.h
@@ -113,17 +113,17 @@ private:
   friend class FailDelayManager;
   friend class CallOnMessageAvailable;
   friend class CallOnStop;
   friend class CallOnServerClose;
   friend class CallAcknowledge;
 
   // Common send code for binary + text msgs
   nsresult SendMsgCommon(const nsACString *aMsg, bool isBinary,
-                         uint32_t length, nsIInputStream *aStream = NULL);
+                         uint32_t length, nsIInputStream *aStream = nullptr);
 
   void EnqueueOutgoingMessage(nsDeque &aQueue, OutboundMessage *aMsg);
 
   void PrimeNewOutgoingMessage();
   void DeleteCurrentOutGoingMessage();
   void GeneratePong(uint8_t *payload, uint32_t len);
   void GeneratePing();
 
--- a/netwerk/socket/nsSOCKSIOLayer.cpp
+++ b/netwerk/socket/nsSOCKSIOLayer.cpp
@@ -876,28 +876,28 @@ nsSOCKSSocketInfo::WriteUint32(uint32_t 
                       "Can't write that much data!");
     memcpy(mData + mDataLength, &v, sizeof(v));
     mDataLength += sizeof(v);
 }
 
 void
 nsSOCKSSocketInfo::WriteNetAddr(const NetAddr *addr)
 {
-    const char *ip = NULL;
+    const char *ip = nullptr;
     uint32_t len = 0;
 
     if (addr->raw.family == AF_INET) {
         ip = (const char*)&addr->inet.ip;
         len = sizeof(addr->inet.ip);
     } else if (addr->raw.family == AF_INET6) {
         ip = (const char*)addr->inet6.ip.u8;
         len = sizeof(addr->inet6.ip.u8);
     }
 
-    NS_ABORT_IF_FALSE(ip != NULL, "Unknown address");
+    NS_ABORT_IF_FALSE(ip != nullptr, "Unknown address");
     NS_ABORT_IF_FALSE(mDataLength + len <= BUFFER_SIZE,
                       "Can't write that much data!");
  
     memcpy(mData + mDataLength, ip, len);
     mDataLength += len;
 }
 
 void
@@ -974,17 +974,17 @@ void
 nsSOCKSSocketInfo::ReadNetPort(NetAddr *addr)
 {
     addr->inet.port = ReadUint16();
 }
 
 void
 nsSOCKSSocketInfo::WantRead(uint32_t sz)
 {
-    NS_ABORT_IF_FALSE(mDataIoPtr == NULL,
+    NS_ABORT_IF_FALSE(mDataIoPtr == nullptr,
                       "WantRead() called while I/O already in progress!");
     NS_ABORT_IF_FALSE(mDataLength + sz <= BUFFER_SIZE,
                       "Can't read that much data!");
     mAmountToRead = sz;
 }
 
 PRStatus
 nsSOCKSSocketInfo::ReadFromSocket(PRFileDesc *fd)
@@ -1072,17 +1072,17 @@ nsSOCKSSocketInfo::WriteToSocket(PRFileD
 
 static PRStatus
 nsSOCKSIOLayerConnect(PRFileDesc *fd, const PRNetAddr *addr, PRIntervalTime to)
 {
     PRStatus status;
     NetAddr dst;
 
     nsSOCKSSocketInfo * info = (nsSOCKSSocketInfo*) fd->secret;
-    if (info == NULL) return PR_FAILURE;
+    if (info == nullptr) return PR_FAILURE;
 
     if (addr->raw.family == PR_AF_INET6 &&
         PR_IsNetAddrType(addr, PR_IpAddrV4Mapped)) {
         const uint8_t *srcp;
 
         LOGDEBUG(("socks: converting ipv4-mapped ipv6 address to ipv4"));
 
         // copied from _PR_ConvertToIpv4NetAddr()
@@ -1108,30 +1108,30 @@ nsSOCKSIOLayerConnect(PRFileDesc *fd, co
 }
 
 static PRStatus
 nsSOCKSIOLayerConnectContinue(PRFileDesc *fd, int16_t oflags)
 {
     PRStatus status;
 
     nsSOCKSSocketInfo * info = (nsSOCKSSocketInfo*) fd->secret;
-    if (info == NULL) return PR_FAILURE;
+    if (info == nullptr) return PR_FAILURE;
 
     do { 
         status = info->DoHandshake(fd, oflags);
     } while (status == PR_SUCCESS && !info->IsConnected());
 
     return status;
 }
 
 static int16_t
 nsSOCKSIOLayerPoll(PRFileDesc *fd, int16_t in_flags, int16_t *out_flags)
 {
     nsSOCKSSocketInfo * info = (nsSOCKSSocketInfo*) fd->secret;
-    if (info == NULL) return PR_FAILURE;
+    if (info == nullptr) return PR_FAILURE;
 
     if (!info->IsConnected()) {
         *out_flags = 0;
         return info->GetPollFlags();
     }
 
     return fd->lower->methods->poll(fd->lower, in_flags, out_flags);
 }
@@ -1173,34 +1173,34 @@ nsSOCKSIOLayerBind(PRFileDesc *fd, const
     return fd->lower->methods->bind(fd->lower, addr);
 }
 
 static PRStatus
 nsSOCKSIOLayerGetName(PRFileDesc *fd, PRNetAddr *addr)
 {
     nsSOCKSSocketInfo * info = (nsSOCKSSocketInfo*) fd->secret;
     
-    if (info != NULL && addr != NULL) {
+    if (info != nullptr && addr != nullptr) {
         NetAddr temp;
         NetAddr *tempPtr = &temp;
         if (info->GetExternalProxyAddr(&tempPtr) == NS_OK) {
             NetAddrToPRNetAddr(tempPtr, addr);
             return PR_SUCCESS;
         }
     }
 
     return PR_FAILURE;
 }
 
 static PRStatus
 nsSOCKSIOLayerGetPeerName(PRFileDesc *fd, PRNetAddr *addr)
 {
     nsSOCKSSocketInfo * info = (nsSOCKSSocketInfo*) fd->secret;
 
-    if (info != NULL && addr != NULL) {
+    if (info != nullptr && addr != nullptr) {
         NetAddr temp;
         NetAddr *tempPtr = &temp;
         if (info->GetDestinationAddr(&tempPtr) == NS_OK) {
             NetAddrToPRNetAddr(tempPtr, addr);
             return PR_SUCCESS;
         }
     }
 
--- a/netwerk/streamconv/converters/nsDirIndexParser.cpp
+++ b/netwerk/streamconv/converters/nsDirIndexParser.cpp
@@ -166,17 +166,17 @@ nsDirIndexParser::ParseFormat(const char
 
     while (*pos && !nsCRT::IsAsciiSpace(PRUnichar(*pos)))
       ++pos;
 
   } while (*pos);
 
   delete[] mFormat;
   mFormat = new int[num+1];
-  // Prevent NULL Deref - Bug 443299 
+  // Prevent nullptr Deref - Bug 443299 
   if (mFormat == nullptr)
     return NS_ERROR_OUT_OF_MEMORY;
   mFormat[num] = -1;
   
   int formatNum=0;
   do {
     while (*aFormatStr && nsCRT::IsAsciiSpace(PRUnichar(*aFormatStr)))
       ++aFormatStr;
--- a/netwerk/streamconv/converters/nsHTTPCompressConv.cpp
+++ b/netwerk/streamconv/converters/nsHTTPCompressConv.cpp
@@ -21,18 +21,18 @@ NS_IMPL_ISUPPORTS3(nsHTTPCompressConv,
                    nsIStreamConverter,
                    nsIStreamListener,
                    nsIRequestObserver)
 
 // nsFTPDirListingConv methods
 nsHTTPCompressConv::nsHTTPCompressConv()
     : mListener(nullptr)
     , mMode(HTTP_COMPRESS_IDENTITY)
-    , mOutBuffer(NULL)
-    , mInpBuffer(NULL)
+    , mOutBuffer(nullptr)
+    , mInpBuffer(nullptr)
     , mOutBufferLen(0)
     , mInpBufferLen(0)
     , mCheckHeaderDone(false)
     , mStreamEnded(false)
     , mStreamInitialized(false)
     , mLen(0)
     , hMode(0)
     , mSkipCount(0)
@@ -129,34 +129,34 @@ nsHTTPCompressConv::OnDataAvailable(nsIR
 
             if (streamLen == 0)
                 return NS_OK;
 
             // FALLTHROUGH
 
         case HTTP_COMPRESS_DEFLATE:
 
-            if (mInpBuffer != NULL && streamLen > mInpBufferLen)
+            if (mInpBuffer != nullptr && streamLen > mInpBufferLen)
             {
                 mInpBuffer = (unsigned char *) nsMemory::Realloc(mInpBuffer, mInpBufferLen = streamLen);
                
                 if (mOutBufferLen < streamLen * 2)
                     mOutBuffer = (unsigned char *) nsMemory::Realloc(mOutBuffer, mOutBufferLen = streamLen * 3);
 
-                if (mInpBuffer == NULL || mOutBuffer == NULL)
+                if (mInpBuffer == nullptr || mOutBuffer == nullptr)
                     return NS_ERROR_OUT_OF_MEMORY;
             }
 
-            if (mInpBuffer == NULL)
+            if (mInpBuffer == nullptr)
                 mInpBuffer = (unsigned char *) nsMemory::Alloc(mInpBufferLen = streamLen);
 
-            if (mOutBuffer == NULL)
+            if (mOutBuffer == nullptr)
                 mOutBuffer = (unsigned char *) nsMemory::Alloc(mOutBufferLen = streamLen * 3);
 
-            if (mInpBuffer == NULL || mOutBuffer == NULL)
+            if (mInpBuffer == nullptr || mOutBuffer == nullptr)
                 return NS_ERROR_OUT_OF_MEMORY;
 
             uint32_t unused;
             iStr->Read((char *)mInpBuffer, streamLen, &unused);
 
             if (mMode == HTTP_COMPRESS_DEFLATE)
             {
                 if (!mStreamInitialized)
--- a/netwerk/streamconv/converters/nsMultiMixedConv.cpp
+++ b/netwerk/streamconv/converters/nsMultiMixedConv.cpp
@@ -444,17 +444,17 @@ nsMultiMixedConv::AsyncConvertData(const
     mFinalListener = aListener;
     return NS_OK;
 }
 
 // AutoFree implementation to prevent memory leaks
 class AutoFree
 {
 public:
-  AutoFree() : mBuffer(NULL) {}
+  AutoFree() : mBuffer(nullptr) {}
 
   AutoFree(char *buffer) : mBuffer(buffer) {}
 
   ~AutoFree() {
     free(mBuffer);
   }
 
   AutoFree& operator=(char *buffer) {
--- a/netwerk/streamconv/test/TestStreamConv.cpp
+++ b/netwerk/streamconv/test/TestStreamConv.cpp
@@ -127,40 +127,40 @@ nsresult SendData(const char * aData, ns
         offset += count;
         avail -= count;
     }
     return NS_OK;
 }
 #define SEND_DATA(x) SendData(x, converterListener, request)
 
 static const mozilla::Module::CIDEntry kTestCIDs[] = {
-    { &kTestConverterCID, false, NULL, CreateTestConverter },
-    { NULL }
+    { &kTestConverterCID, false, nullptr, CreateTestConverter },
+    { nullptr }
 };
 
 static const mozilla::Module::ContractIDEntry kTestContracts[] = {
     { NS_ISTREAMCONVERTER_KEY "?from=a/foo&to=b/foo", &kTestConverterCID },
     { NS_ISTREAMCONVERTER_KEY "?from=b/foo&to=c/foo", &kTestConverterCID },
     { NS_ISTREAMCONVERTER_KEY "?from=b/foo&to=d/foo", &kTestConverterCID },
     { NS_ISTREAMCONVERTER_KEY "?from=c/foo&to=d/foo", &kTestConverterCID },
     { NS_ISTREAMCONVERTER_KEY "?from=d/foo&to=e/foo", &kTestConverterCID },
     { NS_ISTREAMCONVERTER_KEY "?from=d/foo&to=f/foo", &kTestConverterCID },
     { NS_ISTREAMCONVERTER_KEY "?from=t/foo&to=k/foo", &kTestConverterCID },
-    { NULL }
+    { nullptr }
 };
 
 static const mozilla::Module::CategoryEntry kTestCategories[] = {
     { NS_ISTREAMCONVERTER_KEY, "?from=a/foo&to=b/foo", "x" },
     { NS_ISTREAMCONVERTER_KEY, "?from=b/foo&to=c/foo", "x" },
     { NS_ISTREAMCONVERTER_KEY, "?from=b/foo&to=d/foo", "x" },
     { NS_ISTREAMCONVERTER_KEY, "?from=c/foo&to=d/foo", "x" },
     { NS_ISTREAMCONVERTER_KEY, "?from=d/foo&to=e/foo", "x" },
     { NS_ISTREAMCONVERTER_KEY, "?from=d/foo&to=f/foo", "x" },
     { NS_ISTREAMCONVERTER_KEY, "?from=t/foo&to=k/foo", "x" },
-    { NULL }
+    { nullptr }
 };
 
 static const mozilla::Module kTestModule = {
     mozilla::Module::kVersion,
     kTestCIDs,
     kTestContracts,
     kTestCategories
 };
--- a/netwerk/system/win32/nsNotifyAddrListener.cpp
+++ b/netwerk/system/win32/nsNotifyAddrListener.cpp
@@ -150,17 +150,17 @@ nsNotifyAddrListener::Init(void)
         mozilla::services::GetObserverService();
     if (!observerService)
         return NS_ERROR_FAILURE;
 
     nsresult rv = observerService->AddObserver(this, "xpcom-shutdown-threads",
                                                false);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    mShutdownEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+    mShutdownEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
     NS_ENSURE_TRUE(mShutdownEvent, NS_ERROR_OUT_OF_MEMORY);
 
     rv = NS_NewThread(getter_AddRefs(mThread), this);
     NS_ENSURE_SUCCESS(rv, rv);
 
     return NS_OK;
 }
 
@@ -181,17 +181,17 @@ nsNotifyAddrListener::Shutdown(void)
     nsresult rv = mThread->Shutdown();
 
     // Have to break the cycle here, otherwise nsNotifyAddrListener holds
     // onto the thread and the thread holds onto the nsNotifyAddrListener
     // via its mRunnable
     mThread = nullptr;
 
     CloseHandle(mShutdownEvent);
-    mShutdownEvent = NULL;
+    mShutdownEvent = nullptr;
 
     return rv;
 }
 
 /* Sends the given event to the UI thread.  Assumes aEventID never goes out
  * of scope (static strings are ideal).
  */
 nsresult
@@ -251,17 +251,17 @@ nsNotifyAddrListener::CheckICSStatus(PWC
     // of them has the same name as the one provided in aAdapterName. If such
     // connection is found in the collection the adapter is used as ICS gateway
     bool isICSGatewayAdapter = false;
 
     HRESULT hr;
     nsRefPtr<INetSharingManager> netSharingManager;
     hr = CoCreateInstance(
                 CLSID_NetSharingManager,
-                NULL,
+                nullptr,
                 CLSCTX_INPROC_SERVER,
                 IID_INetSharingManager,
                 getter_AddRefs(netSharingManager));
 
     nsRefPtr<INetSharingPrivateConnectionCollection> privateCollection;
     if (SUCCEEDED(hr)) {
         hr = netSharingManager->get_EnumPrivateConnections(
                     ICSSC_DEFAULT,
@@ -321,26 +321,26 @@ DWORD
 nsNotifyAddrListener::CheckAdaptersAddresses(void)
 {
     ULONG len = 16384;
 
     PIP_ADAPTER_ADDRESSES addresses = (PIP_ADAPTER_ADDRESSES) malloc(len);
     if (!addresses)
         return ERROR_OUTOFMEMORY;
 
-    DWORD ret = GetAdaptersAddresses(AF_UNSPEC, 0, NULL, addresses, &len);
+    DWORD ret = GetAdaptersAddresses(AF_UNSPEC, 0, nullptr, addresses, &len);
     if (ret == ERROR_BUFFER_OVERFLOW) {
         free(addresses);
         addresses = (PIP_ADAPTER_ADDRESSES) malloc(len);
         if (!addresses)
             return ERROR_BUFFER_OVERFLOW;
-        ret = GetAdaptersAddresses(AF_UNSPEC, 0, NULL, addresses, &len);
+        ret = GetAdaptersAddresses(AF_UNSPEC, 0, nullptr, addresses, &len);
     }
 
-    if (FAILED(CoInitializeEx(NULL, COINIT_MULTITHREADED))) {
+    if (FAILED(CoInitializeEx(nullptr, COINIT_MULTITHREADED))) {
         free(addresses);
         return ERROR_NOT_SUPPORTED;
     }
 
     if (ret == ERROR_SUCCESS) {
         PIP_ADAPTER_ADDRESSES ptr;
         bool linkUp = false;
 
--- a/netwerk/test/ReadNTLM.cpp
+++ b/netwerk/test/ReadNTLM.cpp
@@ -276,17 +276,17 @@ ReadType3MsgBody(const uint8_t *inBuf, u
   uint32_t flags = ReadUint32(cursor);
   PrintBuf("flags", (const uint8_t *) &flags, sizeof(flags));
   PrintFlags(flags);
 }
 
 static void
 ReadMsg(const char *base64buf, uint32_t bufLen)
 {
-  uint8_t *inBuf = (uint8_t *) PL_Base64Decode(base64buf, bufLen, NULL);
+  uint8_t *inBuf = (uint8_t *) PL_Base64Decode(base64buf, bufLen, nullptr);
   if (!inBuf)
   {
     printf("PL_Base64Decode failed\n");
     return;
   }
 
   const uint8_t *cursor = inBuf;
 
--- a/netwerk/test/TestPageLoad.cpp
+++ b/netwerk/test/TestPageLoad.cpp
@@ -69,49 +69,49 @@ static NS_METHOD streamParse (nsIInputSt
 
   while(i < (int)count) {
     i = getStrLine(tmp, lineBuf, i, count);
     if(i < 0) {
       *writeCount = count;
       return NS_OK;
     }
     parseBuf[0]='\0';
-    if((loc_t=PL_strcasestr(lineBuf, "img"))!= NULL 
-       || (loc_t=PL_strcasestr(lineBuf, "script"))!=NULL) {
+    if((loc_t=PL_strcasestr(lineBuf, "img"))!= nullptr 
+       || (loc_t=PL_strcasestr(lineBuf, "script"))!=nullptr) {
       loc_t2=PL_strcasestr(loc_t, "src");
-      if(loc_t2!=NULL) {
+      if(loc_t2!=nullptr) {
         loc_t2+=3;
         strcpy(loc, loc_t2);
         sscanf(loc, "=\"%[^\"]", parseBuf);
         if(parseBuf[0]=='\0')
           sscanf(loc, "=%s", parseBuf);         
         if(parseBuf[0]!='\0'){
           numFound++;
           auxLoad(parseBuf);
         }     
       }
     }
 
     /***NEED BETTER CHECK FOR STYLESHEETS
-    if((loc_t=PL_strcasestr(lineBuf, "link"))!= NULL) { 
+    if((loc_t=PL_strcasestr(lineBuf, "link"))!= nullptr) { 
        loc_t2=PL_strcasestr(loc_t, "href");
-      if(loc_t2!=NULL) {
+      if(loc_t2!=nullptr) {
         loc_t2+=4;
         strcpy(loc, loc_t2);
         //printf("%s\n", loc);
         sscanf(loc, "=\"%[^\"]", parseBuf);
         if(parseBuf[0]!='\0'){
           //printf("%s\n", parseBuf);
           numFound++;
           auxLoad(parseBuf);
         }     
       }
     }
     */
-    if((loc_t=PL_strcasestr(lineBuf, "background"))!=NULL) {
+    if((loc_t=PL_strcasestr(lineBuf, "background"))!=nullptr) {
       loc_t+=10;
       strcpy(loc, loc_t);
       sscanf(loc, "=\"%[^\"]", parseBuf);
       if(parseBuf[0]!='\0') {
         numFound++;
         auxLoad(parseBuf);
       }
     }
--- a/netwerk/test/TestSTSParser.cpp
+++ b/netwerk/test/TestSTSParser.cpp
@@ -64,17 +64,17 @@ TestSuccess(const char* hdr, bool extraT
 bool TestFailure(const char* hdr,
                  nsISiteSecurityService* sss)
 {
   nsCOMPtr<nsIURI> dummyUri;
   nsresult rv = NS_NewURI(getter_AddRefs(dummyUri), "https://foo.com/bar.html");
   EXPECT_SUCCESS(rv, "Failed to create URI");
 
   rv = sss->ProcessHeader(nsISiteSecurityService::HEADER_HSTS, dummyUri, hdr,
-                          0, NULL, NULL);
+                          0, nullptr, nullptr);
   EXPECT_FAILURE(rv, "Parsed invalid header: %s", hdr);
   passed(hdr);
   return true;
 }
 
 
 int
 main(int32_t argc, char *argv[])
--- a/netwerk/test/TestWriteSpeed.cpp
+++ b/netwerk/test/TestWriteSpeed.cpp
@@ -31,17 +31,17 @@ NS_MeanAndStdDev(double n, double sumOfV
 int
 Test(const char* filename, int32_t minSize, int32_t maxSize, 
      int32_t sizeIncrement, int32_t iterations)
 {
     fprintf(stdout, "      size  write:    mean     stddev      iters  total:    mean     stddev      iters\n");
     for (int32_t size = minSize; size <= maxSize; size += sizeIncrement) {
         // create a buffer of stuff to write
         char* buf = (char*)PR_Malloc(size);
-        if (buf == NULL)
+        if (buf == nullptr)
             return -1;
 
         // initialize it with a pattern
         int32_t i;
         char hex[] = "0123456789ABCDEF";
         for (i = 0; i < size; i++) {
             buf[i] = hex[i & 0xF];
         }
@@ -49,17 +49,17 @@ Test(const char* filename, int32_t minSi
         double writeCount = 0, writeRate = 0, writeRateSquared = 0;
         double totalCount = 0, totalRate = 0, totalRateSquared = 0;
         for (i = 0; i < iterations; i++) {
             PRIntervalTime start = PR_IntervalNow();
 
             char name[1024];
             sprintf(name, "%s_%d", filename, i);
             PRFileDesc* fd = PR_Open(name, PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE, 0664);
-            if (fd == NULL)
+            if (fd == nullptr)
                 return -1;
 
             PRIntervalTime writeStart = PR_IntervalNow();
             int32_t rv = PR_Write(fd, buf, size);
             if (rv < 0) return rv;
             if (rv != size) return -1;
             PRIntervalTime writeStop = PR_IntervalNow();
 
--- a/netwerk/wifi/nsWifiScannerSolaris.cpp
+++ b/netwerk/wifi/nsWifiScannerSolaris.cpp
@@ -53,25 +53,25 @@ do_parse_str(char *bssid_str, char *essi
     ap->setSSID(essid_str, PL_strnlen(essid_str, DLADM_STRSIZE));
   }
   return ap;
 }
 
 static void
 do_dladm(nsCOMArray<nsWifiAccessPoint> &accessPoints)
 {
-  GError *err = NULL;
-  char *sout = NULL;
-  char *serr = NULL;
+  GError *err = nullptr;
+  char *sout = nullptr;
+  char *serr = nullptr;
   int exit_status = 0;
   char * dladm_args[] = { "/usr/bin/pfexec", "/usr/sbin/dladm",
                           "scan-wifi", "-p", "-o", "BSSID,ESSID,STRENGTH" };
 
-  gboolean rv = g_spawn_sync("/", dladm_args, NULL, (GSpawnFlags)0, NULL, NULL,
-                             &sout, &serr, &exit_status, &err);
+  gboolean rv = g_spawn_sync("/", dladm_args, nullptr, (GSpawnFlags)0, nullptr,
+                             nullptr, &sout, &serr, &exit_status, &err);
   if (rv && !exit_status) {
     char wlan[DLADM_SECTIONS][DLADM_STRSIZE+1];
     uint32_t section = 0;
     uint32_t sout_scan = 0;
     uint32_t wlan_put = 0;
     bool escape = false;
     nsWifiAccessPoint* ap;
     char sout_char;
--- a/netwerk/wifi/nsWifiScannerWin.cpp
+++ b/netwerk/wifi/nsWifiScannerWin.cpp
@@ -42,50 +42,50 @@ nsWifiMonitor::DoScan()
     nsCOMArray<nsWifiAccessPoint> lastAccessPoints;
     nsCOMArray<nsWifiAccessPoint> accessPoints;
 
     do {
       accessPoints.Clear();
 
       // Get the handle to the WLAN API.
       DWORD negotiated_version;
-      HANDLE wlan_handle = NULL;
+      HANDLE wlan_handle = nullptr;
       // We could be executing on either Windows XP or Windows Vista, so use the
       // lower version of the client WLAN API. It seems that the negotiated version
       // is the Vista version irrespective of what we pass!
       static const int kXpWlanClientVersion = 1;
       if ((*WlanOpenHandle)(kXpWlanClientVersion,
-                            NULL,
+                            nullptr,
                             &negotiated_version,
                             &wlan_handle) != ERROR_SUCCESS) {
         return NS_ERROR_NOT_AVAILABLE;
       }
 
       // try again later.
       if (!wlan_handle)
         return NS_ERROR_FAILURE;
 
       // Get the list of interfaces. WlanEnumInterfaces allocates interface_list.
-      WLAN_INTERFACE_INFO_LIST *interface_list = NULL;
-      if ((*WlanEnumInterfaces)(wlan_handle, NULL, &interface_list) != ERROR_SUCCESS) {
+      WLAN_INTERFACE_INFO_LIST *interface_list = nullptr;
+      if ((*WlanEnumInterfaces)(wlan_handle, nullptr, &interface_list) != ERROR_SUCCESS) {
         // try again later
-        (*WlanCloseHandle)(wlan_handle, NULL);
+        (*WlanCloseHandle)(wlan_handle, nullptr);
         return NS_ERROR_FAILURE;
       }
 
       // Go through the list of interfaces and get the data for each.
       for (int i = 0; i < static_cast<int>(interface_list->dwNumberOfItems); ++i) {
 
         WLAN_BSS_LIST *bss_list;
         HRESULT rv = (*WlanGetNetworkBssList)(wlan_handle,
                                               &interface_list->InterfaceInfo[i].InterfaceGuid,
-                                              NULL,   // Use all SSIDs.
+                                              nullptr,  // Use all SSIDs.
                                               DOT11_BSS_TYPE_UNUSED,
-                                              false,  // bSecurityEnabled - unused
-                                              NULL,   // reserved
+                                              false,    // bSecurityEnabled - unused
+                                              nullptr,  // reserved
                                               &bss_list);
         if (rv != ERROR_SUCCESS) {
           continue;
         }
 
         for (int j = 0; j < static_cast<int>(bss_list->dwNumberOfItems); ++j) {
 
           nsWifiAccessPoint* ap = new nsWifiAccessPoint();
@@ -103,17 +103,17 @@ nsWifiMonitor::DoScan()
         }
         (*WlanFreeMemory)(bss_list);
       }
 
       // Free interface_list.
       (*WlanFreeMemory)(interface_list);
 
       // Close the handle.
-      (*WlanCloseHandle)(wlan_handle, NULL);
+      (*WlanCloseHandle)(wlan_handle, nullptr);
 
 
       bool accessPointsChanged = !AccessPointsEqual(accessPoints, lastAccessPoints);
       ReplaceArray(lastAccessPoints, accessPoints);
 
       nsresult rv = CallWifiListeners(lastAccessPoints, accessPointsChanged);
       NS_ENSURE_SUCCESS(rv, rv);