[Pkg-shadow-commits] r2171 - in upstream/trunk: . lib

nekral-guest at alioth.debian.org nekral-guest at alioth.debian.org
Fri Jun 13 21:45:47 UTC 2008


Author: nekral-guest
Date: 2008-06-13 21:45:47 +0000 (Fri, 13 Jun 2008)
New Revision: 2171

Modified:
   upstream/trunk/ChangeLog
   upstream/trunk/lib/gshadow.c
Log:
	* lib/gshadow.c: Use a bool when possible instead of int integers.
	* lib/gshadow.c: Remove __setsgNIS() -never used).
	* lib/gshadow.c: Avoid multi-statements lines.
	* lib/gshadow.c: Avoid assignments in comparisons.
	* lib/gshadow.c: ptr[nelem] is a string. Initialize it to NULL
	instead of '\0'.
	* lib/gshadow.c: Add brackets and parenthesis.
	* lib/gshadow.c: The size argument of strncpy is a size_t and the
	size argument of fgets is an int.


Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog	2008-06-13 21:39:24 UTC (rev 2170)
+++ upstream/trunk/ChangeLog	2008-06-13 21:45:47 UTC (rev 2171)
@@ -1,5 +1,17 @@
 2008-06-13  Nicolas François  <nicolas.francois at centraliens.net>
 
+	* lib/gshadow.c: Use a bool when possible instead of int integers.
+	* lib/gshadow.c: Remove __setsgNIS() -never used).
+	* lib/gshadow.c: Avoid multi-statements lines.
+	* lib/gshadow.c: Avoid assignments in comparisons.
+	* lib/gshadow.c: ptr[nelem] is a string. Initialize it to NULL
+	instead of '\0'.
+	* lib/gshadow.c: Add brackets and parenthesis.
+	* lib/gshadow.c: The size argument of strncpy is a size_t and the
+	size argument of fgets is an int.
+
+2008-06-13  Nicolas François  <nicolas.francois at centraliens.net>
+
 	* lib/groupio.c: Add brackets.
 	* lib/groupio.c: Make sure malloc receives a size_t.
 	* lib/groupio.c: Avoid multi-statements lines.

Modified: upstream/trunk/lib/gshadow.c
===================================================================
--- upstream/trunk/lib/gshadow.c	2008-06-13 21:39:24 UTC (rev 2170)
+++ upstream/trunk/lib/gshadow.c	2008-06-13 21:45:47 UTC (rev 2171)
@@ -52,7 +52,7 @@
 
 #ifdef	USE_NIS
 static bool nis_used;
-static int nis_ignore;
+static bool nis_ignore;
 static enum { native, start, middle, native2 } nis_state;
 static bool nis_bound;
 static char *nis_domain;
@@ -65,21 +65,7 @@
 #endif
 
 #ifdef	USE_NIS
-
 /*
- * __setsgNIS - turn on or off NIS searches
- */
-
-void __setsgNIS (int flag)
-{
-	nis_ignore = !flag;
-
-	if (nis_ignore) {
-		nis_used = false;
-	}
-}
-
-/*
  * bind_nis - bind to NIS server
  */
 
@@ -101,16 +87,21 @@
 	while (s != NULL && *s != '\0') {
 		size = (nelem + 1) * sizeof (ptr);
 		if ((ptr = realloc (*list, size)) != NULL) {
-			ptr[nelem++] = s;
+			ptr[nelem] = s;
+			nelem++;
 			*list = ptr;
 			*nlist = nelem;
-			if ((s = strchr (s, ',')))
-				*s++ = '\0';
+			s = strchr (s, ',');
+			if (NULL != s) {
+				*s = '\0';
+				s++;
+			}
 		}
 	}
 	size = (nelem + 1) * sizeof (ptr);
-	if ((ptr = realloc (*list, size)) != NULL) {
-		ptr[nelem] = '\0';
+	ptr = realloc (*list, size);
+	if (NULL != ptr) {
+		ptr[nelem] = NULL;
 		*list = ptr;
 	}
 	return ptr;
@@ -143,7 +134,7 @@
 	char *cp;
 	int i;
 
-	strncpy (sgrbuf, string, (int) sizeof sgrbuf - 1);
+	strncpy (sgrbuf, string, sizeof sgrbuf - 1);
 	sgrbuf[sizeof sgrbuf - 1] = '\0';
 
 	cp = strrchr (sgrbuf, '\n');
@@ -215,9 +206,9 @@
 	}
 
 #ifdef	USE_NIS
-	while (fgetsx (buf, sizeof buf, fp) != (char *) 0)
+	while (fgetsx (buf, (int) sizeof buf, fp) != (char *) 0)
 #else
-	if (fgetsx (buf, sizeof buf, fp) != (char *) 0)
+	if (fgetsx (buf, (int) sizeof buf, fp) != (char *) 0)
 #endif
 	{
 		cp = strchr (buf, '\n');
@@ -225,7 +216,7 @@
 			*cp = '\0';
 		}
 #ifdef	USE_NIS
-		if ((0 != nis_ignore) && IS_NISCHAR (buf[0])) {
+		if (nis_ignore && IS_NISCHAR (buf[0])) {
 			continue;
 		}
 #endif
@@ -241,7 +232,7 @@
 struct sgrp *getsgent (void)
 {
 #ifdef	USE_NIS
-	int nis_1_group = 0;
+	bool nis_1_group = false;
 	struct sgrp *val;
 	char buf[BUFSIZ];
 #endif
@@ -275,7 +266,7 @@
 
 		if (IS_NISCHAR (val->sg_name[0])) {
 			if ('\0' != val->sg_name[1]) {
-				nis_1_group = 1;
+				nis_1_group = true;
 			} else {
 				nis_state = start;
 			}
@@ -286,16 +277,18 @@
 		 * use a NIS map, it must be a regular local group.
 		 */
 
-		if (nis_1_group == 0 && nis_state != start)
+		if (!nis_1_group && (nis_state != start)) {
 			return val;
+		}
 
 		/*
 		 * If this is an escape to use an NIS map, switch over to
 		 * that bunch of code.
 		 */
 
-		if (nis_state == start)
+		if (nis_state == start) {
 			goto again;
+		}
 
 		/*
 		 * NEEDSWORK.  Here we substitute pieces-parts of this entry.
@@ -385,7 +378,7 @@
 #endif
 #ifdef	USE_NIS
 	if (nis_used) {
-		nis_ignore++;
+		nis_ignore = true;
 		nis_disabled = true;
 	}
 #endif
@@ -395,7 +388,7 @@
 		}
 	}
 #ifdef	USE_NIS
-	nis_ignore--;
+	nis_ignore = false;
 #endif
 	return sgrp;
 }
@@ -466,13 +459,15 @@
 
 	for (i = 0; NULL != sgrp->sg_mem[i]; i++) {
 		if (i > 0) {
-			*cp++ = ',';
+			*cp = ',';
+			cp++;
 		}
 
 		strcpy (cp, sgrp->sg_mem[i]);
 		cp += strlen (cp);
 	}
-	*cp++ = '\n';
+	*cp = '\n';
+	cp++;
 	*cp = '\0';
 
 	/*




More information about the Pkg-shadow-commits mailing list