Bug 1237831 - Use a non-format argument in LogMessageToConsole. r=jst
authorArthur Edelstein <arthuredelstein@gmail.com>
Mon, 04 Jan 2016 09:32:21 -0800
changeset 282305 2abc599b04648bb5de1473e5629270a539b0e1e3
parent 282304 7cfbfa3139b409532c1066682546d7fead2d4a65
child 282306 3808d0b70b4f823908162e11fbf2cd74d4b7c53e
push id29955
push userkwierso@gmail.com
push dateFri, 29 Jan 2016 21:12:10 +0000
treeherdermozilla-central@08eddf3af531 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjst
bugs1237831
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 1237831 - Use a non-format argument in LogMessageToConsole. r=jst
dom/base/nsContentUtils.cpp
dom/base/nsContentUtils.h
dom/workers/ServiceWorkerRegistrar.cpp
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -6,17 +6,16 @@
 
 /* A namespace class for static layout utilities. */
 
 #include "nsContentUtils.h"
 
 #include <algorithm>
 #include <math.h>
 
-#include "prprf.h"
 #include "DecoderTraits.h"
 #include "harfbuzz/hb.h"
 #include "imgICache.h"
 #include "imgIContainer.h"
 #include "imgINotificationObserver.h"
 #include "imgLoader.h"
 #include "imgRequestProxy.h"
 #include "jsapi.h"
@@ -3520,35 +3519,25 @@ nsContentUtils::ReportToConsoleNonLocali
                                      aErrorFlags, aCategory,
                                      innerWindowID);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return sConsoleService->LogMessage(errorObject);
 }
 
 void
-nsContentUtils::LogMessageToConsole(const char* aMsg, ...)
+nsContentUtils::LogMessageToConsole(const char* aMsg)
 {
   if (!sConsoleService) { // only need to bother null-checking here
     CallGetService(NS_CONSOLESERVICE_CONTRACTID, &sConsoleService);
     if (!sConsoleService) {
       return;
     }
   }
-
-  va_list args;
-  va_start(args, aMsg);
-  char* formatted = PR_vsmprintf(aMsg, args);
-  va_end(args);
-  if (!formatted) {
-    return;
-  }
-
-  sConsoleService->LogStringMessage(NS_ConvertUTF8toUTF16(formatted).get());
-  PR_smprintf_free(formatted);
+  sConsoleService->LogStringMessage(NS_ConvertUTF8toUTF16(aMsg).get());
 }
 
 bool
 nsContentUtils::IsChromeDoc(nsIDocument *aDocument)
 {
   if (!aDocument) {
     return false;
   }
--- a/dom/base/nsContentUtils.h
+++ b/dom/base/nsContentUtils.h
@@ -888,18 +888,18 @@ public:
                                   const char16_t **aParams = nullptr,
                                   uint32_t aParamsLength = 0,
                                   nsIURI* aURI = nullptr,
                                   const nsAFlatString& aSourceLine
                                     = EmptyString(),
                                   uint32_t aLineNumber = 0,
                                   uint32_t aColumnNumber = 0);
 
-  static void LogMessageToConsole(const char* aMsg, ...);
-  
+  static void LogMessageToConsole(const char* aMsg);
+
   /**
    * Get the localized string named |aKey| in properties file |aFile|.
    */
   static nsresult GetLocalizedString(PropertiesFile aFile,
                                      const char* aKey,
                                      nsXPIDLString& aResult);
 
   /**
--- a/dom/workers/ServiceWorkerRegistrar.cpp
+++ b/dom/workers/ServiceWorkerRegistrar.cpp
@@ -305,18 +305,18 @@ ServiceWorkerRegistrar::ReadData()
   nsAutoCString version;
   bool hasMoreLines;
   rv = lineInputStream->ReadLine(version, &hasMoreLines);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   if (!IsSupportedVersion(version)) {
-    nsContentUtils::LogMessageToConsole(
-      "Unsupported service worker registrar version: %s", version.get());
+    nsContentUtils::LogMessageToConsole(nsPrintfCString(
+      "Unsupported service worker registrar version: %s", version.get()).get());
     return NS_ERROR_FAILURE;
   }
 
   bool overwrite = false;
   while (hasMoreLines) {
     ServiceWorkerRegistrationData* entry = mData.AppendElement();
 
 #define GET_LINE(x)                                   \