Bug 1197311 - Remove PR_snprintf calls in dom/ r=froydnj
authorsakshi <sakshivaid95@mozilla.com>
Wed, 17 Feb 2016 14:23:39 -0500
changeset 325079 deadb414ee23f17f25b5adb90e0caa497263b7bd
parent 325078 c8261cc6c396e27feba3efcb50bac20dc684c232
child 325080 3f727688f71fd533436fb1dfb0c4184ada04ae50
push id1128
push userjlund@mozilla.com
push dateWed, 01 Jun 2016 01:31:59 +0000
treeherdermozilla-release@fe0d30de989d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1197311
milestone47.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 1197311 - Remove PR_snprintf calls in dom/ r=froydnj
dom/base/FragmentOrElement.cpp
dom/base/NodeInfo.cpp
dom/base/nsDocument.cpp
dom/base/nsGenericDOMDataNode.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsXMLContentSerializer.cpp
dom/bindings/BindingUtils.cpp
dom/events/DOMEventTargetHelper.cpp
dom/media/MediaManager.cpp
dom/media/mediasource/MediaSource.cpp
dom/media/mediasource/ResourceQueue.cpp
dom/media/webm/WebMDemuxer.cpp
dom/media/webrtc/RTCCertificate.cpp
dom/plugins/base/nsPluginHost.cpp
dom/system/gonk/NetworkUtils.cpp
dom/wifi/WifiUtils.cpp
--- a/dom/base/FragmentOrElement.cpp
+++ b/dom/base/FragmentOrElement.cpp
@@ -107,17 +107,17 @@
 #ifdef MOZ_XUL
 #include "nsIXULDocument.h"
 #endif /* MOZ_XUL */
 
 #include "nsCCUncollectableMarker.h"
 
 #include "mozAutoDocUpdate.h"
 
-#include "prprf.h"
+#include "mozilla/Snprintf.h"
 #include "nsDOMMutationObserver.h"
 #include "nsWrapperCacheInlines.h"
 #include "nsCycleCollector.h"
 #include "xpcpublic.h"
 #include "nsIScriptError.h"
 #include "mozilla/Telemetry.h"
 
 #include "mozilla/CORSMode.h"
@@ -1878,23 +1878,23 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
     if (!tmp->IsInDoc() &&
         // Ignore xbl:content, which is never in the document and hence always
         // appears to be orphaned.
         !tmp->NodeInfo()->Equals(nsGkAtoms::content, kNameSpaceID_XBL)) {
       orphan.AppendLiteral(" (orphan)");
     }
 
     const char* nsuri = nsid < ArrayLength(kNSURIs) ? kNSURIs[nsid] : "";
-    PR_snprintf(name, sizeof(name), "FragmentOrElement%s %s%s%s%s %s",
-                nsuri,
-                localName.get(),
-                NS_ConvertUTF16toUTF8(id).get(),
-                NS_ConvertUTF16toUTF8(classes).get(),
-                orphan.get(),
-                uri.get());
+    snprintf_literal(name, "FragmentOrElement%s %s%s%s%s %s",
+                     nsuri,
+                     localName.get(),
+                     NS_ConvertUTF16toUTF8(id).get(),
+                     NS_ConvertUTF16toUTF8(classes).get(),
+                     orphan.get(),
+                     uri.get());
     cb.DescribeRefCountedNode(tmp->mRefCnt.get(), name);
   }
   else {
     NS_IMPL_CYCLE_COLLECTION_DESCRIBE(FragmentOrElement, tmp->mRefCnt.get())
   }
 
   // Always need to traverse script objects, so do that before we check
   // if we're uncollectable.
--- a/dom/base/NodeInfo.cpp
+++ b/dom/base/NodeInfo.cpp
@@ -20,17 +20,17 @@
 #include "nsCOMPtr.h"
 #include "nsString.h"
 #include "nsIAtom.h"
 #include "nsDOMString.h"
 #include "nsCRT.h"
 #include "nsContentUtils.h"
 #include "nsReadableUtils.h"
 #include "nsAutoPtr.h"
-#include "prprf.h"
+#include "mozilla/Snprintf.h"
 #include "nsIDocument.h"
 #include "nsGkAtoms.h"
 #include "nsCCUncollectableMarker.h"
 #include "nsNameSpaceManager.h"
 
 using namespace mozilla;
 using mozilla::dom::NodeInfo;
 
@@ -125,21 +125,21 @@ static const char* kNodeInfoNSURIs[] = {
 };
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(NodeInfo)
   if (MOZ_UNLIKELY(cb.WantDebugInfo())) {
     char name[72];
     uint32_t nsid = tmp->NamespaceID();
     nsAtomCString localName(tmp->NameAtom());
     if (nsid < ArrayLength(kNodeInfoNSURIs)) {
-      PR_snprintf(name, sizeof(name), "NodeInfo%s %s", kNodeInfoNSURIs[nsid],
-                  localName.get());
+      snprintf_literal(name, "NodeInfo%s %s", kNodeInfoNSURIs[nsid],
+                       localName.get());
     }
     else {
-      PR_snprintf(name, sizeof(name), "NodeInfo %s", localName.get());
+      snprintf_literal(name, "NodeInfo %s", localName.get());
     }
 
     cb.DescribeRefCountedNode(tmp->mRefCnt.get(), name);
   }
   else {
     NS_IMPL_CYCLE_COLLECTION_DESCRIBE(NodeInfo, tmp->mRefCnt.get())
   }
 
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -18,17 +18,17 @@
 #include "mozilla/EffectSet.h"
 #include "mozilla/IntegerRange.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/Likely.h"
 #include <algorithm>
 
 #include "mozilla/Logging.h"
 #include "plstr.h"
-#include "prprf.h"
+#include "mozilla/Snprintf.h"
 
 #include "mozilla/Telemetry.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsILoadContext.h"
 #include "nsUnicharUtils.h"
 #include "nsContentList.h"
 #include "nsCSSPseudoElements.h"
@@ -1772,22 +1772,22 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
     } else {
       loadedAsData.AssignLiteral("normal");
     }
     uint32_t nsid = tmp->GetDefaultNamespaceID();
     nsAutoCString uri;
     if (tmp->mDocumentURI)
       tmp->mDocumentURI->GetSpec(uri);
     if (nsid < ArrayLength(kNSURIs)) {
-      PR_snprintf(name, sizeof(name), "nsDocument %s %s %s",
-                  loadedAsData.get(), kNSURIs[nsid], uri.get());
+      snprintf_literal(name, "nsDocument %s %s %s",
+                       loadedAsData.get(), kNSURIs[nsid], uri.get());
     }
     else {
-      PR_snprintf(name, sizeof(name), "nsDocument %s %s",
-                  loadedAsData.get(), uri.get());
+      snprintf_literal(name, "nsDocument %s %s",
+                       loadedAsData.get(), uri.get());
     }
     cb.DescribeRefCountedNode(tmp->mRefCnt.get(), name);
   }
   else {
     NS_IMPL_CYCLE_COLLECTION_DESCRIBE(nsDocument, tmp->mRefCnt.get())
   }
 
   // Always need to traverse script objects, so do that before we check
@@ -2946,20 +2946,19 @@ nsDocument::GetLastModified(nsAString& a
 
 static void
 GetFormattedTimeString(PRTime aTime, nsAString& aFormattedTimeString)
 {
   PRExplodedTime prtime;
   PR_ExplodeTime(aTime, PR_LocalTimeParameters, &prtime);
   // "MM/DD/YYYY hh:mm:ss"
   char formatedTime[24];
-  if (PR_snprintf(formatedTime, sizeof(formatedTime),
-                  "%02ld/%02ld/%04hd %02ld:%02ld:%02ld",
-                  prtime.tm_month + 1, prtime.tm_mday, prtime.tm_year,
-                  prtime.tm_hour     ,  prtime.tm_min,  prtime.tm_sec)) {
+  if (snprintf_literal(formatedTime, "%02d/%02d/%04d %02d:%02d:%02d",
+                       prtime.tm_month + 1, prtime.tm_mday, int(prtime.tm_year),
+                       prtime.tm_hour     ,  prtime.tm_min,  prtime.tm_sec)) {
     CopyASCIItoUTF16(nsDependentCString(formatedTime), aFormattedTimeString);
   } else {
     // If we for whatever reason failed to find the last modified time
     // (or even the current time), fall back to what NS4.x returned.
     aFormattedTimeString.AssignLiteral(MOZ_UTF16("01/01/1970 00:00:00"));
   }
 }
 
--- a/dom/base/nsGenericDOMDataNode.cpp
+++ b/dom/base/nsGenericDOMDataNode.cpp
@@ -29,17 +29,17 @@
 #include "nsCOMArray.h"
 #include "nsNodeUtils.h"
 #include "mozilla/dom/DirectionalityUtils.h"
 #include "nsBindingManager.h"
 #include "nsCCUncollectableMarker.h"
 #include "mozAutoDocUpdate.h"
 
 #include "PLDHashTable.h"
-#include "prprf.h"
+#include "mozilla/Snprintf.h"
 #include "nsWrapperCacheInlines.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 nsGenericDOMDataNode::nsGenericDOMDataNode(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
   : nsIContent(aNodeInfo)
 {
@@ -85,18 +85,18 @@ NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_
 
 NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_BEGIN(nsGenericDOMDataNode)
   return Element::CanSkipThis(tmp);
 NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_END
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsGenericDOMDataNode)
   if (MOZ_UNLIKELY(cb.WantDebugInfo())) {
     char name[40];
-    PR_snprintf(name, sizeof(name), "nsGenericDOMDataNode (len=%d)",
-                tmp->mText.GetLength());
+    snprintf_literal(name, "nsGenericDOMDataNode (len=%d)",
+                     tmp->mText.GetLength());
     cb.DescribeRefCountedNode(tmp->mRefCnt.get(), name);
   } else {
     NS_IMPL_CYCLE_COLLECTION_DESCRIBE(nsGenericDOMDataNode, tmp->mRefCnt.get())
   }
 
   // Always need to traverse script objects, so do that before we check
   // if we're uncollectable.
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
@@ -421,17 +421,17 @@ nsGenericDOMDataNode::ToCString(nsAStrin
       if (ch == '&') {
         aBuf.AppendLiteral("&amp;");
       } else if (ch == '<') {
         aBuf.AppendLiteral("&lt;");
       } else if (ch == '>') {
         aBuf.AppendLiteral("&gt;");
       } else if ((ch < ' ') || (ch >= 127)) {
         char buf[10];
-        PR_snprintf(buf, sizeof(buf), "\\u%04x", ch);
+        snprintf_literal(buf, "\\u%04x", ch);
         AppendASCIItoUTF16(buf, aBuf);
       } else {
         aBuf.Append(ch);
       }
     }
   } else {
     unsigned char* cp = (unsigned char*)mText.Get1b() + aOffset;
     const unsigned char* end = cp + aLen;
@@ -441,17 +441,17 @@ nsGenericDOMDataNode::ToCString(nsAStrin
       if (ch == '&') {
         aBuf.AppendLiteral("&amp;");
       } else if (ch == '<') {
         aBuf.AppendLiteral("&lt;");
       } else if (ch == '>') {
         aBuf.AppendLiteral("&gt;");
       } else if ((ch < ' ') || (ch >= 127)) {
         char buf[10];
-        PR_snprintf(buf, sizeof(buf), "\\u%04x", ch);
+        snprintf_literal(buf, "\\u%04x", ch);
         AppendASCIItoUTF16(buf, aBuf);
       } else {
         aBuf.Append(ch);
       }
     }
   }
 }
 #endif
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -15,16 +15,17 @@
 #include "nsScreen.h"
 #include "nsHistory.h"
 #include "nsPerformance.h"
 #include "nsDOMNavigationTiming.h"
 #include "nsIDOMStorageManager.h"
 #include "mozilla/dom/DOMStorage.h"
 #include "mozilla/dom/StorageEvent.h"
 #include "mozilla/dom/StorageEventBinding.h"
+#include "mozilla/IntegerPrintfMacros.h"
 #if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GONK)
 #include "mozilla/dom/WindowOrientationObserver.h"
 #endif
 #include "nsDOMOfflineResourceList.h"
 #include "nsError.h"
 #include "nsIIdleService.h"
 #include "nsISizeOfEventTarget.h"
 #include "nsDOMJSUtils.h"
@@ -1811,19 +1812,18 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(nsGlobalW
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsGlobalWindow)
   if (MOZ_UNLIKELY(cb.WantDebugInfo())) {
     char name[512];
     nsAutoCString uri;
     if (tmp->mDoc && tmp->mDoc->GetDocumentURI()) {
       tmp->mDoc->GetDocumentURI()->GetSpec(uri);
     }
-    PR_snprintf(name, sizeof(name), "nsGlobalWindow #%llu %s %s",
-                tmp->mWindowID, tmp->IsInnerWindow() ? "inner" : "outer",
-                uri.get());
+    snprintf_literal(name, "nsGlobalWindow # %" PRIu64 " %s %s", tmp->mWindowID,
+                     tmp->IsInnerWindow() ? "inner" : "outer", uri.get());
     cb.DescribeRefCountedNode(tmp->mRefCnt.get(), name);
   } else {
     NS_IMPL_CYCLE_COLLECTION_DESCRIBE(nsGlobalWindow, tmp->mRefCnt.get())
   }
 
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mContext)
 
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mControllers)
--- a/dom/base/nsXMLContentSerializer.cpp
+++ b/dom/base/nsXMLContentSerializer.cpp
@@ -18,17 +18,17 @@
 #include "nsIDOMDocumentType.h"
 #include "nsIContent.h"
 #include "nsIDocument.h"
 #include "nsIDocumentEncoder.h"
 #include "nsIParserService.h"
 #include "nsNameSpaceManager.h"
 #include "nsTextFragment.h"
 #include "nsString.h"
-#include "prprf.h"
+#include "mozilla/Snprintf.h"
 #include "nsUnicharUtils.h"
 #include "nsCRT.h"
 #include "nsContentUtils.h"
 #include "nsAttrName.h"
 #include "nsILineBreaker.h"
 #include "mozilla/dom/Element.h"
 #include "nsParserConstants.h"
 
@@ -603,17 +603,17 @@ nsXMLContentSerializer::ConfirmPrefix(ns
   return true;
 }
 
 void
 nsXMLContentSerializer::GenerateNewPrefix(nsAString& aPrefix)
 {
   aPrefix.Assign('a');
   char buf[128];
-  PR_snprintf(buf, sizeof(buf), "%d", mPrefixIndex++);
+  snprintf_literal(buf, "%d", mPrefixIndex++);
   AppendASCIItoUTF16(buf, aPrefix);
 }
 
 bool
 nsXMLContentSerializer::SerializeAttr(const nsAString& aPrefix,
                                       const nsAString& aName,
                                       const nsAString& aValue,
                                       nsAString& aStr,
--- a/dom/bindings/BindingUtils.cpp
+++ b/dom/bindings/BindingUtils.cpp
@@ -25,17 +25,17 @@
 #include "nsIPermissionManager.h"
 #include "nsIPrincipal.h"
 #include "nsIXPConnect.h"
 #include "nsUTF8Utils.h"
 #include "WrapperFactory.h"
 #include "xpcprivate.h"
 #include "XrayWrapper.h"
 #include "nsPrintfCString.h"
-#include "prprf.h"
+#include "mozilla/Snprintf.h"
 #include "nsGlobalWindow.h"
 
 #include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/dom/DOMError.h"
 #include "mozilla/dom/DOMErrorBinding.h"
 #include "mozilla/dom/DOMException.h"
 #include "mozilla/dom/ElementBinding.h"
 #include "mozilla/dom/HTMLObjectElement.h"
@@ -2419,23 +2419,23 @@ ConvertJSValueToByteString(JSContext* cx
 
     if (foundBadChar) {
       MOZ_ASSERT(badCharIndex < length);
       MOZ_ASSERT(badChar > 255);
       // The largest unsigned 64 bit number (18,446,744,073,709,551,615) has
       // 20 digits, plus one more for the null terminator.
       char index[21];
       static_assert(sizeof(size_t) <= 8, "index array too small");
-      PR_snprintf(index, sizeof(index), "%d", badCharIndex);
+      snprintf_literal(index, "%d", badCharIndex);
       // A char16_t is 16 bits long.  The biggest unsigned 16 bit
       // number (65,535) has 5 digits, plus one more for the null
       // terminator.
       char badCharArray[6];
       static_assert(sizeof(char16_t) <= 2, "badCharArray too small");
-      PR_snprintf(badCharArray, sizeof(badCharArray), "%d", badChar);
+      snprintf_literal(badCharArray, "%d", badChar);
       ThrowErrorMessage(cx, MSG_INVALID_BYTESTRING, index, badCharArray);
       return false;
     }
   } else {
     length = js::GetStringLength(s);
   }
 
   static_assert(js::MaxStringLength < UINT32_MAX,
--- a/dom/events/DOMEventTargetHelper.cpp
+++ b/dom/events/DOMEventTargetHelper.cpp
@@ -1,17 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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 "nsContentUtils.h"
 #include "nsIDocument.h"
-#include "prprf.h"
+#include "mozilla/Snprintf.h"
 #include "nsGlobalWindow.h"
 #include "ScriptSettings.h"
 #include "mozilla/DOMEventTargetHelper.h"
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/EventListenerManager.h"
 #include "mozilla/Likely.h"
 
 namespace mozilla {
@@ -26,18 +26,18 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_END
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(DOMEventTargetHelper)
   if (MOZ_UNLIKELY(cb.WantDebugInfo())) {
     char name[512];
     nsAutoString uri;
     if (tmp->mOwnerWindow && tmp->mOwnerWindow->GetExtantDoc()) {
       tmp->mOwnerWindow->GetExtantDoc()->GetDocumentURI(uri);
     }
-    PR_snprintf(name, sizeof(name), "DOMEventTargetHelper %s",
-                NS_ConvertUTF16toUTF8(uri).get());
+    snprintf_literal(name, "DOMEventTargetHelper %s",
+                     NS_ConvertUTF16toUTF8(uri).get());
     cb.DescribeRefCountedNode(tmp->mRefCnt.get(), name);
   } else {
     NS_IMPL_CYCLE_COLLECTION_DESCRIBE(DOMEventTargetHelper, tmp->mRefCnt.get())
   }
 
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mListenerManager)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -49,18 +49,18 @@
 #include "mozilla/media/MediaChild.h"
 #include "MediaTrackConstraints.h"
 #include "VideoUtils.h"
 #include "Latency.h"
 #include "nsProxyRelease.h"
 #include "nsNullPrincipal.h"
 #include "nsVariant.h"
 
-// For PR_snprintf
-#include "prprf.h"
+// For snprintf
+#include "mozilla/Snprintf.h"
 
 #include "nsJSUtils.h"
 #include "nsGlobalWindow.h"
 #include "nsIUUIDGenerator.h"
 #include "nspr.h"
 #include "nss.h"
 #include "pk11pub.h"
 
@@ -2535,17 +2535,17 @@ MediaManager::RemoveWindowID(uint64_t aW
     LOG(("No outer window for inner %llu", aWindowId));
     return;
   }
 
   uint64_t outerID = outer->WindowID();
 
   // Notify the UI that this window no longer has gUM active
   char windowBuffer[32];
-  PR_snprintf(windowBuffer, sizeof(windowBuffer), "%llu", outerID);
+  snprintf_literal(windowBuffer, "%" PRIu64, outerID);
   nsString data = NS_ConvertUTF8toUTF16(windowBuffer);
 
   nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
   obs->NotifyObservers(nullptr, "recording-window-ended", data.get());
   LOG(("Sent recording-window-ended for window %llu (outer %llu)",
        aWindowId, outerID));
 }
 
--- a/dom/media/mediasource/MediaSource.cpp
+++ b/dom/media/mediasource/MediaSource.cpp
@@ -23,16 +23,17 @@
 #include "nsIRunnable.h"
 #include "nsIScriptObjectPrincipal.h"
 #include "nsPIDOMWindow.h"
 #include "nsString.h"
 #include "nsThreadUtils.h"
 #include "mozilla/Logging.h"
 #include "nsServiceManagerUtils.h"
 #include "gfxPlatform.h"
+#include "mozilla/Snprintf.h"
 
 #ifdef MOZ_WIDGET_ANDROID
 #include "AndroidBridge.h"
 #endif
 
 struct JSContext;
 class JSObject;
 
--- a/dom/media/mediasource/ResourceQueue.cpp
+++ b/dom/media/mediasource/ResourceQueue.cpp
@@ -4,16 +4,17 @@
  * 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 "ResourceQueue.h"
 #include "nsDeque.h"
 #include "MediaData.h"
 #include "mozilla/ErrorResult.h"
 #include "mozilla/Logging.h"
+#include "mozilla/Snprintf.h"
 
 extern mozilla::LogModule* GetSourceBufferResourceLog();
 
 #define SBR_DEBUG(arg, ...) MOZ_LOG(GetSourceBufferResourceLog(), mozilla::LogLevel::Debug, ("ResourceQueue(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
 #define SBR_DEBUGV(arg, ...) MOZ_LOG(GetSourceBufferResourceLog(), mozilla::LogLevel::Verbose, ("ResourceQueue(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
 
 namespace mozilla {
 
@@ -159,17 +160,17 @@ ResourceQueue::SizeOfExcludingThis(Mallo
 #if defined(DEBUG)
 void
 ResourceQueue::Dump(const char* aPath)
 {
   for (uint32_t i = 0; i < uint32_t(GetSize()); ++i) {
     ResourceItem* item = ResourceAt(i);
 
     char buf[255];
-    PR_snprintf(buf, sizeof(buf), "%s/%08u.bin", aPath, i);
+    snprintf_literal(buf, "%s/%08u.bin", aPath, i);
     FILE* fp = fopen(buf, "wb");
     if (!fp) {
       return;
     }
     fwrite(item->mData->Elements(), item->mData->Length(), 1, fp);
     fclose(fp);
   }
 }
--- a/dom/media/webm/WebMDemuxer.cpp
+++ b/dom/media/webm/WebMDemuxer.cpp
@@ -13,17 +13,18 @@
 #include "gfx2DGlue.h"
 #include "mozilla/Endian.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/SharedThreadPool.h"
 #include "MediaDataDemuxer.h"
 #include "nsAutoRef.h"
 #include "NesteggPacketHolder.h"
 #include "XiphExtradata.h"
-#include "prprf.h"
+#include "prprf.h"           // leaving it for PR_vsnprintf()
+#include "mozilla/Snprintf.h"
 
 #include <algorithm>
 #include <stdint.h>
 
 #define VPX_DONT_DEFINE_STDINT_TYPES
 #include "vpx/vp8dx.h"
 #include "vpx/vpx_decoder.h"
 
@@ -112,17 +113,17 @@ static void webmdemux_log(nestegg* aCont
       break;
     default:
       sevStr = "UNK";
       break;
   }
 
   va_start(args, aFormat);
 
-  PR_snprintf(msg, sizeof(msg), "%p [Nestegg-%s] ", aContext, sevStr);
+  snprintf_literal(msg, "%p [Nestegg-%s] ", aContext, sevStr);
   PR_vsnprintf(msg+strlen(msg), sizeof(msg)-strlen(msg), aFormat, args);
   MOZ_LOG(gNesteggLog, LogLevel::Debug, (msg));
 
   va_end(args);
 }
 
 
 WebMDemuxer::WebMDemuxer(MediaResource* aResource)
--- a/dom/media/webrtc/RTCCertificate.cpp
+++ b/dom/media/webrtc/RTCCertificate.cpp
@@ -8,16 +8,17 @@
 
 #include <cmath>
 #include "cert.h"
 #include "jsapi.h"
 #include "mozilla/dom/CryptoKey.h"
 #include "mozilla/dom/RTCCertificateBinding.h"
 #include "mozilla/dom/WebCryptoCommon.h"
 #include "mozilla/dom/WebCryptoTask.h"
+#include "mozilla/Snprintf.h"
 
 #include <cstdio>
 
 namespace mozilla {
 namespace dom {
 
 #define RTCCERTIFICATE_SC_VERSION 0x00000001
 
@@ -90,17 +91,17 @@ private:
                                              sizeof(randomName));
     if (rv != SECSuccess) {
       return nullptr;
     }
 
     char buf[sizeof(randomName) * 2 + 4];
     PL_strncpy(buf, "CN=", 3);
     for (size_t i = 0; i < sizeof(randomName); ++i) {
-      PR_snprintf(&buf[i * 2 + 3], 2, "%.2x", randomName[i]);
+      snprintf(&buf[i * 2 + 3], 2, "%.2x", randomName[i]);
     }
     buf[sizeof(buf) - 1] = '\0';
 
     return CERT_AsciiToName(buf);
   }
 
   nsresult GenerateCertificate()
   {
--- a/dom/plugins/base/nsPluginHost.cpp
+++ b/dom/plugins/base/nsPluginHost.cpp
@@ -68,17 +68,17 @@
 #include "nsIXULRuntime.h"
 
 // for the dialog
 #include "nsIWindowWatcher.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMWindow.h"
 
 #include "nsNetCID.h"
-#include "prprf.h"
+#include "mozilla/Snprintf.h"
 #include "nsThreadUtils.h"
 #include "nsIInputStreamTee.h"
 #include "nsQueryObject.h"
 
 #include "nsDirectoryServiceDefs.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsPluginDirServiceProvider.h"
 
@@ -3780,18 +3780,18 @@ nsPluginHost::ParsePostBufferToFixHeader
     }
   } else  if (dataLen) { // no ContentLenHeader is found but there is a data
     // make new output buffer big enough
     // to keep ContentLenHeader+value followed by data
     uint32_t l = sizeof(ContentLenHeader) + sizeof(CRLFCRLF) + 32;
     newBufferLen = dataLen + l;
     if (!(*outPostData = p = (char*)moz_xmalloc(newBufferLen)))
       return NS_ERROR_OUT_OF_MEMORY;
-    headersLen = PR_snprintf(p, l,"%s: %ld%s", ContentLenHeader, dataLen, CRLFCRLF);
-    if (headersLen == l) { // if PR_snprintf has ate all extra space consider this as an error
+    headersLen = snprintf(p, l,"%s: %u%s", ContentLenHeader, dataLen, CRLFCRLF);
+    if (headersLen == l) { // if snprintf has ate all extra space consider this as an error
       free(p);
       *outPostData = 0;
       return NS_ERROR_FAILURE;
     }
     p += headersLen;
     newBufferLen = headersLen + dataLen;
   }
   // at this point we've done with headers.
--- a/dom/system/gonk/NetworkUtils.cpp
+++ b/dom/system/gonk/NetworkUtils.cpp
@@ -10,17 +10,17 @@
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 #include "NetworkUtils.h"
 
-#include "prprf.h"
+#include "mozilla/Snprintf.h"
 #include "SystemProperty.h"
 
 #include <android/log.h>
 #include <limits>
 #include "mozilla/dom/network/NetUtils.h"
 #include "mozilla/fallible.h"
 
 #include <errno.h>
@@ -394,21 +394,21 @@ static void convertUTF8toUTF16(nsTArray<
 }
 
 /**
  * Helper function to get network interface properties from the system property table.
  */
 static void getIFProperties(const char* ifname, IFProperties& prop)
 {
   char key[Property::KEY_MAX_LENGTH];
-  PR_snprintf(key, Property::KEY_MAX_LENGTH - 1, "net.%s.gw", ifname);
+  snprintf(key, Property::KEY_MAX_LENGTH - 1, "net.%s.gw", ifname);
   Property::Get(key, prop.gateway, "");
-  PR_snprintf(key, Property::KEY_MAX_LENGTH - 1, "net.%s.dns1", ifname);
+  snprintf(key, Property::KEY_MAX_LENGTH - 1, "net.%s.dns1", ifname);
   Property::Get(key, prop.dns1, "");
-  PR_snprintf(key, Property::KEY_MAX_LENGTH - 1, "net.%s.dns2", ifname);
+  snprintf(key, Property::KEY_MAX_LENGTH - 1, "net.%s.dns2", ifname);
   Property::Get(key, prop.dns2, "");
 }
 
 static int getIpType(const char *aIp) {
   struct addrinfo hint, *ip_info = NULL;
 
   memset(&hint, 0, sizeof(hint));
   hint.ai_family = AF_UNSPEC;
@@ -519,17 +519,17 @@ bool CommandResult::isPending() const
 void NetworkUtils::nextNetdCommand()
 {
   if (gCommandQueue.IsEmpty() || gPending) {
     return;
   }
 
   gCurrentCommand.chain = GET_CURRENT_CHAIN;
   gCurrentCommand.callback = GET_CURRENT_CALLBACK;
-  PR_snprintf(gCurrentCommand.command, MAX_COMMAND_SIZE - 1, "%s", GET_CURRENT_COMMAND);
+  snprintf(gCurrentCommand.command, MAX_COMMAND_SIZE - 1, "%s", GET_CURRENT_COMMAND);
 
   NU_DBG("Sending \'%s\' command to netd.", gCurrentCommand.command);
   SendNetdCommand(GET_CURRENT_NETD_COMMAND);
 
   gCommandQueue.RemoveElementAt(0);
   gPending = true;
 }
 
@@ -544,19 +544,19 @@ void NetworkUtils::nextNetdCommand()
 void NetworkUtils::doCommand(const char* aCommand, CommandChain* aChain, CommandCallback aCallback)
 {
   NU_DBG("Preparing to send \'%s\' command...", aCommand);
 
   NetdCommand* netdCommand = new NetdCommand();
 
   // Android JB version adds sequence number to netd command.
   if (SDK_VERSION >= 16) {
-    PR_snprintf((char*)netdCommand->mData, MAX_COMMAND_SIZE - 1, "0 %s", aCommand);
+    snprintf((char*)netdCommand->mData, MAX_COMMAND_SIZE - 1, "0 %s", aCommand);
   } else {
-    PR_snprintf((char*)netdCommand->mData, MAX_COMMAND_SIZE - 1, "%s", aCommand);
+    snprintf((char*)netdCommand->mData, MAX_COMMAND_SIZE - 1, "%s", aCommand);
   }
   netdCommand->mSize = strlen((char*)netdCommand->mData) + 1;
 
   gCommandQueue.AppendElement(QueueData(netdCommand, aChain, aCallback));
 
   nextNetdCommand();
 }
 
@@ -566,17 +566,17 @@ void NetworkUtils::doCommand(const char*
 #define GET_CHAR(prop) NS_ConvertUTF16toUTF8(aChain->getParams().prop).get()
 #define GET_FIELD(prop) aChain->getParams().prop
 
 void NetworkUtils::wifiFirmwareReload(CommandChain* aChain,
                                       CommandCallback aCallback,
                                       NetworkResultOptions& aResult)
 {
   char command[MAX_COMMAND_SIZE];
-  PR_snprintf(command, MAX_COMMAND_SIZE - 1, "softap fwreload %s %s", GET_CHAR(mIfname), GET_CHAR(mMode));
+  snprintf(command, MAX_COMMAND_SIZE - 1, "softap fwreload %s %s", GET_CHAR(mIfname), GET_CHAR(mMode));
 
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::startAccessPointDriver(CommandChain* aChain,
                                           CommandCallback aCallback,
                                           NetworkResultOptions& aResult)
 {
@@ -584,17 +584,17 @@ void NetworkUtils::startAccessPointDrive
   if (SDK_VERSION >= 16) {
     aResult.mResultCode = 0;
     aResult.mResultReason = NS_ConvertUTF8toUTF16("");
     aCallback(aChain, false, aResult);
     return;
   }
 
   char command[MAX_COMMAND_SIZE];
-  PR_snprintf(command, MAX_COMMAND_SIZE - 1, "softap start %s", GET_CHAR(mIfname));
+  snprintf(command, MAX_COMMAND_SIZE - 1, "softap start %s", GET_CHAR(mIfname));
 
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::stopAccessPointDriver(CommandChain* aChain,
                                          CommandCallback aCallback,
                                          NetworkResultOptions& aResult)
 {
@@ -602,17 +602,17 @@ void NetworkUtils::stopAccessPointDriver
   if (SDK_VERSION >= 16) {
     aResult.mResultCode = 0;
     aResult.mResultReason = NS_ConvertUTF8toUTF16("");
     aCallback(aChain, false, aResult);
     return;
   }
 
   char command[MAX_COMMAND_SIZE];
-  PR_snprintf(command, MAX_COMMAND_SIZE - 1, "softap stop %s", GET_CHAR(mIfname));
+  snprintf(command, MAX_COMMAND_SIZE - 1, "softap stop %s", GET_CHAR(mIfname));
 
   doCommand(command, aChain, aCallback);
 }
 
 /**
  * Command format for sdk version < 16
  *   Arguments:
  *     argv[2] - wlan interface
@@ -646,55 +646,55 @@ void NetworkUtils::setAccessPoint(Comman
   char command[MAX_COMMAND_SIZE];
   nsCString ssid(GET_CHAR(mSsid));
   nsCString key(GET_CHAR(mKey));
 
   escapeQuote(ssid);
   escapeQuote(key);
 
   if (SDK_VERSION >= 19) {
-    PR_snprintf(command, MAX_COMMAND_SIZE - 1, "softap set %s \"%s\" broadcast 6 %s \"%s\"",
-                     GET_CHAR(mIfname),
-                     ssid.get(),
-                     GET_CHAR(mSecurity),
-                     key.get());
+    snprintf(command, MAX_COMMAND_SIZE - 1, "softap set %s \"%s\" broadcast 6 %s \"%s\"",
+             GET_CHAR(mIfname),
+             ssid.get(),
+             GET_CHAR(mSecurity),
+             key.get());
   } else if (SDK_VERSION >= 16) {
-    PR_snprintf(command, MAX_COMMAND_SIZE - 1, "softap set %s \"%s\" %s \"%s\"",
-                     GET_CHAR(mIfname),
-                     ssid.get(),
-                     GET_CHAR(mSecurity),
-                     key.get());
+    snprintf(command, MAX_COMMAND_SIZE - 1, "softap set %s \"%s\" %s \"%s\"",
+             GET_CHAR(mIfname),
+             ssid.get(),
+             GET_CHAR(mSecurity),
+             key.get());
   } else {
-    PR_snprintf(command, MAX_COMMAND_SIZE - 1, "softap set %s %s \"%s\" %s \"%s\" 6 0 8",
-                     GET_CHAR(mIfname),
-                     GET_CHAR(mWifictrlinterfacename),
-                     ssid.get(),
-                     GET_CHAR(mSecurity),
-                     key.get());
+    snprintf(command, MAX_COMMAND_SIZE - 1, "softap set %s %s \"%s\" %s \"%s\" 6 0 8",
+             GET_CHAR(mIfname),
+             GET_CHAR(mWifictrlinterfacename),
+             ssid.get(),
+             GET_CHAR(mSecurity),
+             key.get());
   }
 
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::cleanUpStream(CommandChain* aChain,
                                  CommandCallback aCallback,
                                  NetworkResultOptions& aResult)
 {
   char command[MAX_COMMAND_SIZE];
-  PR_snprintf(command, MAX_COMMAND_SIZE - 1, "nat disable %s %s 0", GET_CHAR(mPreInternalIfname), GET_CHAR(mPreExternalIfname));
+  snprintf(command, MAX_COMMAND_SIZE - 1, "nat disable %s %s 0", GET_CHAR(mPreInternalIfname), GET_CHAR(mPreExternalIfname));
 
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::createUpStream(CommandChain* aChain,
                                   CommandCallback aCallback,
                                   NetworkResultOptions& aResult)
 {
   char command[MAX_COMMAND_SIZE];
-  PR_snprintf(command, MAX_COMMAND_SIZE - 1, "nat enable %s %s 0", GET_CHAR(mCurInternalIfname), GET_CHAR(mCurExternalIfname));
+  snprintf(command, MAX_COMMAND_SIZE - 1, "nat enable %s %s 0", GET_CHAR(mCurInternalIfname), GET_CHAR(mCurExternalIfname));
 
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::startSoftAP(CommandChain* aChain,
                                CommandCallback aCallback,
                                NetworkResultOptions& aResult)
 {
@@ -735,77 +735,78 @@ void NetworkUtils::disableAlarm(CommandC
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::setQuota(CommandChain* aChain,
                             CommandCallback aCallback,
                             NetworkResultOptions& aResult)
 {
   char command[MAX_COMMAND_SIZE];
-  PR_snprintf(command, MAX_COMMAND_SIZE - 1, "bandwidth setiquota %s %lld", GET_CHAR(mIfname), LLONG_MAX);
+  snprintf(command, MAX_COMMAND_SIZE - 1, "bandwidth setiquota %s % " PRId64, GET_CHAR(mIfname), INT64_MAX);
 
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::removeQuota(CommandChain* aChain,
                                CommandCallback aCallback,
                                NetworkResultOptions& aResult)
 {
   char command[MAX_COMMAND_SIZE];
-  PR_snprintf(command, MAX_COMMAND_SIZE - 1, "bandwidth removeiquota %s", GET_CHAR(mIfname));
+  snprintf(command, MAX_COMMAND_SIZE - 1, "bandwidth removeiquota %s", GET_CHAR(mIfname));
 
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::setAlarm(CommandChain* aChain,
                             CommandCallback aCallback,
                             NetworkResultOptions& aResult)
 {
   char command[MAX_COMMAND_SIZE];
-  PR_snprintf(command, MAX_COMMAND_SIZE - 1, "bandwidth setinterfacealert %s %lld", GET_CHAR(mIfname), GET_FIELD(mThreshold));
+  snprintf(command, MAX_COMMAND_SIZE - 1, "bandwidth setinterfacealert %s %lld",
+           GET_CHAR(mIfname), GET_FIELD(mThreshold));
 
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::removeAlarm(CommandChain* aChain,
                             CommandCallback aCallback,
                             NetworkResultOptions& aResult)
 {
   char command[MAX_COMMAND_SIZE];
-  PR_snprintf(command, MAX_COMMAND_SIZE - 1, "bandwidth removeinterfacealert %s", GET_CHAR(mIfname));
+  snprintf(command, MAX_COMMAND_SIZE - 1, "bandwidth removeinterfacealert %s", GET_CHAR(mIfname));
 
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::setGlobalAlarm(CommandChain* aChain,
                                   CommandCallback aCallback,
                                   NetworkResultOptions& aResult)
 {
   char command[MAX_COMMAND_SIZE];
 
-  PR_snprintf(command, MAX_COMMAND_SIZE - 1, "bandwidth setglobalalert %ld", GET_FIELD(mThreshold));
+  snprintf(command, MAX_COMMAND_SIZE - 1, "bandwidth setglobalalert %lld", GET_FIELD(mThreshold));
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::removeGlobalAlarm(CommandChain* aChain,
                                      CommandCallback aCallback,
                                      NetworkResultOptions& aResult)
 {
   char command[MAX_COMMAND_SIZE];
 
-  PR_snprintf(command, MAX_COMMAND_SIZE - 1, "bandwidth removeglobalalert");
+  snprintf(command, MAX_COMMAND_SIZE - 1, "bandwidth removeglobalalert");
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::tetherInterface(CommandChain* aChain,
                                    CommandCallback aCallback,
                                    NetworkResultOptions& aResult)
 {
   char command[MAX_COMMAND_SIZE];
-  PR_snprintf(command, MAX_COMMAND_SIZE - 1, "tether interface add %s", GET_CHAR(mIfname));
+  snprintf(command, MAX_COMMAND_SIZE - 1, "tether interface add %s", GET_CHAR(mIfname));
 
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::addInterfaceToLocalNetwork(CommandChain* aChain,
                                               CommandCallback aCallback,
                                               NetworkResultOptions& aResult)
 {
@@ -813,18 +814,18 @@ void NetworkUtils::addInterfaceToLocalNe
   if (SDK_VERSION < 20) {
     aResult.mResultCode = 0;
     aResult.mResultReason = NS_ConvertUTF8toUTF16("");
     aCallback(aChain, false, aResult);
     return;
   }
 
   char command[MAX_COMMAND_SIZE];
-  PR_snprintf(command, MAX_COMMAND_SIZE - 1, "network interface add local %s",
-              GET_CHAR(mInternalIfname));
+  snprintf(command, MAX_COMMAND_SIZE - 1, "network interface add local %s",
+           GET_CHAR(mInternalIfname));
 
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::addRouteToLocalNetwork(CommandChain* aChain,
                                           CommandCallback aCallback,
                                           NetworkResultOptions& aResult)
 {
@@ -836,43 +837,43 @@ void NetworkUtils::addRouteToLocalNetwor
     return;
   }
 
   char command[MAX_COMMAND_SIZE];
   uint32_t prefix = atoi(GET_CHAR(mPrefix));
   uint32_t ip = inet_addr(GET_CHAR(mIp));
   char* networkAddr = getNetworkAddr(ip, prefix);
 
-  PR_snprintf(command, MAX_COMMAND_SIZE - 1, "network route add local %s %s/%s",
-              GET_CHAR(mInternalIfname), networkAddr, GET_CHAR(mPrefix));
+  snprintf(command, MAX_COMMAND_SIZE - 1, "network route add local %s %s/%s",
+           GET_CHAR(mInternalIfname), networkAddr, GET_CHAR(mPrefix));
 
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::preTetherInterfaceList(CommandChain* aChain,
                                           CommandCallback aCallback,
                                           NetworkResultOptions& aResult)
 {
   char command[MAX_COMMAND_SIZE];
   if (SDK_VERSION >= 16) {
-    PR_snprintf(command, MAX_COMMAND_SIZE - 1, "tether interface list");
+    snprintf(command, MAX_COMMAND_SIZE - 1, "tether interface list");
   } else {
-    PR_snprintf(command, MAX_COMMAND_SIZE - 1, "tether interface list 0");
+    snprintf(command, MAX_COMMAND_SIZE - 1, "tether interface list 0");
   }
 
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::postTetherInterfaceList(CommandChain* aChain,
                                            CommandCallback aCallback,
                                            NetworkResultOptions& aResult)
 {
   // Send the dummy command to continue the function chain.
   char command[MAX_COMMAND_SIZE];
-  PR_snprintf(command, MAX_COMMAND_SIZE - 1, "%s", DUMMY_COMMAND);
+  snprintf(command, MAX_COMMAND_SIZE - 1, "%s", DUMMY_COMMAND);
 
   char buf[BUF_SIZE];
   NS_ConvertUTF16toUTF8 reason(aResult.mResultReason);
 
   size_t length = reason.Length() + 1 < BUF_SIZE ? reason.Length() + 1 : BUF_SIZE;
   memcpy(buf, reason.get(), length);
   split(buf, INTERFACE_DELIMIT, GET_FIELD(mInterfaceList));
 
@@ -922,18 +923,18 @@ void NetworkUtils::addUpstreamInterface(
   }
 
   if (SUPPORT_IPV6_TETHERING == 0 || !isCommandChainIPv6(aChain, interface.get())) {
     aCallback(aChain, false, aResult);
     return;
   }
 
   char command[MAX_COMMAND_SIZE];
-  PR_snprintf(command, MAX_COMMAND_SIZE - 1, "tether interface add_upstream %s",
-              interface.get());
+  snprintf(command, MAX_COMMAND_SIZE - 1, "tether interface add_upstream %s",
+           interface.get());
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::removeUpstreamInterface(CommandChain* aChain,
                                            CommandCallback aCallback,
                                            NetworkResultOptions& aResult)
 {
   nsCString interface(GET_CHAR(mExternalIfname));
@@ -942,36 +943,36 @@ void NetworkUtils::removeUpstreamInterfa
   }
 
   if (SUPPORT_IPV6_TETHERING == 0 || !isCommandChainIPv6(aChain, interface.get())) {
     aCallback(aChain, false, aResult);
     return;
   }
 
   char command[MAX_COMMAND_SIZE];
-  PR_snprintf(command, MAX_COMMAND_SIZE - 1, "tether interface remove_upstream %s",
-              interface.get());
+  snprintf(command, MAX_COMMAND_SIZE - 1, "tether interface remove_upstream %s",
+           interface.get());
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::setIpForwardingEnabled(CommandChain* aChain,
                                           CommandCallback aCallback,
                                           NetworkResultOptions& aResult)
 {
   char command[MAX_COMMAND_SIZE];
 
   if (GET_FIELD(mEnable)) {
-    PR_snprintf(command, MAX_COMMAND_SIZE - 1, "ipfwd enable");
+    snprintf(command, MAX_COMMAND_SIZE - 1, "ipfwd enable");
   } else {
     // Don't disable ip forwarding because others interface still need it.
     // Send the dummy command to continue the function chain.
     if (GET_FIELD(mInterfaceList).Length() > 1) {
-      PR_snprintf(command, MAX_COMMAND_SIZE - 1, "%s", DUMMY_COMMAND);
+      snprintf(command, MAX_COMMAND_SIZE - 1, "%s", DUMMY_COMMAND);
     } else {
-      PR_snprintf(command, MAX_COMMAND_SIZE - 1, "ipfwd disable");
+      snprintf(command, MAX_COMMAND_SIZE - 1, "ipfwd disable");
     }
   }
 
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::tetheringStatus(CommandChain* aChain,
                                    CommandCallback aCallback,
@@ -985,57 +986,57 @@ void NetworkUtils::stopTethering(Command
                                  CommandCallback aCallback,
                                  NetworkResultOptions& aResult)
 {
   char command[MAX_COMMAND_SIZE];
 
   // Don't stop tethering because others interface still need it.
   // Send the dummy to continue the function chain.
   if (GET_FIELD(mInterfaceList).Length() > 1) {
-    PR_snprintf(command, MAX_COMMAND_SIZE - 1, "%s", DUMMY_COMMAND);
+    snprintf(command, MAX_COMMAND_SIZE - 1, "%s", DUMMY_COMMAND);
   } else {
-    PR_snprintf(command, MAX_COMMAND_SIZE - 1, "tether stop");
+    snprintf(command, MAX_COMMAND_SIZE - 1, "tether stop");
   }
 
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::startTethering(CommandChain* aChain,
                                   CommandCallback aCallback,
                                   NetworkResultOptions& aResult)
 {
   char command[MAX_COMMAND_SIZE];
 
   // We don't need to start tethering again.
   // Send the dummy command to continue the function chain.
   if (aResult.mResultReason.Find("started") != kNotFound) {
-    PR_snprintf(command, MAX_COMMAND_SIZE - 1, "%s", DUMMY_COMMAND);
+    snprintf(command, MAX_COMMAND_SIZE - 1, "%s", DUMMY_COMMAND);
   } else {
     // If usbStartIp/usbEndIp is not valid, don't append them since
     // the trailing white spaces will be parsed to extra empty args
     // See: http://androidxref.com/4.3_r2.1/xref/system/core/libsysutils/src/FrameworkListener.cpp#78
     if (!GET_FIELD(mUsbStartIp).IsEmpty() && !GET_FIELD(mUsbEndIp).IsEmpty()) {
-      PR_snprintf(command, MAX_COMMAND_SIZE - 1, "tether start %s %s %s %s",
-                  GET_CHAR(mWifiStartIp), GET_CHAR(mWifiEndIp),
-                  GET_CHAR(mUsbStartIp),  GET_CHAR(mUsbEndIp));
+      snprintf(command, MAX_COMMAND_SIZE - 1, "tether start %s %s %s %s",
+               GET_CHAR(mWifiStartIp), GET_CHAR(mWifiEndIp),
+               GET_CHAR(mUsbStartIp),  GET_CHAR(mUsbEndIp));
     } else {
-      PR_snprintf(command, MAX_COMMAND_SIZE - 1, "tether start %s %s",
-                  GET_CHAR(mWifiStartIp), GET_CHAR(mWifiEndIp));
+      snprintf(command, MAX_COMMAND_SIZE - 1, "tether start %s %s",
+               GET_CHAR(mWifiStartIp), GET_CHAR(mWifiEndIp));
     }
   }
 
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::untetherInterface(CommandChain* aChain,
                                      CommandCallback aCallback,
                                      NetworkResultOptions& aResult)
 {
   char command[MAX_COMMAND_SIZE];
-  PR_snprintf(command, MAX_COMMAND_SIZE - 1, "tether interface remove %s", GET_CHAR(mIfname));
+  snprintf(command, MAX_COMMAND_SIZE - 1, "tether interface remove %s", GET_CHAR(mIfname));
 
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::removeInterfaceFromLocalNetwork(CommandChain* aChain,
                                                    CommandCallback aCallback,
                                                    NetworkResultOptions& aResult)
 {
@@ -1043,34 +1044,34 @@ void NetworkUtils::removeInterfaceFromLo
   if (SDK_VERSION < 20) {
     aResult.mResultCode = 0;
     aResult.mResultReason = NS_ConvertUTF8toUTF16("");
     aCallback(aChain, false, aResult);
     return;
   }
 
   char command[MAX_COMMAND_SIZE];
-  PR_snprintf(command, MAX_COMMAND_SIZE - 1, "network interface remove local %s",
-              GET_CHAR(mIfname));
+  snprintf(command, MAX_COMMAND_SIZE - 1, "network interface remove local %s",
+           GET_CHAR(mIfname));
 
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::setDnsForwarders(CommandChain* aChain,
                                     CommandCallback aCallback,
                                     NetworkResultOptions& aResult)
 {
   char command[MAX_COMMAND_SIZE];
 
   if (SDK_VERSION >= 20) {
-    PR_snprintf(command, MAX_COMMAND_SIZE - 1, "tether dns set %d %s %s",
-                GET_FIELD(mNetId), GET_CHAR(mDns1), GET_CHAR(mDns2));
+    snprintf(command, MAX_COMMAND_SIZE - 1, "tether dns set %d %s %s",
+             GET_FIELD(mNetId), GET_CHAR(mDns1), GET_CHAR(mDns2));
   } else {
-    PR_snprintf(command, MAX_COMMAND_SIZE - 1, "tether dns set %s %s",
-                GET_CHAR(mDns1), GET_CHAR(mDns2));
+    snprintf(command, MAX_COMMAND_SIZE - 1, "tether dns set %s %s",
+             GET_CHAR(mDns1), GET_CHAR(mDns2));
   }
 
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::enableNat(CommandChain* aChain,
                              CommandCallback aCallback,
                              NetworkResultOptions& aResult)
@@ -1078,55 +1079,55 @@ void NetworkUtils::enableNat(CommandChai
   char command[MAX_COMMAND_SIZE];
 
   if (!GET_FIELD(mIp).IsEmpty() && !GET_FIELD(mPrefix).IsEmpty()) {
     uint32_t prefix = atoi(GET_CHAR(mPrefix));
     uint32_t ip = inet_addr(GET_CHAR(mIp));
     char* networkAddr = getNetworkAddr(ip, prefix);
 
     // address/prefix will only take effect when secondary routing table exists.
-    PR_snprintf(command, MAX_COMMAND_SIZE - 1, "nat enable %s %s 1 %s/%s",
-      GET_CHAR(mInternalIfname), GET_CHAR(mExternalIfname), networkAddr,
-      GET_CHAR(mPrefix));
+    snprintf(command, MAX_COMMAND_SIZE - 1, "nat enable %s %s 1 %s/%s",
+             GET_CHAR(mInternalIfname), GET_CHAR(mExternalIfname), networkAddr,
+             GET_CHAR(mPrefix));
   } else {
-    PR_snprintf(command, MAX_COMMAND_SIZE - 1, "nat enable %s %s 0",
-      GET_CHAR(mInternalIfname), GET_CHAR(mExternalIfname));
+    snprintf(command, MAX_COMMAND_SIZE - 1, "nat enable %s %s 0",
+             GET_CHAR(mInternalIfname), GET_CHAR(mExternalIfname));
   }
 
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::disableNat(CommandChain* aChain,
                               CommandCallback aCallback,
                               NetworkResultOptions& aResult)
 {
   char command[MAX_COMMAND_SIZE];
 
   if (!GET_FIELD(mIp).IsEmpty() && !GET_FIELD(mPrefix).IsEmpty()) {
     uint32_t prefix = atoi(GET_CHAR(mPrefix));
     uint32_t ip = inet_addr(GET_CHAR(mIp));
     char* networkAddr = getNetworkAddr(ip, prefix);
 
-    PR_snprintf(command, MAX_COMMAND_SIZE - 1, "nat disable %s %s 1 %s/%s",
-      GET_CHAR(mInternalIfname), GET_CHAR(mExternalIfname), networkAddr,
-      GET_CHAR(mPrefix));
+    snprintf(command, MAX_COMMAND_SIZE - 1, "nat disable %s %s 1 %s/%s",
+             GET_CHAR(mInternalIfname), GET_CHAR(mExternalIfname), networkAddr,
+             GET_CHAR(mPrefix));
   } else {
-    PR_snprintf(command, MAX_COMMAND_SIZE - 1, "nat disable %s %s 0",
-      GET_CHAR(mInternalIfname), GET_CHAR(mExternalIfname));
+    snprintf(command, MAX_COMMAND_SIZE - 1, "nat disable %s %s 0",
+             GET_CHAR(mInternalIfname), GET_CHAR(mExternalIfname));
   }
 
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::setDefaultInterface(CommandChain* aChain,
                                        CommandCallback aCallback,
                                        NetworkResultOptions& aResult)
 {
   char command[MAX_COMMAND_SIZE];
-  PR_snprintf(command, MAX_COMMAND_SIZE - 1, "resolver setdefaultif %s", GET_CHAR(mIfname));
+  snprintf(command, MAX_COMMAND_SIZE - 1, "resolver setdefaultif %s", GET_CHAR(mIfname));
 
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::removeDefaultRoute(CommandChain* aChain,
                                       CommandCallback aCallback,
                                       NetworkResultOptions& aResult)
 {
@@ -1135,19 +1136,19 @@ void NetworkUtils::removeDefaultRoute(Co
     return;
   }
 
   char command[MAX_COMMAND_SIZE];
   nsTArray<nsString>& gateways = GET_FIELD(mGateways);
   NS_ConvertUTF16toUTF8 autoGateway(gateways[GET_FIELD(mLoopIndex)]);
 
   int type = getIpType(autoGateway.get());
-  PR_snprintf(command, MAX_COMMAND_SIZE - 1, "network route remove %d %s %s/0 %s",
-              GET_FIELD(mNetId), GET_CHAR(mIfname),
-              type == AF_INET6 ? "::" : "0.0.0.0", autoGateway.get());
+  snprintf(command, MAX_COMMAND_SIZE - 1, "network route remove %d %s %s/0 %s",
+           GET_FIELD(mNetId), GET_CHAR(mIfname),
+           type == AF_INET6 ? "::" : "0.0.0.0", autoGateway.get());
 
   struct MyCallback {
     static void callback(CommandCallback::CallbackType aOriginalCallback,
                          CommandChain* aChain,
                          bool aError,
                          mozilla::dom::NetworkResultOptions& aResult)
     {
       NS_ConvertUTF16toUTF8 reason(aResult.mResultReason);
@@ -1168,30 +1169,30 @@ void NetworkUtils::removeDefaultRoute(Co
 void NetworkUtils::setInterfaceDns(CommandChain* aChain,
                                    CommandCallback aCallback,
                                    NetworkResultOptions& aResult)
 {
   char command[MAX_COMMAND_SIZE];
   int written;
 
   if (SDK_VERSION >= 20) {
-    written = PR_snprintf(command, sizeof command, "resolver setnetdns %d %s",
-                                                   GET_FIELD(mNetId), GET_CHAR(mDomain));
+    written = snprintf_literal(command, "resolver setnetdns %d %s",
+                               GET_FIELD(mNetId), GET_CHAR(mDomain));
   } else {
-    written = PR_snprintf(command, sizeof command, "resolver setifdns %s %s",
-                                                   GET_CHAR(mIfname), GET_CHAR(mDomain));
+    written = snprintf_literal(command, "resolver setifdns %s %s",
+                               GET_CHAR(mIfname), GET_CHAR(mDomain));
   }
 
   nsTArray<nsString>& dnses = GET_FIELD(mDnses);
   uint32_t length = dnses.Length();
 
   for (uint32_t i = 0; i < length; i++) {
     NS_ConvertUTF16toUTF8 autoDns(dnses[i]);
 
-    int ret = PR_snprintf(command + written, sizeof(command) - written, " %s", autoDns.get());
+    int ret = snprintf(command + written, sizeof(command) - written, " %s", autoDns.get());
     if (ret <= 1) {
       command[written] = '\0';
       continue;
     }
 
     if (((size_t)ret + written) >= sizeof(command)) {
       command[written] = '\0';
       break;
@@ -1244,48 +1245,48 @@ void NetworkUtils::setConfig(CommandChai
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::clearAddrForInterface(CommandChain* aChain,
                                          CommandCallback aCallback,
                                          NetworkResultOptions& aResult)
 {
   char command[MAX_COMMAND_SIZE];
-  PR_snprintf(command, MAX_COMMAND_SIZE - 1, "interface clearaddrs %s", GET_CHAR(mIfname));
+  snprintf(command, MAX_COMMAND_SIZE - 1, "interface clearaddrs %s", GET_CHAR(mIfname));
 
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::createNetwork(CommandChain* aChain,
                                  CommandCallback aCallback,
                                  NetworkResultOptions& aResult)
 {
   char command[MAX_COMMAND_SIZE];
-  PR_snprintf(command, MAX_COMMAND_SIZE - 1, "network create %d", GET_FIELD(mNetId));
+  snprintf(command, MAX_COMMAND_SIZE - 1, "network create %d", GET_FIELD(mNetId));
 
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::destroyNetwork(CommandChain* aChain,
                                   CommandCallback aCallback,
                                   NetworkResultOptions& aResult)
 {
   char command[MAX_COMMAND_SIZE];
-  PR_snprintf(command, MAX_COMMAND_SIZE - 1, "network destroy %d", GET_FIELD(mNetId));
+  snprintf(command, MAX_COMMAND_SIZE - 1, "network destroy %d", GET_FIELD(mNetId));
 
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::addInterfaceToNetwork(CommandChain* aChain,
                                          CommandCallback aCallback,
                                          NetworkResultOptions& aResult)
 {
   char command[MAX_COMMAND_SIZE];
-  PR_snprintf(command, MAX_COMMAND_SIZE - 1, "network interface add %d %s",
-                    GET_FIELD(mNetId), GET_CHAR(mIfname));
+  snprintf(command, MAX_COMMAND_SIZE - 1, "network interface add %d %s",
+           GET_FIELD(mNetId), GET_CHAR(mIfname));
 
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::addRouteToInterface(CommandChain* aChain,
                                        CommandCallback aCallback,
                                        NetworkResultOptions& aResult)
 {
@@ -1334,20 +1335,20 @@ void NetworkUtils::modifyRouteOnInterfac
     ipOrSubnetIp = getSubnetIp(ipOrSubnetIp, GET_FIELD(mPrefixLength));
     legacyOrEmpty = ""; // Add to interface table for scope link route.
   } else {
     gatewayOrEmpty = nsCString(" ") + NS_ConvertUTF16toUTF8(GET_FIELD(mGateway));
   }
 
   const char* action = aDoAdd ? "add" : "remove";
 
-  PR_snprintf(command, MAX_COMMAND_SIZE - 1, "network route %s%s %d %s %s/%d%s",
-              legacyOrEmpty, action,
-              GET_FIELD(mNetId), GET_CHAR(mIfname), ipOrSubnetIp.get(),
-              GET_FIELD(mPrefixLength), gatewayOrEmpty.get());
+  snprintf(command, MAX_COMMAND_SIZE - 1, "network route %s%s %d %s %s/%d%s",
+           legacyOrEmpty, action,
+           GET_FIELD(mNetId), GET_CHAR(mIfname), ipOrSubnetIp.get(),
+           GET_FIELD(mPrefixLength), gatewayOrEmpty.get());
 
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::addDefaultRouteToNetwork(CommandChain* aChain,
                                             CommandCallback aCallback,
                                             NetworkResultOptions& aResult)
 {
@@ -1356,19 +1357,19 @@ void NetworkUtils::addDefaultRouteToNetw
     return;
   }
 
   char command[MAX_COMMAND_SIZE];
   nsTArray<nsString>& gateways = GET_FIELD(mGateways);
   NS_ConvertUTF16toUTF8 autoGateway(gateways[GET_FIELD(mLoopIndex)]);
 
   int type = getIpType(autoGateway.get());
-  PR_snprintf(command, MAX_COMMAND_SIZE - 1, "network route add %d %s %s/0 %s",
-              GET_FIELD(mNetId), GET_CHAR(mIfname),
-              type == AF_INET6 ? "::" : "0.0.0.0", autoGateway.get());
+  snprintf(command, MAX_COMMAND_SIZE - 1, "network route add %d %s %s/0 %s",
+           GET_FIELD(mNetId), GET_CHAR(mIfname),
+           type == AF_INET6 ? "::" : "0.0.0.0", autoGateway.get());
 
   struct MyCallback {
     static void callback(CommandCallback::CallbackType aOriginalCallback,
                          CommandChain* aChain,
                          bool aError,
                          mozilla::dom::NetworkResultOptions& aResult)
     {
       NS_ConvertUTF16toUTF8 reason(aResult.mResultReason);
@@ -1386,80 +1387,80 @@ void NetworkUtils::addDefaultRouteToNetw
   doCommand(command, aChain, wrappedCallback);
 }
 
 void NetworkUtils::setDefaultNetwork(CommandChain* aChain,
                                      CommandCallback aCallback,
                                      NetworkResultOptions& aResult)
 {
   char command[MAX_COMMAND_SIZE];
-  PR_snprintf(command, MAX_COMMAND_SIZE - 1, "network default set %d", GET_FIELD(mNetId));
+  snprintf(command, MAX_COMMAND_SIZE - 1, "network default set %d", GET_FIELD(mNetId));
 
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::addRouteToSecondaryTable(CommandChain* aChain,
                                             CommandCallback aCallback,
                                             NetworkResultOptions& aResult) {
 
   char command[MAX_COMMAND_SIZE];
 
   if (SDK_VERSION >= 20) {
-    PR_snprintf(command, MAX_COMMAND_SIZE - 1,
-                "network route add %d %s %s/%s %s",
-                GET_FIELD(mNetId),
-                GET_CHAR(mIfname),
-                GET_CHAR(mIp),
-                GET_CHAR(mPrefix),
-                GET_CHAR(mGateway));
+    snprintf(command, MAX_COMMAND_SIZE - 1,
+             "network route add %d %s %s/%s %s",
+             GET_FIELD(mNetId),
+             GET_CHAR(mIfname),
+             GET_CHAR(mIp),
+             GET_CHAR(mPrefix),
+             GET_CHAR(mGateway));
   } else {
-    PR_snprintf(command, MAX_COMMAND_SIZE - 1,
-                "interface route add %s secondary %s %s %s",
-                GET_CHAR(mIfname),
-                GET_CHAR(mIp),
-                GET_CHAR(mPrefix),
-                GET_CHAR(mGateway));
+    snprintf(command, MAX_COMMAND_SIZE - 1,
+             "interface route add %s secondary %s %s %s",
+             GET_CHAR(mIfname),
+             GET_CHAR(mIp),
+             GET_CHAR(mPrefix),
+             GET_CHAR(mGateway));
   }
 
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::removeRouteFromSecondaryTable(CommandChain* aChain,
                                                  CommandCallback aCallback,
                                                  NetworkResultOptions& aResult) {
   char command[MAX_COMMAND_SIZE];
 
   if (SDK_VERSION >= 20) {
-    PR_snprintf(command, MAX_COMMAND_SIZE - 1,
-                "network route remove %d %s %s/%s %s",
-                GET_FIELD(mNetId),
-                GET_CHAR(mIfname),
-                GET_CHAR(mIp),
-                GET_CHAR(mPrefix),
-                GET_CHAR(mGateway));
+    snprintf(command, MAX_COMMAND_SIZE - 1,
+             "network route remove %d %s %s/%s %s",
+             GET_FIELD(mNetId),
+             GET_CHAR(mIfname),
+             GET_CHAR(mIp),
+             GET_CHAR(mPrefix),
+             GET_CHAR(mGateway));
   } else {
-    PR_snprintf(command, MAX_COMMAND_SIZE - 1,
-                "interface route remove %s secondary %s %s %s",
-                GET_CHAR(mIfname),
-                GET_CHAR(mIp),
-                GET_CHAR(mPrefix),
-                GET_CHAR(mGateway));
+    snprintf(command, MAX_COMMAND_SIZE - 1,
+             "interface route remove %s secondary %s %s %s",
+             GET_CHAR(mIfname),
+             GET_CHAR(mIp),
+             GET_CHAR(mPrefix),
+             GET_CHAR(mGateway));
   }
 
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::setIpv6Enabled(CommandChain* aChain,
                                   CommandCallback aCallback,
                                   NetworkResultOptions& aResult,
                                   bool aEnabled)
 {
   char command[MAX_COMMAND_SIZE];
-  PR_snprintf(command, MAX_COMMAND_SIZE - 1, "interface ipv6 %s %s",
-              GET_CHAR(mIfname), aEnabled ? "enable" : "disable");
+  snprintf(command, MAX_COMMAND_SIZE - 1, "interface ipv6 %s %s",
+           GET_CHAR(mIfname), aEnabled ? "enable" : "disable");
 
   struct MyCallback {
     static void callback(CommandCallback::CallbackType aOriginalCallback,
                          CommandChain* aChain,
                          bool aError,
                          mozilla::dom::NetworkResultOptions& aResult)
     {
       aOriginalCallback(aChain, false, aResult);
@@ -1484,18 +1485,18 @@ void NetworkUtils::disableIpv6(CommandCh
   setIpv6Enabled(aChain, aCallback, aResult, false);
 }
 
 void NetworkUtils::setMtu(CommandChain* aChain,
                           CommandCallback aCallback,
                           NetworkResultOptions& aResult)
 {
   char command[MAX_COMMAND_SIZE];
-  PR_snprintf(command, MAX_COMMAND_SIZE - 1, "interface setmtu %s %d",
-              GET_CHAR(mIfname), GET_FIELD(mMtu));
+  snprintf(command, MAX_COMMAND_SIZE - 1, "interface setmtu %s %ld",
+           GET_CHAR(mIfname), GET_FIELD(mMtu));
 
   doCommand(command, aChain, aCallback);
 }
 
 #undef GET_CHAR
 #undef GET_FIELD
 
 /*
@@ -1871,19 +1872,19 @@ void NetworkUtils::onNetdMessage(NetdCom
   if (isBroadcastMessage(code)) {
     NU_DBG("Receiving broadcast message from netd.");
     NU_DBG("          ==> Code: %d  Reason: %s", code, reason);
     sendBroadcastMessage(code, reason);
 
     if (code == NETD_COMMAND_INTERFACE_CHANGE) {
       if (gWifiTetheringParms) {
         char linkdownReason[MAX_COMMAND_SIZE];
-        PR_snprintf(linkdownReason, MAX_COMMAND_SIZE - 1,
-                    "Iface linkstate %s down",
-                    NS_ConvertUTF16toUTF8(gWifiTetheringParms->mIfname).get());
+        snprintf(linkdownReason, MAX_COMMAND_SIZE - 1,
+                 "Iface linkstate %s down",
+                 NS_ConvertUTF16toUTF8(gWifiTetheringParms->mIfname).get());
 
         if (!strcmp(reason, linkdownReason)) {
           NU_DBG("Wifi link down, restarting tethering.");
           runChain(*gWifiTetheringParms, sWifiRetryChain, wifiTetheringFail);
         }
       }
     }
 
@@ -1950,34 +1951,34 @@ CommandResult NetworkUtils::setDNS(Netwo
 {
   uint32_t length = aOptions.mDnses.Length();
 
   if (length > 0) {
     for (uint32_t i = 0; i < length; i++) {
       NS_ConvertUTF16toUTF8 autoDns(aOptions.mDnses[i]);
 
       char dns_prop_key[Property::VALUE_MAX_LENGTH];
-      PR_snprintf(dns_prop_key, sizeof dns_prop_key, "net.dns%d", i+1);
+      snprintf_literal(dns_prop_key, "net.dns%d", i+1);
       Property::Set(dns_prop_key, autoDns.get());
     }
   } else {
     // Set dnses from system properties.
     IFProperties interfaceProperties;
     getIFProperties(GET_CHAR(mIfname), interfaceProperties);
 
     Property::Set("net.dns1", interfaceProperties.dns1);
     Property::Set("net.dns2", interfaceProperties.dns2);
   }
 
   // Bump the DNS change property.
   char dnschange[Property::VALUE_MAX_LENGTH];
   Property::Get("net.dnschange", dnschange, "0");
 
   char num[Property::VALUE_MAX_LENGTH];
-  PR_snprintf(num, Property::VALUE_MAX_LENGTH - 1, "%d", atoi(dnschange) + 1);
+  snprintf(num, Property::VALUE_MAX_LENGTH - 1, "%d", atoi(dnschange) + 1);
   Property::Set("net.dnschange", num);
 
   // DNS needs to be set through netd since JellyBean (4.3).
   if (SDK_VERSION >= 20) {
     // Lollipop.
     static CommandFunc COMMAND_CHAIN[] = {
       setInterfaceDns,
       addDefaultRouteToNetwork,
@@ -2159,17 +2160,17 @@ CommandResult NetworkUtils::setDefaultRo
         RETURN_IF_FAILED(mNetUtils->do_ifc_set_default_route(autoIfname.get(), inet_addr(autoGateway.get())));
       }
     }
   } else {
     // Set default froute from system properties.
     char key[Property::KEY_MAX_LENGTH];
     char gateway[Property::KEY_MAX_LENGTH];
 
-    PR_snprintf(key, sizeof key - 1, "net.%s.gw", autoIfname.get());
+    snprintf(key, sizeof key - 1, "net.%s.gw", autoIfname.get());
     Property::Get(key, gateway, "");
 
     int type = getIpType(gateway);
     if (type != AF_INET && type != AF_INET6) {
       return EAFNOSUPPORT;
     }
 
     if (type == AF_INET6) {
--- a/dom/wifi/WifiUtils.cpp
+++ b/dom/wifi/WifiUtils.cpp
@@ -4,16 +4,17 @@
  * 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 "WifiUtils.h"
 #include <dlfcn.h>
 #include <errno.h>
 #include <cutils/properties.h>
 #include "prinit.h"
+#include "mozilla/Snprintf.h"
 #include "js/CharacterEncoding.h"
 
 using namespace mozilla::dom;
 
 #define BUFFER_SIZE        4096
 #define COMMAND_SIZE       256
 
 // Intentionally not trying to dlclose() this handle. That's playing
@@ -363,20 +364,20 @@ public:
     return wifi_stop_supplicant(arg);
   }
 
   DEFINE_DLFUNC(wifi_command, int32_t, const char*, char*, size_t*)
   int32_t do_wifi_command(const char* iface, const char* cmd, char* buf, size_t* len) {
     char command[COMMAND_SIZE];
     if (!strcmp(iface, "p2p0")) {
       // Commands for p2p0 interface don't need prefix
-      PR_snprintf(command, COMMAND_SIZE, "%s", cmd);
+      snprintf_literal(command, "%s", cmd);
     }
     else {
-      PR_snprintf(command, COMMAND_SIZE, "IFNAME=%s %s", iface, cmd);
+      snprintf_literal(command, "IFNAME=%s %s", iface, cmd);
     }
     USE_DLFUNC(wifi_command)
     return wifi_command(command, buf, len);
   }
 };
 
 // Concrete class to use to access the wpa supplicant.
 WpaSupplicant::WpaSupplicant()