Bug 1347672 - Unbreak build on FreeBSD with GCC 6 or later. r?glandium draft
authorJan Beich <jbeich@FreeBSD.org>
Wed, 15 Mar 2017 20:54:21 +0000
changeset 556432 7729e2f2c317eb6e99b0fc5caa4650d2cd4fac7c
parent 556431 730db8b60c1e4443af45f94b6411b81c889e0759
child 622886 fac2aa2543927be27efd465328d1bdea4505c678
push id52545
push userbmo:jbeich@FreeBSD.org
push dateWed, 05 Apr 2017 21:08:46 +0000
reviewersglandium
bugs1347672
milestone55.0a1
Bug 1347672 - Unbreak build on FreeBSD with GCC 6 or later. r?glandium MozReview-Commit-ID: 67PaHOzlRUs
memory/mozalloc/mozalloc_abort.cpp
memory/mozalloc/throw_gcc.h
--- a/memory/mozalloc/mozalloc_abort.cpp
+++ b/memory/mozalloc/mozalloc_abort.cpp
@@ -16,24 +16,26 @@
 #endif
 #include <stdio.h>
 
 #include "mozilla/Assertions.h"
 
 void
 mozalloc_abort(const char* const msg)
 {
+    char error[128];
+    snprintf(error, sizeof(error)-1, "fatal: STL threw system_error: %s", msg);
 #ifndef ANDROID
-    fputs(msg, stderr);
+    fputs(error, stderr);
     fputs("\n", stderr);
 #else
-    __android_log_print(ANDROID_LOG_ERROR, "Gecko", "mozalloc_abort: %s", msg);
+    __android_log_print(ANDROID_LOG_ERROR, "Gecko", "mozalloc_abort: %s", error);
 #endif
 #ifdef MOZ_WIDGET_ANDROID
-    abortThroughJava(msg);
+    abortThroughJava(error);
 #endif
     MOZ_CRASH();
 }
 
 #ifdef MOZ_WIDGET_ANDROID
 template <size_t N>
 void fillAbortMessage(char (&msg)[N], uintptr_t retAddress) {
     /*
--- a/memory/mozalloc/throw_gcc.h
+++ b/memory/mozalloc/throw_gcc.h
@@ -5,17 +5,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_throw_gcc_h
 #define mozilla_throw_gcc_h
 
 #include "mozilla/Attributes.h"
 
-#include <stdio.h>              // snprintf
 #include <string.h>             // strerror
 
 // For gcc, we define these inline to abort so that we're absolutely
 // certain that (i) no exceptions are thrown from Gecko; (ii) these
 // errors are always terminal and caught by breakpad.
 
 #include "mozilla/mozalloc_abort.h"
 
@@ -127,19 +126,16 @@ MOZ_THROW_NORETURN MOZ_EXPORT MOZ_ALWAYS
 __throw_ios_failure(const char* msg)
 {
     mozalloc_abort(msg);
 }
 
 MOZ_THROW_NORETURN MOZ_EXPORT MOZ_ALWAYS_INLINE void
 __throw_system_error(int err)
 {
-    char error[128];
-    snprintf(error, sizeof(error)-1,
-             "fatal: STL threw system_error: %s (%d)", strerror(err), err);
-    mozalloc_abort(error);
+    mozalloc_abort(strerror(err));
 }
 
 } // namespace std
 
 #undef MOZ_THROW_NORETURN
 
 #endif  // mozilla_throw_gcc_h