Still about POSIX-draft like ACLs. Now that the ACL triviality test has been moved into a function 'acl_access_nontrivial', the code that uses it can be simplified: coalesce two 'if' branches together. Then exploit the fact that chmod_or_fchmod has already the right return value convention.
Committed, but please review nevertheless. 2008-06-07 Bruno Haible <[EMAIL PROTECTED]> * lib/set-mode-acl.c (chmod_or_fchmod): Document return value precisely. * lib/copy-acl.c (qcopy_acl): Trivial code simplifications. *** lib/set-mode-acl.c.orig 2008-06-08 04:28:49.000000000 +0200 --- lib/set-mode-acl.c 2008-06-08 04:28:41.000000000 +0200 *************** *** 26,32 **** /* 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. */ int chmod_or_fchmod (const char *name, int desc, mode_t mode) --- 26,33 ---- /* 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. ! Return 0 if successful. Return -1 and set errno upon failure. */ int chmod_or_fchmod (const char *name, int desc, mode_t mode) *** lib/copy-acl.c.orig 2008-06-08 04:28:49.000000000 +0200 --- lib/copy-acl.c 2008-06-08 04:28:41.000000000 +0200 *************** *** 66,94 **** { int saved_errno = errno; ! if (ACL_NOT_WELL_SUPPORTED (errno)) { - 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); } else { acl_free (acl); chmod_or_fchmod (dst_name, dest_desc, mode); } - errno = saved_errno; - return -1; } else acl_free (acl); --- 66,83 ---- { int saved_errno = errno; ! if (ACL_NOT_WELL_SUPPORTED (errno) && !acl_access_nontrivial (acl)) { acl_free (acl); ! 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; } } else acl_free (acl);