Bug 1334286 - use MOZ_FORMAT_PRINTF in DMD; r?njn draft
authorTom Tromey <tom@tromey.com>
Fri, 21 Apr 2017 15:54:05 -0600
changeset 568839 7b8afe4b9d1ee3be5cc01d05c643780a383b228b
parent 568821 aee0ea9d79a42a0bac6fc5afd23b1f2172f973ab
child 568990 61de1f7972eaac2c0ce582a4dc9129dcc229f8ff
push id55995
push userbmo:ttromey@mozilla.com
push dateWed, 26 Apr 2017 16:49:02 +0000
reviewersnjn
bugs1334286
milestone55.0a1
Bug 1334286 - use MOZ_FORMAT_PRINTF in DMD; r?njn Add MOZ_FORMAT_PRINTF to the appropriate spots in DMD and fix up the one (trivial) error that this pointed out. MozReview-Commit-ID: LS0UWV5YRoM
memory/replace/dmd/DMD.cpp
memory/replace/dmd/DMD.h
--- a/memory/replace/dmd/DMD.cpp
+++ b/memory/replace/dmd/DMD.cpp
@@ -90,16 +90,17 @@ static DMDBridge* gDMDBridge;
 static DMDFuncs gDMDFuncs;
 
 DMDFuncs*
 DMDBridge::GetDMDFuncs()
 {
   return &gDMDFuncs;
 }
 
+MOZ_FORMAT_PRINTF(1, 2)
 inline void
 StatusMsg(const char* aFmt, ...)
 {
   va_list ap;
   va_start(ap, aFmt);
   gDMDFuncs.StatusMsg(aFmt, ap);
   va_end(ap);
 }
@@ -1580,17 +1581,17 @@ Init(const malloc_table_t* aMallocTable)
 #endif
 
   // DMD is controlled by the |DMD| environment variable.
   const char* e = getenv("DMD");
 
   if (e) {
     StatusMsg("$DMD = '%s'\n", e);
   } else {
-    StatusMsg("$DMD is undefined\n", e);
+    StatusMsg("$DMD is undefined\n");
   }
 
   // Parse $DMD env var.
   gOptions = InfallibleAllocPolicy::new_<Options>(e);
 
 #ifdef XP_MACOSX
   // On Mac OS X we need to call StackWalkInitCriticalAddress() very early
   // (prior to the creation of any mutexes, apparently) otherwise we can get
--- a/memory/replace/dmd/DMD.h
+++ b/memory/replace/dmd/DMD.h
@@ -45,17 +45,17 @@ struct DMDFuncs
   virtual void ReportOnAlloc(const void*);
 
   virtual void ClearReports();
 
   virtual void Analyze(UniquePtr<JSONWriteFunc>);
 
   virtual void SizeOf(Sizes*);
 
-  virtual void StatusMsg(const char*, va_list);
+  virtual void StatusMsg(const char*, va_list) MOZ_FORMAT_PRINTF(2, 0);
 
   virtual void ResetEverything(const char*);
 
 #ifndef REPLACE_MALLOC_IMPL
   // We deliberately don't use ReplaceMalloc::GetDMDFuncs here, because if we
   // did, the following would happen.
   // - The code footprint of each call to Get() larger as GetDMDFuncs ends
   //   up inlined.
@@ -267,16 +267,17 @@ SizeOf(Sizes* aSizes)
 {
   DMDFuncs* funcs = DMDFuncs::Get();
   if (funcs) {
     funcs->SizeOf(aSizes);
   }
 }
 
 // Prints a status message prefixed with "DMD[<pid>]". Use sparingly.
+MOZ_FORMAT_PRINTF(1, 2)
 inline void
 StatusMsg(const char* aFmt, ...)
 {
   DMDFuncs* funcs = DMDFuncs::Get();
   if (funcs) {
     va_list ap;
     va_start(ap, aFmt);
     funcs->StatusMsg(aFmt, ap);