public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [gold commit] Fix use of system fallocate
@ 2021-03-19 23:21 Cary Coutant
  0 siblings, 0 replies; only message in thread
From: Cary Coutant @ 2021-03-19 23:21 UTC (permalink / raw)
  To: Binutils

I've committed the following patch to fix the improper error handling
when calling system fallocate when posix_fallocate is not available.

-cary


2021-03-19  Holger Berger  <holger.berger@googlemail.com>

gold/
        PR gold/26541
        * output.cc (gold_fallocate): Use errno when calling system fallocate.

diff --git a/gold/output.cc b/gold/output.cc
index b7505ffd72c..afdba06753e 100644
--- a/gold/output.cc
+++ b/gold/output.cc
@@ -141,12 +141,14 @@ gold_fallocate(int o, off_t offset, off_t len)

 #ifdef HAVE_FALLOCATE
   {
+    errno = 0;
     int err = ::fallocate(o, 0, offset, len);
-    if (err != EINVAL && err != ENOSYS && err != EOPNOTSUPP)
-      return err;
+    if (err < 0 && errno != EINVAL && errno != ENOSYS && errno != EOPNOTSUPP)
+      return errno;
   }
 #endif // defined(HAVE_FALLOCATE)

+  errno = 0;
   if (::ftruncate(o, offset + len) < 0)
     return errno;
   return 0;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-03-19 23:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-19 23:21 [gold commit] Fix use of system fallocate Cary Coutant

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).