Bug 1388789 - make va_list nsTextFormatter private; r=froydnj
authorTom Tromey <tom@tromey.com>
Thu, 31 Aug 2017 15:21:37 -0600
changeset 431515 e9844f691218261440035e835748826b64c7ca38
parent 431514 81457c20869561533141c80aaf762a39ecfedbda
child 431516 ec3f626df9d1fde0095c0df104a7f4e7863ca5ff
push id7784
push userryanvm@gmail.com
push dateThu, 21 Sep 2017 00:40:13 +0000
treeherdermozilla-beta@efff4f307675 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1388789
milestone57.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 1388789 - make va_list nsTextFormatter private; r=froydnj The runtime type-checking rewrite of nsTextFormatter will not support va_list uses. So, make these functions private and fix the sole user. MozReview-Commit-ID: IBWALVzIcHC
toolkit/components/commandlines/nsCommandLine.cpp
xpcom/string/nsTextFormatter.h
--- a/toolkit/components/commandlines/nsCommandLine.cpp
+++ b/toolkit/components/commandlines/nsCommandLine.cpp
@@ -478,24 +478,22 @@ nsCommandLine::Init(int32_t argc, const 
     appendArg(curarg);
   }
 
   mState = aState;
 
   return NS_OK;
 }
 
+template<typename ...T>
 static void
-LogConsoleMessage(const char16_t* fmt, ...)
+LogConsoleMessage(const char16_t* fmt, T... args)
 {
-  va_list args;
-  va_start(args, fmt);
   nsString msg;
-  nsTextFormatter::vssprintf(msg, fmt, args);
-  va_end(args);
+  nsTextFormatter::ssprintf(msg, fmt, args...);
 
   nsCOMPtr<nsIConsoleService> cs = do_GetService("@mozilla.org/consoleservice;1");
   if (cs)
     cs->LogStringMessage(msg.get());
 }
 
 nsresult
 nsCommandLine::EnumerateHandlers(EnumerateHandlersCallback aCallback, void *aClosure)
--- a/xpcom/string/nsTextFormatter.h
+++ b/xpcom/string/nsTextFormatter.h
@@ -53,16 +53,18 @@ public:
                            const char16_t* aFmt, ...);
 
   /*
    * sprintf into an existing nsAString, overwriting any contents it already
    * has. Infallible.
    */
   static uint32_t ssprintf(nsAString& aOut, const char16_t* aFmt, ...);
 
+private:
+
   /*
    * va_list forms of the above.
    */
   static uint32_t vsnprintf(char16_t* aOut, uint32_t aOutLen, const char16_t* aFmt,
                             va_list aAp);
   static uint32_t vssprintf(nsAString& aOut, const char16_t* aFmt, va_list aAp);
 };