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

nekral-guest at alioth.debian.org nekral-guest at alioth.debian.org
Mon Jun 9 18:11:21 UTC 2008


Author: nekral-guest
Date: 2008-06-09 18:11:20 +0000 (Mon, 09 Jun 2008)
New Revision: 2072

Modified:
   upstream/trunk/ChangeLog
   upstream/trunk/libmisc/console.c
Log:
	* libmisc/console.c: Change is_listed() prototype to return a bool.
	The default parameter should also be a bool.
	* libmisc/console.c: Add brackets and parenthesis.
	* libmisc/console.c: Avoid assignments in comparisons.
	* libmisc/console.c: Change console() prototype to return a bool.


Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog	2008-05-26 09:39:29 UTC (rev 2071)
+++ upstream/trunk/ChangeLog	2008-06-09 18:11:20 UTC (rev 2072)
@@ -1,3 +1,11 @@
+2008-06-09  Nicolas François  <nicolas.francois at centraliens.net>
+
+	* libmisc/console.c: Change is_listed() prototype to return a bool.
+	The default parameter should also be a bool.
+	* libmisc/console.c: Add brackets and parenthesis.
+	* libmisc/console.c: Avoid assignments in comparisons.
+	* libmisc/console.c: Change console() prototype to return a bool.
+
 2008-05-26  Nicolas François  <nicolas.francois at centraliens.net>
 
 	* lib/sgetspent.c: Add brackets and parenthesis.

Modified: upstream/trunk/libmisc/console.c
===================================================================
--- upstream/trunk/libmisc/console.c	2008-05-26 09:39:29 UTC (rev 2071)
+++ upstream/trunk/libmisc/console.c	2008-06-09 18:11:20 UTC (rev 2072)
@@ -40,14 +40,14 @@
 #ident "$Id$"
 
 /* local function prototypes */
-static int is_listed (const char *cfgin, const char *tty, int def);
+static bool is_listed (const char *cfgin, const char *tty, bool def);
 
 /*
  * This is now rather generic function which decides if "tty" is listed
  * under "cfgin" in config (directly or indirectly). Fallback to default if
  * something is bad.
  */
-static int is_listed (const char *cfgin, const char *tty, int def)
+static bool is_listed (const char *cfgin, const char *tty, bool def)
 {
 	FILE *fp;
 	char buf[200], *cons, *s;
@@ -57,8 +57,10 @@
 	 * fallback to default.
 	 */
 
-	if ((cons = getdef_str (cfgin)) == NULL)
+	cons = getdef_str (cfgin);
+	if (NULL == cons) {
 		return def;
+	}
 
 	/*
 	 * If this isn't a filename, then it is a ":" delimited list of
@@ -68,12 +70,13 @@
 	if (*cons != '/') {
 		cons = strcpy (buf, cons);
 		while ((s = strtok (cons, ":")) != NULL) {
-			if (strcmp (s, tty) == 0)
-				return 1;
+			if (strcmp (s, tty) == 0) {
+				return true;
+			}
 
 			cons = NULL;
 		}
-		return 0;
+		return false;
 	}
 
 	/*
@@ -81,8 +84,10 @@
 	 * console - otherwise root will never be allowed to login.
 	 */
 
-	if ((fp = fopen (cons, "r")) == NULL)
+	fp = fopen (cons, "r");
+	if (NULL == fp) {
 		return def;
+	}
 
 	/*
 	 * See if this tty is listed in the console file.
@@ -92,7 +97,7 @@
 		buf[strlen (buf) - 1] = '\0';
 		if (strcmp (buf, tty) == 0) {
 			(void) fclose (fp);
-			return 1;
+			return true;
 		}
 	}
 
@@ -101,7 +106,7 @@
 	 */
 
 	(void) fclose (fp);
-	return 0;
+	return false;
 }
 
 /*
@@ -114,7 +119,8 @@
  * that would allow an unauthorized root login.
  */
 
-int console (const char *tty)
+bool console (const char *tty)
 {
-	return is_listed ("CONSOLE", tty, 1);
+	return is_listed ("CONSOLE", tty, true);
 }
+




More information about the Pkg-shadow-commits mailing list