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
--- 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);