Trivial code simplifications.
authorBruno Haible <bruno@clisp.org>
Sun, 8 Jun 2008 02:34:52 +0000 (04:34 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 8 Jun 2008 02:34:52 +0000 (04:34 +0200)
ChangeLog
lib/copy-acl.c
lib/set-mode-acl.c

index a98bf7c9bc30f3e6acccecb1a917313eb9141bda..e373fd0046cd489bffb70ec27cc1e7fbb11255f2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-06-07  Bruno Haible  <bruno@clisp.org>
+
+       * lib/set-mode-acl.c (chmod_or_fchmod): Document return value
+       precisely.
+       * lib/copy-acl.c (qcopy_acl): Trivial code simplifications.
+
 2008-06-07  Bruno Haible  <bruno@clisp.org>
 
        * lib/copy-acl.c (qcopy_acl): Make the #if branches independent.
index d0817265c3e09d5e9651d5049fc74ce38cb7a952..f0c8dc2ce38e2b2561ce9b173a996c9c8b9619e6 100644 (file)
@@ -66,29 +66,18 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name,
     {
       int saved_errno = errno;
 
-      if (ACL_NOT_WELL_SUPPORTED (errno))
+      if (ACL_NOT_WELL_SUPPORTED (errno) && !acl_access_nontrivial (acl))
         {
-         int nontrivial = acl_access_nontrivial (acl);
-
          acl_free (acl);
-
-         if (!nontrivial)
-           {
-             if (chmod_or_fchmod (dst_name, dest_desc, mode) != 0)
-               saved_errno = errno;
-             else
-               return 0;
-           }
-         else
-           chmod_or_fchmod (dst_name, dest_desc, mode);
+         return chmod_or_fchmod (dst_name, dest_desc, mode);
        }
       else
        {
          acl_free (acl);
          chmod_or_fchmod (dst_name, dest_desc, mode);
+         errno = saved_errno;
+         return -1;
        }
-      errno = saved_errno;
-      return -1;
     }
   else
     acl_free (acl);
index f1f7a1ca06ed45c1c573bf6114243db2f3ebc3d0..ae146c32b362eb18dc8af25e808d70f768ba34c9 100644 (file)
@@ -26,7 +26,8 @@
 /* If DESC is a valid file descriptor use fchmod to change the
    file's mode to MODE on systems that have fchown. On systems
    that don't have fchown and if DESC is invalid, use chown on
-   NAME instead.  */
+   NAME instead.
+   Return 0 if successful.  Return -1 and set errno upon failure.  */
 
 int
 chmod_or_fchmod (const char *name, int desc, mode_t mode)