Bug 965022 - Use MOZ_FORMAT_PRINTF for [f]printf_stderr, and fix incorrect usages. r=jrmuizel
☠☠ backed out by 894b7372561d ☠ ☠
authorBotond Ballo <botond@mozilla.com>
Mon, 25 Aug 2014 18:28:25 -0400
changeset 201734 24251d4da0191cc8121b9c693c17aaf35701e717
parent 201733 a34ae046c94729021676108c4c69e04fcaa3c3aa
child 201735 7f68752ffe1e6990b04dccf1b05e87df493adbad
push id27380
push userkwierso@gmail.com
push dateWed, 27 Aug 2014 00:50:11 +0000
treeherdermozilla-central@83289be2cd12 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs965022
milestone34.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 965022 - Use MOZ_FORMAT_PRINTF for [f]printf_stderr, and fix incorrect usages. r=jrmuizel
gfx/gl/GLBlitHelper.cpp
gfx/gl/GLContext.cpp
gfx/gl/GLContextProviderGLX.cpp
ipc/glue/MessageChannel.cpp
layout/style/AnimationCommon.cpp
xpcom/glue/nsDebug.h
--- a/gfx/gl/GLBlitHelper.cpp
+++ b/gfx/gl/GLBlitHelper.cpp
@@ -828,17 +828,17 @@ GLBlitHelper::BlitTextureToFramebuffer(G
         mGL->BindFB(destFB);
     }
 
     // Does destructive things to (only!) what we just saved above.
     bool good = UseTexQuadProgram(type, srcSize);
     if (!good) {
         // We're up against the wall, so bail.
         // This should really be MOZ_CRASH(why) or MOZ_RUNTIME_ASSERT(good).
-        printf_stderr("[%s:%d] Fatal Error: Failed to prepare to blit texture->framebuffer.\n");
+        printf_stderr("Fatal Error: Failed to prepare to blit texture->framebuffer.\n");
         MOZ_CRASH();
     }
     mGL->fDrawArrays(LOCAL_GL_TRIANGLE_STRIP, 0, 4);
 }
 
 void
 GLBlitHelper::BlitFramebufferToTexture(GLuint srcFB, GLuint destTex,
                                        const gfx::IntSize& srcSize,
--- a/gfx/gl/GLContext.cpp
+++ b/gfx/gl/GLContext.cpp
@@ -24,16 +24,17 @@
 #include "prlink.h"
 #include "ScopedGLHelpers.h"
 #include "SharedSurfaceGL.h"
 #include "SurfaceStream.h"
 #include "GfxTexturesReporter.h"
 #include "TextureGarbageBin.h"
 #include "gfx2DGlue.h"
 #include "gfxPrefs.h"
+#include "mozilla/IntegerPrintfMacros.h"
 
 #include "OGLShaderProgram.h" // for ShaderProgramType
 
 #include "mozilla/DebugOnly.h"
 
 #ifdef XP_MACOSX
 #include <CoreServices/CoreServices.h>
 #include "gfxColor.h"
@@ -1266,17 +1267,17 @@ GLContext::DebugCallback(GLenum source,
     case LOCAL_GL_DEBUG_SEVERITY_NOTIFICATION:
         sevStr = NS_LITERAL_CSTRING("SEVERITY_NOTIFICATION");
         break;
     default:
         sevStr = nsPrintfCString("<severity 0x%04x>", severity);
         break;
     }
 
-    printf_stderr("[KHR_debug: 0x%x] ID %u: %s %s %s:\n    %s",
+    printf_stderr("[KHR_debug: 0x%" PRIuPTR "] ID %u: %s %s %s:\n    %s",
                   (uintptr_t)this,
                   id,
                   sourceStr.BeginReading(),
                   typeStr.BeginReading(),
                   sevStr.BeginReading(),
                   message);
 }
 
--- a/gfx/gl/GLContextProviderGLX.cpp
+++ b/gfx/gl/GLContextProviderGLX.cpp
@@ -476,17 +476,17 @@ GLXLibrary::BeforeGLXCall()
 void
 GLXLibrary::AfterGLXCall()
 {
     if (mDebug) {
         FinishX(DefaultXDisplay());
         if (sErrorEvent.mError.error_code) {
             char buffer[2048];
             XGetErrorText(DefaultXDisplay(), sErrorEvent.mError.error_code, buffer, sizeof(buffer));
-            printf_stderr("X ERROR: %s (%i) - Request: %i.%i, Serial: %i",
+            printf_stderr("X ERROR: %s (%i) - Request: %i.%i, Serial: %lu",
                           buffer,
                           sErrorEvent.mError.error_code,
                           sErrorEvent.mError.request_code,
                           sErrorEvent.mError.minor_code,
                           sErrorEvent.mError.serial);
             NS_ABORT();
         }
         XSetErrorHandler(sOldErrorHandler);
--- a/ipc/glue/MessageChannel.cpp
+++ b/ipc/glue/MessageChannel.cpp
@@ -1800,23 +1800,23 @@ MessageChannel::DebugAbort(const char* f
     printf_stderr("###!!! [MessageChannel][%s][%s:%d] "
                   "Assertion (%s) failed.  %s %s\n",
                   mSide == ChildSide ? "Child" : "Parent",
                   file, line, cond,
                   why,
                   reply ? "(reply)" : "");
     // technically we need the mutex for this, but we're dying anyway
     DumpInterruptStack("  ");
-    printf_stderr("  remote Interrupt stack guess: %lu\n",
+    printf_stderr("  remote Interrupt stack guess: %" PRIuSIZE "\n",
                   mRemoteStackDepthGuess);
-    printf_stderr("  deferred stack size: %lu\n",
+    printf_stderr("  deferred stack size: %" PRIuSIZE "\n",
                   mDeferred.size());
-    printf_stderr("  out-of-turn Interrupt replies stack size: %lu\n",
+    printf_stderr("  out-of-turn Interrupt replies stack size: %" PRIuSIZE "\n",
                   mOutOfTurnReplies.size());
-    printf_stderr("  Pending queue size: %lu, front to back:\n",
+    printf_stderr("  Pending queue size: %" PRIuSIZE ", front to back:\n",
                   mPending.size());
 
     MessageQueue pending = mPending;
     while (!pending.empty()) {
         printf_stderr("    [ %s%s ]\n",
                       pending.front().is_interrupt() ? "intr" :
                       (pending.front().is_sync() ? "sync" : "async"),
                       pending.front().is_reply() ? "reply" : "");
--- a/layout/style/AnimationCommon.cpp
+++ b/layout/style/AnimationCommon.cpp
@@ -446,17 +446,17 @@ AnimationPlayerCollection::LogAsyncAnima
     if (id) {
       aMessage.AppendLiteral(" with id '");
       aMessage.Append(nsAtomCString(aContent->GetID()));
       aMessage.Append('\'');
     }
     aMessage.Append(']');
   }
   aMessage.Append('\n');
-  printf_stderr(aMessage.get());
+  printf_stderr("%s", aMessage.get());
 }
 
 /*static*/ void
 AnimationPlayerCollection::PropertyDtor(void *aObject, nsIAtom *aPropertyName,
                                          void *aPropertyValue, void *aData)
 {
   AnimationPlayerCollection* collection =
     static_cast<AnimationPlayerCollection*>(aPropertyValue);
--- a/xpcom/glue/nsDebug.h
+++ b/xpcom/glue/nsDebug.h
@@ -397,22 +397,23 @@ typedef void (*StderrCallback)(const cha
  * be linked with a static CRT (-MT) even when it's not. This means that we
  * cannot link to data exports from the CRT, only function exports. So,
  * instead of referencing "stderr" directly, use fdopen.
  */
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-NS_COM_GLUE void printf_stderr(const char* aFmt, ...);
+NS_COM_GLUE void printf_stderr(const char* aFmt, ...) MOZ_FORMAT_PRINTF(1, 2);
 
 NS_COM_GLUE void vprintf_stderr(const char* aFmt, va_list aArgs);
 
 // fprintf with special handling for stderr to print to the console
-NS_COM_GLUE void fprintf_stderr(FILE* aFile, const char* aFmt, ...);
+NS_COM_GLUE void fprintf_stderr(FILE* aFile, const char* aFmt, ...)
+    MOZ_FORMAT_PRINTF(2, 3);
 
 // used by the profiler to log stderr in the profiler for more
 // advanced performance debugging and display/layers visualization.
 NS_COM_GLUE void set_stderr_callback(StderrCallback aCallback);
 
 #ifdef __cplusplus
 }
 #endif