* output.cc (posix_fallocate): Return 0 on success, errno on failure.
authorCary Coutant <ccoutant@google.com>
Tue, 18 Oct 2011 21:36:29 +0000 (21:36 +0000)
committerCary Coutant <ccoutant@google.com>
Tue, 18 Oct 2011 21:36:29 +0000 (21:36 +0000)
(Output_file::map_no_anonymous): Check for non-zero
return code from posix_fallocate.

gold/ChangeLog
gold/output.cc

index 18339967649c5c030070e7b468a8a210828fde4c..61ad6cdd33f3589e87f998f28590d46b9d12d908 100644 (file)
@@ -1,3 +1,9 @@
+2011-10-18  Cary Coutant  <ccoutant@google.com>
+
+       * output.cc (posix_fallocate): Return 0 on success, errno on failure.
+       (Output_file::map_no_anonymous): Check for non-zero
+       return code from posix_fallocate.
+
 2011-10-17  Cary Coutant  <ccoutant@google.com>
 
        PR gold/13245
index 7b272e854721354c10cc0087077fd68a0272a1bb..7633c730807353cdc507840217c6dee68d39ef24 100644 (file)
@@ -119,7 +119,9 @@ extern "C" void *gold_mremap(void *, size_t, size_t, int);
 static int
 posix_fallocate(int o, off_t offset, off_t len)
 {
-  return ftruncate(o, offset + len);
+  if (ftruncate(o, offset + len) < 0)
+    return errno;
+  return 0;
 }
 #endif // !defined(HAVE_POSIX_FALLOCATE)
 
@@ -5075,8 +5077,12 @@ Output_file::map_no_anonymous(bool writable)
   // output file will wind up incomplete, but we will have already
   // exited.  The alternative to fallocate would be to use fdatasync,
   // but that would be a more significant performance hit.
-  if (writable && ::posix_fallocate(o, 0, this->file_size_) < 0)
-    gold_fatal(_("%s: %s"), this->name_, strerror(errno));
+  if (writable)
+    {
+      int err = ::posix_fallocate(o, 0, this->file_size_);
+      if (err != 0)
+       gold_fatal(_("%s: %s"), this->name_, strerror(err));
+    }
 
   // Map the file into memory.
   int prot = PROT_READ;
This page took 0.033628 seconds and 4 git commands to generate.