changeset 39882:423dd81f09f4

fcntl: Make it possible to namespace the defined symbol, part 2. * lib/fcntl.c: Fix syntax errors in last commit.
author Bruno Haible <bruno@clisp.org>
date Fri, 05 Oct 2018 01:16:56 +0200
parents 2ea5ba48211b
children cd549182ef0e
files lib/fcntl.c
diffstat 1 files changed, 17 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/lib/fcntl.c	Fri Oct 05 00:27:25 2018 +0200
+++ b/lib/fcntl.c	Fri Oct 05 01:16:56 2018 +0200
@@ -460,22 +460,22 @@
       /* Haiku alpha 2 loses fd flags on original.  */
       int flags = fcntl (fd, F_GETFD);
       if (flags < 0)
-        {
-          result = -1;
-          break;
-        }
-      result = fcntl (fd, action, target);
-      if (0 <= result && fcntl (fd, F_SETFD, flags) == -1)
+        result = -1;
+      else
         {
-          int saved_errno = errno;
-          close (result);
-          result = -1;
-          errno = saved_errno;
+          result = fcntl (fd, F_DUPFD, target);
+          if (0 <= result && fcntl (fd, F_SETFD, flags) == -1)
+            {
+              int saved_errno = errno;
+              close (result);
+              result = -1;
+              errno = saved_errno;
+            }
+# if REPLACE_FCHDIR
+          if (0 <= result)
+            result = _gl_register_dup (fd, result);
+# endif
         }
-# if REPLACE_FCHDIR
-      if (0 <= result)
-        result = _gl_register_dup (fd, result);
-# endif
     }
 #else
   result = fcntl (fd, F_DUPFD, target);
@@ -506,7 +506,7 @@
   static int have_dupfd_cloexec = GNULIB_defined_F_DUPFD_CLOEXEC ? -1 : 0;
   if (0 <= have_dupfd_cloexec)
     {
-      result = fcntl (fd, action, target);
+      result = fcntl (fd, F_DUPFD_CLOEXEC, target);
       if (0 <= result || errno != EINVAL)
         {
           have_dupfd_cloexec = 1;
@@ -518,9 +518,8 @@
       else
         {
           result = rpl_fcntl_DUPFD (fd, target);
-          if (result < 0)
-            break;
-          have_dupfd_cloexec = -1;
+          if (result >= 0)
+            have_dupfd_cloexec = -1;
         }
     }
   else