[Pkg-shadow-commits] r2088 - in upstream/trunk: . src

nekral-guest at alioth.debian.org nekral-guest at alioth.debian.org
Mon Jun 9 20:30:34 UTC 2008


Author: nekral-guest
Date: 2008-06-09 20:30:34 +0000 (Mon, 09 Jun 2008)
New Revision: 2088

Modified:
   upstream/trunk/ChangeLog
   upstream/trunk/src/pwunconv.c
Log:
	* src/pwunconv.c: Use a bool when possible instead of int
	integers.
	* src/pwunconv.c: Add brackets and parenthesis.
	* src/pwunconv.c: Ignore return value of setlocale(),
	bindtextdomain(), and textdomain().
	* src/pwunconv.c: Avoid implicit conversion of pointers / integers
	/ chars to booleans.
	* src/pwunconv.c: Avoid assignments in comparisons.


Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog	2008-06-09 20:17:48 UTC (rev 2087)
+++ upstream/trunk/ChangeLog	2008-06-09 20:30:34 UTC (rev 2088)
@@ -1,5 +1,16 @@
 2008-06-09  Nicolas François  <nicolas.francois at centraliens.net>
 
+	* src/pwunconv.c: Use a bool when possible instead of int
+	integers.
+	* src/pwunconv.c: Add brackets and parenthesis.
+	* src/pwunconv.c: Ignore return value of setlocale(),
+	bindtextdomain(), and textdomain().
+	* src/pwunconv.c: Avoid implicit conversion of pointers / integers
+	/ chars to booleans.
+	* src/pwunconv.c: Avoid assignments in comparisons.
+
+2008-06-09  Nicolas François  <nicolas.francois at centraliens.net>
+
 	* src/usermod.c: Use a bool when possible instead of int integers.
 	* src/usermod.c: Add brackets and parenthesis.
 	* src/usermod.c: Avoid implicit conversion of pointers / integers

Modified: upstream/trunk/src/pwunconv.c
===================================================================
--- upstream/trunk/src/pwunconv.c	2008-06-09 20:17:48 UTC (rev 2087)
+++ upstream/trunk/src/pwunconv.c	2008-06-09 20:30:34 UTC (rev 2088)
@@ -47,17 +47,20 @@
 /*
  * Global variables
  */
-static int shadow_locked = 0, passwd_locked = 0;
+static bool shadow_locked = false;
+static bool passwd_locked = false;
 
 /* local function prototypes */
 static void fail_exit (int);
 
 static void fail_exit (int status)
 {
-	if (shadow_locked)
+	if (shadow_locked) {
 		spw_unlock ();
-	if (passwd_locked)
+	}
+	if (passwd_locked) {
 		pw_unlock ();
+	}
 	exit (status);
 }
 
@@ -70,46 +73,50 @@
 
 	char *Prog = argv[0];
 
-	setlocale (LC_ALL, "");
-	bindtextdomain (PACKAGE, LOCALEDIR);
-	textdomain (PACKAGE);
+	(void) setlocale (LC_ALL, "");
+	(void) bindtextdomain (PACKAGE, LOCALEDIR);
+	(void) textdomain (PACKAGE);
 
-	if (!spw_file_present ())
+	if (!spw_file_present ()) {
 		/* shadow not installed, do nothing */
 		exit (0);
+	}
 
-	if (!pw_lock ()) {
+	if (pw_lock () == 0) {
 		fprintf (stderr, _("%s: can't lock passwd file\n"), Prog);
 		fail_exit (5);
 	}
-	passwd_locked++;
-	if (!pw_open (O_RDWR)) {
+	passwd_locked = true;
+	if (pw_open (O_RDWR) == 0) {
 		fprintf (stderr, _("%s: can't open passwd file\n"), Prog);
 		fail_exit (1);
 	}
 
-	if (!spw_lock ()) {
+	if (spw_lock () == 0) {
 		fprintf (stderr, _("%s: can't lock shadow file\n"), Prog);
 		fail_exit (5);
 	}
-	shadow_locked++;
-	if (!spw_open (O_RDWR)) {
+	shadow_locked = true;
+	if (spw_open (O_RDWR) == 0) {
 		fprintf (stderr, _("%s: can't open shadow file\n"), Prog);
 		fail_exit (1);
 	}
 
 	pw_rewind ();
-	while ((pw = pw_next ())) {
-		if (!(spwd = spw_locate (pw->pw_name)))
+	while ((pw = pw_next ()) != NULL) {
+		spwd = spw_locate (pw->pw_name);
+		if (NULL == spwd) {
 			continue;
+		}
 
 		pwent = *pw;
 
 		/*
 		 * Update password if non-shadow is "x".
 		 */
-		if (strcmp (pw->pw_passwd, SHADOW_PASSWD_STRING) == 0)
+		if (strcmp (pw->pw_passwd, SHADOW_PASSWD_STRING) == 0) {
 			pwent.pw_passwd = spwd->sp_pwdp;
+		}
 
 		/*
 		 * Password aging works differently in the two different
@@ -121,7 +128,7 @@
 		 * put into the new file. Otherwise, the days are converted
 		 * to weeks and so on.
 		 */
-		if (!pw_update (&pwent)) {
+		if (pw_update (&pwent) == 0) {
 			fprintf (stderr,
 				 _("%s: can't update entry for user %s\n"),
 				 Prog, pwent.pw_name);
@@ -129,13 +136,13 @@
 		}
 	}
 
-	if (!spw_close ()) {
+	if (spw_close () == 0) {
 		fprintf (stderr,
 			 _("%s: can't update shadow password file\n"), Prog);
 		fail_exit (3);
 	}
 
-	if (!pw_close ()) {
+	if (pw_close () == 0) {
 		fprintf (stderr, _("%s: can't update password file\n"), Prog);
 		fail_exit (3);
 	}
@@ -153,3 +160,4 @@
 
 	return 0;
 }
+




More information about the Pkg-shadow-commits mailing list