[newlib-cygwin] Rename index variable from i to idx.

Corinna Vinschen corinna@sourceware.org
Thu Apr 2 11:49:00 GMT 2015


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=94bb7da6b4a7b8400ede75e000c9df1f15588b22

commit 94bb7da6b4a7b8400ede75e000c9df1f15588b22
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Thu Apr 2 13:48:55 2015 +0200

    Rename index variable from i to idx.
    
    	* sec_acl.cc (CYG_ACE_ISBITS_TO_WIN): Fix typo.
    	(get_posix_access): Rename index variable from i to idx.  Define only
    	once at top level.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/ChangeLog  |  6 ++++++
 winsup/cygwin/sec_acl.cc | 32 ++++++++++++++++----------------
 2 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index b2472a8..9871b96 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,11 @@
 2015-04-02  Corinna Vinschen  <corinna@vinschen.de>
 
+	* sec_acl.cc (CYG_ACE_ISBITS_TO_WIN): Fix typo.
+	(get_posix_access): Rename index variable from i to idx.  Define only
+	once at top level.
+
+2015-04-02  Corinna Vinschen  <corinna@vinschen.de>
+
 	* security.cc (add_access_allowed_ace): Drop unused parameter "offset".
 	Accommodate throughout.
 	(add_access_denied_ace): Ditto.
diff --git a/winsup/cygwin/sec_acl.cc b/winsup/cygwin/sec_acl.cc
index c2470b3..749ba94 100644
--- a/winsup/cygwin/sec_acl.cc
+++ b/winsup/cygwin/sec_acl.cc
@@ -69,7 +69,7 @@ details. */
 #define CYG_ACE_ISBITS_TO_POSIX(val)	\
 				(((val) & 0x007) << 9)
 #define CYG_ACE_ISBITS_TO_WIN(val) \
-				(((val) & (S_ISVTX | S_ISUID | S_IS_GID)) >> 9)
+				(((val) & (S_ISVTX | S_ISUID | S_ISGID)) >> 9)
 
 #define CYG_ACE_MASK_X		0x008		/* 0x001 <-> 0x008 */
 #define CYG_ACE_MASK_W		0x010		/* 0x002 <-> 0x010 */
@@ -449,7 +449,7 @@ get_posix_access (PSECURITY_DESCRIPTOR psd,
   mode_t attr = 0;
   aclent_t *lacl = NULL;
   cygpsid ace_sid;
-  int pos, type, id;
+  int pos, type, id, idx;
 
   bool new_style = false;
   bool saw_user_obj = false;
@@ -536,9 +536,9 @@ get_posix_access (PSECURITY_DESCRIPTOR psd,
       goto out;
     }
 
-  for (int i = 0; i < acl->AceCount; ++i)
+  for (idx = 0; idx < acl->AceCount; ++idx)
     {
-      if (!NT_SUCCESS (RtlGetAce (acl, i, (PVOID *) &ace)))
+      if (!NT_SUCCESS (RtlGetAce (acl, idx, (PVOID *) &ace)))
 	continue;
 
       ace_sid = (PSID) &ace->SidStart;
@@ -745,13 +745,13 @@ get_posix_access (PSECURITY_DESCRIPTOR psd,
 
   /* For old-style or non-Cygwin ACLs, check for merging permissions. */
   if (!new_style)
-    for (int i = 0; i < pos; ++i)
+    for (idx = 0; idx < pos; ++idx)
       {
 	/* Current user?  If the user entry has a deny ACE, don't check. */
-	if (lacl[i].a_id == myself->uid
-	    && lacl[i].a_type & (USER_OBJ | USER)
-	    && !(lacl[i].a_type & ACL_DEFAULT)
-	    && !(lacl[i].a_perm & DENY_RWX))
+	if (lacl[idx].a_id == myself->uid
+	    && lacl[idx].a_type & (USER_OBJ | USER)
+	    && !(lacl[idx].a_type & ACL_DEFAULT)
+	    && !(lacl[idx].a_perm & DENY_RWX))
 	  {
 	    int gpos;
 	    gid_t grps[NGROUPS_MAX];
@@ -766,14 +766,14 @@ get_posix_access (PSECURITY_DESCRIPTOR psd,
 		  || (gpos = searchace (lacl, MAX_ACL_ENTRIES, GROUP, grps[g]))
 		     >= 0)
 		grp_perm |= lacl[gpos].a_perm & S_IRWXO;
-	    lacl[i].a_perm |= grp_perm;
+	    lacl[idx].a_perm |= grp_perm;
 	  }
 	/* For all groups, if everyone has more permissions, add everyone
 	   perms to group perms.  Skip groups with deny ACE. */
-	else if (lacl[i].a_id & (GROUP_OBJ | GROUP)
-		 && !(lacl[i].a_type & ACL_DEFAULT)
-		 && !(lacl[i].a_perm & DENY_RWX))
-	  lacl[i].a_perm |= lacl[2].a_perm & S_IRWXO;
+	else if (lacl[idx].a_id & (GROUP_OBJ | GROUP)
+		 && !(lacl[idx].a_type & ACL_DEFAULT)
+		 && !(lacl[idx].a_perm & DENY_RWX))
+	  lacl[idx].a_perm |= lacl[2].a_perm & S_IRWXO;
       }
   /* Construct POSIX permission bits.  Fortunately we know exactly where
      to fetch the affecting bits from, at least as long as the array
@@ -797,8 +797,8 @@ out:
 	  return -1;
 	}
       memcpy (aclbufp, lacl, pos * sizeof (aclent_t));
-      for (int i = 0; i < pos; ++i)
-	aclbufp[i].a_perm &= S_IRWXO;
+      for (idx = 0; idx < pos; ++idx)
+	aclbufp[idx].a_perm &= S_IRWXO;
       aclsort32 (pos, 0, aclbufp);
     }
   return pos;



More information about the Cygwin-cvs mailing list