aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2008-05-09 14:13:06 +0000
committerIan Lance Taylor <ian@airs.com>2008-05-09 14:13:06 +0000
commit55ba0940d96a0da92a3ab3234a5fb7ae0b445b5f (patch)
tree9ca90fbe5be741ec63fa19d85805210877e57e70
parent0ead4f8d3f902fa7b56cb52642486d799e5fba56 (diff)
downloadgdb-55ba0940d96a0da92a3ab3234a5fb7ae0b445b5f.zip
gdb-55ba0940d96a0da92a3ab3234a5fb7ae0b445b5f.tar.gz
gdb-55ba0940d96a0da92a3ab3234a5fb7ae0b445b5f.tar.bz2
PR 6493
* gold.cc (gold_nomem): Use return value of write.
-rw-r--r--gold/ChangeLog5
-rw-r--r--gold/gold.cc15
2 files changed, 17 insertions, 3 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog
index 9a95d32..7ded231 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -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
diff --git a/gold/gold.cc b/gold/gold.cc
index 396a5a9..267c4d1 100644
--- a/gold/gold.cc
+++ b/gold/gold.cc
@@ -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);
}