Bug 754198 - Warning treated as error in jemalloc.c. Build busted. [r=jlebar,bsmedberg]
☠☠ backed out by 04f69f8d207c ☠ ☠
authorFabrice Desré <fabrice@mozilla.com>
Fri, 11 May 2012 12:34:24 -0700
changeset 93820 c209fea124e106511d7e3297827c2764b1b866d3
parent 93819 e8a8cbac81db81f3d773f5de77c5a796bf05b559
child 93821 90aa22311c7c7fb7756a1711ff9e2afe75fb494b
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersjlebar, bsmedberg
bugs754198
milestone15.0a1
Bug 754198 - Warning treated as error in jemalloc.c. Build busted. [r=jlebar,bsmedberg]
config/elf-dynstr-gc.c
dom/plugins/test/testplugin/nptest.cpp
memory/jemalloc/jemalloc.c
modules/libmar/tool/mar.c
netwerk/test/TestProtocols.cpp
testing/mochitest/ssltunnel/ssltunnel.cpp
toolkit/xre/glxtest.cpp
widget/gtk2/nsAppShell.cpp
xpcom/base/MapsMemoryReporter.cpp
xpcom/base/nsCycleCollector.cpp
xpcom/threads/nsThread.cpp
--- a/config/elf-dynstr-gc.c
+++ b/config/elf-dynstr-gc.c
@@ -1229,16 +1229,16 @@ main(int argc, char *argv[])
   /* 3. Do the real compacting. */
 
   memmove(mapping + hole_index,
 	  mapping + hole_index + hole_len,
 	  size - (hole_index + hole_len));
   
   munmap(mapping, size);
 
-  ftruncate(fd, size - hole_len);
+  int result = ftruncate(fd, size - hole_len);
   close(fd);
 
-  return 0;
+  return result == -1 ? 1 : 0;
 }
 
 
 
--- a/dom/plugins/test/testplugin/nptest.cpp
+++ b/dom/plugins/test/testplugin/nptest.cpp
@@ -1349,22 +1349,22 @@ NPP_StreamAsFile(NPP instance, NPStream*
     instanceData->err << "NPP_StreamAsFile called";
   }
 
   if (!fname)
     return;
 
   FILE *file = fopen(fname, "rb");
   if (file) {
-    fseek(file, 0, SEEK_END);
+    ssize_t unused = fseek(file, 0, SEEK_END);
     size = ftell(file);
     instanceData->fileBuf = malloc((int32_t)size + 1);
     char* buf = reinterpret_cast<char *>(instanceData->fileBuf);
-    fseek(file, 0, SEEK_SET);
-    fread(instanceData->fileBuf, 1, size, file);
+    unused = fseek(file, 0, SEEK_SET);
+    unused = fread(instanceData->fileBuf, 1, size, file);
     fclose(file);
     buf[size] = '\0';
     instanceData->fileBufSize = (int32_t)size;
   }
   else {
     printf("Unable to open file\n");
     instanceData->err << "Unable to open file " << fname;
   }
--- a/memory/jemalloc/jemalloc.c
+++ b/memory/jemalloc/jemalloc.c
@@ -1522,20 +1522,21 @@ umax2s(uintmax_t x, unsigned base, char 
 }
 
 static void
 wrtmessage(const char *p1, const char *p2, const char *p3, const char *p4)
 {
 #if defined(MOZ_MEMORY) && !defined(MOZ_MEMORY_WINDOWS)
 #define	_write	write
 #endif
-	_write(STDERR_FILENO, p1, (unsigned int) strlen(p1));
-	_write(STDERR_FILENO, p2, (unsigned int) strlen(p2));
-	_write(STDERR_FILENO, p3, (unsigned int) strlen(p3));
-	_write(STDERR_FILENO, p4, (unsigned int) strlen(p4));
+	int res;
+	res = _write(STDERR_FILENO, p1, (unsigned int) strlen(p1));
+	res = _write(STDERR_FILENO, p2, (unsigned int) strlen(p2));
+	res = _write(STDERR_FILENO, p3, (unsigned int) strlen(p3));
+	res = _write(STDERR_FILENO, p4, (unsigned int) strlen(p4));
 }
 
 #define _malloc_message malloc_message
 
 void	(*_malloc_message)(const char *p1, const char *p2, const char *p3,
 	    const char *p4) = wrtmessage;
 
 #ifdef MALLOC_DEBUG
--- a/modules/libmar/tool/mar.c
+++ b/modules/libmar/tool/mar.c
@@ -121,17 +121,19 @@ int main(int argc, char **argv) {
     if (argv[1][0] == '-' && (argv[1][1] == 'c' || 
         argv[1][1] == 't' || argv[1][1] == 'x' || 
         argv[1][1] == 'v' || argv[1][1] == 's' ||
         argv[1][1] == 'i' || argv[1][1] == 'T' ||
         argv[1][1] == 'r')) {
       break;
     /* -C workingdirectory */
     } else if (argv[1][0] == '-' && argv[1][1] == 'C') {
-      chdir(argv[2]);
+      int res = chdir(argv[2]);
+      if (res == -1)
+        return -1;
       argv += 2;
       argc -= 2;
     } 
 #if defined(XP_WIN) && !defined(MAR_NSS) && !defined(NO_SIGN_VERIFY)
     /* -D DERFilePath */
     else if (argv[1][0] == '-' && argv[1][1] == 'D') {
       DERFilePath = argv[2];
       argv += 2;
--- a/netwerk/test/TestProtocols.cpp
+++ b/netwerk/test/TestProtocols.cpp
@@ -83,16 +83,20 @@
 #include "nsChannelProperties.h"
 
 #include "nsISimpleEnumerator.h"
 #include "nsStringAPI.h"
 #include "nsNetUtil.h"
 #include "prlog.h"
 #include "prtime.h"
 
+#include "mozilla/unused.h"
+
+using mozilla::unused;
+
 namespace TestProtocols {
 
 #if defined(PR_LOGGING)
 //
 // set NSPR_LOG_MODULES=Test:5
 //
 static PRLogModuleInfo *gTestLog = nsnull;
 #endif
@@ -333,17 +337,17 @@ TestAuthPrompt::PromptUsernameAndPasswor
     printf("* --------------------------------------------------------------------------- *\n");
     printf("* Authentication Required [%s]\n", text.get());
     printf("* --------------------------------------------------------------------------- *\n");
 
     char buf[256];
     int n;
 
     printf("Enter username: ");
-    fgets(buf, sizeof(buf), stdin);
+    unused << fgets(buf, sizeof(buf), stdin);
     n = strlen(buf);
     buf[n-1] = '\0'; // trim trailing newline
     *user = NS_StringCloneData(NS_ConvertUTF8toUTF16(buf));
 
     const char *p;
 #if defined(XP_UNIX) && !defined(ANDROID)
     p = getpass("Enter password: ");
 #else
@@ -819,17 +823,17 @@ nsresult LoadURLsFromFile(char *aFileNam
     return NS_OK;
 }
 
 
 nsresult LoadURLFromConsole()
 {
     char buffer[1024];
     printf("Enter URL (\"q\" to start): ");
-    scanf("%s", buffer);
+    unused << scanf("%s", buffer);
     if (buffer[0]=='q') 
         gAskUserForInput = false;
     else
         StartLoadingURL(buffer);
     return NS_OK;
 }
 
 } // namespace
--- a/testing/mochitest/ssltunnel/ssltunnel.cpp
+++ b/testing/mochitest/ssltunnel/ssltunnel.cpp
@@ -61,19 +61,21 @@
 #include "prtypes.h"
 #include "nsAlgorithm.h"
 #include "nss.h"
 #include "pk11func.h"
 #include "key.h"
 #include "keyt.h"
 #include "ssl.h"
 #include "plhash.h"
+#include "mozilla/unused.h"
 
 using std::string;
 using std::vector;
+using mozilla::unused;
 
 #define IS_DELIM(m, c)          ((m)[(c) >> 3] & (1 << ((c) & 7)))
 #define SET_DELIM(m, c)         ((m)[(c) >> 3] |= (1 << ((c) & 7)))
 #define DELIM_TABLE_SIZE        32
 
 // You can set the level of logging by env var SSLTUNNEL_LOG_LEVEL=n, where n
 // is 0 through 3.  The default is 1, INFO level logging.
 enum LogLevel {
@@ -1259,17 +1261,17 @@ int parseConfigFile(const char* filePath
   FILE* f = fopen(filePath, "r");
   if (!f)
     return 1;
 
   char buffer[1024], *b = buffer;
   while (!feof(f))
   {
     char c;
-    fscanf(f, "%c", &c);
+    unused << fscanf(f, "%c", &c);
     switch (c)
     {
     case '\n':
       *b++ = 0;
       if (processConfigLine(buffer))
         return 1;
       b = buffer;
     case '\r':
--- a/toolkit/xre/glxtest.cpp
+++ b/toolkit/xre/glxtest.cpp
@@ -60,16 +60,20 @@
 #include "nscore.h"
 
 #include <fcntl.h>
 
 #ifdef __SUNPRO_CC
 #include <stdio.h>
 #endif
 
+#include "mozilla/unused.h"
+
+using mozilla::unused;
+
 namespace mozilla {
 namespace widget {
 // the read end of the pipe, which will be used by GfxInfo
 extern int glxtest_pipe;
 // the PID of the glxtest process, to pass to waitpid()
 extern pid_t glxtest_pid;
 }
 }
@@ -85,32 +89,32 @@ static func_ptr_type cast(void *ptr)
 {
   return reinterpret_cast<func_ptr_type>(
            reinterpret_cast<size_t>(ptr)
          );
 }
 
 static void fatal_error(const char *str)
 {
-  write(write_end_of_the_pipe, str, strlen(str));
-  write(write_end_of_the_pipe, "\n", 1);
+  unused << write(write_end_of_the_pipe, str, strlen(str));
+  unused << write(write_end_of_the_pipe, "\n", 1);
   exit(EXIT_FAILURE);
 }
 
 static int
 x_error_handler(Display *, XErrorEvent *ev)
 {
   enum { bufsize = 1024 };
   char buf[bufsize];
   int length = snprintf(buf, bufsize,
                         "X error occurred in GLX probe, error_code=%d, request_code=%d, minor_code=%d\n",
                         ev->error_code,
                         ev->request_code,
                         ev->minor_code);
-  write(write_end_of_the_pipe, buf, length);
+  unused << write(write_end_of_the_pipe, buf, length);
   exit(EXIT_FAILURE);
   return 0;
 }
 
 static void glxtest()
 {
   // we want to redirect to /dev/null stdout, stderr, and while we're at it,
   // any PR logging file descriptors. To that effect, we redirect all positive
@@ -248,17 +252,17 @@ static void glxtest()
   glXMakeCurrent(dpy, None, NULL); // must release the GL context before destroying it
   glXDestroyContext(dpy, context);
   glXDestroyPixmap(dpy, glxpixmap);
   XFreePixmap(dpy, pixmap);
   XCloseDisplay(dpy);
   dlclose(libgl);
 
   ///// Finally write data to the pipe
-  write(write_end_of_the_pipe, buf, length);
+  unused << write(write_end_of_the_pipe, buf, length);
 }
 
 /** \returns true in the child glxtest process, false in the parent process */
 bool fire_glxtest_process()
 {
   int pfd[2];
   if (pipe(pfd) == -1) {
       perror("pipe");
--- a/widget/gtk2/nsAppShell.cpp
+++ b/widget/gtk2/nsAppShell.cpp
@@ -41,16 +41,19 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <gdk/gdk.h>
 #include "nsAppShell.h"
 #include "nsWindow.h"
 #include "prlog.h"
 #include "prenv.h"
 #include "mozilla/HangMonitor.h"
+#include "mozilla/unused.h"
+
+using mozilla::unused;
 
 #define NOTIFY_TOKEN 0xFA
 
 #ifdef PR_LOGGING
 PRLogModuleInfo *gWidgetLog = nsnull;
 PRLogModuleInfo *gWidgetFocusLog = nsnull;
 PRLogModuleInfo *gWidgetDragLog = nsnull;
 PRLogModuleInfo *gWidgetDrawLog = nsnull;
@@ -71,17 +74,17 @@ PollWrapper(GPollFD *ufds, guint nfsd, g
 /*static*/ gboolean
 nsAppShell::EventProcessorCallback(GIOChannel *source, 
                                    GIOCondition condition,
                                    gpointer data)
 {
     nsAppShell *self = static_cast<nsAppShell *>(data);
 
     unsigned char c;
-    read(self->mPipeFDs[0], &c, 1);
+    ssize_t ununsed = read(self->mPipeFDs[0], &c, 1);
     NS_ASSERTION(c == (unsigned char) NOTIFY_TOKEN, "wrong token");
 
     self->NativeEventCallback();
     return TRUE;
 }
 
 nsAppShell::~nsAppShell()
 {
@@ -148,16 +151,16 @@ failed:
     mPipeFDs[0] = mPipeFDs[1] = 0;
     return NS_ERROR_FAILURE;
 }
 
 void
 nsAppShell::ScheduleNativeEventCallback()
 {
     unsigned char buf[] = { NOTIFY_TOKEN };
-    write(mPipeFDs[1], buf, 1);
+    unused << write(mPipeFDs[1], buf, 1);
 }
 
 bool
 nsAppShell::ProcessNextNativeEvent(bool mayWait)
 {
     return g_main_context_iteration(NULL, mayWait);
 }
--- a/xpcom/base/MapsMemoryReporter.cpp
+++ b/xpcom/base/MapsMemoryReporter.cpp
@@ -41,16 +41,19 @@
 
 #include "mozilla/MapsMemoryReporter.h"
 #include "nsIMemoryReporter.h"
 #include "nsString.h"
 #include "nsCOMPtr.h"
 #include "nsTHashtable.h"
 #include "nsHashKeys.h"
 #include <stdio.h>
+#include "mozilla/unused.h"
+
+using mozilla::unused;
 
 namespace mozilla {
 namespace MapsMemoryReporter {
 
 #if !defined(XP_LINUX)
 #error "This doesn't have a prayer of working if we're not on Linux."
 #endif
 
@@ -334,17 +337,17 @@ MapsReporter::ParseMapping(
   // with or without a path, but we don't want to look to a new line for the
   // path.  Thus we have %u%1024[^\n] at the end of the pattern.  This will
   // capture into the path some leading whitespace, which we'll later trim off.
   int numRead = fscanf(aFile, "%llx-%llx %4s %llx %2s:%2s %u%1024[^\n]",
                        &addrStart, &addrEnd, perms, &offset, devMajor,
                        devMinor, &inode, path);
 
   // Eat up any whitespace at the end of this line, including the newline.
-  fscanf(aFile, " ");
+  unused << fscanf(aFile, " ");
 
   // We might or might not have a path, but the rest of the arguments should be
   // there.
   if (numRead != argCount && numRead != argCount - 1) {
     return NS_ERROR_FAILURE;
   }
 
   nsCAutoString name, description;
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -1361,17 +1361,19 @@ public:
         }
         char basename[MAXPATHLEN] = {'\0'};
         char ccname[MAXPATHLEN] = {'\0'};
 #ifdef XP_WIN
         // On Windows, tmpnam returns useless stuff, such as "\\s164.".
         // Therefore we need to call the APIs directly.
         GetTempPathA(mozilla::ArrayLength(basename), basename);
 #else
-        tmpnam(basename);
+        char *tmp = tmpnam(basename);
+        if (!tmp)
+            return NS_ERROR_FAILURE;
         char *lastSlash = strrchr(basename, XPCOM_FILE_PATH_SEPARATOR[0]);
         if (lastSlash) {
             *lastSlash = '\0';
         }
 #endif
 
         ++gLogCounter;
 
--- a/xpcom/threads/nsThread.cpp
+++ b/xpcom/threads/nsThread.cpp
@@ -42,16 +42,17 @@
 #include "nsIClassInfoImpl.h"
 #include "nsIProgrammingLanguage.h"
 #include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "prlog.h"
 #include "nsIObserverService.h"
 #include "mozilla/HangMonitor.h"
 #include "mozilla/Services.h"
+#include "mozilla/unused.h"
 
 #define HAVE_UALARM _BSD_SOURCE || (_XOPEN_SOURCE >= 500 ||                 \
                       _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) &&           \
                       !(_POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700)
 
 #if defined(XP_UNIX) && !defined(ANDROID) && !defined(DEBUG) && HAVE_UALARM \
   && defined(_GNU_SOURCE)
 # define MOZ_CANARY
@@ -67,16 +68,17 @@
 #include "nsTimerImpl.h"
 #include "nsStackWalk.h"
 #endif
 #ifdef NS_FUNCTION_TIMER
 #include "nsCRT.h"
 #endif
 
 using namespace mozilla;
+using mozilla::unused;
 
 #ifdef PR_LOGGING
 static PRLogModuleInfo *sLog = PR_NewLogModule("nsThread");
 #endif
 #define LOG(args) PR_LOG(sLog, PR_LOG_DEBUG, args)
 
 NS_DECL_CI_INTERFACE_GETTER(nsThread)
 
@@ -563,17 +565,17 @@ public:
 
 int Canary::sOutputFD = -1;
 
 void canary_alarm_handler (int signum)
 {
   void *array[30];
   const char msg[29] = "event took too long to run:\n";
   // use write to be safe in the signal handler
-  write(Canary::sOutputFD, msg, sizeof(msg)); 
+  unused << write(Canary::sOutputFD, msg, sizeof(msg)); 
   backtrace_symbols_fd(array, backtrace(array, 30), Canary::sOutputFD);
 }
 
 #endif
 
 #define NOTIFY_EVENT_OBSERVERS(func_, params_)                                 \
   PR_BEGIN_MACRO                                                               \
     if (!mEventObservers.IsEmpty()) {                                          \