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

Nicolas FRANÇOIS nekral-guest at alioth.debian.org
Thu Apr 23 17:45:42 UTC 2009


Author: nekral-guest
Date: 2009-04-23 17:45:42 +0000 (Thu, 23 Apr 2009)
New Revision: 2778

Modified:
   upstream/trunk/ChangeLog
   upstream/trunk/libmisc/setupenv.c
Log:
	* libmisc/setupenv.c: Avoid assignments in comparisons.
	* libmisc/setupenv.c: Added brackets and parenthesis.
	* libmisc/setupenv.c: Ignore the return value of fclose (file
	opened read-only)
	* libmisc/setupenv.c: Ignore the return value of puts().
	* libmisc/setupenv.c:Avoid implicit conversion of pointers to
	booleans.


Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog	2009-04-23 17:43:27 UTC (rev 2777)
+++ upstream/trunk/ChangeLog	2009-04-23 17:45:42 UTC (rev 2778)
@@ -1,5 +1,15 @@
 2009-04-22  Nicolas François  <nicolas.francois at centraliens.net>
 
+	* libmisc/setupenv.c: Avoid assignments in comparisons.
+	* libmisc/setupenv.c: Added brackets and parenthesis.
+	* libmisc/setupenv.c: Ignore the return value of fclose (file
+	opened read-only)
+	* libmisc/setupenv.c: Ignore the return value of puts().
+	* libmisc/setupenv.c:Avoid implicit conversion of pointers to
+	booleans.
+
+2009-04-22  Nicolas François  <nicolas.francois at centraliens.net>
+
 	* libmisc/find_new_gid.c, libmisc/find_new_uid.c,
 	libmisc/isexpired.c, src/groupadd.c, lib/pwauth.h, lib/groupmem.c,
 	lib/shadowmem.c, lib/pwmem.c, lib/prototypes.h: Added splint

Modified: upstream/trunk/libmisc/setupenv.c
===================================================================
--- upstream/trunk/libmisc/setupenv.c	2009-04-23 17:43:27 UTC (rev 2777)
+++ upstream/trunk/libmisc/setupenv.c	2009-04-23 17:45:42 UTC (rev 2778)
@@ -2,7 +2,7 @@
  * Copyright (c) 1989 - 1994, Julianne Frances Haugh
  * Copyright (c) 1996 - 2000, Marek Michałkiewicz
  * Copyright (c) 2001 - 2006, Tomasz Kłoczko
- * Copyright (c) 2007 - 2008, Nicolas François
+ * Copyright (c) 2007 - 2009, Nicolas François
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -76,21 +76,26 @@
 
 		cp = buf;
 		/* ignore whitespace and comments */
-		while (*cp && isspace (*cp))
+		while (('\0' != *cp) && isspace (*cp)) {
 			cp++;
-		if (*cp == '\0' || *cp == '#')
+		}
+		if (('\0' == *cp) || ('#' == *cp)) {
 			continue;
+		}
 		/*
 		 * ignore lines which don't follow the name=value format
 		 * (for example, the "export NAME" shell commands)
 		 */
 		name = cp;
-		while (*cp && !isspace (*cp) && *cp != '=')
+		while (('\0' != *cp) && !isspace (*cp) && ('=' != *cp)) {
 			cp++;
-		if (*cp != '=')
+		}
+		if ('=' != *cp) {
 			continue;
+		}
 		/* NUL-terminate the name */
-		*cp++ = '\0';
+		*cp = '\0';
+		cp++;
 		val = cp;
 #if 0				/* XXX untested, and needs rewrite with fewer goto's :-) */
 /*
@@ -174,7 +179,7 @@
 		 */
 		addenv (name, val);
 	}
-	fclose (fp);
+	(void) fclose (fp);
 }
 #endif				/* USE_PAM */
 
@@ -213,9 +218,9 @@
 				 "unable to cd to `%s' for user `%s'\n",
 				 info->pw_dir, info->pw_name));
 			closelog ();
-			exit (1);
+			exit (EXIT_FAILURE);
 		}
-		puts (_("No directory, logging in with HOME=/"));
+		(void) puts (_("No directory, logging in with HOME=/"));
 		info->pw_dir = temp_pw_dir;
 	}
 
@@ -251,7 +256,7 @@
 
 	cp = getdef_str ((info->pw_uid == 0) ? "ENV_SUPATH" : "ENV_PATH");
 
-	if (!cp) {
+	if (NULL == cp) {
 		/* not specified, use a minimal default */
 		addenv ("PATH=/bin:/usr/bin", NULL);
 	} else if (strchr (cp, '=')) {
@@ -269,23 +274,30 @@
 	 */
 
 	if (getdef_bool ("MAIL_CHECK_ENAB")) {
-		if ((cp = getdef_str ("MAIL_DIR")))
+		cp = getdef_str ("MAIL_DIR");
+		if (NULL != cp) {
 			addenv_path ("MAIL", cp, info->pw_name);
-		else if ((cp = getdef_str ("MAIL_FILE")))
-			addenv_path ("MAIL", info->pw_dir, cp);
-		else {
+		} else {
+			cp = getdef_str ("MAIL_FILE");
+			if (NULL != cp) {
+				addenv_path ("MAIL", info->pw_dir, cp);
+			} else {
 #if defined(MAIL_SPOOL_FILE)
-			addenv_path ("MAIL", info->pw_dir, MAIL_SPOOL_FILE);
+				addenv_path ("MAIL", info->pw_dir, MAIL_SPOOL_FILE);
 #elif defined(MAIL_SPOOL_DIR)
-			addenv_path ("MAIL", MAIL_SPOOL_DIR, info->pw_name);
+				addenv_path ("MAIL", MAIL_SPOOL_DIR, info->pw_name);
 #endif
+			}
 		}
 	}
 
 	/*
 	 * Read environment from optional config file.  --marekm
 	 */
-	if ((envf = getdef_str ("ENVIRON_FILE")))
+	envf = getdef_str ("ENVIRON_FILE");
+	if (NULL != envf) {
 		read_env_file (envf);
+	}
 #endif				/* !USE_PAM */
 }
+




More information about the Pkg-shadow-commits mailing list