From ebbcc86eb8eb43b0c5da8f1ce90e0f600e9ca19b Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 8 Jun 2008 04:34:52 +0200 Subject: [PATCH] Trivial code simplifications. --- ChangeLog | 6 ++++++ lib/copy-acl.c | 19 ++++--------------- lib/set-mode-acl.c | 3 ++- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index a98bf7c9b..e373fd004 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2008-06-07 Bruno Haible + * 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 + * lib/copy-acl.c (qcopy_acl): Make the #if branches independent. * lib/set-mode-acl.c (qset_acl): Choose better local variable names. diff --git a/lib/copy-acl.c b/lib/copy-acl.c index d0817265c..f0c8dc2ce 100644 --- a/lib/copy-acl.c +++ b/lib/copy-acl.c @@ -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); diff --git a/lib/set-mode-acl.c b/lib/set-mode-acl.c index f1f7a1ca0..ae146c32b 100644 --- a/lib/set-mode-acl.c +++ b/lib/set-mode-acl.c @@ -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) -- 2.11.0