Bug 521677: Use fputs instead of printf/fprintf in a few cases, to fix "format not a string literal and no format arguments" build warnings. r=dbaron
authorDaniel Holbert <dholbert@cs.stanford.edu>
Mon, 19 Oct 2009 08:03:00 -0700
changeset 34247 872a2ad2af5d10869365085b60a0a98473504c5f
parent 34246 d3298de30066bb48d1c7babc544dcaaeec3ca7b3
child 34248 d490e107ea2ac3f53af4380d34421ea0ddd4504e
push id115
push userbmcbride@mozilla.com
push dateMon, 19 Oct 2009 23:27:00 +0000
reviewersdbaron
bugs521677
milestone1.9.3a1pre
Bug 521677: Use fputs instead of printf/fprintf in a few cases, to fix "format not a string literal and no format arguments" build warnings. r=dbaron
js/src/xpconnect/shell/xpcshell.cpp
js/src/xpconnect/tests/TestXPC.cpp
js/src/xpconnect/tests/components/xpctest_echo.cpp
toolkit/xre/nsSigHandlers.cpp
widget/src/gtk2/nsFilePicker.cpp
xpcom/base/nsTraceRefcntImpl.cpp
--- a/js/src/xpconnect/shell/xpcshell.cpp
+++ b/js/src/xpconnect/shell/xpcshell.cpp
@@ -262,17 +262,17 @@ GetLine(JSContext *cx, char *bufp, FILE 
         JS_free(cx, linep);
         bufp += strlen(bufp);
         *bufp++ = '\n';
         *bufp = '\0';
     } else
 #endif
     {
         char line[256];
-        fprintf(gOutFile, prompt);
+        fputs(prompt, gOutFile);
         fflush(gOutFile);
         if (!fgets(line, sizeof line, file))
             return JS_FALSE;
         strcpy(bufp, line);
     }
     return JS_TRUE;
 }
 
--- a/js/src/xpconnect/tests/TestXPC.cpp
+++ b/js/src/xpconnect/tests/TestXPC.cpp
@@ -125,17 +125,17 @@ static JSClass global_class = {
     "global", 0,
     JS_PropertyStub,  JS_PropertyStub,  JS_PropertyStub,  JS_PropertyStub,
     JS_EnumerateStub, JS_ResolveStub,   JS_ConvertStub,   nsnull
 };
 
 static void
 my_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
 {
-    printf(message);
+    fputs(message, stdout);
 }
 
 /***************************************************************************/
 // Foo class for used with some of the tests
 
 class nsTestXPCFoo : public nsITestXPCFoo2
 {
     NS_DECL_ISUPPORTS
@@ -299,17 +299,17 @@ MySecMan::CanAccess(PRUint32 aAction, ns
     }
 }
 
 /**********************************************/
 static void
 EvaluateScript(JSContext* jscontext, JSObject* glob, MySecMan* sm, MySecMan::Mode mode, const char* msg, const char* t, jsval &rval)
 {
     sm->SetMode(mode);
-    printf(msg);
+    fputs(msg, stdout);
     JSAutoRequest ar(jscontext);
     JS_EvaluateScript(jscontext, glob, t, strlen(t), "builtin", 1, &rval);
 }
 
 static void
 TestSecurityManager(JSContext* jscontext, JSObject* glob, nsIXPConnect* xpc)
 {
     jsval rval;
@@ -602,18 +602,17 @@ static void ShowXPCException()
         nsCOMPtr<nsIException> e;
         xpc->GetPendingException(getter_AddRefs(e));
         if(e)
         {
             char* str;
             rv = e->ToString(&str);
             if(NS_SUCCEEDED(rv) && str)
             {
-                printf(str);
-                printf("\n");
+                printf("%s\n", str);
                 nsMemory::Free(str);
 
                 nsresult res;
                 e->GetResult(&res);
                 if(res == NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS)
                 {
                     nsCOMPtr<nsISupports> data;
                     e->GetData(getter_AddRefs(data));
--- a/js/src/xpconnect/tests/components/xpctest_echo.cpp
+++ b/js/src/xpconnect/tests/components/xpctest_echo.cpp
@@ -478,17 +478,17 @@ xpctestEcho::PrintArgTypes(void)
             type = "string";
         else if (JSVAL_IS_DOUBLE(argv[i]))
             type = "double";
         else if (JSVAL_IS_INT(argv[i]))
             type = "int";
         else if (JSVAL_IS_VOID(argv[i]))
             type = "void";
 
-        printf(type);
+        fputs(type, stdout);
 
         if(i < argc-1)
             printf(", ");
     }
     printf("]\n");
     
     return NS_OK;
 }
--- a/toolkit/xre/nsSigHandlers.cpp
+++ b/toolkit/xre/nsSigHandlers.cpp
@@ -120,17 +120,17 @@ extern "C" {
 
 static void PrintStackFrame(void *aPC, void *aClosure)
 {
   char buf[1024];
   nsCodeAddressDetails details;
 
   NS_DescribeCodeAddress(aPC, &details);
   NS_FormatCodeAddressDetails(aPC, &details, buf, sizeof(buf));
-  fprintf(stdout, buf);
+  fputs(buf, stdout);
 }
 
 }
 
 void
 ah_crap_handler(int signum)
 {
   printf("\nProgram %s (pid = %d) received signal %d.\n",
--- a/widget/src/gtk2/nsFilePicker.cpp
+++ b/widget/src/gtk2/nsFilePicker.cpp
@@ -402,17 +402,17 @@ confirm_overwrite_file(GtkWidget *parent
 
   GtkWindow *parent_window = GTK_WINDOW(parent);
   GtkWidget *dialog;
   
   dialog = gtk_message_dialog_new(parent_window,
                                   GTK_DIALOG_DESTROY_WITH_PARENT,
                                   GTK_MESSAGE_QUESTION,
                                   GTK_BUTTONS_YES_NO,
-                                  NS_ConvertUTF16toUTF8(message).get());
+                                  "%s", NS_ConvertUTF16toUTF8(message).get());
   gtk_window_set_title(GTK_WINDOW(dialog), NS_ConvertUTF16toUTF8(title).get());
   if (parent_window && parent_window->group) {
     gtk_window_group_add_window(parent_window->group, GTK_WINDOW(dialog));
   }
 
   PRBool result = (RunDialog(GTK_DIALOG(dialog)) == GTK_RESPONSE_YES);
 
   gtk_widget_destroy(dialog);
--- a/xpcom/base/nsTraceRefcntImpl.cpp
+++ b/xpcom/base/nsTraceRefcntImpl.cpp
@@ -812,17 +812,17 @@ extern "C" {
 static void PrintStackFrame(void *aPC, void *aClosure)
 {
   FILE *stream = (FILE*)aClosure;
   nsCodeAddressDetails details;
   char buf[1024];
 
   NS_DescribeCodeAddress(aPC, &details);
   NS_FormatCodeAddressDetails(aPC, &details, buf, sizeof(buf));
-  fprintf(stream, buf);
+  fputs(buf, stream);
 }
 
 }
 
 NS_COM void
 nsTraceRefcntImpl::WalkTheStack(FILE* aStream)
 {
   NS_StackWalk(PrintStackFrame, 2, aStream);