[Pkg-shadow-commits] r2766 - in upstream/trunk: . libmisc

Nicolas FRANÇOIS nekral-guest at alioth.debian.org
Thu Apr 23 11:16:38 UTC 2009


Author: nekral-guest
Date: 2009-04-23 11:16:38 +0000 (Thu, 23 Apr 2009)
New Revision: 2766

Modified:
   upstream/trunk/ChangeLog
   upstream/trunk/libmisc/find_new_gid.c
   upstream/trunk/libmisc/find_new_uid.c
Log:
	* libmisc/find_new_gid.c: Use booleans instead of char fo
	used_gids.
	* libmisc/find_new_gid.c: Use getdef_ulong and cast to git_t to
	get GID values.
	* libmisc/find_new_gid.c: Use UL as a prefix for ulong values.
	* libmisc/find_new_uid.c: Likewise.


Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog	2009-04-23 11:14:56 UTC (rev 2765)
+++ upstream/trunk/ChangeLog	2009-04-23 11:16:38 UTC (rev 2766)
@@ -1,5 +1,14 @@
 2009-04-22  Nicolas François  <nicolas.francois at centraliens.net>
 
+	* libmisc/find_new_gid.c: Use booleans instead of char fo
+	used_gids.
+	* libmisc/find_new_gid.c: Use getdef_ulong and cast to git_t to
+	get GID values.
+	* libmisc/find_new_gid.c: Use UL as a prefix for ulong values.
+	* libmisc/find_new_uid.c: Likewise.
+
+2009-04-22  Nicolas François  <nicolas.francois at centraliens.net>
+
 	* libmisc/yesno.c: Ignore the return value of puts.
 
 2009-04-22  Nicolas François  <nicolas.francois at centraliens.net>

Modified: upstream/trunk/libmisc/find_new_gid.c
===================================================================
--- upstream/trunk/libmisc/find_new_gid.c	2009-04-23 11:14:56 UTC (rev 2765)
+++ upstream/trunk/libmisc/find_new_gid.c	2009-04-23 11:16:38 UTC (rev 2766)
@@ -51,20 +51,20 @@
 {
 	const struct group *grp;
 	gid_t gid_min, gid_max, group_id;
-	char *used_gids;
+	bool *used_gids;
 
 	assert (gid != NULL);
 
 	if (!sys_group) {
-		gid_min = getdef_ulong ("GID_MIN", 1000L);
-		gid_max = getdef_ulong ("GID_MAX", 60000L);
+		gid_min = (gid_t) getdef_ulong ("GID_MIN", 1000UL);
+		gid_max = (gid_t) getdef_ulong ("GID_MAX", 60000UL);
 	} else {
-		gid_min = getdef_ulong ("SYS_GID_MIN", 1L);
-		gid_max = getdef_ulong ("GID_MIN", 1000L) - 1;
-		gid_max = getdef_ulong ("SYS_GID_MAX", (unsigned long) gid_max);
+		gid_min = (gid_t) getdef_ulong ("SYS_GID_MIN", 1UL);
+		gid_max = (gid_t) getdef_ulong ("GID_MIN", 1000UL) - 1;
+		gid_max = (gid_t) getdef_ulong ("SYS_GID_MAX", (unsigned long) gid_max);
 	}
-	used_gids = alloca (sizeof (char) * gid_max +1);
-	memset (used_gids, 0, sizeof (char) * gid_max + 1);
+	used_gids = alloca (sizeof (bool) * (gid_max +1));
+	memset (used_gids, false, sizeof (bool) * (gid_max + 1));
 
 	if (   (NULL != preferred_gid)
 	    && (*preferred_gid >= gid_min)
@@ -95,7 +95,7 @@
 		}
 		/* create index of used GIDs */
 		if (grp->gr_gid <= gid_max) {
-			used_gids[grp->gr_gid] = 1;
+			used_gids[grp->gr_gid] = true;
 		}
 	}
 	endgrent ();
@@ -106,14 +106,14 @@
 		}
 		/* create index of used GIDs */
 		if (grp->gr_gid <= gid_max) {
-			used_gids[grp->gr_gid] = 1;
+			used_gids[grp->gr_gid] = true;
 		}
 	}
 
 	/* find free system account in reverse order */
 	if (sys_group) {
 		for (group_id = gid_max; group_id >= gid_min; group_id--) {
-			if (0 == used_gids[group_id]) {
+			if (false == used_gids[group_id]) {
 				break;
 			}
 		}
@@ -134,7 +134,7 @@
 	 */
 	if (group_id == gid_max + 1) {
 		for (group_id = gid_min; group_id < gid_max; group_id++) {
-			if (0 == used_gids[group_id]) {
+			if (false == used_gids[group_id]) {
 				break;
 			}
 		}

Modified: upstream/trunk/libmisc/find_new_uid.c
===================================================================
--- upstream/trunk/libmisc/find_new_uid.c	2009-04-23 11:14:56 UTC (rev 2765)
+++ upstream/trunk/libmisc/find_new_uid.c	2009-04-23 11:16:38 UTC (rev 2766)
@@ -51,20 +51,20 @@
 {
 	const struct passwd *pwd;
 	uid_t uid_min, uid_max, user_id;
-	char *used_uids;
+	bool *used_uids;
 
 	assert (uid != NULL);
 
 	if (!sys_user) {
-		uid_min = getdef_ulong ("UID_MIN", 1000L);
-		uid_max = getdef_ulong ("UID_MAX", 60000L);
+		uid_min = (uid_t) getdef_ulong ("UID_MIN", 1000UL);
+		uid_max = (uid_t) getdef_ulong ("UID_MAX", 60000UL);
 	} else {
-		uid_min = getdef_ulong ("SYS_UID_MIN", 1L);
-		uid_max = getdef_ulong ("UID_MIN", 1000L) - 1;
-		uid_max = getdef_ulong ("SYS_UID_MAX", (unsigned long) uid_max);
+		uid_min = (uid_t) getdef_ulong ("SYS_UID_MIN", 1UL);
+		uid_max = (uid_t) getdef_ulong ("UID_MIN", 1000UL) - 1;
+		uid_max = (uid_t) getdef_ulong ("SYS_UID_MAX", (unsigned long) uid_max);
 	}
-	used_uids = alloca (sizeof (char) * uid_max +1);
-	memset (used_uids, 0, sizeof (char) * uid_max + 1);
+	used_uids = alloca (sizeof (bool) * (uid_max +1));
+	memset (used_uids, false, sizeof (bool) * (uid_max + 1));
 
 	if (   (NULL != preferred_uid)
 	    && (*preferred_uid >= uid_min)
@@ -96,7 +96,7 @@
 		}
 		/* create index of used UIDs */
 		if (pwd->pw_uid <= uid_max) {
-			used_uids[pwd->pw_uid] = 1;
+			used_uids[pwd->pw_uid] = true;
 		}
 	}
 	endpwent ();
@@ -107,14 +107,14 @@
 		}
 		/* create index of used UIDs */
 		if (pwd->pw_uid <= uid_max) {
-			used_uids[pwd->pw_uid] = 1;
+			used_uids[pwd->pw_uid] = true;
 		}
 	}
 
 	/* find free system account in reverse order */
 	if (sys_user) {
 		for (user_id = uid_max; user_id >= uid_min; user_id--) {
-			if (0 == used_uids[user_id]) {
+			if (false == used_uids[user_id]) {
 				break;
 			}
 		}
@@ -135,7 +135,7 @@
 	 */
 	if (user_id == uid_max + 1) {
 		for (user_id = uid_min; user_id < uid_max; user_id++) {
-			if (0 == used_uids[user_id]) {
+			if (false == used_uids[user_id]) {
 				break;
 			}
 		}




More information about the Pkg-shadow-commits mailing list