PR 6493
authorIan Lance Taylor <ian@airs.com>
Fri, 9 May 2008 14:13:06 +0000 (14:13 +0000)
committerIan Lance Taylor <ian@airs.com>
Fri, 9 May 2008 14:13:06 +0000 (14:13 +0000)
* gold.cc (gold_nomem): Use return value of write.

gold/ChangeLog
gold/gold.cc

index 9a95d327fdd4997df5893b27ab1c8b3ab6e6bd80..7ded23176d0654a6900e47b2a1a02b70b338a076 100644 (file)
@@ -1,3 +1,8 @@
+2008-05-09  Ian Lance Taylor  <iant@google.com>
+
+       PR 6493
+       * gold.cc (gold_nomem): Use return value of write.
+
 2008-05-08  Ian Lance Taylor  <iant@google.com>
 
        * symtab.c (Symbol::init_base_output_data): Add version
index 396a5a940f3744feb63b45e9e64ac38a4be085ad..267c4d11682d380a7be6737b37acd16f00ca4b46 100644 (file)
@@ -60,9 +60,18 @@ gold_nomem()
   // We are out of memory, so try hard to print a reasonable message.
   // Note that we don't try to translate this message, since the
   // translation process itself will require memory.
-  write(2, program_name, strlen(program_name));
-  const char* const s = ": out of memory\n";
-  write(2, s, strlen(s));
+
+  // LEN only exists to avoid a pointless warning when write is
+  // declared with warn_use_result, as when compiling with
+  // -D_USE_FORTIFY on GNU/Linux.  Casting to void does not appear to
+  // work, at least not with gcc 4.3.0.
+
+  ssize_t len = write(2, program_name, strlen(program_name));
+  if (len >= 0)
+    {
+      const char* const s = ": out of memory\n";
+      len = write(2, s, strlen(s));
+    }
   gold_exit(false);
 }
 
This page took 0.028616 seconds and 4 git commands to generate.