Bug 1197331 - remove PR_snprintf calls in miscellaneous directories. r=nfroyd
authorIgor <palmieri.igor@gmail.com>
Thu, 04 Aug 2016 16:41:00 +0200
changeset 308405 4321017e1f834414444770f1a4b2a1be972ac2f9
parent 308404 72e5792fe990871f53f6ccf8cf0f211e25026e7f
child 308406 85105a2f62d24ffe97e37ae70df08f6b23fe5e0f
push id30537
push userphilringnalda@gmail.com
push dateSun, 07 Aug 2016 06:34:58 +0000
treeherdermozilla-central@70948f120f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnfroyd
bugs1197331
milestone51.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 1197331 - remove PR_snprintf calls in miscellaneous directories. r=nfroyd
accessible/atk/AccessibleWrap.cpp
browser/components/shell/nsGNOMEShellService.cpp
image/decoders/icon/nsIconURI.cpp
toolkit/components/url-classifier/nsUrlClassifierUtils.cpp
tools/profiler/core/ProfilerMarkers.cpp
widget/xremoteclient/XRemoteClient.cpp
xpfe/appshell/nsXULWindow.cpp
--- a/accessible/atk/AccessibleWrap.cpp
+++ b/accessible/atk/AccessibleWrap.cpp
@@ -14,25 +14,25 @@
 #include "OuterDocAccessible.h"
 #include "ProxyAccessible.h"
 #include "RootAccessible.h"
 #include "TableAccessible.h"
 #include "TableCellAccessible.h"
 #include "nsMai.h"
 #include "nsMaiHyperlink.h"
 #include "nsString.h"
-#include "prprf.h"
 #include "nsStateMap.h"
 #include "mozilla/a11y/Platform.h"
 #include "Relation.h"
 #include "RootAccessible.h"
 #include "States.h"
 #include "nsISimpleEnumerator.h"
 
 #include "mozilla/ArrayUtils.h"
+#include "mozilla/Snprintf.h"
 #include "nsXPCOMStrings.h"
 #include "nsComponentManagerUtils.h"
 #include "nsIPersistentProperties2.h"
 
 using namespace mozilla;
 using namespace mozilla::a11y;
 
 MaiAtkObject::EAvailableAtkSignals MaiAtkObject::gAvailableAtkSignals =
@@ -431,18 +431,17 @@ GetMaiAtkType(uint16_t interfacesBits)
 static const char*
 GetUniqueMaiAtkTypeName(uint16_t interfacesBits)
 {
 #define MAI_ATK_TYPE_NAME_LEN (30)     /* 10+sizeof(uint16_t)*8/4+1 < 30 */
 
     static gchar namePrefix[] = "MaiAtkType";   /* size = 10 */
     static gchar name[MAI_ATK_TYPE_NAME_LEN + 1];
 
-    PR_snprintf(name, MAI_ATK_TYPE_NAME_LEN, "%s%x", namePrefix,
-                interfacesBits);
+    snprintf_literal(name, "%s%x", namePrefix, interfacesBits);
     name[MAI_ATK_TYPE_NAME_LEN] = '\0';
 
     return name;
 }
 
 bool
 AccessibleWrap::IsValidObject()
 {
--- a/browser/components/shell/nsGNOMEShellService.cpp
+++ b/browser/components/shell/nsGNOMEShellService.cpp
@@ -22,17 +22,17 @@
 #include "nsIOutputStream.h"
 #include "nsIProcess.h"
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsIDOMHTMLImageElement.h"
 #include "nsIImageLoadingContent.h"
 #include "imgIRequest.h"
 #include "imgIContainer.h"
-#include "prprf.h"
+#include "mozilla/Snprintf.h"
 #if defined(MOZ_WIDGET_GTK)
 #include "nsIImageToPixbuf.h"
 #endif
 #include "nsXULAppAPI.h"
 
 #include <glib.h>
 #include <glib-object.h>
 #include <gtk/gtk.h>
@@ -511,17 +511,17 @@ ColorToCString(uint32_t aColor, nsCStrin
   char *buf = aResult.BeginWriting(13);
   if (!buf)
     return;
 
   uint16_t red = COLOR_8_TO_16_BIT((aColor >> 16) & 0xff);
   uint16_t green = COLOR_8_TO_16_BIT((aColor >> 8) & 0xff);
   uint16_t blue = COLOR_8_TO_16_BIT(aColor & 0xff);
 
-  PR_snprintf(buf, 14, "#%04x%04x%04x", red, green, blue);
+  snprintf(buf, 14, "#%04x%04x%04x", red, green, blue);
 }
 
 NS_IMETHODIMP
 nsGNOMEShellService::SetDesktopBackgroundColor(uint32_t aColor)
 {
   NS_ASSERTION(aColor <= 0xffffff, "aColor has extra bits");
   nsAutoCString colorString;
   ColorToCString(aColor, colorString);
--- a/image/decoders/icon/nsIconURI.cpp
+++ b/image/decoders/icon/nsIconURI.cpp
@@ -4,21 +4,21 @@
  * 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 "nsIconURI.h"
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/ipc/URIUtils.h"
+#include "mozilla/Snprintf.h"
 
 #include "nsIIOService.h"
 #include "nsIURL.h"
 #include "nsNetUtil.h"
-#include "prprf.h"
 #include "plstr.h"
 #include <stdlib.h>
 
 using namespace mozilla;
 using namespace mozilla::ipc;
 
 #define DEFAULT_IMAGE_SIZE 16
 
@@ -89,17 +89,17 @@ nsMozIconURI::GetSpec(nsACString& aSpec)
     aSpec += mFileName;
   }
 
   aSpec += "?size=";
   if (mIconSize >= 0) {
     aSpec += kSizeStrings[mIconSize];
   } else {
     char buf[20];
-    PR_snprintf(buf, sizeof(buf), "%d", mSize);
+    snprintf_literal(buf, "%d", mSize);
     aSpec.Append(buf);
   }
 
   if (mIconState >= 0) {
     aSpec += "&state=";
     aSpec += kStateStrings[mIconState];
   }
 
--- a/toolkit/components/url-classifier/nsUrlClassifierUtils.cpp
+++ b/toolkit/components/url-classifier/nsUrlClassifierUtils.cpp
@@ -4,19 +4,19 @@
 
 #include "nsEscape.h"
 #include "nsString.h"
 #include "nsIURI.h"
 #include "nsUrlClassifierUtils.h"
 #include "nsTArray.h"
 #include "nsReadableUtils.h"
 #include "plbase64.h"
-#include "prprf.h"
 #include "nsPrintfCString.h"
 #include "safebrowsing.pb.h"
+#include "mozilla/Snprintf.h"
 
 #define DEFAULT_PROTOCOL_VERSION "2.2"
 
 static char int_to_hex_digit(int32_t i)
 {
   NS_ASSERTION((i >= 0) && (i <= 15), "int too big in int_to_hex_digit");
   return static_cast<char>(((i < 10) ? (i + '0') : ((i - 10) + 'A')));
 }
@@ -479,17 +479,17 @@ nsUrlClassifierUtils::CanonicalNum(const
       return;
     }
   } else {
     return;
   }
 
   while (bytes--) {
     char buf[20];
-    PR_snprintf(buf, sizeof(buf), "%u", val & 0xff);
+    snprintf_literal(buf, "%u", val & 0xff);
     if (_retval.IsEmpty()) {
       _retval.Assign(buf);
     } else {
       _retval = nsDependentCString(buf) + NS_LITERAL_CSTRING(".") + _retval;
     }
     val >>= 8;
   }
 }
--- a/tools/profiler/core/ProfilerMarkers.cpp
+++ b/tools/profiler/core/ProfilerMarkers.cpp
@@ -5,17 +5,17 @@
 
 #include "GeckoProfiler.h"
 #include "ProfilerBacktrace.h"
 #include "ProfilerMarkers.h"
 #include "SyncProfile.h"
 #ifndef SPS_STANDALONE
 #include "gfxASurface.h"
 #include "Layers.h"
-#include "prprf.h"
+#include "mozilla/Snprintf.h"
 #endif
 
 ProfilerMarkerPayload::ProfilerMarkerPayload(ProfilerBacktrace* aStack)
   : mStack(aStack)
 {}
 
 ProfilerMarkerPayload::ProfilerMarkerPayload(const mozilla::TimeStamp& aStartTime,
                                              const mozilla::TimeStamp& aEndTime,
@@ -169,17 +169,17 @@ LayerTranslationPayload::LayerTranslatio
 }
 
 void
 LayerTranslationPayload::StreamPayload(SpliceableJSONWriter& aWriter,
                                        UniqueStacks& aUniqueStacks)
 {
   const size_t bufferSize = 32;
   char buffer[bufferSize];
-  PR_snprintf(buffer, bufferSize, "%p", mLayer);
+  snprintf_literal(buffer, "%p", mLayer);
 
   aWriter.StringProperty("layer", buffer);
   aWriter.IntProperty("x", mPoint.x);
   aWriter.IntProperty("y", mPoint.y);
   aWriter.StringProperty("category", "LayerTranslation");
 }
 
 TouchDataPayload::TouchDataPayload(const mozilla::ScreenIntPoint& aPoint)
--- a/widget/xremoteclient/XRemoteClient.cpp
+++ b/widget/xremoteclient/XRemoteClient.cpp
@@ -2,19 +2,19 @@
 /* vim:expandtab:shiftwidth=2:tabstop=8:
  */
 /* vim:set ts=8 sw=2 et cindent: */
 /* 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 "mozilla/ArrayUtils.h"
+#include "mozilla/Snprintf.h"
 #include "XRemoteClient.h"
 #include "prmem.h"
-#include "prprf.h"
 #include "plstr.h"
 #include "prsystem.h"
 #include "mozilla/Logging.h"
 #include "prenv.h"
 #include "prdtoa.h"
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
@@ -288,17 +288,17 @@ XRemoteClient::GetLock(Window aWindow, b
   *aDestroyed = false;
 
   nsresult rv = NS_OK;
 
   if (!mLockData) {
     
     char pidstr[32];
     char sysinfobuf[SYS_INFO_BUFFER_LENGTH];
-    PR_snprintf(pidstr, sizeof(pidstr), "pid%d@", getpid());
+    snprintf_literal(pidstr, "pid%d@", getpid());
     PRStatus status;
     status = PR_GetSystemInfo(PR_SI_HOSTNAME, sysinfobuf,
 			      SYS_INFO_BUFFER_LENGTH);
     if (status != PR_SUCCESS) {
       return NS_ERROR_FAILURE;
     }
     
     // allocate enough space for the string plus the terminating
--- a/xpfe/appshell/nsXULWindow.cpp
+++ b/xpfe/appshell/nsXULWindow.cpp
@@ -9,20 +9,20 @@
 // Local includes
 #include "nsXULWindow.h"
 #include <algorithm>
 
 // Helper classes
 #include "nsPrintfCString.h"
 #include "nsString.h"
 #include "nsWidgetsCID.h"
-#include "prprf.h"
 #include "nsThreadUtils.h"
 #include "nsNetCID.h"
 #include "nsQueryObject.h"
+#include "mozilla/Snprintf.h"
 
 //Interfaces needed to be included
 #include "nsIAppShell.h"
 #include "nsIAppShellService.h"
 #include "nsIServiceManager.h"
 #include "nsIContentViewer.h"
 #include "nsIDocument.h"
 #include "nsIDOMDocument.h"
@@ -1596,48 +1596,44 @@ NS_IMETHODIMP nsXULWindow::SavePersisten
     docShellElement->GetId(windowElementId);
   }
 
   bool shouldPersist = !isFullscreen && ownerXULDoc;
   ErrorResult rv;
   // (only for size elements which are persisted)
   if ((mPersistentAttributesDirty & PAD_POSITION) && gotRestoredBounds) {
     if (persistString.Find("screenX") >= 0) {
-      PR_snprintf(sizeBuf, sizeof(sizeBuf), "%d",
-                  NSToIntRound(rect.x / posScale.scale));
+      snprintf_literal(sizeBuf, "%d", NSToIntRound(rect.x / posScale.scale));
       sizeString.AssignWithConversion(sizeBuf);
       docShellElement->SetAttribute(SCREENX_ATTRIBUTE, sizeString, rv);
       if (shouldPersist) {
         ownerXULDoc->Persist(windowElementId, SCREENX_ATTRIBUTE);
       }
     }
     if (persistString.Find("screenY") >= 0) {
-      PR_snprintf(sizeBuf, sizeof(sizeBuf), "%d",
-                  NSToIntRound(rect.y / posScale.scale));
+      snprintf_literal(sizeBuf, "%d", NSToIntRound(rect.y / posScale.scale));
       sizeString.AssignWithConversion(sizeBuf);
       docShellElement->SetAttribute(SCREENY_ATTRIBUTE, sizeString, rv);
       if (shouldPersist) {
         ownerXULDoc->Persist(windowElementId, SCREENY_ATTRIBUTE);
       }
     }
   }
 
   if ((mPersistentAttributesDirty & PAD_SIZE) && gotRestoredBounds) {
     if (persistString.Find("width") >= 0) {
-      PR_snprintf(sizeBuf, sizeof(sizeBuf), "%d",
-                  NSToIntRound(rect.width / sizeScale.scale));
+      snprintf_literal(sizeBuf, "%d", NSToIntRound(rect.width / sizeScale.scale));
       sizeString.AssignWithConversion(sizeBuf);
       docShellElement->SetAttribute(WIDTH_ATTRIBUTE, sizeString, rv);
       if (shouldPersist) {
         ownerXULDoc->Persist(windowElementId, WIDTH_ATTRIBUTE);
       }
     }
     if (persistString.Find("height") >= 0) {
-      PR_snprintf(sizeBuf, sizeof(sizeBuf), "%d",
-                  NSToIntRound(rect.height / sizeScale.scale));
+      snprintf_literal(sizeBuf, "%d", NSToIntRound(rect.height / sizeScale.scale));
       sizeString.AssignWithConversion(sizeBuf);
       docShellElement->SetAttribute(HEIGHT_ATTRIBUTE, sizeString, rv);
       if (shouldPersist) {
         ownerXULDoc->Persist(windowElementId, HEIGHT_ATTRIBUTE);
       }
     }
   }
 
@@ -1656,17 +1652,17 @@ NS_IMETHODIMP nsXULWindow::SavePersisten
         ownerXULDoc->Persist(windowElementId, MODE_ATTRIBUTE);
       }
     }
     if (persistString.Find("zlevel") >= 0) {
       uint32_t zLevel;
       nsCOMPtr<nsIWindowMediator> mediator(do_GetService(NS_WINDOWMEDIATOR_CONTRACTID));
       if (mediator) {
         mediator->GetZLevel(this, &zLevel);
-        PR_snprintf(sizeBuf, sizeof(sizeBuf), "%lu", (unsigned long)zLevel);
+        snprintf_literal(sizeBuf, "%" PRIu32, zLevel);
         sizeString.AssignWithConversion(sizeBuf);
         docShellElement->SetAttribute(ZLEVEL_ATTRIBUTE, sizeString, rv);
         if (shouldPersist) {
           ownerXULDoc->Persist(windowElementId, ZLEVEL_ATTRIBUTE);
         }
       }
     }
   }