Bug 1060419 - make nsChromeRegistry.cpp use Printf.h, r?froydnj draft
authorTom Tromey <tom@tromey.com>
Fri, 09 Dec 2016 09:58:57 -1000
changeset 486143 da86bf49feb6bb10a0c7cce0f77e6acbbdfe960e
parent 486142 567238bf274382cbebea4519e901f84349464fed
child 486144 f1893ac08710b26bf29b5e1ac9edb52976737af4
push id45909
push userbmo:ttromey@mozilla.com
push dateFri, 17 Feb 2017 16:00:11 +0000
reviewersfroydnj
bugs1060419
milestone54.0a1
Bug 1060419 - make nsChromeRegistry.cpp use Printf.h, r?froydnj MozReview-Commit-ID: AMewawTLaGl
chrome/nsChromeRegistry.cpp
chrome/nsChromeRegistry.h
--- a/chrome/nsChromeRegistry.cpp
+++ b/chrome/nsChromeRegistry.cpp
@@ -3,18 +3,16 @@
 /* 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 "nsChromeRegistry.h"
 #include "nsChromeRegistryChrome.h"
 #include "nsChromeRegistryContent.h"
 
-#include "prprf.h"
-
 #include "nsCOMPtr.h"
 #include "nsError.h"
 #include "nsEscape.h"
 #include "nsNetUtil.h"
 #include "nsString.h"
 #include "nsQueryObject.h"
 
 #include "mozilla/dom/URL.h"
@@ -24,16 +22,17 @@
 #include "nsIDOMLocation.h"
 #include "nsIDOMWindowCollection.h"
 #include "nsIDOMWindow.h"
 #include "nsIObserverService.h"
 #include "nsIPresShell.h"
 #include "nsIScriptError.h"
 #include "nsIWindowMediator.h"
 #include "nsIPrefService.h"
+#include "mozilla/Printf.h"
 #include "mozilla/StyleSheet.h"
 #include "mozilla/StyleSheetInlines.h"
 
 #ifdef ENABLE_INTL_API
 #include "unicode/uloc.h"
 #endif
 
 nsChromeRegistry* nsChromeRegistry::gChromeRegistry;
@@ -50,23 +49,23 @@ nsChromeRegistry::LogMessage(const char*
 {
   nsCOMPtr<nsIConsoleService> console 
     (do_GetService(NS_CONSOLESERVICE_CONTRACTID));
   if (!console)
     return;
 
   va_list args;
   va_start(args, aMsg);
-  char* formatted = PR_vsmprintf(aMsg, args);
+  char* formatted = mozilla::Vsmprintf(aMsg, args);
   va_end(args);
   if (!formatted)
     return;
 
   console->LogStringMessage(NS_ConvertUTF8toUTF16(formatted).get());
-  PR_smprintf_free(formatted);
+  mozilla::SmprintfFree(formatted);
 }
 
 void
 nsChromeRegistry::LogMessageWithContext(nsIURI* aURL, uint32_t aLineNumber, uint32_t flags,
                                         const char* aMsg, ...)
 {
   nsresult rv;
 
@@ -75,30 +74,30 @@ nsChromeRegistry::LogMessageWithContext(
 
   nsCOMPtr<nsIScriptError> error
     (do_CreateInstance(NS_SCRIPTERROR_CONTRACTID));
   if (!console || !error)
     return;
 
   va_list args;
   va_start(args, aMsg);
-  char* formatted = PR_vsmprintf(aMsg, args);
+  char* formatted = mozilla::Vsmprintf(aMsg, args);
   va_end(args);
   if (!formatted)
     return;
 
   nsCString spec;
   if (aURL)
     aURL->GetSpec(spec);
 
   rv = error->Init(NS_ConvertUTF8toUTF16(formatted),
                    NS_ConvertUTF8toUTF16(spec),
                    EmptyString(),
                    aLineNumber, 0, flags, "chrome registration");
-  PR_smprintf_free(formatted);
+  mozilla::SmprintfFree(formatted);
 
   if (NS_FAILED(rv))
     return;
 
   console->LogMessage(error);
 }
 
 nsChromeRegistry::~nsChromeRegistry()
--- a/chrome/nsChromeRegistry.h
+++ b/chrome/nsChromeRegistry.h
@@ -78,19 +78,21 @@ protected:
 
   void FlushSkinCaches();
   void FlushAllCaches();
 
   // Update the selected locale used by the chrome registry, and fire a
   // notification about this change
   virtual nsresult UpdateSelectedLocale() = 0;
 
-  static void LogMessage(const char* aMsg, ...);
+  static void LogMessage(const char* aMsg, ...)
+    MOZ_FORMAT_PRINTF(1, 2);
   static void LogMessageWithContext(nsIURI* aURL, uint32_t aLineNumber, uint32_t flags,
-                                    const char* aMsg, ...);
+                                    const char* aMsg, ...)
+    MOZ_FORMAT_PRINTF(4, 5);
 
   virtual nsIURI* GetBaseURIFromPackage(const nsCString& aPackage,
                                         const nsCString& aProvider,
                                         const nsCString& aPath) = 0;
   virtual nsresult GetFlagsFromPackage(const nsCString& aPackage,
                                        uint32_t* aFlags) = 0;
 
   nsresult SelectLocaleFromPref(nsIPrefBranch* prefs);